RINASim  October 2016
Documentation of framework for OMNeT++
SingleDomainGenerator.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
24 #include "APN.h"
25 
26 
27 
29 
31 
32 using namespace std;
33 
34 // A new flow has been inserted/or removed
35 void SingleDomainGenerator::insertedFlow(const Address &addr, const QoSCube & qos, RMTPort * port){
36  std::string dst = addr.getIpcAddress().getName();
37  neighbours[dst].insert(port);
38  if(neighbours[dst].size() == 1){
39  rt->addFlow(addr, "", dst,1);
40  routingUpdated();
41  }
42 }
43 void SingleDomainGenerator::removedFlow(const Address &addr, const QoSCube& qos, RMTPort * port){
44  std::string dst = addr.getIpcAddress().getName();
45  neighbours[dst].erase(port);
46  if(neighbours[dst].size() <= 0){
47  rt->removeFlow(addr,"", dst);
48  neighbours.erase(dst);
49  routingUpdated();
50  }
51 }
52 
53 //Routing has processes a routing update
55  DMRnms::dmUpdateM changes = rt->getChanges();
56  for(DMRnms::dmUpdateMIt it = changes.begin(); it!= changes.end(); it++){
57  for(DMRnms::s2AIt eIt = it->entries.begin(); eIt != it->entries.end(); eIt++){
58  std::string dst = eIt->first;
59  std::string nextHop = eIt->second.getIpcAddress().getName();
60 
61  EV << "Entry ::: "<< dst << " -> " << nextHop << " ("<< eIt->second<<")" <<endl;
62  RMTPort * p = NULL;
63 
64  NTableIt n = neighbours.find(nextHop);
65  if(n != neighbours.end()){
66  p = *(n->second.begin());
67  }
68 
69  if(p == NULL) {
70  fwd->remove(dst);
71  } else {
72  fwd->insert(dst, p);
73  }
74  }
75  }
76 }
77 
78 // Called after initialize
80  //Set Forwarding policy
81  fwd = getRINAModule<IntMiniForwarding *>(this, 2, {MOD_RELAYANDMUX, MOD_POL_RMT_PDUFWD});
82  rt = getRINAModule<DMRnms::Routing *>(this, 2, {MOD_POL_ROUTING});
83 
84  std::string alg = par("alg").stdstringValue();
85 
86  if(alg == "LS"){
87  rt->addDomain("", getModuleByPath("^.^")->par("ipcAddress").stringValue(), DMRnms::LS);
88  } else {
89  rt->addDomain("", getModuleByPath("^.^")->par("ipcAddress").stringValue(), DMRnms::DV);
90  }
91 
92 
93  difA = getRINAModule<DA *>(this, 3, {MOD_DIFALLOC, MOD_DA});
94 }
95 
96 }
const char * MOD_POL_ROUTING
Definition: ExternConsts.cc:77
const char * MOD_DIFALLOC
Definition: ExternConsts.cc:34
s2A::iterator s2AIt
Definition: rModule.h:54
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
virtual void insertedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
const char * MOD_RELAYANDMUX
Definition: ExternConsts.cc:57
dmUpdateM::iterator dmUpdateMIt
Definition: rModule.h:56
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
Register_Class(SingleDomainGenerator)
const char * MOD_DA
Definition: ExternConsts.cc:33
std::vector< dmNxt > dmUpdateM
Definition: rModule.h:52
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