SatNode Class Reference

#include <satnode.h>

Inheritance diagram for SatNode:

Node RNode ParentNode nodehead_ TclObject Collaboration diagram for SatNode:

Collaboration graph
[legend]

Detailed Description

Definition at line 54 of file satnode.h.

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 ()
void delete_route (char *dst, NsObject *nullagent)
Channeldownlink ()
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 ()
int nodeid ()
SatPositionposition ()
SatRouteAgentragent ()
void route_notify (RoutingModule *rtm)
 SatNode ()
void set_table_size (int level, int csize)
void set_table_size (int nn)
SatTracetrace ()
void unreg_route_notify (RoutingModule *rtm)
void Update (void)
void UpdateNeighbors (void)
Channeluplink ()

Static Public Member Functions

static int addNode (int)
static Nodeget_node_by_address (nsaddr_t)
static int IsASatNode (int)

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 int dist_routing_ = 0
static struct node_head nodehead_

Protected Member Functions

int command (int argc, const char *const *argv)
void dumpSats ()
 LIST_ENTRY (Node) entry
void namdump ()

Protected Attributes

int address_
SatChanneldownlink_
EnergyModelenergy_model_
LinkHandoffMgrhm_
if_head ifhead_
linklist_head linklisthead_
Locationlocation_
Tcl_Channel namChan_
int nodeid_
SatPositionpos_
SatRouteAgentragent_
RoutingModulertnotif_
SatTracetrace_
SatChanneluplink_

Static Protected Attributes

static int maxsatnodelist_ = 0
static char nwrk_ [NODE_NAMLOG_BUFSZ]
static int * satnodelist_ = NULL


Constructor & Destructor Documentation

SatNode::SatNode  ) 
 

Definition at line 61 of file satnode.cc.

References dist_routing_.

00061                  : ragent_(0), trace_(0), hm_(0)  
00062 {
00063     bind_bool("dist_routing_", &dist_routing_);
00064 }


Member Function Documentation

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

Reimplemented from ParentNode.

Definition at line 241 of file node.cc.

References RoutingModule::add_route(), and Node::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, inherited]
 

Reimplemented from RNode.

void Node::addNeighbor Node node  )  [inherited]
 

Definition at line 262 of file node.cc.

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

Referenced by Node::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 SatNode::addNode int   )  [static]
 

Definition at line 151 of file satnode.cc.

References MAXSATNODELIST, maxsatnodelist_, and satnodelist_.

Referenced by command().

00152 {
00153     if (maxsatnodelist_ == 0) {
00154         satnodelist_ = new int[MAXSATNODELIST];
00155         memset(satnodelist_, 0, MAXSATNODELIST * sizeof(satnodelist_));
00156         maxsatnodelist_ = MAXSATNODELIST;
00157     }
00158     assert(nodenum < 2*maxsatnodelist_);
00159     if (nodenum >= maxsatnodelist_) {
00160         // Double size of array
00161         int i;
00162         int* temp = new int[2 * maxsatnodelist_];
00163         memset(temp, 0, 2 * maxsatnodelist_ * sizeof(temp));
00164         for (i = 0; i < maxsatnodelist_; i++) {
00165             temp[i] = satnodelist_[i];
00166         }
00167         delete [] satnodelist_;
00168         satnodelist_ = temp;
00169         maxsatnodelist_ *= 2;
00170     }
00171     satnodelist_[nodenum] = 1;
00172     return 0;
00173 }

int Node::address  )  [inline, virtual, inherited]
 

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(), dumpSats(), GridKeeper::get_neighbors(), LinkHandoffMgr::get_peer_linkhead(), GridHandler::handle(), WebTrafPool::launchReq(), SatRouteObject::populate_routing_tables(), and EmpFtpTrafSession::sendFile().

00131 { return address_;}

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

Reimplemented from Node.

Definition at line 66 of file satnode.cc.

References addNode(), Node::command(), downlink_, dumpSats(), hm_, Node::ifhead_, Phy::insertnode(), pos_, ragent_, Phy::setnode(), LinkHandoffMgr::start(), trace_, and uplink_.

00066                                                      {     
00067     Tcl& tcl = Tcl::instance();
00068     if (argc == 2) {
00069         if (strcmp(argv[1], "set_downlink") == 0) {
00070             if (downlink_ != NULL) {
00071                 tcl.result(downlink_->name());
00072                 return (TCL_OK);
00073             }
00074         } else if (strcmp(argv[1], "set_uplink") == 0) {
00075             if (downlink_ != NULL) {
00076                 tcl.result(uplink_->name());
00077                 return (TCL_OK);
00078             }
00079         } else if (strcmp(argv[1], "start_handoff") == 0) {
00080             if (hm_)
00081                 hm_->start();
00082             else {
00083                 printf("Error: starting non-existent ");
00084                 printf("handoff mgr\n");
00085                 exit(1);
00086             }
00087             return (TCL_OK);
00088         } else if (strcmp(argv[1], "dump_sats") == 0) {
00089             dumpSats();
00090             return (TCL_OK);
00091         }
00092     }
00093     if (argc == 3) {
00094         if (strcmp(argv[1], "set_uplink") == 0) {
00095             uplink_ = (SatChannel *) TclObject::lookup(argv[2]);
00096             if (uplink_ == 0) {
00097                 tcl.resultf("no such object %s", argv[2]);
00098                 return (TCL_ERROR);
00099             }
00100             return (TCL_OK);
00101         } else if (strcmp(argv[1], "set_downlink") == 0) {
00102             downlink_ = (SatChannel *) TclObject::lookup(argv[2]);
00103             if (downlink_ == 0) {
00104                 tcl.resultf("no such object %s", argv[2]);
00105                 return (TCL_ERROR);
00106             }
00107             return (TCL_OK);
00108         } else if (strcmp(argv[1], "set_trace") == 0) {
00109             trace_ = (SatTrace *) TclObject::lookup(argv[2]);
00110             if (trace_ == 0) {
00111                 tcl.resultf("no such object %s", argv[2]);
00112                 return (TCL_ERROR);
00113             }
00114             return (TCL_OK);
00115         } else if (strcmp(argv[1], "set_ragent") == 0) {
00116             ragent_ = (SatRouteAgent *) TclObject::lookup(argv[2]);
00117             if (ragent_ == 0) {
00118                 tcl.resultf("no such object %s", argv[2]);
00119                 return (TCL_ERROR);
00120             }
00121             return (TCL_OK);
00122         } else if(strcmp(argv[1], "addif") == 0) {
00123                         SatPhy* n = (SatPhy*) TclObject::lookup(argv[2]);
00124                         if(n == 0)
00125                                 return TCL_ERROR; 
00126                         n->insertnode(&ifhead_);
00127                         n->setnode(this);
00128                         return TCL_OK;
00129         } else if (strcmp(argv[1], "set_position") == 0) {
00130             pos_ = (SatPosition*) TclObject::lookup(argv[2]);
00131             if (pos_ == 0) {
00132                 tcl.resultf("no such object %s", argv[2]);
00133                 return (TCL_ERROR);
00134             }
00135             return (TCL_OK);
00136         } else if (strcmp(argv[1], "set_handoff_mgr") == 0) {
00137             hm_ = (LinkHandoffMgr*) TclObject::lookup(argv[2]);
00138             if (hm_ == 0) {
00139                 tcl.resultf("no such object %s", argv[2]);
00140                 return (TCL_ERROR);
00141             }
00142             return (TCL_OK);
00143         } else if (strcmp(argv[1], "set_address") == 0) {
00144             addNode(atoi(argv[2]));
00145             return (TCL_OK);
00146         }
00147     }
00148     return (Node::command(argc, argv));
00149 }

Here is the call graph for this function:

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

Reimplemented from ParentNode.

Definition at line 247 of file node.cc.

References RoutingModule::delete_route(), and Node::rtnotif_.

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

Here is the call graph for this function:

Channel* SatNode::downlink  )  [inline]
 

Definition at line 65 of file satnode.h.

References downlink_.

00065 { return ((Channel*) downlink_);} 

void Node::Dump void   )  [inherited]
 

Definition at line 624 of file calcdest.cc.

References Node::destination, Node::direction, Neighbor::index, Node::index, Node::neighbor, Node::position, Neighbor::reachable, Node::speed, Node::time_arrival, Node::time_transition, Node::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 }

void SatNode::dumpSats  )  [protected]
 

Definition at line 186 of file satnode.cc.

References Node::address(), SatPosition::coord(), SatGeometry::get_latitude(), SatGeometry::get_longitude(), IsASatNode(), Node::nextnode(), Node::nodehead_, NOW, PolarSatPosition::plane(), position(), POSITION_SAT_POLAR, RAD_TO_DEG, and SatPosition::type().

Referenced by command().

00187 {
00188     SatNode *snodep, *peer_snodep;
00189     SatPosition *sposp, *peer_sposp;
00190     PolarSatPosition *polar_sposp;
00191     SatLinkHead *slhp;
00192     int linktype;
00193 
00194         printf("\nDumping satellites at time %.2f\n\n", NOW);
00195         for (snodep= (SatNode*) Node::nodehead_.lh_first; snodep; 
00196         snodep = (SatNode*) snodep->nextnode()) {
00197         if (!SatNode::IsASatNode(snodep->address()))
00198             continue;
00199         sposp = snodep->position();
00200                 printf("%d\t%.2f\t%.2f", snodep->address(), 
00201             RAD_TO_DEG(SatGeometry::get_latitude(sposp->coord())), 
00202             RAD_TO_DEG(SatGeometry::get_longitude(sposp->coord())));
00203         // If SatNode is polar, append plane information
00204         if (sposp->type()==POSITION_SAT_POLAR) {
00205             polar_sposp = (PolarSatPosition*) snodep->position();
00206             printf ("\t%d", polar_sposp->plane());
00207         } else if (sposp->type()==POSITION_SAT_GEO) {
00208             printf ("\tGEO");
00209         } else if (sposp->type()==POSITION_SAT_TERM) {
00210             printf ("\tTERM");
00211         }
00212         printf("\n");
00213     }
00214         printf("\n");
00215         // Dump satellite links
00216         // There is a static list of address classifiers //QQQ
00217         printf("Links:\n");
00218         for (snodep = (SatNode*) Node::nodehead_.lh_first; snodep; 
00219         snodep = (SatNode*) snodep->nextnode()) {
00220         if (!SatNode::IsASatNode(snodep->address()))
00221             continue;
00222         // XXX Not all links necessarily satlinks
00223         for (slhp = (SatLinkHead*) snodep->linklisthead_.lh_first; 
00224             slhp; slhp = (SatLinkHead*) slhp->nextlinkhead() ) {
00225             linktype = slhp->type();
00226                     if (linktype == LINK_GENERIC)
00227                             continue;
00228             if (!slhp->linkup_)
00229                 continue;
00230                         // Link is up.
00231             // Print out source and dest coordinates.
00232             sposp = snodep->position();
00233             peer_snodep = hm_->get_peer(slhp);
00234             if (peer_snodep == 0)
00235                 continue; // this link interface is not attached
00236             // need something in here for txs.
00237             peer_sposp = peer_snodep->position();
00238                         printf("%.2f\t%.2f\t%.2f\t%.2f\t%d\n", 
00239              RAD_TO_DEG(SatGeometry::get_latitude(sposp->coord())),
00240              RAD_TO_DEG(SatGeometry::get_longitude(sposp->coord())),
00241              RAD_TO_DEG(SatGeometry::get_latitude(peer_sposp->coord())), 
00242              RAD_TO_DEG(SatGeometry::get_longitude(peer_sposp->coord())),
00243              linktype);
00244         }
00245     }
00246     printf("\nDumped satellites at time %.2f\n\n", NOW);
00247 }

Here is the call graph for this function:

EnergyModel* Node::energy_model  )  [inline, inherited]
 

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, inherited]
 

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, inherited]
 

Definition at line 315 of file node.cc.

References Node::address_, Node::nextnode(), and Node::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, inherited]
 

Reimplemented from RNode.

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

Reimplemented in NixNode.

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

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, inherited]
 

Definition at line 141 of file node.h.

References LIST_INSERT_HEAD.

Referenced by Node::Node().

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

NsObject * Node::intf_to_target int32_t   )  [inherited]
 

Definition at line 305 of file node.cc.

References LinkHead::label(), Node::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:

int SatNode::IsASatNode int   )  [static]
 

Definition at line 175 of file satnode.cc.

References maxsatnodelist_, and satnodelist_.

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

00176 {
00177     if (nodenum > maxsatnodelist_) {
00178         printf("Error: IsASatNode() nodenum %d greater than maxsatnodelist_ %d\n", nodenum, maxsatnodelist_);
00179         exit(1);
00180     }
00181     return satnodelist_[nodenum];
00182 }

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

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, inherited]
 

Location* Node::location  )  [inline, inherited]
 

Definition at line 193 of file node.h.

00193 { return location_; }

void Node::namdump  )  [protected, inherited]
 

Definition at line 281 of file node.cc.

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

Referenced by Node::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, inherited]
 

Definition at line 270 of file node.cc.

References Node::namChan_, Node::namdump(), and Node::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, inherited]
 

Reimplemented from RNode.

Node* Node::nextnode  )  [inline, inherited]
 

Reimplemented in MobileNode.

Definition at line 144 of file node.h.

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

00144 { return entry.le_next; }

int Node::nodeid  )  [inline, virtual, inherited]
 

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_;}

SatPosition* SatNode::position  )  [inline]
 

Definition at line 60 of file satnode.h.

References pos_.

Referenced by dumpSats(), and SatLinkHandoffMgr::handoff().

00060 { return pos_; }

SatRouteAgent* SatNode::ragent  )  [inline]
 

Definition at line 59 of file satnode.h.

References ragent_.

Referenced by SatLL::getRoute(), and SatRouteObject::populate_routing_tables().

00059 { return ragent_; }

void Node::route_notify RoutingModule rtm  )  [inherited]
 

Definition at line 222 of file node.cc.

References RoutingModule::route_notify(), and Node::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, inherited]
 

Reimplemented from ParentNode.

Definition at line 257 of file node.cc.

References Node::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, inherited]
 

Reimplemented from ParentNode.

Definition at line 252 of file node.cc.

References Node::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:

SatTrace* SatNode::trace  )  [inline]
 

Definition at line 61 of file satnode.h.

References trace_.

00061 { return trace_; }

void Node::unreg_route_notify RoutingModule rtm  )  [inherited]
 

Definition at line 229 of file node.cc.

References RoutingModule::next_rtm_, Node::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   )  [inherited]
 

Definition at line 427 of file calcdest.cc.

References Node::destination, Node::direction, vector::length(), LIST_NEXT, LIST_REMOVE, MAXTIME, Node::position, setdest::speed, Node::speed, TIME, Node::time_arrival, Node::time_transition, Node::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   )  [inherited]
 

Definition at line 472 of file calcdest.cc.

References a, b, Node::direction, Node::index, vector::length(), m1, m2, Node::neighbor, NodeList, Node::position, RANGE, ROUND_ERROR, SANITY_CHECKS, Node::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:

Channel* SatNode::uplink  )  [inline]
 

Definition at line 64 of file satnode.h.

References uplink_.

00064 { return ((Channel*) uplink_);} 


Field Documentation

int Node::address_ [protected, inherited]
 

Reimplemented from ParentNode.

Definition at line 169 of file node.h.

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

int SatNode::dist_routing_ = 0 [static]
 

Definition at line 68 of file satnode.h.

Referenced by SatNode().

SatChannel* SatNode::downlink_ [protected]
 

Definition at line 75 of file satnode.h.

Referenced by command(), and downlink().

EnergyModel* Node::energy_model_ [protected, inherited]
 

Definition at line 195 of file node.h.

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

LinkHandoffMgr* SatNode::hm_ [protected]
 

Definition at line 78 of file satnode.h.

Referenced by command().

struct if_head Node::ifhead_ [protected, inherited]
 

Definition at line 179 of file node.h.

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

int Node::link_changes [inherited]
 

Definition at line 86 of file setdest.h.

struct linklist_head Node::linklisthead_ [protected, inherited]
 

Definition at line 180 of file node.h.

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

Location* Node::location_ [protected, inherited]
 

Definition at line 199 of file node.h.

EdgeVec_t Node::m_Adj [inherited]
 

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().

int SatNode::maxsatnodelist_ = 0 [static, protected]
 

Definition at line 81 of file satnode.h.

Referenced by addNode(), and IsASatNode().

Tcl_Channel Node::namChan_ [protected, inherited]
 

Definition at line 173 of file node.h.

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

Neighbor* Node::neighbor [inherited]
 

Definition at line 109 of file setdest.h.

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

neighbor_list_node* Node::neighbor_list_ [inherited]
 

Definition at line 154 of file node.h.

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

struct node_head Node::nodehead_ [static, inherited]
 

Definition at line 140 of file node.h.

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

int Node::nodeid_ [protected, inherited]
 

Reimplemented from ParentNode.

Definition at line 170 of file node.h.

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

char Node::nwrk_ [static, protected, inherited]
 

Definition at line 176 of file node.h.

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

SatPosition* SatNode::pos_ [protected]
 

Definition at line 76 of file satnode.h.

Referenced by command(), and position().

SatRouteAgent* SatNode::ragent_ [protected]
 

Definition at line 73 of file satnode.h.

Referenced by command(), and ragent().

int Node::route_changes [inherited]
 

Definition at line 85 of file setdest.h.

Referenced by show_diffs().

RoutingModule* Node::rtnotif_ [protected, inherited]
 

Definition at line 183 of file node.h.

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

int * SatNode::satnodelist_ = NULL [static, protected]
 

Definition at line 80 of file satnode.h.

Referenced by addNode(), and IsASatNode().

double Node::time_arrival [inherited]
 

Definition at line 81 of file setdest.h.

Referenced by Node::Dump(), and Node::Update().

double Node::time_transition [inherited]
 

Definition at line 82 of file setdest.h.

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

SatTrace* SatNode::trace_ [protected]
 

Definition at line 77 of file satnode.h.

Referenced by command(), and trace().

SatChannel* SatNode::uplink_ [protected]
 

Definition at line 74 of file satnode.h.

Referenced by command(), and uplink().


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