RINASim  October 2016
Documentation of framework for OMNeT++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StaticGenerator.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 namespace StaticGenerator {
28 
30 
31 using namespace std;
32 
33 // A new flow has been inserted/or removed
34 void StaticGenerator::insertedFlow(const Address &addr, const QoSCube &qos, RMTPort * port){
35  //Iterate through all QoS cubes and check if qos is a valid
36  for(QoSCube qosI : cubes) {
37  if(comparer->isValid(qosI, qos)) {
38  fwd->insert(addr, qosI.getQosId(), port);
39  fwd->insert(addr, port);
40  const APNList* remoteApps = difA->findNeigborApns(addr.getApn());
41  if (remoteApps) {
42  for (ApnCItem it = remoteApps->begin(); it != remoteApps->end(); ++it) {
43  fwd->insert(Address(it->getName()), qosI.getQosId(), port);
44  fwd->insert(Address(it->getName()), port);
45  }
46  }
47  }
48  }
49 
50  if(qos.getQosId() == VAL_UNDEF_QOSID) {
51  error("Undef QoS");
52  }
53 
54 }
55 void StaticGenerator::removedFlow(const Address &addr, const QoSCube& qos, RMTPort * port){
56  //Iterate through all QoS cubes and check if exist an entry with qos
57  for(QoSCube qosI : cubes) {
58  auto res = fwd->lookup(addr, qosI.getQosId());
59  if(!res.empty()){
60  RMTPort * tp = *res.begin();
61  if(tp == port){
62  fwd->remove(addr, qosI.getQosId());
63  }
64  if (const APNList* remoteApps = difA->findNeigborApns(addr.getApn())) {
65  for (ApnCItem it = remoteApps->begin(); it != remoteApps->end(); ++it){
66  res = fwd->lookup(Address(it->getName()), qosI.getQosId());
67  if(!res.empty()) {
68  tp = *res.begin();
69  if(tp == port){
70  fwd->remove(Address(it->getName()), qosI.getQosId());
71  }
72  }
73  }
74  }
75  }
76  }
77 
78  auto res = fwd->lookup(addr, ANY_QOS);
79  if(!res.empty()){
80  RMTPort * tp = *res.begin();
81  if(tp == port){
82  fwd->remove(addr);
83  }
84  if (const APNList* remoteApps = difA->findNeigborApns(addr.getApn())) {
85  for (ApnCItem it = remoteApps->begin(); it != remoteApps->end(); ++it){
86  res = fwd->lookup(Address(it->getName()), ANY_QOS);
87  if(!res.empty()) {
88  tp = *res.begin();
89  if(tp == port){
90  fwd->remove(Address(it->getName()));
91  }
92  }
93  }
94  }
95  }
96 }
97 
98 //Routing has processes a routing update
100 
101 // Called after initialize
103  //Set Forwarding policy
104  fwd = getRINAModule<SimpleTable::SimpleTable *>(this, 2, {MOD_RELAYANDMUX, MOD_POL_RMT_PDUFWD});
105 
106  difA = getRINAModule<DA *>(this, 3, {MOD_DIFALLOC, MOD_DA});
107 
108 
109  RABase* ResourceAllocator = getRINAModule<RABase*>(this, 2, {MOD_RESALLOC, MOD_RA});
110  cubes = ResourceAllocator->getQoSCubes();
111 
112  comparer = getRINAModule<MultilevelQoS *>(this, 2, {MOD_FLOWALLOC, MOD_POL_RA_QOSCOMPARER});
113 }
114 
115 }
const char * MOD_RESALLOC
Definition: ExternConsts.cc:58
const char * MOD_DIFALLOC
Definition: ExternConsts.cc:34
virtual void insertedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
std::list< APN > APNList
APNList represents the list of APNs.
Definition: APN.h:96
const QoSCubeSet & getQoSCubes() const
Definition: RABase.cc:35
const std::string VAL_UNDEF_QOSID
Definition: QoSCube.cc:36
const char * MOD_RELAYANDMUX
Definition: ExternConsts.cc:57
#define ANY_QOS
Definition: SimpleTable.h:32
const char * MOD_FLOWALLOC
Definition: ExternConsts.cc:47
virtual void removedFlow(const Address &addr, const QoSCube &qos, RMTPort *port)
Definition: RABase.h:36
const char * MOD_POL_RA_QOSCOMPARER
Definition: ExternConsts.cc:70
Class representing QoSCube with all its properties that is primarily used by FA, RMT and RA Specifica...
Definition: QoSCube.h:57
Register_Class(StaticGenerator)
const char * MOD_RA
Definition: ExternConsts.cc:55
std::string getQosId() const
Gets QoSCube identifier.
Definition: QoSCube.cc:364
const char * MOD_DA
Definition: ExternConsts.cc:33
const APN & getApn() const
Getter of unique APN which is initialized during object construction.
Definition: Address.cc:119
APNList::const_iterator ApnCItem
APNList constant iterator.
Definition: APN.h:103
const char * MOD_POL_RMT_PDUFWD
Definition: ExternConsts.cc:73
Address class holds IPC Process identification.
Definition: Address.h:42