RINASim  October 2016
Documentation of framework for OMNeT++
Flow.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 "Flow.h"
24 
25 const int VAL_UNDEF_PORTID = -1;
26 const int VAL_MGMT_PORTID = 0;
27 const int VAL_MAXHOPCOUNT = 16;
28 const int VAL_MAXCREATERETRIES = 3;
29 
31 
33  srcApni(APNamingInfo()), dstApni(APNamingInfo()),
34  srcPortId(VAL_UNDEF_PORTID), dstPortId(VAL_UNDEF_PORTID),
35  srcAddr(Address()), dstAddr(Address()),
36  srcNeighbor(Address()), dstNeighbor(Address()),
37  conId(ConnectionId()),
38  createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT),
39  allocInvokeId(0), deallocInvokeId(0),
40  ddtFlag(false)
41 {
42 }
43 
45  srcApni(src), dstApni(dst),
46  srcPortId(VAL_UNDEF_PORTID), dstPortId(VAL_UNDEF_PORTID),
47  srcAddr(Address()), dstAddr(Address()),
48  srcNeighbor(Address()), dstNeighbor(Address()),
49  conId(ConnectionId()),
50  createFlowRetries(0), maxCreateFlowRetries(VAL_MAXCREATERETRIES), hopCount(VAL_MAXHOPCOUNT),
51  allocInvokeId(0), deallocInvokeId(0),
52  ddtFlag(false)
53 {
54 }
55 
57  this->srcApni = APNamingInfo();
58  this->dstApni = APNamingInfo();
59  this->srcPortId = 0;
60  this->dstPortId = 0;
61  this->srcAddr = Address();
62  this->dstAddr = Address();
63  this->createFlowRetries = 0;
64  this->maxCreateFlowRetries = 0;
65  this->hopCount = 0;
66  srcNeighbor = Address();
67  dstNeighbor = Address();
68  allocInvokeId = 0;
69  deallocInvokeId = 0;
70  ddtFlag = false;
71 }
72 
73 bool Flow::operator ==(const Flow& other) const {
74  return (srcApni == other.srcApni && dstApni == other.dstApni
75  && srcPortId == other.srcPortId && dstPortId == other.dstPortId
76  && srcAddr == other.srcAddr && dstAddr == other.dstAddr
77  && conId == other.conId
79  && hopCount == other.hopCount
80  && srcNeighbor == other.srcNeighbor && dstNeighbor == other.dstNeighbor
81  //&& allocInvokeId == other.allocInvokeId && deallocInvokeId == other.deallocInvokeId
82  && ddtFlag == other.ddtFlag
83  );
84 }
85 
86 const ConnectionId& Flow::getConId() const {
87  return conId;
88 }
89 
90 void Flow::setConId(const ConnectionId& conId) {
91  this->conId = conId;
92 }
93 
94 uint32_t Flow::getCreateFlowRetries() const {
95  return createFlowRetries;
96 }
97 
98 void Flow::setCreateFlowRetries(uint32_t createFlowRetries) {
99  this->createFlowRetries = createFlowRetries;
100 }
101 
103  return dstApni;
104 }
105 
106 void Flow::setDstApni(const APNamingInfo& dstApni) {
107  this->dstApni = dstApni;
108 }
109 
110 int Flow::getDstPortId() const {
111  return dstPortId;
112 }
113 
114 void Flow::setDstPortId(int dstPortId) {
115  this->dstPortId = dstPortId;
116 }
117 
118 uint32_t Flow::getHopCount() const {
119  return hopCount;
120 }
121 
122 void Flow::setHopCount(uint32_t hopCount) {
123  this->hopCount = hopCount;
124 }
125 
127  return maxCreateFlowRetries;
128 }
129 
130 void Flow::setMaxCreateFlowRetries(uint32_t maxCreateFlowRetries) {
131  this->maxCreateFlowRetries = maxCreateFlowRetries;
132 }
133 
135  return srcApni;
136 }
137 
138 void Flow::setSrcApni(const APNamingInfo& srcApni) {
139  this->srcApni = srcApni;
140 }
141 
142 int Flow::getSrcPortId() const {
143  return srcPortId;
144 }
145 
146 void Flow::setSrcPortId(int srcPortId) {
147  this->srcPortId = srcPortId;
148 }
149 
150 const Address& Flow::getDstAddr() const {
151  return dstAddr;
152 }
153 
154 void Flow::setDstAddr(const Address& dstAddr) {
155  this->dstAddr = dstAddr;
156 }
157 
158 const Address& Flow::getSrcAddr() const {
159  return srcAddr;
160 }
161 
162 void Flow::setSrcAddr(const Address& srcAddr) {
163  this->srcAddr = srcAddr;
164 }
165 
166 
167 void Flow::setQosCube(const QoSCube& qosCube) {
168  this->qosCube = qosCube;
169 }
170 
171 const QoSCube& Flow::getQosCube() const {
172  return qosCube;
173 }
174 
175 
177  return qosReqs;
178 }
179 
180 
181 
182 Flow* Flow::dup() const {
183  Flow* flow = new Flow();
184  flow->setSrcApni(this->getSrcApni());
185  flow->setDstApni(this->getDstApni());
186  flow->setSrcAddr(this->getSrcAddr());
187  flow->setDstAddr(this->getDstAddr());
188  flow->setSrcPortId(this->getSrcPortId());
189  flow->setDstPortId(this->getDstPortId());
190  flow->setConId(this->getConId());
192  flow->setHopCount(this->getHopCount());
194  flow->setQosCube(this->getQosCube());
195  flow->setQosRequirements(this->getQosRequirements());
196  flow->setSrcNeighbor(this->getSrcNeighbor());
197  flow->setDstNeighbor(this->getDstNeighbor());
198  flow->setAllocInvokeId(this->getAllocInvokeId());
199  flow->setDeallocInvokeId(this->getDeallocInvokeId());
200  return flow;
201 }
202 
203 std::string Flow::getFlowName() const {
204  std::stringstream os;
205  os << srcApni << "<=>" << dstApni;
206  return os.str();
207 }
208 
210  return conId;
211 }
212 
214  int tmp = srcPortId;
216  dstPortId = tmp;
217 }
218 
220  Address tmpa = srcAddr;
221  srcAddr = dstAddr;
222  dstAddr = tmpa;
223 }
224 
226  conId = conId.swapCepIds();
227 }
228 
229 std::string Flow::infoSource() const {
230  std::stringstream os;
231  os << "SRC> " << (isManagementFlowLocalToIPCP() ? "RIBd of ": "") << srcApni
232  << "\n address: " << srcAddr
233  << ", neighbor: " << srcNeighbor
234  << "\n port: " << srcPortId
235  << "\n cep: " << conId.getSrcCepId();
236  return os.str();
237 }
238 
239 std::string Flow::infoDestination() const {
240  std::stringstream os;
241  os << "DST> " << (isManagementFlowLocalToIPCP() ? "RIBd of ": "") << dstApni
242  << "\n address: " << dstAddr
243  << ", neighbor: " << dstNeighbor
244  << "\n port: " << dstPortId
245  << "\n cep: " << conId.getDstCepId();
246  return os.str();
247 }
248 
249 std::string Flow::infoOther() const {
250  std::stringstream os;
251  os << "Hop Count: " << hopCount << endl
252  << "Retries: " << createFlowRetries << "/" << maxCreateFlowRetries << endl
253  << "DDT: " << (ddtFlag ? "yes" : "no");
254  //endl << "InvokeIds: allocate(" << allocInvokeId << ") deallocate(" << deallocInvokeId << ")";
255  return os.str();
256 }
257 
258 std::string Flow::infoQoS() const {
259  std::stringstream os;
260  os << "Chosen RA's QoS cube: " << conId.getQoSId();
261  if (this->isManagementFlow() && !this->isManagementFlowLocalToIPCP())
262  {
263  os << " (aggregated)";
264  }
265  os << endl << qosReqs.info();
266  return os.str();
267 }
268 
269 bool Flow::compare(const Flow& other) const {
270  return (srcApni == other.srcApni && dstApni == other.dstApni
271  && srcPortId == other.srcPortId && dstPortId == other.dstPortId
272  && srcAddr == other.srcAddr && dstAddr == other.dstAddr
273  && conId == other.conId
274  );
275 }
276 
278  return allocInvokeId;
279 }
280 
281 void Flow::setAllocInvokeId(long allocInvokeId) {
282  this->allocInvokeId = allocInvokeId;
283 }
284 
286  return deallocInvokeId;
287 }
288 
289 void Flow::setDeallocInvokeId(long deallocInvokeId) {
290  this->deallocInvokeId = deallocInvokeId;
291 }
292 
293 bool Flow::isDdtFlag() const {
294  return ddtFlag;
295 }
296 
297 void Flow::setDdtFlag(bool ddtFlag) {
298  this->ddtFlag = ddtFlag;
299 }
300 
302  return qosReqs;
303 }
304 
306  APNamingInfo tmpapni = srcApni;
307  srcApni = dstApni;
308  dstApni = tmpapni;
309 }
310 
312  swapApni();
313 
314  swapAddresses();
315 
316  swapPortIds();
317 
318  swapCepIds();
319 
320  return *this;
321 }
322 
323 void Flow::setQosRequirements(const QoSReq& qosParameters) {
324  this->qosReqs = qosParameters;
325 }
326 
327 std::string Flow::info() const {
328  std::stringstream os;
329  os << infoSource() << endl;
330  os << infoDestination() << endl;
331  os << infoOther() << endl;
332  os << infoQoS() << endl;
333  return os.str();
334 }
335 
336 std::ostream& operator<< (std::ostream& os, const Flow& fl) {
337  return os << fl.info();
338 }
339 
341  return dstNeighbor;
342 }
343 
344 void Flow::setDstNeighbor(const Address& dstNeighbor) {
345  this->dstNeighbor = dstNeighbor;
346 }
347 
349  return srcNeighbor;
350 }
351 
352 void Flow::setSrcNeighbor(const Address& srcNeighbor) {
353  this->srcNeighbor = srcNeighbor;
354 }
355 
357  Flow* mgmtflow = this->dup();
359  mgmtflow->setSrcApni(getSrcAddr().getApn());
360  mgmtflow->setDstApni(getDstNeighbor().getApn());
361  mgmtflow->setDstAddr(getDstNeighbor().getApn());
362  //EV << mgmtflow->info() << endl;
363  return mgmtflow;
364 }
365 
368 }
369 
371  return isManagementFlow()
372  && this->getSrcApni().getApn() == getSrcAddr().getApn()
373  && this->getDstApni().getApn() == getDstAddr().getApn();
374 }
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
const APNamingInfo & getSrcApni() const
Gets read-only source APNamingInfo.
Definition: Flow.cc:134
void setDstApni(const APNamingInfo &dstApni)
Sets destination APNamingInfo.
Definition: Flow.cc:106
ConnectionId & swapCepIds()
Exchanges source and destination CEP identifiers.
void setDstAddr(const Address &dstAddr)
Sets (end-point) destination Address.
Definition: Flow.cc:154
const int VAL_UNDEF_PORTID
Definition: Flow.cc:25
ConnectionId & getConnectionId()
Gets Flow's ConnectionId.
Definition: Flow.cc:209
const int VAL_MAXCREATERETRIES
Definition: Flow.cc:28
long deallocInvokeId
Attribute holding persistant InvokeId used for deallocation.
Definition: Flow.h:436
std::string getQoSId() const
Getter of selected QoS-cube identifier.
Definition: ConnectionId.cc:44
void setAllocInvokeId(long allocInvokeId)
Sets allocation InvokeId.
Definition: Flow.cc:281
bool isDdtFlag() const
Gets whether flow is for Degenerate Data Transfer.
Definition: Flow.cc:293
long getAllocInvokeId() const
Gets allocation InvokeId Used inside M_CREATE(_R)(flow) messages.
Definition: Flow.cc:277
const Address & getSrcNeighbor() const
Gets neighbor source Address, which is the address of (interim) hop-by-hop source Used during flow al...
Definition: Flow.cc:348
std::string info() const
Prints Flow information as string Calls variety of other info functions to produce final output...
Definition: Flow.cc:327
bool ddtFlag
Attribute representing whether flow is for Degenerate Data Transfer or not.
Definition: Flow.h:441
Address srcAddr
Attribute holding source address (initiator of communication)
Definition: Flow.h:380
Connection identifier as defined in specifications.
Definition: ConnectionId.h:42
int getSrcCepId() const
Getter of source Connection-Endpoint identifier.
Definition: ConnectionId.cc:54
QoSReq & getQosReqs()
Definition: Flow.cc:301
void setDstPortId(int dstPortId)
Sets destination PortId.
Definition: Flow.cc:114
Register_Class(Flow)
const APN & getApn() const
Getter of APN.
Definition: APNamingInfo.h:142
void swapAddresses()
Auxiliary function swapping source and destination Addresses.
Definition: Flow.cc:219
void setMaxCreateFlowRetries(uint32_t maxCreateFlowRetries)
Sets maximum allowed number of CreateFlow retries.
Definition: Flow.cc:130
uint32_t maxCreateFlowRetries
Attribute holding maximum allowed number of CreateFlow retries.
Definition: Flow.h:410
void setHopCount(uint32_t hopCount)
Sets a new hop-count. Hop-count should be decremented each time message is forwarded within DIF...
Definition: Flow.cc:122
Address dstAddr
Attribute holding destination address (end-host for communication)
Definition: Flow.h:385
void setSrcApni(const APNamingInfo &srcApni)
Sets source APNamingInfo.
Definition: Flow.cc:138
void setSrcNeighbor(const Address &srcNeighbor)
Sets neighbor source Address.
Definition: Flow.cc:352
int getDstPortId() const
Gets destination PortId.
Definition: Flow.cc:110
std::string infoDestination() const
Prints Flow destination information as string Outputs destination APNI, address, neigbor-address, PortId, CEP-Id.
Definition: Flow.cc:239
int srcPortId
Attribute holding source PortId.
Definition: Flow.h:370
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
Flow * dupToMgmt() const
Definition: Flow.cc:356
const Address & getSrcAddr() const
Gets source Address, which is the address of communication start-point.
Definition: Flow.cc:158
const QoSReq & getQosRequirements() const
Gets QoS parameters wanted by flow initiator.
Definition: Flow.cc:176
const int VAL_MGMT_PORTID
Definition: Flow.cc:26
std::string getFlowName() const
Prints flow name consisting of source and destination APNI Primary use is for OMNeT++ cMessage proper...
Definition: Flow.cc:203
QoSCube qosCube
Attribute holding the assigned QoSCube.
Definition: Flow.h:421
uint32_t hopCount
Attribute holding flow's hop-count.
Definition: Flow.h:415
void setDdtFlag(bool ddtFlag)
Sets Degenerate Data Transfer flag.
Definition: Flow.cc:297
const Address & getDstNeighbor() const
Gets neighbor destination Address, which is the address of (interim) hop-by-hop destination Used duri...
Definition: Flow.cc:340
const int VAL_MAXHOPCOUNT
Definition: Flow.cc:27
void setSrcAddr(const Address &srcAddr)
Sets (start-point) source Address.
Definition: Flow.cc:162
bool isManagementFlow() const
Definition: Flow.cc:366
QoSReq qosReqs
Attribute holding wanted QoS parameters in form of QoSReq.
Definition: Flow.h:426
uint32_t getMaxCreateFlowRetries() const
Gets maximum allowed number CreateFlow retries By default 3 (const VAL_MAXCREATERETRIES). Value is checked during Flow allocation.
Definition: Flow.cc:126
Flow()
Constructor for the flow with undefined values.
Definition: Flow.cc:32
Address dstNeighbor
Attribute holding hop-by-hop destination address.
Definition: Flow.h:395
std::string info() const
Prints QoSReq information as string.
Definition: QoSReq.cc:368
int getDstCepId() const
Getter of destination Connection-Endpoint identifier.
Definition: ConnectionId.cc:34
void setConId(const ConnectionId &conId)
Sets Flow's ConnectionId.
Definition: Flow.cc:90
virtual ~Flow()
Destructor assigning default uninitialized values.
Definition: Flow.cc:56
APNamingInfo srcApni
Attribute holding source APNI.
Definition: Flow.h:360
std::string infoSource() const
Prints Flow source information as string Outputs source APNI, address, neigbor-address, PortId, CEP-Id.
Definition: Flow.cc:229
int getSrcPortId() const
Gets source PortId.
Definition: Flow.cc:142
bool operator==(const Flow &other) const
Equal operator overloading.
Definition: Flow.cc:73
Address srcNeighbor
Attribute holding hop-by-hop source address.
Definition: Flow.h:390
std::ostream & operator<<(std::ostream &os, const Flow &fl)
Definition: Flow.cc:336
std::string infoOther() const
Prints Flow create flow information and hop-cpunt as string.
Definition: Flow.cc:249
std::string infoQoS() const
Prints RA's QoSCube-id that FA choosed during Flow allocation phase Accompanied QoSParameters could b...
Definition: Flow.cc:258
void swapCepIds()
Auxiliary function swapping source and destination CEP-Ids.
Definition: Flow.cc:225
int dstPortId
Attribute holding destination PortId.
Definition: Flow.h:375
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
const ConnectionId & getConId() const
Gets read-only Flow's ConnectionId.
Definition: Flow.cc:86
void setSrcPortId(int srcPortId)
Sets source PortId.
Definition: Flow.cc:146
void setCreateFlowRetries(uint32_t createFlowRetries)
Sets current number of CreateFlow retries During Flow allocation phase, CreateFlow is incremented eac...
Definition: Flow.cc:98
uint32_t createFlowRetries
Attribute holding current number of allowed CreateFlow retries.
Definition: Flow.h:405
void swapApni()
Auxiliary function swapping source and destinatio APNI.
Definition: Flow.cc:305
uint32_t getCreateFlowRetries() const
Gets current number of CreateFlow retries During Flow allocation phase, CreateFlow is incremented eac...
Definition: Flow.cc:94
APNamingInfo dstApni
Attribute holding destination APNI.
Definition: Flow.h:365
const APN & getApn() const
Getter of unique APN which is initialized during object construction.
Definition: Address.cc:119
Class representing QoSReq with all its properties that is primarily used by FA, RMT and RA Specificat...
Definition: QoSReq.h:44
void swapPortIds()
Auxiliary function swapping source and destination PortIds.
Definition: Flow.cc:213
void setDstNeighbor(const Address &dstNeighbor)
Sets neighbor destination Address.
Definition: Flow.cc:344
bool compare(const QoSReq &other) const
Definition: QoSReq.cc:355
const Address & getDstAddr() const
Gets source Address, which is the address of communication end-point.
Definition: Flow.cc:150
bool compare(const Flow &other) const
Comparator taking into account src/dst addresses, src/dst APNIs, src-dst ConIds/PortIds.
Definition: Flow.cc:269
uint32_t getHopCount() const
Gets hop-count, which is number of allowed message forwards from this device towards destination By d...
Definition: Flow.cc:118
bool isManagementFlowLocalToIPCP() const
Definition: Flow.cc:370
const QoSCube & getQosCube() const
Definition: Flow.cc:171
virtual Flow * dup() const
Flow object duplication method that creates copy with.
Definition: Flow.cc:182
long allocInvokeId
Attribute holding persistant InvokeId used for allocation.
Definition: Flow.h:431
ConnectionId conId
Attribute holding ConnectionId containing source and destination CEP-Ids and chosen RA's QoSCube...
Definition: Flow.h:400
Address class holds IPC Process identification.
Definition: Address.h:42
Flow & swapFlow()
Function that swaps relevant source and destination Flow parameters It is being used mainly for count...
Definition: Flow.cc:311
const APNamingInfo & getDstApni() const
Gets read-only destination APNamingInfo.
Definition: Flow.cc:102
void setQosCube(const QoSCube &qosCube)
Definition: Flow.cc:167
void setDeallocInvokeId(long deallocInvokeId)
Sets deallocation InvokeId.
Definition: Flow.cc:289
static const QoSReq MANAGEMENT
Definition: QoSReq.h:152
long getDeallocInvokeId() const
Gets deallocation InvokeId Used inside M_DELETE(_R)(flow) messages.
Definition: Flow.cc:285