net.clackrouter.component.tcp
Class TCP

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

public class TCP
extends ClackComponent

A class representing a simplified TCP stack on a local host.

This TCP stack can respresent multiple IP addresses, and Transmission Control Blocks (TCBs) for ports on each of those addresses. This component takes care of demultiplexing packets for processing by each TCB, and also performs the TCP checksum. Some portions of TCP behavior are simplified from that of a real TCP stack. For example, sender or receiver side congestion control is not implemented, and reset packets are ignored.


Nested Class Summary
static class TCP.UpdateEvent
          TCP specific class to provide more information to a GUI object about changes to the TCP data.
 
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_INTERNAL_TO_NET
           
static int PORT_NET_OUT
           
static int PORT_UNREACH_OUT
           
static int TYPE_CLIENT
           
static int TYPE_SERVER
           
static int TYPE_UNKNOWN
           
 
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
TCP(Router r, java.lang.String name)
           
 
Method Summary
 void acceptPacket(VNSPacket packet, int port_num)
          Strips the IP header and handles the packet for one of the following three cases: If the port is a simple client-end of a connection, it hands the packet to this TCB.
 void createMapping(TCB tcb)
          method called when a socket is bound to a local address with bind()
 TCB createTCB(java.lang.String name)
          Used to create a Transmission Control Block (TCB) to be associated with a socket.
 ClackView getHierarchicalView()
          Supplies hierarchical view that implements ClackView if ClackComponent.isHierarchical() is true
 boolean isHierarchical()
          Tells whether this component is hierarchical, that is, capable of being zoomed into within a Clack Router.
 void removeTCB(TCB tcb)
          Not currently used, but removes a mapping once a socket no longer exists on a port.
 TCB serverAcceptCall(TCB tcb)
          Method used when the server port identified by this TCB is calling accept()
 void setupClientMapping(TCB tcb)
          Sets the type of this TCB to CLIENT and creates a mapping for later look-ups.
 void setupListenMapping(TCB tcb)
          Sets the type of this TCB to LISTENING and creates a mapping for later look-ups.
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, getLog, getName, getNumPorts, getPacketCountIn, getPacketCountOut, getPendingError, getPort, getPropertiesView, getRouter, getSerializableProperties, getTime, getTypeName, getUniqueCount, getView, handlePullRequest, hasError, initializeProperties, isModifying, 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

TYPE_UNKNOWN

public static int TYPE_UNKNOWN

TYPE_SERVER

public static int TYPE_SERVER

TYPE_CLIENT

public static int TYPE_CLIENT

PORT_IN

public static int PORT_IN

PORT_NET_OUT

public static int PORT_NET_OUT

PORT_UNREACH_OUT

public static int PORT_UNREACH_OUT

PORT_INTERNAL_TO_NET

public static int PORT_INTERNAL_TO_NET

NUM_PORTS

public static int NUM_PORTS
Constructor Detail

TCP

public TCP(Router r,
           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

isHierarchical

public boolean isHierarchical()
Description copied from class: ClackComponent
Tells whether this component is hierarchical, that is, capable of being zoomed into within a Clack Router.

Overrides:
isHierarchical in class ClackComponent
Returns:
default value is false

getHierarchicalView

public ClackView getHierarchicalView()
Description copied from class: ClackComponent
Supplies hierarchical view that implements ClackView if ClackComponent.isHierarchical() is true

Overrides:
getHierarchicalView in class ClackComponent

acceptPacket

public void acceptPacket(VNSPacket packet,
                         int port_num)
Strips the IP header and handles the packet for one of the following three cases:

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

serverAcceptCall

public TCB serverAcceptCall(TCB tcb)
                     throws java.lang.Exception
Method used when the server port identified by this TCB is calling accept()

Throws:
java.lang.Exception

createTCB

public TCB createTCB(java.lang.String name)
Used to create a Transmission Control Block (TCB) to be associated with a socket.

Parameters:
name - a name identifying the TCB and socket.
Returns:
created TCB

createMapping

public void createMapping(TCB tcb)
                   throws java.lang.Exception
method called when a socket is bound to a local address with bind()

Throws:
java.lang.Exception

setupListenMapping

public void setupListenMapping(TCB tcb)
                        throws java.lang.Exception
Sets the type of this TCB to LISTENING and creates a mapping for later look-ups.

Parameters:
tcb -
Throws:
java.lang.Exception

setupClientMapping

public void setupClientMapping(TCB tcb)
Sets the type of this TCB to CLIENT and creates a mapping for later look-ups.

Parameters:
tcb -

removeTCB

public void removeTCB(TCB tcb)
Not currently used, but removes a mapping once a socket no longer exists on a port. TODO: when a socket is destroyed, free the assoicated port.

Parameters:
tcb -