RINASim  October 2016
Documentation of framework for OMNeT++
DTPState.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  * @file DTPState.h
24  * @author Marcel Marek
25  * @date Apr 28, 2014
26  * @brief
27  * @detail
28  * EFCPSpec 8.5.2 DTP State - the DTSV
29  */
30 #ifndef DTPSTATE_H_
31 #define DTPSTATE_H_
32 
33 #include <omnetpp.h>
34 #include <queue>
35 #include <vector>
36 #include "Utils.h"
37 #include "EFCP_defs.h"
38 #include "DataTransferPDU.h"
39 
40 
41 #include "PDU.h"
42 
43 /* Dirty hacks */
44 #include "DTPTimers_m.h"
45 /* End dirty hacks */
46 
47 
48 
49 typedef enum
50 {
51  //NULL = 0,
53  DTP_STATE_PORT_ID_TRANS = 0x10, //Port-id transition
55 
56 
57 /*
58  *
59  */
60 class DTPState : public cSimpleModule {
61 
62 private:
64 
65  /* These parameters can set smaller values of the DTAE constants
66  * for a given flow. These must have values less than or equal
67  * those defined for the DIF. */
68  unsigned int maxFlowSDUSize;
69  unsigned int maxFlowPDUSize;
70 
71  unsigned int seqNumRollOverThresh;
72  int state;
73  bool dtcpPresent;
76  /* Move to DTCPState! */
77 
78 
79 
83 
84  const QoSCube* qoSCube;
85 
86  bool partDeliv; /* Partial Delivery of SDUs is Allowed */
87  bool incompDeliv; /* Delivery of Incomplete SDUs is Allowed */
88  unsigned int rcvLeftWinEdge;
89  unsigned int maxSeqNumRcvd;
90 
91  unsigned int nextSeqNumToSend;
92  unsigned int lastSDUDelivered;
93  //queue<PDU,seqNum> pduReassemblyQ
94 
95  /* Not in specs */
96  unsigned int dropDup; //number of dropped duplicates (this variable is not mentioned in specs)
97 
98  /* Not defined in specs, but referred to */
99  unsigned int lastSeqNumSent;
100 
101  /* Moved from DTCP-SV */
102  bool setDRFFlag; // This Boolean indicates that the next PDU sent should have the DRF Flag set.
103  double rtt;
104  double mpl;
105 
106 
107 
108  /* new */
109  bool ecnSet; //This variable gets set upon reception of DataTransfer PDU with ECN bit set and cleared upon reception of DataTransfer PDU with ECN bit cleared.
111 
112  /* Dirty hacks */
113  /* This section contains temporary 'dirty hacks' variables to bypass obstacles.
114  * They might and hopefully will be removed very soon, so do not depend on them.
115  */
117 
118  /* End Dirsty hacks */
119 
120  void clearPDUQ(std::vector<DataTransferPDU*>* pduQ);
121  void clearGeneratedPDUQ();
122  void clearPostablePDUQ();
123 
124 public:
125  DTPState();
126  virtual ~DTPState();
127 
128  void initDefaults();
129 
130  void incDropDup(){dropDup++;}
131  unsigned int getDropDup() const;
132 
133 // bool isFCPresent(){ return winBased || rateBased;}
134 
135  bool isDtcpPresent() const;
136  void setDtcpPresent(bool dtcpPresent);
137  bool isIncompDeliv() const;
138  void setIncompDeliv(bool incompDeliv);
139  unsigned int getMaxFlowPduSize() const;
140  void setMaxFlowPduSize(unsigned int maxFlowPduSize);
141  unsigned int getMaxFlowSduSize() const;
142  void setMaxFlowSduSize(unsigned int maxFlowSduSize);
143  unsigned int getMaxSeqNumRcvd() const;
144  void setMaxSeqNumRcvd(unsigned int maxSeqNumRcvd);
145  void incMaxSeqNumRcvd();
146  void incRcvLeftWindowEdge();
147  unsigned int getNextSeqNumToSend();
149  void setNextSeqNumToSend(unsigned int nextSeqNumToSend);
150  void incNextSeqNumToSend();
151  bool isPartDeliv() const;
152  void setPartDeliv(bool partDeliv);
153 // bool isRateBased() const;
154 // void setRateBased(bool rateBased);
155  bool isRateFullfilled() const;
156  void setRateFullfilled(bool rateFullfilled);
157  unsigned int getRcvLeftWinEdge() const;
158  void setRcvLeftWinEdge(unsigned int rcvLeftWinEdge);
159 // bool isRxPresent() const;
160 // void setRxPresent(bool rxPresent);
161  unsigned int getSeqNumRollOverThresh() const;
162  void setSeqNumRollOverThresh(unsigned int seqNumRollOverThresh);
163  int getState() const;
164  void setState(int state);
165 // bool isWinBased() const;
166 // void setWinBased(bool winBased);
167  bool isSetDrfFlag() const;
168  void setSetDrfFlag(bool setDrfFlag);
169  double getRtt() const;
170  void setRtt(double rtt);
171 
172  unsigned int getLastCtrlSeqNumRcv();
173  unsigned int getLastSeqNumSent() const;
174  void setLastSeqNumSent(unsigned int lastSeqNumSent);
175  bool isEcnSet() const;
176  void setEcnSet(bool ecnSet);
177  const PDU* getCurrentPdu() const;
178  void setCurrentPdu(PDU* currentPdu);
179 
180  std::vector<DataTransferPDU*>* getReassemblyPDUQ();
183  void clearReassemblyPDUQ();
184 
187 
190  const QoSCube* getQoSCube() const;
191  void setQoSCube(const QoSCube*& qoSCube);
192  unsigned int getLastSduDelivered() const;
193  void setLastSduDelivered(unsigned int lastSduDelivered);
194 
195  void updateRcvLWE(unsigned int seqNum);
196  void updateSndLWE();
197  double getMPL() const;
198  void setMpl(double mpl);
199  bool isBlockingPort() const;
200  void setBlockingPort(bool blockingPort);
201 
202 
203  /* Dirty hacks */
204  ATimer* getTmpAtimer() const;
205  void setTmpAtimer(ATimer* tmpAtimer);
206  void resetRcvVars();
207  void resetSndVars();
208 
209 // double getDelimitDelay() const;
210 // void setDelimitDelay(double delimitDelay);
211 
212  /* End dirty hacks */
213 
214 protected:
215  virtual void handleMessage(cMessage *msg);
216  virtual void initialize(int step);
217  int numInitStages() const { return 2;};
218 };
219 
220 #endif /* DTPSTATE_H_ */
void resetSndVars()
Definition: DTPState.cc:95
PDUQ_t generatedPDUs
Definition: DTPState.h:81
bool isPartDeliv() const
Definition: DTPState.cc:234
bool dtcpPresent
Definition: DTPState.h:73
DTPStateState
Definition: DTPState.h:49
void setRcvLeftWinEdge(unsigned int rcvLeftWinEdge)
Definition: DTPState.cc:262
int state
Definition: DTPState.h:72
void pushBackToReassemblyPDUQ(DataTransferPDU *pdu)
Definition: DTPState.cc:356
unsigned int getLastSeqNumSent() const
Definition: DTPState.cc:319
unsigned int getMaxFlowSduSize() const
Definition: DTPState.cc:186
bool blockingPort
Definition: DTPState.h:110
PDUQ_t * getPostablePDUQ()
Definition: DTPState.cc:419
unsigned int dropDup
Definition: DTPState.h:96
bool isRateFullfilled() const
bool ecnSet
Definition: DTPState.h:109
virtual void handleMessage(cMessage *msg)
Definition: DTPState.cc:473
void setNextSeqNumToSend(unsigned int nextSeqNumToSend)
Definition: DTPState.cc:225
double getMPL() const
Definition: DTPState.cc:33
unsigned int nextSeqNumToSend
Definition: DTPState.h:91
void setMaxFlowPduSize(unsigned int maxFlowPduSize)
Definition: DTPState.cc:182
ATimer * tmpAtimer
Definition: DTPState.h:116
unsigned int maxSeqNumRcvd
Definition: DTPState.h:89
unsigned int lastSeqNumSent
Definition: DTPState.h:99
bool isEcnSet() const
Definition: DTPState.cc:329
void pushBackToGeneratedPDUQ(DataTransferPDU *pdu)
Definition: DTPState.cc:414
unsigned int getMaxSeqNumRcvd() const
Definition: DTPState.cc:194
unsigned int getNextSeqNumToSend()
Definition: DTPState.cc:215
void setRtt(double rtt)
Definition: DTPState.cc:309
bool partDeliv
Definition: DTPState.h:86
void setEcnSet(bool ecnSet)
Definition: DTPState.cc:334
PDU * currentPDU
Definition: DTPState.h:63
PDUQ_t reassemblyPDUQ
Definition: DTPState.h:80
void setState(int state)
Definition: DTPState.cc:286
unsigned int getSeqNumRollOverThresh() const
Definition: DTPState.cc:274
void setPartDeliv(bool partDeliv)
Definition: DTPState.cc:238
void clearGeneratedPDUQ()
Definition: DTPState.cc:145
unsigned int maxFlowSDUSize
Definition: DTPState.h:68
DTPState()
Definition: DTPState.cc:27
bool isBlockingPort() const
Definition: DTPState.cc:43
bool isSetDrfFlag() const
Definition: DTPState.cc:298
void incNextSeqNumToSend()
Definition: DTPState.cc:229
PDUQ_t * getGeneratedPDUQ()
Definition: DTPState.cc:409
void setMaxFlowSduSize(unsigned int maxFlowSduSize)
Definition: DTPState.cc:190
Definition: PDU.h:42
bool isIncompDeliv() const
Definition: DTPState.cc:170
bool isDtcpPresent() const
Definition: DTPState.cc:162
void clearReassemblyPDUQ()
Definition: DTPState.cc:140
void setQoSCube(const QoSCube *&qoSCube)
Definition: DTPState.cc:448
bool setDRFFlag
Definition: DTPState.h:102
void setIncompDeliv(bool incompDeliv)
Definition: DTPState.cc:174
void setMpl(double mpl)
Definition: DTPState.cc:38
void addPDUToReassemblyQ(DataTransferPDU *pdu)
Definition: DTPState.cc:364
void setSeqNumRollOverThresh(unsigned int seqNumRollOverThresh)
Definition: DTPState.cc:278
unsigned int maxFlowPDUSize
Definition: DTPState.h:69
unsigned int rcvLeftWinEdge
Definition: DTPState.h:88
unsigned int getRcvLeftWinEdge() const
Definition: DTPState.cc:258
const QoSCube * getQoSCube() const
Definition: DTPState.cc:433
void updateRcvLWE(unsigned int seqNum)
Definition: DTPState.cc:453
void incMaxSeqNumRcvd()
Definition: DTPState.cc:203
std::vector< DataTransferPDU * > PDUQ_t
void setTmpAtimer(ATimer *tmpAtimer)
Definition: DTPState.cc:483
int getState() const
Definition: DTPState.cc:282
void initDefaults()
Definition: DTPState.cc:104
void setSetDrfFlag(bool setDrfFlag)
Definition: DTPState.cc:314
void pushBackToPostablePDUQ(DataTransferPDU *pdu)
Definition: DTPState.cc:424
double mpl
Definition: DTPState.h:104
const PDU * getCurrentPdu() const
Definition: DTPState.cc:339
double getRtt() const
Definition: DTPState.cc:303
int numInitStages() const
Definition: DTPState.h:217
std::vector< DataTransferPDU * > * getReassemblyPDUQ()
Definition: DTPState.cc:351
void clearPostablePDUQ()
Definition: DTPState.cc:150
void updateSndLWE()
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
void setLastSduDelivered(unsigned int lastSduDelivered)
Definition: DTPState.cc:443
unsigned int getMaxFlowPduSize() const
Definition: DTPState.cc:178
void resetRcvVars()
Definition: DTPState.cc:53
unsigned int getDropDup() const
Definition: DTPState.cc:428
void setRateFullfilled(bool rateFullfilled)
unsigned int seqNumRollOverThresh
Definition: DTPState.h:71
void incDropDup()
Definition: DTPState.h:130
ATimer * getTmpAtimer() const
Definition: DTPState.cc:478
virtual ~DTPState()
Definition: DTPState.cc:155
void setLastSeqNumSent(unsigned int lastSeqNumSent)
Definition: DTPState.cc:324
unsigned int getLastCtrlSeqNumRcv()
const QoSCube * qoSCube
Definition: DTPState.h:84
unsigned int lastSDUDelivered
Definition: DTPState.h:92
double rtt
Definition: DTPState.h:103
void incRcvLeftWindowEdge()
Definition: DTPState.cc:207
void clearPDUQ(std::vector< DataTransferPDU * > *pduQ)
Definition: DTPState.cc:127
unsigned int getLastSduDelivered() const
Definition: DTPState.cc:438
void setDtcpPresent(bool dtcpPresent)
Definition: DTPState.cc:166
void setCurrentPdu(PDU *currentPdu)
Definition: DTPState.cc:344
void setBlockingPort(bool blockingPort)
Definition: DTPState.cc:48
virtual void initialize(int step)
Definition: DTPState.cc:64
bool incompDeliv
Definition: DTPState.h:87
PDUQ_t postablePDUs
Definition: DTPState.h:82
void setMaxSeqNumRcvd(unsigned int maxSeqNumRcvd)
Definition: DTPState.cc:198
unsigned int getNextSeqNumToSendWithoutIncrement()
Definition: DTPState.cc:220