public class Capturer
extends java.lang.Object
implements java.lang.Runnable
Capturer captures all the packets from a given network interface.
These packets are then queued up for the FlowGenerator.
A filter removes local subnet traffic based on the subnet address. | Modifier and Type | Field and Description |
|---|---|
private java.lang.Thread |
capturerThread
Thread used by the class.
|
private org.jnetpcap.PcapIf |
device
Network interface on which we run the capture.
|
private java.util.ArrayList<byte[]> |
IPAddresses
List of IP addresses assigned to the interface used for capture.
|
private boolean |
isStarted
Used to dermine if the thread is already started.
|
private static org.apache.log4j.Logger |
log
Used to log different events.
|
private CapturedPacketsQueue |
myPacketQueue
Queue of captured packets.
|
private org.jnetpcap.Pcap |
pcap
Logical capturing device.
|
private boolean |
stateOK
Used to dermine if the capturer crashed.
|
| Constructor and Description |
|---|
Capturer(org.jnetpcap.PcapIf device,
CapturedPacketsQueue myPacketQueue)
Constructs the class.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getChosenInterface()
Gets string identifier of the chosen interface.
|
boolean |
isAlive()
Checks if
Capturer is alive. |
private boolean |
isLocalIP(byte[] source)
Checks if the provided IP address is assigned to the local network interface.
|
boolean |
isOK()
Tells if the capturer is operating 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 capturerThread
private org.jnetpcap.PcapIf device
private org.jnetpcap.Pcap pcap
private java.util.ArrayList<byte[]> IPAddresses
private CapturedPacketsQueue myPacketQueue
private boolean isStarted
private boolean stateOK
public Capturer(org.jnetpcap.PcapIf device,
CapturedPacketsQueue myPacketQueue)
device - network interface on which we run the capturemyPacketQueue - queue of captured packetspublic void start()
public void stop()
Breakloop breaks the capturing loop after the next packet is captured from the interface.
If the interface is down, no new packets can be captured. It is why we have the second method to force the thread to close.public boolean isAlive()
Capturer 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()
stateOK flag is set to false,
what causes the VBS client to restart. Such situation can take place after the computer is suspended or hibernated.run in interface java.lang.Runnablepublic boolean isOK()
true if the capturer is operating properly, false if it crashedpublic java.lang.String getChosenInterface()
private boolean isLocalIP(byte[] source)
source - the IP address to be checkedtrue if this is a local IP address, false otherwise