public class PacketCapturer
extends java.lang.Object
implements java.lang.Runnable
PacketCapturer is the primary class of the Packet Capturer module.
When it is instantiated it sets up a Capturer for all Ethernet network interfaces.
Each Capturer runs in its own thread.
It also sets up a queue where all captured packets are stored until they are retrieved by the FlowGenerator.
It is intended to run in its own thread.
| Modifier and Type | Field and Description |
|---|---|
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 java.util.ArrayList<Capturer> |
myCapturers
List of capturers for particular network interfaces.
|
private CapturedPacketsQueue |
myPacketsQueue
Queue of captured packets.
|
private java.lang.Thread |
packetCapturerThread
Thread used by this class.
|
private boolean |
runFlag
Flag used to stop the thread.
|
private java.util.ArrayList<org.jnetpcap.PcapIf> |
supportedDevices
List of interfaces which we support to capture the traffic on.
|
| Constructor and Description |
|---|
PacketCapturer()
Constructs the object.
|
| Modifier and Type | Method and Description |
|---|---|
private boolean |
addedDevices()
Checks if new network interfaces were added to the system.
|
CapturedPacketsQueue |
getCapturedPacketsQueue()
Gets queue of captured packets.
|
private java.util.ArrayList<org.jnetpcap.PcapIf> |
getValidDevices()
Gets list of supported network devices.
|
boolean |
isAlive()
Checks if
PacketCapturer is alive. |
private boolean |
isOK()
Checks if all the capturers are functioning properly.
|
void |
run()
Runs the thread.
|
void |
start()
Starts the thread.
|
void |
stop()
Stops the thread.
|
private static org.apache.log4j.Logger log
private java.lang.Thread packetCapturerThread
private boolean runFlag
private boolean isStarted
private CapturedPacketsQueue myPacketsQueue
private java.util.ArrayList<Capturer> myCapturers
private java.util.ArrayList<org.jnetpcap.PcapIf> supportedDevices
public void start()
public void stop()
public boolean isAlive()
PacketCapturer 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 java.util.ArrayList<org.jnetpcap.PcapIf> getValidDevices()
private boolean addedDevices()
true if new devices were added, false otherwiseprivate boolean isOK()
true if all capturers are functioning properly, false if one or more capturers crashedpublic CapturedPacketsQueue getCapturedPacketsQueue()