#include <satroute.h>
Inheritance diagram for SatRouteObject:


Public Member Functions | |
| SatRouteObject () | |
| void | recompute () |
| void | recompute_node (int node) |
| int | command (int argc, const char *const *argv) |
| int | data_driven_computation () |
| void | insert_link (int src, int dst, double cost) |
| void | insert_link (int src, int dst, double cost, void *entry) |
| int | wiredRouting () |
| virtual int | lookup_flat (char *asrc, char *adst, int &result) |
| virtual int | lookup_flat (int sid, int did) |
| int | lookup_hier (char *asrc, char *adst, int &result) |
| int | elements_in_level (int *addr, int level) |
| int | domains () |
| int | domain_size (int domain) |
| int | cluster_size (int domain, int cluster) |
Static Public Member Functions | |
| SatRouteObject & | instance () |
| void | ns_strtok (char *addr, int *addrstr) |
Protected Member Functions | |
| void | compute_topology () |
| void | populate_routing_tables (int node=-1) |
| int | lookup (int src, int dst) |
| void * | lookup_entry (int src, int dst) |
| void | node_compute_routes (int node) |
| void | dump () |
| void | check (int) |
| void | alloc (int n) |
| void | reset (int src, int dst) |
| void | compute_routes () |
| void | insert (int src, int dst, double cost) |
| void | insert (int src, int dst, double cost, void *entry) |
| void | reset_all () |
| void | hier_check (int index) |
| void | hier_alloc (int size) |
| void | hier_init (void) |
| void | str2address (const char *const *address, int *src, int *dst) |
| void | get_address (char *target, int next_hop, int index, int d, int size, int *src) |
| void | hier_insert (int *src, int *dst, int cost) |
| void | hier_reset (int *src, int *dst) |
| void | hier_compute () |
| void | hier_compute_routes (int index, int d) |
| void | hier_print_hadj () |
| void | hier_print_route () |
Protected Attributes | |
| int | metric_delay_ |
| int | suppress_initial_computation_ |
| int | data_driven_computation_ |
| int | wiredRouting_ |
| adj_entry * | adj_ |
| route_entry * | route_ |
| int | size_ |
| int | maxnode_ |
| int ** | hadj_ |
| int ** | hroute_ |
| int * | hsize_ |
| int * | cluster_size_ |
| char *** | hconnect_ |
| int | level_ |
| int * | C_ |
| int | D_ |
| int | Cmax_ |
Static Protected Attributes | |
| SatRouteObject * | instance_ |
|
|
Definition at line 210 of file satroute.cc. References data_driven_computation_, metric_delay_, and wiredRouting_.
00210 : suppress_initial_computation_(0) 00211 { 00212 bind_bool("wiredRouting_", &wiredRouting_); 00213 bind_bool("metric_delay_", &metric_delay_); 00214 bind_bool("data_driven_computation_", &data_driven_computation_); 00215 } |
|
|
Definition at line 354 of file route.cc. References RouteLogic::adj_, adj_entry::cost, adj_entry::entry, INFINITY, and RouteLogic::size_. Referenced by RouteLogic::check().
|
|
|
Definition at line 369 of file route.cc. References RouteLogic::adj_, RouteLogic::alloc(), INDEX, and RouteLogic::size_. Referenced by RouteLogic::insert().
00370 {
00371 if (n < size_)
00372 return;
00373
00374 adj_entry* old = adj_;
00375 int osize = size_;
00376 int m = osize;
00377 if (m == 0)
00378 m = 16;
00379 while (m <= n)
00380 m <<= 1;
00381
00382 alloc(m);
00383 for (int i = 0; i < osize; ++i) {
00384 for (int j = 0; j < osize; ++j)
00385 adj_[INDEX(i, j, m)].cost =old[INDEX(i, j, osize)].cost;
00386 }
00387 size_ = m;
00388 delete[] old;
00389 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 534 of file route.cc. References RouteLogic::cluster_size_, RouteLogic::Cmax_, and INDEX. Referenced by RouteLogic::elements_in_level().
00534 {
00535 d += 1;
00536 c += 1;
00537 return (cluster_size_[INDEX(d, c, Cmax_)]);
00538 }
|
|
||||||||||||
|
Reimplemented from RouteLogic. Definition at line 217 of file satroute.cc. References RouteLogic::command(), dump(), instance_, recompute(), and suppress_initial_computation_.
00218 {
00219 if (instance_ == 0)
00220 instance_ = this;
00221 if (argc == 2) {
00222 // While suppress_initial_computation_ may seem more
00223 // appropriate as a bound variable, it is useful to
00224 // implement the setting of this variable this way so that
00225 // the ``instance_ = this'' assignment is made at the
00226 // start of simulation.
00227 if (strcmp(argv[1], "suppress_initial_computation") == 0) {
00228 suppress_initial_computation_ = 1;
00229 return (TCL_OK);
00230 }
00231 if (strcmp(argv[1], "compute_routes") == 0) {
00232 recompute();
00233 return (TCL_OK);
00234 }
00235 if (strcmp(argv[1], "dump") == 0) {
00236 printf("Dumping\n");
00237 dump();
00238 return (TCL_OK);
00239 }
00240 }
00241 return (RouteLogic::command(argc, argv));
00242 }
|
Here is the call graph for this function:

|
|
Definition at line 412 of file route.cc. References INFINITY, RouteLogic::route_, and RouteLogic::size_. Referenced by RouteLogic::command(), and recompute().
00413 {
00414 int n = size_;
00415 int* parent = new int[n];
00416 double* hopcnt = new double[n];
00417 #define ADJ(i, j) adj_[INDEX(i, j, size_)].cost
00418 #define ADJ_ENTRY(i, j) adj_[INDEX(i, j, size_)].entry
00419 #define ROUTE(i, j) route_[INDEX(i, j, size_)].next_hop
00420 #define ROUTE_ENTRY(i, j) route_[INDEX(i, j, size_)].entry
00421 delete[] route_;
00422 route_ = new route_entry[n * n];
00423 memset((char *)route_, 0, n * n * sizeof(route_[0]));
00424
00425 /* do for all the sources */
00426 int k;
00427 for (k = 1; k < n; ++k) {
00428 int v;
00429 for (v = 0; v < n; v++)
00430 parent[v] = v;
00431
00432 /* set the route for all neighbours first */
00433 for (v = 1; v < n; ++v) {
00434 if (parent[v] != k) {
00435 hopcnt[v] = ADJ(k, v);
00436 if (hopcnt[v] != INFINITY) {
00437 ROUTE(k, v) = v;
00438 ROUTE_ENTRY(k, v) = ADJ_ENTRY(k, v);
00439 }
00440 }
00441 }
00442 for (v = 1; v < n; ++v) {
00443 /*
00444 * w is the node that is the nearest to the subtree
00445 * that has been routed
00446 */
00447 int o = 0;
00448 /* XXX */
00449 hopcnt[0] = INFINITY;
00450 int w;
00451 for (w = 1; w < n; w++)
00452 if (parent[w] != k && hopcnt[w] < hopcnt[o])
00453 o = w;
00454 parent[o] = k;
00455 /*
00456 * update distance counts for the nodes that are
00457 * adjacent to o
00458 */
00459 if (o == 0)
00460 continue;
00461 for (w = 1; w < n; w++) {
00462 if (parent[w] != k &&
00463 hopcnt[o] + ADJ(o, w) < hopcnt[w]) {
00464 ROUTE(k, w) = ROUTE(k, o);
00465 ROUTE_ENTRY(k, w) =
00466 ROUTE_ENTRY(k, o);
00467 hopcnt[w] = hopcnt[o] + ADJ(o, w);
00468 }
00469 }
00470 }
00471 }
00472 /*
00473 * The route to yourself is yourself.
00474 */
00475 for (k = 1; k < n; ++k) {
00476 ROUTE(k, k) = k;
00477 ROUTE_ENTRY(k, k) = 0; // This should not matter
00478 }
00479
00480 delete[] hopcnt;
00481 delete[] parent;
00482 }
|
|
|
Definition at line 292 of file satroute.cc. References Node::address(), Phy::channel(), Phy::head(), Channel::ifhead_, insert_link(), SatNode::IsASatNode(), LINK_GSL_REPEATER, Node::linklisthead(), SatLinkHead::linkup_, metric_delay_, Phy::nextchnl(), LinkHead::nextlinkhead(), Node::nextnode(), Phy::node(), Node::nodehead_, SatLinkHead::phy_tx(), RouteLogic::reset_all(), LinkHead::type(), and wiredRouting_. Referenced by recompute(), and recompute_node().
00293 {
00294 Node *nodep;
00295 Phy *phytxp, *phyrxp, *phytxp2, *phyrxp2;
00296 SatLinkHead *slhp;
00297 Channel *channelp, *channelp2;
00298 int src, dst;
00299 double delay;
00300
00301 // wired-satellite integration
00302 if (wiredRouting_) {
00303 // There are two route objects being used
00304 // a SatRouteObject and a RouteLogic (for wired)
00305 // We need to also reset the RouteLogic one
00306 Tcl::instance().evalf("[[Simulator instance] get-routelogic] reset");
00307 }
00308 reset_all();
00309 // Compute adjacencies. Traverse linked list of nodes
00310 for (nodep=Node::nodehead_.lh_first; nodep; nodep = nodep->nextnode()) {
00311 // Cycle through the linked list of linkheads
00312 if (!SatNode::IsASatNode(nodep->address()))
00313 continue;
00314 for (slhp = (SatLinkHead*) nodep->linklisthead().lh_first; slhp;
00315 slhp = (SatLinkHead*) slhp->nextlinkhead()) {
00316 if (slhp->type() == LINK_GSL_REPEATER)
00317 continue;
00318 if (!slhp->linkup_)
00319 continue;
00320 phytxp = (Phy *) slhp->phy_tx();
00321 assert(phytxp);
00322 channelp = phytxp->channel();
00323 if (!channelp)
00324 continue; // Not currently connected to channel
00325 // Next, look for receive interfaces on this channel
00326 phyrxp = channelp->ifhead_.lh_first;
00327 for (; phyrxp; phyrxp = phyrxp->nextchnl()) {
00328 if (phyrxp == phytxp) {
00329 printf("Configuration error: a transmit interface \
00330 is a channel target\n");
00331 exit(1);
00332 }
00333 if (phyrxp->head()->type() == LINK_GSL_REPEATER) {
00334 double delay_firsthop = ((SatChannel*)
00335 channelp)->get_pdelay(phytxp->node(),
00336 phyrxp->node());
00337 if (!((SatLinkHead*)phyrxp->head())->linkup_)
00338 continue;
00339 phytxp2 = ((SatLinkHead*)phyrxp->head())->phy_tx();
00340 channelp2 = phytxp2->channel();
00341 if (!channelp2)
00342 continue; // Not currently connected to channel
00343 phyrxp2 = channelp2->ifhead_.lh_first;
00344 for (; phyrxp2; phyrxp2 = phyrxp2->nextchnl()) {
00345 if (phyrxp2 == phytxp2) {
00346 printf("Config error: a transmit interface \
00347 is a channel target\n");
00348 exit(1);
00349 }
00350 // Found an adjacency relationship.
00351 // Add this link to the RouteLogic
00352 src = phytxp->node()->address() + 1;
00353 dst = phyrxp2->node()->address() + 1;
00354 if (src == dst)
00355 continue;
00356 if (metric_delay_)
00357 delay = ((SatChannel*)
00358 channelp2)->get_pdelay(phytxp2->node(),
00359 phyrxp2->node());
00360 else {
00361 delay = 1;
00362 delay_firsthop = 0;
00363 }
00364 insert_link(src, dst, delay+delay_firsthop, (void*)slhp);
00365 }
00366 } else {
00367 // Found an adjacency relationship.
00368 // Add this link to the RouteLogic
00369 src = phytxp->node()->address() + 1;
00370 dst = phyrxp->node()->address() + 1;
00371 if (metric_delay_)
00372 delay = ((SatChannel*)
00373 channelp)->get_pdelay(phytxp->node(),
00374 phyrxp->node());
00375 else
00376 delay = 1;
00377 insert_link(src, dst, delay, (void*)slhp);
00378 }
00379 }
00380 }
00381 }
00382 //dump();
00383 }
|
Here is the call graph for this function:

|
|
Definition at line 101 of file satroute.h. References data_driven_computation_. Referenced by SatRouteAgent::forwardPacket().
00101 { return data_driven_computation_; }
|
|
|
Definition at line 531 of file route.cc. References RouteLogic::C_. Referenced by RouteLogic::elements_in_level().
00531 {
00532 return (C_[domain+1]-1);
00533 }
|
|
|
Definition at line 83 of file route.h. References RouteLogic::D_. Referenced by RouteLogic::elements_in_level().
00083 { return (D_-1); }
|
|
|
Definition at line 448 of file satroute.cc. References RouteLogic::adj_, adj_entry::cost, INFINITY, and RouteLogic::size_. Referenced by command().
|
|
||||||||||||
|
Definition at line 540 of file route.cc. References RouteLogic::cluster_size(), RouteLogic::domain_size(), and RouteLogic::domains(). Referenced by Simulator::populate_hier_classifiers().
00540 {
00541 if (level == 1)
00542 return (domains());
00543 else if (level == 2)
00544 return (domain_size(addr[0]));
00545 else if (level == 3) {
00546 return (cluster_size(addr[0], addr[1]));
00547 }
00548 return (-1);
00549 }
|
Here is the call graph for this function:

|
||||||||||||||||||||||||||||
|
Definition at line 589 of file route.cc. References RouteLogic::C_, RouteLogic::D_, and RouteLogic::hconnect_. Referenced by RouteLogic::lookup_hier().
00591 {
00592 if (next_hop <= size) {
00593 sprintf(address,"%d.%d.%d", src[0]-1, src[1]-1, next_hop-1);
00594 }
00595 else if ((next_hop > size) && (next_hop < (size + C_[d]))) {
00596 int temp = next_hop - size;
00597 int I = src[2] * (C_[d] + D_) + temp;
00598 strcpy(address, hconnect_[index][I]);
00599 }
00600 else {
00601 int temp = next_hop - size - (C_[d] - 1);
00602 int I = src[2] * (C_[d] + D_) + (C_[d] - 1 + temp);
00603 strcpy(address,hconnect_[index][I]);
00604 }
00605 }
|
|
|
Definition at line 492 of file route.cc. References RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, RouteLogic::hadj_, RouteLogic::hconnect_, RouteLogic::hroute_, RouteLogic::hsize_, and INFINITY. Referenced by RouteLogic::hier_check().
00493 {
00494 hsize_[i] = cluster_size_[i]+ Cmax_+ D_ ;
00495 hsize_[i] *= hsize_[i];
00496 hadj_[i] = new int[hsize_[i]];
00497 hroute_[i] = new int[hsize_[i]];
00498 hconnect_[i] = new char*[(Cmax_ + D_) * (cluster_size_[i]+1)];
00499 for (int n = 0; n < hsize_[i]; n++){
00500 hadj_[i][n] = INFINITY;
00501 hroute_[i][n] = INFINITY;
00502 }
00503 }
|
|
|
Definition at line 505 of file route.cc. References RouteLogic::hier_alloc(), and RouteLogic::hsize_. Referenced by RouteLogic::hier_insert().
00506 {
00507 if(hsize_[i] > 0)
00508 return;
00509 else
00510 hier_alloc(i);
00511 }
|
Here is the call graph for this function:

|
|
Definition at line 800 of file route.cc. References RouteLogic::adj_, RouteLogic::C_, RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, RouteLogic::hadj_, RouteLogic::hier_compute_routes(), RouteLogic::hroute_, INDEX, and RouteLogic::route_. Referenced by RouteLogic::command().
00801 {
00802 int i, j, k, m, n;
00803 for (j=1; j < D_; j++)
00804 for (k=1; k < C_[j]; k++) {
00805 i = INDEX(j, k, Cmax_);
00806 int s = (cluster_size_[i] + C_[j] + D_);
00807 adj_ = new adj_entry[(s * s)];
00808 memset((char *)adj_, 0, s * s * sizeof(adj_[0]));
00809 for (n=0; n < s; n++)
00810 for(m=0; m < s; m++)
00811 adj_[INDEX(n, m, s)].cost = hadj_[i][INDEX(n, m, s)];
00812 hier_compute_routes(i, j);
00813
00814 for (n=0; n < s; n++)
00815 for(m=0; m < s; m++)
00816 hroute_[i][INDEX(n, m, s)] = route_[INDEX(n, m, s)].next_hop;
00817 delete [] adj_;
00818 }
00819 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 705 of file route.cc. References RouteLogic::C_, RouteLogic::cluster_size_, RouteLogic::D_, INFINITY, and RouteLogic::route_. Referenced by RouteLogic::hier_compute().
00706 {
00707 int size = (cluster_size_[i] + C_[j] + D_);
00708 int n = size ;
00709 double* hopcnt = new double[n];
00710 #define HADJ(i, j) adj_[INDEX(i, j, size)].cost
00711 #define HROUTE(i, j) route_[INDEX(i, j, size)].next_hop
00712 delete[] route_;
00713 route_ = new route_entry[n * n];
00714 int* parent = new int[n];
00715 memset((char *)route_, 0, n * n * sizeof(route_[0]));
00716
00717 /* do for all the sources */
00718 int k;
00719 for (k = 1; k < n; ++k) {
00720 int v;
00721 for (v = 0; v < n; v++)
00722 parent[v] = v;
00723
00724 /* set the route for all neighbours first */
00725 for (v = 1; v < n; ++v) {
00726 if (parent[v] != k) {
00727 hopcnt[v] = HADJ(k, v);
00728 if (hopcnt[v] != INFINITY)
00729 HROUTE(k, v) = v;
00730 }
00731 }
00732 for (v = 1; v < n; ++v) {
00733 /*
00734 * w is the node that is the nearest to the subtree
00735 * that has been routed
00736 */
00737 int o = 0;
00738 /* XXX */
00739 hopcnt[0] = INFINITY;
00740 int w;
00741 for (w = 1; w < n; w++)
00742 if (parent[w] != k && hopcnt[w] < hopcnt[o])
00743 o = w;
00744 parent[o] = k;
00745 /*
00746 * update distance counts for the nodes that are
00747 * adjacent to o
00748 */
00749 if (o == 0)
00750 continue;
00751 for (w = 1; w < n; w++) {
00752 if (parent[w] != k &&
00753 hopcnt[o] + HADJ(o, w) < hopcnt[w]) {
00754 HROUTE(k, w) = HROUTE(k, o);
00755 hopcnt[w] = hopcnt[o] + HADJ(o, w);
00756 }
00757 }
00758 }
00759 }
00760 /*
00761 * The route to yourself is yourself.
00762 */
00763 for (k = 1; k < n; ++k)
00764 HROUTE(k, k) = k;
00765
00766 delete[] hopcnt;
00767 delete[] parent;
00768 }
|
|
|
Definition at line 513 of file route.cc. References RouteLogic::C_, RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, RouteLogic::hadj_, RouteLogic::hconnect_, RouteLogic::hroute_, and RouteLogic::hsize_. Referenced by RouteLogic::command().
00514 {
00515 int i;
00516
00517 for (i = 1; i < D_; i++) {
00518 Cmax_ = C_[i] > Cmax_ ? C_[i]: Cmax_;
00519 }
00520 int arr_size = Cmax_ * D_ ;
00521 cluster_size_ = new int[arr_size];
00522 hsize_ = new int[arr_size];
00523 for (i = 0; i < arr_size; i++)
00524 hsize_[i] = 0;
00525 hadj_ = new int*[arr_size];
00526 hroute_ = new int*[arr_size];
00527 hconnect_ = new char**[arr_size];
00528 }
|
|
||||||||||||||||
|
Definition at line 640 of file route.cc. References RouteLogic::C_, C_C_INDEX, C_D_INDEX, RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, D_D_INDEX, RouteLogic::hadj_, RouteLogic::hconnect_, RouteLogic::hier_check(), INDEX, N_C_INDEX, N_D_INDEX, N_N_INDEX, and SMALL_LEN. Referenced by RouteLogic::command().
00641 {
00642 int X1 = src_addr[0];
00643 int Y1 = src_addr[1];
00644 int Z1 = src_addr[2];
00645 int X2 = dst_addr[0];
00646 int Y2 = dst_addr[1];
00647 int Z2 = dst_addr[2];
00648 int n, i;
00649
00650 if ( X1 == X2)
00651 if (Y1 == Y2){
00652 /*
00653 * For the same domain & cluster
00654 */
00655 i = INDEX(X1, Y1, Cmax_);
00656 n = cluster_size_[i];
00657 hier_check(i);
00658 hadj_[i][N_N_INDEX(Z1, Z2, n, C_[X1], D_)] = cost;
00659 } else {
00660 /*
00661 * For the same domain but diff clusters
00662 */
00663 for (int y=1; y < C_[X1]; y++) { /* insert cluster connectivity */
00664 i = INDEX(X1, y, Cmax_);
00665 n = cluster_size_[i];
00666 hier_check(i);
00667 hadj_[i][C_C_INDEX(Y1, Y2, n, C_[X1], D_)] = cost;
00668
00669 if (y == Y1) { /* insert node conn. */
00670 hadj_[i][N_C_INDEX(Z1, Y2, n, C_[X1], D_)] = cost;
00671 int I = Z1 * (C_[X1]+ D_) + Y2;
00672 hconnect_[i][I] = new char[SMALL_LEN];
00673 sprintf(hconnect_[i][I],"%d.%d.%d",X2-1,Y2-1,Z2-1);
00674 }
00675 }
00676 }
00677 else {
00678 /*
00679 * For different domains
00680 */
00681 for (int x=1; x < D_; x++) { /* inset domain connectivity */
00682 for (int y=1; y < C_[x]; y++) {
00683 i = INDEX(x, y, Cmax_);
00684 n = cluster_size_[i];
00685 hier_check(i);
00686 hadj_[i][D_D_INDEX(X1, X2, n, C_[x], D_)] = cost;
00687 }
00688 }
00689 for (int y=1; y < C_[X1]; y++) { /* insert cluster connectivity */
00690 i = INDEX(X1, y, Cmax_);
00691 n = cluster_size_[i];
00692 hier_check(i);
00693 hadj_[i][C_D_INDEX(Y1, X2, n, C_[X1], D_)] = cost;
00694 }
00695 /* insert node connectivity */
00696 i = INDEX(X1, Y1, Cmax_);
00697 n = cluster_size_[i];
00698 hadj_[i][N_D_INDEX(Z1, X2, n, C_[X1], D_)] = cost;
00699 int I = Z1 * (C_[X1] + D_) + (C_[X1] - 1 + X2);
00700 hconnect_[i][I] = new char[SMALL_LEN];
00701 sprintf(hconnect_[i][I],"%d.%d.%d",X2-1,Y2-1,Z2-1);
00702 }
00703 }
|
Here is the call graph for this function:

|
|
Definition at line 771 of file route.cc. References RouteLogic::C_, RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, RouteLogic::hadj_, INDEX, and INFINITY. Referenced by RouteLogic::command().
00771 {
00772 int i, j, k;
00773
00774 for (j=1; j < D_; j++)
00775 for (k=1; k < C_[j]; k++) {
00776 i = INDEX(j, k, Cmax_);
00777 int s = (cluster_size_[i] + C_[j] + D_);
00778 printf("ADJ MATRIX[%d] for cluster %d.%d :\n",i,j,k);
00779 int temp = 1;
00780 printf(" ");
00781 while(temp < s){
00782 printf(" %d",temp);
00783 temp++;
00784 }
00785 printf("\n");
00786 for(int n=1; n < s;n++){
00787 printf("%d ",n);
00788 for(int m=1;m < s;m++){
00789 if(hadj_[i][INDEX(n,m,s)] == INFINITY)
00790 printf("~ ");
00791 else
00792 printf("%d ",hadj_[i][INDEX(n,m,s)]);
00793 }
00794 printf("\n");
00795 }
00796 printf("\n\n");
00797 }
00798 }
|
|
|
Definition at line 824 of file route.cc. References RouteLogic::C_, RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, RouteLogic::hroute_, and INDEX. Referenced by RouteLogic::command().
00825 {
00826 for (int j=1; j < D_; j++)
00827 for (int k=1; k < C_[j]; k++) {
00828 int i = INDEX(j, k, Cmax_);
00829 int s = (cluster_size_[i]+C_[j]+D_);
00830 printf("ROUTE_TABLE[%d] for cluster %d.%d :\n",i,j,k);
00831 int temp = 1;
00832 printf(" ");
00833 while(temp < s){
00834 printf(" %d",temp);
00835 temp++;
00836 }
00837 printf("\n");
00838 for(int n=1; n < s; n++){
00839 printf("%d ",n);
00840 for(int m=1; m < s; m++)
00841 printf("%d ",hroute_[i][INDEX(n, m, s)]);
00842 printf("\n");
00843 }
00844 printf("\n\n");
00845 }
00846 }
|
|
||||||||||||
|
Definition at line 607 of file route.cc. References RouteLogic::C_, C_C_INDEX, C_D_INDEX, RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, D_D_INDEX, RouteLogic::hadj_, INDEX, INFINITY, N_C_INDEX, N_D_INDEX, and N_N_INDEX. Referenced by RouteLogic::command().
00608 {
00609 int i, d, n;
00610 d = src[0];
00611 if (src[0] == dst[0])
00612 if (src[1] == dst[1]) {
00613 i = INDEX(src[0], src[1], Cmax_);
00614 n = cluster_size_[i];
00615 hadj_[i][N_N_INDEX(src[2], dst[2], n, C_[d], D_)] = INFINITY;
00616 } else {
00617 for (int y=1; y < C_[d]; y++) {
00618 i = INDEX(src[0], y, Cmax_);
00619 n = cluster_size_[i];
00620 hadj_[i][C_C_INDEX(src[1], dst[1], n, C_[d], D_)] = INFINITY;
00621 if (y == src[1])
00622 hadj_[i][N_C_INDEX(src[2], dst[1], n, C_[d], D_)] = INFINITY;
00623 }
00624 }
00625 else {
00626 for (int x=1; x < D_; x++)
00627 for (int y=1; y < C_[x]; y++) {
00628 i = INDEX(x, y, Cmax_);
00629 n = cluster_size_[i];
00630 hadj_[i][D_D_INDEX(src[0], dst[0], n, C_[x], D_)] = INFINITY;
00631 if ( x == src[0] ){
00632 hadj_[i][C_D_INDEX(src[1], dst[0], n, C_[x], D_)] = INFINITY;
00633 if (y == src[1])
00634 hadj_[i][N_D_INDEX(src[2], dst[0], n, C_[x], D_)] = INFINITY;
00635 }
00636 }
00637 }
00638 }
|
|
||||||||||||||||||||
|
Definition at line 397 of file route.cc. References RouteLogic::adj_, RouteLogic::check(), INDEX, and RouteLogic::size_.
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 391 of file route.cc. References RouteLogic::adj_, RouteLogic::check(), INDEX, and RouteLogic::size_. Referenced by RouteLogic::command(), and insert_link().
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 254 of file satroute.cc. References RouteLogic::insert(), SatLinkHead::queue(), and wiredRouting_.
00255 {
00256 SatLinkHead* slhp = (SatLinkHead*) entry;
00257 if (wiredRouting_) {
00258 // Here we do an upcall to an instproc in ns-sat.tcl
00259 // that populates the link_(:) array
00260 Tcl::instance().evalf("[Simulator instance] sat_link_up %d %d %f %s %s", (src - 1), (dst - 1), cost, slhp->name(), slhp->queue()->name());
00261 } else
00262 insert(src, dst, cost, entry); // base class insert()
00263 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 245 of file satroute.cc. References RouteLogic::insert(), and wiredRouting_. Referenced by compute_topology().
00246 {
00247 if (wiredRouting_) {
00248 Tcl::instance().evalf("[Simulator instance] sat_link_up %d %d %f", (src - 1), (dst - 1), cost);
00249 } else
00250 insert(src, dst, cost);
00251 }
|
Here is the call graph for this function:

|
|
Definition at line 95 of file satroute.h. Referenced by SatRouteAgent::forwardPacket(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), and SatLL::sendDown().
00095 {
00096 return (*instance_); // general access to route object
00097 }
|
|
||||||||||||
|
Definition at line 427 of file satroute.cc. References INDEX, RouteLogic::route_, and RouteLogic::size_. Referenced by populate_routing_tables().
|
|
||||||||||||
|
Definition at line 437 of file satroute.cc. References INDEX, RouteLogic::route_, and RouteLogic::size_. Referenced by populate_routing_tables().
|
|
||||||||||||
|
Definition at line 225 of file route.cc. References INDEX, RouteLogic::route_, and RouteLogic::size_.
00225 {
00226 int src = sid+1;
00227 int dst = did+1;
00228 if (route_ == 0) {
00229 // routes are computed only after the simulator is running
00230 // ($ns run).
00231 printf("routes not yet computed\n");
00232 return (-1);
00233 }
00234 if (src >= size_ || dst >= size_) {
00235 printf("node out of range\n");
00236 return (-2);
00237 }
00238 return route_[INDEX(src, dst, size_)].next_hop - 1;
00239 }
|
|
||||||||||||||||
|
Reimplemented in RouteLogicAlgo. Definition at line 204 of file route.cc. References INDEX, RouteLogic::route_, and RouteLogic::size_. Referenced by RouteLogic::command(), LoggingDataStruct::log(), LoggingDataStruct::LoggingDataStruct(), LanRouter::next_hop(), Simulator::populate_flat_classifiers(), VirtualClassifier::recv(), and SatLL::sendDown().
00204 {
00205 Tcl& tcl = Tcl::instance();
00206 int src = atoi(asrc) + 1;
00207 int dst = atoi(adst) + 1;
00208
00209 if (route_ == 0) {
00210 // routes are computed only after the simulator is running
00211 // ($ns run).
00212 tcl.result("routes not yet computed");
00213 return (TCL_ERROR);
00214 }
00215 if (src >= size_ || dst >= size_) {
00216 tcl.result("node out of range");
00217 return (TCL_ERROR);
00218 }
00219 result = route_[INDEX(src, dst, size_)].next_hop - 1;
00220 return TCL_OK;
00221 }
|
|
||||||||||||||||
|
Definition at line 242 of file route.cc. References RouteLogic::C_, RouteLogic::cluster_size_, RouteLogic::Cmax_, RouteLogic::D_, RouteLogic::get_address(), RouteLogic::hroute_, RouteLogic::hsize_, INDEX, Address::instance(), RouteLogic::level_, N_C_INDEX, N_D_INDEX, N_N_INDEX, RouteLogic::ns_strtok(), SMALL_LEN, and Address::str2addr(). Referenced by RouteLogic::command(), LanRouter::next_hop(), and Simulator::populate_hier_classifiers().
00242 {
00243 int i;
00244 int src[SMALL_LEN], dst[SMALL_LEN];
00245 Tcl& tcl = Tcl::instance();
00246
00247 if ( hroute_ == 0) {
00248 tcl.result("Required Hier_data not sent");
00249 return TCL_ERROR;
00250 }
00251
00252 ns_strtok(asrc, src);
00253 ns_strtok(adst, dst);
00254
00255 for (i=0; i < level_; i++)
00256 if (src[i] <= 0) {
00257 tcl.result("negative src node number");
00258 return TCL_ERROR;
00259 }
00260 if (dst[0] <= 0) {
00261 tcl.result("negative dst domain number");
00262 return TCL_ERROR;
00263 }
00264
00265 int d = src[0];
00266 int index = INDEX(src[0], src[1], Cmax_);
00267 int size = cluster_size_[index];
00268
00269 if (hsize_[index] == 0) {
00270 tcl.result("Routes not computed");
00271 return TCL_ERROR;
00272 }
00273 if ((src[0] < D_) || (dst[0] < D_)) {
00274 if((src[1] < C_[d]) || (dst[1] < C_[dst[0]]))
00275 if((src[2] <= size) ||
00276 (dst[2]<=cluster_size_[INDEX(dst[0],dst[1],Cmax_)]))
00277 ;
00278 } else {
00279 tcl.result("node out of range");
00280 return TCL_ERROR;
00281 }
00282 int next_hop = 0;
00283 /* if node-domain lookup */
00284 if (((dst[1] <= 0) && (dst[2] <= 0)) ||
00285 (src[0] != dst[0])){
00286 next_hop = hroute_[index][N_D_INDEX(src[2], dst[0], size, C_[d], D_)];
00287 }
00288 /* if node-cluster lookup */
00289 else if ((dst[2] <= 0) || (src[1] != dst[1])) {
00290 next_hop = hroute_[index][N_C_INDEX(src[2], dst[1], size, C_[d], D_)];
00291 }
00292 /* if node-node lookup */
00293 else {
00294 next_hop = hroute_[index][N_N_INDEX(src[2], dst[2], size, C_[d], D_)];
00295 }
00296
00297 char target[SMALL_LEN];
00298 if (next_hop > 0) {
00299 get_address(target, next_hop, index, d, size, src);
00300 tcl.result(target);
00301 result= Address::instance().str2addr(target);
00302 } else {
00303 tcl.result("-1");
00304 result = -1;
00305 }
00306 return TCL_OK;
00307 }
|
Here is the call graph for this function:

|
|
Definition at line 460 of file satroute.cc. References INFINITY, RouteLogic::route_, and RouteLogic::size_. Referenced by recompute_node().
00461 {
00462 int n = size_;
00463 int* parent = new int[n];
00464 double* hopcnt = new double[n];
00465 #define ADJ(i, j) adj_[INDEX(i, j, size_)].cost
00466 #define ADJ_ENTRY(i, j) adj_[INDEX(i, j, size_)].entry
00467 #define ROUTE(i, j) route_[INDEX(i, j, size_)].next_hop
00468 #define ROUTE_ENTRY(i, j) route_[INDEX(i, j, size_)].entry
00469 delete[] route_;
00470 route_ = new route_entry[n * n];
00471 memset((char *)route_, 0, n * n * sizeof(route_[0]));
00472 /* compute routes only for node "node" */
00473 int k = node + 1; // must add one to get the right offset in tables
00474 int v;
00475 for (v = 0; v < n; v++)
00476 parent[v] = v;
00477
00478 /* set the route for all neighbours first */
00479 for (v = 1; v < n; ++v) {
00480 if (parent[v] != k) {
00481 hopcnt[v] = ADJ(k, v);
00482 if (hopcnt[v] != INFINITY) {
00483 ROUTE(k, v) = v;
00484 ROUTE_ENTRY(k, v) = ADJ_ENTRY(k, v);
00485 }
00486 }
00487 }
00488 for (v = 1; v < n; ++v) {
00489 /*
00490 * w is the node that is the nearest to the subtree
00491 * that has been routed
00492 */
00493 int o = 0;
00494 /* XXX */
00495 hopcnt[0] = INFINITY;
00496 int w;
00497 for (w = 1; w < n; w++)
00498 if (parent[w] != k && hopcnt[w] < hopcnt[o])
00499 o = w;
00500 parent[o] = k;
00501 /*
00502 * update distance counts for the nodes that are
00503 * adjacent to o
00504 */
00505 if (o == 0)
00506 continue;
00507 for (w = 1; w < n; w++) {
00508 if (parent[w] != k &&
00509 hopcnt[o] + ADJ(o, w) < hopcnt[w]) {
00510 ROUTE(k, w) = ROUTE(k, o);
00511 ROUTE_ENTRY(k, w) =
00512 ROUTE_ENTRY(k, o);
00513 hopcnt[w] = hopcnt[o] + ADJ(o, w);
00514 }
00515 }
00516 }
00517 /*
00518 * The route to yourself is yourself.
00519 */
00520 ROUTE(k, k) = k;
00521 ROUTE_ENTRY(k, k) = 0; // This should not matter
00522
00523 delete[] hopcnt;
00524 delete[] parent;
00525 }
|
|
||||||||||||
|
Definition at line 563 of file route.cc. References SMALL_LEN. Referenced by HierClassifier::do_install(), RouteLogic::lookup_hier(), Address::str2addr(), and RouteLogic::str2address().
00564 {
00565 int i;
00566 char tmpstr[SMALL_LEN];
00567 char *next, *index;
00568
00569 i = 0;
00570 strcpy(tmpstr, addr);
00571 next = tmpstr;
00572 while(*next){
00573 index = strstr(next, ".");
00574 if (index != NULL){
00575 next[index - next] = '\0';
00576 addrstr[i] = atoi(next) + 1;
00577 next = index + 1;
00578 i++;
00579 }
00580 else {
00581 if (*next != '\0') //damn that ending point
00582 addrstr[i] = atoi(next) + 1;
00583 break;
00584 }
00585 }
00586 }
|
|
|
Definition at line 385 of file satroute.cc. References Node::address(), SatRouteAgent::clear_slots(), SatNode::IsASatNode(), lookup(), lookup_entry(), Node::nextnode(), Node::nodehead_, NOW, SatNode::ragent(), and wiredRouting_. Referenced by recompute(), and recompute_node().
00386 {
00387 SatNode *snodep = (SatNode*) Node::nodehead_.lh_first;
00388 SatNode *snodep2;
00389 int next_hop, src, dst;
00390 NsObject *target;
00391
00392 if (wiredRouting_) {
00393 Tcl::instance().evalf("[Simulator instance] populate-flat-classifiers [Node set nn_]");
00394 return;
00395 }
00396 for (; snodep; snodep = (SatNode*) snodep->nextnode()) {
00397 if (!SatNode::IsASatNode(snodep->address()))
00398 continue;
00399 // First, clear slots of the current routing table
00400 if (snodep->ragent())
00401 snodep->ragent()->clear_slots();
00402 src = snodep->address();
00403 if (node != -1 && node != src)
00404 continue;
00405 snodep2 = (SatNode*) Node::nodehead_.lh_first;
00406 for (; snodep2; snodep2 = (SatNode*) snodep2->nextnode()) {
00407 if (!SatNode::IsASatNode(snodep->address()))
00408 continue;
00409 dst = snodep2->address();
00410 next_hop = lookup(src, dst);
00411 if (next_hop != -1 && src != dst) {
00412 // Here need to insert target into slot table
00413 target = (NsObject*) lookup_entry(src, dst);
00414 if (target == 0) {
00415 printf("Error, routelogic target ");
00416 printf("not populated %f\n", NOW);
00417 exit(1);
00418 }
00419 ((SatNode*)snodep)->ragent()->install(dst,
00420 next_hop, target);
00421 }
00422 }
00423 }
00424
00425 }
|
Here is the call graph for this function:

|
|
Definition at line 271 of file satroute.cc. References RouteLogic::compute_routes(), compute_topology(), data_driven_computation_, NOW, populate_routing_tables(), suppress_initial_computation_, and wiredRouting_. Referenced by command(), SatLinkHandoffMgr::handoff(), and TermLinkHandoffMgr::handoff().
00272 {
00273 // For very large topologies (e.g., Teledesic), we don't want to
00274 // waste a lot of time computing routes at the beginning of the
00275 // simulation. This first if() clause suppresses route computations.
00276 if (data_driven_computation_ ||
00277 (NOW < 0.001 && suppress_initial_computation_) )
00278 return;
00279 else {
00280 compute_topology();
00281 if (wiredRouting_) {
00282 Tcl::instance().evalf("[Simulator instance] compute-flat-routes");
00283 } else {
00284 compute_routes(); // base class function
00285 }
00286 populate_routing_tables();
00287 }
00288 }
|
Here is the call graph for this function:

|
|
Definition at line 265 of file satroute.cc. References compute_topology(), node_compute_routes(), and populate_routing_tables(). Referenced by SatRouteAgent::forwardPacket().
00266 {
00267 compute_topology();
00268 node_compute_routes(node);
00269 populate_routing_tables(node);
00270 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 405 of file route.cc. References RouteLogic::adj_, INDEX, INFINITY, and RouteLogic::size_. Referenced by RouteLogic::command().
|
|
|
Definition at line 59 of file route.cc. References RouteLogic::adj_, RouteLogic::route_, and RouteLogic::size_. Referenced by RouteLogic::command(), and compute_topology().
|
|
||||||||||||||||
|
Definition at line 551 of file route.cc. References RouteLogic::ns_strtok(), and SMALL_LEN. Referenced by RouteLogic::command().
|
Here is the call graph for this function:

|
|
Definition at line 104 of file satroute.h. References wiredRouting_. Referenced by SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), and SatLL::sendDown().
00104 { return wiredRouting_;}
|
|
|
Definition at line 93 of file route.h. Referenced by RouteLogic::alloc(), RouteLogic::check(), RouteLogic::command(), dump(), RouteLogic::hier_compute(), RouteLogic::insert(), RouteLogic::reset(), RouteLogic::reset_all(), RouteLogic::RouteLogic(), and RouteLogic::~RouteLogic(). |
|
|
|
|
|
|
Definition at line 118 of file satroute.h. Referenced by data_driven_computation(), recompute(), and SatRouteObject(). |
|
|
Definition at line 116 of file route.h. Referenced by RouteLogic::command(), RouteLogic::hier_alloc(), RouteLogic::hier_compute(), RouteLogic::hier_init(), RouteLogic::hier_insert(), RouteLogic::hier_print_hadj(), RouteLogic::hier_reset(), RouteLogic::RouteLogic(), and RouteLogic::~RouteLogic(). |
|
|
Definition at line 120 of file route.h. Referenced by RouteLogic::get_address(), RouteLogic::hier_alloc(), RouteLogic::hier_init(), RouteLogic::hier_insert(), RouteLogic::RouteLogic(), and RouteLogic::~RouteLogic(). |
|
|
Definition at line 117 of file route.h. Referenced by RouteLogic::hier_alloc(), RouteLogic::hier_compute(), RouteLogic::hier_init(), RouteLogic::hier_print_route(), RouteLogic::lookup_hier(), RouteLogic::RouteLogic(), and RouteLogic::~RouteLogic(). |
|
|
Definition at line 118 of file route.h. Referenced by RouteLogic::hier_alloc(), RouteLogic::hier_check(), RouteLogic::hier_init(), RouteLogic::lookup_hier(), RouteLogic::RouteLogic(), and RouteLogic::~RouteLogic(). |
|
|
Definition at line 208 of file satroute.cc. Referenced by command(). |
|
|
Definition at line 121 of file route.h. Referenced by RouteLogic::command(), RouteLogic::lookup_hier(), and RouteLogic::RouteLogic(). |
|
|
|
|
|
Definition at line 116 of file satroute.h. Referenced by compute_topology(), and SatRouteObject(). |
|
|
Definition at line 94 of file route.h. Referenced by RouteLogic::compute_routes(), RouteLogic::hier_compute(), RouteLogic::hier_compute_routes(), lookup(), lookup_entry(), RouteLogic::lookup_flat(), node_compute_routes(), RouteLogic::reset_all(), RouteLogic::RouteLogic(), and RouteLogic::~RouteLogic(). |
|
|
Definition at line 97 of file route.h. Referenced by RouteLogic::alloc(), RouteLogic::check(), RouteLogic::compute_routes(), dump(), RouteLogic::insert(), lookup(), lookup_entry(), RouteLogic::lookup_flat(), node_compute_routes(), RouteLogic::reset(), RouteLogic::reset_all(), and RouteLogic::RouteLogic(). |
|
|
Definition at line 117 of file satroute.h. Referenced by command(), and recompute(). |
|
|
Definition at line 119 of file satroute.h. Referenced by compute_topology(), insert_link(), populate_routing_tables(), recompute(), SatRouteObject(), and wiredRouting(). |
1.3.3