RINASim  October 2016
Documentation of framework for OMNeT++
SenderAckPolicyLG.cc
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.
30 #include "SenderAckPolicyLG.h"
31 #include "DTCP.h"
32 
33 const char * ECN_MARKED_CTRL = "ECN_MARKED_CTRL";
34 const char * APPR_LOAD = "APPR_LOAD";
35 
37 
39 {
40  load = 0;
41  gamma = 0.005;
42 }
43 
45 {
46 }
47 
49  return load;
50 }
51 
53  sigStatECNMarked = registerSignal(ECN_MARKED_CTRL);
54  sigStatApprLoad = registerSignal(APPR_LOAD);
55 
56 
57  txControlPolicyLG = getRINAModule<TxControlPolicyLG*>(this, 1, {"txControlPolicy"});
58 }
59 
60 bool SenderAckPolicyLG::run(DTPState* dtpState, DTCPState* dtcpState)
61 {
62  Enter_Method("SenderAckPolicyLG");
63 
64  // defaultAction(dtpState, dtcpState);
65  DTCP* dtcp = getRINAModule<DTCP*>(this, 1, {MOD_DTCP});
66  /* Default */
67  unsigned int endSeqNum = ((NAckPDU*)dtpState->getCurrentPdu())->getAckNackSeqNum();
68  unsigned int startSeqNum = endSeqNum;
69  bool startTrue = false;
70 
71  int count = 0;
72 
73  std::vector<DTCPRxExpiryTimer*>* rxQ = dtcpState->getRxQ();
74  std::vector<DTCPRxExpiryTimer*>::iterator it;
75 
76  for (unsigned int index = 0; index < rxQ->size(); )
77  {
78  DTCPRxExpiryTimer* timer = rxQ->at(index);
79  unsigned int seqNum =(timer->getPdu())->getSeqNum();
80 
81  if ((seqNum >= startSeqNum || startTrue) && seqNum <= endSeqNum)
82  {
83  dtcp->deleteRxTimer(seqNum);
84  count++;
85 
86  continue;
87  }
88  index++;
89  }
90  //update SendLeftWindowEdge
91  dtcpState->updateSndLWE(endSeqNum + 1);
92 
93 
94  if(endSeqNum >= 2) {
95  if(((NAckPDU*)dtpState->getCurrentPdu())->getFlags() & ECN_FLAG) {
96  emit(sigStatECNMarked, ((NAckPDU*)dtpState->getCurrentPdu())->getSeqNum());
97  if(load == 0)
98  load = 1;
99  else
100  load = (1 - gamma) * load + gamma * 1;
101  } else
102  load = (1 - gamma) * load + gamma * 0;
103  }
104 
105  emit(sigStatApprLoad, load);
106 
108  dtcpState->setClosedWindow(false);
109 
110  return false;
111 }
virtual bool run(DTPState *dtpState, DTCPState *dtcpState)
TxControlPolicyLG * txControlPolicyLG
Register_Class(SenderAckPolicyLG)
Definition: DTCP.h:63
const char * ECN_MARKED_CTRL
virtual DTPDU_p & getPdu()
void updateRate(double load, double acked)
This is an example policy class implementing LG Initial Sequence Number behavior .
const PDU * getCurrentPdu() const
Definition: DTPState.cc:339
void updateSndLWE(unsigned int seqNum)
Definition: DTCPState.cc:433
virtual ~SenderAckPolicyLG()
std::vector< DTCPRxExpiryTimer * > * getRxQ()
Definition: DTCPState.cc:264
const char * MOD_DTCP
Definition: ExternConsts.cc:36
void deleteRxTimer(unsigned int seqNum)
Definition: DTCP.cc:324
#define ECN_FLAG
Definition: PDU.h:37
void setClosedWindow(bool closedWindow)
Definition: DTCPState.cc:333
simsignal_t sigStatECNMarked
simsignal_t sigStatApprLoad
const char * APPR_LOAD