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

Send queue that manages actual bytes. More...

#include <TCP_NSC_ByteStreamQueues.h>

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

Public Member Functions

 TCP_NSC_ByteStreamSendQueue ()
 Ctor. More...
 
virtual ~TCP_NSC_ByteStreamSendQueue ()
 Virtual dtor. More...
 
virtual void setConnection (TCP_NSC_Connection *connP) override
 set connection queue, and initialise queue variables. More...
 
virtual void enqueueAppData (cPacket *msgP) override
 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 override
 Copy data to the buffer for send to NSC. More...
 
virtual void dequeueTcpLayerMsg (int msgLengthP) override
 The function should remove msgLengthP bytes from NSCqueue. More...
 
virtual unsigned long getBytesAvailable () const override
 Utility function: returns how many bytes are available in the queue. More...
 
virtual TCPSegmentcreateSegmentWithBytes (const void *tcpDataP, int tcpLengthP) 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 seqNumP) 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::TCP_NSC_SendQueue
 TCP_NSC_SendQueue ()
 Ctor. More...
 
virtual ~TCP_NSC_SendQueue ()
 Virtual dtor. More...
 

Protected Attributes

ByteArrayBuffer byteArrayBufferM
 
- Protected Attributes inherited from inet::tcp::TCP_NSC_SendQueue
TCP_NSC_ConnectionconnM
 

Detailed Description

Send queue that manages actual bytes.

Constructor & Destructor Documentation

inet::tcp::TCP_NSC_ByteStreamSendQueue::TCP_NSC_ByteStreamSendQueue ( )

Ctor.

36 {
37 }
inet::tcp::TCP_NSC_ByteStreamSendQueue::~TCP_NSC_ByteStreamSendQueue ( )
virtual

Virtual dtor.

40 {
41 }

Member Function Documentation

TCPSegment * inet::tcp::TCP_NSC_ByteStreamSendQueue::createSegmentWithBytes ( const void *  tcpDataP,
int  tcpLengthP 
)
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 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

Implements inet::tcp::TCP_NSC_SendQueue.

77 {
78  ASSERT(tcpDataP);
79 
80  TCPSegment *tcpseg = serializer::TCPSerializer().deserialize((const unsigned char *)tcpDataP, tcpLengthP, true);
81  uint32 numBytes = tcpseg->getPayloadLength();
82 
83  char msgname[80];
84  sprintf(msgname, "%.10s%s%s%s(l=%lu,%u bytes)",
85  "tcpseg",
86  tcpseg->getSynBit() ? " SYN" : "",
87  tcpseg->getFinBit() ? " FIN" : "",
88  (tcpseg->getAckBit() && 0 == numBytes) ? " ACK" : "",
89  (unsigned long)numBytes,
90  tcpseg->getByteArray().getDataArraySize());
91  tcpseg->setName(msgname);
92 
93  return tcpseg;
94 }
uint32_t uint32
Definition: Compat.h:30
void inet::tcp::TCP_NSC_ByteStreamSendQueue::dequeueTcpLayerMsg ( int  msgLengthP)
overridevirtual

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

Implements inet::tcp::TCP_NSC_SendQueue.

67 {
68  byteArrayBufferM.drop(msgLengthP);
69 }
virtual unsigned int drop(unsigned int lengthP)
Drop bytes from buffer.
Definition: ByteArrayBuffer.cc:78
ByteArrayBuffer byteArrayBufferM
Definition: TCP_NSC_ByteStreamQueues.h:62
void inet::tcp::TCP_NSC_ByteStreamSendQueue::discardUpTo ( uint32  seqNumP)
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::TCP_NSC_SendQueue.

97 {
98  // nothing to do here
99 }
void inet::tcp::TCP_NSC_ByteStreamSendQueue::enqueueAppData ( cPacket *  msgP)
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::TCP_NSC_SendQueue.

50 {
51  ASSERT(msgP);
52 
53  RawPacket *msg = check_and_cast<RawPacket *>(msgP);
54  int64 bytes = msg->getByteLength();
55  ASSERT(bytes == msg->getByteArray().getDataArraySize());
56  byteArrayBufferM.push(msg->getByteArray());
57  delete msgP;
58 }
virtual void push(const ByteArray &byteArrayP)
Push data to end of buffer.
Definition: ByteArrayBuffer.cc:40
ByteArrayBuffer byteArrayBufferM
Definition: TCP_NSC_ByteStreamQueues.h:62
int64_t int64
Definition: Compat.h:29
ulong inet::tcp::TCP_NSC_ByteStreamSendQueue::getBytesAvailable ( ) const
overridevirtual

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

Implements inet::tcp::TCP_NSC_SendQueue.

72 {
73  return byteArrayBufferM.getLength();
74 }
virtual uint64 getLength() const
Returns length of stored data.
Definition: ByteArrayBuffer.h:55
ByteArrayBuffer byteArrayBufferM
Definition: TCP_NSC_ByteStreamQueues.h:62
int inet::tcp::TCP_NSC_ByteStreamSendQueue::getBytesForTcpLayer ( void *  bufferP,
int  bufferLengthP 
) const
overridevirtual

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

Implements inet::tcp::TCP_NSC_SendQueue.

61 {
62  ASSERT(bufferP);
63  return byteArrayBufferM.getBytesToBuffer(bufferP, bufferLengthP);
64 }
virtual unsigned int getBytesToBuffer(void *bufferP, unsigned int bufferLengthP, unsigned int srcOffsP=0) const
Copy bytes to an external buffer.
Definition: ByteArrayBuffer.cc:54
ByteArrayBuffer byteArrayBufferM
Definition: TCP_NSC_ByteStreamQueues.h:62
void inet::tcp::TCP_NSC_ByteStreamSendQueue::setConnection ( TCP_NSC_Connection connP)
overridevirtual

set connection queue, and initialise queue variables.

Reimplemented from inet::tcp::TCP_NSC_SendQueue.

44 {
47 }
virtual void setConnection(TCP_NSC_Connection *connP)
set connection queue, and initialise queue variables.
Definition: TCP_NSC_Queues.h:102
ByteArrayBuffer byteArrayBufferM
Definition: TCP_NSC_ByteStreamQueues.h:62
virtual void clear()
Clear buffer.
Definition: ByteArrayBuffer.cc:102

Member Data Documentation


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