33 portQoS[port] = qosId;
34 neighbours[qosId][dst].insert(port);
35 int lat = dstLat[dst];
37 fwd->setPortDelay(port, dstDLat[dst]);
44 if(neighbours[qosId][dst].size() == 1){
45 if(urgentQoS.find(qosId) != urgentQoS.end()) {
46 rt->insertFlow(addr, dst, qosId, lat);
48 rt->insertFlow(addr, dst, qosId, 1);
54 neighbours[qosId][dst].insert(port);
55 if(neighbours[qosId][dst].size() == 1){
56 if(urgentQoS.find(qosId) != urgentQoS.end()) {
57 rt->insertFlow(addr, dst, qosId, lat);
59 rt->insertFlow(addr, dst, qosId, 1);
66 string qosId = portQoS[port];
67 neighbours[qosId][dst].erase(port);
68 if(neighbours[qosId][dst].size() <= 0){
69 rt->removeFlow(addr, dst, qosId);
70 neighbours[qosId].erase(dst);
71 if(neighbours[qosId].size()<=0) {
72 neighbours.erase(qosId);
78 neighbours[qosId][dst].erase(port);
79 if(neighbours[qosId][dst].size() <= 0){
80 rt->removeFlow(addr, dst, qosId);
81 neighbours[qosId].erase(dst);
82 if(neighbours[qosId].size()<=0) {
83 neighbours.erase(qosId);
93 map<string, map<string, nhLMetric<mType> > > changes = rt->getChanges();
95 for(
const auto & qosEntries : changes){
96 string qosId = qosEntries.first;
97 for(
const auto & entry : qosEntries.second){
98 std::vector< RMTPort * > ps;
99 for(
string nextHop : entry.second.nh){
102 auto n = neighbours[qosId].find(nextHop);
103 if(n != neighbours[qosId].end()){
104 if(!n->second.empty()) {
105 p = *(n->second.begin());
112 fwd->addReplace(entry.first, qosId, ps);
122 (getModuleByPath(
"^.^.relayAndMux.pduForwardingPolicy"));
124 (getModuleByPath(
"^.^.routingPolicy"));
126 difA = check_and_cast<
DA *>(getModuleByPath(
"^.^.^.difAllocator.da"));
128 mType infMetric = par(
"infinite");
129 rt->setInfinite(infMetric);
131 maxLat = par(
"maxLat").longValue();
133 string myAddr = getModuleByPath(
"^.^")->par(
"ipcAddress").stringValue();
136 cXMLElement* Xml = NULL;
137 if (par(
"data").xmlValue() != NULL && par(
"data").xmlValue()->hasChildren()){
138 Xml = par(
"data").xmlValue();
142 cXMLElementList QoSs = Xml->getChildrenByTagName(
"Qos");
143 for(
auto qos : QoSs){
144 if (!qos->getAttribute(
"id")) { error(
"Error. ID is missing!"); }
145 std::string
id = qos->getAttribute(
"id");
146 if (
id==
"") { error(
"Error. ID cannot be empty!"); }
148 if (!qos->getAttribute(
"urgent")) {
continue; }
149 urgentQoS.insert(
id);
152 double latMultip = par(
"latMultip").doubleValue();
154 cXMLElementList Links = Xml->getChildrenByTagName(
"Link");
155 for(
auto link : Links){
156 if (!link->getAttribute(
"src")) { error(
"Error. Addr is missing!"); }
157 std::string src = link->getAttribute(
"src");
158 if (src==
"") { error(
"Error. Addr cannot be empty!"); }
160 if (!link->getAttribute(
"dst")) { error(
"Error. Addr is missing!"); }
161 std::string dst = link->getAttribute(
"dst");
162 if (dst==
"") { error(
"Error. Addr cannot be empty!"); }
165 if (!link->getAttribute(
"l")) { error(
"Error. Latency is missing!"); }
166 double l = atof(link->getAttribute(
"l"));
167 if (l < 0.0) { error(
"Error. Latency cannot be < 0"); }
168 int lat = l*latMultip;
169 if (lat > maxLat) { lat = maxLat; }
171 if(src == myAddr) { dstLat[dst] = lat; dstDLat[dst] = l/1000.0; }
172 else if(dst == myAddr) { dstLat[src] = lat; dstDLat[src] = l/1000.0; }
virtual void removedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
Register_Class(IQoSAwareMEntries)
const APN & getIpcAddress() const
Getter of IPC Process address which should be unambiguous within DIF.
virtual void insertedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
std::string getQosId() const
Gets QoSCube identifier.
virtual void onPolicyInit()
virtual void routingUpdated()
const std::string & getName() const
Gets APN string name representation.
Address class holds IPC Process identification.