INET Framework for OMNeT++/OMNEST
inet::tcp::TCP_NSC_SendQueue Class Referenceabstract

Abstract base class for TCP_NSC send queues. More...

#include <TCP_NSC_Queues.h>

Inheritance diagram for inet::tcp::TCP_NSC_SendQueue:
inet::tcp::TCP_NSC_ByteStreamSendQueue inet::tcp::TCP_NSC_VirtualDataSendQueue

Public Member Functions

 TCP_NSC_SendQueue ()
 Ctor. More...
 
virtual ~TCP_NSC_SendQueue ()
 Virtual dtor. More...
 
virtual void setConnection (TCP_NSC_Connection *connP)
 set connection queue, and initialise queue variables. More...
 
virtual void enqueueAppData (cPacket *msgP)=0
 Called on SEND app command, it inserts in the queue the data the user wants to send. More...
 
virtual int getBytesForTcpLayer (void *bufferP, int bufferLengthP) const =0
 Copy data to the buffer for send to NSC. More...
 
virtual void dequeueTcpLayerMsg (int msgLengthP)=0
 The function should remove msgLengthP bytes from NSCqueue. More...
 
virtual unsigned long getBytesAvailable () const =0
 Utility function: returns how many bytes are available in the queue. More...
 
virtual TCPSegmentcreateSegmentWithBytes (const void *tcpDataP, int tcpLengthP)=0
 Called when the TCP wants to send or retransmit data, it constructs a TCP segment which contains the data from the requested sequence number range. More...
 
virtual void discardUpTo (uint32 seqNumP)=0
 Tells the queue that bytes up to (but NOT including) seqNum have been transmitted and ACKed, so they can be removed from the queue. More...
 

Protected Attributes

TCP_NSC_ConnectionconnM
 

Detailed Description

Abstract base class for TCP_NSC send queues.

In fact a single object represents both the send queue and the retransmission queue (no need to separate them). The TCPConnection object knows which data in the queue have already been transmitted ("retransmission queue") and which not ("send queue"). This class is not interested in where's the boundary.

There is another particularity about this class: as a retransmission queue, it stores bytes and not segments. TCP is a bytestream oriented protocol (sequence numbers refer to bytes and not to TPDUs as e.g. in ISO TP4), and the protocol doesn't rely on retransmitted segments having the same segment boundaries as the original segments. Some implementations store segments on the retransmission queue, and others store only the data bytes; RFCs explicitly allow both. (See e.g. RFC1122 p90, section 4.2.2.15, "IMPLEMENTATION" note).

To simulate a TCP that retains segment boundaries in retransmissions, the appropriate TCPAlgorithm class should remember where the segment boundaries were at the original transmission, and it should form identical segments when retransmitting. The createSegmentWithBytes() send queue method makes this possible.

This class is polymorphic because depending on where and how you use the TCP model you might have different ideas about "sending data" on a simulated connection.

You might want to:

  • transmit a real bytes, especially if the application which uses TCP is a ported version of a real socket application.
  • simulate a "dummy" connection, that is, simulated TCP segments contain do not contain any real data, only the number of bytes they represent. You'll want to do this when the app is there solely as a traffic generator (e.g. simulated file transfer or telnet session), but actual data is unimportant.
  • transmit a sequence of cMessage objects, and you want exactly the same cMessage sequence to be reproduced on the receiver side. Here every cMessage maps to a sequence number range in the TCP stream, and the object is passed up to the application on the receiving side when its last byte has arrived on the simulated connection.

Different TCP_NSCSendQueue subclasses can be written to accomodate different needs.

This class goes hand-in-hand with TCP_NSCReceiveQueue.

See also
TCP_NSCReceiveQueue

Constructor & Destructor Documentation

inet::tcp::TCP_NSC_SendQueue::TCP_NSC_SendQueue ( )
inline

Ctor.

92 : connM(nullptr) {}
TCP_NSC_Connection * connM
Definition: TCP_NSC_Queues.h:157
virtual inet::tcp::TCP_NSC_SendQueue::~TCP_NSC_SendQueue ( )
inlinevirtual

Virtual dtor.

97 {}

Member Function Documentation

virtual TCPSegment* inet::tcp::TCP_NSC_SendQueue::createSegmentWithBytes ( const void *  tcpDataP,
int  tcpLengthP 
)
pure virtual

Called when the TCP wants to send or retransmit data, it constructs a TCP segment which contains the data from the requested sequence number range.

The actually returned segment may contain less then maxNumBytes bytes if the subclass wants to reproduce the original segment boundaries when retransmitting.

called from inside of send_callback() called before called the send() to IP layer

Implemented in inet::tcp::TCP_NSC_ByteStreamSendQueue, and inet::tcp::TCP_NSC_VirtualDataSendQueue.

Referenced by inet::tcp::TCP_NSC::sendToIP().

virtual void inet::tcp::TCP_NSC_SendQueue::dequeueTcpLayerMsg ( int  msgLengthP)
pure virtual

The function should remove msgLengthP bytes from NSCqueue.

But the NSC sometimes reread from this datapart (when data destroyed in IP Layer) inside of createSegmentWithBytes() function.

called with return value of socket->send_data() if larger than 0

Implemented in inet::tcp::TCP_NSC_ByteStreamSendQueue, and inet::tcp::TCP_NSC_VirtualDataSendQueue.

Referenced by inet::tcp::TCP_NSC_Connection::abort(), and inet::tcp::TCP_NSC_Connection::do_SEND().

virtual void inet::tcp::TCP_NSC_SendQueue::discardUpTo ( uint32  seqNumP)
pure virtual

Tells the queue that bytes up to (but NOT including) seqNum have been transmitted and ACKed, so they can be removed from the queue.

Implemented in inet::tcp::TCP_NSC_ByteStreamSendQueue, and inet::tcp::TCP_NSC_VirtualDataSendQueue.

virtual void inet::tcp::TCP_NSC_SendQueue::enqueueAppData ( cPacket *  msgP)
pure virtual

Called on SEND app command, it inserts in the queue the data the user wants to send.

Implementations of this abstract class will decide what this means: copying actual bytes, just increasing the "last byte queued" variable, or storing cMessage object(s). The msg object should not be referenced after this point (sendQueue may delete it.)

Implemented in inet::tcp::TCP_NSC_ByteStreamSendQueue, and inet::tcp::TCP_NSC_VirtualDataSendQueue.

Referenced by inet::tcp::TCP_NSC_Connection::send().

virtual unsigned long inet::tcp::TCP_NSC_SendQueue::getBytesAvailable ( ) const
pure virtual

Utility function: returns how many bytes are available in the queue.

Implemented in inet::tcp::TCP_NSC_ByteStreamSendQueue, and inet::tcp::TCP_NSC_VirtualDataSendQueue.

Referenced by inet::tcp::TCP_NSC_Connection::abort(), and inet::tcp::TCP_NSC_Connection::do_SEND().

virtual int inet::tcp::TCP_NSC_SendQueue::getBytesForTcpLayer ( void *  bufferP,
int  bufferLengthP 
) const
pure virtual

Copy data to the buffer for send to NSC.

returns lengh of copied data. create msg for socket->send_data()

called before called socket->send_data()

Implemented in inet::tcp::TCP_NSC_ByteStreamSendQueue, and inet::tcp::TCP_NSC_VirtualDataSendQueue.

Referenced by inet::tcp::TCP_NSC_Connection::do_SEND().

virtual void inet::tcp::TCP_NSC_SendQueue::setConnection ( TCP_NSC_Connection connP)
inlinevirtual

Member Data Documentation

TCP_NSC_Connection* inet::tcp::TCP_NSC_SendQueue::connM
protected

The documentation for this class was generated from the following file: