public class FlowGenerator
extends java.lang.Object
implements java.lang.Runnable
FlowGenerator is responsible for managing flows.
Flow is defined as a group of packets having the same: | Modifier and Type | Field and Description |
|---|---|
private java.util.Hashtable<java.lang.Integer,SocketInfo> |
availableSockets
List of sockets, which are available to be matched to flows.
|
private static long |
DEFAULT_TIMEOUT_THRESHOLD
Default time-out for flows.
|
private java.lang.Thread |
flowGeneratorThread
Thread used by this class.
|
private java.util.LinkedHashSet<Flow> |
flowTimeOutList
List of flows, which will be closed based on time-out, instead of normal closing based on closed matching socket.
|
private boolean |
isStarted
Flag used to determine if the thread is fully started.
|
private static org.apache.log4j.Logger |
log
Used to log different events.
|
private CapturedPacketsQueue |
myCapturedPacketsQueue
Queue of captured packets.
|
private ClosedFlowsQueue |
myClosedFlowsQueue
Queue to store closed flows.
|
private SocketMonitorQueue |
mySocketMonitorQueue
Queue of information about opened or closed sockets.
|
private java.util.Hashtable<java.lang.Integer,Flow> |
openFlowList
List of open flows.
|
private boolean |
runFlag
Flag used to stop the thread.
|
private java.util.LinkedHashSet<SocketInfo> |
socketsToClose
List of sockets which needs to be closed.
|
private long |
timeoutThreshold
Time-out for flows.
|
| Constructor and Description |
|---|
FlowGenerator(CapturedPacketsQueue myCapturedPacketsQueue,
SocketMonitorQueue mySocketMonitorQueue)
Constructs the object.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
closeAllFlows()
Closes all flows.
|
private void |
closeFlow(Flow currentFlow,
long endTimeInUsec)
Closes the flow.
|
private void |
createNewFlow(CapturedPacket newCapturedPacket)
Creates a new
Flow and adds it to the openFlowList. |
private void |
flushTimeoutFlows()
Closes all timed-out flows.
|
ClosedFlowsQueue |
getClosedFlowsQueue()
Gets queue of closed flows.
|
private void |
handleClosedSockets()
Processes information about closed sockets.
|
private void |
handleOpenSockets()
Processes information about newly opened sockets.
|
boolean |
isAlive()
Checks if
FlowGenerator is alive. |
void |
run()
Runs the thread in loop.
|
void |
setTimeoutThreshold(long timeoutThresholdInMillis)
Sets time after which a flow will be timed out.
|
void |
start()
Starts the thread.
|
void |
stop()
Stops the thread.
|
private void |
updateFlow(CapturedPacket newCapturedPacket,
Flow currentFlow)
The
currentFlow is updated with the newCapturedPacket. |
private static org.apache.log4j.Logger log
private java.lang.Thread flowGeneratorThread
private static final long DEFAULT_TIMEOUT_THRESHOLD
private long timeoutThreshold
private CapturedPacketsQueue myCapturedPacketsQueue
private SocketMonitorQueue mySocketMonitorQueue
private java.util.Hashtable<java.lang.Integer,Flow> openFlowList
private java.util.LinkedHashSet<Flow> flowTimeOutList
private java.util.Hashtable<java.lang.Integer,SocketInfo> availableSockets
private java.util.LinkedHashSet<SocketInfo> socketsToClose
private boolean runFlag
private boolean isStarted
private ClosedFlowsQueue myClosedFlowsQueue
public FlowGenerator(CapturedPacketsQueue myCapturedPacketsQueue, SocketMonitorQueue mySocketMonitorQueue)
myCapturedPacketsQueue - queue of captured packetsmySocketMonitorQueue - queue of socket informationpublic void start()
public void stop()
public boolean isAlive()
FlowGenerator is alive. It means that: isStarted equals true).
This condition is used to check if the thread is fully started or if it needs more time to start.true if the thread is fully started and operational, false otherwisepublic void run()
run in interface java.lang.Runnableprivate void handleOpenSockets()
private void handleClosedSockets()
private void createNewFlow(CapturedPacket newCapturedPacket)
Flow and adds it to the openFlowList.
UDP flows are always a subject to timeout, even if the matching socket is still open for other flows.
TCP flows are a subject to timeout if they are not matched to an appropriate socket. newCapturedPacket - the packet that caused the flow to be created, and is added to the Flowprivate void updateFlow(CapturedPacket newCapturedPacket, Flow currentFlow)
currentFlow is updated with the newCapturedPacket.newCapturedPacket - packet that is added to the FlowcurrentFlow - the Flow to be updatedprivate void flushTimeoutFlows()
private void closeAllFlows()
FlowGenerator is closedpublic void setTimeoutThreshold(long timeoutThresholdInMillis)
timeoutThresholdInMillis - the time measured in milisecondsprivate void closeFlow(Flow currentFlow, long endTimeInUsec)
currentFlow - flow which will be closedendTimeInUsec - timestamp of closing the flow measured in microsecondspublic ClosedFlowsQueue getClosedFlowsQueue()