RINASim  October 2016
Documentation of framework for OMNeT++
SimpleDV.h
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 
23 #ifndef SimpleDV_H_
24 #define SimpleDV_H_
25 
26 #include <IntSimpleRouting.h>
27 
28 namespace SimpleDV {
29 
30 struct rtEntry {
31  std::string addr;
32  unsigned short metric;
34  addr = "";
35  metric = UINT16_MAX;
36  }
37  rtEntry(const std::string &_addr, const unsigned short &_metric){
38  addr = _addr;
39  metric = _metric;
40  }
41 };
42 
43 typedef std::vector<rtEntry> entriesL;
44 typedef std::vector<rtEntry>::iterator entriesIt;
45 
46 typedef std::map<Address, unsigned short> neighMetric;
47 typedef std::map<std::string, neighMetric> qosNeighMetric;
48 typedef neighMetric::iterator neighMetricIt;
49 typedef qosNeighMetric::iterator qosNeighMetricIt;
50 
51 typedef std::map<std::string, rtEntry> tTable;
52 typedef std::map<std::string, tTable> rtTable;
53 typedef tTable::iterator tTableIt;
54 typedef rtTable::iterator rtTableIt;
55 
56 
57 
59 public:
60  RoutingUpdate(const Address &_addr, const std::string &_src, const std::string& _qos);
61 
62  std::string getSrc();
63  std::string getQoS();
64 
65  void addEntry(rtEntry);
66 
67  entriesIt entriesBegin();
68  entriesIt entriesEnd();
69 
70 protected:
71  std::string src;
72  std::string qos;
73  entriesL entries;
74 };
75 
76 class SimpleDV: public IntSimpleRouting {
77 public:
78  //Process a Routing Update, return true => inform FWDG of the update
79  bool processUpdate(IntRoutingUpdate * update);
80 
81 
82  //Flow inserted/removed
83  void insertFlow(const Address &addr, const std::string &dst, const std::string& qos, const unsigned short &metric);
84  void removeFlow(const Address &addr, const std::string &dst, const std::string& qos);
85 
86 
87  //Get Changes
88  entries2Next getChanges();
89  entries2Next getAll();
90 
91  void handleMessage(cMessage *msg);
92  void finish();
93 
94 protected:
95  // Called after initialize
96  void onPolicyInit();
97 
98 private:
99  unsigned short infMetric;
100  std::string myAddr;
101  qosNeighMetric neig;
102  rtTable table;
103 
105 
107  void scheduleUpdate();
108 };
109 
110 }
111 
112 #endif /* SimpleDV_H_ */
entries2Next changes
Definition: SimpleDV.h:104
std::vector< rtEntry >::iterator entriesIt
Definition: SimpleDV.h:44
Definition: SimpleDV.h:30
qosNeighMetric::iterator qosNeighMetricIt
Definition: SimpleDV.h:49
qosNeighMetric neig
Definition: SimpleDV.h:101
entriesIt entriesEnd()
Definition: SimpleDV.cc:51
std::map< std::string, rtEntry > tTable
Definition: SimpleDV.h:51
rtTable::iterator rtTableIt
Definition: SimpleDV.h:54
std::string myAddr
Definition: SimpleDV.h:100
std::vector< rtEntry > entriesL
Definition: SimpleDV.h:43
rtEntry()
Definition: SimpleDV.h:33
std::map< std::string, tTable > rtTable
Definition: SimpleDV.h:52
std::map< qosPaddr, std::string > entries2Next
RoutingUpdate(const Address &_addr, const std::string &_src, const std::string &_qos)
Definition: SimpleDV.cc:32
std::string getSrc()
Definition: SimpleDV.cc:37
unsigned short metric
Definition: SimpleDV.h:32
std::string getQoS()
Definition: SimpleDV.cc:40
std::map< Address, unsigned short > neighMetric
Definition: SimpleDV.h:46
tTable::iterator tTableIt
Definition: SimpleDV.h:53
neighMetric::iterator neighMetricIt
Definition: SimpleDV.h:48
entriesIt entriesBegin()
Definition: SimpleDV.cc:48
std::string addr
Definition: SimpleDV.h:31
rtEntry(const std::string &_addr, const unsigned short &_metric)
Definition: SimpleDV.h:37
std::map< std::string, neighMetric > qosNeighMetric
Definition: SimpleDV.h:47
Address class holds IPC Process identification.
Definition: Address.h:42
unsigned short infMetric
Definition: SimpleDV.h:99
void addEntry(rtEntry)
Definition: SimpleDV.cc:44