RINASim  October 2016
Documentation of framework for OMNeT++
SenderAckPolicyTCP.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 //
15 
16 #include <SenderAckPolicyTCP.h>
17 #include <DTCP.h>
19 
21  // TODO Auto-generated constructor stub
22  numOfAcked = 0;
23 }
24 
26  // TODO Auto-generated destructor stub
27 }
28 
29 bool SenderAckPolicyTCP::run(DTPState* dtpState, DTCPState* dtcpState) {
30  unsigned int seqNum = ((NAckPDU*)dtpState->getCurrentPdu())->getAckNackSeqNum();
31 
32  ackPDU(dtpState, dtcpState, seqNum);
33  dtcpState->updateSndLWE(seqNum + 1);
34 
35  dtcpState->setClosedWindow(false);
36 
37  return false;
38 }
39 
40 void SenderAckPolicyTCP::ackPDU(DTPState* dtpState, DTCPState* dtcpState, unsigned int startSeqNum, unsigned int endSeqNum)
41 {
42  bool startTrue = false;
43  bool notFound = true;
44  DTCP* dtcp = getRINAModule<DTCP*>(this, 1, {MOD_DTCP});
45  if(!endSeqNum){
46  startTrue = true;
47  endSeqNum = startSeqNum;
48  }
49 
50  std::vector<DTCPRxExpiryTimer*>* rxQ = dtcpState->getRxQ();
51  std::vector<DTCPRxExpiryTimer*>::iterator it;
52 
53  for (unsigned int index = 0; index < rxQ->size(); )
54  {
55  DTCPRxExpiryTimer* timer = rxQ->at(index);
56  unsigned int seqNum =(timer->getPdu())->getSeqNum();
57  unsigned int gap = dtpState->getQoSCube()->getMaxAllowGap();
58  //TODO A2 This is weird. Why value from MAX(Ack/Nack, NextAck -1) What does NextAck-1 got to do with it?
59  if ((seqNum >= startSeqNum || startTrue) && seqNum <= endSeqNum + gap)
60  {
61  dtcp->deleteRxTimer(seqNum);
62  numOfAcked++;
63  notFound = false;
64  continue;
65  }
66  index++;
67  }
68  if(notFound)
69  EV << "not found!";
70 }
Register_Class(SenderAckPolicyTCP)
Definition: DTCP.h:63
virtual DTPDU_p & getPdu()
void ackPDU(DTPState *dtpState, DTCPState *dtcpState, unsigned int startSeqNum, unsigned int endSeqNum=0)
const QoSCube * getQoSCube() const
Definition: DTPState.cc:433
const PDU * getCurrentPdu() const
Definition: DTPState.cc:339
void updateSndLWE(unsigned int seqNum)
Definition: DTCPState.cc:433
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
void setClosedWindow(bool closedWindow)
Definition: DTCPState.cc:333
virtual bool run(DTPState *dtpState, DTCPState *dtcpState)
int getMaxAllowGap() const
Gets Maximum Allowable Gap in SDUs parameter.
Definition: QoSCube.cc:316