RINASim  October 2016
Documentation of framework for OMNeT++
SimpleHopMEntries.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
15 
17 #include "APN.h"
18 
19 
20 
22 
24 
25 using namespace std;
26 using namespace common_GraphCL;
27 
28 // A new flow has been inserted/or removed
29 void SimpleHopMEntries::insertedFlow(const Address &addr, const QoSCube &qos, RMTPort * port){
30 
31  string dst = addr.getIpcAddress().getName();
32  neighbours[dst].insert(port);
33 
34  if(neighbours[dst].size() == 1){
35  rt->insertFlow(addr, dst, "hops", 1);
36  routingUpdated();
37  }
38 }
39 void SimpleHopMEntries::removedFlow(const Address &addr, const QoSCube& qos, RMTPort * port){
40  std::string dst = addr.getIpcAddress().getName();
41 
42  neighbours[dst].erase(port);
43  if(neighbours[dst].size() <= 0){
44  rt->removeFlow(addr, dst, "hops");
45  neighbours.erase(dst);
46  routingUpdated();
47  }
48 }
49 
50 //Routing has processes a routing update
52  map<string, map<string, nhLMetric<mType> > > changes = rt->getChanges();
53 
54  for(const auto & qosEntries : changes){
55  for(const auto & entry : qosEntries.second){
56  std::vector< RMTPort * > ps;
57  for(string nextHop : entry.second.nh){
58  if(nextHop != "") {
59  if(!neighbours[nextHop].empty()) {
60  ps.push_back(*neighbours[nextHop].begin());
61  }
62  }
63  }
64 
65  fwd->addReplace(entry.first, ps);
66  }
67  }
68 }
69 
70 // Called after initialize
72  //Set Forwarding policy
73  fwd = check_and_cast<IntMMForwarding *>
74  (getModuleByPath("^.^.relayAndMux.pduForwardingPolicy"));
75  rt = check_and_cast<IntTSimpleRouting<mType> *>
76  (getModuleByPath("^.^.routingPolicy"));
77 
78  difA = check_and_cast<DA *>(getModuleByPath("^.^.^.difAllocator.da"));
79 
80  mType infMetric = par("infinite");
81  rt->setInfinite(infMetric);
82 
83  string myAddr = getModuleByPath("^.^")->par("ipcAddress").stringValue();
84 }
85 
86 }
const APN & getIpcAddress() const
Getter of IPC Process address which should be unambiguous within DIF.
Definition: Address.cc:83
virtual void insertedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
Definition: DA.h:43
Register_Class(SimpleHopMEntries)
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
virtual void removedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
const std::string & getName() const
Gets APN string name representation.
Definition: APN.cc:40
Address class holds IPC Process identification.
Definition: Address.h:42