jist.swans.trans
Class TransTcp

java.lang.Object
  extended by jist.swans.trans.TransTcp
All Implemented Interfaces:
JistAPI.Proxiable, JistAPI.Timeless, NetInterface.NetHandler, TransInterface, TransInterface.TransTcpInterface

public class TransTcp
extends java.lang.Object
implements TransInterface.TransTcpInterface

Implementation of TCP Transport Layer.

Since:
SWANS1.0

Nested Class Summary
static class TransTcp.TcpMessage
          Data structure for TCP Message.
static class TransTcp.TcpOptions
          Implementation for TCP Options.
 
Nested classes/interfaces inherited from interface jist.swans.trans.TransInterface
TransInterface.SocketHandler, TransInterface.TransMessage, TransInterface.TransTcpInterface, TransInterface.TransUdpInterface
 
Constructor Summary
TransTcp()
          Constructor.
 
Method Summary
 void addSocketHandler(int port, TransInterface.SocketHandler socketCallback)
          Register socket handler.
 boolean checkSocketHandler(int port)
          Return whether socket bound to port.
 void delSocketHandler(int port)
          Unregister socket handler.
 void dropNotify(Message msg, MacAddress nextHopMac, Reason reason)
          Notification mechanism for packet dropped due to various "Reasons"
 TransInterface.TransTcpInterface getProxy()
          Returns an entity reference to this object.
 void receive(Message msg, NetAddress src, MacAddress lastHop, byte macId, NetAddress dst, byte priority, byte ttl)
          Receive a message from network layer.
 void send(Message msg, NetAddress dst, int dstPort, int srcPort, byte priority)
          Send message (from APPLICATON).
 void send(NetMessage msg)
          Send a message through the routing protocol
 void setNetEntity(NetInterface netEntity)
          Sets the reference to the network layer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransTcp

public TransTcp()
Constructor.

Method Detail

send

public void send(NetMessage msg)
Description copied from interface: NetInterface.NetHandler
Send a message through the routing protocol

Specified by:
send in interface NetInterface.NetHandler

dropNotify

public void dropNotify(Message msg,
                       MacAddress nextHopMac,
                       Reason reason)
Description copied from interface: NetInterface.NetHandler
Notification mechanism for packet dropped due to various "Reasons"

Specified by:
dropNotify in interface NetInterface.NetHandler

getProxy

public TransInterface.TransTcpInterface getProxy()
Returns an entity reference to this object.

Returns:
entity reference to TransTcp itself

setNetEntity

public void setNetEntity(NetInterface netEntity)
Sets the reference to the network layer.

Parameters:
netEntity - entity reference to network layer

addSocketHandler

public void addSocketHandler(int port,
                             TransInterface.SocketHandler socketCallback)
Register socket handler.

Specified by:
addSocketHandler in interface TransInterface
Parameters:
port - bound socket port
socketCallback - callback handler

delSocketHandler

public void delSocketHandler(int port)
Unregister socket handler.

Specified by:
delSocketHandler in interface TransInterface
Parameters:
port - bound socket port

checkSocketHandler

public boolean checkSocketHandler(int port)
Return whether socket bound to port.

Specified by:
checkSocketHandler in interface TransInterface.TransTcpInterface
Parameters:
port - port to check
Returns:
whether socket bound to port

receive

public void receive(Message msg,
                    NetAddress src,
                    MacAddress lastHop,
                    byte macId,
                    NetAddress dst,
                    byte priority,
                    byte ttl)
Receive a message from network layer.

Specified by:
receive in interface NetInterface.NetHandler
Parameters:
msg - message received
src - source network address
lastHop - source link address
macId - incoming interface
dst - destination network address
priority - packet priority
ttl - packet time-to-live

send

public void send(Message msg,
                 NetAddress dst,
                 int dstPort,
                 int srcPort,
                 byte priority)
Send message (from APPLICATON).

Specified by:
send in interface TransInterface
Parameters:
msg - packet payload (usually from application layer)
dst - packet destination address
dstPort - packet destination port
srcPort - packet source port
priority - packet priority