57 void SimpleLS::insertFlow(
const Address &addr,
const std::string &dst,
const std::string& qos,
const unsigned short &metric){
58 neig[qos][addr] = metric;
59 lastChanges[qos].insert(myAddr);
61 linksU * myEntry = &(netState[qos][myAddr]);
63 myEntry->
links[dst] = metric;
66 void SimpleLS::removeFlow(
const Address &addr,
const std::string &dst,
const std::string& qos){
67 neig[qos].erase(addr);
68 if(neig[qos].size() <= 0){
71 lastChanges[qos].insert(myAddr);
73 linksU * myEntry = &(netState[qos][myAddr]);
75 myEntry->
links.erase(dst);
80 void SimpleLS::scheduleUpdate(){
81 Enter_Method_Silent();
83 scheduledUpdate =
true;
84 scheduleAt(simTime()+1,
new cMessage(
"Time2Update"));
92 for(
linksStColIt qosIt = netState.begin(); qosIt != netState.end(); qosIt++){
93 std::string qos = qosIt->first;
94 TreeNode t = constructTree(qosIt->second);
97 et->
metric = (*it)->metric;
98 et->
nh.insert((*it)->addr);
99 addRecursive(ret, qos, (*it)->addr, *it);
105 for(
entries2NextIt tIt = table.begin(); tIt != table.end(); tIt++){
106 if (ret[tIt->first].metric == tIt->second.metric && ret[tIt->first].nh == tIt->second.nh){
107 ret.erase(tIt->first);
118 for(
linksStColIt qosIt = netState.begin(); qosIt != netState.end(); qosIt++){
119 std::string qos = qosIt->first;
120 TreeNode t = constructTree(qosIt->second);
123 et->
metric = (*it)->metric;
124 et->
nh.insert((*it)->addr);
125 addRecursive(ret, qos, (*it)->addr, *it);
139 aMap * links = &(ls[myAddr].links);
140 for(
linksIt it = links->begin(); it !=links->end(); it++){
141 waiting[it->first] =
psT(&t, it->second);
144 while(!waiting.empty()){
145 unsigned short min = UINT16_MAX;
148 for (
wMapIt it = waiting.begin(); it != waiting.end(); it++){
149 if(it->second.metric < min){
150 min = it->second.metric;
153 if(it->second.metric == min){
154 mins.push_back(it->first);
158 while(!mins.empty()){
159 string addr = mins.back();
162 psT ps = waiting[addr];
178 links = &(ls[addr].links);
180 for(
linksIt it = links->begin(); it !=links->end(); it++){
181 string daddr = it->first;
182 if(added.find(daddr) == added.end()){
183 wMapIt eI = waiting.find(daddr);
184 if(eI == waiting.end()){
185 waiting[daddr] =
psT(nt, ps.
metric + it->second);
186 }
else if(eI->second.metric >= ps.
metric + it->second){
187 eI->second.addParent(nt, ps.
metric + it->second);
199 et->
metric = (*it)->metric;
201 addRecursive(ret, qos, next, *it);
209 std::string qos = up->
getQoS();
210 linksSt * st = &(netState[qos]);
213 string node = it->first;
214 if((*st)[node].sId < it->second.sId){
215 (*st)[node] = it->second;
216 lastChanges[qos].insert(node);
219 if(!lastChanges.empty()){
227 void SimpleLS::onPolicyInit(){
228 myAddr = par(
"myAddr").stdstringValue();
230 myAddr = myAddress.getIpcAddress().getName();
233 infMetric = par(
"infMetric").longValue();
238 void SimpleLS::handleMessage(cMessage *msg){
239 if(msg->isSelfMessage()){
243 linksSt _entries = getChangedEntries (it->first);
246 for(
neighMetricIt it2 = it->second.begin(); it2 != it->second.end(); it2++){
259 scheduledUpdate =
false;
264 linksSt SimpleLS::getChangedEntries (
const std::string& qos){
266 addrSet * set = &lastChanges[qos];
267 for(
addrSetIt it = set->begin(); it != set->end(); it++){
274 void SimpleLS::finish(){
277 if(par(
"printAtEnd").boolValue() ){
278 EV <<
"I'm "<< myAddr<<endl;
280 for(
linksStColIt qosIt = netState.begin(); qosIt != netState.end(); qosIt++){
281 EV <<
" QoS " << qosIt->first<<endl;
282 TreeNode t = constructTree(qosIt->second);
285 printTreeNode(*it, (*it)->addr);
292 void SimpleLS::printTreeNode(
TreeNode *t,
const std::string &next){
293 for(
int i = 0; i < t->
metric; i++) { EV <<
" ";}
294 EV<<
" " << t->
addr <<
" -> "<<next <<
" ("<<t->
metric<<
") " <<
" childs: "<< t->
chl.size() << endl;
296 printTreeNode(*it, next);
std::map< std::string, linksU > linksSt
void addEntry(const std::string &, linksU)
std::set< std::string > nh
neighMetric::iterator neighMetricIt
std::map< std::string, unsigned short > aMap
addrSet::iterator addrSetIt
std::set< std::string > addrSet
std::map< std::string, psT > wMap
std::map< qosPaddr, std::string > entries2Next
std::map< std::string, unsigned short > links
std::set< TreeNode * >::iterator TreeNodeIt
std::vector< std::string > addrList
std::map< std::string, unsigned short >::iterator linksIt
entries2Next::iterator entries2NextIt
std::pair< std::string, linksU > linksStEntry
std::pair< std::string, std::string > qosPaddr
std::set< TreeNode * > chldel
qosNeighMetric::iterator qosNeighMetricIt
linksStCol::iterator linksStColIt
RoutingUpdate(const Address &_addr, const std::string &_qos)
std::set< TreeNode * > chl
Address class holds IPC Process identification.
linksSt::iterator linksStIt