RINASim  October 2016
Documentation of framework for OMNeT++
DTCPState.h
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 /*
24  * @file DTCPState.h
25  * @author Marcel Marek (imarek@fit.vutbr.cz)
26  * @date May 3, 2014
27  * @brief
28  * @detail
29  */
30 
31 #ifndef DTCPSTATE_H_
32 #define DTCPSTATE_H_
33 
34 #include <omnetpp.h>
35 #include "Utils.h"
36 #include <DTCPTimers_m.h>
37 
38 /*
39  *
40  */
41 class DTCPState : public cSimpleModule
42 {
43  private:
44  bool winBased;
45  bool rateBased;
46  bool rxPresent;
48 // bool setDRFFlag; // This Boolean indicates that the next PDU sent should have the DRF Flag set.
49 // bool immediate; //If Retransmission Control is present, this Boolean indicates whether Acks are sent immediately or after the A timer expires, or if DTCP is not present that there is no delay to allow late packets to arrive.
50  unsigned int sndLeftWinEdge;
51  unsigned int sndRightWinEdge;
52  unsigned int rcvRightWinEdge; //The absolute value of the credit on this flow.
53  unsigned int rcvRightWinEdgeSent;
54 // unsigned int rtt;
55  unsigned int rcvCredit; // Size of the receiver's window (local value)
56  unsigned int sndCredit; // Size of the sender's window (desired value from remote end)
57 
58 
59 // unsigned int controlSeqNum; //sequence number for ControlPDUs
60  /* Moved from RX */
61  unsigned int nextSenderControlSeqNum; //This state variable will contain the Sequence Number to be assigned to a Control PDU sent on this connection.
62  unsigned int lastControlSeqNumRcv; // - This state variable contains the sequence number of the next expected Transfer PDU received on this connection.
63  unsigned int lastControlSeqNumSent;
64 
65  unsigned int dataReXmitMax; // The maximum number of retransmissions of PDUs without a positive acknowledgment that will be tried before declaring an error.
66 
67  /* Moved from FC */
68  unsigned long timeUnit; //This field contains the unit of time in milliseconds over which the rate is computed.
69  unsigned int sendingRate; // This variable contains the number of PDUs that may be sent in one Time Unit. The rate is defined such that the sender may send the specified number of PDUs in that unit of time. Thus, the rate will not necessarily generate a steady flow, but may exhibit a bursty pattern.
70 
71  unsigned int pdusSentInTimeUnit; //This variable contains the number of PDUs sent in this Time Unit. When PDUsSentinTimeUnit equals SndrRate, the sender must wait for the beginning of a new time unit before additional PDUs may be sent.
72  unsigned long sendingTimeUnit; //The time period used to measure the SendingRate (measured in milliseconds).
73 
74  /* Without getters/setters */
75  unsigned int sendBytesFree; // The number of bytes that this flow can assume it has available for Writes.
76  unsigned int sendBytesPercentFree; // The percent of bytes that are free for Writes.
77  unsigned int sendBytesThreshold; //The number of free bytes at which flow control blocks the user from doing any more Writes.
78  unsigned int sendBytesPercentThresh; //The percent of free bytes at which flow control blocks the user from doing any more Writes.
79  unsigned int sendBuffersFree; //The number of buffers of MaxSDU size that this flow can assume it has available for Writes.
80  unsigned int sendBuffersPercentFree; //The percent of buffers of MaxSDU size that are free for Writes.
81  unsigned int sendBuffersThreshold; //The number of free buffers at which flow control blocks the user from doing any more Writes.
82  unsigned int sendBufferPercentThreshold; //The percent of free buffers at which flow control blocks the user from doing any more Writes.
83  /* End without getters/setters */
84 
85 
86  unsigned int rcvrRate; //This variable contains the current rate that the receiver has told the sender that it may send PDUs at.
87 
88  unsigned int pdusRcvdinTimeUnit; //This variable contains the number of PDUs received in this Time Unit. When PDUsRcvdinTimeUnit equals RcvrRate, the receiver is allowed to discard any PDUs received until a new time unit begins.
89 
90  /* Without getters/setters */
91  unsigned int rcvBytesFree; //The number of bytes that this flow can assume it has available for incoming PDUs on this connection.
92  unsigned int rcvBytesPercentFree; //The percent of bytes that are free for incoming PDUs on this connection.
93  unsigned int rcvBytesThreshold; //The number of free bytes at which flow control does not move the Right Window Edge.
94  unsigned int rcvBytesPercentThreshold; //The percent of free bytes at which flow control does not move the Right Window Edge.
95  unsigned int rcvBuffersFree; //The number of buffers of MaxPDU size that this flow can assume it has available for incoming PDUs
96  /* End without getters/setters */
97 
98  unsigned int rcvBuffersPercentFree; //The percent of buffers of MaxPDU size that are free.
99  unsigned int rcvBufferPercentThreshold; //The percent of free buffers at which flow control does not advance the Right Window Edge.
100 
101  bool sendingRateFullfilled; //This Boolean indicates that with rate-based flow control all the PDUs that can be sent during this time period have been sent.
102 
103 
104  unsigned int dupAcks;
105  /* Not found in specs but needed */
106  unsigned int configRcvrRate; //contains the initial and desired rcvrRate - or at least that's how I understand ConfigRate variable from RateReduction Policy
107  unsigned int dupFC; //duplicate Flow Control PDUs
109  unsigned int maxClosedWinQueLen;
110  std::vector<DataTransferPDU*> closedWindowQ;
111 
112  std::vector<DTCPRxExpiryTimer*> rxQ;
113 
114 
115  bool sndRendez; //Rendezvous-at-sender state
116  bool rcvRendez; //Rendezvous-at-receiver state
119 
120  unsigned int rendezSeqNum;
121 
122 
123  unsigned int rxSent; //number of PDUs sent from RxQ due to RxTimer expiration
124 
125  void clearPDUQ(PDUQ_t* pduQ);
126 
127  const QoSCube* qoSCube; //We'll see how this work out.
128 
129 
130  public:
131  DTCPState();
132  virtual ~DTCPState();
133 // unsigned int getRtt() const;
134 // void setRtt(unsigned int rtt);
135 // bool isImmediate() const;
136 // void setImmediate(bool immediate);
137  unsigned int getRcvrRightWinEdgeSent() const;
138  void setRcvRightWinEdgeSent(unsigned int rcvrRightWinEdgeSent);
139  unsigned int getSndRightWinEdge() const;
140  void setSenderRightWinEdge(unsigned int senderRightWinEdge);
141  unsigned int getSndLeftWinEdge() const;
142  void setSenderLeftWinEdge(unsigned int senderLeftWinEdge);
143 // bool isSetDrfFlag() const;
144 // void setSetDrfFlag(bool setDrfFlag);
145  unsigned int getRcvCredit() const;
146  void setRcvCredit(unsigned int rcvCredit);
147  unsigned int getSndCredit() const;
148  void setSndCredit(unsigned int sndCredit);
149 
150  void updateRcvRtWinEdge(unsigned int rcvLtWinEdge);
151 // unsigned int getNextCtrlSeqNum();
152  unsigned int getNextSndCtrlSeqNum();
153  unsigned int getNextSndCtrlSeqNumNoInc();
154  unsigned int getLastCtrlSeqNumRcv();
155  void setLastCtrlSeqNumRcv(unsigned int ctrlSeqNum);
156  void incRcvRtWinEdge();
157  void initFC();
158  unsigned int getRcvRightWinEdge() const;
159  void setRcvRtWinEdge(unsigned int rcvRtWinEdge);
160  unsigned int getRcvBufferPercentThreshold() const;
161  void setRcvBufferPercentThreshold(unsigned int rcvBufferPercentThreshold);
162  unsigned int getRcvBuffersPercentFree() const;
163  void setRcvBuffersPercentFree(unsigned int rcvBuffersPercentFree);
164 
165 
166 // void deleteRxTimer(unsigned int seqNum);
167  unsigned int getDataReXmitMax() const;
168  void setDataReXmitMax(unsigned int dataReXmitMax);
169 
170  std::vector<DTCPRxExpiryTimer*>* getRxQ();
171  void pushBackToRxQ(DTCPRxExpiryTimer* timer);
172  void clearRxQ();
173 
174  bool isClosedWindow() const;
175  void setClosedWindow(bool closedWindow);
176  unsigned int getClosedWinQueLen() const;
177  std::vector<DataTransferPDU*>* getClosedWindowQ();
179  void clearClosedWindowQ();
180 
181  unsigned int getMaxClosedWinQueLen() const;
182  void setMaxClosedWinQueLen(unsigned int maxClosedWinQueLen);
183 
184  /* Maybe */
185  unsigned int getRxQLen();
186  DTCPRxExpiryTimer* getRxTimer(unsigned int index);
187  bool isSendingRateFullfilled() const;
188  void setSendingRateFullfilled(bool sendingRateFullfilled);
189  unsigned int getPdusSentInTimeUnit() const;
190  void setPdusSentInTimeUnit(unsigned int pdusSentInTimeUnit);
191  unsigned long getSendingTimeUnit() const;
192  void setSendingTimeUnit(unsigned long sendingTimeUnit);
193  unsigned int getSendingRate() const;
194  void setSendingRate(unsigned int sendingRate);
195  unsigned int getRcvrRate() const;
196  void setRcvrRate(unsigned int rcvrRate);
197  unsigned int getConfigRcvrRate() const;
198  void setConfigRcvrRate(unsigned int configRcvrRate);
199 
200  void incDupAcks();
201  unsigned int getDupAcks() const;
202  void incDupFC();
203  unsigned int getDupFC() const;
204  unsigned long getTimeUnit() const;
205 
206  void updateSndLWE(unsigned int seqNum);
207  bool isClosedWinQClosed() const;
208  void incRxSent();
209  unsigned int getRxSent() const;
210  bool isRateBased() const;
211  void setRateBased(bool rateBased);
212  bool isRxPresent() const;
213  void setRxPresent(bool rxPresent);
214  bool isWinBased() const;
215  void setWinBased(bool winBased);
216 
217  bool isFCPresent(){ return winBased || rateBased;}
218 
219  const QoSCube* getQoSCube() const;
220  void setQoSCube(const QoSCube*& qoSCube);
221 
222  unsigned int getPdusRcvdInTimeUnit() const;
223  void setPdusRcvdinTimeUnit(unsigned int pdusRcvdinTimeUnit);
224 
225  void resetRcvVars();
226  bool isRcvRendez() const;
227  void setRcvRendez(bool rcvRendez);
228  bool isSndRendez() const;
229  void setSndRendez(bool sndRendez);
230  unsigned int getLastControlSeqNumSent() const;
231  void setLastControlSeqNumSent(unsigned int lastControlSeqNumSent);
233  void setRendezvousTimer(DTCPRendezvousTimer* rendezvousTimer);
235  void setReliableCpduTimer(DTCPReliableControlPDUTimer* reliableCpduTimer);
236  unsigned int getRendezSeqNum() const;
237  void setRendezSeqNum(unsigned int rendezSeqNum);
238  void resetSndVars();
239 
240  protected:
241  virtual void handleMessage(cMessage *msg);
242  virtual void initialize(int step);
243  int numInitStages() const { return 3;};
244  void initFromQoS(const QoSCube* qosCube);
245 
246 };
247 
248 #endif /* DTCPSTATE_H_ */
unsigned int rcvBuffersPercentFree
Definition: DTCPState.h:98
DTCPReliableControlPDUTimer * reliableCPDUTimer
Definition: DTCPState.h:118
void setRateBased(bool rateBased)
Definition: DTCPState.cc:521
void setSenderLeftWinEdge(unsigned int senderLeftWinEdge)
Definition: DTCPState.cc:138
void incRcvRtWinEdge()
Definition: DTCPState.cc:188
bool isRcvRendez() const
Definition: DTCPState.cc:561
unsigned int lastControlSeqNumRcv
Definition: DTCPState.h:62
void setWinBased(bool winBased)
Definition: DTCPState.cc:537
void clearClosedWindowQ()
Definition: DTCPState.cc:300
unsigned int sendBytesPercentThresh
Definition: DTCPState.h:78
unsigned int rcvrRate
Definition: DTCPState.h:86
void setSndRendez(bool sndRendez)
Definition: DTCPState.cc:576
void setSendingTimeUnit(unsigned long sendingTimeUnit)
Definition: DTCPState.cc:428
void initFromQoS(const QoSCube *qosCube)
Definition: DTCPState.cc:507
void pushBackToRxQ(DTCPRxExpiryTimer *timer)
Definition: DTCPState.cc:269
unsigned int getDupFC() const
Definition: DTCPState.cc:418
unsigned int sendBufferPercentThreshold
Definition: DTCPState.h:82
unsigned int sendBytesThreshold
Definition: DTCPState.h:77
void clearPDUQ(PDUQ_t *pduQ)
Definition: DTCPState.cc:274
std::vector< DataTransferPDU * > closedWindowQ
Definition: DTCPState.h:110
unsigned int getPdusRcvdInTimeUnit() const
Definition: DTCPState.cc:541
unsigned int getRxSent() const
Definition: DTCPState.cc:484
unsigned int maxClosedWinQueLen
Definition: DTCPState.h:109
void setDataReXmitMax(unsigned int dataReXmitMax)
Definition: DTCPState.cc:259
virtual ~DTCPState()
Definition: DTCPState.cc:152
virtual void handleMessage(cMessage *msg)
Definition: DTCPState.cc:442
unsigned int getDataReXmitMax() const
Definition: DTCPState.cc:254
unsigned int rcvBytesThreshold
Definition: DTCPState.h:93
void setSenderRightWinEdge(unsigned int senderRightWinEdge)
Definition: DTCPState.cc:147
void setRxPresent(bool rxPresent)
Definition: DTCPState.cc:529
unsigned int sndCredit
Definition: DTCPState.h:56
unsigned int nextSenderControlSeqNum
Definition: DTCPState.h:61
unsigned int rcvRightWinEdgeSent
Definition: DTCPState.h:53
bool isWinBased() const
Definition: DTCPState.cc:533
unsigned int rcvBufferPercentThreshold
Definition: DTCPState.h:99
void setSendingRateFullfilled(bool sendingRateFullfilled)
Definition: DTCPState.cc:354
void setLastCtrlSeqNumRcv(unsigned int ctrlSeqNum)
Definition: DTCPState.cc:212
unsigned int pdusSentInTimeUnit
Definition: DTCPState.h:71
void setRcvCredit(unsigned int rcvCredit)
Definition: DTCPState.cc:163
unsigned int getRendezSeqNum() const
Definition: DTCPState.cc:591
unsigned int getNextSndCtrlSeqNum()
Definition: DTCPState.cc:198
unsigned int configRcvrRate
Definition: DTCPState.h:106
const QoSCube * qoSCube
Definition: DTCPState.h:127
void setRcvRightWinEdgeSent(unsigned int rcvrRightWinEdgeSent)
Definition: DTCPState.cc:129
unsigned int getSndRightWinEdge() const
Definition: DTCPState.cc:142
unsigned int rcvBuffersFree
Definition: DTCPState.h:95
unsigned int getRcvBuffersPercentFree() const
Definition: DTCPState.cc:226
unsigned int getPdusSentInTimeUnit() const
Definition: DTCPState.cc:358
unsigned int rcvRightWinEdge
Definition: DTCPState.h:52
unsigned int getDupAcks() const
Definition: DTCPState.cc:398
unsigned int pdusRcvdinTimeUnit
Definition: DTCPState.h:88
unsigned int getClosedWinQueLen() const
Definition: DTCPState.cc:337
unsigned int dupFC
Definition: DTCPState.h:107
const QoSCube * getQoSCube() const
Definition: DTCPState.cc:489
void setPdusSentInTimeUnit(unsigned int pdusSentInTimeUnit)
Definition: DTCPState.cc:363
bool isClosedWindow() const
Definition: DTCPState.cc:328
void setReliableCpduTimer(DTCPReliableControlPDUTimer *reliableCpduTimer)
Definition: DTCPState.cc:502
int numInitStages() const
Definition: DTCPState.h:243
void setMaxClosedWinQueLen(unsigned int maxClosedWinQueLen)
Definition: DTCPState.cc:345
unsigned int getSendingRate() const
Definition: DTCPState.cc:368
void resetRcvVars()
Definition: DTCPState.cc:35
unsigned int getMaxClosedWinQueLen() const
Definition: DTCPState.cc:341
unsigned int getLastControlSeqNumSent() const
Definition: DTCPState.cc:551
void setPdusRcvdinTimeUnit(unsigned int pdusRcvdinTimeUnit)
Definition: DTCPState.cc:546
std::vector< DTCPRxExpiryTimer * > rxQ
Definition: DTCPState.h:112
unsigned long sendingTimeUnit
Definition: DTCPState.h:72
bool rcvRendez
Definition: DTCPState.h:116
void initFC()
Definition: DTCPState.cc:61
unsigned int rcvBytesFree
Definition: DTCPState.h:91
bool isRateBased() const
Definition: DTCPState.cc:517
unsigned int rcvBytesPercentThreshold
Definition: DTCPState.h:94
unsigned int sendBuffersPercentFree
Definition: DTCPState.h:80
void setQoSCube(const QoSCube *&qoSCube)
Definition: DTCPState.cc:493
void setSndCredit(unsigned int sndCredit)
Definition: DTCPState.cc:173
std::vector< DataTransferPDU * > PDUQ_t
void setRcvRtWinEdge(unsigned int rcvRtWinEdge)
Definition: DTCPState.cc:183
bool isRxPresent() const
Definition: DTCPState.cc:525
void setSendingRate(unsigned int sendingRate)
Definition: DTCPState.cc:393
unsigned int dataReXmitMax
Definition: DTCPState.h:65
bool rateBased
Definition: DTCPState.h:45
void setConfigRcvrRate(unsigned int configRcvrRate)
Definition: DTCPState.cc:383
bool rxPresent
Definition: DTCPState.h:46
DTCPReliableControlPDUTimer * getReliableCpduTimer()
Definition: DTCPState.cc:497
unsigned int getRcvRightWinEdge() const
Definition: DTCPState.cc:178
unsigned int sendBuffersFree
Definition: DTCPState.h:79
void resetSndVars()
Definition: DTCPState.cc:49
void incDupAcks()
Definition: DTCPState.cc:403
DTCPRendezvousTimer * rendezvousTimer
Definition: DTCPState.h:117
void setRendezSeqNum(unsigned int rendezSeqNum)
Definition: DTCPState.cc:596
bool isSndRendez() const
Definition: DTCPState.cc:571
bool isSendingRateFullfilled() const
Definition: DTCPState.cc:350
void updateSndLWE(unsigned int seqNum)
Definition: DTCPState.cc:433
virtual void initialize(int step)
Definition: DTCPState.cc:446
unsigned int getSndLeftWinEdge() const
Definition: DTCPState.cc:134
unsigned int getNextSndCtrlSeqNumNoInc()
Definition: DTCPState.cc:203
unsigned int getConfigRcvrRate() const
Definition: DTCPState.cc:378
unsigned int getLastCtrlSeqNumRcv()
Definition: DTCPState.cc:208
void setRcvrRate(unsigned int rcvrRate)
Definition: DTCPState.cc:388
unsigned int rcvBytesPercentFree
Definition: DTCPState.h:92
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
std::vector< DTCPRxExpiryTimer * > * getRxQ()
Definition: DTCPState.cc:264
bool sndRendez
Definition: DTCPState.h:115
unsigned int getRcvrRate() const
Definition: DTCPState.cc:373
void setRcvBufferPercentThreshold(unsigned int rcvBufferPercentThreshold)
Definition: DTCPState.cc:221
unsigned int sndRightWinEdge
Definition: DTCPState.h:51
void setRcvBuffersPercentFree(unsigned int rcvBuffersPercentFree)
Definition: DTCPState.cc:231
bool isFCPresent()
Definition: DTCPState.h:217
std::vector< DataTransferPDU * > * getClosedWindowQ()
Definition: DTCPState.cc:312
unsigned int lastControlSeqNumSent
Definition: DTCPState.h:63
unsigned int sendBuffersThreshold
Definition: DTCPState.h:81
void setRendezvousTimer(DTCPRendezvousTimer *rendezvousTimer)
Definition: DTCPState.cc:586
unsigned int sndLeftWinEdge
Definition: DTCPState.h:50
unsigned int sendingRate
Definition: DTCPState.h:69
void incRxSent()
Definition: DTCPState.cc:108
unsigned int getRxQLen()
Definition: DTCPState.cc:512
unsigned int sendBytesFree
Definition: DTCPState.h:75
void setClosedWindow(bool closedWindow)
Definition: DTCPState.cc:333
bool winBased
Definition: DTCPState.h:44
unsigned int getRcvBufferPercentThreshold() const
Definition: DTCPState.cc:216
unsigned int rxSent
Definition: DTCPState.h:123
bool sendingRateFullfilled
Definition: DTCPState.h:101
bool closedWindow
Definition: DTCPState.h:108
unsigned int sendBytesPercentFree
Definition: DTCPState.h:76
unsigned int rendezSeqNum
Definition: DTCPState.h:120
void setLastControlSeqNumSent(unsigned int lastControlSeqNumSent)
Definition: DTCPState.cc:556
void clearRxQ()
Definition: DTCPState.cc:284
unsigned int rcvCredit
Definition: DTCPState.h:55
unsigned int getRcvrRightWinEdgeSent() const
Definition: DTCPState.cc:124
DTCPRendezvousTimer * getRendezvousTimer()
Definition: DTCPState.cc:581
bool isClosedWinQClosed() const
Definition: DTCPState.cc:317
unsigned int dupAcks
Definition: DTCPState.h:104
unsigned long timeUnit
Definition: DTCPState.h:68
unsigned int getSndCredit() const
Definition: DTCPState.cc:168
void setRcvRendez(bool rcvRendez)
Definition: DTCPState.cc:566
unsigned long getTimeUnit() const
Definition: DTCPState.cc:413
unsigned int getRcvCredit() const
Definition: DTCPState.cc:158
void incDupFC()
Definition: DTCPState.cc:408
DTCPRxExpiryTimer * getRxTimer(unsigned int index)
unsigned long getSendingTimeUnit() const
Definition: DTCPState.cc:423
void pushBackToClosedWinQ(DataTransferPDU *pdu)
Definition: DTCPState.cc:305
void updateRcvRtWinEdge(unsigned int rcvLtWinEdge)
Definition: DTCPState.cc:193