simnet
Class PacketDump

java.lang.Object
  extended byjava.lang.Thread
      extended bysimnet.Application
          extended bysimnet.PacketDump
All Implemented Interfaces:
BPFConsumer, Pluggable, PlugoutListener, java.lang.Runnable, SimnetWindowListener

public class PacketDump
extends Application
implements BPFConsumer, Pluggable

An application that will record specified types of packets to a file.


Field Summary
protected static int count
           
(package private)  java.io.FileOutputStream fos
          The output stream to this Node' s log file
(package private)  BPF inbpf
          The BPF rule used to capture incoming packets
protected static int maxLen
          How much of the data of a TCP/UDP packet to include in the dump (<=0 means all).
(package private)  BPF outbpf
          The BPF rule used to capture outgoing packets
 
Fields inherited from class simnet.Application
appid, appstart, frame, initialized, node, NODE_ID, pid, random, sim, win
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PacketDump()
           
 
Method Summary
 void dump(java.lang.Integer src, java.lang.Integer dest)
          Logs all packets matching the specified source and destination to a log file by initializing appropriate BPF rules and the log file.
 void dump(java.lang.Integer src, java.lang.Integer src_fb, java.lang.Integer dest, java.lang.Integer dest_fb)
           
 void dump(int src, int dest)
          Logs all packets matching the specified source and destination to a log file by initializing appropriate BPF rules and the log file.
 void dump(int src, int src_fb, int dest, int dest_fb)
          new version of dump constructor that uses fixed bits; new rules overwrites old ones.
 void dump(java.lang.String src, java.lang.Integer src_fb, java.lang.String dest, java.lang.Integer dest_fb)
           
 void dump(java.lang.String src, int src_fb, java.lang.String dest, int dest_fb)
           
 void dump(java.lang.String src, java.lang.String dest)
          Logs all packets matching the specified source and destination to a log file by initializing appropriate BPF rules and the log file.
 java.lang.String fix(int num, int len)
          Returns a string representation of num with leading zeros.
static java.lang.String getIPString(int ip)
           
static int getMaxDataLen()
           
static int getNextID()
           
 void inBPF(int bpf_id, IP_Packet ipp)
          Processes incoming IP packets from the previously loaded BPF rule and outputs header information to the log file.
 boolean prePlugout(java.lang.Object replacement)
          If another packet dumper is being plugged in, keep the file open and let the BPF's transfer to our replacement; otherwise, remove the BPF rules and close the file.
static void setMaxDataLen(int i)
           
static void setMaxDataLen(java.lang.Integer i)
           
 void stopdump()
          Stops the logging of all packets by removing the previously loaded BPF rules.
 
Methods inherited from class simnet.Application
closeWindow, customInit, finalize, getTitleString, initialize, plugoutNotification, printout, printout, processWindowCommand, rawOut, run, window
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

count

protected static int count

maxLen

protected static int maxLen
How much of the data of a TCP/UDP packet to include in the dump (<=0 means all).


fos

java.io.FileOutputStream fos
The output stream to this Node' s log file


inbpf

BPF inbpf
The BPF rule used to capture incoming packets


outbpf

BPF outbpf
The BPF rule used to capture outgoing packets

Constructor Detail

PacketDump

public PacketDump()
Method Detail

getNextID

public static int getNextID()

getMaxDataLen

public static int getMaxDataLen()

setMaxDataLen

public static void setMaxDataLen(java.lang.Integer i)

setMaxDataLen

public static void setMaxDataLen(int i)

dump

public void dump(java.lang.Integer src,
                 java.lang.Integer dest)
Logs all packets matching the specified source and destination to a log file by initializing appropriate BPF rules and the log file. Same as dump(int, int). Called direcly from the UserInterface.

Parameters:
src - the packet source
dest - the packet destination

dump

public void dump(java.lang.Integer src,
                 java.lang.Integer src_fb,
                 java.lang.Integer dest,
                 java.lang.Integer dest_fb)

dump

public void dump(java.lang.String src,
                 java.lang.Integer src_fb,
                 java.lang.String dest,
                 java.lang.Integer dest_fb)

dump

public void dump(java.lang.String src,
                 int src_fb,
                 java.lang.String dest,
                 int dest_fb)

dump

public void dump(java.lang.String src,
                 java.lang.String dest)
Logs all packets matching the specified source and destination to a log file by initializing appropriate BPF rules and the log file. Same as dump(int, int). Called direcly from the UserInterface to provide dump command that takes Node names as arguments.

Parameters:
src - the packet source
dest - the packet destination

dump

public void dump(int src,
                 int dest)
Logs all packets matching the specified source and destination to a log file by initializing appropriate BPF rules and the log file.

Parameters:
src - the packet source
dest - the packet destination

dump

public void dump(int src,
                 int src_fb,
                 int dest,
                 int dest_fb)
new version of dump constructor that uses fixed bits; new rules overwrites old ones.


stopdump

public void stopdump()
Stops the logging of all packets by removing the previously loaded BPF rules.


fix

public java.lang.String fix(int num,
                            int len)
Returns a string representation of num with leading zeros.


getIPString

public static java.lang.String getIPString(int ip)

inBPF

public void inBPF(int bpf_id,
                  IP_Packet ipp)
Processes incoming IP packets from the previously loaded BPF rule and outputs header information to the log file.

Specified by:
inBPF in interface BPFConsumer
Parameters:
bpf_id - the ID of the BPF rule that the ip_packet matched
ipp - incoming IP packet

prePlugout

public boolean prePlugout(java.lang.Object replacement)
If another packet dumper is being plugged in, keep the file open and let the BPF's transfer to our replacement; otherwise, remove the BPF rules and close the file.

Specified by:
prePlugout in interface Pluggable
Returns:
if this object can now be removed (was the operation sucessful)