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

TcpLwip receive queue. More...

#include <TcpLwipQueues.h>

Inheritance diagram for inet::tcp::TcpLwipReceiveQueue:

Public Member Functions

 TcpLwipReceiveQueue ()
 
virtual ~TcpLwipReceiveQueue ()
 
virtual void setConnection (TcpLwipConnection *connP)
 Add a connection queue. More...
 
virtual void notifyAboutIncomingSegmentProcessing (Packet *packet, uint32_t seqNo, const void *bufferP, size_t bufferLengthP)
 Called when a TCP segment arrives, it should extract the payload from the segment and store it in the receive queue. More...
 
virtual void enqueueTcpLayerData (void *dataP, unsigned int dataLengthP)
 The method called when data received from LWIP The method should set status of the data in queue to received called after socket->read_data() successfull. More...
 
virtual unsigned long getExtractableBytesUpTo () const
 
virtual PacketextractBytesUpTo ()
 Should create a packet to be passed up to the app, up to (but NOT including) the given sequence no (usually rcv_nxt). More...
 
virtual uint32_t getAmountOfBufferedBytes () const
 Returns the number of bytes (out-of-order-segments) currently buffered in queue. More...
 
virtual uint32_t getQueueLength () const
 Returns the number of blocks currently buffered in queue. More...
 
virtual void getQueueStatus () const
 Shows current queue status. More...
 
virtual void notifyAboutSending (const TcpHeader *tcpsegP)
 notify the queue about output messages More...
 

Protected Attributes

TcpLwipConnectionconnM = nullptr
 
ChunkQueue dataBuffer
 

Detailed Description

TcpLwip receive queue.

Constructor & Destructor Documentation

◆ TcpLwipReceiveQueue()

inet::tcp::TcpLwipReceiveQueue::TcpLwipReceiveQueue ( )
99 {
100 }

◆ ~TcpLwipReceiveQueue()

inet::tcp::TcpLwipReceiveQueue::~TcpLwipReceiveQueue ( )
virtual
103 {
104  // nothing to do here
105 }

Member Function Documentation

◆ enqueueTcpLayerData()

void inet::tcp::TcpLwipReceiveQueue::enqueueTcpLayerData ( void *  dataP,
unsigned int  dataLengthP 
)
virtual

The method called when data received from LWIP The method should set status of the data in queue to received called after socket->read_data() successfull.

123 {
124  dataBuffer.push(makeShared<BytesChunk>(static_cast<uint8_t *>(dataP), dataLengthP));
125 }

Referenced by inet::tcp::TcpLwip::tcp_event_recv().

◆ extractBytesUpTo()

Packet * inet::tcp::TcpLwipReceiveQueue::extractBytesUpTo ( )
virtual

Should create a packet to be passed up to the app, up to (but NOT including) the given sequence no (usually rcv_nxt).

It should return nullptr if there's no more data to be passed up – this method is called several times until it returns nullptr.

called after socket->read_data() successfull

133 {
134  ASSERT(connM);
135 
136  Packet *dataMsg = nullptr;
137  b queueLength = dataBuffer.getLength();
138 
139  if (queueLength > b(0)) {
140  dataMsg = new Packet("DATA", TCP_I_DATA);
141  const auto& data = dataBuffer.pop<Chunk>(queueLength);
142  dataMsg->insertAtBack(data);
143  }
144 
145  return dataMsg;
146 }

Referenced by inet::tcp::TcpLwipConnection::sendUpData().

◆ getAmountOfBufferedBytes()

uint32_t inet::tcp::TcpLwipReceiveQueue::getAmountOfBufferedBytes ( ) const
virtual

Returns the number of bytes (out-of-order-segments) currently buffered in queue.

149 {
150  return B(dataBuffer.getLength()).get();
151 }

◆ getExtractableBytesUpTo()

unsigned long inet::tcp::TcpLwipReceiveQueue::getExtractableBytesUpTo ( ) const
virtual
128 {
129  return B(dataBuffer.getLength()).get();
130 }

◆ getQueueLength()

uint32_t inet::tcp::TcpLwipReceiveQueue::getQueueLength ( ) const
virtual

Returns the number of blocks currently buffered in queue.

154 {
155  return B(dataBuffer.getLength()).get();
156 }

◆ getQueueStatus()

void inet::tcp::TcpLwipReceiveQueue::getQueueStatus ( ) const
virtual

Shows current queue status.

159 {
160  // TODO
161 }

◆ notifyAboutIncomingSegmentProcessing()

void inet::tcp::TcpLwipReceiveQueue::notifyAboutIncomingSegmentProcessing ( Packet packet,
uint32_t  seqNo,
const void *  bufferP,
size_t  bufferLengthP 
)
virtual

Called when a TCP segment arrives, it should extract the payload from the segment and store it in the receive queue.

The segment object should not be deleted. //FIXME revise this comment

117 {
118  ASSERT(packet);
119  ASSERT(bufferP);
120 }

Referenced by inet::tcp::TcpLwip::notifyAboutIncomingSegmentProcessing().

◆ notifyAboutSending()

void inet::tcp::TcpLwipReceiveQueue::notifyAboutSending ( const TcpHeader tcpsegP)
virtual

notify the queue about output messages

called when connM send out a packet. for read AckNo, if have

164 {
165  // nothing to do
166 }

Referenced by inet::tcp::TcpLwipConnection::notifyAboutSending().

◆ setConnection()

void inet::tcp::TcpLwipReceiveQueue::setConnection ( TcpLwipConnection connP)
virtual

Add a connection queue.

108 {
109  ASSERT(connP);
110  ASSERT(connM == nullptr);
111 
112  dataBuffer.clear();
113  connM = connP;
114 }

Referenced by inet::tcp::TcpLwipConnection::initConnection().

Member Data Documentation

◆ connM

TcpLwipConnection* inet::tcp::TcpLwipReceiveQueue::connM = nullptr
protected

Referenced by extractBytesUpTo(), and setConnection().

◆ dataBuffer


The documentation for this class was generated from the following files:
inet::tcp::TcpLwipReceiveQueue::connM
TcpLwipConnection * connM
Definition: TcpLwipQueues.h:198
inet::tcp::TcpLwipReceiveQueue::dataBuffer
ChunkQueue dataBuffer
Definition: TcpLwipQueues.h:199
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::ChunkQueue::getLength
b getLength() const
Returns the total length of data currently available in the queue.
Definition: ChunkQueue.h:74
inet::ChunkQueue::push
void push(const Ptr< const Chunk > &chunk)
Inserts the provided chunk at the tail of the queue.
Definition: ChunkQueue.cc:85
inet::TCP_I_DATA
@ TCP_I_DATA
Definition: TcpCommand_m.h:125
inet::ChunkQueue::clear
void clear()
Erases all data from the queue.
Definition: ChunkQueue.cc:78
inet::ChunkQueue::pop
const Ptr< const Chunk > pop(b length=b(-1), int flags=0)
Pops the designated data and returns it as an immutable chunk in its current representation.
Definition: ChunkQueue.cc:69