RINASim  October 2016
Documentation of framework for OMNeT++
AEConstantClient.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 #include "AEConstantClient.h"
24 
26 
28 
31  FlowObject = NULL;
32  Irm = NULL;
33  Cdap = NULL;
34 }
35 
36 
38 {
39  //Init pointers
40  initPointers();
41  //Source info
43  //Setup signals
45  //Init QoSRequirements
47 
48  //Destination for flow
49  dstApName = this->par("dstApName").stringValue();
50  dstApInstance = this->par("dstApInstance").stringValue();
51  dstAeName = this->par("dstAeName").stringValue();
52  dstAeInstance = this->par("dstAeInstance").stringValue();
53 
54  signal = registerSignal("AEConstantPing-RCV");
55 
56  //Timers
57  simtime_t startAt = simTime() + par("startAt");
58  if(startAt<0) { startAt = 0; }
59  scheduleAt(startAt, new cMessage("Start"));
60 }
61 
63 
65  EV << "Flow not initialized :" << endl;
66 
67  APNamingInfo src = this->getApni();
69  this->dstAeName, this->dstAeInstance);
70  EV << "\t" << src << " -> " << dst << endl;
71  }
72 }
73 
75  if(StartMsg* m = dynamic_cast<StartMsg*>(msg)) {
77  sendData(FlowObject, m);
78  } else {
79  scheduleAt(simTime()+1, m);
80  }
81  } else {
82  APNamingInfo src = this->getApni();
84  this->dstAeName, this->dstAeInstance);
85 
86  FlowObject = new Flow(src, dst);
88 
89  insertFlow();
90 
92 
93  scheduleAt(simTime()+1, new StartMsg());
94  delete msg;
95  }
96 }
97 
98 void AEConstantClient::handleMessage(cMessage *msg) {
99  if ( msg->isSelfMessage() ) {
100  this->handleSelfMessage(msg);
101  } else if(PingMsg* m = dynamic_cast<PingMsg*>(msg)) {
102  if(m->counted) {
103  emit(signal, new SignalMsg(FlowObject->getConId().getQoSId(), simTime() - m->pingAt));
104  }
105 
106  PongMsg* r = new PongMsg(m->pingAt, m->counted);
107  r->setByteLength(m->getByteLength());
108  sendData(FlowObject, r);
109  } else {
110  std::cout << "Unknown msg received" << endl;
111  // error ("Unknown msg received");
112  }
113 }
114 
116  handleMessage(msg);
117 }
118 
120  handleMessage(msg);
121 }
virtual void processMRead(CDAPMessage *msg)
Class representing flow object with attributes from specs.
Definition: Flow.h:45
void setQosRequirements(const QoSReq &qosReqs)
Sets QoS parameters wanted by flow initiator.
Definition: Flow.cc:323
virtual void initialize()
std::string dstApInstance
Flow * FlowObject
Definition: AEBase.h:90
CDAPConnectionState connectionState
Definition: AEBase.h:106
Application Process Name class.
Definition: APN.h:36
Definition: AE.h:44
const APNamingInfo & getApni() const
Definition: AEBase.cc:47
std::string getQoSId() const
Getter of selected QoS-cube identifier.
Definition: ConnectionId.cc:44
cModule * Cdap
Definition: AE.h:74
void handleSelfMessage(cMessage *msg)
simsignal_t signal
void initNamingInfo()
Definition: AEBase.cc:111
Definition: AEBase.h:58
virtual void processMReadR(CDAPMessage *msg)
const int VAL_UNDEF_CEPID
Definition: ConnectionId.cc:26
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
virtual void finish()
std::string dstAeInstance
void initPointers()
Definition: AE.cc:56
void initQoSRequiremets()
Definition: AEBase.cc:136
IRM * Irm
Definition: AE.h:73
int getDstCepId() const
Getter of destination Connection-Endpoint identifier.
Definition: ConnectionId.cc:34
void insertFlow()
Definition: AE.cc:200
const ConnectionId & getConId() const
Gets read-only Flow's ConnectionId.
Definition: Flow.cc:86
const QoSReq & getQoSRequirements() const
Definition: AEBase.cc:128
Define_Module(AEConstantClient)
void initSignalsAndListeners()
Definition: AE.cc:67
void sendData(Flow *flow, CDAPMessage *msg)
Definition: AE.cc:383
std::string dstAeName
virtual ~AEConstantClient()
std::string dstApName
void sendAllocationRequest(Flow *flow)
Definition: AE.cc:369
virtual void handleMessage(cMessage *msg)