Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

TORADest Class Reference

#include <tora_dest.h>

Collaboration diagram for TORADest:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TORADest (nsaddr_t id, Agent *a)
TORANeighbornb_add (nsaddr_t id)
int nb_del (nsaddr_t id)
TORANeighbornb_find (nsaddr_t id)
void update_height_nb (TORANeighbor *tn, struct hdr_tora_upd *uh)
void update_height (double TAU, nsaddr_t OID, int R, int DELTA, nsaddr_t ID)
int nb_check_same_ref (void)
TORANeighbornb_find_next_hop ()
TORANeighbornb_find_height (int R)
TORANeighbornb_find_max_height (void)
TORANeighbornb_find_min_height (int R)
TORANeighbornb_find_min_nonnull_height (Height *h)
void dump (void)

Private Member Functions

 LIST_ENTRY (TORADest) link

Private Attributes

nsaddr_t index
Height height
int rt_req
double time_upd
double time_tx_qry
double time_rt_req
tn_head nblist
int num_active
int num_down
int num_up
toraAgentagent

Friends

class toraAgent

Constructor & Destructor Documentation

TORADest::TORADest nsaddr_t  id,
Agent a
 

Definition at line 53 of file tora_dest.cc.

References agent, index, LIST_INIT, nblist, num_active, num_down, num_up, rt_req, time_rt_req, time_tx_qry, and time_upd.

00053                                         :  height(id)
00054 {
00055         index = id;
00056 
00057         rt_req = 0;
00058         time_upd = 0.0;
00059 
00060         time_rt_req = 0.0;
00061         time_tx_qry = 0.0;
00062 
00063         LIST_INIT(&nblist);
00064         num_active = num_down = num_up = 0;
00065 
00066         agent = (toraAgent*) a;
00067 }


Member Function Documentation

void TORADest::dump void   ) 
 

Definition at line 71 of file tora_dest.cc.

References Height::delta, TORANeighbor::dump(), height, Height::id, TORANeighbor::index, index, nb_find_next_hop(), nblist, num_active, num_down, num_up, Height::oid, Height::r, rt_req, Height::tau, and time_upd.

00072 {
00073         TORANeighbor *tn = nb_find_next_hop();
00074 
00075         fprintf(stdout, "\tDEST: %d, RT Req: %x, Time UPD: %f\n",
00076                 index, rt_req, time_upd);
00077         fprintf(stdout, "\t\ttau: %f, oid: %d, r: %d, delta: %d, id: %d\n",
00078                 height.tau, height.oid, height.r, height.delta, height.id);
00079         fprintf(stdout, "\t\tActive: %d, Down: %d, Up: %d, Next Hop: %d\n\n",
00080                 num_active, num_down, num_up, tn ? tn->index : -1);
00081 
00082         for(tn = nblist.lh_first; tn; tn = tn->link.le_next)
00083                 tn->dump();
00084 }

Here is the call graph for this function:

TORADest::LIST_ENTRY TORADest   )  [private]
 

TORANeighbor * TORADest::nb_add nsaddr_t  id  ) 
 

Definition at line 90 of file tora_dest.cc.

References agent, TORANeighbor::height, index, TORANeighbor::index, LINK_DN, LIST_INSERT_HEAD, TORANeighbor::lnk_stat, nblist, num_active, num_down, and Height::Zero().

Referenced by toraAgent::dst_add(), and toraAgent::rtNotifyLinkUP().

00091 {
00092         TORANeighbor *tn = new TORANeighbor(id, agent);
00093         assert(tn);
00094 
00095         LIST_INSERT_HEAD(&nblist, tn, link);
00096 
00097         num_active += 1;
00098         if(tn->index == index) {
00099                 tn->height.Zero();
00100                 tn->lnk_stat = LINK_DN;
00101                 num_down += 1;
00102         }
00103 
00104         return tn;
00105 }

Here is the call graph for this function:

int TORADest::nb_check_same_ref void   ) 
 

Definition at line 264 of file tora_dest.cc.

References TORANeighbor::height, Height::isNull(), nblist, Height::oid, Height::r, and Height::tau.

Referenced by toraAgent::recvUPD().

00265 {
00266         TORANeighbor *tn = nblist.lh_first;
00267         TORANeighbor *tref = 0;
00268 
00269         for( ; tn; tn = tn->link.le_next) {
00270                 if(tn->height.isNull() == 0) {
00271                         if(tref == 0)
00272                                 tref = tn;
00273                         else if(tref->height.tau != tn->height.tau ||
00274                                 tref->height.oid != tn->height.oid ||
00275                                 tref->height.r != tn->height.r)
00276                                 return 0;
00277                 }
00278         }
00279         return 1;
00280 }

Here is the call graph for this function:

int TORADest::nb_del nsaddr_t  id  ) 
 

Definition at line 109 of file tora_dest.cc.

References agent, CURRENT_TIME, index, TORANeighbor::index, LINK_DN, LINK_UP, LIST_REMOVE, TORANeighbor::lnk_stat, toraAgent::logNbDeletedLastDN(), nblist, num_active, num_down, num_up, and update_height().

Referenced by toraAgent::rtNotifyLinkDN().

00110 {
00111         TORANeighbor *tn = nblist.lh_first;
00112 
00113         for( ; tn; tn = tn->link.le_next) {
00114                 if(tn->index == id) {
00115 
00116                         num_active -= 1;
00117 
00118                         if(tn->lnk_stat == LINK_DN)
00119                                 num_down -=1;
00120                         if(tn->lnk_stat == LINK_UP)
00121                                 num_up -= 1;
00122 
00123 
00124                         LIST_REMOVE(tn, link);
00125                         delete tn;
00126 
00127                         /*
00128                          *  Here's were we decide whether or not to
00129                          *  do route maintenance.
00130                          */
00131                         if(num_down == 0) {
00132                                 if(num_up > 0) {
00133                                         update_height(CURRENT_TIME,
00134                                                       index,
00135                                                       0,
00136                                                       0,
00137                                                       index);
00138                                 } else {
00139                                         update_height(-1,
00140                                                       -1,
00141                                                       -1,
00142                                                       -1,
00143                                                       index);
00144                                         // set height to NULL
00145                                 }
00146 
00147                                 agent->logNbDeletedLastDN(this);
00148 
00149                                 return 1;
00150                                 // send an UPDATE packet
00151                         }
00152                         return 0;
00153                 }
00154         }
00155         return 0;
00156 }

Here is the call graph for this function:

TORANeighbor * TORADest::nb_find nsaddr_t  id  ) 
 

Definition at line 160 of file tora_dest.cc.

References TORANeighbor::index, and nblist.

Referenced by toraAgent::recvCLR(), toraAgent::recvQRY(), toraAgent::recvUPD(), and toraAgent::rtNotifyLinkUP().

00161 {
00162         TORANeighbor *tn = nblist.lh_first;
00163         for( ; tn; tn = tn->link.le_next) {
00164                 if(tn->index == id)
00165                         return tn;
00166         }
00167         return 0;
00168 }

TORANeighbor* TORADest::nb_find_height int  R  ) 
 

TORANeighbor * TORADest::nb_find_max_height void   ) 
 

Definition at line 245 of file tora_dest.cc.

References Height::compare(), TORANeighbor::height, Height::isNull(), and nblist.

Referenced by toraAgent::recvUPD().

00246 {
00247         TORANeighbor *tn = nblist.lh_first;
00248         TORANeighbor *tn_max = 0;
00249 
00250         for( ; tn; tn = tn->link.le_next) {
00251                 if(tn->height.isNull() == 0) {
00252                         if(tn_max == 0 ||
00253                            tn_max->height.compare(&tn->height) > 0)
00254                                 tn_max = tn;
00255                 }
00256         }
00257         return tn_max;
00258 }

Here is the call graph for this function:

TORANeighbor * TORADest::nb_find_min_height int  R  ) 
 

Definition at line 198 of file tora_dest.cc.

References Height::compare(), TORANeighbor::height, nblist, and Height::r.

Referenced by toraAgent::recvQRY(), and toraAgent::recvUPD().

00199 {
00200         TORANeighbor *tn = nblist.lh_first;
00201         TORANeighbor *tn_min = 0;
00202 
00203         for( ; tn; tn = tn->link.le_next) {
00204                 if(tn->height.r == R) {
00205                         if(tn_min == 0 ||
00206                            tn_min->height.compare(&tn->height) < 0)
00207                                 tn_min = tn;
00208                 }
00209         }
00210         return tn_min;
00211 }

Here is the call graph for this function:

TORANeighbor * TORADest::nb_find_min_nonnull_height Height h  ) 
 

Definition at line 219 of file tora_dest.cc.

References Height::compare(), TORANeighbor::height, Height::isNull(), nblist, Height::oid, Height::r, and Height::tau.

Referenced by toraAgent::recvUPD().

00220 {
00221         TORANeighbor *tn = nblist.lh_first;
00222         TORANeighbor *tn_min = 0;
00223 
00224         assert(h);
00225 
00226         for( ; tn; tn = tn->link.le_next) {
00227                 if(tn->height.isNull() == 0 &&
00228                    tn->height.tau == h->tau &&
00229                    tn->height.oid == h->oid &&
00230                    tn->height.r == h->r) {
00231                         if(tn_min == 0 ||
00232                            tn_min->height.compare(&tn->height) < 0)
00233                         tn_min = tn;
00234                 }
00235         }
00236         return tn_min;
00237 }

Here is the call graph for this function:

TORANeighbor * TORADest::nb_find_next_hop  ) 
 

Definition at line 172 of file tora_dest.cc.

References Height::compare(), TORANeighbor::height, Height::isNull(), LINK_DN, TORANeighbor::lnk_stat, and nblist.

Referenced by dump(), toraAgent::log_route_table(), toraAgent::logNextHopChange(), toraAgent::recvTORA(), and toraAgent::rt_resolve().

00173 {
00174         TORANeighbor *tn = nblist.lh_first;
00175         TORANeighbor *tn_min = 0;
00176 
00177         for( ; tn; tn = tn->link.le_next) {
00178                 if(tn->height.isNull())
00179                         continue;
00180 
00181                 if(tn->lnk_stat != LINK_DN)
00182                         continue;
00183 
00184                 if(tn_min == 0 || tn_min->height.compare(&tn->height) < 0) {
00185                         tn_min = tn;
00186                 }
00187         }
00188         assert(tn_min == 0 || tn_min->lnk_stat == LINK_DN);
00189         return tn_min;
00190 }

Here is the call graph for this function:

void TORADest::update_height double  TAU,
nsaddr_t  OID,
int  R,
int  DELTA,
nsaddr_t  ID
 

Definition at line 320 of file tora_dest.cc.

References agent, Height::delta, height, Height::id, LINK_DN, LINK_UP, TORANeighbor::lnk_stat, toraAgent::log_dst_state_change(), nblist, num_active, num_down, num_up, Height::oid, Height::r, Height::tau, and TORANeighbor::update_link_status().

Referenced by nb_del(), toraAgent::recvCLR(), toraAgent::recvQRY(), and toraAgent::recvUPD().

00321 {
00322         TORANeighbor *tn = nblist.lh_first;
00323 
00324         height.tau = TAU;
00325         height.oid = OID;
00326         height.r = R;
00327         height.delta = DELTA;
00328         height.id = ID;
00329 
00330 #ifdef LOGGING
00331         agent->log_dst_state_change(this);
00332 #endif
00333         num_active = num_down = num_up = 0;
00334 
00335         for( ; tn; tn = tn->link.le_next) {
00336 
00337                 tn->update_link_status(&height);
00338 
00339                 num_active += 1;
00340 
00341                 if(tn->lnk_stat == LINK_DN)
00342                         num_down += 1;
00343                 if(tn->lnk_stat == LINK_UP)
00344                         num_up += 1;
00345         }
00346 }

Here is the call graph for this function:

void TORADest::update_height_nb TORANeighbor tn,
struct hdr_tora_upd uh
 

Definition at line 284 of file tora_dest.cc.

References Height::delta, height, TORANeighbor::height, LINK_DN, LINK_UP, TORANeighbor::lnk_stat, num_down, num_up, Height::oid, Height::r, Height::tau, hdr_tora_upd::tu_delta, hdr_tora_upd::tu_id, hdr_tora_upd::tu_oid, hdr_tora_upd::tu_r, hdr_tora_upd::tu_tau, Height::update(), and TORANeighbor::update_link_status().

Referenced by toraAgent::recvUPD().

00285 {
00286         Height h(uh->tu_id);
00287 
00288         h.tau = uh->tu_tau;
00289         h.oid = uh->tu_oid;
00290         h.r = uh->tu_r;
00291         h.delta = uh->tu_delta;
00292 
00293         tn->height.update(&h);
00294 
00295         /*
00296          *  Update num_down/num_up
00297          */
00298         if(tn->lnk_stat == LINK_DN)
00299                 num_down -= 1;
00300         if(tn->lnk_stat == LINK_UP)
00301                 num_up -= 1;
00302 
00303         tn->update_link_status(&height);
00304 
00305         /*
00306          *  Update num_down/num_up
00307          */
00308         if(tn->lnk_stat == LINK_DN)
00309                 num_down += 1;
00310         if(tn->lnk_stat == LINK_UP)
00311                 num_up += 1;
00312 }

Here is the call graph for this function:


Friends And Related Function Documentation

friend class toraAgent [friend]
 

Definition at line 45 of file tora_dest.h.


Member Data Documentation

toraAgent* TORADest::agent [private]
 

Definition at line 88 of file tora_dest.h.

Referenced by nb_add(), nb_del(), TORADest(), and update_height().

Height TORADest::height [private]
 

Definition at line 76 of file tora_dest.h.

Referenced by dump(), toraAgent::log_route_table(), toraAgent::logToraDest(), toraAgent::recvCLR(), toraAgent::recvQRY(), toraAgent::recvUPD(), toraAgent::sendUPD(), update_height(), and update_height_nb().

nsaddr_t TORADest::index [private]
 

Definition at line 75 of file tora_dest.h.

Referenced by toraAgent::dst_find(), dump(), toraAgent::log_route_table(), toraAgent::logNbDeletedLastDN(), toraAgent::logNextHopChange(), toraAgent::logToraDest(), nb_add(), nb_del(), toraAgent::recvCLR(), toraAgent::recvQRY(), toraAgent::recvTORA(), toraAgent::recvUPD(), toraAgent::rtNotifyLinkDN(), toraAgent::rtNotifyLinkUP(), and TORADest().

tn_head TORADest::nblist [private]
 

Definition at line 83 of file tora_dest.h.

Referenced by dump(), toraAgent::logNextHopChange(), nb_add(), nb_check_same_ref(), nb_del(), nb_find(), nb_find_max_height(), nb_find_min_height(), nb_find_min_nonnull_height(), nb_find_next_hop(), toraAgent::recvCLR(), toraAgent::recvUPD(), TORADest(), and update_height().

int TORADest::num_active [private]
 

Definition at line 84 of file tora_dest.h.

Referenced by dump(), toraAgent::log_route_table(), toraAgent::logToraDest(), nb_add(), nb_del(), toraAgent::recvCLR(), toraAgent::recvQRY(), TORADest(), and update_height().

int TORADest::num_down [private]
 

Definition at line 85 of file tora_dest.h.

Referenced by dump(), toraAgent::log_route_table(), toraAgent::logToraDest(), nb_add(), nb_del(), toraAgent::recvCLR(), toraAgent::recvUPD(), TORADest(), update_height(), and update_height_nb().

int TORADest::num_up [private]
 

Definition at line 86 of file tora_dest.h.

Referenced by dump(), toraAgent::log_route_table(), toraAgent::logToraDest(), nb_del(), toraAgent::recvCLR(), toraAgent::recvUPD(), TORADest(), update_height(), and update_height_nb().

int TORADest::rt_req [private]
 

Definition at line 77 of file tora_dest.h.

Referenced by dump(), toraAgent::log_route_table(), toraAgent::logToraDest(), toraAgent::recvCLR(), toraAgent::recvQRY(), toraAgent::recvUPD(), toraAgent::rt_resolve(), toraAgent::rtNotifyLinkUP(), and TORADest().

double TORADest::time_rt_req [private]
 

Definition at line 81 of file tora_dest.h.

Referenced by toraAgent::recvQRY(), and TORADest().

double TORADest::time_tx_qry [private]
 

Definition at line 80 of file tora_dest.h.

Referenced by toraAgent::rt_resolve(), toraAgent::rtNotifyLinkUP(), and TORADest().

double TORADest::time_upd [private]
 

Definition at line 78 of file tora_dest.h.

Referenced by dump(), toraAgent::log_route_table(), toraAgent::logToraDest(), toraAgent::recvCLR(), toraAgent::recvQRY(), toraAgent::recvUPD(), and TORADest().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:33:24 2004 for NS2.26SourcesOriginal by doxygen 1.3.3