RINASim  October 2016
Documentation of framework for OMNeT++
TxControlPolicyTCPTahoe.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
25  // TODO Auto-generated constructor stub
28  rxSent = 0;
29  ackRcvd = 0;
30  snd_cwnd = RST_WND;
31  flightSize = 0;
32 }
33 
35  // TODO Auto-generated destructor stub
36 }
37 
39 {
40  if(step == 0){
41  sigStatTCPTahoeCWND = registerSignal("TCP_Tahoe_CWND");
42  }
43  slowedDown = false;
44  packetSize = par("packetSize").longValue();
45  ackPolicy = check_and_cast<SenderAckPolicyTCP *>(getModuleByPath("^.senderAckPolicy"));//^.^.efcp
46 }
47 
49  if(! slowedDown ) {
51  snd_cwnd = std::max(int(snd_cwnd / 2), 2);
53  slowedDown = true;
55  }
56 }
57 
58 bool TxControlPolicyTCPTahoe::run(DTPState* dtpState, DTCPState* dtcpState)
59 {
60  int sendCredit = 0;
61  double time = simTime().dbl();
62  time = time + 1;
63 
65  if( ackPolicy->numOfAcked > ackRcvd ) {
66  uint32_t n = 0;
68  flightSize -= n;
70 
71  if(state == STATE_SLOW_START && n > 10)
72  //FIXME: Vesely -> Marek: Resolve!
73  n = 5 ; //5 instead of n = n;
74 
75  if(snd_cwnd >= ssthresh)
77 
78 // int old_cwnd = snd_cwnd;
79 
80  for (uint32_t i = 0; i < n; i++) { // Appropriate Byte Counting
81  if(state == STATE_SLOW_START)
82  snd_cwnd += 1;
83  if(state == STATE_CNG_AVOID)
84  snd_cwnd += 1 / snd_cwnd; // snd_cwnd += SMSS * SMSS / snd_cwnd;
85  }
86 
87 // sendCredit = int(snd_cwnd) - old_cwnd + n;
88  sendCredit = int(snd_cwnd) - flightSize;
89  }
90 
91  if( dtcpState->getRxSent() > rxSent) {
92  rxSent = dtcpState->getRxSent();
93  slowDown();
94 // ssthresh = std::max(int(snd_cwnd / 2), 2);
95 // state = STATE_SLOW_START;
96 // snd_cwnd = RST_WND;
97 // rxSent = dtcpState->getRxSent();
98 //
99 // sendCredit = snd_cwnd;
100  }
101  } else {
103  sendCredit = snd_cwnd;
104  }
105 
106  if(snd_cwnd > dtcpState->getRcvCredit())
108 
109  if(sendCredit > 0)
111 
112  // ------------- adding packets to send queue
113  std::vector<DataTransferPDU*>::iterator it;
114  PDUQ_t* pduQ = NULL;
115  int sentNo = 1;
116 
117  for(int i = 1; i <= 2; i++) {
118  if (dtcpState->getClosedWinQueLen() > 0) {
119  pduQ = dtcpState->getClosedWindowQ();
120  } else
121  pduQ = dtpState->getGeneratedPDUQ();
122 
123  for (it = pduQ->begin(); it != pduQ->end() && (*it)->getSeqNum() <= dtcpState->getSndRightWinEdge() && sentNo <= sendCredit; sentNo++) {
124  dtpState->pushBackToPostablePDUQ((*it));
125  flightSize++;
126  slowedDown = false;
127  it = pduQ->erase(it);
128  }
129  }
130 
131  dtcpState->setClosedWindow(true);
132 // if (!dtpState->getGeneratedPDUQ()->empty() || dtcpState->getClosedWinQueLen() >= dtcpState->getMaxClosedWinQueLen() || (sentNo > sendCredit) ) {
133 // dtcpState->setClosedWindow(true);
134 // }
135 
136  return false;
137 }
SenderAckPolicyTCP * ackPolicy
unsigned int getRxSent() const
Definition: DTCPState.cc:484
unsigned int getSndRightWinEdge() const
Definition: DTCPState.cc:142
PDUQ_t * getGeneratedPDUQ()
Definition: DTPState.cc:409
unsigned int getClosedWinQueLen() const
Definition: DTCPState.cc:337
virtual bool run(DTPState *dtpState, DTCPState *dtcpState)
std::vector< DataTransferPDU * > PDUQ_t
float snd_cwnd
congestion window
void pushBackToPostablePDUQ(DataTransferPDU *pdu)
Definition: DTPState.cc:424
#define STATE_SLOW_START
slow start
float ssthresh
slow start threshold
#define RST_WND
#define MAX_SSTHRESH
slow start threshold
#define STATE_CNG_AVOID
congestion avoidance
std::vector< DataTransferPDU * > * getClosedWindowQ()
Definition: DTCPState.cc:312
void setClosedWindow(bool closedWindow)
Definition: DTCPState.cc:333
virtual void initialize()
#define STATE_STARTING_SLOW_START
starting slow start
Register_Class(TxControlPolicyTCPTahoe)
unsigned int getRcvCredit() const
Definition: DTCPState.cc:158