56 void SimpleDV::scheduleUpdate(){
57 Enter_Method_Silent();
59 scheduledUpdate =
true;
60 scheduleAt(simTime()+1,
new cMessage(
"Time2Update"));
65 void SimpleDV::insertFlow(
const Address &addr,
const std::string &dst,
const std::string& qos,
const unsigned short &metric){
66 EV <<
"Insert Flow info" << endl;
67 neig[qos][addr] = metric;
69 rtEntry * oldEntry = &table[qos][dst];
71 bool entryChangedDst =
false;
73 if(oldEntry->
addr == dst){
74 if(oldEntry->
metric != metric){
77 }
else if(oldEntry->
metric >= metric){
80 entryChangedDst =
true;
84 if(oldEntry->
metric >= infMetric){
86 table[qos].erase(dst);
87 }
else if(entryChangedDst){
94 void SimpleDV::removeFlow(
const Address &addr,
const std::string &dst,
const std::string& qos){
95 neig[qos].erase(addr);
96 if(neig[qos].size() <= 0){
100 tTable * qosTable = &table[qos];
103 for(
tTableIt it = qosTable->begin(); it != qosTable->end();){
104 rtEntry * oldEntry = &it->second;
108 if(oldEntry->
addr == dst){
112 qosTable->erase(actIt);
129 for(
rtTableIt it = table.begin(); it != table.end(); it++){
130 for(
tTableIt it2 = it->second.begin(); it2 != it->second.end(); it2++){
132 if(it2->second.metric < infMetric) {
133 et.
metric = it2->second.metric;
134 et.
nh.insert(it2->second.addr);
138 ret[
qosPaddr(it->first, it2->first)] = et;
141 map<unsigned short, map<string, rtEntry> > table;
150 std::string src = up->
getSrc();
157 std::string qos = up->
getQoS();
160 if(it->addr == myAddr) {
continue; }
165 bool entryChangedDst =
false;
167 if(oldEntry->
addr == src){
173 oldEntry->
addr = src;
175 entryChangedDst =
true;
181 if(oldEntry->
metric >= infMetric){
184 table[qos].erase(newEntry->
addr);
186 }
else if(entryChangedDst){
198 return ! changes.empty();
202 void SimpleDV::onPolicyInit(){
203 myAddr = par(
"myAddr").stdstringValue();
205 myAddr = myAddress.getIpcAddress().getName();
208 infMetric = par(
"infMetric").longValue();
210 scheduledUpdate =
false;
215 void SimpleDV::handleMessage(cMessage *msg){
216 if(msg->isSelfMessage()){
220 tTable * qosTable = &table[it->first];
223 for(
neighMetricIt it2 = it->second.begin(); it2 != it->second.end(); it2++){
228 for(
tTableIt it3 = qosTable->begin(); it3 != qosTable->end();it3++){
229 update->
addEntry(
rtEntry(it3->first, it3->second.metric+ it2->second));
240 scheduledUpdate =
false;
246 void SimpleDV::finish(){
249 if(par(
"printAtEnd").boolValue() ){
250 EV <<
"I'm " << myAddr<<endl;
252 for (
rtTableIt it = table.begin(); it != table.end(); it++)
254 EV <<
" QoS " << it->first << endl;
255 for (
tTableIt it2 = it->second.begin(); it2 != it->second.end(); it2++)
257 EV <<
" " << it2->first <<
" via " << it2->second.addr <<
" ("
258 << it2->second.metric <<
")" << endl;
std::vector< rtEntry >::iterator entriesIt
qosNeighMetric::iterator qosNeighMetricIt
std::set< std::string > nh
std::map< std::string, rtEntry > tTable
rtTable::iterator rtTableIt
std::map< qosPaddr, std::string > entries2Next
RoutingUpdate(const Address &_addr, const std::string &_src, const std::string &_qos)
tTable::iterator tTableIt
neighMetric::iterator neighMetricIt
std::pair< std::string, std::string > qosPaddr
Address class holds IPC Process identification.