RINASim  October 2016
Documentation of framework for OMNeT++
RxTimerExpiryPolicyBase.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 
33 
35 {
36 }
37 
39 {
40 }
41 
43 {
44  DTP* dtp = getRINAModule<DTP*>(this, 1, {MOD_DTP});
45  DTCP* dtcp = getRINAModule<DTCP*>(this, 1, {MOD_DTCP});
46  DTCPRxExpiryTimer* timer = NULL;
47 
48  std::vector<DTCPRxExpiryTimer*>* rxQ = dtcpState->getRxQ();
49  std::vector<DTCPRxExpiryTimer*>::iterator it;
50 
51  for(it = rxQ->begin(); it != rxQ->end(); ++it){
52  if(!(*it)->isScheduled()){
53  timer = (*it);
54  break;
55  }
56  }
57 
58  if(timer == NULL){
59  throw cRuntimeError("Error, couldn't find RxTimerExpiry");
60  }
61 
62 
63  DataTransferPDU* pdu = timer->getPdu();
64 
65 
66 
67  if (timer->getExpiryCount() == dtcpState->getDataReXmitMax() + 1)
68  {
69  dtcp->deleteRxTimer(timer->getPdu()->getSeqNum());
70  // Notify User Flow that we were unable to maintain the QoS for this connection
72  // throw cRuntimeError("Unable to maintain the QoS for this connection");
73  ASSERT2(true,"Unable to maintain the QoS for this connection. Continue at your own risk.");
74  }
75  else
76  {
77 
78  DataTransferPDU* dup = pdu->dup();
79  dup->setDisplayString("b=15,15,oval,#0099FF,#0099FF,0");
80  std::ostringstream out;
81  out << "Sending PDU number " << pdu->getSeqNum() << " from RX Queue";
82 
83  bubble(out.str().c_str());
84  EV << this->getFullPath() << ": " << out.str().c_str() << " in time " << simTime() << endl;
85  dtp->sendToRMT(dup);
86 
87  dtcpState->incRxSent();
88 
89  timer->setExpiryCount(timer->getExpiryCount() + 1);
90  dtcp->scheduleRxTimerExpiry();
91 
92 
93 
94  }
95 }
unsigned int getDataReXmitMax() const
Definition: DTCPState.cc:254
Definition: DTCP.h:63
void sendToRMT(PDU *pdu)
Definition: DTP.cc:1649
void defaultAction(DTPState *dtpState, DTCPState *dtcpState)
virtual unsigned int getSeqNum() const
Definition: PDU_m.cc:376
virtual void setDisplayString(const char *displayString)
Definition: PDU_m.cc:281
virtual DataTransferPDU * dup() const
std::vector< DTCPRxExpiryTimer * > * getRxQ()
Definition: DTCPState.cc:264
const char * MOD_DTCP
Definition: ExternConsts.cc:36
void incRxSent()
Definition: DTCPState.cc:108
const char * MOD_DTP
Definition: ExternConsts.cc:38
Definition: DTP.h:60
void notifyAboutUnableMaintain()
Definition: DTP.cc:1565