RINASim  October 2016
Documentation of framework for OMNeT++
RTTEstimatorPolicyBase.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.
22 
23 /*
24  * @file DTPRTTEstimatorPolicyBase.cc
25  * @author Marcel Marek (imarek@fit.vutbr.cz)
26  * @date Jan 22, 2015
27  * @brief
28  * @detail
29  */
30 
31 #include "RTTEstimatorPolicyBase.h"
32 #include "ControlPDU_m.h"
33 
35 {
36  RTO = 1;
37 }
38 
40 {
41 
42 }
43 
45  return RTO;
46 }
47 
49 {
50  double newRtt = dtpState->getRtt();
51  double alpha = 0.998;
52  /* Default */
53  ControlPDU* pdu = (ControlPDU*) dtpState->getCurrentPdu();
54  if (pdu->getType() & PDU_SEL_BIT)
55  {
56 
57  }
58  else
59  {
60  if (pdu->getType() & PDU_ACK_BIT)
61  {
62  unsigned int seqNum = ((AckOnlyPDU*) pdu)->getAckNackSeqNum();
63  std::vector<DTCPRxExpiryTimer*>* pduQ = dtcpState->getRxQ();
64  std::vector<DTCPRxExpiryTimer*>::iterator it;
65  bool foundAck = false;
66  for (it = pduQ->begin(); it != pduQ->end(); ++it)
67  {
68  if ((*it)->getPdu()->getSeqNum() == seqNum)
69  {
70  foundAck = true;
71  double now = simTime().dbl();
72  double sent = (*it)->getSent();
73  newRtt = now - sent;
74 
75  newRtt = floor(newRtt * 1000000000);
76  newRtt = newRtt / 1000000000;
77 
78  }
79  }
80  if (!foundAck)
81  {
82 
83  EV << "RTTEstimator: Did not find PDU on RxQ to compare times." << endl;
84  return;
85  }
86 
87  }
88  else
89  {
90 
91  }
92  }
93  double tmp = floor(((alpha * dtpState->getRtt()) + ((1 - alpha) * newRtt)) * 1000000000);
94 // dtpState->setRtt(((double) tmp / 1000000000) * 1.1);
95  dtpState->setRtt(((double) tmp / 1000000000)); // removing * 1.1
96  EV << "Current RTT: " << dtpState->getRtt() << endl;
97  RTO = dtpState->getRtt() + (double)dtpState->getQoSCube()->getATime()/(double)1000 + DTP_EPSILON;
98 
99 }
100 
102 {
103  RTO = rto;
104 }
void setRtt(double rtt)
Definition: DTPState.cc:309
double getATime() const
Gets A-Timer parameter.
Definition: QoSCube.cc:384
#define DTP_EPSILON
Definition: EFCP_defs.h:44
const QoSCube * getQoSCube() const
Definition: DTPState.cc:433
virtual int getType() const
Definition: PDU_m.cc:346
const PDU * getCurrentPdu() const
Definition: DTPState.cc:339
void defaultAction(DTPState *dtpState, DTCPState *dtcpState)
double getRtt() const
Definition: DTPState.cc:303
std::vector< DTCPRxExpiryTimer * > * getRxQ()
Definition: DTCPState.cc:264