RINASim  October 2016
Documentation of framework for OMNeT++
HopsSingle1Entry.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 HopsSingle1Entry {
22 
24 
25 using namespace std;
26 using namespace common_GraphCL;
27 
28 // A new flow has been inserted/or removed
29 void HopsSingle1Entry::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 HopsSingle1Entry::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::string nextHop = "";
53  if(!entry.second.nh.empty()){
54  nextHop = *(entry.second.nh.begin());
55  }
56  RMTPort * p = NULL;
57  if(nextHop != "") {
58  auto n = neighbours.find(nextHop);
59  if(n != neighbours.end()){
60  if(!n->second.empty()) {
61  p = *(n->second.begin());
62  }
63  }
64  }
65  if(p == NULL) {
66  fwd->remove(entry.first);
67  } else {
68  fwd->insert(entry.first, p);
69  }
70  }
71 }
72 
73 // Called after initialize
75  //Set Forwarding policy
76  fwd = getRINAModule<IntMiniForwarding *>(this, 2, {MOD_RELAYANDMUX, MOD_POL_RMT_PDUFWD});
77  rt = getRINAModule<IntTSimpleRouting<mType> *>(this, 2, {MOD_POL_ROUTING});
78 
79  difA = getRINAModule<DA *>(this, 3, {MOD_DIFALLOC, MOD_DA});
80 
81  mType infMetric = par("infinite");
82  rt->setInfinite(infMetric);
83 }
84 
85 }
const char * MOD_POL_ROUTING
Definition: ExternConsts.cc:77
const char * MOD_DIFALLOC
Definition: ExternConsts.cc:34
virtual void routingUpdated()
const APN & getIpcAddress() const
Getter of IPC Process address which should be unambiguous within DIF.
Definition: Address.cc:83
unsigned short mType
virtual void removedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
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
Register_Class(HopsSingle1Entry)
const std::string & getName() const
Gets APN string name representation.
Definition: APN.cc:40
virtual void onPolicyInit()
const char * MOD_POL_RMT_PDUFWD
Definition: ExternConsts.cc:73
Address class holds IPC Process identification.
Definition: Address.h:42