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

#include <SCTPReceiveStream.h>

Inheritance diagram for inet::sctp::SCTPReceiveStream:

Public Member Functions

uint32 enqueueNewDataChunk (SCTPDataVariables *dchunk)
 
 SCTPReceiveStream (SCTPAssociation *assoc)
 Ctor. More...
 
int32 getExpectedStreamSeqNum ()
 
void setExpectedStreamSeqNum (const int32 num)
 
 ~SCTPReceiveStream ()
 Virtual dtor. More...
 
SCTPQueuegetDeliveryQ () const
 
SCTPQueuegetOrderedQ () const
 
SCTPQueuegetUnorderedQ () const
 
int32 getStreamId () const
 
void setStreamId (const uint16 id)
 

Protected Member Functions

uint32 reassemble (SCTPQueue *queue, uint32 tsn)
 

Protected Attributes

SCTPAssociationassoc
 
uint16 streamId
 
int32 expectedStreamSeqNum
 
SCTPQueuedeliveryQ
 
SCTPQueueorderedQ
 
SCTPQueueunorderedQ
 

Constructor & Destructor Documentation

inet::sctp::SCTPReceiveStream::SCTPReceiveStream ( SCTPAssociation assoc)

Ctor.

28 {
29  streamId = 0;
31  deliveryQ = new SCTPQueue();
32  orderedQ = new SCTPQueue();
33  unorderedQ = new SCTPQueue();
34  assoc = assoc_;
35 }
SCTPQueue * orderedQ
Definition: SCTPReceiveStream.h:37
SCTPQueue * deliveryQ
Definition: SCTPReceiveStream.h:36
int32 expectedStreamSeqNum
Definition: SCTPReceiveStream.h:35
SCTPAssociation * assoc
Definition: SCTPReceiveStream.h:33
SCTPQueue * unorderedQ
Definition: SCTPReceiveStream.h:38
uint16 streamId
Definition: SCTPReceiveStream.h:34
inet::sctp::SCTPReceiveStream::~SCTPReceiveStream ( )

Virtual dtor.

38 {
39  delete deliveryQ;
40  delete orderedQ;
41  delete unorderedQ;
42 }
SCTPQueue * orderedQ
Definition: SCTPReceiveStream.h:37
SCTPQueue * deliveryQ
Definition: SCTPReceiveStream.h:36
SCTPQueue * unorderedQ
Definition: SCTPReceiveStream.h:38

Member Function Documentation

uint32 inet::sctp::SCTPReceiveStream::enqueueNewDataChunk ( SCTPDataVariables dchunk)
100 {
101  uint32 delivery = 0; //0:orderedQ=false && deliveryQ=false; 1:orderedQ=true && deliveryQ=false; 2:oderedQ=true && deliveryQ=true; 3:fragment
102 
103  SCTPDataVariables *chunk;
104  /* Enqueueing NEW data chunk. Append it to the respective queue */
105 
106  // ====== Unordered delivery =============================================
107  if (!dchunk->ordered) {
108  if (dchunk->bbit && dchunk->ebit) {
109  /* put message into deliveryQ */
110  if (deliveryQ->checkAndInsertChunk(dchunk->tsn, dchunk)) {
111  delivery = 2;
112  }
113  } else {
114  if (unorderedQ->checkAndInsertChunk(dchunk->tsn, dchunk)) {
115  delivery = 3;
116  }
117 
118  /* try to reassemble here */
119  uint32 reassembled = reassemble(unorderedQ, dchunk->tsn);
120 
121  if ((unorderedQ->getChunk(reassembled))->bbit && (unorderedQ->getChunk(reassembled))->bbit) {
122  /* put message into deliveryQ */
123  if (deliveryQ->checkAndInsertChunk(reassembled, unorderedQ->getAndExtractChunk(reassembled))) {
124  delivery = 2;
125  }
126  }
127  }
128  }
129  // ====== Ordered delivery ===============================================
130  else if (dchunk->ordered) {
131  /* put message into orderedQ */
132  if (orderedQ->checkAndInsertChunk(dchunk->tsn, dchunk))
133  delivery = 1;
134 
135  if (!dchunk->bbit || !dchunk->ebit) {
136  delivery = 3;
137  /* try to reassemble */
138  reassemble(orderedQ, dchunk->tsn);
139  }
140 
141  if (orderedQ->getQueueSize() > 0) {
142  /* dequeue first from orderedQ */
144  if (chunk) {
145  if (deliveryQ->checkAndInsertChunk(chunk->tsn, chunk)) {
147  if (expectedStreamSeqNum > 65535)
149  delivery = 2;
150  }
151  }
152  }
153  }
154 
155  return delivery;
156 }
SCTPQueue * orderedQ
Definition: SCTPReceiveStream.h:37
SCTPQueue * deliveryQ
Definition: SCTPReceiveStream.h:36
int32 expectedStreamSeqNum
Definition: SCTPReceiveStream.h:35
SCTPDataVariables * getAndExtractChunk(const uint32 tsn)
Definition: SCTPQueue.cc:76
SCTPDataVariables * getChunk(const uint32 key) const
Definition: SCTPQueue.cc:123
bool checkAndInsertChunk(const uint32 key, SCTPDataVariables *chunk)
Definition: SCTPQueue.cc:50
uint32_t uint32
Definition: Compat.h:30
uint32 getQueueSize() const
Definition: SCTPQueue.cc:60
SCTPQueue * unorderedQ
Definition: SCTPReceiveStream.h:38
uint32 reassemble(SCTPQueue *queue, uint32 tsn)
Definition: SCTPReceiveStream.cc:44
SCTPDataVariables * dequeueChunkBySSN(const uint16 ssn)
Definition: SCTPQueue.cc:186
SCTPQueue* inet::sctp::SCTPReceiveStream::getDeliveryQ ( ) const
inline
int32 inet::sctp::SCTPReceiveStream::getExpectedStreamSeqNum ( )
int32 inet::sctp::SCTPReceiveStream::getStreamId ( ) const
inline

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

58 { return streamId; };
uint16 streamId
Definition: SCTPReceiveStream.h:34
SCTPQueue* inet::sctp::SCTPReceiveStream::getUnorderedQ ( ) const
inline

Referenced by inet::sctp::SCTPAssociation::calculateRcvBuffer(), and inet::sctp::SCTPAssociation::makeRoomForTsn().

56 { return unorderedQ; };
SCTPQueue * unorderedQ
Definition: SCTPReceiveStream.h:38
uint32 inet::sctp::SCTPReceiveStream::reassemble ( SCTPQueue queue,
uint32  tsn 
)
protected

Referenced by enqueueNewDataChunk().

45 {
46  uint32 begintsn = tsn, endtsn = 0;
47 
48  EV_INFO << "Trying to reassemble message..." << endl;
49 
50  /* test if we have all fragments down to the first */
51  while (queue->getChunk(begintsn) && !(queue->getChunk(begintsn))->bbit)
52  begintsn--;
53 
54  if (queue->getChunk(begintsn)) {
55  endtsn = begintsn;
56 
57  /* test if we have all fragments up to the end */
58  while (queue->getChunk(endtsn) && !(queue->getChunk(endtsn))->ebit)
59  endtsn++;
60 
61  if (queue->getChunk(endtsn)) {
62  EV_INFO << "All fragments found, now reassembling..." << endl;
63 
64  SCTPDataVariables *firstVar = queue->getChunk(begintsn), *processVar;
65  SCTPSimpleMessage *firstSimple = check_and_cast<SCTPSimpleMessage *>(firstVar->userData);
66 
67  EV_INFO << "First fragment has " << firstVar->len / 8 << " bytes." << endl;
68 
69  while (++begintsn <= endtsn) {
70  processVar = queue->getAndExtractChunk(begintsn);
71  SCTPSimpleMessage *processSimple = check_and_cast<SCTPSimpleMessage *>(processVar->userData);
72 
73  EV_INFO << "Adding fragment with " << processVar->len / 8 << " bytes." << endl;
74 
75  if ((firstSimple->getDataArraySize() > 0) && (processSimple->getDataArraySize() > 0)) {
76  firstSimple->setDataArraySize(firstSimple->getDataArraySize() + processSimple->getDataArraySize());
77  firstSimple->setDataLen(firstSimple->getDataLen() + processSimple->getDataLen());
78  firstSimple->setByteLength(firstSimple->getByteLength() + processSimple->getByteLength());
79  /* copy data */
80  for (uint32 i = 0; i < (processVar->len / 8); i++)
81  firstSimple->setData(i + (firstVar->len / 8), processSimple->getData(i));
82  }
83 
84  firstVar->len += processVar->len;
85 
86  delete processVar->userData;
87  delete processVar;
88  }
89 
90  firstVar->ebit = 1;
91 
92  EV_INFO << "Reassembly done. Length=" << firstVar->len << "\n";
93  return firstVar->tsn;
94  }
95  }
96  return tsn;
97 }
uint32_t uint32
Definition: Compat.h:30
void inet::sctp::SCTPReceiveStream::setExpectedStreamSeqNum ( const int32  num)
void inet::sctp::SCTPReceiveStream::setStreamId ( const uint16  id)
inline

Referenced by inet::sctp::SCTPAssociation::addInStreams(), and inet::sctp::SCTPAssociation::initStreams().

59 { streamId = id; };
uint16_t id
Definition: TCP_NSC.cc:85
uint16 streamId
Definition: SCTPReceiveStream.h:34

Member Data Documentation

SCTPAssociation* inet::sctp::SCTPReceiveStream::assoc
protected

Referenced by SCTPReceiveStream().

SCTPQueue* inet::sctp::SCTPReceiveStream::deliveryQ
protected
int32 inet::sctp::SCTPReceiveStream::expectedStreamSeqNum
protected
SCTPQueue* inet::sctp::SCTPReceiveStream::orderedQ
protected
uint16 inet::sctp::SCTPReceiveStream::streamId
protected

Referenced by SCTPReceiveStream().

SCTPQueue* inet::sctp::SCTPReceiveStream::unorderedQ
protected

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