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

Receive queue that manages "objects". More...

#include <TcpLwipMsgBasedQueues.h>

Inheritance diagram for inet::tcp::TcpLwipMsgBasedReceiveQueue:
inet::tcp::TcpLwipReceiveQueue

Classes

struct  PayloadItem
 

Public Member Functions

 TcpLwipMsgBasedReceiveQueue ()
 Ctor. More...
 
virtual ~TcpLwipMsgBasedReceiveQueue ()
 Virtual dtor. More...
 
virtual void setConnection (TcpLwipConnection *connP) override
 Set the connection. More...
 
virtual void notifyAboutIncomingSegmentProcessing (TCPSegment *tcpsegP, uint32 seqNo, const void *bufferP, size_t bufferLengthP) override
 called back from lwip::tcp_input() More...
 
virtual void enqueueTcpLayerData (void *dataP, unsigned int dataLengthP) override
 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() successful. More...
 
virtual cPacket * extractBytesUpTo () override
 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 getAmountOfBufferedBytes () const override
 Returns the number of bytes (out-of-order-segments) currently buffered in queue. More...
 
virtual uint32 getQueueLength () const override
 Returns the number of blocks currently buffered in queue. More...
 
virtual void getQueueStatus () const override
 Shows current queue status. More...
 
virtual void notifyAboutSending (const TCPSegment *tcpsegP) override
 notify the queue about output messages More...
 
- Public Member Functions inherited from inet::tcp::TcpLwipReceiveQueue
 TcpLwipReceiveQueue ()
 Ctor. More...
 
virtual ~TcpLwipReceiveQueue ()
 Virtual dtor. More...
 

Protected Types

typedef std::list< PayloadItemPayloadList
 

Protected Attributes

PayloadList payloadListM
 
bool isValidSeqNoM
 
uint32 lastExtractedSeqNoM
 
long int bytesInQueueM
 
- Protected Attributes inherited from inet::tcp::TcpLwipReceiveQueue
TcpLwipConnectionconnM
 

Detailed Description

Receive queue that manages "objects".

Member Typedef Documentation

Constructor & Destructor Documentation

inet::tcp::TcpLwipMsgBasedReceiveQueue::TcpLwipMsgBasedReceiveQueue ( )

Ctor.

180  :
181  bytesInQueueM(0)
182 {
183 }
long int bytesInQueueM
Definition: TcpLwipMsgBasedQueues.h:200
inet::tcp::TcpLwipMsgBasedReceiveQueue::~TcpLwipMsgBasedReceiveQueue ( )
virtual

Virtual dtor.

186 {
187  while (!payloadListM.empty()) {
188  delete payloadListM.front().packet;
189  payloadListM.pop_front();
190  }
191 }
PayloadList payloadListM
Definition: TcpLwipMsgBasedQueues.h:133

Member Function Documentation

void inet::tcp::TcpLwipMsgBasedReceiveQueue::enqueueTcpLayerData ( void *  dataP,
unsigned int  dataLengthP 
)
overridevirtual

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

Implements inet::tcp::TcpLwipReceiveQueue.

244 {
245  bytesInQueueM += dataLengthP;
246 }
long int bytesInQueueM
Definition: TcpLwipMsgBasedQueues.h:200
cPacket * inet::tcp::TcpLwipMsgBasedReceiveQueue::extractBytesUpTo ( )
overridevirtual

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

Implements inet::tcp::TcpLwipReceiveQueue.

249 {
250  ASSERT(connM);
251 
252  cPacket *dataMsg = nullptr;
253 
254  if (!isValidSeqNoM) {
255  isValidSeqNoM = true;
257 
258  if (connM->pcbM->state >= LwipTcpLayer::CLOSE_WAIT)
259  lastExtractedSeqNoM--; // received FIN
260  }
261 
262  uint32 firstSeqNo = lastExtractedSeqNoM;
263  uint32 lastSeqNo = firstSeqNo + bytesInQueueM;
264 
265  // remove old messages
266  while ((!payloadListM.empty()) && seqLE(payloadListM.front().seqNo, firstSeqNo)) {
267  EV_DEBUG << "Remove old payload MSG: seqno=" << payloadListM.front().seqNo
268  << ", len=" << payloadListM.front().packet->getByteLength() << endl;
269  delete payloadListM.front().packet;
270  payloadListM.erase(payloadListM.begin());
271  }
272 
273  // pass up payload messages, in sequence number order
274  if (!payloadListM.empty()) {
275  uint32 endSeqNo = payloadListM.front().seqNo;
276 
277  if (seqLE(endSeqNo, lastSeqNo)) {
278  dataMsg = payloadListM.front().packet;
279  uint32 dataLength = dataMsg->getByteLength();
280 
281  ASSERT(endSeqNo - dataLength == firstSeqNo);
282 
283  payloadListM.erase(payloadListM.begin());
284  lastExtractedSeqNoM += dataLength;
285  bytesInQueueM -= dataLength;
286 
287  dataMsg->setKind(TCP_I_DATA);
288  }
289  }
290 
291  return dataMsg;
292 }
long int bytesInQueueM
Definition: TcpLwipMsgBasedQueues.h:200
TcpLwipConnection * connM
Definition: TcpLwipQueues.h:216
LwipTcpLayer::tcp_pcb * pcbM
Definition: TcpLwipConnection.h:113
PayloadList payloadListM
Definition: TcpLwipMsgBasedQueues.h:133
bool seqLE(uint32 a, uint32 b)
Definition: TCPSegment.h:33
bool isValidSeqNoM
Definition: TcpLwipMsgBasedQueues.h:134
uint32_t uint32
Definition: Compat.h:30
Definition: TCPCommand_m.h:98
uint32 lastExtractedSeqNoM
Definition: TcpLwipMsgBasedQueues.h:135
uint32 inet::tcp::TcpLwipMsgBasedReceiveQueue::getAmountOfBufferedBytes ( ) const
overridevirtual

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

Implements inet::tcp::TcpLwipReceiveQueue.

295 {
296  return bytesInQueueM;
297 }
long int bytesInQueueM
Definition: TcpLwipMsgBasedQueues.h:200
uint32 inet::tcp::TcpLwipMsgBasedReceiveQueue::getQueueLength ( ) const
overridevirtual

Returns the number of blocks currently buffered in queue.

Implements inet::tcp::TcpLwipReceiveQueue.

300 {
301  return payloadListM.size();
302 }
PayloadList payloadListM
Definition: TcpLwipMsgBasedQueues.h:133
void inet::tcp::TcpLwipMsgBasedReceiveQueue::getQueueStatus ( ) const
overridevirtual

Shows current queue status.

Implements inet::tcp::TcpLwipReceiveQueue.

305 {
306  // TODO
307 }
void inet::tcp::TcpLwipMsgBasedReceiveQueue::notifyAboutIncomingSegmentProcessing ( TCPSegment tcpsegP,
uint32  seqNo,
const void *  bufferP,
size_t  bufferLengthP 
)
overridevirtual

called back from lwip::tcp_input()

Implements inet::tcp::TcpLwipReceiveQueue.

209 {
210  ASSERT(tcpsegP);
211  ASSERT(bufferP);
212  ASSERT(seqLE(tcpsegP->getSequenceNo(), seqNoP));
213  uint32 lastSeqNo = seqNoP + bufferLengthP;
214  ASSERT(seqGE(tcpsegP->getSequenceNo() + tcpsegP->getPayloadLength(), lastSeqNo));
215 
216  cPacket *msg;
217  uint32 endSeqNo;
218 
219  auto i = payloadListM.begin();
220  while ((msg = tcpsegP->removeFirstPayloadMessage(endSeqNo)) != nullptr) {
221  if (seqLess(seqNoP, endSeqNo) && seqLE(endSeqNo, lastSeqNo)
222  && (!isValidSeqNoM || seqLess(lastExtractedSeqNoM, endSeqNo)))
223  {
224  while (i != payloadListM.end() && seqLess(i->seqNo, endSeqNo))
225  ++i;
226 
227  // insert, avoiding duplicates
228  if (i != payloadListM.end() && i->seqNo == endSeqNo) {
229  ASSERT(msg->getByteLength() == i->packet->getByteLength());
230  delete msg;
231  }
232  else {
233  i = payloadListM.insert(i, PayloadItem(endSeqNo, msg));
234  ASSERT(seqLE(payloadListM.front().seqNo, payloadListM.back().seqNo));
235  }
236  }
237  else {
238  delete msg;
239  }
240  }
241 }
bool seqGE(uint32 a, uint32 b)
Definition: TCPSegment.h:35
bool seqLess(uint32 a, uint32 b)
Definition: TCPSegment.h:32
PayloadList payloadListM
Definition: TcpLwipMsgBasedQueues.h:133
bool seqLE(uint32 a, uint32 b)
Definition: TCPSegment.h:33
bool isValidSeqNoM
Definition: TcpLwipMsgBasedQueues.h:134
uint32_t uint32
Definition: Compat.h:30
uint32 lastExtractedSeqNoM
Definition: TcpLwipMsgBasedQueues.h:135
void inet::tcp::TcpLwipMsgBasedReceiveQueue::notifyAboutSending ( const TCPSegment tcpsegP)
overridevirtual

notify the queue about output messages

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

Implements inet::tcp::TcpLwipReceiveQueue.

310 {
311  // nothing to do
312 }
void inet::tcp::TcpLwipMsgBasedReceiveQueue::setConnection ( TcpLwipConnection connP)
overridevirtual

Set the connection.

Reimplemented from inet::tcp::TcpLwipReceiveQueue.

194 {
195  ASSERT(connP);
196 
197  bytesInQueueM = 0;
199  isValidSeqNoM = false;
201 
202  while (!payloadListM.empty()) {
203  delete payloadListM.front().packet;
204  payloadListM.pop_front();
205  }
206 }
long int bytesInQueueM
Definition: TcpLwipMsgBasedQueues.h:200
PayloadList payloadListM
Definition: TcpLwipMsgBasedQueues.h:133
bool isValidSeqNoM
Definition: TcpLwipMsgBasedQueues.h:134
virtual void setConnection(TcpLwipConnection *connP)
Add a connection queue.
Definition: TcpLwipQueues.h:164
uint32 lastExtractedSeqNoM
Definition: TcpLwipMsgBasedQueues.h:135

Member Data Documentation

long int inet::tcp::TcpLwipMsgBasedReceiveQueue::bytesInQueueM
protected
bool inet::tcp::TcpLwipMsgBasedReceiveQueue::isValidSeqNoM
protected
uint32 inet::tcp::TcpLwipMsgBasedReceiveQueue::lastExtractedSeqNoM
protected
PayloadList inet::tcp::TcpLwipMsgBasedReceiveQueue::payloadListM
protected

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