RINASim  October 2016
Documentation of framework for OMNeT++
HopsSingleMEntries.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 
21 namespace HopsSingleMEntries {
22 
24 
25 using namespace std;
26 using namespace common_GraphCL;
27 
28 // A new flow has been inserted/or removed
29 void HopsSingleMEntries::insertedFlow(const Address &addr, const QoSCube &qos, RMTPort * port){
30  string dst = addr.getIpcAddress().getName();
31  neighbours[dst].insert(port);
32  if(neighbours[dst].size() == 1){
33  rt->insertFlow(addr, dst, "", 1);
34  routingUpdated();
35  }
36 }
37 void HopsSingleMEntries::removedFlow(const Address &addr, const QoSCube& qos, RMTPort * port){
38  std::string dst = addr.getIpcAddress().getName();
39  neighbours[dst].erase(port);
40  if(neighbours[dst].size() <= 0){
41  rt->removeFlow(addr, dst, "");
42  neighbours.erase(dst);
43  routingUpdated();
44  }
45 }
46 
47 //Routing has processes a routing update
49  map<string, map<string, nhLMetric<mType> > > changes = rt->getChanges();
50 
51  for(const auto & entry : changes[""]){
52  std::vector< RMTPort * > ps;
53  for(string nextHop : entry.second.nh){
54  RMTPort * p = NULL;
55  if(nextHop != "") {
56  auto n = neighbours.find(nextHop);
57  if(n != neighbours.end()){
58  if(!n->second.empty()) {
59  p = *(n->second.begin());
60  }
61  }
62  }
63  if(p != NULL) {
64  ps.push_back(p);
65  }
66  }
67  fwd->addReplace(entry.first, ps);
68  }
69 }
70 
71 // Called after initialize
73  //Set Forwarding policy
74  fwd = getRINAModule<IntMMForwarding *>(this, 2, {MOD_RELAYANDMUX, MOD_POL_RMT_PDUFWD});
75  rt = getRINAModule<IntTSimpleRouting<mType> *>(this, 2, {MOD_POL_ROUTING});
76 
77  difA = getRINAModule<DA*>(this, 3, {MOD_DIFALLOC, MOD_DA});
78 
79  mType infMetric = par("infinite");
80  rt->setInfinite(infMetric);
81 }
82 
83 }
const char * MOD_POL_ROUTING
Definition: ExternConsts.cc:77
const char * MOD_DIFALLOC
Definition: ExternConsts.cc:34
virtual void removedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
const APN & getIpcAddress() const
Getter of IPC Process address which should be unambiguous within DIF.
Definition: Address.cc:83
Register_Class(HopsSingleMEntries)
const char * MOD_RELAYANDMUX
Definition: ExternConsts.cc:57
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...
Definition: QoSCube.h:57
const char * MOD_DA
Definition: ExternConsts.cc:33
const std::string & getName() const
Gets APN string name representation.
Definition: APN.cc:40
const char * MOD_POL_RMT_PDUFWD
Definition: ExternConsts.cc:73
Address class holds IPC Process identification.
Definition: Address.h:42
unsigned short mType