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

Send queue that manages "data stream", that is, actual bytes. More...

#include <TcpLwipByteStreamQueues.h>

Inheritance diagram for inet::tcp::TcpLwipByteStreamSendQueue:
inet::tcp::TcpLwipSendQueue

Public Member Functions

 TcpLwipByteStreamSendQueue ()
 Ctor. More...
 
virtual ~TcpLwipByteStreamSendQueue ()
 Virtual dtor. More...
 
virtual void setConnection (TcpLwipConnection *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 unsigned int getBytesForTcpLayer (void *bufferP, unsigned int bufferLengthP) const override
 Copy data to the buffer for send to LWIP. More...
 
virtual void dequeueTcpLayerMsg (unsigned int msgLengthP) override
 This function should remove msgLengthP bytes from TCP layer queue. More...
 
unsigned long getBytesAvailable () const override
 Utility function: returns how many bytes are available in the queue. More...
 
virtual TCPSegmentcreateSegmentWithBytes (const void *tcpDataP, unsigned 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 discardAckedBytes (unsigned long bytesP)
 
- Public Member Functions inherited from inet::tcp::TcpLwipSendQueue
 TcpLwipSendQueue ()
 Ctor. More...
 
virtual ~TcpLwipSendQueue ()
 Virtual dtor. More...
 

Protected Attributes

ByteArrayBuffer byteArrayBufferM
 
- Protected Attributes inherited from inet::tcp::TcpLwipSendQueue
TcpLwipConnectionconnM
 

Detailed Description

Send queue that manages "data stream", that is, actual bytes.

Constructor & Destructor Documentation

inet::tcp::TcpLwipByteStreamSendQueue::TcpLwipByteStreamSendQueue ( )

Ctor.

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

Virtual dtor.

40 {
41 }

Member Function Documentation

TCPSegment * inet::tcp::TcpLwipByteStreamSendQueue::createSegmentWithBytes ( const void *  tcpDataP,
unsigned 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::TcpLwipSendQueue.

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

This function should remove msgLengthP bytes from TCP layer queue.

Implements inet::tcp::TcpLwipSendQueue.

70 {
71  byteArrayBufferM.drop(msgLengthP);
72 }
virtual unsigned int drop(unsigned int lengthP)
Drop bytes from buffer.
Definition: ByteArrayBuffer.cc:78
ByteArrayBuffer byteArrayBufferM
Definition: TcpLwipByteStreamQueues.h:62
void inet::tcp::TcpLwipByteStreamSendQueue::discardAckedBytes ( unsigned long  bytesP)
virtual
101 {
102  // nothing to do here
103 }
void inet::tcp::TcpLwipByteStreamSendQueue::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::TcpLwipSendQueue.

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

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

Implements inet::tcp::TcpLwipSendQueue.

75 {
76  return byteArrayBufferM.getLength();
77 }
virtual uint64 getLength() const
Returns length of stored data.
Definition: ByteArrayBuffer.h:55
ByteArrayBuffer byteArrayBufferM
Definition: TcpLwipByteStreamQueues.h:62
unsigned int inet::tcp::TcpLwipByteStreamSendQueue::getBytesForTcpLayer ( void *  bufferP,
unsigned int  bufferLengthP 
) const
overridevirtual

Copy data to the buffer for send to LWIP.

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

called before called socket->send_data()

Implements inet::tcp::TcpLwipSendQueue.

63 {
64  ASSERT(bufferP);
65 
66  return byteArrayBufferM.getBytesToBuffer(bufferP, bufferLengthP);
67 }
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: TcpLwipByteStreamQueues.h:62
void inet::tcp::TcpLwipByteStreamSendQueue::setConnection ( TcpLwipConnection connP)
overridevirtual

set connection queue, and initialise queue variables.

Reimplemented from inet::tcp::TcpLwipSendQueue.

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

Member Data Documentation


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