net.clackrouter.component.extension
Class Capture

java.lang.Object
  extended by net.clackrouter.component.base.ClackComponent
      extended by net.clackrouter.component.extension.Capture
All Implemented Interfaces:
Alarm

public class Capture
extends ClackComponent

Component that allows the user to capture packet through it to a PCAP file readable by Ethereal or another packet-analyzer.

Depending on the layer of the packets captured, this component will wrap the packet in dummy layers because PCAP expects Ethernet frames.

Ignore the code about JCaptor and JpcapDumper, as it was an early attempt to build in a packet analyzer that we have halted, at least for now


Nested Class Summary
 
Nested classes/interfaces inherited from class net.clackrouter.component.base.ClackComponent
ClackComponent.Waiter
 
Field Summary
static int PORT_IN
           
static int PORT_OUT
           
 
Fields inherited from class net.clackrouter.component.base.ClackComponent
componentCell, m_has_error, m_log, m_name, m_num_ports, m_packetcount_in, m_packetcount_out, m_ports, mListeners, mRouter, pendingError, SIGNAL_ERROR_LEN_MSEC, UNIQUE_COUNT, view
 
Constructor Summary
Capture(Router router, java.lang.String name)
           
 
Method Summary
 void acceptPacket(VNSPacket packet, int port_number)
           Looks at all packets sent through the component, and keeps a copy of the packet if it is supposed to be capturing the packet, then passes the packet on.
 VNSEthernetPacket encapPacket(VNSPacket packet)
          Encapusulates a VNSPacket with fake header layers so that TCPDump can make sense of it.
 java.awt.Color getColor()
          The color this component should be rendered in, assuming a standard component rendering by the ComponentView.ComponentRenderer class.
 javax.swing.JPanel getPropertiesView()
          Method for getting the properties view associated with this component Property views are used to display more detailed information about internal component state.
 boolean isModifying()
          Reports whether this component modifies packets passed through it This value is used by the static checking algorithm used to make sure port connections are valid.
 void saveToFile(java.lang.String filename)
          Writes all packets capture in the last capture sequence to the specified file
protected  void setupPorts(int numPorts)
          Allocates an array of ClackPort objects to be used by this component
 void startCapture()
          Signals that this component should begin capturing packets, but does not write them to file
 void stopCapture()
          Ends capture process
 
Methods inherited from class net.clackrouter.component.base.ClackComponent
createCopy, createInputPullPort, createInputPushPort, createOutputPullPort, createOutputPushPort, error, fireListeners, getComponentCell, getHierarchicalView, getLog, getName, getNumPorts, getPacketCountIn, getPacketCountOut, getPendingError, getPort, getRouter, getSerializableProperties, getTime, getTypeName, getUniqueCount, getView, handlePullRequest, hasError, initializeProperties, isHierarchical, log, notifyAlarm, poll, registerListener, sendOutPort, setAlarm, setComponentCell, setName, setPendingError, setView, showErrorDialog, signalError, try_repaint, unregisterListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT_IN

public static int PORT_IN

PORT_OUT

public static int PORT_OUT
Constructor Detail

Capture

public Capture(Router router,
               java.lang.String name)
Method Detail

startCapture

public void startCapture()
Signals that this component should begin capturing packets, but does not write them to file


stopCapture

public void stopCapture()
Ends capture process


saveToFile

public void saveToFile(java.lang.String filename)
                throws java.lang.Exception
Writes all packets capture in the last capture sequence to the specified file

Throws:
java.lang.Exception

setupPorts

protected void setupPorts(int numPorts)
Description copied from class: ClackComponent
Allocates an array of ClackPort objects to be used by this component

Overrides:
setupPorts in class ClackComponent
Parameters:
numPorts - the number of ports to create

isModifying

public boolean isModifying()
Description copied from class: ClackComponent
Reports whether this component modifies packets passed through it This value is used by the static checking algorithm used to make sure port connections are valid. Sub-classes that do not modify packets should override this method

Overrides:
isModifying in class ClackComponent
Returns:
by default, we assume the component modifies packets

acceptPacket

public void acceptPacket(VNSPacket packet,
                         int port_number)

Looks at all packets sent through the component, and keeps a copy of the packet if it is supposed to be capturing the packet, then passes the packet on.

Overrides:
acceptPacket in class ClackComponent
Parameters:
packet - The pushed packet
port_number - The number of the port that this packet is arriving on

encapPacket

public VNSEthernetPacket encapPacket(VNSPacket packet)
                              throws java.lang.Exception

Encapusulates a VNSPacket with fake header layers so that TCPDump can make sense of it.

Assumes that the provided packet is TCP, UDP, or Ethernet.

Throws:
java.lang.Exception

getPropertiesView

public javax.swing.JPanel getPropertiesView()
Description copied from class: ClackComponent
Method for getting the properties view associated with this component Property views are used to display more detailed information about internal component state. This method creates a default property view, and can be overriden to provide custom properties views

Overrides:
getPropertiesView in class ClackComponent
Returns:
this component's property view

getColor

public java.awt.Color getColor()
Description copied from class: ClackComponent

The color this component should be rendered in, assuming a standard component rendering by the ComponentView.ComponentRenderer class.

Other renderers may ignore this value.

Overrides:
getColor in class ClackComponent
Returns:
the rendering color