INET Framework for OMNeT++/OMNEST
inet::sctp::SCTPQueue Class Reference

Abstract base class for SCTP receive queues. More...

#include <SCTPQueue.h>

Inheritance diagram for inet::sctp::SCTPQueue:

Public Types

typedef std::map< uint32, SCTPDataVariables * > PayloadQueue
 

Public Member Functions

 SCTPQueue ()
 Constructor. More...
 
 SCTPQueue (SCTPAssociation *assoc)
 
 ~SCTPQueue ()
 Virtual destructor. More...
 
bool checkAndInsertChunk (const uint32 key, SCTPDataVariables *chunk)
 
SCTPDataVariablesgetAndExtractChunk (const uint32 tsn)
 
SCTPDataVariablesextractMessage ()
 
void printQueue () const
 
uint32 getQueueSize () const
 
SCTPDataVariablesgetFirstChunk () const
 
cMessage * getMsg (const uint32 key) const
 
SCTPDataVariablesgetChunk (const uint32 key) const
 
SCTPDataVariablesgetChunkFast (const uint32 tsn, bool &firstTime)
 
void removeMsg (const uint32 key)
 
bool deleteMsg (const uint32 tsn)
 
int32 getNumBytes () const
 
SCTPDataVariablesdequeueChunkBySSN (const uint16 ssn)
 
uint32 getSizeOfFirstChunk (const L3Address &remoteAddress)
 
uint16 getFirstSsnInQueue (const uint16 sid)
 
void findEarliestOutstandingTSNsForPath (const L3Address &remoteAddress, uint32 &earliestOutstandingTSN, uint32 &rtxEarliestOutstandingTSN) const
 

Public Attributes

PayloadQueue payloadQueue
 

Protected Attributes

SCTPAssociationassoc
 

Private Attributes

PayloadQueue::iterator GetChunkFastIterator
 

Detailed Description

Abstract base class for SCTP receive queues.

This class represents data received by SCTP but not yet passed up to the application. The class also accomodates for selective retransmission, i.e. also acts as a segment buffer.

This class goes hand-in-hand with SCTPSendQueue.

This class is polymorphic because depending on where and how you use the SCTP model you might have different ideas about "sending data" on a simulated connection: you might want to transmit real bytes, "dummy" (byte count only), cMessage objects, etc; see discussion at SCTPSendQueue. Different subclasses can be written to accomodate different needs.

See also
SCTPSendQueue

Member Typedef Documentation

Constructor & Destructor Documentation

inet::sctp::SCTPQueue::SCTPQueue ( )

Constructor.

29 {
30  assoc = nullptr;
31 }
SCTPAssociation * assoc
Definition: SCTPQueue.h:104
inet::sctp::SCTPQueue::SCTPQueue ( SCTPAssociation assoc)
34 {
35  assoc = assoc_;
36 }
SCTPAssociation * assoc
Definition: SCTPQueue.h:104
inet::sctp::SCTPQueue::~SCTPQueue ( )

Virtual destructor.

39 {
40  for (auto & elem : payloadQueue)
41  {
42  SCTPDataVariables *chunk = elem.second;
43  delete chunk->userData;
44  }
45  if (!payloadQueue.empty()) {
46  payloadQueue.clear();
47  }
48 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101

Member Function Documentation

bool inet::sctp::SCTPQueue::checkAndInsertChunk ( const uint32  key,
SCTPDataVariables chunk 
)
bool inet::sctp::SCTPQueue::deleteMsg ( const uint32  tsn)

Referenced by inet::sctp::SCTPAssociation::makeRoomForTsn().

164 {
165  auto iterator = payloadQueue.find(tsn);
166  if (iterator != payloadQueue.end()) {
167  SCTPDataVariables *chunk = iterator->second;
168  cMessage *msg = check_and_cast<cMessage *>(chunk->userData);
169  delete msg;
170  payloadQueue.erase(iterator);
171  return true;
172  }
173  return false;
174 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
SCTPDataVariables * inet::sctp::SCTPQueue::dequeueChunkBySSN ( const uint16  ssn)

Referenced by inet::sctp::SCTPReceiveStream::enqueueNewDataChunk(), and inet::sctp::SCTPAssociation::putInDeliveryQ().

187 {
188  for (auto iterator = payloadQueue.begin();
189  iterator != payloadQueue.end(); iterator++)
190  {
191  SCTPDataVariables *chunk = iterator->second;
192  if ((iterator->second->ssn == ssn) &&
193  (iterator->second->bbit) &&
194  (iterator->second->ebit))
195  {
196  payloadQueue.erase(iterator);
197  return chunk;
198  }
199  }
200  return nullptr;
201 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
SCTPDataVariables * inet::sctp::SCTPQueue::extractMessage ( )

Referenced by inet::sctp::SCTPAssociation::pushUlp().

66 {
67  if (!payloadQueue.empty()) {
68  auto iterator = payloadQueue.begin();
69  SCTPDataVariables *chunk = iterator->second;
70  payloadQueue.erase(iterator);
71  return chunk;
72  }
73  return nullptr;
74 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
void inet::sctp::SCTPQueue::findEarliestOutstandingTSNsForPath ( const L3Address remoteAddress,
uint32 earliestOutstandingTSN,
uint32 rtxEarliestOutstandingTSN 
) const

Referenced by inet::sctp::SCTPAssociation::checkPseudoCumAck().

211 {
212  bool findEarliestOutstandingTSN = true;
213  bool findRTXEarliestOutstandingTSN = true;
214 
215  for (const auto & elem : payloadQueue)
216  {
217  const SCTPDataVariables *chunk = elem.second;
218  if (chunk->getLastDestination() == remoteAddress) {
219  // ====== Find earliest outstanding TSNs ===========================
220  if (chunk->hasBeenAcked == false) {
221  if ((findEarliestOutstandingTSN) &&
222  (chunk->numberOfRetransmissions == 0))
223  {
224  earliestOutstandingTSN = chunk->tsn;
225  }
226  findEarliestOutstandingTSN = false;
227  if ((findRTXEarliestOutstandingTSN) &&
228  (chunk->numberOfRetransmissions > 0))
229  {
230  rtxEarliestOutstandingTSN = chunk->tsn;
231  }
232  findRTXEarliestOutstandingTSN = false;
233  }
234  }
235  }
236 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
SCTPDataVariables * inet::sctp::SCTPQueue::getAndExtractChunk ( const uint32  tsn)

Referenced by inet::sctp::SCTPReceiveStream::enqueueNewDataChunk(), inet::sctp::SCTPAssociation::nonRenegablyAckChunk(), and inet::sctp::SCTPReceiveStream::reassemble().

77 {
78  if (!payloadQueue.empty()) {
79  auto iterator = payloadQueue.find(tsn);
80  SCTPDataVariables *chunk = iterator->second;
81  payloadQueue.erase(iterator);
82  return chunk;
83  }
84  return nullptr;
85 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
SCTPDataVariables * inet::sctp::SCTPQueue::getChunk ( const uint32  key) const
SCTPDataVariables * inet::sctp::SCTPQueue::getChunkFast ( const uint32  tsn,
bool &  firstTime 
)

Referenced by inet::sctp::SCTPAssociation::processSackArrived().

134 {
135  if (!firstTime) {
136  if (GetChunkFastIterator != payloadQueue.end()) {
137  SCTPDataVariables *chunk = GetChunkFastIterator->second;
138  if (chunk->tsn == tsn) {
140  return chunk; // Found the right TSN!
141  }
142  }
143  // TSN not found -> needs regular TSN lookup.
144  }
145 
147  if (GetChunkFastIterator != payloadQueue.end()) {
148  SCTPDataVariables *chunk = GetChunkFastIterator->second;
150  firstTime = false;
151  return chunk;
152  }
153 
154  return nullptr;
155 }
PayloadQueue::iterator GetChunkFastIterator
Definition: SCTPQueue.h:107
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
SCTPDataVariables * inet::sctp::SCTPQueue::getFirstChunk ( ) const
106 {
107  PayloadQueue::const_iterator iterator = payloadQueue.begin();
108  SCTPDataVariables *chunk = iterator->second;
109  return chunk;
110 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
uint16 inet::sctp::SCTPQueue::getFirstSsnInQueue ( const uint16  sid)

Referenced by inet::sctp::SCTPAssociation::processForwardTsnArrived().

204 {
205  return payloadQueue.begin()->second->ssn;
206 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
cMessage * inet::sctp::SCTPQueue::getMsg ( const uint32  key) const
113 {
114  PayloadQueue::const_iterator iterator = payloadQueue.find(tsn);
115  if (iterator != payloadQueue.end()) {
116  SCTPDataVariables *chunk = iterator->second;
117  cMessage *msg = check_and_cast<cMessage *>(chunk->userData);
118  return msg;
119  }
120  return nullptr;
121 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
int32 inet::sctp::SCTPQueue::getNumBytes ( ) const
177 {
178  int32 qb = 0;
179  for (const auto & elem : payloadQueue)
180  {
181  qb += (elem.second->len / 8);
182  }
183  return qb;
184 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
int32_t int32
Definition: Compat.h:31
uint32 inet::sctp::SCTPQueue::getSizeOfFirstChunk ( const L3Address remoteAddress)

Referenced by inet::sctp::SCTPAssociation::sendOnPath().

239 {
240  for (PayloadQueue::const_iterator iterator = payloadQueue.begin();
241  iterator != payloadQueue.end(); ++iterator)
242  {
243  const SCTPDataVariables *chunk = iterator->second;
244  if (chunk->getNextDestination() == remoteAddress) {
245  return chunk->booksize;
246  }
247  }
248  return 0;
249 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
void inet::sctp::SCTPQueue::printQueue ( ) const
88 {
89  EV_DEBUG << "Queue contents:\n";
90  for (const auto & elem : payloadQueue)
91  {
92  const uint32 key = elem.first;
93  const SCTPDataVariables *chunk = elem.second;
94  EV_DEBUG << key << ":\t"
95  << "lastDestination=" << chunk->getLastDestination()
96  << " nextDestination=" << chunk->getNextDestination()
97  << " hasBeenAcked=" << chunk->hasBeenAcked
98  << " countsAsOutstanding=" << chunk->countsAsOutstanding
99  << " numberOfRetransmissions=" << chunk->numberOfRetransmissions
100  << endl;
101  }
102  EV_DEBUG << endl;
103 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101
uint32_t uint32
Definition: Compat.h:30
void inet::sctp::SCTPQueue::removeMsg ( const uint32  key)

Referenced by inet::sctp::SCTPAssociation::nonRenegablyAckChunk(), and inet::sctp::SCTPAssociation::renegablyAckChunk().

158 {
159  auto iterator = payloadQueue.find(tsn);
160  payloadQueue.erase(iterator);
161 }
PayloadQueue payloadQueue
Definition: SCTPQueue.h:101

Member Data Documentation

SCTPAssociation* inet::sctp::SCTPQueue::assoc
protected

Referenced by SCTPQueue().

PayloadQueue::iterator inet::sctp::SCTPQueue::GetChunkFastIterator
private

Referenced by getChunkFast().


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