RINASim  October 2016
Documentation of framework for OMNeT++
AEConstantServer.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 "AEConstantServer.h"
24 
26 
27 
28 
30 
33  FlowObject = NULL;
34  Irm = NULL;
35  Cdap = NULL;
36 }
37 
38 
40 {
41  //Init pointers
42  initPointers();
43  //Source info
45  //Setup signals
47  //Init QoSRequirements
49 
50  countStart = par("countStart").longValue();
51  countEnd = par("countEnd").longValue();
52  stopAt = par("stopAt").longValue();
53 
54  rate = par("rate").doubleValue();
55  wperbit = 1.0/(rate*1024);
56  wvar = par("waitvar").doubleValue();
57 
58  size = par("size").longValue();
59  sizevar = par("sizevar").longValue();
60 
61  signal_snd = registerSignal("AEConstantPing-SND");
62  signal_rcv = registerSignal("AEConstantPong-RCV");
63 
64  count=0;
65 }
66 
68  if(count < 10) {
69  std::cout << "WTF!! count >> "<<count <<endl;
70  }
71  /*
72  if(FlowObject != NULL) {
73  EV << this->getFullPath() << " / ";
74  EV << "With QoS " << FlowObject->getConId().getQoSId() <<endl;
75  }
76  */
77 }
78 
80  if(count < stopAt) {
81  PingMsg* ping = new PingMsg(count >= countStart && count < countEnd);
82 
83  int msgSize = size + intuniform(-sizevar,sizevar);
84  ping->setByteLength(msgSize);
85 
86  if(ping->counted) {
88  }
89 
90  //Send message
91  sendData(FlowObject, ping);
92  count++;
93  double wtime = (msgSize+40)*wperbit*uniform(1-wvar, 1+wvar);
94  scheduleAt(simTime() + wtime, msg);
95 
96  } else if(count == stopAt) {
97  scheduleAt(simTime() + 1, msg);
98  } else {
99  delete msg;
100  }
101 }
102 
104 {
105  if ( msg->isSelfMessage() ) {
106  this->handleSelfMessage(msg);
107  } else if(PongMsg* m = dynamic_cast<PongMsg*>(msg)) {
108  if(m->counted) {
109  emit(signal_rcv, new SignalMsg(FlowObject->getConId().getQoSId(), simTime() - m->pongAt, simTime() - m->pingAt));
110  }
111  } else if(dynamic_cast<StartMsg*>(msg)) {
112  scheduleAt(simTime(), new cMessage("Send"));
113  } else {
114  error ("Unknown msg received");
115  }
116 }
117 
119  handleMessage(msg);
120 }
121 
123  handleMessage(msg);
124 }
Flow * FlowObject
Definition: AEBase.h:90
CDAPConnectionState connectionState
Definition: AEBase.h:106
Definition: AE.h:44
std::string getQoSId() const
Getter of selected QoS-cube identifier.
Definition: ConnectionId.cc:44
cModule * Cdap
Definition: AE.h:74
virtual void initialize()
virtual void finish()
simsignal_t signal_rcv
virtual void processMRead(CDAPMessage *msg)
void initNamingInfo()
Definition: AEBase.cc:111
Definition: AEBase.h:58
void initPointers()
Definition: AE.cc:56
void initQoSRequiremets()
Definition: AEBase.cc:136
IRM * Irm
Definition: AE.h:73
simsignal_t signal_snd
virtual ~AEConstantServer()
virtual void handleMessage(cMessage *msg)
const ConnectionId & getConId() const
Gets read-only Flow's ConnectionId.
Definition: Flow.cc:86
virtual void processMReadR(CDAPMessage *msg)
void handleSelfMessage(cMessage *msg)
void initSignalsAndListeners()
Definition: AE.cc:67
void sendData(Flow *flow, CDAPMessage *msg)
Definition: AE.cc:383
Define_Module(AEConstantServer)
bool counted