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

#include <SCTPGapList.h>

Public Member Functions

 SCTPSimpleGapList ()
 
 ~SCTPSimpleGapList ()
 
void check (const uint32 cTsnAck) const
 
void print (std::ostream &os) const
 
uint32 getNumGaps () const
 
uint32 getGapStart (const uint32 index) const
 
uint32 getGapStop (const uint32 index) const
 
bool tsnInGapList (const uint32 tsn) const
 
void forwardCumAckTSN (const uint32 cTsnAck)
 
bool tryToAdvanceCumAckTSN (uint32 &cTsnAck)
 
void removeFromGapList (const uint32 removedTSN)
 
bool updateGapList (const uint32 receivedTSN, uint32 &cTsnAck, bool &newChunkReceived)
 
void resetGaps ()
 

Private Attributes

uint32 NumGaps
 
uint32 GapStartList [MAX_GAP_COUNT]
 
uint32 GapStopList [MAX_GAP_COUNT]
 

Constructor & Destructor Documentation

inet::sctp::SCTPSimpleGapList::SCTPSimpleGapList ( )
28 {
29  NumGaps = 0;
30  for (unsigned int i = 0; i < MAX_GAP_COUNT; i++) {
31  GapStartList[i] = 0xffff00ff;
32  GapStopList[i] = 0xffff0000;
33  }
34 }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
#define MAX_GAP_COUNT
Definition: SCTPGapList.h:32
uint32 NumGaps
Definition: SCTPGapList.h:72
inet::sctp::SCTPSimpleGapList::~SCTPSimpleGapList ( )
38 {
39 }

Member Function Documentation

void inet::sctp::SCTPSimpleGapList::check ( const uint32  cTsnAck) const
43 {
44  for (uint32 i = 0; i < NumGaps; i++) {
45  if (i == 0) {
46  assert(SCTPAssociation::tsnGt(GapStartList[i], cTsnAck + 1));
47  }
48  else {
49  assert(SCTPAssociation::tsnGt(GapStartList[i], GapStopList[i - 1] + 1));
50  }
52  }
53 }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
uint32 NumGaps
Definition: SCTPGapList.h:72
static int32 tsnLe(const uint32 tsn1, const uint32 tsn2)
Definition: SCTPAssociation.h:1082
uint32_t uint32
Definition: Compat.h:30
static int32 tsnGt(const uint32 tsn1, const uint32 tsn2)
Definition: SCTPAssociation.h:1081
void inet::sctp::SCTPSimpleGapList::forwardCumAckTSN ( const uint32  cTsnAck)
90 {
91  if (NumGaps > 0) {
92  // It is only possible to advance CumAckTSN when there are gaps.
93  uint32 counter = 0;
94  uint32 advance = 0;
95  while (counter < NumGaps) {
96  // Check whether CumAckTSN can be advanced.
97  if (SCTPAssociation::tsnGe(cTsnAck, GapStartList[counter])) { // Yes!
98  advance++;
99  }
100  else { // No -> end of search.
101  break;
102  }
103  counter++;
104  }
105 
106  if (advance > 0) {
107  // We can remove "advance" block now.
108  for (uint32 i = advance; i < NumGaps; i++) {
109  GapStartList[i - advance] = GapStartList[i];
110  GapStopList[i - advance] = GapStopList[i];
111  }
112  NumGaps -= advance;
113  }
114  }
115 }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
uint32 NumGaps
Definition: SCTPGapList.h:72
uint32_t uint32
Definition: Compat.h:30
static int32 tsnGe(const uint32 tsn1, const uint32 tsn2)
Definition: SCTPAssociation.h:1080
uint32 inet::sctp::SCTPSimpleGapList::getGapStart ( const uint32  index) const
inline
49  {
50  assert(index < NumGaps);
51  return GapStartList[index];
52  }
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
uint32 NumGaps
Definition: SCTPGapList.h:72
uint32 inet::sctp::SCTPSimpleGapList::getGapStop ( const uint32  index) const
inline
55  {
56  assert(index < NumGaps);
57  return GapStopList[index];
58  }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 NumGaps
Definition: SCTPGapList.h:72
uint32 inet::sctp::SCTPSimpleGapList::getNumGaps ( ) const
inline
44  {
45  return NumGaps;
46  }
uint32 NumGaps
Definition: SCTPGapList.h:72
void inet::sctp::SCTPSimpleGapList::print ( std::ostream &  os) const

Referenced by inet::sctp::operator<<().

66 {
67  os << "{";
68  for (uint32 i = 0; i < NumGaps; i++) {
69  if (i > 0) {
70  os << ",";
71  }
72  os << " " << GapStartList[i] << "-" << GapStopList[i];
73  }
74  os << " }";
75 }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
uint32 NumGaps
Definition: SCTPGapList.h:72
uint32_t uint32
Definition: Compat.h:30
void inet::sctp::SCTPSimpleGapList::removeFromGapList ( const uint32  removedTSN)
143 {
144  const int32 initialNumGaps = NumGaps;
145 
146  for (int32 i = initialNumGaps - 1; i >= 0; i--) {
147  if (SCTPAssociation::tsnBetween(GapStartList[i], removedTSN, GapStopList[i])) {
148  // ====== Gap block contains more than one TSN =====================
149  const int32 gapsize = (int32)(GapStopList[i] - GapStartList[i] + 1);
150  if (gapsize > 1) {
151  if (GapStopList[i] == removedTSN) { // Remove stop TSN
152  GapStopList[i]--;
153  }
154  else if (GapStartList[i] == removedTSN) { // Remove start TSN
155  GapStartList[i]++;
156  }
157  else { // Block has to be splitted up
158  NumGaps = std::min(NumGaps + 1, (uint32)MAX_GAP_COUNT); // Enforce upper limit!
159  for (int32 j = NumGaps - 1; j > i; j--) {
160  GapStopList[j] = GapStopList[j - 1];
161  GapStartList[j] = GapStartList[j - 1];
162  }
163  GapStopList[i] = removedTSN - 1;
164  if ((uint32)i + 1 < NumGaps) {
165  GapStartList[i + 1] = removedTSN + 1;
166  }
167  }
168  }
169  // ====== Just a single TSN in the gap block (start==stop) =========
170  else {
171  for (int32 j = i; j <= initialNumGaps - 1; j++) {
172  GapStopList[j] = GapStopList[j + 1];
173  GapStartList[j] = GapStartList[j + 1];
174  }
175  GapStartList[initialNumGaps - 1] = 0;
176  GapStopList[initialNumGaps - 1] = 0;
177  NumGaps--;
178  }
179 
180  break; // TSN removed -> done!
181  }
182  }
183 }
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
#define MAX_GAP_COUNT
Definition: SCTPGapList.h:32
uint32 NumGaps
Definition: SCTPGapList.h:72
static int32 tsnBetween(const uint32 tsn1, const uint32 midtsn, const uint32 tsn2)
Definition: SCTPAssociation.h:1084
int32_t int32
Definition: Compat.h:31
uint32_t uint32
Definition: Compat.h:30
void inet::sctp::SCTPSimpleGapList::resetGaps ( )
56 {
57  NumGaps = 0;
58  for (unsigned int i = 0; i < MAX_GAP_COUNT; i++) {
59  GapStartList[i] = 0xffff00ff;
60  GapStopList[i] = 0xffff0000;
61  }
62 }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
#define MAX_GAP_COUNT
Definition: SCTPGapList.h:32
uint32 NumGaps
Definition: SCTPGapList.h:72
bool inet::sctp::SCTPSimpleGapList::tryToAdvanceCumAckTSN ( uint32 cTsnAck)
119 {
120  bool progress = false;
121  if (NumGaps > 0) {
122  // It is only possible to advance CumAckTSN when there are gaps.
123  uint32 counter = 0;
124  while (counter < NumGaps) {
125  // Check whether CumAckTSN can be advanced.
126  if (cTsnAck + 1 == GapStartList[0]) { // Yes!
127  cTsnAck = GapStopList[0];
128  // We can take out all fragments of this block
129  for (uint32 i = 1; i < NumGaps; i++) {
130  GapStartList[i - 1] = GapStartList[i];
131  GapStopList[i - 1] = GapStopList[i];
132  }
133  progress = true;
134  }
135  counter++;
136  }
137  }
138  return progress;
139 }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
uint32 NumGaps
Definition: SCTPGapList.h:72
uint32_t uint32
Definition: Compat.h:30
bool inet::sctp::SCTPSimpleGapList::tsnInGapList ( const uint32  tsn) const
79 {
80  for (uint32 i = 0; i < NumGaps; i++) {
82  return true;
83  }
84  }
85  return false;
86 }
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
uint32 NumGaps
Definition: SCTPGapList.h:72
static int32 tsnBetween(const uint32 tsn1, const uint32 midtsn, const uint32 tsn2)
Definition: SCTPAssociation.h:1084
uint32_t uint32
Definition: Compat.h:30
bool inet::sctp::SCTPSimpleGapList::updateGapList ( const uint32  receivedTSN,
uint32 cTsnAck,
bool &  newChunkReceived 
)

TSN either sits at the end of one gap, and thus changes gap boundaries, or it is in between two gaps, and becomes a new gap

189 {
190  if (SCTPAssociation::tsnLe(receivedTSN, cTsnAck)) {
191  // Received TSN covered by CumAckTSN -> nothing to do.
192  return false;
193  }
194 
195  uint32 lo = cTsnAck + 1;
196  for (uint32 i = 0; i < NumGaps; i++) {
197  if (GapStartList[i] > 0) {
198  const uint32 hi = GapStartList[i] - 1;
199  if (SCTPAssociation::tsnBetween(lo, receivedTSN, hi)) {
200  const uint32 gapsize = hi - lo + 1;
201  if (gapsize > 1) {
206  if (receivedTSN == hi) {
207  GapStartList[i] = receivedTSN;
208  newChunkReceived = true;
209  return true;
210  }
211  else if (receivedTSN == lo) {
212  if (receivedTSN == (cTsnAck + 1)) {
213  cTsnAck++;
214  newChunkReceived = true;
215  return true;
216  }
217  /* some gap must increase its upper bound */
218  GapStopList[i - 1] = receivedTSN;
219  newChunkReceived = true;
220  return true;
221  }
222  else { /* a gap in between */
223  NumGaps = std::min(NumGaps + 1, (uint32)MAX_GAP_COUNT); // Enforce upper limit!
224 
225  for (uint32 j = NumGaps - 1; j > i; j--) {
226  GapStartList[j] = GapStartList[j - 1];
227  GapStopList[j] = GapStopList[j - 1];
228  }
229  GapStartList[i] = receivedTSN;
230  GapStopList[i] = receivedTSN;
231  newChunkReceived = true;
232  return true;
233  }
234  }
235  else { /* alright: gapsize is 1: our received tsn may close gap between fragments */
236  if (lo == cTsnAck + 1) {
237  cTsnAck = GapStopList[i];
238  if (i == NumGaps - 1) {
239  GapStartList[i] = 0;
240  GapStopList[i] = 0;
241  }
242  else {
243  for (uint32 j = i; j < NumGaps - 1; j++) {
244  GapStartList[j] = GapStartList[j + 1];
245  GapStopList[j] = GapStopList[j + 1];
246  }
247  }
248  NumGaps--;
249  newChunkReceived = true;
250  return true;
251  }
252  else {
253  GapStopList[i - 1] = GapStopList[i];
254  if (i == NumGaps - 1) {
255  GapStartList[i] = 0;
256  GapStopList[i] = 0;
257  }
258  else {
259  for (uint32 j = i; j < NumGaps - 1; j++) {
260  GapStartList[j] = GapStartList[j + 1];
261  GapStopList[j] = GapStopList[j + 1];
262  }
263  }
264  NumGaps--;
265  newChunkReceived = true;
266  return true;
267  }
268  }
269  }
270  else { /* receivedTSN is not in the gap between these fragments... */
271  lo = GapStopList[i] + 1;
272  }
273  } /* end: for */
274  } /* end: for */
275 
276  // ====== We have reached the end of the list ============================
277  if (receivedTSN == lo) { // just increase CumAckTSN, handle further update of CumAckTSN later
278  if (receivedTSN == cTsnAck + 1) {
279  cTsnAck = receivedTSN;
280  newChunkReceived = true;
281  return true;
282  }
283  // Update last fragment, stop TSN by one.
284  GapStopList[NumGaps - 1]++;
285 
286  newChunkReceived = true;
287  return true;
288  }
289  else {
290  // If the received TSN is new, the list is either empty or the received
291  // TSN is larger than the last gap end + 1. Otherwise, the TSN has already
292  // been acknowledged.
293  if ((NumGaps == 0) ||
294  (SCTPAssociation::tsnGt(receivedTSN, GapStopList[NumGaps - 1] + 1)))
295  {
296  // A new fragment altogether, past the end of the list
297  if (NumGaps < MAX_GAP_COUNT) { // T.D. 18.12.09: Enforce upper limit!
298  GapStartList[NumGaps] = receivedTSN;
299  GapStopList[NumGaps] = receivedTSN;
300  NumGaps++;
301  newChunkReceived = true;
302  }
303  }
304  return true;
305  }
306 
307  return false;
308 }
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
uint32 GapStopList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:74
uint32 GapStartList[MAX_GAP_COUNT]
Definition: SCTPGapList.h:73
#define MAX_GAP_COUNT
Definition: SCTPGapList.h:32
uint32 NumGaps
Definition: SCTPGapList.h:72
static int32 tsnBetween(const uint32 tsn1, const uint32 midtsn, const uint32 tsn2)
Definition: SCTPAssociation.h:1084
static int32 tsnLe(const uint32 tsn1, const uint32 tsn2)
Definition: SCTPAssociation.h:1082
uint32_t uint32
Definition: Compat.h:30
static int32 tsnGt(const uint32 tsn1, const uint32 tsn2)
Definition: SCTPAssociation.h:1081

Member Data Documentation


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