RINASim  October 2016
Documentation of framework for OMNeT++
IntDCRouting.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 #pragma once
24 
25 #include <IntRouting.h>
26 #include <vector>
27 #include <set>
28 #include <map>
29 #include <queue>
30 #include "DCAddr.h"
31 
32 namespace NSPSimpleDC {
33 
34 using namespace std;
35 
36 struct linkId {
37  /*
38  * type - (src/dst)
39  * 0 - (TOR/Fabric)
40  * 1 - (Fabric/Spine)
41  */
42  DCAddr src, dst;
43 
44  linkId();
45  linkId(const DCAddr &_src, const DCAddr &_dst);
46 
47  bool operator<(const linkId &o) const;
48  bool operator==(const linkId & o) const;
49  bool operator!=(const linkId & o) const;
50 };
51 
52 struct linkInfo {
53  /*
54  * link
55  * Affected link
56  *
57  * status
58  * true - link OK
59  * false - link KO
60  * timestamp
61  * last time the link state changed
62  */
64  bool status;
65  simtime_t timestamp;
66 
67  linkInfo();
68  linkInfo(const linkId &_link, const bool &_status, const simtime_t &_timestamp);
69 };
70 
71 struct tableNode {
72  int d;
73  set<const linkId *> L;
74  tableNode();
75  tableNode(const linkId * n);
76 
77  void insert (set<const linkId *> Ls);
78 };
79 
80 class LinksUpdate : public IntRoutingUpdate {
81  public:
82  vector<linkInfo> linksStatus;
83 
84  LinksUpdate * toDst(Address dst);
85 };
86 
87 struct rtEntry {
89  set<DCAddr> next;
90 };
91 
92 class IntDCRouting: public IntRouting {
93 public:
94  //Process a Routing Update, return true => inform FWDG of the update
95  bool processUpdate(IntRoutingUpdate * update);
96 
97  //Flow inserted/removed
98  void insertNeighbour(const Address &addr, const DCAddr &dst);
99  void removeNeighbour(const Address &addr, const DCAddr &dst);
100 
101  //Get Changes
102  vector<rtEntry> getChanges();
103  vector<rtEntry> getAll();
104 
105 protected:
107 
108  cMessage * clean, * start, * sched;
109  int pods, torXpod, fabricXpod, spineXfabric, edgeSets;
110  simtime_t updateWait, expiration;
111 
112  map<linkId, linkInfo> myLinks, linksOk, linksKo;
113  set<Address> activeNeighbours;
114 
115  map<DCAddr, set<const linkId *>> cache;
116 
117  // Called after initialize
118  void onPolicyInit();
119 
120  //Used for cache cleaning
121  virtual void handleMessage(cMessage * msg);
122 
123 
124  virtual void activeNeigh(const DCAddr &dst) = 0;
125  virtual void inactiveNeigh(const DCAddr &dst) = 0;
126 
127  virtual void printAtEnd() = 0;
128 
129  virtual void startMyLinks() = 0;
130  void scheduleUpdate();
131  void scheduleClean();
132 
133  map<DCAddr, tableNode> * computeTable();
134 
135  vector<DCAddr> getNeis(DCAddr);
136 
137  virtual set<DCAddr> getNotOptimalDst(map<DCAddr, tableNode> * table) = 0;
138 
139  void finish();
140 };
141 }
DCAddr dst
Definition: IntDCRouting.h:88
Definition: IntDCRouting.h:87
set< const linkId * > L
Definition: IntDCRouting.h:73
map< linkId, linkInfo > myLinks
Definition: IntDCRouting.h:112
set< DCAddr > next
Definition: IntDCRouting.h:89
set< Address > activeNeighbours
Definition: IntDCRouting.h:113
map< DCAddr, set< const linkId * > > cache
Definition: IntDCRouting.h:115
Address class holds IPC Process identification.
Definition: Address.h:42