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

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

#include <TCPSendQueue.h>

Inheritance diagram for inet::tcp::TCPSendQueue:
inet::tcp::TCPByteStreamSendQueue inet::tcp::TCPMsgBasedSendQueue inet::tcp::TCPVirtualDataSendQueue

Public Member Functions

 TCPSendQueue ()
 Ctor. More...
 
virtual ~TCPSendQueue ()
 Virtual dtor. More...
 
virtual void setConnection (TCPConnection *_conn)
 Set the connection that owns this queue. More...
 
virtual void init (uint32 startSeq)=0
 Initialize the object. More...
 
virtual void enqueueAppData (cPacket *msg)=0
 Called on SEND app command, it inserts in the queue the data the user wants to send. More...
 
virtual uint32 getBufferStartSeq ()=0
 Returns the sequence number of the first byte stored in the buffer. More...
 
virtual uint32 getBufferEndSeq ()=0
 Returns the sequence number of the last byte stored in the buffer plus one. More...
 
ulong getBytesAvailable (uint32 fromSeq)
 Utility function: returns how many bytes are available in the queue, from (and including) the given sequence number. More...
 
virtual TCPSegmentcreateSegmentWithBytes (uint32 fromSeq, ulong maxNumBytes)=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 seqNum)=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

TCPConnectionconn
 

Detailed Description

Abstract base class for TCP 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. RFC 1122 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 TCPSendQueue subclasses can be written to accomodate different needs.

This class goes hand-in-hand with TCPReceiveQueue.

See also
TCPReceiveQueue

Constructor & Destructor Documentation

inet::tcp::TCPSendQueue::TCPSendQueue ( )
inline

Ctor.

91 { conn = nullptr; }
TCPConnection * conn
Definition: TCPSendQueue.h:85
virtual inet::tcp::TCPSendQueue::~TCPSendQueue ( )
inlinevirtual

Virtual dtor.

96 {}

Member Function Documentation

virtual TCPSegment* inet::tcp::TCPSendQueue::createSegmentWithBytes ( uint32  fromSeq,
ulong  maxNumBytes 
)
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 than maxNumBytes bytes if the subclass wants to reproduce the original segment boundaries when retransmitting.

Implemented in inet::tcp::TCPMsgBasedSendQueue, inet::tcp::TCPVirtualDataSendQueue, and inet::tcp::TCPByteStreamSendQueue.

Referenced by inet::tcp::TCPConnection::sendSegment().

virtual void inet::tcp::TCPSendQueue::discardUpTo ( uint32  seqNum)
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::TCPMsgBasedSendQueue, inet::tcp::TCPVirtualDataSendQueue, and inet::tcp::TCPByteStreamSendQueue.

Referenced by inet::tcp::TCPConnection::processAckInEstabEtc(), inet::tcp::TCPConnection::processRstInSynReceived(), and inet::tcp::TCPConnection::processSegmentInSynSent().

virtual void inet::tcp::TCPSendQueue::enqueueAppData ( cPacket *  msg)
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::TCPMsgBasedSendQueue, inet::tcp::TCPVirtualDataSendQueue, and inet::tcp::TCPByteStreamSendQueue.

Referenced by inet::tcp::TCPConnection::process_SEND().

virtual uint32 inet::tcp::TCPSendQueue::getBufferEndSeq ( )
pure virtual

Returns the sequence number of the last byte stored in the buffer plus one.

(The first byte of the next send operation would get this sequence number.)

Implemented in inet::tcp::TCPMsgBasedSendQueue, inet::tcp::TCPVirtualDataSendQueue, and inet::tcp::TCPByteStreamSendQueue.

Referenced by inet::tcp::TCPConnection::process_CLOSE(), inet::tcp::TCPConnection::processRstInSynReceived(), inet::tcp::TCPConnection::retransmitData(), and inet::tcp::TCPConnection::retransmitOneSegment().

virtual uint32 inet::tcp::TCPSendQueue::getBufferStartSeq ( )
pure virtual

Returns the sequence number of the first byte stored in the buffer.

Implemented in inet::tcp::TCPMsgBasedSendQueue, inet::tcp::TCPVirtualDataSendQueue, and inet::tcp::TCPByteStreamSendQueue.

Referenced by inet::tcp::TCPConnection::sendSegment().

ulong inet::tcp::TCPSendQueue::getBytesAvailable ( uint32  fromSeq)
inline

Utility function: returns how many bytes are available in the queue, from (and including) the given sequence number.

Referenced by inet::tcp::TCPConnection::isSendQueueEmpty(), inet::tcp::TCPConnection::nextSeg(), inet::tcp::TCPConnection::process_SEND(), inet::tcp::TCPConnection::retransmitData(), inet::tcp::TCPConnection::retransmitOneSegment(), inet::tcp::TCPConnection::sendData(), inet::tcp::TCPConnection::sendOneNewSegment(), inet::tcp::TCPConnection::sendProbe(), and inet::tcp::TCPConnection::sendSegment().

139  {
140  uint32 bufEndSeq = getBufferEndSeq();
141  return seqLess(fromSeq, bufEndSeq) ? bufEndSeq - fromSeq : 0;
142  }
bool seqLess(uint32 a, uint32 b)
Definition: TCPSegment.h:32
uint32_t uint32
Definition: Compat.h:30
virtual uint32 getBufferEndSeq()=0
Returns the sequence number of the last byte stored in the buffer plus one.
virtual void inet::tcp::TCPSendQueue::init ( uint32  startSeq)
pure virtual

Initialize the object.

The startSeq parameter tells what sequence number the first byte of app data should get. This is usually ISS + 1 because SYN consumes one byte in the sequence number space.

init() may be called more than once; every call flushes the existing contents of the queue.

Implemented in inet::tcp::TCPMsgBasedSendQueue, inet::tcp::TCPByteStreamSendQueue, and inet::tcp::TCPVirtualDataSendQueue.

Referenced by inet::tcp::TCPConnection::selectInitialSeqNum().

virtual void inet::tcp::TCPSendQueue::setConnection ( TCPConnection _conn)
inlinevirtual

Set the connection that owns this queue.

Referenced by inet::tcp::TCPConnection::cloneListeningConnection(), and inet::tcp::TCPConnection::initConnection().

101 { conn = _conn; }
TCPConnection * conn
Definition: TCPSendQueue.h:85

Member Data Documentation

TCPConnection* inet::tcp::TCPSendQueue::conn
protected

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