net.clackrouter.component.extension
Class TCPMonitor

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

public class TCPMonitor
extends ClackComponent

A class for tracking and analyzing the TCP flows being forwarded by a router.

TODO: This class provides the basic infrastructure for tracking TCP flows and keeping certain stats about the flows. It's property view is meant to give a graphical view of all this data but both have fallen into a state of disrepair and need a little care before they will be usuable again.


Nested Class Summary
 class TCPMonitor.TCPFlow
          Helper class to contain all information about a single TCP flow.
static interface TCPMonitor.TCPFlowListener
          Listener interface for classes wishing to be updated about changes to a TCPMonitor.TCPFlow.
 class TCPMonitor.TimerCallback
           
 
Nested classes/interfaces inherited from class net.clackrouter.component.base.ClackComponent
ClackComponent.Waiter
 
Field Summary
static int NUM_PORTS
           
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
TCPMonitor(Router router, java.lang.String name)
           
 
Method Summary
 void acceptPacket(VNSPacket packet, int port_number)
          Extracts TCP packets from the IP that is being passed through the component and analyzes them.
 java.lang.String createKey(java.net.InetAddress aAddr, int aPort, java.net.InetAddress bAddr, int bPort)
           
 java.util.Hashtable getFlowMap()
          Get map from flow id to TCPFlow objects
 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.
protected  void setupPorts(int numports)
          Allocates an array of ClackPort objects to be used by this component
 
Methods inherited from class net.clackrouter.component.base.ClackComponent
createCopy, createInputPullPort, createInputPushPort, createOutputPullPort, createOutputPushPort, error, fireListeners, getColor, 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

NUM_PORTS

public static int NUM_PORTS
Constructor Detail

TCPMonitor

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

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

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

acceptPacket

public void acceptPacket(VNSPacket packet,
                         int port_number)
Extracts TCP packets from the IP that is being passed through the component and analyzes them.

We identify a flow by a 4-tuple of (host A address, host A port, host B address, host B port). We arbitrarily define host A to be the host with the numerically lower address when the two addresses are compared as integers.

Each flow then has a TCPMonitor.TCPFlow object that is updated each time we see a packet.

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

getFlowMap

public java.util.Hashtable getFlowMap()
Get map from flow id to TCPFlow objects


createKey

public java.lang.String createKey(java.net.InetAddress aAddr,
                                  int aPort,
                                  java.net.InetAddress bAddr,
                                  int bPort)