33 portQoS[port] = qosId;
34 neighbours[qosId][dst].insert(port);
35 int lat = dstLat[dst];
41 if(neighbours[qosId][dst].size() == 1){
42 if(urgentQoS.find(qosId) != urgentQoS.end()) {
43 rt->insertFlow(addr, dst, qosId, lat);
45 rt->insertFlow(addr, dst, qosId, 1);
51 neighbours[qosId][dst].insert(port);
52 if(neighbours[qosId][dst].size() == 1){
53 if(urgentQoS.find(qosId) != urgentQoS.end()) {
54 rt->insertFlow(addr, dst, qosId, lat);
56 rt->insertFlow(addr, dst, qosId, 1);
63 string qosId = portQoS[port];
64 neighbours[qosId][dst].erase(port);
65 if(neighbours[qosId][dst].size() <= 0){
66 rt->removeFlow(addr, dst, qosId);
67 neighbours[qosId].erase(dst);
68 if(neighbours[qosId].size()<=0) {
69 neighbours.erase(qosId);
75 neighbours[qosId][dst].erase(port);
76 if(neighbours[qosId][dst].size() <= 0){
77 rt->removeFlow(addr, dst, qosId);
78 neighbours[qosId].erase(dst);
79 if(neighbours[qosId].size()<=0) {
80 neighbours.erase(qosId);
90 map<string, map<string, nhLMetric<mType> > > changes = rt->getChanges();
92 for(
const auto & qosEntries : changes){
93 string qosId = qosEntries.first;
94 for(
const auto & entry : qosEntries.second){
95 std::vector< RMTPort * > ps;
96 for(
string nextHop : entry.second.nh){
99 auto n = neighbours[qosId].find(nextHop);
100 if(n != neighbours[qosId].end()){
101 if(!n->second.empty()) {
102 p = *(n->second.begin());
109 fwd->addReplace(entry.first, qosId, ps);
119 (getModuleByPath(
"^.^.relayAndMux.pduForwardingPolicy"));
121 (getModuleByPath(
"^.^.routingPolicy"));
123 difA = check_and_cast<
DA *>(getModuleByPath(
"^.^.^.difAllocator.da"));
125 mType infMetric = par(
"infinite");
126 rt->setInfinite(infMetric);
128 maxLat = par(
"maxLat").longValue();
130 string myAddr = getModuleByPath(
"^.^")->par(
"ipcAddress").stringValue();
133 cXMLElement* Xml = NULL;
134 if (par(
"data").xmlValue() != NULL && par(
"data").xmlValue()->hasChildren()){
135 Xml = par(
"data").xmlValue();
139 cXMLElementList QoSs = Xml->getChildrenByTagName(
"Qos");
140 for(
auto qos : QoSs){
141 if (!qos->getAttribute(
"id")) { error(
"Error. ID is missing!"); }
142 std::string
id = qos->getAttribute(
"id");
143 if (
id==
"") { error(
"Error. ID cannot be empty!"); }
145 if (!qos->getAttribute(
"urgent")) {
continue; }
146 urgentQoS.insert(
id);
149 double latMultip = par(
"latMultip").doubleValue();
151 cXMLElementList Links = Xml->getChildrenByTagName(
"Link");
152 for(
auto link : Links){
153 if (!link->getAttribute(
"src")) { error(
"Error. Addr is missing!"); }
154 std::string src = link->getAttribute(
"src");
155 if (src==
"") { error(
"Error. Addr cannot be empty!"); }
157 if (!link->getAttribute(
"dst")) { error(
"Error. Addr is missing!"); }
158 std::string dst = link->getAttribute(
"dst");
159 if (dst==
"") { error(
"Error. Addr cannot be empty!"); }
162 if (!link->getAttribute(
"l")) { error(
"Error. Latency is missing!"); }
163 double l = atof(link->getAttribute(
"l"));
164 if (l < 0.0) { error(
"Error. Latency cannot be < 0"); }
165 int lat = l*latMultip;
166 if (lat > maxLat) { lat = maxLat; }
168 if(src == myAddr) { dstLat[dst] = lat; }
169 else if(dst == myAddr) { dstLat[src] = lat; }
virtual void onPolicyInit()
const APN & getIpcAddress() const
Getter of IPC Process address which should be unambiguous within DIF.
virtual void removedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
virtual void routingUpdated()
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
std::string getQosId() const
Gets QoSCube identifier.
const std::string & getName() const
Gets APN string name representation.
virtual void insertedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
Address class holds IPC Process identification.
Register_Class(QoSAwareMEntries)