41 if(
src < o.
src) {
return true; }
42 if(o.
src <
src) {
return false; }
43 if(
dst < o.
dst) {
return true; }
58 link(), status(false), timestamp(-1){}
61 link(_link), status(_status), timestamp(_timestamp){}
77 L.insert(Ls.begin(), Ls.end());
88 }
else if(msg ==
sched) {
90 for(
const auto & linkData :
linksOk) {
91 if(linkData.second.link.src ==
DCAddr()) {
92 cerr <<
"Invalid link in ok list" << endl;
97 for(
const auto & linkData :
linksKo) {
98 if(linkData.second.link.src ==
DCAddr()) {
99 cerr <<
"Invalid link in ko list" << endl;
113 }
else if(msg ==
start) {
115 for(
const auto & linkData :
linksKo) {
116 if(linkData.second.link.src ==
DCAddr()) {
117 cerr <<
"Start - Invalid link in ko list" << endl;
132 cerr <<
"Unknown message" << endl;
139 string myAddr = getModuleByPath(
"^")->par(
"ipcAddress").stringValue();
143 start =
new cMessage(
"Start updates");
146 pods = par(
"pods").longValue();
147 torXpod = par(
"torXpod").longValue();
150 edgeSets = par(
"edgeSets").longValue();
153 double starttime = par(
"starttime").doubleValue();
155 scheduleAt(simTime() + starttime,
start);
163 cerr <<
"Invalid update message received" << endl;
169 bool changes =
false;
172 auto ml =
myLinks.find(l.link);
176 && ml->second.timestamp < (simTime()-
expiration)) {
177 ml->second.timestamp = simTime();
183 if(l.link.src ==
DCAddr(-1,0,0)) {
184 cerr <<
"At " <<
Im <<
", received invalid link info from "<< u->
getSource() << endl;
196 }
else if(l.timestamp > simTime() +
expiration) {
234 Enter_Method_Silent();
240 Enter_Method_Silent();
246 Enter_Method_Silent();
248 sched =
new cMessage(
"Scheduled update");
253 Enter_Method_Silent();
254 if(
clean ==
nullptr) {
255 clean =
new cMessage(
"Scheduled clean");
262 map<DCAddr, tableNode> * table =
new map<DCAddr, tableNode>();
263 map<DCAddr, tableNode> & t = (*table);
264 for(
int p = 0; p <
pods; p++) {
265 for(
int k = 0; k <
torXpod; k++) {
285 if(l.second.status) {
286 if(l.first.dst ==
Im) {
287 t[l.first.src] =
tableNode( &(l.first) );
288 next.push(l.first.src);
290 t[l.first.dst] =
tableNode( &(l.first) );
291 next.push(l.first.dst);
296 while(!next.empty()) {
297 auto n = next.front();
301 vector<DCAddr> neis =
getNeis(n);
302 for(
auto &ni : neis) {
311 }
else if(tni.
d == tD) {
325 ret.push_back(
DCAddr(1, n.
a, f) );
329 for(
int t = 0; t <
torXpod; t++) {
330 ret.push_back(
DCAddr(0, n.
a, t) );
333 ret.push_back(
DCAddr(2, n.
b, s) );
337 for(
int p = 0; p <
pods; p++) {
338 ret.push_back(
DCAddr(1, p, n.
a) );
341 ret.push_back(
DCAddr(3, p, n.
a) );
356 for(
auto it =
cache.begin(); it!=
cache.end();) {
357 const DCAddr & n = it->first;
358 auto noIt = no.find(n);
362 if(noIt == no.end()) {
365 }
else if(it->second != tn.L) {
378 for(
auto & nd : tn.L) {
379 if(nd->src ==
Im) { e.
next.insert(nd->dst); }
380 else { e.
next.insert(nd->src); }
391 for(
auto & nd : tn.L) {
392 if(nd->src ==
Im) { e.
next.insert(nd->dst); }
393 else { e.
next.insert(nd->src); }
411 for(
auto & nd : tn.L) {
412 if(nd->src ==
Im) { e.
next.insert(nd->dst); }
413 else { e.
next.insert(nd->src); }
422 if(par(
"printAtEnd").boolValue()) {
423 cout <<
"-------------" <<endl;
424 cout <<
"routing at "<<
Im <<endl;
425 if(par(
"printMyLinks").boolValue()) {
426 cout <<
"-print links status" <<endl;
428 cout <<
"\t" << e.first.src <<
" -> " << e.first.dst
429 <<
" status : " << (e.second.status?
"OK" :
"KO") << endl;
433 if(par(
"printKoList").boolValue()) {
434 cout <<
"-print Ko List"<<endl;
436 cout <<
"\t" << e.first.src <<
" -> " << e.first.dst <<
" (@ "<<e.second.timestamp<<
")" << endl;
440 if(par(
"printFullTable").boolValue()) {
441 cout <<
"-print Table"<<endl;
444 cout <<
"\t" << e.first;
445 cout <<
"\t\t--distance : " << e.second.d << endl;
446 for(
auto k : e.second.L) {
447 cout <<
"\t\t" << k->src <<
" -> " << k->dst << endl;
450 if(par(
"printNotOptimal").boolValue()) {
451 cout <<
"-print not optimal paths"<<endl;
455 cout <<
"\t"<<n<<endl;
456 cout <<
"\t\t distance "<< tn.d<<endl;
457 for(
auto & nd : tn.L) {
459 cout <<
"\t\t-> "<< nd->dst <<endl;
461 cout <<
"\t\t-> "<< nd->src <<endl;
466 }
else if(par(
"printNotOptimal").boolValue()) {
468 cout <<
"-print not optimal paths"<<endl;
472 cout <<
"\t"<<n<<endl;
473 cout <<
"\t\t distance "<< tn.d<<endl;
474 for(
auto & nd : tn.L) {
476 cout <<
"\t\t-> "<< nd->dst <<endl;
478 cout <<
"\t\t-> "<< nd->src <<endl;
488 cout <<
"-------------" <<endl;
vector< linkInfo > linksStatus
vector< rtEntry > getChanges()
virtual void inactiveNeigh(const DCAddr &dst)=0
void insertNeighbour(const Address &addr, const DCAddr &dst)
bool operator<(const linkId &o) const
void removeNeighbour(const Address &addr, const DCAddr &dst)
LinksUpdate * toDst(Address dst)
map< linkId, linkInfo > linksKo
bool operator==(const linkId &o) const
map< linkId, linkInfo > myLinks
map< DCAddr, tableNode > * computeTable()
void insert(set< const linkId * > Ls)
bool operator!=(const linkId &o) const
virtual set< DCAddr > getNotOptimalDst(map< DCAddr, tableNode > *table)=0
virtual void activeNeigh(const DCAddr &dst)=0
vector< DCAddr > getNeis(DCAddr)
void sendUpdate(IntRoutingUpdate *update)
set< Address > activeNeighbours
map< linkId, linkInfo > linksOk
virtual void startMyLinks()=0
map< DCAddr, set< const linkId * > > cache
Address class holds IPC Process identification.
virtual void handleMessage(cMessage *msg)
vector< rtEntry > getAll()
bool processUpdate(IntRoutingUpdate *update)
virtual void printAtEnd()=0