RINASim  October 2016
Documentation of framework for OMNeT++
DV.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 /*
24  * DV.h
25  *
26  * Created on: Mar 23, 2015
27  * Author: gaixas1
28  */
29 
30 #ifndef DV_H_
31 #define DV_H_
32 
33 #include <DomainRouting/rModule.h>
34 
35 namespace DMRnmsDV {
36 
37 using namespace DMRnms;
38 
40 // Data structures
41 
42 struct rtEntry {
43  std::string addr;
44  unsigned short metric;
46  :addr(""), metric(UINT16_MAX){}
47  rtEntry(const std::string &_addr, const unsigned short &_metric)
48  :addr(_addr), metric(_metric){}
49 };
50 typedef std::vector<rtEntry> entriesL;
51 typedef std::vector<rtEntry>::iterator entriesIt;
52 
53 typedef std::map<Address, unsigned short> neighMetric;
54 typedef neighMetric::iterator neighMetricIt;
55 
56 
57 struct tEntry {
59  unsigned short metric;
61  :addr(""), metric(UINT16_MAX){}
62  tEntry(const std::string &_addr, const unsigned short &_metric)
63  :addr(_addr), metric(_metric){}
64 };
65 typedef std::map<std::string, tEntry> tTable;
66 typedef tTable::iterator tTableIt;
67 
68 typedef std::set<std::string> sSet;
69 typedef sSet::iterator sSetIt;
70 
71 
72 
74 // Update Message
75 
76 class DVUpdate : public RoutingUpdate {
77 public:
78  DVUpdate(const Address &_addr, const std::string &_domain);
79 
80  void addEntry(rtEntry _e);
81 
82  entriesIt entriesBegin();
83  entriesIt entriesEnd();
84 
85 protected:
86  entriesL entries;
87 };
88 
89 
90 
92 // Routing Module
93 
94 class DomainRouting;
95 
96 class DV: public rModule {
97 public:
98  DV(Routing * parent, const Address &_nAddr,const std::string &_domain, const std::string &_addr);
99 
100  bool processUpdate(RoutingUpdate * update);
101  void addFlow(const Address &_nAddr, const std::string &_addr, const unsigned short &_metric);
102  void removeFlow(const Address &_nAddr, const std::string &_addr);
103 
104  void addAddr(const std::string &_addr);
105  void removeAddr(const std::string &_addr);
106 
107  void setInfMetric(const unsigned short &inf);
108 
109  dmNxt getChanges();
110  dmNxt getAll();
111 
112  void handleMessage(cMessage *msg);
113 
114 protected:
115  tTable table;
116  neighMetric nei;
117  unsigned short infMetric;
120  sSet myAddrSet;
121 
123  void scheduleUpdate();
124 };
125 
126 } /* namespace DomainRoutingDV */
127 
128 #endif /* DV_H_ */
entriesL entries
Definition: DV.h:86
sSet myAddrSet
Definition: DV.h:120
tEntry(const std::string &_addr, const unsigned short &_metric)
Definition: DV.h:62
bool scheduledUpdate
Definition: DV.h:122
Definition: DV.h:57
tTable::iterator tTableIt
Definition: DV.h:66
std::map< std::string, tEntry > tTable
Definition: DV.h:65
Definition: DV.h:42
std::vector< rtEntry >::iterator entriesIt
Definition: DV.h:51
sSet::iterator sSetIt
Definition: DV.h:69
std::set< std::string > sSet
Definition: DV.h:68
std::vector< rtEntry > entriesL
Definition: DV.h:50
rtEntry()
Definition: DV.h:45
tEntry()
Definition: DV.h:60
s2A changes
Definition: DV.h:118
Address addr
Definition: DV.h:58
std::string addr
Definition: DV.h:43
tTable table
Definition: DV.h:115
neighMetric nei
Definition: DV.h:116
unsigned short metric
Definition: DV.h:44
sSet changedEntries
Definition: DV.h:119
unsigned short metric
Definition: DV.h:59
std::map< std::string, Address > s2A
Definition: rModule.h:43
rtEntry(const std::string &_addr, const unsigned short &_metric)
Definition: DV.h:47
std::map< Address, unsigned short > neighMetric
Definition: DV.h:53
Address class holds IPC Process identification.
Definition: Address.h:42
neighMetric::iterator neighMetricIt
Definition: DV.h:54
unsigned short infMetric
Definition: DV.h:117
Definition: DV.cc:33