|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectRDTProtocol
public abstract class RDTProtocol
An RDTProtocol implements a reliable data transfer protocol on behalf of a TCP connection thread in the Transport layer. It operates within a context provided by a TCP entity object, which provides a sandbox environment that hides synchronization with the application layer above and the network layer below. Each RDTProtocol is associated with a specific socket on a specific host.
When created, a RDTProtocol is given a name. After setup, it has a partner, which is the RDTProtocol at the other end of the socket connection. In reality, of course, setup would only give it the host internet ID and port number of the partner.
To implement a reliable data transfer protocol, write a class that extends the RDTProtocol class. This class should provide three kinds of functionality:
Initialization is provided by declaring variables needed for receive
and send side functionality and implementing the
doInit()
abstract method.
The createPacket() and createTimer() methods can be used to
construct packets and timers needed by the protocol.
The setAcceptingNewSegments() and setPendingAcknowledgements()
methods can be used to initalize the TCPEntity.
Receive side functionality is provided by implementing the following abstract methods.
When a received segment is ready it can be sent to the reassembler in the TCPEntity using the reassemble() method. The terminate() method can be used to terminate the thread used by the protocol in response to a received close packet.
Send side functionality is provided by implementing the following abstract methods.
handleNewSegment()
method is invoked by the
segmenter in the TCPEntity in response to messages from the
application layer.
The handleTimedOutPacket()
method is invoked by the
TCPEntity in response to expiration of a timer.
The initiateDisconnect()
method is invoked by the
TCPEntity in response to a close operation from the application
layer.
The send() method can be used for passing packets to the transport layer multiplexer, which will send them to the other end of the connection. The setAcceptingNewSegments() method can be used to notify the TCPEntity whether or not new segments are being accepted. The setPendingAcknowledgements() method can be used to notify the TCPEntity whether or not there are packets that have been sent but not acknowledged. This controls when the TCPEntity will begin a disconnect.
Constructor Summary | |
---|---|
RDTProtocol()
|
Method Summary | |
---|---|
protected Packet |
createPacket()
createPacket() returns a new Packet that only requires setting its type, its identification number, and its sequence number before use. |
protected RDTTimer |
createTimer()
createTimer() returns a new Timer that only requires setting its packet before use. |
protected abstract void |
doInit()
doInit() is invoked to perform protocol-dependent initialization for this RDTProtocol. |
abstract void |
handleNewSegment(int id)
rdtp.handleNewSegment(id) is invoked to get rdtp to handle a new segment with identification number id. |
abstract void |
handleReceivedAck(Packet pkt)
rdtp.handleReceivedAck(pkt) is invoked to get rdtp to handle a ACK_TYPE packet received from its TCPEntity's connection partner. |
void |
handleReceivedClose(Packet pkt)
rdtp.handleReceivedClose(pkt) is invoked to get rdtp to handle a CLOSE_TYPE packet received from its TCPEntity's connection partner. |
abstract void |
handleReceivedData(Packet pkt)
rdtp.handleReceivedData(pkt) is invoked to get rdtp to handle a DATA_TYPE packet received from its TCPEntity's connection partner. |
void |
handleReceivedNack(Packet pkt)
rdtp.handleReceivedNack(pkt) is invoked to get rdtp to handle a NACK_TYPE packet received from its TCPEntity's connection partner. |
abstract void |
handleTimedOutPacket(Packet pkt)
rdtp.handleTimedOutPacket(pkt) is invoked to get rdtp to handle a packet acknowledgement timeout for pkt. |
void |
initialize(TCPEntity.Context cntxt)
rdtp.initialize(cntxt) is invoked when a connection is set up using rdtp. |
void |
initiateDisconnect()
rdtp.initiateDisconnect() is invoked to get rdtp to initate a disconnect sequence. |
protected void |
reassemble(int id)
reassemble(id) sends id to the reassembler. |
protected void |
send(Packet pkt)
send(pkt) sends pkt to the receiving end of the connection. |
protected void |
setAcceptingNewSegments(boolean acc)
setAcceptingNewSegments(acc) informs the TCPEntity whether or not this RDTProtocol is accepting new segments. |
protected void |
setPendingAcknowledgements(boolean pa)
setPendingAcknowledgements(pa) informs the TCPEntity whether or not this RDTProtocol has packets that have been sent but not yet acknowledged. |
protected void |
terminate()
terminate() terminates the thread used by this RDTProtocol. |
java.lang.String |
toString()
rdtp.toString() returns the name of rdtp, which is derived from its TCPEntity's name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public RDTProtocol()
Method Detail |
---|
protected Packet createPacket()
protected RDTTimer createTimer()
protected void setAcceptingNewSegments(boolean acc)
If the TCPEntity is not properly informed, the protocol may hang or behave unpredictably.
protected void setPendingAcknowledgements(boolean pa)
If the TCPEntity is not properly informed, the protocol may close prematurely or not close at all.
protected void reassemble(int id)
protected void send(Packet pkt)
protected void terminate()
protected abstract void doInit()
public abstract void handleNewSegment(int id)
public abstract void handleReceivedData(Packet pkt)
public abstract void handleReceivedAck(Packet pkt)
public abstract void handleTimedOutPacket(Packet pkt)
public void handleReceivedNack(Packet pkt)
public void handleReceivedClose(Packet pkt)
public void initiateDisconnect()
public void initialize(TCPEntity.Context cntxt)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |