SSF.OS.TCP
Class tcpSession

java.lang.Object
  |
  +--SSF.OS.ProtocolSession
        |
        +--SSF.OS.TCP.tcpSession
All Implemented Interfaces:
com.renesys.raceway.DML.Configurable

public class tcpSession
extends ProtocolSession

This class represents a TCP session of one end of the connection which is identified by source and destination IP address and port number. It keeps all the state information and controls data transfer by using class Send_WndManager and Rcv_WndManager.


Field Summary
static long close_timer_basis
          CLOSE Timer basis, default value 0.5 seconds.
static int CLOSE_WAIT
           
static int CLOSED
           
static int CLOSING
           
 boolean DEBUG
          Option used to switch on/off verbose session debugging output.
static int ESTABLISHED
           
static int FIN_WAIT_1
           
static int FIN_WAIT_2
           
 boolean INFO
          Option used to switch on/off verbose session information output.
 IpHeader ipHdr
          IP header template of this session.
 ProtocolSession ipsess
          Local IP Session in the ProtocolGraph.
static int LAST_ACK
           
static int LISTEN
           
static long maxIdleTime
          maximum FIN_WAIT_2 idle time
static int MSL
          maximum segment lifetime in slow ticks
 tcpSocket mySocket
          For listening server TCP session, it is the reference to master server socket.
 Send_WndManager snd
          Object managing the send queue and processing the received ACKs
static int SYN_RECEIVED
           
static int SYN_SENT
           
 int tcp_state
          TCP connection state variable.
 TCP_Header tcpHdr
          TCP header template of this session.
 tcpSessionMaster tcpServ
          TCP master service that owns this TCP session.
static int TIME_WAIT
           
 
Fields inherited from class SSF.OS.ProtocolSession
name, use
 
Constructor Summary
tcpSession()
          False zero-argument constructor to flag improper direct use of the tcpSession protocol from configuration files.
tcpSession(tcpSessionMaster serv)
          Initialize TCP session with LISTEN state and port number of the listening server application
tcpSession(tcpSessionMaster serv, tcpSocket upSession, ProtocolSession lowSession, int SrcIpAddr, int SrcPort, int DesIpAddr, int DesPort)
          Initialize TCP session with SYN_RECEIVED state and IP address and port number of source and destination
 
Method Summary
 void ActiveOpen()
          Active open a connection by sending a message with a SYN flag.
 boolean close()
          Socket closes its TCP session.
 boolean closed()
          Tell the caller if the TCP connection exist
 void CloseStateTransfer1()
          State transfer when FIN is received.
 void CloseStateTransfer2()
          State transfer when 1) FIN is sent; 2) ACK of FIN is received;
 void CloseStateTransfer3()
           
 void fastTimeout()
          fast timer function called every 200 ms
 int get_protocol_status()
          Get the value of protocol_status.
 float getSimTime()
           
 boolean isClosed()
          test if the connection is closed
 boolean opened()
          Tell the caller if the TCP connection exists
 void PassiveOpen()
          Passive open a listening connection.
 boolean push(ProtocolMessage message, ProtocolSession fromSession)
          Classify and process the incoming TCP message according to message flags and connection state.
 void read(java.lang.Object[] obj, int nbytes, Continuation caller)
           
 void set_protocol_status(int v)
          Set the value of protocol_status.
 void slowTimeout()
          slow timer function called every 500 ms
 java.lang.String stateToString(int state)
           
 void TwoMSLtimeout()
          Performs 2MSL timer and FIN_WAIT_2 timer timeout functions.
 void write(dataMessage dmsg, Continuation caller)
           
 
Methods inherited from class SSF.OS.ProtocolSession
close, closed, config, debugIdentifier, inGraph, init, open, opened, pushAfterDelay, pushAfterDelayFailed, setGraph, version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public boolean DEBUG
Option used to switch on/off verbose session debugging output.


INFO

public boolean INFO
Option used to switch on/off verbose session information output.


tcpServ

public tcpSessionMaster tcpServ
TCP master service that owns this TCP session.


close_timer_basis

public static final long close_timer_basis
CLOSE Timer basis, default value 0.5 seconds.


ipHdr

public IpHeader ipHdr
IP header template of this session.


tcpHdr

public TCP_Header tcpHdr
TCP header template of this session.


ipsess

public ProtocolSession ipsess
Local IP Session in the ProtocolGraph.


mySocket

public tcpSocket mySocket
For listening server TCP session, it is the reference to master server socket. For other TCP sessions, it is the socket connected to this TCP session.


tcp_state

public int tcp_state
TCP connection state variable.


snd

public Send_WndManager snd
Object managing the send queue and processing the received ACKs


CLOSED

public static final int CLOSED
See Also:
Constant Field Values

LISTEN

public static final int LISTEN
See Also:
Constant Field Values

SYN_SENT

public static final int SYN_SENT
See Also:
Constant Field Values

SYN_RECEIVED

public static final int SYN_RECEIVED
See Also:
Constant Field Values

ESTABLISHED

public static final int ESTABLISHED
See Also:
Constant Field Values

CLOSE_WAIT

public static final int CLOSE_WAIT
See Also:
Constant Field Values

CLOSING

public static final int CLOSING
See Also:
Constant Field Values

FIN_WAIT_1

public static final int FIN_WAIT_1
See Also:
Constant Field Values

FIN_WAIT_2

public static final int FIN_WAIT_2
See Also:
Constant Field Values

LAST_ACK

public static final int LAST_ACK
See Also:
Constant Field Values

TIME_WAIT

public static final int TIME_WAIT
See Also:
Constant Field Values

MSL

public static int MSL
maximum segment lifetime in slow ticks


maxIdleTime

public static long maxIdleTime
maximum FIN_WAIT_2 idle time

Constructor Detail

tcpSession

public tcpSession()
           throws TCPException
False zero-argument constructor to flag improper direct use of the tcpSession protocol from configuration files.


tcpSession

public tcpSession(tcpSessionMaster serv)
Initialize TCP session with LISTEN state and port number of the listening server application


tcpSession

public tcpSession(tcpSessionMaster serv,
                  tcpSocket upSession,
                  ProtocolSession lowSession,
                  int SrcIpAddr,
                  int SrcPort,
                  int DesIpAddr,
                  int DesPort)
Initialize TCP session with SYN_RECEIVED state and IP address and port number of source and destination

Method Detail

stateToString

public java.lang.String stateToString(int state)

ActiveOpen

public void ActiveOpen()
Active open a connection by sending a message with a SYN flag.


PassiveOpen

public void PassiveOpen()
Passive open a listening connection.


CloseStateTransfer1

public void CloseStateTransfer1()
State transfer when FIN is received.


CloseStateTransfer2

public void CloseStateTransfer2()
State transfer when 1) FIN is sent; 2) ACK of FIN is received;


CloseStateTransfer3

public void CloseStateTransfer3()

slowTimeout

public void slowTimeout()
slow timer function called every 500 ms


fastTimeout

public void fastTimeout()
fast timer function called every 200 ms


TwoMSLtimeout

public void TwoMSLtimeout()
Performs 2MSL timer and FIN_WAIT_2 timer timeout functions.


opened

public boolean opened()
Tell the caller if the TCP connection exists

Returns:
true if the state is ESTABLISHED

closed

public boolean closed()
Tell the caller if the TCP connection exist

Returns:
true if the state is CLOSED

get_protocol_status

public int get_protocol_status()
Get the value of protocol_status.

Returns:
Value of protocol_status.

set_protocol_status

public void set_protocol_status(int v)
Set the value of protocol_status.

Parameters:
v - Value to assign to protocol_status.

close

public boolean close()
              throws TCPException
Socket closes its TCP session.

Returns:
true if success, false if failed
TCPException

getSimTime

public float getSimTime()

push

public boolean push(ProtocolMessage message,
                    ProtocolSession fromSession)
             throws ProtocolException
Classify and process the incoming TCP message according to message flags and connection state.

Specified by:
push in class ProtocolSession
Parameters:
message - incoming TCP message
fromSession - ProtocolSession that invoked the push() method, here IP.
Returns:
result of the push action: If successful return true, otherwise return false.
ProtocolException

isClosed

public boolean isClosed()
test if the connection is closed


write

public void write(dataMessage dmsg,
                  Continuation caller)

read

public void read(java.lang.Object[] obj,
                 int nbytes,
                 Continuation caller)