RINASim  October 2016
Documentation of framework for OMNeT++
Spine_Routing.cc
Go to the documentation of this file.
1 #include "Spine_Routing.h"
2 
3 
4 
5 namespace NSPSimpleDC {
6 
7  Register_Class(Spine_Routing);
8 
9  void Spine_Routing::activeNeigh(const DCAddr &dst) {
10  if((dst.type != 1 && dst.type != 3 )|| dst.b != Im.a) {
11  cerr << "ADD - I'm " << Im
12  << " -- "
13  << "Invalid neighbour "<< dst
14  << endl;
15  return;
16  }
17 
18  linkId lid = linkId(dst, Im);
19  linkInfo & li = myLinks [lid];
20 
21  if(!li.status) {
22  li.status = true;
23  if(start == nullptr) {
24  li.timestamp = simTime();
25  } else {
26  li.timestamp = 0;
27  }
28  linksKo.erase(lid);
30  }
31  }
32 
34  if((dst.type != 1 && dst.type != 3 )|| dst.b != Im.a) {
35  cerr << "REM - I'm " << Im
36  << " -- "
37  << "Invalid neighbour "<< dst
38  << endl;
39  return;
40  }
41 
42  linkId lid = linkId(dst, Im);
43  linkInfo & li = myLinks [lid];
44 
45  if(li.status) {
46  li.status = false;
47  li.timestamp = simTime();
48  linksKo[lid] = li;
50  }
51  }
52 
54  for(int i = 0; i < pods; i++) {
55  linkId l = linkId(DCAddr(1, i, Im.a), Im);
56  myLinks [l] = linkInfo(l, false, 0);
57  linksKo[l] = linkInfo(l, false, 0);
58  }
59  for(int i = 0; i < edgeSets; i++) {
60  linkId l = linkId(DCAddr(3, i, Im.a), Im);
61  myLinks [l] = linkInfo(l, false, 0);
62  linksKo[l] = linkInfo(l, false, 0);
63  }
64  }
65 
66 
67  set<DCAddr> Spine_Routing::getNotOptimalDst(map<DCAddr, tableNode> * table) {
68  set<DCAddr> ret;
69 
70  for(auto & e : *table) {
71  const DCAddr & dst = e.first;
72  tableNode & tn = e.second;
73  if(dst == Im) { continue; }
74  switch(dst.type) {
75  case 0: {
76  if(tn.d > 2 || (int)tn.L.size() != 1) {
77  ret.insert(dst);
78  } else {
79  const linkId & li = **(tn.L.begin());
80  if(li.src.a != dst.a) {
81  ret.insert(dst);
82  }
83  }
84 
85  }break;
86  case 1: {
87  if(dst.b == Im.a) {
88  if(tn.d > 1 || (int)tn.L.size() != 1) {
89  ret.insert(dst);
90  } else {
91  const linkId & li = **(tn.L.begin());
92  if(li.src != dst) {
93  ret.insert(dst);
94  }
95  }
96  } else {
97  if(tn.d > 3 || (int)tn.L.size() != 1) {
98  ret.insert(dst);
99  } else {
100  const linkId & li = **(tn.L.begin());
101  if(li.src.a != dst.a) {
102  ret.insert(dst);
103  }
104  }
105  }
106  }break;
107  case 2: {
108  if(dst.a == Im.a) {
109  if(tn.d > 2 || (int)tn.L.size() != pods) {
110  ret.insert(dst);
111  }
112  } else {
113  if(tn.d > 4 || (int)tn.L.size() != pods) {
114  ret.insert(dst);
115  }
116  }
117  }break;
118  case 3: {
119  if(dst.b == Im.a) {
120  if(tn.d > 1 || (int)tn.L.size() != 1) {
121  ret.insert(dst);
122  } else {
123  const linkId & li = **(tn.L.begin());
124  if(li.dst != dst) {
125  ret.insert(dst);
126  }
127  }
128  } else {
129  if(tn.d > 5 || (int)tn.L.size() != pods) {
130  ret.insert(dst);
131  }
132  }
133  }break;
134  }
135  }
136 
137  return ret;
138  }
139 
140 
142 
143  }
144 }
Register_Class(SimpleDCGenerator)
map< linkId, linkInfo > linksKo
Definition: IntDCRouting.h:112
set< const linkId * > L
Definition: IntDCRouting.h:73
map< linkId, linkInfo > myLinks
Definition: IntDCRouting.h:112
void insert(set< const linkId * > Ls)
Definition: IntDCRouting.cc:76
void activeNeigh(const DCAddr &dst)
Definition: Spine_Routing.cc:9
set< DCAddr > getNotOptimalDst(map< DCAddr, tableNode > *table)
void inactiveNeigh(const DCAddr &dst)