Node Class Reference

#include <node.h>

Inheritance diagram for Node:

RNode ParentNode nodehead_ TclObject MobileNode SatNode Collaboration diagram for Node:

Collaboration graph
[legend]

Detailed Description

Definition at line 98 of file node.cc.

Public Member Functions

void add_route (char *dst, NsObject *target)
virtual void AddAdj (nodeid_t a, int w=1)
void addNeighbor (Node *node)
int address ()
virtual int command (int argc, const char *const *argv)
void delete_route (char *dst, NsObject *nullagent)
void Dump (void)
EnergyModelenergy_model ()
bool exist_namchan () const
virtual nodeid_t GetNeighbor (Nix_t)
virtual NixPair_t GetNix (nodeid_t)
virtual Nixl_t GetNixl ()
const struct if_head & ifhead () const
void insert (struct node_head *head)
NsObjectintf_to_target (int32_t)
const struct linklist_head & linklisthead () const
Locationlocation ()
virtual void namlog (const char *fmt,...)
virtual const NodeWeight_t NextAdj (const NodeWeight_t &)
Nodenextnode ()
 Node (const Node &n)
 Node (nodeid_t id)
 Node (void)
 Node (void)
int nodeid ()
void route_notify (RoutingModule *rtm)
void set_table_size (int level, int csize)
void set_table_size (int nn)
void unreg_route_notify (RoutingModule *rtm)
void Update (void)
void UpdateNeighbors (void)
virtual ~Node ()
 ~Node ()

Static Public Member Functions

static Nodeget_node_by_address (nsaddr_t)

Data Fields

int link_changes
EdgeVec_t m_Adj
nodeid_t m_id
Neighborneighbor
neighbor_list_nodeneighbor_list_
int route_changes
double time_arrival
double time_transition

Static Public Attributes

static struct node_head nodehead_

Protected Member Functions

 LIST_ENTRY (Node) entry
void namdump ()

Protected Attributes

int address_
EnergyModelenergy_model_
if_head ifhead_
linklist_head linklisthead_
Locationlocation_
Tcl_Channel namChan_
int nodeid_
RoutingModulertnotif_

Static Protected Attributes

static char nwrk_ [NODE_NAMLOG_BUFSZ]

Private Member Functions

 LIST_HEAD (traj, setdest) traj
void RandomDestination (void)
void RandomPosition (void)
void RandomSpeed (void)

Private Attributes

vector destination
vector direction
u_int32_t first_trip
u_int32_t index
vector position
double speed
double time_update

Static Private Attributes

static u_int32_t NodeIndex = 0

Friends

void ReadInMovementPattern (void)


Constructor & Destructor Documentation

Node::Node void   ) 
 

Definition at line 105 of file node.cc.

References ifhead_, insert(), linklisthead_, LIST_INIT, neighbor_list_, NixRoutingUsed, and nodehead_.

Referenced by command(), and get_node_by_address().

00105            : 
00106     address_(-1), nodeid_ (-1), namChan_(0),
00107     rtnotif_(NULL),
00108 #ifdef HAVE_STL
00109     nixnode_(NULL),
00110 #endif //HAVE_STL
00111     energy_model_(NULL), location_(NULL)
00112 {
00113     LIST_INIT(&ifhead_);
00114     LIST_INIT(&linklisthead_);
00115     insert(&(Node::nodehead_)); // insert self into static list of nodes
00116 #ifdef HAVE_STL
00117     // Mods for Nix-Vector routing
00118     if (NixRoutingUsed < 0) {
00119         // Find out if nix routing is in use
00120         Tcl& tcl = Tcl::instance();
00121         tcl.evalf("Simulator set nix-routing");
00122         tcl.resultAs(&NixRoutingUsed);
00123     }
00124     if (NixRoutingUsed) {
00125         // Create the NixNode pointer
00126         if(0)printf("Nix routing in use, creating NixNode\n");
00127         nixnode_ = new NixNode();
00128     }
00129 #endif //HAVE_STL
00130     neighbor_list_ = NULL;
00131 }

Here is the call graph for this function:

Node::~Node  ) 
 

Definition at line 133 of file node.cc.

References LIST_REMOVE.

00134 {
00135     LIST_REMOVE(this, entry);
00136 }

Node::Node void   ) 
 

Node::Node nodeid_t  id  )  [inline]
 

Definition at line 75 of file tnode.h.

00075 : RNode(id) { };

Node::Node const Node n  )  [inline]
 

Definition at line 76 of file tnode.h.

00076 : RNode(n.m_id) { };

virtual Node::~Node  )  [inline, virtual]
 

Definition at line 77 of file tnode.h.

00077 { };


Member Function Documentation

void Node::add_route char *  dst,
NsObject target
[virtual]
 

Reimplemented from ParentNode.

Definition at line 241 of file node.cc.

References RoutingModule::add_route(), and rtnotif_.

00241                                                 {
00242     if (rtnotif_)
00243         rtnotif_->add_route(dst, target);
00244 }

Here is the call graph for this function:

virtual void Node::AddAdj nodeid_t  a,
int  w = 1
[virtual]
 

Reimplemented from RNode.

void Node::addNeighbor Node node  ) 
 

Definition at line 262 of file node.cc.

References neighbor, neighbor_list_, neighbor_list_node::next, and neighbor_list_node::nodeid.

Referenced by command().

00262                                       {
00263 
00264     neighbor_list_node* nlistItem = (neighbor_list_node *)malloc(sizeof(neighbor_list_node));
00265     nlistItem->nodeid = neighbor->nodeid();
00266     nlistItem->next = neighbor_list_;
00267     neighbor_list_=nlistItem; 
00268 }

int Node::address  )  [inline, virtual]
 

Reimplemented from ParentNode.

Definition at line 131 of file node.h.

Referenced by ARPTable::arpinput(), ARPTable::arpresolve(), SctpAgent::command(), PushbackAgent::command(), God::command(), SatRouteObject::compute_topology(), GridKeeper::dump(), SatNode::dumpSats(), GridKeeper::get_neighbors(), LinkHandoffMgr::get_peer_linkhead(), GridHandler::handle(), WebTrafPool::launchReq(), SatRouteObject::populate_routing_tables(), and EmpFtpTrafSession::sendFile().

00131 { return address_;}

int Node::command int  argc,
const char *const *  argv
[virtual]
 

Reimplemented in MobileNode, and SatNode.

Definition at line 139 of file node.cc.

References addNeighbor(), address_, energy_model_, LinkHead::insertlink(), Address::instance(), linklisthead_, namChan_, Node(), nodeid_, and Address::str2addr().

Referenced by SatNode::command(), and MobileNode::command().

00140 {
00141     Tcl& tcl = Tcl::instance();
00142     if (argc == 2) {
00143 #ifdef HAVE_STL
00144         // Mods for Nix-Vector Routing
00145         if(strcmp(argv[1], "populate-objects") == 0) {
00146             if (nixnode_) {
00147                 nixnode_->PopulateObjects();
00148             }
00149             return TCL_OK;
00150         }
00151         // End mods for Nix-Vector routing
00152 #endif // HAVE_STL
00153         if(strcmp(argv[1], "address?") == 0) {
00154             tcl.resultf("%d", address_);
00155             return TCL_OK;
00156         }
00157         
00158         
00159     } else if (argc == 3) {
00160 #ifdef HAVE_STL
00161         // Mods for Nix-Vector Routing
00162         if (strcmp(argv[1], "get-nix-vector") == 0) {
00163             if (nixnode_) {
00164                 nixnode_->GetNixVector(atol(argv[2]));
00165             }
00166             return TCL_OK;
00167         }
00168 #endif //HAVE_STL
00169         if (strcmp(argv[1], "set-neighbor") == 0) {
00170 #ifdef HAVE_STL
00171             if (nixnode_) {
00172                 nixnode_->AddAdj(atol(argv[2]));
00173             }
00174 #endif //HAVE_STL
00175             return(TCL_OK);
00176         }
00177         if (strcmp(argv[1], "addr") == 0) {
00178             address_ = Address::instance().str2addr(argv[2]);
00179 #ifdef HAVE_STL
00180             if (nixnode_) {
00181                 nixnode_->Id(address_);
00182             }
00183 #endif //HAVE_STL
00184             return TCL_OK;
00185         // End mods for Nix-Vector routing
00186         } else if (strcmp(argv[1], "nodeid") == 0) {
00187             nodeid_ = atoi(argv[2]);
00188             return TCL_OK;
00189         } else if(strcmp(argv[1], "addlinkhead") == 0) {
00190             LinkHead* slhp = (LinkHead*)TclObject::lookup(argv[2]);
00191             if (slhp == 0)
00192                 return TCL_ERROR;
00193             slhp->insertlink(&linklisthead_);
00194             return TCL_OK;
00195         } else if (strcmp(argv[1], "addenergymodel") == 0) {
00196             energy_model_=(EnergyModel*)TclObject::lookup(argv[2]);
00197             if(!energy_model_)
00198                 return TCL_ERROR;
00199             return TCL_OK;
00200         } else if (strcmp(argv[1], "namattach") == 0) {
00201                         int mode;
00202                         namChan_ = Tcl_GetChannel(tcl.interp(), (char*)argv[2],
00203                                                   &mode);
00204                         if (namChan_ == 0) {
00205                                 tcl.resultf("node: can't attach %s", argv[2]);
00206                                 return (TCL_ERROR);
00207                         }
00208                         return (TCL_OK);
00209         } else if (strcmp(argv[1], "add-neighbor") == 0) {
00210             Node * node = (Node *)TclObject::lookup(argv[2]);
00211             if (node == 0) {
00212                 tcl.resultf("Invalid node %s", argv[2]);
00213                                  return (TCL_ERROR);
00214             }
00215             addNeighbor(node);
00216             return TCL_OK;
00217         }
00218     }
00219     return ParentNode::command(argc,argv);
00220 }

Here is the call graph for this function:

void Node::delete_route char *  dst,
NsObject nullagent
[virtual]
 

Reimplemented from ParentNode.

Definition at line 247 of file node.cc.

References RoutingModule::delete_route(), and rtnotif_.

00247                                                       {
00248     if (rtnotif_)
00249         rtnotif_->delete_route(dst, nullagent);
00250 }

Here is the call graph for this function:

void Node::Dump void   ) 
 

Definition at line 624 of file calcdest.cc.

References destination, direction, Neighbor::index, index, neighbor, position, Neighbor::reachable, speed, time_arrival, time_transition, time_update, vector::X, vector::Y, and vector::Z.

00625 {
00626     Neighbor *m;
00627     u_int32_t i;
00628 
00629     fprintf(stdout,
00630         "Node: %d\tpos: (%.2f, %.2f, %.2f) dst: (%.2f, %.2f, %.2f)\n",
00631         index, position.X, position.Y, position.Z,
00632         destination.X, destination.Y, destination.Z);
00633     fprintf(stdout, "\tdir: (%.2f, %.2f, %.2f) speed: %.2f\n",
00634         direction.X, direction.Y, direction.Z, speed);
00635     fprintf(stdout, "\tArrival: %.2f, Update: %.2f, Transition: %.2f\n",
00636         time_arrival, time_update, time_transition);
00637 
00638     for(i = 1; i < NODES; i++) {
00639         m = &neighbor[i];
00640         fprintf(stdout, "\tNeighbor: %d (%lx), Reachable: %d, Transition Time: %.2f\n",
00641             m->index, (long) m, m->reachable, m->time_transition);
00642     }
00643 }

EnergyModel* Node::energy_model  )  [inline]
 

Definition at line 192 of file node.h.

Referenced by MobileNode::command(), WirelessPhy::em(), EnergyTimer::EnergyTimer(), EnergyTimer::expire(), CMUTrace::format_mac_common(), CMUTrace::format_rtp(), GAFAgent::myttl(), CMUTrace::nam_format(), CMUTrace::node_energy(), GAFAgent::node_off(), GAFAgent::node_on(), Phy802_15_4::recv(), Mac802_15_4::recv(), Mac802_11::send(), and Mac802_15_4::sendDown().

00192 { return energy_model_; }

bool Node::exist_namchan  )  const [inline]
 

Definition at line 133 of file node.h.

Referenced by EnergyModel::set_node_sleep().

00133 { return (namChan_ != 0); }

Node * Node::get_node_by_address nsaddr_t   )  [static]
 

Definition at line 315 of file node.cc.

References address_, nextnode(), and Node().

Referenced by CMUTrace::format_mac_common(), CMUTrace::format_rtp(), GAFAgent::GAFAgent(), CMUTrace::nam_format(), and CMUTrace::node_energy().

00316 {
00317     Node * tnode = nodehead_.lh_first;
00318     for (; tnode; tnode = tnode->nextnode()) {
00319         if (tnode->address_ == id ) {
00320             return (tnode);
00321         }
00322     }
00323     return NULL;
00324 }

Here is the call graph for this function:

virtual nodeid_t RNode::GetNeighbor Nix_t   )  [virtual, inherited]
 

virtual NixPair_t Node::GetNix nodeid_t   )  [virtual]
 

Reimplemented from RNode.

virtual Nixl_t RNode::GetNixl  )  [virtual, inherited]
 

Reimplemented in NixNode.

const struct if_head& Node::ifhead  )  const [inline]
 

Definition at line 148 of file node.h.

Referenced by GAFAgent::myttl(), GAFAgent::node_off(), GAFAgent::node_on(), and WirelessChannel::sendUp().

00148 { return ifhead_; }

void Node::insert struct node_head *  head  )  [inline]
 

Definition at line 141 of file node.h.

References LIST_INSERT_HEAD.

Referenced by Node().

00141                                                {
00142         LIST_INSERT_HEAD(head, this, entry);
00143     }

NsObject * Node::intf_to_target int32_t   ) 
 

Definition at line 305 of file node.cc.

References LinkHead::label(), linklisthead_, and LinkHead::nextlinkhead().

00306 {
00307     LinkHead *lhp = linklisthead_.lh_first;
00308     for (; lhp; lhp = lhp->nextlinkhead()) 
00309         if (label == lhp->label())
00310             return ((NsObject*) lhp);
00311     return NULL;
00312 }

Here is the call graph for this function:

const struct linklist_head& Node::linklisthead  )  const [inline]
 

Definition at line 149 of file node.h.

Referenced by SatRouteObject::compute_topology(), LinkHandoffMgr::get_peer_next_linkhead(), SatLinkHandoffMgr::handoff(), and TermLinkHandoffMgr::handoff().

00149                                                             { 
00150         return linklisthead_; 
00151     }

Node::LIST_ENTRY Node   )  [protected]
 

Node::LIST_HEAD traj  ,
setdest 
[private]
 

Location* Node::location  )  [inline]
 

Definition at line 193 of file node.h.

00193 { return location_; }

void Node::namdump  )  [protected]
 

Definition at line 281 of file node.cc.

References abort(), namChan_, NODE_NAMLOG_BUFSZ, and nwrk_.

Referenced by namlog(), and MobileNode::set_destination().

00282 {
00283         int n = 0;
00284         /* Otherwise nwrk_ isn't initialized */
00285     n = strlen(nwrk_);
00286     if (n >= NODE_NAMLOG_BUFSZ-1) {
00287         fprintf(stderr, 
00288             "Node::namdump() exceeds buffer size. Bail out.\n");
00289         abort();
00290     }
00291     if (n > 0) {
00292         /*
00293          * tack on a newline (temporarily) instead
00294          * of doing two writes
00295          */
00296         nwrk_[n] = '\n';
00297         nwrk_[n + 1] = 0;
00298         (void)Tcl_Write(namChan_, nwrk_, n + 1);
00299         nwrk_[n] = 0;
00300     }
00301 }

Here is the call graph for this function:

void Node::namlog const char *  fmt,
  ...
[virtual]
 

Definition at line 270 of file node.cc.

References namChan_, namdump(), and nwrk_.

00271 {
00272     // Don't do anything if we don't have a log file.
00273     if (namChan_ == 0) 
00274         return;
00275     va_list ap;
00276     va_start(ap, fmt);
00277     vsprintf(nwrk_, fmt, ap);
00278     namdump();
00279 }

Here is the call graph for this function:

virtual const NodeWeight_t Node::NextAdj const NodeWeight_t  )  [virtual]
 

Reimplemented from RNode.

Node* Node::nextnode  )  [inline]
 

Reimplemented in MobileNode.

Definition at line 144 of file node.h.

Referenced by SatRouteObject::compute_topology(), SatNode::dumpSats(), get_node_by_address(), and SatRouteObject::populate_routing_tables().

00144 { return entry.le_next; }

int Node::nodeid  )  [inline, virtual]
 

Reimplemented from ParentNode.

Definition at line 132 of file node.h.

Referenced by PushbackAgent::calculateLowerBound(), PushbackAgent::command(), PushbackAgent::getQID(), LoggingDataStruct::LoggingDataStruct(), CMUTrace::nam_format(), PushbackAgent::printMsg(), PushbackAgent::processPushbackStatus(), PushbackAgent::pushbackCancel(), PushbackAgent::pushbackCheck(), PushbackAgent::pushbackRefresh(), PushbackAgent::pushbackStatus(), PushbackAgent::refreshUpstreamLimits(), and PushbackQueue::timeout().

00132 { return nodeid_;}

void Node::RandomDestination void   )  [private]
 

Definition at line 409 of file calcdest.cc.

References destination, MAXX, MAXY, position, uniform(), vector::X, vector::Y, and vector::Z.

00410 {
00411     destination.X = uniform() * MAXX;
00412     destination.Y = uniform() * MAXY;
00413     destination.Z = 0.0;
00414     assert(destination != position);
00415 }

Here is the call graph for this function:

void Node::RandomPosition void   )  [private]
 

Definition at line 400 of file calcdest.cc.

References MAXX, MAXY, position, uniform(), vector::X, vector::Y, and vector::Z.

00401 {
00402     position.X = uniform() * MAXX;
00403     position.Y = uniform() * MAXY;
00404     position.Z = 0.0;
00405 }

Here is the call graph for this function:

void Node::RandomSpeed void   )  [private]
 

Definition at line 418 of file calcdest.cc.

References MAXSPEED, speed, and uniform().

00419 {
00420     speed = uniform() * MAXSPEED;
00421 
00422     assert(speed != 0.0);
00423 }

Here is the call graph for this function:

void Node::route_notify RoutingModule rtm  ) 
 

Definition at line 222 of file node.cc.

References RoutingModule::route_notify(), and rtnotif_.

Referenced by VcRoutingModule::command(), ManualRoutingModule::command(), HierRoutingModule::command(), McastRoutingModule::command(), QSRoutingModule::command(), SourceRoutingModule::command(), BaseRoutingModule::command(), and MPLSModule::command().

00222                                           {
00223     if (rtnotif_ == NULL)
00224         rtnotif_ = rtm;
00225     else
00226         rtnotif_->route_notify(rtm);
00227 }

Here is the call graph for this function:

void Node::set_table_size int  level,
int  csize
[virtual]
 

Reimplemented from ParentNode.

Definition at line 257 of file node.cc.

References rtnotif_, and RoutingModule::set_table_size().

00257                                               {
00258     if (rtnotif_)
00259         rtnotif_->set_table_size(level, csize);
00260 }

Here is the call graph for this function:

void Node::set_table_size int  nn  )  [virtual]
 

Reimplemented from ParentNode.

Definition at line 252 of file node.cc.

References rtnotif_, and RoutingModule::set_table_size().

00252                                 {
00253     if (rtnotif_)
00254         rtnotif_->set_table_size(nn);
00255 }

Here is the call graph for this function:

void Node::unreg_route_notify RoutingModule rtm  ) 
 

Definition at line 229 of file node.cc.

References RoutingModule::next_rtm_, rtnotif_, and RoutingModule::unreg_route_notify().

Referenced by VcRoutingModule::command(), ManualRoutingModule::command(), HierRoutingModule::command(), McastRoutingModule::command(), QSRoutingModule::command(), SourceRoutingModule::command(), BaseRoutingModule::command(), and MPLSModule::command().

00229                                                 {
00230     if (rtnotif_) {
00231         if (rtnotif_ == rtm) {
00232             //RoutingModule *tmp = rtnotif_;
00233             rtnotif_= rtnotif_->next_rtm_;
00234             //free (tmp);
00235         }
00236         else
00237             rtnotif_->unreg_route_notify(rtm);
00238     }
00239 }

Here is the call graph for this function:

void Node::Update void   ) 
 

Definition at line 427 of file calcdest.cc.

References destination, direction, vector::length(), LIST_NEXT, LIST_REMOVE, MAXTIME, position, setdest::speed, speed, TIME, time_arrival, time_transition, time_update, setdest::X, vector::X, setdest::Y, vector::Y, and vector::Z.

00428 {
00429         struct setdest *setdest = traj.lh_first;
00430 
00431     position += (speed * (TIME - time_update)) * direction;
00432 
00433     if(TIME == time_arrival) {
00434 
00435       if (NULL == setdest) 
00436         {
00437           destination = position;
00438           direction.X = direction.Y = direction.Z = 0.0;
00439           speed = 0.0;
00440           time_arrival = MAXTIME + 1;
00441         } 
00442       else 
00443         {
00444           vector v;
00445           destination.X = setdest->X;
00446           destination.Y = setdest->Y;
00447           speed = setdest->speed;
00448           if (0.0 == speed)
00449         { // it's a pause at the current location
00450           if (LIST_NEXT(setdest,traj))
00451             time_arrival = LIST_NEXT(setdest,traj)->time;
00452           else
00453             time_arrival = MAXTIME + 1;
00454         }
00455           else 
00456         { // we're moving somewhere, when do we get there?
00457           v = destination - position;
00458           direction = v / v.length();
00459           time_arrival = TIME + v.length() / speed;
00460         }
00461           LIST_REMOVE(setdest,traj);
00462           free(setdest);
00463         }
00464     }
00465 
00466     time_update = TIME;
00467     time_transition = 0.0;
00468 }

Here is the call graph for this function:

void Node::UpdateNeighbors void   ) 
 

Definition at line 472 of file calcdest.cc.

References a, b, direction, index, vector::length(), m1, m2, neighbor, NodeList, position, RANGE, ROUND_ERROR, SANITY_CHECKS, speed, and TIME.

00473 {
00474     static Node *n2;
00475     static Neighbor *m1, *m2;
00476     static vector D, B, v1, v2;
00477     static double a, b, c, t1, t2, Q;
00478     static u_int32_t i, reachable;
00479 
00480     v1 = speed * direction;
00481 
00482     /*
00483      *  Only need to go from INDEX --> N for each one since links
00484      *  are symmetric.
00485      */
00486     for(i = index+1; i < NODES; i++) {
00487 
00488         m1 = &neighbor[i];
00489         n2 = &NodeList[i];
00490         m2 = &n2->neighbor[index];
00491 
00492         assert(i == m1->index);
00493         assert(m1->index == n2->index);
00494         assert(index == m2->index);
00495                 assert(m1->reachable == m2->reachable);
00496 
00497                 reachable = m1->reachable;
00498 
00499         /* ==================================================
00500            Determine Reachability
00501            ================================================== */
00502         {   vector d = position - n2->position;
00503 
00504             if(d.length() < RANGE) {
00505 #ifdef SANITY_CHECKS
00506                 if(TIME > 0.0 && m1->reachable == 0)
00507                     assert(RANGE - d.length() < ROUND_ERROR);
00508 #endif
00509                 m1->reachable = m2->reachable = 1;
00510             }
00511             // Boundary condition handled below.
00512             else {
00513 #ifdef SANITY_CHECKS
00514                 if(TIME > 0.0 && m1->reachable == 1)
00515                     assert(d.length() - RANGE < ROUND_ERROR);
00516 #endif
00517                 m1->reachable = m2->reachable = 0;
00518             }
00519 #ifdef DEBUG
00520                         fprintf(stdout, "# %.6f (%d, %d) %.2fm\n",
00521                                 TIME, index, m1->index, d.length());
00522 #endif
00523         }
00524 
00525         /* ==================================================
00526            Determine Next Event Time
00527            ================================================== */
00528         v2 = n2->speed * n2->direction;
00529 
00530         D = v2 - v1;
00531         B = n2->position - position;
00532 
00533         a = (D.X * D.X) + (D.Y * D.Y) + (D.Z * D.Z);
00534         b = 2 * ((D.X * B.X) + (D.Y * B.Y) + (D.Z * B.Z));
00535         c = (B.X * B.X) + (B.Y * B.Y) + (B.Z * B.Z) - (RANGE * RANGE);
00536 
00537         if(a == 0.0) {
00538             /*
00539              *  No Finite Solution
00540              */
00541             m1->time_transition= 0.0;
00542             m2->time_transition= 0.0;
00543             goto  next;
00544         }
00545 
00546         Q = b * b - 4 * a * c;
00547         if(Q < 0.0) {
00548             /*
00549              *  No real roots.
00550              */
00551             m1->time_transition = 0.0;
00552             m2->time_transition = 0.0;
00553             goto next;
00554         }
00555         Q = sqrt(Q);
00556 
00557         t1 = (-b + Q) / (2 * a);
00558         t2 = (-b - Q) / (2 * a);
00559 
00560         // Stupid Rounding/Boundary Cases
00561         if(t1 > 0.0 && t1 < ROUND_ERROR) t1 = 0.0;
00562         if(t1 < 0.0 && -t1 < ROUND_ERROR) t1 = 0.0;
00563         if(t2 > 0.0 && t2 < ROUND_ERROR) t2 = 0.0;
00564         if(t2 < 0.0 && -t2 < ROUND_ERROR) t2 = 0.0;
00565 
00566         if(t1 < 0.0 && t2 < 0.0) {
00567             /*
00568              *  No "future" time solution.
00569              */
00570             m1->time_transition = 0.0;
00571             m2->time_transition = 0.0;
00572             goto next;
00573         }
00574 
00575         /*
00576          * Boundary conditions.
00577          */
00578         if((t1 == 0.0 && t2 > 0.0) || (t2 == 0.0 && t1 > 0.0)) {
00579             m1->reachable = m2->reachable = 1;
00580             m1->time_transition = m2->time_transition = TIME + max(t1, t2);
00581         }
00582         else if((t1 == 0.0 && t2 < 0.0) || (t2 == 0.0 && t1 < 0.0)) {
00583             m1->reachable = m2->reachable = 0;
00584             m1->time_transition = m2->time_transition = 0.0;
00585         }
00586 
00587         /*
00588          * Non-boundary conditions.
00589          */
00590         else if(t1 > 0.0 && t2 > 0.0) {
00591             m1->time_transition = TIME + min(t1, t2);
00592             m2->time_transition = TIME + min(t1, t2);
00593         }
00594         else if(t1 > 0.0) {
00595             m1->time_transition = TIME + t1;
00596             m2->time_transition = TIME + t1;
00597         }
00598         else {
00599             m1->time_transition = TIME + t2;
00600             m2->time_transition = TIME + t2;
00601         }
00602 
00603         /* ==================================================
00604            Update the transition times for both NODEs.
00605            ================================================== */
00606         if(time_transition == 0.0 || (m1->time_transition &&
00607            time_transition > m1->time_transition)) {
00608             time_transition = m1->time_transition;
00609         }
00610         if(n2->time_transition == 0.0 || (m2->time_transition &&
00611            n2->time_transition > m2->time_transition)) {
00612             n2->time_transition = m2->time_transition;
00613         }
00614         next:
00615                 if(reachable != m1->reachable && TIME > 0.0) {
00616                         LinkChangeCount++;
00617                         link_changes++;
00618                         n2->link_changes++;
00619                 }
00620     }
00621 }

Here is the call graph for this function:


Friends And Related Function Documentation

void ReadInMovementPattern void   )  [friend]
 

Definition at line 176 of file calcdest.cc.

00177 {
00178   char buf[256];
00179   u_int n;
00180   double x,y,z,t,s;
00181   struct setdest *setdest;
00182 
00183   while (!feof(in_file)) {
00184 
00185     fgets(buf, sizeof(buf), in_file);
00186     fprintf(out_file, "%s", buf);
00187     if (*buf == '#') continue;
00188     if (*buf == '\n') continue;
00189 
00190     /* check to see if we need data from the line */
00191     if (2 == sscanf(buf,"$node_(%d) set Z_ %lf", &n, &z)) 
00192       {
00193     assert(n < NODES);
00194     NodeList[n].position.Z = z;
00195       }
00196     else if (2 == sscanf(buf,"$node_(%d) set X_ %lf", &n, &x)) 
00197       {
00198     assert(n < NODES);
00199     NodeList[n].position.X = x;
00200       }
00201     else if (2 == sscanf(buf,"$node_(%d) set Y_ %lf", &n, &y)) 
00202       {
00203     assert(n < NODES);
00204     NodeList[n].position.Y = y;
00205       }
00206     else if (5 == sscanf(buf,"$ns_ at %lf \"$node_(%d) setdest %lf %lf %lf\"", 
00207             &t, &n, &x, &y, &s)) 
00208       {
00209     assert(n < NODES);
00210     assert(t <= MAXTIME);
00211     setdest = (struct setdest *)malloc(sizeof(*setdest));
00212     assert(setdest);
00213     setdest->X = x; setdest->Y = y; setdest->Z = 0;
00214     setdest->time = t;
00215     setdest->speed = s;
00216     if (NodeList[n].traj.lh_first 
00217         && t > NodeList[n].traj.lh_first->time)
00218       {
00219         printf("setdest's must be in anti-chronological order in input file!\n");
00220         printf("failed on node %d\n",n);
00221         exit(-1);
00222       }
00223     LIST_INSERT_HEAD(&NodeList[n].traj,setdest,traj);
00224       }
00225     else 
00226       {
00227     printf("unparsable line: '%s'", buf);
00228     continue;
00229       }
00230   }  
00231   fflush(out_file);  
00232 }


Field Documentation

int Node::address_ [protected]
 

Reimplemented from ParentNode.

Definition at line 169 of file node.h.

Referenced by MobileNode::bound_position(), command(), MobileNode::command(), MobileNode::dump(), get_node_by_address(), MobileNode::log_energy(), MobileNode::log_movement(), MobileNode::random_destination(), MobileNode::set_destination(), MobileNode::start(), and MobileNode::update_position().

vector Node::destination [private]
 

Definition at line 97 of file setdest.h.

Referenced by Dump(), RandomDestination(), and Update().

vector Node::direction [private]
 

Definition at line 98 of file setdest.h.

Referenced by Dump(), Update(), and UpdateNeighbors().

EnergyModel* Node::energy_model_ [protected]
 

Definition at line 195 of file node.h.

Referenced by command(), and MobileNode::log_energy().

u_int32_t Node::first_trip [private]
 

Definition at line 94 of file setdest.h.

struct if_head Node::ifhead_ [protected]
 

Definition at line 179 of file node.h.

Referenced by SatNode::command(), MobileNode::command(), MobileNode::dump(), MobileNode::MobileNode(), and Node().

u_int32_t Node::index [private]
 

Definition at line 93 of file setdest.h.

Referenced by Dump(), and UpdateNeighbors().

int Node::link_changes
 

Definition at line 86 of file setdest.h.

struct linklist_head Node::linklisthead_ [protected]
 

Definition at line 180 of file node.h.

Referenced by command(), intf_to_target(), and Node().

Location* Node::location_ [protected]
 

Definition at line 199 of file node.h.

EdgeVec_t Node::m_Adj
 

Definition at line 82 of file tnode.h.

nodeid_t RNode::m_id [inherited]
 

Definition at line 42 of file rnode.h.

Referenced by NixNode::Id().

Tcl_Channel Node::namChan_ [protected]
 

Definition at line 173 of file node.h.

Referenced by command(), namdump(), namlog(), and MobileNode::set_destination().

Neighbor* Node::neighbor
 

Definition at line 109 of file setdest.h.

Referenced by addNeighbor(), Dump(), and UpdateNeighbors().

neighbor_list_node* Node::neighbor_list_
 

Definition at line 154 of file node.h.

Referenced by addNeighbor(), LoggingDataStruct::LoggingDataStruct(), and Node().

struct node_head Node::nodehead_ [static]
 

Definition at line 140 of file node.h.

Referenced by SatRouteObject::compute_topology(), SatNode::dumpSats(), Node(), and SatRouteObject::populate_routing_tables().

int Node::nodeid_ [protected]
 

Reimplemented from ParentNode.

Definition at line 170 of file node.h.

Referenced by command(), and MobileNode::set_destination().

u_int32_t Node::NodeIndex = 0 [static, private]
 

Definition at line 103 of file setdest.h.

char Node::nwrk_ [static, protected]
 

Definition at line 176 of file node.h.

Referenced by namdump(), namlog(), and MobileNode::set_destination().

vector Node::position [private]
 

Definition at line 96 of file setdest.h.

Referenced by Dump(), RandomDestination(), RandomPosition(), ReadInMovementPattern(), Update(), and UpdateNeighbors().

int Node::route_changes
 

Definition at line 85 of file setdest.h.

Referenced by show_diffs().

RoutingModule* Node::rtnotif_ [protected]
 

Definition at line 183 of file node.h.

Referenced by add_route(), delete_route(), route_notify(), set_table_size(), and unreg_route_notify().

double Node::speed [private]
 

Definition at line 100 of file setdest.h.

Referenced by Dump(), RandomSpeed(), Update(), and UpdateNeighbors().

double Node::time_arrival
 

Definition at line 81 of file setdest.h.

Referenced by Dump(), and Update().

double Node::time_transition
 

Definition at line 82 of file setdest.h.

Referenced by Dump(), main(), and Update().

double Node::time_update [private]
 

Definition at line 101 of file setdest.h.

Referenced by Dump(), and Update().


The documentation for this class was generated from the following files:
Generated on Tue Mar 6 17:22:57 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6