RINASim  October 2016
Documentation of framework for OMNeT++
RcvrControlAckPolicyBase.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.
31 #include "DTP.h"
32 
34 {
35 
36 
37 }
38 
40 {
41 
42 }
43 
45 {
46 
47  //TODO A1: Update it according to the new specs update.
48 
49  DTP* dtp = getRINAModule<DTP*>(this, 1, {MOD_DTP});
50  DTCP* dtcp = getRINAModule<DTCP*>(this, 1, {MOD_DTCP});
51  /* Default */
52 
53  // bool sendAck = false;
54  // bool sendFC = true;
55 
56  /* RcvrControlAck Policy with Default: */
57  //"adjust as necessary" :D great advice
58  ControlAckPDU* ctrlAckPDU = (ControlAckPDU*)dtpState->getCurrentPdu();
59  // TODO: unsigned int lastCtrlSeqNumRcv;
60  if(dtcpState->getNextSndCtrlSeqNumNoInc() != ctrlAckPDU->getLastCtrlSeqNumRcv()){
61  // Does not necessary means an error.
62 
63  }
64  //unsigned int sndLtWinEdge;
65  if(ctrlAckPDU->getRcvLeftWinEdge() > dtpState->getRcvLeftWinEdge()){
66  bubble("ControlAckPDU: Missing PDU on the receiver end.");
67  // throw cRuntimeError("ControlAckPDU: Missing PDU on the receiver end.");
68  }else if(ctrlAckPDU->getRcvLeftWinEdge() < dtpState->getRcvLeftWinEdge()){
69  // sendAck = true;
70  }
71 
72  //unsigned int sndRtWinEdge;
73  if(ctrlAckPDU->getRcvRightWinEdge() != dtcpState->getRcvRightWinEdge()){
74  // sendFC = true;
75  }
76 
77  //unsigned int myLtWinEdge;
78  if(ctrlAckPDU->getSndLeftWinEdge() > dtcpState->getSndLeftWinEdge()){
79  //serves as an ack -> remove PDUs from RxQ
80  dtcp->ackPDU(ctrlAckPDU->getSndLeftWinEdge() - 1);
81  dtcp->updateSenderLWE(ctrlAckPDU->getSndLeftWinEdge());
82  }else if(ctrlAckPDU->getSndLeftWinEdge() < dtcpState->getSndLeftWinEdge()){
83  bubble("ControlAckPDU: Missing PDU on the sender's end.");
84  // throw cRuntimeError("ControlAckPDU: Missing PDU on the sender's end.");
85  }
86 
87  // unsigned int myRtWinEdge;
88  if(ctrlAckPDU->getSndRightWinEdge() != dtcpState->getSndRightWinEdge()){
89  dtcpState->setSenderRightWinEdge(ctrlAckPDU->getSndRightWinEdge());
90  }
91 
92  //unsigned int myRcvRate;
93  if(ctrlAckPDU->getRcvRate() != dtcpState->getSendingRate()){
94  dtcpState->setSendingRate(ctrlAckPDU->getRcvRate());
95  }
96 
97  //TODO A2 Verify it one more time
98  // if(sendAck && sendFC){
99  // dtp->sendAckFlowPDU();
100  // }else if (sendAck){
101  // dtp->sendAckOnlyPDU(dtpState->getRcvLeftWinEdge() - 1);
102  // }else{
103  // dtp->sendFCOnlyPDU();
104  // }
105  // Send Ack/Flow Control PDU with LWE and RWE
106  dtp->sendAckFlowPDU();
107 
108 
109  //TODO A1 Consult Specifications (Commented it out for just for now)
110 // // Send empty Transfer PDU with NextSeqNumToSend-1
111 // DataTransferPDU* dataPdu = new DataTransferPDU("Empty DTPDU");
112 // dtp->setPDUHeader(dataPdu);
113 // unsigned int seqNum = dtpState->getNextSeqNumToSendWithoutIncrement() - 1;
114 // dataPdu->setSeqNum(seqNum);
115 // UserDataField* userData = new UserDataField("Empty UserDataField");
116 //
118 // dataPdu->encapsulate(userData);
119 //
120 // dtp->sendToRMT(dataPdu);
121 
122 
123  /* End default */
124 }
void setSenderRightWinEdge(unsigned int senderRightWinEdge)
Definition: DTCPState.cc:147
Definition: DTCP.h:63
unsigned int getSndRightWinEdge() const
Definition: DTCPState.cc:142
unsigned int getSendingRate() const
Definition: DTCPState.cc:368
unsigned int getRcvLeftWinEdge() const
Definition: DTPState.cc:258
void setSendingRate(unsigned int sendingRate)
Definition: DTCPState.cc:393
unsigned int getRcvRightWinEdge() const
Definition: DTCPState.cc:178
const PDU * getCurrentPdu() const
Definition: DTPState.cc:339
void sendAckFlowPDU(unsigned int seqNum=0, bool seqNumValid=false)
Definition: DTP.cc:565
unsigned int getSndLeftWinEdge() const
Definition: DTCPState.cc:134
unsigned int getNextSndCtrlSeqNumNoInc()
Definition: DTCPState.cc:203
void defaultAction(DTPState *dtpState, DTCPState *dtcpState)
const char * MOD_DTCP
Definition: ExternConsts.cc:36
const char * MOD_DTP
Definition: ExternConsts.cc:38
Definition: DTP.h:60