Max Faces Per Prefix behavior, LSA Refresh Time and Router Dead Interval Time
diff --git a/nlsr-sync-0.0/macbook.conf b/nlsr-sync-0.0/macbook.conf
index d29553f..18f9537 100755
--- a/nlsr-sync-0.0/macbook.conf
+++ b/nlsr-sync-0.0/macbook.conf
@@ -4,6 +4,7 @@
ccnneighbor /ndn/memphis.edu/cs/maia
ccnneighbor /ndn/memphis.edu/cs/mira
ccnneighbor /ndn/memphis.edu/cs/castor
+ccnneighbor /ndn/router/pollux 141.225.11.132
ccnname /ndn/memphis.edu/macbook/patterson
ccnname /ndn/memphis.edu/macbook/houston/
#------lsdb-synch-interval-----
@@ -16,7 +17,7 @@
debug on
hyperbolic-routing on
hyperbolic-cordinate 1234.0 0.875
-tunnel-type tcp
+tunnel-type udp
topo-prefix /ndn/routing/nlsr/
slice-prefix /ndn/routing/nlsr/LSA
diff --git a/nlsr-sync-0.0/nlsr.c b/nlsr-sync-0.0/nlsr.c
index 14244af..9ba67c6 100755
--- a/nlsr-sync-0.0/nlsr.c
+++ b/nlsr-sync-0.0/nlsr.c
@@ -159,7 +159,11 @@
char *rem;
const char *sep=" \t\n";
char *rtr_name;
+ char *nbr_ip_addr;
+ int is_ip_configured=0;
//char *face;
+ char *ip_addr=(char *)malloc(13);
+ memset(ip_addr,0,13);
rtr_name=strtok_r(command,sep,&rem);
if(rtr_name==NULL)
@@ -167,47 +171,39 @@
printf(" Wrong Command Format ( ccnneighbor router_name faceX)\n");
return;
}
-
- /*face=strtok_r(NULL,sep,&rem);
- if(face==NULL)
- {
- printf(" Wrong Command Format ( ccnneighbor router_name faceX)\n");
- return;
- }
-
- printf("Router: %s face: %s\n",rtr_name,face);
- int face_id;
- int res;
- res=sscanf(face,"face%d",&face_id);
-
- if(res != 1 )
- {
- printf(" Wrong Command Format ( ccnneighbor router_name faceX) where X is integer\n");
- return;
- }*/
-
if ( rtr_name[strlen(rtr_name)-1] == '/' )
{
rtr_name[strlen(rtr_name)-1]='\0';
}
+
+ if (rem != NULL )
+ {
+ nbr_ip_addr=strtok_r(NULL,sep,&rem);
+ is_ip_configured=1;
+ }
struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
nbr->name=(char *)malloc(strlen(rtr_name)+1);
memset(nbr->name,0,strlen(rtr_name)+1);
memcpy(nbr->name,rtr_name,strlen(rtr_name)+1);
nbr->length=strlen(rtr_name)+1;
- //add_nbr_to_adl(nbr,face_id);
-
- struct name_prefix *nbr_name=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
- get_host_name_from_command_string(nbr_name,nbr->name,0);
- printf("Hostname of neighbor: %s ",nbr_name->name);
-
-
- char *ip_addr=(char *)malloc(13);
- memset(ip_addr,0,13);
- get_ip_from_hostname_02(nbr_name->name,ip_addr);
- printf("IP Address: %s \n",ip_addr);
-
+
+ if ( !is_ip_configured )
+ {
+ struct name_prefix *nbr_name=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
+ get_host_name_from_command_string(nbr_name,nbr->name,0);
+ printf("Hostname of neighbor: %s ",nbr_name->name);
+ get_ip_from_hostname_02(nbr_name->name,ip_addr);
+ printf("IP Address: %s \n",ip_addr);
+ free(nbr_name->name);
+ free(nbr_name);
+ }
+ else
+ {
+ memcpy(ip_addr,nbr_ip_addr,strlen(nbr_ip_addr));
+ printf("Name of neighbor: %s ",nbr->name);
+ printf("IP Address: %s \n",ip_addr);
+ }
add_nbr_to_adl(nbr,0,ip_addr);
@@ -388,9 +384,13 @@
}
seconds=atoi(secs);
- if ( seconds >= 240 && seconds <= 3600 )
+ if ( seconds >= 240)
{
nlsr->lsa_refresh_time=seconds;
+ if ( nlsr->router_dead_interval < nlsr->lsa_refresh_time * 2 )
+ {
+ nlsr->router_dead_interval=2*nlsr->lsa_refresh_time;
+ }
}
}
@@ -416,19 +416,23 @@
}
seconds=atoi(secs);
- if ( seconds >= 360 && seconds <= 5400 )
+ if ( seconds >= 480 )
{
nlsr->router_dead_interval=seconds;
+ if ( nlsr->router_dead_interval < nlsr->lsa_refresh_time * 2 )
+ {
+ nlsr->router_dead_interval=2*nlsr->lsa_refresh_time;
+ }
}
}
void
-process_command_multi_path_face_num(char *command)
+process_command_max_faces_per_prefix(char *command)
{
if(command==NULL)
{
- printf(" Wrong Command Format ( multi-path-face-num n )\n");
+ printf(" Wrong Command Format ( max-faces-per-prefix n )\n");
return;
}
char *rem;
@@ -439,14 +443,14 @@
num=strtok_r(command,sep,&rem);
if(num==NULL)
{
- printf(" Wrong Command Format ( multi-path-face-num n)\n");
+ printf(" Wrong Command Format ( max-faces-per-prefix n)\n");
return;
}
number=atoi(num);
if ( number >= 0 && number <= 60 )
{
- nlsr->multi_path_face_num=number;
+ nlsr->max_faces_per_prefix=number;
}
}
@@ -672,6 +676,10 @@
{
nlsr->tunnel_type=IPPROTO_TCP;
}
+ else if ( strcmp(on_off,"UDP") == 0 || strcmp(on_off,"udp") == 0 )
+ {
+ nlsr->tunnel_type=IPPROTO_UDP;
+ }
}
void
@@ -718,9 +726,9 @@
{
process_command_router_dead_interval(remainder);
}
- else if(!strcmp(cmd_type,"multi-path-face-num") )
+ else if(!strcmp(cmd_type,"max-faces-per-prefix") )
{
- process_command_multi_path_face_num(remainder);
+ process_command_max_faces_per_prefix(remainder);
}
else if(!strcmp(cmd_type,"logdir") )
{
@@ -809,6 +817,7 @@
int face_id=add_ccn_face(nlsr->ccn, (const char *)nbr->neighbor->name, (const char *)nbr->ip_address, 9695,nlsr->tunnel_type);
update_face_to_adl_for_nbr(nbr->neighbor->name, face_id);
add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_REG, face_id);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_REG, face_id);
hashtb_next(e);
}
@@ -835,6 +844,7 @@
{
add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_UNREG, nbr->face);
add_delete_ccn_face_by_face_id(nlsr->ccn,(const char *)nbr->neighbor->name,OP_UNREG,nbr->face);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_UNREG, nbr->face);
}
hashtb_next(e);
}
@@ -927,6 +937,10 @@
else
{
update_adjacent_status_to_adl(np,NBR_DOWN);
+ int face_id=get_next_hop_face_from_adl(np->name);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)np->name, OP_UNREG, face_id);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_UNREG, face_id);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_UNREG, face_id);
delete_nbr_from_adl(np);
if(!nlsr->is_build_adj_lsa_sheduled)
{
@@ -951,7 +965,8 @@
printf("IP Address: %s \n",ip_addr);
int face_id=add_ccn_face(nlsr->ccn, (const char *)nbr_name->name, (const char *)ip_addr, 9695,nlsr->tunnel_type);
update_face_to_adl_for_nbr(nbr_name->name, face_id);
- add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_REG, face_id);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->topo_prefix, OP_REG, face_id);
+ add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nlsr->slice_prefix, OP_REG, face_id);
add_nbr_to_adl(np,face_id,ip_addr);
@@ -1204,7 +1219,7 @@
nlsr->interest_resend_time = INTEREST_RESEND_TIME;
nlsr->lsa_refresh_time=LSA_REFRESH_TIME;
nlsr->router_dead_interval=ROUTER_DEAD_INTERVAL;
- nlsr->multi_path_face_num=MULTI_PATH_FACE_NUM;
+ nlsr->max_faces_per_prefix=MAX_FACES_PER_PREFIX;
nlsr->semaphor=NLSR_UNLOCKED;
nlsr->api_port=API_PORT;
diff --git a/nlsr-sync-0.0/nlsr.h b/nlsr-sync-0.0/nlsr.h
index b1b279f..dcaf947 100755
--- a/nlsr-sync-0.0/nlsr.h
+++ b/nlsr-sync-0.0/nlsr.h
@@ -9,7 +9,7 @@
#define NLSR_UNLOCKED 0
#define LSA_REFRESH_TIME 1800
#define ROUTER_DEAD_INTERVAL 3600
-#define MULTI_PATH_FACE_NUM 0
+#define MAX_FACES_PER_PREFIX 0
#define LINK_METRIC 10
@@ -88,7 +88,8 @@
long int interest_resend_time;
long int lsa_refresh_time;
long int router_dead_interval;
- long int multi_path_face_num;
+ //long int multi_path_face_num;
+ long int max_faces_per_prefix;
char *logDir;
int detailed_logging;
int debugging;
diff --git a/nlsr-sync-0.0/nlsr_lsdb.c b/nlsr-sync-0.0/nlsr_lsdb.c
index e36a922..0275e1f 100755
--- a/nlsr-sync-0.0/nlsr_lsdb.c
+++ b/nlsr-sync-0.0/nlsr_lsdb.c
@@ -69,7 +69,7 @@
void
make_name_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, long int ls_id,char *orig_time,char *slice_prefix)
{
- sprintf(key,"%s/%d/%ld/%s%s",slice_prefix, ls_type, ls_id, orig_time, orig_router);
+ sprintf(key,"%s%s/%ld/%d/%s",slice_prefix, orig_router, ls_id,ls_type, orig_time);
if ( nlsr->debugging )
printf("Name LSA prefix for repo content: %s\n",key);
@@ -79,7 +79,7 @@
make_adj_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, char *orig_time,char *slice_prefix)
{
- sprintf(key,"%s/%d/%s%s",slice_prefix,ls_type, orig_time, orig_router);
+ sprintf(key,"%s%s/%d/%s",slice_prefix,orig_router,ls_type, orig_time );
if ( nlsr->debugging )
printf("Name LSA prefix for repo content:%s\n",key);
@@ -89,7 +89,7 @@
make_cor_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, char *orig_time,char *slice_prefix)
{
- sprintf(key,"%s/%d/%s%s",slice_prefix,ls_type, orig_time, orig_router);
+ sprintf(key,"%s%s/%d/%s",slice_prefix,orig_router,ls_type, orig_time );
if ( nlsr->debugging )
printf("Cor LSA prefix for repo content:%s\n",key);
diff --git a/nlsr-sync-0.0/nlsr_npt.c b/nlsr-sync-0.0/nlsr_npt.c
index 64373fe..fb167f5 100755
--- a/nlsr-sync-0.0/nlsr_npt.c
+++ b/nlsr-sync-0.0/nlsr_npt.c
@@ -216,23 +216,22 @@
}
}
- first_face=num_face-1;
-
- if ( nlsr->multi_path_face_num == 0 )
+ last_face=0;
+ if ( nlsr->max_faces_per_prefix == 0) // add all faces available in routing table
{
- last_face=first_face;
+ first_face=num_face-1;
}
- else
+ else if( nlsr->max_faces_per_prefix > 0)
{
- if ( num_face <= nlsr->multi_path_face_num)
+ if ( nlsr->max_faces_per_prefix >= num_face)
{
- last_face=0;
+ first_face=num_face-1;
}
- else
+ else if ( nlsr->max_faces_per_prefix < num_face)
{
- last_face=num_face-nlsr->multi_path_face_num;
+ first_face=nlsr->max_faces_per_prefix-1;
}
-
+
}
int i,j, nl_element;
@@ -343,24 +342,23 @@
sort_faces_by_distance(faces,route_costs,0,num_face);
- first_face=num_face-1;
-
- if ( nlsr->multi_path_face_num == 0 )
+ last_face=0;
+ if ( nlsr->max_faces_per_prefix == 0) // add all faces available in routing table
{
- last_face=first_face;
+ first_face=num_face-1;
}
- else
+ else if( nlsr->max_faces_per_prefix > 0)
{
- if ( num_face <= nlsr->multi_path_face_num)
+ if ( nlsr->max_faces_per_prefix >= num_face)
{
- last_face=0;
+ first_face=num_face-1;
}
- else
+ else if ( nlsr->max_faces_per_prefix < num_face)
{
- last_face=num_face-nlsr->multi_path_face_num;
+ first_face=nlsr->max_faces_per_prefix-1;
}
- }
-
+
+ }
for( j=first_face; j>= last_face; j--)
{
@@ -974,7 +972,7 @@
get_all_faces_for_orig_router_from_npt(orig_router,faces,route_costs,num_face);
sort_faces_by_distance(faces,route_costs,0,num_face);
-
+ /*
first_face=num_face-1;
if ( nlsr->multi_path_face_num == 0 )
@@ -992,6 +990,25 @@
last_face=num_face-nlsr->multi_path_face_num;
}
}
+ */
+
+ last_face=0;
+ if ( nlsr->max_faces_per_prefix == 0) // add all faces available in routing table
+ {
+ first_face=num_face-1;
+ }
+ else if( nlsr->max_faces_per_prefix > 0)
+ {
+ if ( nlsr->max_faces_per_prefix >= num_face)
+ {
+ first_face=num_face-1;
+ }
+ else if ( nlsr->max_faces_per_prefix < num_face)
+ {
+ first_face=nlsr->max_faces_per_prefix-1;
+ }
+
+ }
int i,j, nl_element;
struct name_list_entry *nle;
diff --git a/nlsr-sync-0.0/nlsr_route.c b/nlsr-sync-0.0/nlsr_route.c
index 08a574e..573fcf9 100755
--- a/nlsr-sync-0.0/nlsr_route.c
+++ b/nlsr-sync-0.0/nlsr_route.c
@@ -106,22 +106,25 @@
}
sort_hyperbolic_route(nbr_to_dest,nbr_dist, faces,0,num_link);
- if (nlsr->multi_path_face_num <= 1 )
+ if (nlsr->max_faces_per_prefix == 0 )
{
- update_routing_table_with_new_hyperbolic_route(me->mapping,faces[0],nbr_to_dest[0]);
+ for ( i=0 ; i < num_link; i++)
+ {
+ update_routing_table_with_new_hyperbolic_route(me->mapping,faces[i],nbr_to_dest[i]);
+ }
}
- else
+ else if ( nlsr->max_faces_per_prefix > 0 )
{
- if ( num_link <= nlsr->multi_path_face_num )
+ if ( num_link <= nlsr->max_faces_per_prefix )
{
for ( i=0 ; i < num_link; i++)
{
update_routing_table_with_new_hyperbolic_route(me->mapping,faces[i],nbr_to_dest[i]);
}
}
- else if (num_link > nlsr->multi_path_face_num)
+ else if (num_link > nlsr->max_faces_per_prefix)
{
- for ( i=0 ; i < nlsr->multi_path_face_num; i++)
+ for ( i=0 ; i < nlsr->max_faces_per_prefix; i++)
{
update_routing_table_with_new_hyperbolic_route(me->mapping,faces[i],nbr_to_dest[i]);
}
@@ -146,14 +149,14 @@
long int *dist=(long int *)malloc(map_element * sizeof(long int));
- if ( (num_link == 0) || (nlsr->multi_path_face_num == 1 ) )
+ if ( (num_link == 0) || (nlsr->max_faces_per_prefix == 1 ) )
{
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 if ( (num_link != 0) && (nlsr->multi_path_face_num > 1 ) )
+ else if ( (num_link != 0) && (nlsr->max_faces_per_prefix == 0 || nlsr->max_faces_per_prefix > 1 ) )
{
long int *links=(long int *)malloc(num_link*sizeof(long int));
long int *link_costs=(long int *)malloc(num_link*sizeof(long int));
diff --git a/nlsr-sync-0.0/nlsr_sync.c b/nlsr-sync-0.0/nlsr_sync.c
index ee72d79..52f9ca4 100644
--- a/nlsr-sync-0.0/nlsr_sync.c
+++ b/nlsr-sync-0.0/nlsr_sync.c
@@ -456,16 +456,21 @@
ccn_charbuf_destroy(&name);
- res=ccn_name_comp_get(content_name->buf, components,lsa_position+1,&lst, &comp_size);
-
+ //res=ccn_name_comp_get(content_name->buf, components,lsa_position+1,&lst, &comp_size);
+ res=ccn_name_comp_get(content_name->buf, components,components->n-2-1,&lst, &comp_size);
ls_type=atoi((char *)lst);
+
if(ls_type == LS_TYPE_NAME)
{
- res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&lsid, &comp_size);
+ res=ccn_name_comp_get(content_name->buf, components,components->n-2-2,&lsid, &comp_size);
ls_id=atoi((char *)lsid);
- res=ccn_name_comp_get(content_name->buf, components,lsa_position+3,&origtime, &comp_size);
- get_name_part(orig_router,content_name,components,3);
+ res=ccn_name_comp_get(content_name->buf, components,components->n-2,&origtime, &comp_size);
+ ccn_name_chop(content_name,components,-3);
+ get_name_part(orig_router,content_name,components,0);
+
+ if ( nlsr->debugging )
+ printf("Orig Router: %s Ls Type: %d Ls id: %ld Orig Time: %s\n",orig_router->name,ls_type,ls_id,origtime);
int lsa_life_time=get_time_diff(time_stamp,(char *)origtime);
@@ -499,11 +504,12 @@
}
else if(ls_type == LS_TYPE_ADJ)
{
- res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&origtime, &comp_size);
- get_name_part(orig_router,content_name,components,2);
+ res=ccn_name_comp_get(content_name->buf, components,components->n-2,&origtime, &comp_size);
+ ccn_name_chop(content_name,components,-2);
+ get_name_part(orig_router,content_name,components,0);
if ( nlsr->debugging )
- printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name);
+ printf("Orig Router: %s Ls Type: %d Orig Time: %s\n",orig_router->name,ls_type,origtime);
int lsa_life_time=get_time_diff(time_stamp,(char *)origtime);
if ( (strcmp((char *)orig_router,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) || (strcmp((char *)orig_router,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) )
@@ -536,11 +542,12 @@
}
else if(ls_type == LS_TYPE_COR)
{
- res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&origtime, &comp_size);
- get_name_part(orig_router,content_name,components,2);
+ res=ccn_name_comp_get(content_name->buf, components,components->n-2,&origtime, &comp_size);
+ ccn_name_chop(content_name,components,-2);
+ get_name_part(orig_router,content_name,components,0);
if ( nlsr->debugging )
- printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name);
+ printf("Orig Router: %s Ls Type: %d Orig Time: %s\n",orig_router->name,ls_type,origtime);
int lsa_life_time=get_time_diff(time_stamp,(char *)origtime);
if ( (strcmp((char *)orig_router,nlsr->router_name) == 0 && lsa_life_time < nlsr->lsa_refresh_time) || (strcmp((char *)orig_router,nlsr->router_name) != 0 && lsa_life_time < nlsr->router_dead_interval) )
diff --git a/nlsr.c b/nlsr.c
index bd2ac39..f71e4ae 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -179,7 +179,6 @@
printf(" Wrong Command Format ( ccnneighbor router_name faceX) where X is integer\n");
return;
}
-
if ( rtr_name[strlen(rtr_name)-1] == '/' )
{
rtr_name[strlen(rtr_name)-1]='\0';