INET Framework for OMNeT++/OMNEST
inet::tcp::TCPByteStreamSendQueue Class Reference

Send queue that manages messages. More...

#include <TCPByteStreamSendQueue.h>

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

Public Member Functions

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

Protected Attributes

ByteArrayBuffer dataBuffer
 
uint32 begin
 
uint32 end
 
- Protected Attributes inherited from inet::tcp::TCPSendQueue
TCPConnectionconn
 

Detailed Description

Send queue that manages messages.

See also
TCPRcvQueue

Constructor & Destructor Documentation

inet::tcp::TCPByteStreamSendQueue::TCPByteStreamSendQueue ( )

Ctor.

29  : TCPSendQueue()
30 {
31  begin = end = 0;
32 }
TCPSendQueue()
Ctor.
Definition: TCPSendQueue.h:91
uint32 begin
Definition: TCPByteStreamSendQueue.h:40
uint32 end
Definition: TCPByteStreamSendQueue.h:41
inet::tcp::TCPByteStreamSendQueue::~TCPByteStreamSendQueue ( )
virtual

Virtual dtor.

35 {
36 }

Member Function Documentation

TCPSegment * inet::tcp::TCPByteStreamSendQueue::createSegmentWithBytes ( uint32  fromSeq,
ulong  maxNumBytes 
)
overridevirtual

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.

Implements inet::tcp::TCPSendQueue.

74 {
75  //tcpEV << "sendQ: " << info() << " createSeg(seq=" << fromSeq << " len=" << numBytes << ")\n";
76  ASSERT(seqLE(begin, fromSeq) && seqLE(fromSeq + numBytes, end));
77 
78  TCPSegment *tcpseg = new TCPSegment();
79  tcpseg->setSequenceNo(fromSeq);
80  tcpseg->setPayloadLength(numBytes);
81 
82  // add payload messages whose endSequenceNo is between fromSeq and fromSeq+numBytes
83  unsigned int fromOffs = (uint32)(fromSeq - begin);
84  char *buffer = new char[numBytes];
85  unsigned int bytes = dataBuffer.getBytesToBuffer(buffer, numBytes, fromOffs);
86  ASSERT(bytes == numBytes);
87  tcpseg->getByteArray().assignBuffer(buffer, bytes);
88 
89  // give segment a name
90  char msgname[80];
91  sprintf(msgname, "tcpseg(l=%lu)", numBytes);
92  tcpseg->setName(msgname);
93 
94  return tcpseg;
95 }
uint32 begin
Definition: TCPByteStreamSendQueue.h:40
virtual unsigned int getBytesToBuffer(void *bufferP, unsigned int bufferLengthP, unsigned int srcOffsP=0) const
Copy bytes to an external buffer.
Definition: ByteArrayBuffer.cc:54
bool seqLE(uint32 a, uint32 b)
Definition: TCPSegment.h:33
ByteArrayBuffer dataBuffer
Definition: TCPByteStreamSendQueue.h:39
uint32_t uint32
Definition: Compat.h:30
uint32 end
Definition: TCPByteStreamSendQueue.h:41
void inet::tcp::TCPByteStreamSendQueue::discardUpTo ( uint32  seqNum)
overridevirtual

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

Implements inet::tcp::TCPSendQueue.

98 {
99  //tcpEV << "sendQ: " << info() << " discardUpTo(seq=" << seqNum << ")\n";
100  ASSERT(seqLE(begin, seqNum) && seqLE(seqNum, end));
101  dataBuffer.drop(seqNum - begin);
102  begin = seqNum;
103 }
uint32 begin
Definition: TCPByteStreamSendQueue.h:40
virtual unsigned int drop(unsigned int lengthP)
Drop bytes from buffer.
Definition: ByteArrayBuffer.cc:78
bool seqLE(uint32 a, uint32 b)
Definition: TCPSegment.h:33
ByteArrayBuffer dataBuffer
Definition: TCPByteStreamSendQueue.h:39
uint32 end
Definition: TCPByteStreamSendQueue.h:41
void inet::tcp::TCPByteStreamSendQueue::enqueueAppData ( cPacket *  msg)
overridevirtual

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.)

Implements inet::tcp::TCPSendQueue.

53 {
54  //tcpEV << "sendQ: " << info() << " enqueueAppData(bytes=" << msg->getByteLength() << ")\n";
55  RawPacket *bamsg = check_and_cast<RawPacket *>(msg);
56  int64 bytes = bamsg->getByteLength();
57  ASSERT(bytes == bamsg->getByteArray().getDataArraySize());
58  dataBuffer.push(bamsg->getByteArray());
59  end += bytes;
60  delete msg;
61 }
virtual void push(const ByteArray &byteArrayP)
Push data to end of buffer.
Definition: ByteArrayBuffer.cc:40
ByteArrayBuffer dataBuffer
Definition: TCPByteStreamSendQueue.h:39
uint32 end
Definition: TCPByteStreamSendQueue.h:41
int64_t int64
Definition: Compat.h:29
uint32 inet::tcp::TCPByteStreamSendQueue::getBufferEndSeq ( )
overridevirtual

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.)

Implements inet::tcp::TCPSendQueue.

69 {
70  return end;
71 }
uint32 end
Definition: TCPByteStreamSendQueue.h:41
uint32 inet::tcp::TCPByteStreamSendQueue::getBufferStartSeq ( )
overridevirtual

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

Implements inet::tcp::TCPSendQueue.

64 {
65  return begin;
66 }
uint32 begin
Definition: TCPByteStreamSendQueue.h:40
std::string inet::tcp::TCPByteStreamSendQueue::info ( ) const
overridevirtual
46 {
47  std::stringstream out;
48  out << "[" << begin << ".." << end << "), " << dataBuffer.getLength() << " bytes";
49  return out.str();
50 }
virtual uint64 getLength() const
Returns length of stored data.
Definition: ByteArrayBuffer.h:55
uint32 begin
Definition: TCPByteStreamSendQueue.h:40
ByteArrayBuffer dataBuffer
Definition: TCPByteStreamSendQueue.h:39
uint32 end
Definition: TCPByteStreamSendQueue.h:41
void inet::tcp::TCPByteStreamSendQueue::init ( uint32  startSeq)
overridevirtual

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.

Implements inet::tcp::TCPSendQueue.

39 {
40  begin = startSeq;
41  end = startSeq;
42  dataBuffer.clear();
43 }
uint32 begin
Definition: TCPByteStreamSendQueue.h:40
ByteArrayBuffer dataBuffer
Definition: TCPByteStreamSendQueue.h:39
uint32 end
Definition: TCPByteStreamSendQueue.h:41
virtual void clear()
Clear buffer.
Definition: ByteArrayBuffer.cc:102

Member Data Documentation

uint32 inet::tcp::TCPByteStreamSendQueue::begin
protected
ByteArrayBuffer inet::tcp::TCPByteStreamSendQueue::dataBuffer
protected
uint32 inet::tcp::TCPByteStreamSendQueue::end
protected

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