org.jnetpcap.winpcap
Class WinPcapSamp

java.lang.Object
  extended by org.jnetpcap.winpcap.WinPcapSamp

public final class WinPcapSamp
extends java.lang.Object

Class peered with native pcap_samp structure. This class can change the capture algorithm used by WinPcap. By changing the values within this specially peered object, before any capture takes place, you can influence the sampling algorithm used during capture.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Field Summary
static int FIRST_AFTER_N_MS
          It defines that we have to return 1 packet every N milliseconds.
static int NO_SAMP
          No sampling has to be done on the current capture.
static int ONE_EVERY_N
          It defines that only 1 out of N packets must be returned to the user.
 
Method Summary
 int getMethod()
          Gets the current method type for capture sampling.
 int getValue()
          This value depends on the sampling method defined.
 void setMethod(int method)
          Sets the current method type for capturing sampling.
 void setValue(int value)
          Sets the value.
 java.lang.String toString()
          Returns the current values of this object as strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_SAMP

public static final int NO_SAMP
No sampling has to be done on the current capture. In this case, no sampling algorithms are applied to the current capture.

See Also:
Constant Field Values

ONE_EVERY_N

public static final int ONE_EVERY_N
It defines that only 1 out of N packets must be returned to the user. In this case, the 'value' field of the 'pcap_samp' structure indicates the number of packets (minus 1) that must be discarded before one packet got accepted. In other words, if 'value = 10', the first packet is returned to the caller, while the following 9 are discarded.

See Also:
Constant Field Values

FIRST_AFTER_N_MS

public static final int FIRST_AFTER_N_MS
It defines that we have to return 1 packet every N milliseconds. In this case, the 'value' field of the 'WinPcapSamp' class indicates the 'waiting time' in milliseconds before one packet got accepted. In other words, if 'value = 10', the first packet is returned to the caller; the next returned one will be the first packet that arrives when 10ms have elapsed.

See Also:
Constant Field Values
Method Detail

getMethod

public int getMethod()
Gets the current method type for capture sampling.

Returns:
the return value specifies the sampling type:
  • 0 - NO_SAMP - No sampling has to be done on the current capture
  • 1 - ONE_EVERY_N - only 1 out of N packets must be returned to the user
  • 2 - FIRST_AFTER_N_MS - return 1 packet every N milliseconds

setMethod

public void setMethod(int method)
Sets the current method type for capturing sampling. The algorithm is changed for the current capture, as long as no packets have been captured or entered any dispatchable loops.

Parameters:
method - sampling type:
  • 0 - NO_SAMP - No sampling has to be done on the current capture
  • 1 - ONE_EVERY_N - only 1 out of N packets must be returned to the user
  • 2 - FIRST_AFTER_N_MS - return 1 packet every N milliseconds

getValue

public int getValue()
This value depends on the sampling method defined.

Returns:
this value depends on the sampling method defined

setValue

public void setValue(int value)
Sets the value. this value depends on the sampling method defined.

Parameters:
value - new value; this value depends on the sampling method defined

toString

public java.lang.String toString()
Returns the current values of this object as strings.

Overrides:
toString in class java.lang.Object