Multi Path Routing Calculation Done
diff --git a/macbook.conf b/macbook.conf
index 402a0ad..e780f00 100644
--- a/macbook.conf
+++ b/macbook.conf
@@ -3,6 +3,7 @@
router-name /ndn/memphis.edu/netlab/macbook/
ccnneighbor /ndn/memphis.edu/dunhall/castor face14
ccnneighbor /ndn/memphis.edu/joneshall/mira/ face11
+ccnneighbor /ndn/memphis.edu/netlab/pollux face30
ccnname /ndn/memphis.edu/patterson
ccnname /ndn/memphis.edu/houston/
#------lsdb-synch-interval-----
diff --git a/nlsr_adl.c b/nlsr_adl.c
index 087f9c4..1184cb6 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -381,7 +381,6 @@
int
is_adj_lsa_build(void)
{
- //print_adjacent_from_adl();
int ret=0;
int nbr_count=0;
@@ -404,7 +403,6 @@
}
else if ( (nbr->status == 0) && (nbr->info_interest_timed_out >= nlsr->interest_retry || nbr->lsdb_interest_timed_out >= nlsr->interest_retry))
{
- //printf(" In Status: 0 info_interest_timed_out= %d and lsdb_interest_timed_out= %d\n",nbr->info_interest_timed_out,nbr->lsdb_interest_timed_out);
nbr_count++;
}
hashtb_next(e);
diff --git a/nlsr_route.c b/nlsr_route.c
index 1d8bc42..fcdea08 100644
--- a/nlsr_route.c
+++ b/nlsr_route.c
@@ -72,13 +72,32 @@
long int *parent=(long int *)malloc(map_element * sizeof(long int));
long int *dist=(long int *)malloc(map_element * sizeof(long int));
- calculate_path(adj_matrix,parent,dist, map_element, source);
+ int num_link=get_no_link_from_adj_matrix(adj_matrix, map_element ,source);
- print_all_path_from_source(parent,source);
+ if ( num_link == 0 )
+ {
+ calculate_path(adj_matrix,parent,dist, map_element, source);
+ print_all_path_from_source(parent,source);
+ print_all_next_hop(parent,source);
+ update_routing_table_with_new_route(parent, dist,source);
+ }
+ else
+ {
+ long int *links=(long int *)malloc(num_link*sizeof(long int));
+ long int *link_costs=(long int *)malloc(num_link*sizeof(long int));
+ get_links_from_adj_matrix(adj_matrix, map_element , links, link_costs, source);
+ for ( i=0 ; i < num_link; i++)
+ {
+ adjust_adj_matrix(adj_matrix, map_element,source,links[i],link_costs[i]);
+ calculate_path(adj_matrix,parent,dist, map_element, source);
+ print_all_path_from_source(parent,source);
+ print_all_next_hop(parent,source);
+ update_routing_table_with_new_route(parent, dist,source);
+ }
- print_all_next_hop(parent,source);
-
- update_routing_table_with_new_route(parent, dist,source);
+ free(links);
+ free(link_costs);
+ }
update_npt_with_new_route();
@@ -119,40 +138,42 @@
Q[i]=i;
}
- dist[S]=0;
- sort_queue_by_distance(Q,dist,head,V);
-
- while (head < V )
+ if ( S != NO_MAPPING_NUM )
{
- u=Q[head];
- if(dist[u] == INF_DISTANCE)
- {
- break;
- }
+ dist[S]=0;
+ sort_queue_by_distance(Q,dist,head,V);
- for(v=0 ; v <V; v++)
+ while (head < V )
{
- if( adj_matrix[u][v] > 0 ) //
+ u=Q[head];
+ if(dist[u] == INF_DISTANCE)
{
- if ( is_not_explored(Q,v,head+1,V) )
+ break;
+ }
+
+ for(v=0 ; v <V; v++)
+ {
+ if( adj_matrix[u][v] > 0 ) //
{
-
- if( dist[u] + adj_matrix[u][v] < dist[v])
+ if ( is_not_explored(Q,v,head+1,V) )
{
- dist[v]=dist[u] + adj_matrix[u][v] ;
- parent[v]=u;
- }
+
+ if( dist[u] + adj_matrix[u][v] < dist[v])
+ {
+ dist[v]=dist[u] + adj_matrix[u][v] ;
+ parent[v]=u;
+ }
+
+ }
}
}
+ head++;
+ sort_queue_by_distance(Q,dist,head,V);
}
-
- head++;
- sort_queue_by_distance(Q,dist,head,V);
}
-
free(Q);
//free(dist);
}
@@ -169,17 +190,19 @@
hashtb_start(nlsr->map, e);
map_element=hashtb_n(nlsr->map);
- for(i=0;i<map_element;i++)
+ if ( source != NO_MAPPING_NUM)
{
- me=e->data;
- if(me->mapping != source)
+ for(i=0;i<map_element;i++)
{
- print_path(parent,(long int)me->mapping);
- printf("\n");
+ me=e->data;
+ if(me->mapping != source)
+ {
+ print_path(parent,(long int)me->mapping);
+ printf("\n");
+ }
+ hashtb_next(e);
}
- hashtb_next(e);
}
-
hashtb_end(e);
}
@@ -337,6 +360,8 @@
hashtb_start(nlsr->lsdb->adj_lsdb, e);
adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);
+ add_map_entry(nlsr->router_name);
+
for(i=0;i<adj_lsdb_element;i++)
{
adj_lsa=e->data;
@@ -623,6 +648,55 @@
int
+get_no_link_from_adj_matrix(int **adj_matrix,long int V, long int S)
+{
+ int no_link=0;
+ int i;
+
+ for(i=0;i<V;i++)
+ {
+ if ( adj_matrix[S][i] > 0 )
+ {
+ no_link++;
+ }
+ }
+ return no_link;
+}
+
+void
+get_links_from_adj_matrix(int **adj_matrix, long int V ,long int *links, long int *link_costs,long int S)
+{
+ int i,j;
+ j=0;
+ for (i=0; i <V; i++)
+ {
+ if ( adj_matrix[S][i] > 0 )
+ {
+ links[j]=i;
+ link_costs[j]=adj_matrix[S][i];
+ j++;
+ }
+ }
+}
+
+void adjust_adj_matrix(int **adj_matrix, long int V, long int S, long int link,long int link_cost)
+{
+ int i;
+ for ( i = 0; i < V; i++ )
+ {
+ if ( i == link )
+ {
+ adj_matrix[S][i]=link_cost;
+ }
+ else
+ {
+ adj_matrix[S][i]=0;
+ }
+ }
+
+}
+
+int
get_number_of_next_hop(char *dest_router)
{
struct routing_table_entry *rte;
diff --git a/nlsr_route.h b/nlsr_route.h
index 021429d..cd023e5 100644
--- a/nlsr_route.h
+++ b/nlsr_route.h
@@ -45,6 +45,9 @@
void add_rev_map_entry(long int mapping_number, char *router);
void print_rev_map(void);
char * get_router_from_rev_map(long int mapping_number);
+int get_no_link_from_adj_matrix(int **adj_matrix,long int V, long int S);
+void get_links_from_adj_matrix(int **adj_matrix, long int V ,long int *links, long int *link_costs,long int S);
+void adjust_adj_matrix(int **adj_matrix, long int V, long int S, long int link,long int link_cost);
/* Routing Table Relates function */