RINASim  October 2016
Documentation of framework for OMNeT++
IDPerNQoSxPLen.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 "IDPerNQoSxPLen.h"
24 #include "IPLSPDUFG.h"
25 
26 using namespace std;
27 
29 
31 {
32  if(pdu->getConnId().getQoSId() == VAL_MGMTQOSID){
33  return "M";
34  }
35 
36  string qos = pdu->getConnId().getQoSId();
37 
38  int h = hCount[qos][pdu->getDstAddr().getIpcAddress().getName()] + pdu->getHopCount();
39  if(h >= maxHCount) { h = maxHCount; }
40  if(h <= 0) { h = 1; }
41 
42  return qos + "_" + to_string(h);
43 }
44 
46 {
47  if(pdu->getConnId().getQoSId() != VAL_MGMTQOSID){ return "M"; }
48  return "Q";
49 }
50 
51 
53  maxHCount = par("maxHCount").longValue();
54  if(maxHCount <= 0) { maxHCount = 1; }
55 
56  cXMLElement* Xml = NULL;
57  if (par("data").xmlValue() != NULL && par("data").xmlValue()->hasChildren()) {
58  Xml = par("data").xmlValue();
59 
60  cXMLElementList nodeList = Xml->getChildrenByTagName("node");
61  for(auto & node : nodeList) {
62  if(!node->getAttribute("addr")) { error("node/addr parameter not initialized!"); }
63  if(!node->getAttribute("qos")) { error("node/qos parameter not initialized!"); }
64  if(!node->getAttribute("d")) { error("node/d parameter not initialized!"); }
65 
66  string addr = node->getAttribute("addr");
67  string qos = node->getAttribute("qos");
68  int d = atoi(node->getAttribute("d"));
69  if(d <= 0) { d = 1; }
70 
71  hCount[qos][addr] = d;
72  }
73  }
74 
75  IPLSPDUFG * genMod = check_and_cast<IPLSPDUFG *>
76  (getModuleByPath(par("genModPath").stdstringValue().c_str()));
77  genMod->registerQidsGen(this);
78 
79 }
80 
82  IPLSPDUFG * genMod = check_and_cast<IPLSPDUFG *>
83  (getModuleByPath(par("genModPath").stdstringValue().c_str()));
84  genMod->unregisterQidsGen(this);
85 }
86 
87 void IDPerNQoSxPLen::setDistance(string addr, string qos, int d) {
88  hCount[qos][addr] = d;
89 }
std::string getQoSId() const
Getter of selected QoS-cube identifier.
Definition: ConnectionId.cc:44
const APN & getIpcAddress() const
Getter of IPC Process address which should be unambiguous within DIF.
Definition: Address.cc:83
void registerQidsGen(IDPerNQoSxPLen *qId)
Definition: IPLSPDUFG.cc:4
const std::string VAL_MGMTQOSID
Definition: QoSCube.cc:37
virtual ConnectionId & getConnId()
Definition: PDU_m.cc:336
void unregisterQidsGen(IDPerNQoSxPLen *qId)
Definition: IPLSPDUFG.cc:7
Definition: PDU.h:42
virtual Address & getDstAddr()
Definition: PDU_m.cc:306
string generateOutputQueueID(PDU *pdu)
string generateInputQueueID(PDU *pdu)
Define_Module(IDPerNQoSxPLen)
virtual unsigned int getHopCount() const
Definition: PDU_m.cc:386
const std::string & getName() const
Gets APN string name representation.
Definition: APN.cc:40
void setDistance(string addr, string qos, int d)