#include <landmark.h>
Collaboration diagram for ParentChildrenList:

|
||||||||||||
|
Definition at line 1815 of file landmark.cc. References a_, adverts_type_, FLOOD, level_, LMPeriodicAdvtHandler, mylmaddrs_, num_tags_, periodic_handler_, periodic_update_event_, and tag_list_.
01815 : parent_(NULL), num_heard_(0), num_children_(0), num_potl_children_(0), num_pparent_(0), pchildren_(NULL), pparent_(NULL) , seqnum_(0) ,last_update_sent_(-(a->update_period_)), update_period_(a->update_period_), update_timeout_(a->update_timeout_), next_(NULL) 01816 { 01817 level_ = level; 01818 periodic_update_event_ = new Event; 01819 periodic_handler_ = new LMPeriodicAdvtHandler(this); 01820 a_ = a; 01821 tag_list_ = NULL; 01822 num_tags_ = 0; 01823 adverts_type_ = FLOOD; // default is to flood adverts 01824 mylmaddrs_ = new LMAddrs; 01825 } |
|
|
Definition at line 293 of file landmark.h. References Scheduler::cancel(), Scheduler::instance(), mylmaddrs_, LMNode::next_, pchildren_, periodic_update_event_, pparent_, and Event::uid_.
00293 {
00294 LMNode *node1, *node2;
00295
00296 node1 = pchildren_;
00297 while(node1) {
00298 node2 = node1;
00299 node1 = node1->next_;
00300 delete node2;
00301 }
00302
00303 node1 = pparent_;
00304 while(node1) {
00305 node2 = node1;
00306 node1 = node1->next_;
00307 delete node2;
00308 }
00309
00310 // Event id > 0 for valid event
00311 if(periodic_update_event_->uid_) {
00312 Scheduler &s = Scheduler::instance();
00313 s.cancel(periodic_update_event_);
00314 }
00315 delete mylmaddrs_;
00316 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 279 of file landmark.cc. References LMNode::id_, LMNode::lmaddr_, LMNode::next_, and pchildren_. Referenced by LandmarkAgent::assign_lmaddress().
00280 {
00281 LMNode *potl_ch = NULL;
00282
00283 potl_ch = pchildren_;
00284 while(potl_ch) {
00285 if(potl_ch->id_ == id)
00286 break;
00287 potl_ch = potl_ch->next_;
00288 }
00289
00290 assert(potl_ch);
00291 (potl_ch->lmaddr_)->delete_lm_addrs();
00292 for(int i = 0; i < num_lm_addrs; ++i)
00293 (potl_ch->lmaddr_)->add_lm_addr(lm_addrs[i]);
00294 }
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Definition at line 410 of file landmark.cc. References a_, LMNode::child_flag_, Scheduler::clock(), LandmarkAgent::compare_tag_lists(), LMNode::copy_tag_list(), ENTRY_NOT_FOUND, Scheduler::instance(), IS_CHILD, LMNode::last_upd_seqnum_, LMNode, NEW_CHILD, NEW_ENTRY, LMNode::next_, LMNode::next_hop_, NOT_CHILD, NOT_POTL_CHILD, num_children_, num_heard_, num_potl_children_, OLD_CHILD_TAGS_CHANGED, OLD_ENTRY, OLD_MESSAGE, and pchildren_. Referenced by PromotionTimer::expire(), LandmarkAgent::periodic_callback(), and LandmarkAgent::SendChangedTagListUpdate().
00411 {
00412 LMNode *potl_child, *list_ptr;
00413 double now = Scheduler::instance().clock();
00414 int new_child = 0;
00415 int tags_changed = 0;
00416 int seqnum = origin_time & 0xFFFF;
00417 origin_time = origin_time >> 16;
00418
00419 // if(a_->debug_) printf("Node %d: Number of potl children %d",a_->myaddr_,num_potl_children_);
00420
00421 // cannot delete from an empty list!
00422 if(delete_flag && !pchildren_) {
00423 return(ENTRY_NOT_FOUND);
00424 }
00425
00426 assert(num_potl_children_ >= 0);
00427 assert(num_children_ >= 0);
00428
00429 if(pchildren_ == NULL) {
00430 pchildren_ = new LMNode(id, next_hop, num_hops, level, num_children, energy, origin_time, now);
00431 pchildren_->child_flag_ = child_flag;
00432 pchildren_->last_upd_seqnum_ = seqnum;
00433 if(child_flag == IS_CHILD) ++(num_children_);
00434 if(child_flag != NOT_POTL_CHILD) ++(num_potl_children_);
00435 ++(num_heard_);
00436 pchildren_->copy_tag_list(taglist);
00437 if(child_flag == IS_CHILD)
00438 return(NEW_CHILD);
00439 else
00440 return(NEW_ENTRY);
00441 }
00442
00443 list_ptr = pchildren_;
00444 potl_child = list_ptr;
00445 while(list_ptr != NULL) {
00446 if(list_ptr->id_ == id) {
00447 // Check if this is a old message floating around in the network
00448 if(list_ptr->last_upd_origin_time_ > origin_time || (list_ptr->last_upd_origin_time_ == origin_time && list_ptr->last_upd_seqnum_ >= seqnum)) {
00449
00450 // Check if we got this update on a shorter path; If the update rcvd
00451 // on a shorter path, we need to forward this message to ensure that
00452 // this message reaches all nodes in the advertising node's vicinity
00453 if(list_ptr->num_hops_ > num_hops) {
00454 list_ptr->next_hop_ = next_hop;
00455 list_ptr->num_hops_ = num_hops;
00456 return(OLD_ENTRY);
00457 }
00458
00459 return(OLD_MESSAGE);
00460 }
00461 if(!delete_flag) {
00462
00463 // Old entry but the status has changed to child or vice-versa
00464 if((list_ptr->child_flag_ == NOT_CHILD || list_ptr->child_flag_ == NOT_POTL_CHILD) && (child_flag == IS_CHILD)) {
00465 list_ptr->child_flag_ = child_flag;
00466 ++(num_children_);
00467 new_child = 1;
00468 }
00469 else if((list_ptr->child_flag_ == IS_CHILD) && (child_flag == NOT_CHILD || child_flag == NOT_POTL_CHILD)) {
00470 list_ptr->child_flag_ = child_flag;
00471 --(num_children_);
00472 }
00473 list_ptr->next_hop_ = next_hop;
00474 list_ptr->num_hops_ = num_hops;
00475 list_ptr->level_ = level;
00476 list_ptr->num_children_ = num_children;
00477 list_ptr->energy_ = energy;
00478 list_ptr->last_upd_origin_time_ = origin_time;
00479 list_ptr->last_upd_seqnum_ = seqnum;
00480 list_ptr->last_update_rcvd_ = Scheduler::instance().clock();
00481 if(!a_->compare_tag_lists(list_ptr->tag_list_,-1,taglist,-1)) {
00482 tags_changed = 1;
00483 // Delete the old tag list and copy the specified taglist
00484 list_ptr->copy_tag_list(taglist);
00485 }
00486 }
00487 else {
00488 if(pchildren_ == list_ptr)
00489 pchildren_ = list_ptr->next_;
00490 else
00491 potl_child->next_ = list_ptr->next_;
00492
00493 if(list_ptr->child_flag_ == IS_CHILD) --num_children_;
00494 if(list_ptr->child_flag_ != NOT_POTL_CHILD) --num_potl_children_;
00495 --num_heard_;
00496 delete list_ptr;
00497 }
00498 if(new_child)
00499 return(NEW_CHILD);
00500 else if(tags_changed && child_flag == IS_CHILD)
00501 return(OLD_CHILD_TAGS_CHANGED);
00502 else
00503 return(OLD_ENTRY);
00504 }
00505 potl_child = list_ptr;
00506 list_ptr = list_ptr->next_;
00507 }
00508
00509 // delete flag must be FALSE if we are here
00510 // assert(!delete_flag);
00511 if(delete_flag) {
00512 return(ENTRY_NOT_FOUND);
00513 }
00514
00515 potl_child->next_ = new LMNode(id, next_hop, num_hops, level, num_children, energy, origin_time, now);
00516 (potl_child->next_)->copy_tag_list(taglist);
00517 (potl_child->next_)->child_flag_ = child_flag;
00518 (potl_child->next_)->last_upd_seqnum_ = seqnum;
00519 if(child_flag == IS_CHILD) ++(num_children_);
00520 if(child_flag != NOT_POTL_CHILD) ++(num_potl_children_);
00521 ++(num_heard_);
00522 if(child_flag == IS_CHILD)
00523 return(NEW_CHILD);
00524 else
00525 return(NEW_ENTRY);
00526 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||||||||||
|
Definition at line 300 of file landmark.cc. References Scheduler::clock(), ENTRY_NOT_FOUND, LMNode::id_, Scheduler::instance(), LMNode::last_upd_seqnum_, LMNode, NEW_ENTRY, LMNode::next_, LMNode::next_hop_, LMNode::num_hops_, num_pparent_, OLD_ENTRY, OLD_MESSAGE, parent_, and pparent_. Referenced by PromotionTimer::expire(), and LandmarkAgent::periodic_callback().
00301 {
00302 LMNode *potl_parent, *list_ptr;
00303 double now = Scheduler::instance().clock();
00304 // Extract seqnum and origin time
00305 int seqnum = origin_time & 0xFFFF;
00306 origin_time = origin_time >> 16;
00307
00308 assert(num_pparent_ >= 0);
00309
00310 // cannot delete from an empty list!
00311 if(delete_flag && !pparent_)
00312 return(ENTRY_NOT_FOUND);
00313
00314 // if((a_->debug_) && (a_->myaddr_ == 24)) {
00315 // a_->trace("Node %d: Updating Potl Parent level %d, id %d, delete_flag %d, time %f",a_->myaddr_,level_,id,delete_flag,now);
00316 // }
00317
00318 if(pparent_ == NULL) {
00319 pparent_ = new LMNode(id, next_hop, num_hops, level, num_children, energy, origin_time, now);
00320 pparent_->last_upd_seqnum_ = seqnum;
00321 parent_ = pparent_;
00322 ++num_pparent_;
00323 return(NEW_ENTRY);
00324 }
00325
00326 list_ptr = pparent_;
00327 potl_parent = list_ptr;
00328 while(list_ptr != NULL) {
00329 if(list_ptr->id_ == id) {
00330 // Check if this is a old message floating around in the network
00331 if(list_ptr->last_upd_origin_time_ > origin_time || (list_ptr->last_upd_origin_time_ == origin_time && list_ptr->last_upd_seqnum_ >= seqnum)) {
00332 // Check if we got the old update on a shorter path
00333 if(list_ptr->num_hops_ > num_hops) {
00334 list_ptr->next_hop_ = next_hop;
00335 list_ptr->num_hops_ = num_hops;
00336 return(OLD_ENTRY);
00337 }
00338 return(OLD_MESSAGE);
00339 }
00340 if(!delete_flag) {
00341 // Make this node as parent if it's closer than current parent
00342 if(parent_->num_hops_ > num_hops + 10 || num_hops == 0) {
00343 parent_ = list_ptr;
00344 }
00345 list_ptr->next_hop_ = next_hop;
00346 list_ptr->num_hops_ = num_hops;
00347 list_ptr->level_ = level;
00348 list_ptr->num_children_ = num_children;
00349 list_ptr->energy_ = energy;
00350 list_ptr->last_upd_origin_time_ = origin_time;
00351 list_ptr->last_upd_seqnum_ = seqnum;
00352 list_ptr->last_update_rcvd_ = Scheduler::instance().clock();
00353 }
00354 else { // delete the entry
00355 if(num_pparent_)
00356 --(num_pparent_);
00357
00358 if(pparent_ == list_ptr)
00359 pparent_ = list_ptr->next_;
00360 else
00361 potl_parent->next_ = list_ptr->next_;
00362
00363 if(parent_->id_ == list_ptr->id_)
00364 assert(parent_ == list_ptr);
00365
00366 // No parent if potl parent list is empty
00367 if(pparent_ == NULL) {
00368 parent_ = NULL;
00369 }
00370 else if(parent_ == list_ptr) {
00371 // Select new parent if current parent is deleted and
00372 // potl parent is not empty; closest potl parent is new parent
00373 LMNode *tmp = pparent_;
00374 int best_num_hops = pparent_->num_hops_;
00375 LMNode *best_parent = pparent_;
00376 while(tmp != NULL) {
00377 if(tmp->num_hops_ < best_num_hops) {
00378 best_num_hops = tmp->num_hops_;
00379 best_parent = tmp;
00380 }
00381 tmp = tmp->next_;
00382 }
00383 parent_ = best_parent;
00384 }
00385 delete list_ptr;
00386 }
00387 return(OLD_ENTRY);
00388 }
00389 potl_parent = list_ptr;
00390 list_ptr = list_ptr->next_;
00391 }
00392
00393 if(delete_flag)
00394 return(ENTRY_NOT_FOUND);
00395
00396 potl_parent->next_ = new LMNode(id, next_hop, num_hops, level, num_children, energy, origin_time, now);
00397 (potl_parent->next_)->last_upd_seqnum_ = seqnum;
00398 ++num_pparent_;
00399 // Make this node as parent if it's closer than current parent
00400 if(parent_->num_hops_ > num_hops) {
00401 parent_ = potl_parent->next_;
00402 }
00403 return(NEW_ENTRY);
00404 }
|
Here is the call graph for this function:

|
|
Definition at line 287 of file landmark.h. |
|
|
Definition at line 288 of file landmark.h. Referenced by UpdatePotlChild(), and UpdatePotlParent(). |
|
|
Definition at line 290 of file landmark.h. Referenced by ParentChildrenList(). |
|
|
Definition at line 289 of file landmark.h. |
|
|
Definition at line 359 of file landmark.h. Referenced by LMPeriodicAdvtHandler::handle(), ParentChildrenList(), and UpdatePotlChild(). |
|
|
Definition at line 363 of file landmark.h. Referenced by ParentChildrenList(). |
|
|
Definition at line 338 of file landmark.h. Referenced by PromotionTimer::expire(), LandmarkAgent::periodic_callback(), LandmarkAgent::ProcessHierUpdate(), and LandmarkAgent::SendChangedTagListUpdate(). |
|
|
|
Definition at line 365 of file landmark.h. Referenced by LandmarkAgent::assign_lmaddress(), LandmarkAgent::command(), PromotionTimer::expire(), LandmarkAgent::makeUpdate(), ParentChildrenList(), and ~ParentChildrenList(). |
|
|
|
Definition at line 330 of file landmark.h. Referenced by LandmarkAgent::assign_lmaddress(), LandmarkAgent::command(), PromotionTimer::expire(), LandmarkAgent::makeUpdate(), LandmarkAgent::periodic_callback(), and UpdatePotlChild(). |
|
|
Definition at line 327 of file landmark.h. Referenced by LandmarkAgent::command(), PromotionTimer::expire(), LandmarkAgent::periodic_callback(), LandmarkAgent::ProcessHierUpdate(), and UpdatePotlChild(). |
|
|
Definition at line 331 of file landmark.h. Referenced by LandmarkAgent::command(), LandmarkAgent::makeUpdate(), LandmarkAgent::periodic_callback(), and UpdatePotlChild(). |
|
|
Definition at line 332 of file landmark.h. Referenced by LandmarkAgent::command(), PromotionTimer::expire(), and UpdatePotlParent(). |
|
|
Definition at line 361 of file landmark.h. Referenced by LandmarkAgent::AddMobileTag(), LandmarkAgent::makeUpdate(), LandmarkAgent::MoveTags(), ParentChildrenList(), and LandmarkAgent::SendChangedTagListUpdate(). |
|
|
Definition at line 326 of file landmark.h. Referenced by LandmarkAgent::command(), PromotionTimer::expire(), LandmarkAgent::makeUpdate(), LandmarkAgent::periodic_callback(), LandmarkAgent::search_tag(), and UpdatePotlParent(). |
|
|
|
Definition at line 343 of file landmark.h. Referenced by PromotionTimer::expire(), ParentChildrenList(), and LandmarkAgent::periodic_callback(). |
|
|
Definition at line 341 of file landmark.h. Referenced by PromotionTimer::expire(), LandmarkAgent::makeUpdate(), ParentChildrenList(), LandmarkAgent::periodic_callback(), and ~ParentChildrenList(). |
|
|
Definition at line 334 of file landmark.h. Referenced by LandmarkAgent::command(), LandmarkAgent::periodic_callback(), UpdatePotlParent(), and ~ParentChildrenList(). |
|
|
Definition at line 337 of file landmark.h. Referenced by PromotionTimer::expire(), LandmarkAgent::makeUpdate(), LandmarkAgent::periodic_callback(), and LandmarkAgent::SendChangedTagListUpdate(). |
|
|
Definition at line 360 of file landmark.h. Referenced by LandmarkAgent::AddMobileTag(), PromotionTimer::expire(), LandmarkAgent::makeUpdate(), LandmarkAgent::MoveTags(), ParentChildrenList(), LandmarkAgent::periodic_callback(), LandmarkAgent::search_tag(), and LandmarkAgent::SendChangedTagListUpdate(). |
|
|
Definition at line 339 of file landmark.h. Referenced by LandmarkAgent::periodic_callback(). |
|
|
Definition at line 346 of file landmark.h. |
|
|
Definition at line 340 of file landmark.h. Referenced by LandmarkAgent::periodic_callback(). |
1.3.3