Merge branch 'master' of github.com:NDN-Routing/NLSR0.0
diff --git a/Makefile b/Makefile
index 3236fe6..f9d826c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,20 @@
-CC = cc
-CFLAGS = -g -Wall -Wpointer-arith -Wreturn-type -Wstrict-prototypes
-LIBS = -lccn -lcrypto
+CC = gcc
+CFLAGS = -Wall -gdwarf-2 -g3 
+LIBS = -lccn -lccnsync -lcrypto 
 
 PROGRAMS = nlsrc nlsr
 INSTALL_PATH=/usr/local/bin/
 
-NLSR_SRCS=nlsr.c nlsr_ndn.c nlsr_npl.c  nlsr_adl.c nlsr_lsdb.c nlsr_route.c nlsr_npt.c nlsr_fib.c utility.c
+NLSR_SRCS=nlsr.c nlsr_ndn.c nlsr_npl.c  nlsr_adl.c nlsr_lsdb.c nlsr_route.c nlsr_npt.c nlsr_fib.c nlsr_sync.c  nlsr_face.c utility.c
 NLSRC_SRCS=nlsrc.c
 
 all: $(PROGRAMS)
 
 nlsr: $(NLSR_SRCS)
-	$(CC) $(CFLAGS) $(NLSR_SRCS) -o nlsr $(LIBS) -lm
+	$(CC) $(CFLAGS) $(NLSR_SRCS) $(LIBS) -lm -o nlsr
 
 nlsrc: $(NLSRC_SRCS)
-	$(CC) $(CFLAGS) $(NLSRC_SRCS) -o nlsrc $(LIBS) -lm
+	$(CC) $(CFLAGS) $(NLSRC_SRCS) $(LIBS) -lm -o nlsrc
 
 install: $(PROGRAMS)
 	cp $(PROGRAMS) $(INSTALL_PATH)
diff --git a/NLSR_Timing_Diagram.odg b/NLSR_Timing_Diagram.odg
index 41e9837..820b307 100644
--- a/NLSR_Timing_Diagram.odg
+++ b/NLSR_Timing_Diagram.odg
Binary files differ
diff --git a/nlsr-sync-0.0/docs/FigureSource.odg b/docs/FigureSource.odg
similarity index 100%
rename from nlsr-sync-0.0/docs/FigureSource.odg
rename to docs/FigureSource.odg
Binary files differ
diff --git a/nlsr-sync-0.0/docs/NLSR Sync-v1.pptx b/docs/NLSR Sync-v1.pptx
similarity index 100%
rename from nlsr-sync-0.0/docs/NLSR Sync-v1.pptx
rename to docs/NLSR Sync-v1.pptx
Binary files differ
diff --git a/nlsr-sync-0.0/docs/NLSR Sync.pptx b/docs/NLSR Sync.pptx
similarity index 100%
rename from nlsr-sync-0.0/docs/NLSR Sync.pptx
rename to docs/NLSR Sync.pptx
Binary files differ
diff --git a/docs/NLSR_Design_Doc.odg b/docs/NLSR_Design_Doc.odg
new file mode 100644
index 0000000..bd38d2c
--- /dev/null
+++ b/docs/NLSR_Design_Doc.odg
Binary files differ
diff --git a/nlsr-sync-0.0/docs/NLSR_Manual.doc b/docs/NLSR_Manual.doc
similarity index 60%
rename from nlsr-sync-0.0/docs/NLSR_Manual.doc
rename to docs/NLSR_Manual.doc
index aa63d0c..9449934 100644
--- a/nlsr-sync-0.0/docs/NLSR_Manual.doc
+++ b/docs/NLSR_Manual.doc
Binary files differ
diff --git a/macbook.conf b/macbook.conf
index 19b6c30..52e84f7 100644
--- a/macbook.conf
+++ b/macbook.conf
@@ -1,17 +1,25 @@
 #----configuration file for macbook----------
 #
-router-name /ndn/memphis.edu/netlab/macbook/
-ccnneighbor /ndn/memphis.edu/dunhall/castor face9
-ccnneighbor /ndn/memphis.edu/pollux face38
-ccnname /ndn/memphis.edu/patterson
-ccnname /ndn/memphis.edu/houston/
+router-name /ndn/memphis.edu/netlab/macbook
+ccnneighbor /ndn/memphis.edu/cs/maia
+ccnneighbor /ndn/memphis.edu/cs/mira
+ccnneighbor /ndn/memphis.edu/cs/castor
+ccnneighbor /ndn/memphis.edu/cs/pollux 141.225.11.132
+ccnname /ndn/memphis.edu/macbook/patterson
+ccnname /ndn/memphis.edu/macbook/houston/
 #------lsdb-synch-interval-----
-lsdb-synch-interval 350
+#lsdb-synch-interval 350
 interest-retry 2 
 interest-resend-time 5
 lsa-refresh-time 600
 router-dead-interval 900
-multi-path-face-num 2 
-#debug on
+max_faces_per_prefix 1 
+debug on
+#hyperbolic-routing on
+hyperbolic-cordinate 1234.0 0.875
+tunnel-type udp
+
+topo-prefix /ndn/routing/nlsr/
+slice-prefix /ndn/routing/nlsr/LSA
 
 logdir /Users/akmhoque/NLSR2.0
diff --git a/nlsr-sync-0.0/1 b/nlsr-sync-0.0/1
deleted file mode 100755
index dfc274e..0000000
--- a/nlsr-sync-0.0/1
+++ /dev/null
@@ -1,8 +0,0 @@
-router-name /ndn/memphis.edu/netlab/macbook
-ccnneighbor /ndn/memphis.edu/dunhall/castor face9
-ccnneighbor /ndn/memphis.edu/joneshall/mira face11
-ccnname /ndn/memphis.edu/patterson
-ccnname /ndn/memphis.edu/houston
-lsdb-synch-interval 350
-interest-retry 4
-interest-resend-time 5
diff --git a/nlsr-sync-0.0/Makefile b/nlsr-sync-0.0/Makefile
deleted file mode 100755
index 313a3ac..0000000
--- a/nlsr-sync-0.0/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-CC = gcc
-CFLAGS = -g -Wall -gdwarf-2 -g3 
-LIBS = -lccn -lccnsync -lcrypto 
-
-PROGRAMS = nlsrc nlsr
-INSTALL_PATH=/usr/local/bin/
-
-NLSR_SRCS=nlsr.c nlsr_ndn.c nlsr_npl.c  nlsr_adl.c nlsr_lsdb.c nlsr_route.c nlsr_npt.c nlsr_fib.c nlsr_sync.c  nlsr_face.c utility.c
-NLSRC_SRCS=nlsrc.c
-
-all: $(PROGRAMS)
-
-nlsr: $(NLSR_SRCS)
-	$(CC) $(CFLAGS) $(NLSR_SRCS) $(LIBS) -lm -o nlsr
-
-nlsrc: $(NLSRC_SRCS)
-	$(CC) $(CFLAGS) $(NLSRC_SRCS) $(LIBS) -lm -o nlsrc
-
-install: $(PROGRAMS)
-	cp $(PROGRAMS) $(INSTALL_PATH)
-	cd $(INSTALL_PATH); chown root:0 $(PROGRAMS); chmod 755 $(PROGRAMS)
-
-uninstall:
-	cd $(INSTALL_PATH); rm -f $(PROGRAMS)
-
-clean:
-	rm -f *.o
-	rm -f $(PROGRAMS)
-	rm -rf *.dSYM
-
-.c.o:
-	$(CC) $(CFLAGS) -c $<
-
-.PHONY: all clean
diff --git a/nlsr-sync-0.0/NLSR_Design.docx b/nlsr-sync-0.0/NLSR_Design.docx
deleted file mode 100755
index c9070c6..0000000
--- a/nlsr-sync-0.0/NLSR_Design.docx
+++ /dev/null
Binary files differ
diff --git a/nlsr-sync-0.0/NLSR_Timing_Diagram.odg b/nlsr-sync-0.0/NLSR_Timing_Diagram.odg
deleted file mode 100755
index 820b307..0000000
--- a/nlsr-sync-0.0/NLSR_Timing_Diagram.odg
+++ /dev/null
Binary files differ
diff --git a/nlsr-sync-0.0/README b/nlsr-sync-0.0/README
deleted file mode 100644
index bd4039a..0000000
--- a/nlsr-sync-0.0/README
+++ /dev/null
@@ -1,4 +0,0 @@
-Only experimental code here for nlsr using parc's sync implementation.
-It's not a working version, so don't rely on it at all.
-This README will be updated once the code is in working condition. 
-
diff --git a/nlsr-sync-0.0/README.md b/nlsr-sync-0.0/README.md
deleted file mode 100755
index 18880a1..0000000
--- a/nlsr-sync-0.0/README.md
+++ /dev/null
@@ -1,111 +0,0 @@
-NLSR0.0
-=======
-
-Named-data Link State Routing ( NLSR ):
-  NLSR is routing protocol caluclate routing table dynamically and manipulate 
-ccnd forwarding information base (FIB) based on routing table.
-
-1. Download:
-	Check out the code from the github by following
-git://github.com/NDN-Routing/NLSR0.0.git
-
-2. Installation:
-	For installation of NLSR you must need to have ccnd installed. Go to NLSR0.0.
-Then make it and install by following
-
-$make
-$sudo make install
-
-3. Configuring NLSR:
-	For the explanation of configuring NLSR, we will consider following network topology.
-
-
-                                ---------
-                                |       |
-                                |       |  /ndn/memphis.edu/castor
-                                ---------
-                           face9/       \ face11
-                               /         \
-                              /           \
-                             /             \
-                       face7/               \ face10
-                   ---------               ---------                    ---------
-                   |       |face8   face11 |       |face13         face7|       |
-                   |       |---------------|       |--------------------|       |
-                   ---------               ---------                    ---------
-           -/ndn/memphis.edu/pollux     /ndn/memphis.edu/mira     /ndn/memphis.edu/sirius
-		
-
-3.1 Creating faces for neighbors
-	For configuring of NLSR first system admin first need to create faces for the neighbors.
-For router having router-name /ndn/memphis.edu/castor, system admin need to create two faces for
-neighbors routers /ndn/memphis.edu/pollux and /ndn/memphis.edu/mira. By ccndc utility one can
-create face as below
-
-$ccndc add /ndn/memphis.edu/pollux udp pollux.cs.memphis.edu
-$ccndc add /ndn/memphis.edu/mira udp mira.cs.memphis.edu
-
-Let us assume that that face id for /ndn/memphis.edu/pollux is 9 and /ndn/memphis.edu/mira is 11.
-
-3.2 Configuration Commands
-3.2.1 router-name /name/prefix/of/router
-	router-name commands assigns name of the router. Router-name is unique in the network and
-maintained by name management. This is mandatory configuration command.
-
-3.2.2 ccnneighbor /name/prefix/of/neighbor/router faceX.
-	By this command router configures neighboring router. X is integer and must be precedeed 
-by "face". faceX is the connecting face for that neighbors.
-
-3.2.3 ccnname /name/prefix/to/be/advertised
-	With this configuration command router advertise name prefix
-
-3.2.4 lsdb-synch-interval secs
-	its the time interval after which neighbors will synchronize Link State Database. Default
-value is 300.
-
-3.2.5 interest-retry tries
-	its number of tries router will try if interest is timed out. Defualt value is 3.
-
-3.2.6 interest-resend-time secs
-	its the amount of time after which interest for a content will timed out. Defualt value
-is 15.
-
-3.2.7 lsa-refresh-time secs
-	its the amount of time after which router will regenerate its own LSDB and regenerate
-every LSA. Default value is 1800.
-
-3.2.8 router-dead-interval secs
-	its the amounnt of time after which a router will consider its neighbor dead if it does
-not hear anything from the neighbor. Default value 3600.
-
-3.2.9 multi-path-face-num n
-	with this command one activate to do multi-path routing. If n is greater than 1 then
-multi-path is triggered on and n faces will be added in ccnd fib after routing table calculation.
-Default value is 0 and then NLSR perform single path routing.
-
-3.2.10 logdir path/to/log/dir
-	By this command one can configure where NLSR will write logfiles. By default NLSR will
-write log file to /home/nlsrLog/ directory.
-
-3.3 Sample configuration file
-	Let assume that router /ndn/memphis.edu/castor wants to advertise two names 
-/ndn/memphis.edu/cslab/netlab and /ndn/memphis.edu/cslab/wisemanet. Configuration file for 
-/ndn/memphis.edu/castor will look like below 
-
-!-----Configuration file starts here
-
-router-name /ndn/memphis.edu/castor
-ccnneighbor /ndn/memphis.edu/mira face10
-ccnneighbor /ndn/memphis.edu/pollux face9
-ccnname /ndn/memphis.edu/cslab/netlab
-ccnname /ndn/memphis.edu/cslab/wisemanet
-
-lsdb-synch-interval 350
-interest-retry 3 
-interest-resend-time 10
-lsa-refresh-time 1800
-router-dead-interval 3600
-multi-path-face-num 2
-logdir /home/nlsrLog/ 
-
-!-----Configuration file ends here
diff --git a/nlsr-sync-0.0/docs/NLSR_Design_Doc.odg b/nlsr-sync-0.0/docs/NLSR_Design_Doc.odg
deleted file mode 100644
index 6dba61e..0000000
--- a/nlsr-sync-0.0/docs/NLSR_Design_Doc.odg
+++ /dev/null
Binary files differ
diff --git a/nlsr-sync-0.0/macbook.conf b/nlsr-sync-0.0/macbook.conf
deleted file mode 100755
index d29553f..0000000
--- a/nlsr-sync-0.0/macbook.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-#----configuration file for macbook----------
-#
-router-name /ndn/memphis.edu/netlab/macbook
-ccnneighbor /ndn/memphis.edu/cs/maia
-ccnneighbor /ndn/memphis.edu/cs/mira
-ccnneighbor /ndn/memphis.edu/cs/castor
-ccnname /ndn/memphis.edu/macbook/patterson
-ccnname /ndn/memphis.edu/macbook/houston/
-#------lsdb-synch-interval-----
-lsdb-synch-interval 350
-interest-retry 2 
-interest-resend-time 5
-lsa-refresh-time 600
-router-dead-interval 900
-multi-path-face-num 2 
-debug on
-hyperbolic-routing on
-hyperbolic-cordinate 1234.0 0.875
-tunnel-type tcp
-
-topo-prefix /ndn/routing/nlsr/
-slice-prefix /ndn/routing/nlsr/LSA
-
-logdir /Users/akmhoque/NLSR2.0
diff --git a/nlsr-sync-0.0/nlsr.c b/nlsr-sync-0.0/nlsr.c
deleted file mode 100755
index 14244af..0000000
--- a/nlsr-sync-0.0/nlsr.c
+++ /dev/null
@@ -1,1370 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-#include <ccn/sync.h>
-#include <ccn/seqwriter.h>
-
-#include "nlsr.h"
-#include "nlsr_ndn.h"
-#include "nlsr_lsdb.h"
-#include "utility.h"
-#include "nlsr_npl.h"
-#include "nlsr_adl.h"
-#include "nlsr_npt.h"
-#include "nlsr_route.h"
-#include "nlsr_sync.h"
-#include "nlsr_face.h"
-#include "nlsr_fib.h"
-
-
-#define ON_ERROR_DESTROY(resval) \
-{           \
-    if ((resval) < 0) { \
-        nlsr_destroy(); \
-	exit(1);\
-    } \
-}
-
-
-#define ON_ERROR_EXIT(resval) \
-{           \
-    if ((resval) < 0) { \
-        exit(1); \
-    } \
-}
-
-struct option longopts[] =
-{
-    { "daemon",      no_argument,       NULL, 'd'},
-    { "config_file", required_argument, NULL, 'f'},
-    { "api_port",    required_argument, NULL, 'p'},
-    { "help",        no_argument,       NULL, 'h'},
-    { 0 }
-};
-
-static int 
-usage(char *progname)
-{
-
-    printf("Usage: %s [OPTIONS...]\n\
-	NDN routing....\n\
-	-d, --daemon        Run in daemon mode\n\
-	-f, --config_file   Specify configuration file name\n\
-	-p, --api_port      port where api client will connect\n\
-	-h, --help          Display this help message\n", progname);
-
-    exit(1);
-}
-
-void ndn_rtr_gettime(const struct ccn_gettime *self, struct ccn_timeval *result)
-{
-    struct timeval now = {0};
-    gettimeofday(&now, 0);
-    result->s = now.tv_sec;
-    result->micros = now.tv_usec;
-}
-
-static struct ccn_gettime ndn_rtr_ticker = {
-    "timer",
-    &ndn_rtr_gettime,
-    1000000,
-    NULL
-};
-
-void
-nlsr_lock(void)
-{
-	nlsr->semaphor=NLSR_LOCKED;
-}
-
-void
-nlsr_unlock(void)
-{
-	nlsr->semaphor=NLSR_UNLOCKED;
-}
-
-void 
-nlsr_stop_signal_handler(int sig)
-{
-	signal(sig, SIG_IGN);
- 	nlsr_destroy();
-	exit(0);	
-}
-
-void  
-daemonize_nlsr(void)
-{
-	int ret;
-	pid_t process_id = 0;
-	pid_t sid = 0;
-	process_id = fork();
-	if (process_id < 0)
-	{
-		printf("Daemonization failed!\n");
-		ON_ERROR_DESTROY(process_id);
-	}
-	if (process_id > 0)
-	{
-		printf("Process daemonized. Process id: %d \n", process_id);
-		ret=process_id;
-		exit(0);
-	}
-	
-	umask(0);
-	sid = setsid();
-	if(sid < 0)
-	{
-		ON_ERROR_DESTROY(sid);		
-	}
-	
-	chdir("/");	
-	close(STDIN_FILENO);
-	close(STDOUT_FILENO);
-	close(STDERR_FILENO);
-}
-
-void 
-process_command_ccnneighbor(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( ccnneighbor router_name faceX)\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *rtr_name;
-	//char *face;
-
-	rtr_name=strtok_r(command,sep,&rem);
-	if(rtr_name==NULL)
-	{
-		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';
-	}
-	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);
-
-	add_nbr_to_adl(nbr,0,ip_addr);
-	
-
-	free(nbr->name);
-	free(nbr);
-}
-
-void 
-process_command_ccnname(char *command)
-{
-
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( ccnname /name/prefix)\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *name;
-	name=strtok_r(command,sep,&rem);
-	if(name==NULL)
-	{
-		printf(" Wrong Command Format ( ccnname /name/prefix/ )\n");
-		return;
-	}
-
-	printf("Name Prefix: %s \n",name);
-
-	if ( name[strlen(name)-1] == '/' )
-		name[strlen(name)-1]='\0';
-
-	struct name_prefix *np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	np->name=(char *)malloc(strlen(name)+1);
-	memset(np->name,0,strlen(name)+1);
-	memcpy(np->name,name,strlen(name)+1);
-	np->length=strlen(name)+1;
-
-	add_name_to_npl(np);
-
-	free(np->name);
-	free(np);
-}
-
-
-void 
-process_command_router_name(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( router-name /router/name )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *rtr_name;
-
-	rtr_name=strtok_r(command,sep,&rem);
-	if(rtr_name==NULL)
-	{
-		printf(" Wrong Command Format ( router-name /router/name )\n");
-		return;
-	}
-	
-
-	if ( rtr_name[strlen(rtr_name)-1] == '/' )
-		rtr_name[strlen(rtr_name)-1]='\0';
-
-	nlsr->router_name=(char *)malloc(strlen(rtr_name)+1);
-	memset(nlsr->router_name,0,strlen(rtr_name)+1);
-	memcpy(nlsr->router_name,rtr_name,strlen(rtr_name)+1);
-
-
-}
-
-void 
-process_command_lsdb_synch_interval(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( lsdb-synch-interval secs )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *secs;
-	long int seconds;
-	
-	secs=strtok_r(command,sep,&rem);
-	if(secs==NULL)
-	{
-		printf(" Wrong Command Format ( lsdb-synch-interval secs)\n");
-		return;
-	}
-
-	seconds=atoi(secs);
-	if ( seconds >= 120 && seconds <= 3600 )
-	{
-		nlsr->lsdb_synch_interval=seconds;
-	}
-
-}
-
-
-void 
-process_command_interest_retry(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( interest-retry number )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *retry;
-	long int retry_number;
-	
-	retry=strtok_r(command,sep,&rem);
-	if(retry==NULL)
-	{
-		printf(" Wrong Command Format ( interest-retry number)\n");
-		return;
-	}
-
-	retry_number=atoi(retry);
-	if ( retry_number >= 1 && retry_number<=10 )
-	{
-		nlsr->interest_retry=retry_number;
-	}
-
-}
-
-void 
-process_command_interest_resend_time(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( interest-resend-time secs )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *secs;
-	long int seconds;
-	
-	secs=strtok_r(command,sep,&rem);
-	if(secs==NULL)
-	{
-		printf(" Wrong Command Format ( interest-resend-time secs)\n");
-		return;
-	}
-
-	seconds=atoi(secs);
-	if ( seconds <= 60 && seconds >= 1 )
-	{
-		nlsr->interest_resend_time=seconds;
-	}
-}
-
-
-void 
-process_command_lsa_refresh_time(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( lsa-refresh-time secs )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *secs;
-	long int seconds;
-	
-	secs=strtok_r(command,sep,&rem);
-	if(secs==NULL)
-	{
-		printf(" Wrong Command Format ( lsa-refresh-time secs)\n");
-		return;
-	}
-
-	seconds=atoi(secs);
-	if ( seconds >= 240 && seconds <= 3600 )
-	{
-		nlsr->lsa_refresh_time=seconds;
-	}
-
-}
-
-void 
-process_command_router_dead_interval(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( router-dead-interval secs )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *secs;
-	long int seconds;
-	
-	secs=strtok_r(command,sep,&rem);
-	if(secs==NULL)
-	{
-		printf(" Wrong Command Format ( router-dead-interval secs)\n");
-		return;
-	}
-
-	seconds=atoi(secs);
-	if ( seconds >= 360 && seconds <= 5400 )
-	{
-		nlsr->router_dead_interval=seconds;
-	}
-
-}
-
-void 
-process_command_multi_path_face_num(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( multi-path-face-num n )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *num;
-	long int number;
-	
-	num=strtok_r(command,sep,&rem);
-	if(num==NULL)
-	{
-		printf(" Wrong Command Format ( multi-path-face-num n)\n");
-		return;
-	}
-
-	number=atoi(num);
-	if ( number >= 0 && number <= 60 )
-	{
-		nlsr->multi_path_face_num=number;
-	}
-
-}
-
-void 
-process_command_logdir(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( logdir /path/to/logdir )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *dir;
-
-	dir=strtok_r(command,sep,&rem);
-	if(dir==NULL)
-	{
-		printf(" Wrong Command Format ( logdir /path/to/logdir/ )\n");
-		return;
-	}
-	
-	nlsr->logDir=(char *)malloc(strlen(dir)+1);
-	memset(nlsr->logDir,0,strlen(dir)+1);
-	memcpy(nlsr->logDir,dir,strlen(dir));
-}
-
-void 
-process_command_detailed_log(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( detailed-log on/off )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *on_off;
-
-	on_off=strtok_r(command,sep,&rem);
-	if(on_off==NULL)
-	{
-		printf(" Wrong Command Format ( detailed-log on/off )\n");
-		return;
-	}
-	
-	if ( strcmp(on_off,"ON") == 0  || strcmp(on_off,"on") == 0)
-	{
-		nlsr->detailed_logging=1;
-	}
-}
-
-void 
-process_command_debug(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( debug on/off )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *on_off;
-
-	on_off=strtok_r(command,sep,&rem);
-	if(on_off==NULL)
-	{
-		printf(" Wrong Command Format ( debug on/off )\n");
-		return;
-	}
-	
-	if ( strcmp(on_off,"ON") == 0 || strcmp(on_off,"on") == 0 )
-	{
-		nlsr->debugging=1;
-	}
-}
-
-
-void 
-process_command_topo_prefix(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( topo-prefix )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *topo_prefix;
-
-	topo_prefix=strtok_r(command,sep,&rem);
-	if(topo_prefix==NULL)
-	{
-		printf(" Wrong Command Format (  topo-prefix /name/prefix  )\n");
-		return;
-	}
-	else
-	{
-		if( nlsr->topo_prefix != NULL)	
-			free(nlsr->topo_prefix);
-		if ( topo_prefix[strlen(topo_prefix)-1] == '/' )
-			topo_prefix[strlen(topo_prefix)-1]='\0';
-
-		nlsr->topo_prefix=(char *)malloc(strlen(topo_prefix)+1);
-		memset(nlsr->topo_prefix,0,strlen(topo_prefix)+1);
-		puts(topo_prefix);
-		memcpy(nlsr->topo_prefix,topo_prefix,strlen(topo_prefix));
-
-	}
-}
-
-
-void 
-process_command_slice_prefix(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( slice-prefix /name/prefix )\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *slice_prefix;
-
-	slice_prefix=strtok_r(command,sep,&rem);
-	if(slice_prefix==NULL)
-	{
-		printf(" Wrong Command Format (  slice-prefix /name/prefix  )\n");
-		return;
-	}
-	else
-	{
-		if ( nlsr->slice_prefix != NULL)
-			free(nlsr->slice_prefix);
-		if ( slice_prefix[strlen(slice_prefix)-1] == '/' )
-			slice_prefix[strlen(slice_prefix)-1]='\0';
-
-		nlsr->slice_prefix=(char *)malloc(strlen(slice_prefix)+1);
-		memset(nlsr->slice_prefix,0,strlen(slice_prefix)+1);
-		memcpy(nlsr->slice_prefix,slice_prefix,strlen(slice_prefix));
-	}
-}
-
-void 
-process_command_hyperbolic_routing(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( hyperbolic-routing on)\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *on_off;
-
-	on_off=strtok_r(command,sep,&rem);
-	if(on_off==NULL)
-	{
-		printf(" Wrong Command Format ( hyperbolic-routing on )\n");
-		return;
-	}
-	
-	if ( strcmp(on_off,"ON") == 0 || strcmp(on_off,"on") == 0 )
-	{
-		nlsr->is_hyperbolic_calc=1;
-	}
-}
-
-void
-process_command_hyperbolic_cordinate(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( hyperbolic r 0 )\n");
-		return;
-	}
-
-	char *rem;
-	const char *sep=" \t\n\r";
-	char *radious;
-	char *theta;
-
-	radious=strtok_r(command,sep,&rem);
-	if (radious == NULL )
-	{
-		printf(" Wrong Command Format ( hyperbolic r 0 )\n");
-		return;
-	}
-
-	theta=strtok_r(NULL,sep,&rem);
-	if (theta == NULL )
-	{
-		printf(" Wrong Command Format ( hyperbolic r 0 )\n");
-		return;
-	}
-
-	nlsr->cor_r=strtof(radious,NULL);
-	nlsr->cor_theta=strtof(theta,NULL);
-
-}
-
-void 
-process_command_tunnel_type(char *command)
-{
-	if(command==NULL)
-	{
-		printf(" Wrong Command Format ( tunnel-type udp/tcp)\n");
-		return;
-	}
-	char *rem;
-	const char *sep=" \t\n";
-	char *on_off;
-
-	on_off=strtok_r(command,sep,&rem);
-	if(on_off==NULL)
-	{
-		printf(" Wrong Command Format ( tunnel-type udp/tcp )\n");
-		return;
-	}
-	
-	if ( strcmp(on_off,"TCP") == 0 || strcmp(on_off,"tcp") == 0 )
-	{
-		nlsr->tunnel_type=IPPROTO_TCP;
-	}
-}
-
-void 
-process_conf_command(char *command)
-{
-	const char *separators=" \t\n";
-	char *remainder=NULL;
-	char *cmd_type=NULL;
-
-	if(command==NULL || strlen(command)==0 || command[0]=='!')
-		return;	
-
-	cmd_type=strtok_r(command,separators,&remainder);
-
-	if(!strcmp(cmd_type,"router-name") )
-	{
-		process_command_router_name(remainder);
-	}
-	else if(!strcmp(cmd_type,"ccnneighbor") )
-	{
-		process_command_ccnneighbor(remainder);
-	} 
-	else if(!strcmp(cmd_type,"ccnname") )
-	{
-		process_command_ccnname(remainder);
-	}
-	else if(!strcmp(cmd_type,"lsdb-synch-interval") )
-	{
-		process_command_lsdb_synch_interval(remainder);
-	}
-	else if(!strcmp(cmd_type,"interest-retry") )
-	{
-		process_command_interest_retry(remainder);
-	}
-	else if(!strcmp(cmd_type,"interest-resend-time") )
-	{
-		process_command_interest_resend_time(remainder);
-	}
-	else if(!strcmp(cmd_type,"lsa-refresh-time") )
-	{
-		process_command_lsa_refresh_time(remainder);
-	}
-	else if(!strcmp(cmd_type,"router-dead-interval") )
-	{
-		process_command_router_dead_interval(remainder);
-	}
-	else if(!strcmp(cmd_type,"multi-path-face-num") )
-	{
-		process_command_multi_path_face_num(remainder);
-	}
-	else if(!strcmp(cmd_type,"logdir") )
-	{
-			process_command_logdir(remainder);
-	}
-	else if(!strcmp(cmd_type,"detailed-log") )
-	{
-			process_command_detailed_log(remainder);
-	}
-	else if(!strcmp(cmd_type,"debug") )
-	{
-			process_command_debug(remainder);
-	}
-	else if(!strcmp(cmd_type,"topo-prefix") )
-	{
-			process_command_topo_prefix(remainder);
-	}
-	else if(!strcmp(cmd_type,"slice-prefix") )
-	{
-			process_command_slice_prefix(remainder);
-	}
-	else if(!strcmp(cmd_type,"hyperbolic-cordinate") )
-	{
-		process_command_hyperbolic_cordinate(remainder);
-	}
-	else if(!strcmp(cmd_type,"hyperbolic-routing") )
-	{
-		process_command_hyperbolic_routing(remainder);
-	}
-	else if(!strcmp(cmd_type,"tunnel-type") )
-	{
-		process_command_tunnel_type(remainder);
-	}
-	else 
-	{
-		printf("Wrong configuration Command %s \n",cmd_type);
-	}
-}
-
-
-int 
-readConfigFile(const char *filename)
-{
-	FILE *cfg;
-	char buf[1024];
-	int len;
-
-	cfg=fopen(filename, "r");
-
-	if(cfg == NULL)
-	{
-		printf("\nConfiguration File does not exists\n");
-		exit(1);	
-	}
-
-	while(fgets((char *)buf, sizeof(buf), cfg))
-	{
-		len=strlen(buf);
-		if(buf[len-1] == '\n')
-		buf[len-1]='\0';
-		if ( buf[0] != '#' && buf[0] != '!') 
-			process_conf_command(buf);	
-	}
-
-	fclose(cfg);
-
-	return 0;
-}
-
-
-void
-add_faces_for_nbrs(void)
-{	
-	int i, adl_element;
-	struct ndn_neighbor *nbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-		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);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-void
-destroy_faces_for_nbrs(void)
-{	
-	int i, adl_element;
-	struct ndn_neighbor *nbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-		if ( nbr->face > 0 )
-		{	
-			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);
-		}
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-char *
-process_api_client_command(char *command)
-{
-	char *msg;
-	msg=(char *)malloc(100);	
-	memset(msg,0,100);
-	
-	const char *sep=" \t\n";
-	char *rem=NULL;
-	char *cmd_type=NULL;
-	char *op_type=NULL;
-	char *name=NULL;
-	char *face=NULL;
-	int face_id;
-	int res;
-
-	op_type=strtok_r(command,sep,&rem);
-	cmd_type=strtok_r(NULL,sep,&rem);
-	name=strtok_r(NULL,sep,&rem);
-	if ( name[strlen(name)-1] == '/' )
-		name[strlen(name)-1]='\0';
-
-	struct name_prefix *np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	np->name=(char *)malloc(strlen(name)+1);
-	memset(np->name,0,strlen(name)+1);
-	memcpy(np->name,name,strlen(name)+1);
-	np->length=strlen(name)+1;
-
-	if ( strcmp(cmd_type,"name")!= 0 )
-	{
-		face=strtok_r(NULL,sep,&rem);
-		sscanf(face,"face%d",&face_id);
-	}
-	
-	if ( strcmp(cmd_type,"name")== 0 )
-	{
-		if ( strcmp(op_type,"del") == 0 ) 
-		{
-			res=does_name_exist_in_npl(np);
-			if ( res == 0)
-			{
-				sprintf(msg,"Name %s does not exist !!",name);
-			}
-			else
-			{
-				long int ls_id=get_lsa_id_from_npl(np);
-				if ( ls_id != 0 )
-				{
-					make_name_lsa_invalid(np,LS_TYPE_NAME,ls_id);
-					sprintf(msg,"Name %s has been deleted and Advertised.",name);
-				}
-				else 
-				{
-					sprintf(msg,"Name %s does not have an Name LSA yet !!",name);
-				}
-			}			
-		}
-		else if ( strcmp(op_type,"add") == 0 )
-		{
-			res=does_name_exist_in_npl(np);
-			if ( res == 0)
-			{
-				add_name_to_npl(np);
-				build_and_install_single_name_lsa(np);
-				sprintf(msg,"Name %s has been added to advertise.",name);
-			}
-			else
-			{
-				sprintf(msg,"Name %s has already been advertised from this router !!",name);
-			}
-		} 
-	}
-	else if ( strcmp(cmd_type,"neighbor") == 0 )
-	{
-		if ( strcmp(op_type,"del") == 0 ) 
-		{
-			res=is_neighbor(np->name);
-			if ( res == 0)
-			{
-				sprintf(msg,"Neighbor %s does not exist !!",name);
-			}
-			else
-			{
-				update_adjacent_status_to_adl(np,NBR_DOWN);
-				delete_nbr_from_adl(np);
-				if(!nlsr->is_build_adj_lsa_sheduled)
-				{
-					nlsr->event_build_adj_lsa = ccn_schedule_event(nlsr->sched, 1000, &build_and_install_adj_lsa, NULL, 0);
-					nlsr->is_build_adj_lsa_sheduled=1;		
-				}
-				sprintf(msg,"Neighbor %s has been deleted from adjacency list.",name);	
-			}
-		}
-		else if ( strcmp(op_type,"add") == 0 )
-		{
-			res=is_neighbor(np->name);
-			if ( res == 0 )
-			{
-				struct name_prefix *nbr_name=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-				get_host_name_from_command_string(nbr_name,np->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);
-				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_nbr_to_adl(np,face_id,ip_addr);
-
-				sprintf(msg,"Neighbor %s has been added to adjacency list.",name);
-
-			}
-			else
-			{
-				sprintf(msg,"Neighbor %s already exists in adjacency list.",name);
-			}
-		}
-	}
-		
-
-	return msg;
-}
-
-int
-nlsr_api_server_poll(long int time_out_micro_sec, int ccn_fd)
-{
-	struct timeval timeout;
-	if (time_out_micro_sec< 500000 && time_out_micro_sec> 0 )
-	{
-		timeout.tv_sec=0;
-		timeout.tv_usec=time_out_micro_sec;
-	}
-	else 
-	{
-		timeout.tv_sec = 0;
-		timeout.tv_usec = 500000;
-	}
-	
-	int fd;
-	int nread;
-	int result;
-	fd_set testfds;
-	unsigned int client_len;
-	int client_sockfd;
-	char recv_buffer[1024];
-	bzero(recv_buffer,1024);
-	struct sockaddr_in client_address;
-
-	testfds=nlsr->readfds;
-	result = select(FD_SETSIZE, &testfds, NULL,NULL, &timeout);
-	
-	for(fd = 0; fd < FD_SETSIZE && result > 0; fd++) 
-	{
-		if(FD_ISSET(fd,&testfds)) 
-		{
-			if ( fd == ccn_fd )
-			{
-				return 0;
-			}			
-			else if(fd == nlsr->nlsr_api_server_sock_fd)
-			{
-				client_len = sizeof(client_address);
-				client_sockfd = accept(nlsr->nlsr_api_server_sock_fd,(struct sockaddr *)&client_address, &client_len);
-				FD_SET(client_sockfd, &nlsr->readfds);
-			}
-			else
-			{   
-					
-				ioctl(fd, FIONREAD, &nread);
-				if(nread == 0) 
-				{
-					close(fd);
-					FD_CLR(fd, &nlsr->readfds);
-				}
-				else 
-				{
-					recv(fd, recv_buffer, 1024, 0);
-					printf("Received Data from NLSR API cleint: %s \n",recv_buffer);
-					char *msg=process_api_client_command(recv_buffer);
-					send(fd, msg, strlen(msg),0);
-					free(msg);
-					close(fd);
-					FD_CLR(fd, &nlsr->readfds);
-				}
-			}
-		}
-	}
-
-	return 0;
-}
-
-void 
-nlsr_destroy( void )
-{
-	if ( nlsr->debugging )
-	{
-		printf("Freeing Allocated Memory....\n");
-	}	
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"Freeing Allocated Memory....\n");	
-	/* Destroying all face created by nlsr in CCND */
-	destroy_all_face_by_nlsr();	
-	destroy_faces_for_nbrs();
-	/* Destroying every hash table attached to each neighbor in ADL before destorying ADL */	
-	hashtb_destroy(&nlsr->npl);
-	hashtb_destroy(&nlsr->adl);	
-	hashtb_destroy(&nlsr->lsdb->name_lsdb);
-	hashtb_destroy(&nlsr->lsdb->adj_lsdb);
-	hashtb_destroy(&nlsr->pit_alsa);
-
-		
-
-	hashtb_destroy(&nlsr->routing_table);
-
-
-	int i, npt_element;
-	struct npt_entry *ne;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	hashtb_start(nlsr->npt, e);
-	npt_element=hashtb_n(nlsr->npt);
-	for(i=0;i<npt_element;i++)
-	{
-		ne=e->data;
-		hashtb_destroy(&ne->name_list);
-		hashtb_destroy(&ne->face_list);	
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-	hashtb_destroy(&nlsr->npt);
-
-
-	ccns_close(&nlsr->ccns, NULL, NULL);
-	ccns_slice_destroy(&nlsr->slice);
-
-
-
-	close(nlsr->nlsr_api_server_sock_fd);	
-
-	ccn_schedule_destroy(&nlsr->sched);
-	ccn_destroy(&nlsr->ccn);
-
-	free(nlsr->lsdb->lsdb_version);
-	free(nlsr->lsdb);
-	free(nlsr->router_name);
-	free(nlsr);
-	if ( nlsr->debugging )
-	{
-		printf("Finished freeing allocated memory\n");
-	}
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"Finished freeing allocated memory\n");
-
-}
-
-
-
-void
-init_api_server(int ccn_fd)
-{
-	int server_sockfd;
-	int server_len;
-	struct sockaddr_in server_address;
-	unsigned int yes=1;	
-
-	server_sockfd = socket(AF_INET, SOCK_STREAM, 0);
-
-	int flags = fcntl(server_sockfd, F_GETFL, 0);
-	fcntl(server_sockfd, F_SETFL, O_NONBLOCK|flags);
-
-	if (setsockopt(server_sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(yes)) < 0) 
-	{
-       		ON_ERROR_DESTROY(-1);
-       	}
-
-	server_address.sin_family = AF_INET;
-	server_address.sin_addr.s_addr = INADDR_ANY;
-	server_address.sin_port = htons(nlsr->api_port);
-
-	server_len = sizeof(server_address);
-	bind(server_sockfd, (struct sockaddr *)&server_address, server_len);
-	listen(server_sockfd, 100);
-	FD_ZERO(&nlsr->readfds);
-	FD_SET(server_sockfd, &nlsr->readfds);
-	FD_SET(ccn_fd, &nlsr->readfds);
-	nlsr->nlsr_api_server_sock_fd=server_sockfd;
-
-}
-
-int 
-init_nlsr(void)
-{
-	if (signal(SIGQUIT, nlsr_stop_signal_handler ) == SIG_ERR) 
-	{
-		perror("SIGQUIT install error\n");
-		return -1;
-	}
-	if (signal(SIGTERM, nlsr_stop_signal_handler ) == SIG_ERR) 
-	{
-		perror("SIGTERM install error\n");
-		return -1;
-    	}
- 	if (signal(SIGINT, nlsr_stop_signal_handler ) == SIG_ERR)
-	{
-		perror("SIGTERM install error\n");
-		return -1;
-	}
-
-	nlsr=(struct nlsr *)malloc(sizeof(struct nlsr));
-	
-	struct hashtb_param param_adl = {0};
-	nlsr->adl=hashtb_create(sizeof(struct ndn_neighbor), &param_adl);
-	struct hashtb_param param_npl = {0};
-	nlsr->npl = hashtb_create(sizeof(struct name_prefix_list_entry), &param_npl);
-	struct hashtb_param param_pit_alsa = {0};	
-	nlsr->pit_alsa = hashtb_create(sizeof(struct pending_interest), &param_pit_alsa);
-	struct hashtb_param param_npt = {0};	
-	nlsr->npt = hashtb_create(sizeof(struct npt_entry), &param_npt);
-	struct hashtb_param param_rte = {0};	
-	nlsr->routing_table = hashtb_create(sizeof(struct routing_table_entry), &param_rte);
-
-	nlsr->in_interest.p = &incoming_interest;
-	nlsr->in_content.p = &incoming_content;
-
-	nlsr->lsdb=(struct linkStateDatabase *)malloc(sizeof(struct linkStateDatabase));
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-	nlsr->lsdb->lsdb_version=(char *)malloc(strlen(time_stamp)+1);
-	memset(nlsr->lsdb->lsdb_version,0,strlen(time_stamp));
-	free(time_stamp);
-	
-	struct hashtb_param param_adj_lsdb = {0};
-	nlsr->lsdb->adj_lsdb = hashtb_create(sizeof(struct alsa), &param_adj_lsdb);
-	struct hashtb_param param_name_lsdb = {0};
-	nlsr->lsdb->name_lsdb = hashtb_create(sizeof(struct nlsa), &param_name_lsdb);
-	struct hashtb_param param_cor_lsdb = {0};
-	nlsr->lsdb->cor_lsdb = hashtb_create(sizeof(struct clsa), &param_cor_lsdb);
-	
-	
-
-
-	nlsr->is_synch_init=1;
-	nlsr->nlsa_id=0;
-	nlsr->adj_build_flag=0;
-	nlsr->adj_build_count=0;
-	nlsr->is_build_adj_lsa_sheduled=0;
-	nlsr->is_send_lsdb_interest_scheduled=0;
-	nlsr->is_route_calculation_scheduled=0;	
-
-	nlsr->detailed_logging=0;
-	nlsr->debugging=0;
-
-	nlsr->lsdb_synch_interval = LSDB_SYNCH_INTERVAL;
-	nlsr->interest_retry = INTEREST_RETRY;
-	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->semaphor=NLSR_UNLOCKED;
-
-	nlsr->api_port=API_PORT;
-
-	nlsr->topo_prefix=(char *)malloc(strlen("/ndn/routing/nlsr")+1);
-	memset(nlsr->topo_prefix,0,strlen("/ndn/routing/nlsr")+1);
-	memcpy(nlsr->topo_prefix,"/ndn/routing/nlsr",strlen("/ndn/routing/nlsr"));
-
-	nlsr->slice_prefix=(char *)malloc(strlen("/ndn/routing/nlsr/LSA")+1);
-	memset(nlsr->slice_prefix, 0, strlen("/ndn/routing/nlsr/LSA")+1);
-	memcpy(nlsr->slice_prefix,"/ndn/routing/nlsr/LSA",strlen("/ndn/routing/nlsr/LSA"));
-
-	nlsr->is_hyperbolic_calc=0;
-	nlsr->cor_r=-1.0;
-	nlsr->cor_theta=-1.0;
-
-	nlsr->tunnel_type=IPPROTO_UDP;
-
-	return 0;
-}
-
-
-int 
-main(int argc, char *argv[])
-{
-    	int res, ret;
-    	char *config_file;
-	int daemon_mode=0;
-	int port=0;
-
-	
-
-	while ((res = getopt_long(argc, argv, "df:p:h", longopts, 0)) != -1) 
-	{
-        	switch (res) 
-		{
-			case 'd':
-				daemon_mode = 1;
-				break;
-			case 'f':
-				config_file = optarg;
-				break;
-			case 'p':
-				port = atoi(optarg);
-				break;
-			case 'h':
-			default:
-				usage(argv[0]);
-		}
-    	}
-
-	ret=init_nlsr();	
-    	ON_ERROR_EXIT(ret);
-
-	if ( port !=0 )
-		nlsr->api_port=port;
-
-	readConfigFile(config_file);
-
-	if ( nlsr->is_hyperbolic_calc == 1 && (nlsr->cor_r == -1.0 && nlsr->cor_theta== -1.0) ) 	
-	{
-		fprintf(stderr,"Hyperbolic codinate has not been defined :(\n");
-		ON_ERROR_DESTROY(-1);
-	}
-	print_adjacent_from_adl();
-
-	if ( daemon_mode == 1 )
-	{
-		nlsr->debugging=0;
-		daemonize_nlsr();
-	}
-	
-	startLogging(nlsr->logDir);
-	
-	nlsr->ccn=ccn_create();
-	int ccn_fd=ccn_connect(nlsr->ccn, NULL);
-	if(ccn_fd == -1)
-	{
-		fprintf(stderr,"Could not connect to ccnd\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Could not connect to ccnd\n");
-		ON_ERROR_DESTROY(-1);
-	}
-
-	init_api_server(ccn_fd);
-
-	res=create_sync_slice(nlsr->topo_prefix, nlsr->slice_prefix);
-	if(res<0)
-	{
-		fprintf(stderr, "Can not create slice for prefix %s\n",nlsr->slice_prefix);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Can not create slice for prefix %s\n",nlsr->slice_prefix);
-		ON_ERROR_DESTROY(res);
-	}
-	struct ccn_charbuf *router_prefix;	
-	router_prefix=ccn_charbuf_create(); 
-	res=ccn_name_from_uri(router_prefix,nlsr->router_name);		
-	if(res<0)
-	{
-		fprintf(stderr, "Bad ccn URI: %s\n",nlsr->router_name);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Bad ccn URI: %s\n",nlsr->router_name);
-		ON_ERROR_DESTROY(res);
-	}
-
-	ccn_name_append_str(router_prefix,"nlsr");
-	nlsr->in_interest.data=nlsr->router_name;
-	res=ccn_set_interest_filter(nlsr->ccn,router_prefix,&nlsr->in_interest);
-	if ( res < 0 )
-	{
-		fprintf(stderr,"Failed to register interest for router\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Failed to register interest for router\n");
-		ON_ERROR_DESTROY(res);
-	}
-	ccn_charbuf_destroy(&router_prefix);
-	
-	if ( nlsr->debugging )
-		printf("Router Name : %s\n",nlsr->router_name);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"Router Name : %s\n",nlsr->router_name);
-	if ( nlsr->debugging )
-		printf("lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
-
-	add_faces_for_nbrs();
-	print_name_prefix_from_npl();
-	print_adjacent_from_adl();
-	build_and_install_name_lsas();	
-
-	sync_monitor(nlsr->topo_prefix,nlsr->slice_prefix);
-
-
-	print_name_lsdb();
-	build_and_install_cor_lsa();
-	write_name_lsdb_to_repo(nlsr->slice_prefix);
-
-	nlsr->sched = ccn_schedule_create(nlsr, &ndn_rtr_ticker);
-	nlsr->event_send_info_interest = ccn_schedule_event(nlsr->sched, 1, &send_info_interest, NULL, 0);
-	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
-
-	
-	while(1)
-	{	
-		if ( nlsr->semaphor == NLSR_UNLOCKED  )
-		{
-			if( nlsr->sched != NULL )
-			{
-				long int micro_sec=ccn_schedule_run(nlsr->sched);
-				res=nlsr_api_server_poll(micro_sec,ccn_fd);
-				ON_ERROR_DESTROY(res);
-			}
-			if(nlsr->ccn != NULL)
-			{
-        			res = ccn_run(nlsr->ccn, 1);
-			}
-			if (!(nlsr->sched && nlsr->ccn))
-			{	      
-				break;
-			}
-		}
-
-	}
-	
-
-	return 0;
-}
-
diff --git a/nlsr-sync-0.0/nlsr.conf b/nlsr-sync-0.0/nlsr.conf
deleted file mode 100755
index ced844f..0000000
--- a/nlsr-sync-0.0/nlsr.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-router-name /ndn/memphis.edu/netlab/macbook
-ccnneighbor /ndn/memphis.edu/netlab/pollux face2 10
-ccnneighbor /ndn/memphis.edu/netlab/castor face3 8
-ccnname /ndn/memphis.edu/netlab/macbook/name1
-ccnname /ndn/memphis.edu/netlab/macbook/test
-lsdb-synch-interval 310
-interest-retry 4
-interest-resend-time 5
-
-
diff --git a/nlsr-sync-0.0/nlsr.h b/nlsr-sync-0.0/nlsr.h
deleted file mode 100755
index b1b279f..0000000
--- a/nlsr-sync-0.0/nlsr.h
+++ /dev/null
@@ -1,131 +0,0 @@
-#ifndef _NLSR_H_
-#define _NLSR_H_
-
-
-#define LSDB_SYNCH_INTERVAL 300
-#define INTEREST_RETRY 3
-#define INTEREST_RESEND_TIME 15
-#define NLSR_LOCKED 1
-#define NLSR_UNLOCKED 0
-#define LSA_REFRESH_TIME 1800
-#define ROUTER_DEAD_INTERVAL 3600
-#define MULTI_PATH_FACE_NUM 0
-
-#define LINK_METRIC 10
-
-#define NAME_LSA_VALID 1
-#define NAME_LSA_INVALID 0
-
-#define API_PORT 9999
-
-
-struct name_prefix
-{
-	char *name;
-	int length;
-};
-
-struct linkStateDatabase
-{
-	struct hashtb *name_lsdb;
-	struct hashtb *adj_lsdb;
-	struct hashtb *cor_lsdb;
-	
-	char *lsdb_version;
-};
-
-struct pending_interest
-{
-	char *int_name;
-	int timed_out;
-};
-
-struct nlsr
-{
-
-	struct ccn_closure in_interest;
-	struct ccn_closure in_content;
-
-	struct ccns_name_closure *closure;
-
-	struct ccns_slice *slice;
-    	struct ccns_handle *ccns;
-
-	struct ccn_schedule *sched;
-    	struct ccn_scheduled_event *event;
-	struct ccn_scheduled_event *event_send_lsdb_interest;
-	struct ccn_scheduled_event *event_send_info_interest;
-	struct ccn_scheduled_event *event_build_name_lsa;
-	struct ccn_scheduled_event *event_build_adj_lsa;
-	struct ccn_scheduled_event *event_calculate_route;
-
-	struct hashtb *adl;
-	struct hashtb *npl;
-	struct hashtb *pit_alsa;
-	struct hashtb *map;
-	struct hashtb *rev_map;
-	struct hashtb *npt;
-	struct hashtb *routing_table;
-
-
-	struct linkStateDatabase *lsdb;
-
-	struct ccn *ccn;
-	char *router_name;
-
-	
-
-	int is_synch_init;
-	long int nlsa_id;
-	int adj_build_flag;
-	long int adj_build_count;
-	int is_build_adj_lsa_sheduled;
-	int is_send_lsdb_interest_scheduled;
-	int is_route_calculation_scheduled;
-
-	long int lsdb_synch_interval;
-	int interest_retry;
-	long int interest_resend_time;
-	long int lsa_refresh_time;
-	long int router_dead_interval;
-	long int multi_path_face_num;
-	char *logDir;
-	int detailed_logging;
-	int debugging;
-
-	int semaphor;
-
-	int nlsr_api_server_sock_fd;
-	fd_set readfds;
-	int api_port;
-
-	char *topo_prefix;
-	char *slice_prefix;
-
-	int is_hyperbolic_calc;
-	double cor_r;
-	double cor_theta;
-
-	int tunnel_type;
-	
-	
-};
-
-struct nlsr *nlsr;
-
-void process_command_ccnneighbor(char *command);
-void process_command_ccnname(char *command);
-void process_command_lsdb_synch_interval(char *command);
-void process_command_interest_retry(char *command);
-void process_command_interest_resend_time(char *command);
-void process_conf_command(char *command);
-int readConfigFile(const char *filename);
-
-void nlsr_lock(void);
-void nlsr_unlock(void);
-
-int init_nlsr(void);
-void nlsr_destroy( void );
-void nlsr_stop_signal_handler(int sig);
-
-#endif
diff --git a/nlsr-sync-0.0/nlsr_adl.c b/nlsr-sync-0.0/nlsr_adl.c
deleted file mode 100755
index 042466a..0000000
--- a/nlsr-sync-0.0/nlsr_adl.c
+++ /dev/null
@@ -1,978 +0,0 @@
-#include<stdio.h>
-#include<string.h>
-#include<stdlib.h>
-#include<math.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <assert.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-
-#include "nlsr.h"
-#include "nlsr_npl.h"
-#include "nlsr_adl.h"
-#include "utility.h"
-#include "nlsr_npt.h"
-
-void 
-add_nbr_to_adl(struct name_prefix *new_nbr,int face,char *ip)
-{
-	struct ndn_neighbor *nbr=(struct ndn_neighbor *)malloc(sizeof(struct ndn_neighbor )); //free
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->adl, e);
-    	res = hashtb_seek(e, new_nbr->name, new_nbr->length, 0);
-
-	if(res == HT_NEW_ENTRY )
-	{
-   
-		nbr = e->data;
-
-		nbr->neighbor=(struct name_prefix *)malloc(sizeof( struct name_prefix )); //free
-		nbr->neighbor->name=(char *)malloc(new_nbr->length);
-		memcpy(nbr->neighbor->name,new_nbr->name,new_nbr->length);
-		nbr->neighbor->length=new_nbr->length;
-		nbr->face=face;
-		nbr->status=NBR_DOWN;
-		nbr->info_interest_timed_out=0;
-		nbr->lsdb_interest_timed_out=0;
-		nbr->lsdb_random_time_component=(int)(LSDB_SYNCH_INTERVAL/2);
-		nbr->lsdb_synch_interval=LSDB_SYNCH_INTERVAL;
-		nbr->metric=LINK_METRIC;
-		nbr->is_lsdb_send_interest_scheduled=0;
-		
-		nbr->ip_address=(char *)malloc(13);
-		memset(nbr->ip_address,0,13);
-		memcpy(nbr->ip_address,ip,strlen(ip));
-
-		char *time_stamp=(char *)malloc(20);
-		get_current_timestamp_micro(time_stamp);
-		nbr->last_lsdb_version=(char *)malloc(strlen(time_stamp)+1); //free
-		memcpy(nbr->last_lsdb_version,time_stamp,strlen(time_stamp)+1);
-		memset(nbr->last_lsdb_version,'0',strlen(time_stamp));
-		nbr->last_info_version=(char *)malloc(strlen(time_stamp)+1); //free
-		memcpy(nbr->last_info_version,time_stamp,strlen(time_stamp)+1);
-		memset(nbr->last_info_version,'0',strlen(time_stamp));
-		free(time_stamp);		
-
-		nbr->last_lsdb_requested=0;
-	}
-
-    	hashtb_end(e);
-}
-
-
-void 
-print_adjacent(struct ndn_neighbor *nbr)
-{
-	if ( nlsr->debugging )
-	{
-		printf("print_adjacent called\n");
-		printf("--------Neighbor---------------------------\n");
-		printf("	Neighbor: %s \n",nbr->neighbor->name);
-		printf("	Length  : %d \n",nbr->neighbor->length);
-		printf("	Ip Address: %s \n",nbr->ip_address);
-		printf("	Face    : %d \n",nbr->face);
-		printf("	Metric    : %d \n",nbr->metric);
-		printf("	Status  : %d \n",nbr->status);
-		printf("	LSDB Version: %s \n",nbr->last_lsdb_version);
-		printf("	Info Version: %s \n",nbr->last_info_version);
-		printf("	Info Interest Timed Out : %d \n",nbr->info_interest_timed_out);
-		printf("	LSDB Interest Timed Out : %d \n",nbr->lsdb_interest_timed_out);
-		printf("	LSDB Synch Interval     : %ld \n",nbr->lsdb_synch_interval);
-		printf("	LSDB Random Time comp   : %d \n",nbr->lsdb_random_time_component);
-		printf("	Las Time LSDB Requested: %ld \n",nbr->last_lsdb_requested);
-		printf("	IS_lsdb_send_interest_scheduled : %d \n",nbr->is_lsdb_send_interest_scheduled);
-
-		printf("\n");
-	}
-
-	if ( nlsr->detailed_logging )
-	{
-		
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_adjacent called\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"--------Neighbor---------------------------\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Neighbor: %s \n",nbr->neighbor->name);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Length  : %d \n",nbr->neighbor->length);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Face    : %d \n",nbr->face);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Metric    : %d \n",nbr->metric);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Status  : %d \n",nbr->status);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LSDB Version: %s \n",nbr->last_lsdb_version);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Info Version: %s \n",nbr->last_info_version);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Info Interest Timed Out : %d \n",nbr->info_interest_timed_out);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LSDB Interest Timed Out : %d \n",nbr->lsdb_interest_timed_out);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LSDB Synch Interval     : %ld \n",nbr->lsdb_synch_interval);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LSDB Random Time comp   : %d \n",nbr->lsdb_random_time_component);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Las Time LSDB Requested: %ld \n",nbr->last_lsdb_requested);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"	IS_lsdb_send_interest_scheduled : %d \n",nbr->is_lsdb_send_interest_scheduled);
-
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-	}
-
-}
-
-void
-print_adjacent_from_adl(void)
-{
-	if ( nlsr->debugging )
-		printf("print_adjacent_from_adl called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_adjacent_from_adl called \n");		
-	
-	int i, adl_element;
-	struct ndn_neighbor *nbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-		print_adjacent(nbr);	
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-int 
-get_adjacent_status(struct name_prefix *nbr)
-{
-
-	if ( nlsr->debugging )
-		printf("get_adjacent_status called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adjacent_status called \n");
-
-	int res;
-	int status=-1;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		status=nnbr->status;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return status;
-
-}
-
-int 
-get_timed_out_number(struct name_prefix *nbr)
-{
-
-	if ( nlsr->debugging )
-		printf("get_timed_out_number called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_timed_out_number called \n");
-
-
-	int res,ret=-1;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		ret=nnbr->info_interest_timed_out;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return ret;	
-}
-
-int 
-get_lsdb_interest_timed_out_number(struct name_prefix *nbr)
-{
-
-	if ( nlsr->debugging )
-		printf("get_lsdb_interest_timed_out_number called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_lsdb_interest_timed_out_number called \n");
-
-	int res,ret=-1;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		ret=nnbr->lsdb_interest_timed_out;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return ret;	
-}
-
-void 
-update_adjacent_timed_out_to_adl(struct name_prefix *nbr, int increment)
-{
-	if ( nlsr->debugging )
-		printf("update_adjacent_timed_out_to_adl called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_to_adl called \n");
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		nnbr->info_interest_timed_out += increment;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-void 
-update_adjacent_timed_out_zero_to_adl(struct name_prefix *nbr)
-{
-	if ( nlsr->debugging )
-		printf("update_adjacent_timed_out_zero_to_adl called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_zero_to_adl called \n");
-	
-	int time_out_number=get_timed_out_number(nbr);
-	update_adjacent_timed_out_to_adl(nbr,-time_out_number);
-
-}
-
-
-void 
-update_lsdb_interest_timed_out_to_adl(struct name_prefix *nbr, int increment)
-{
-	if ( nlsr->debugging )
-		printf("update_lsdb_interest_timed_out_to_adl called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_lsdb_interest_timed_out_to_adl called \n");
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-
-	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		nnbr->lsdb_interest_timed_out += increment;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}		
-	hashtb_end(e);
-}
-
-void 
-update_lsdb_interest_timed_out_zero_to_adl(struct name_prefix *nbr)
-{
-	if ( nlsr->debugging )
-		printf("update_adjacent_timed_out_zero_to_adl called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_zero_to_adl called\n");
-	
-	int time_out_number=get_lsdb_interest_timed_out_number(nbr);
-	update_lsdb_interest_timed_out_to_adl(nbr,-time_out_number);
-
-}
-
-void 
-update_adjacent_status_to_adl(struct name_prefix *nbr, int status)
-{
-	if ( nlsr->debugging )
-		printf("update_adjacent_status_to_adl called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_status_to_adl called \n");
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-   	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		if ( nnbr->status!=status )
-		{
-			nnbr->status=status;
-			nlsr->adj_build_flag++;
-		}
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-
-void 
-delete_nbr_from_adl(struct name_prefix *nbr)
-{
-	if ( nlsr->debugging )
-		printf("delete_nbr_from_adl called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_nbr_from_adl called \n");
-
-	int res;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-   	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-
-	if (res == HT_OLD_ENTRY)
-	{
-		hashtb_delete(e);	
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-void 
-update_lsdb_synch_interval_to_adl(struct name_prefix *nbr, long int interval)
-{
-	if ( nlsr->debugging )
-		printf("update_lsdb_synch_interval_to_adl called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_lsdb_synch_interval_to_adl called \n");
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-   	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		if ( nnbr->lsdb_synch_interval!= interval )
-		{
-			nnbr->lsdb_synch_interval=interval;
-			nnbr->lsdb_random_time_component=(int)(interval/2);
-
-		}
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-
-int 
-no_active_nbr(void)
-{
-	int i, adl_element;
-	int no_link=0;
-	struct ndn_neighbor *nbr;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-		if( nbr->status	== 1 )
-			no_link++;
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-	return no_link;
-
-}
-
-int
-is_adj_lsa_build(void)
-{
-	int ret=0;
-
-	int nbr_count=0;	
-
-	int i, adl_element;
-	struct ndn_neighbor *nbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-		if(nbr->status	== 1 )
-		{
-			nbr_count++;
-		}
-		else if ( (nbr->status == 0) && (nbr->info_interest_timed_out >= nlsr->interest_retry || nbr->lsdb_interest_timed_out >= nlsr->interest_retry))
-		{
-			nbr_count++;
-		}
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-	if(nbr_count == adl_element)
-		ret=1;
-
-	return ret;
-}
-
-
-void 
-get_active_nbr_adj_data(struct ccn_charbuf *c)
-{
-
-	int i, adl_element;
-	struct ndn_neighbor *nbr;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-		if( nbr->status	== 1 )
-		{
-			ccn_charbuf_append_string(c,nbr->neighbor->name);
-			ccn_charbuf_append_string(c,"|");
-
-			char *temp_length=(char *)malloc(20);
-			memset(temp_length,0,20);
-			sprintf(temp_length,"%d",nbr->neighbor->length);
-			ccn_charbuf_append_string(c,temp_length);
-			free(temp_length);
-			ccn_charbuf_append_string(c,"|");
-
-			char *temp_face=(char *)malloc(20);
-			memset(temp_face,0,20);
-			sprintf(temp_face,"%d",nbr->face);
-			ccn_charbuf_append_string(c,temp_face);
-			free(temp_face);
-			ccn_charbuf_append_string(c,"|");
-
-			char *temp_metric=(char *)malloc(20);
-			memset(temp_metric,0,20);
-			sprintf(temp_metric,"%d",nbr->metric);
-			ccn_charbuf_append_string(c,temp_metric);
-			free(temp_metric);
-			ccn_charbuf_append_string(c,"|");
-
-		}
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-}
-
-long int
-get_nbr_time_diff_lsdb_req(char *nbr)
-{
-	if ( nlsr->debugging )
-		printf("get_nbr_time_diff_lsdb_req called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr_time_diff_lsdb_req called\n");
-
-	long int time_diff=get_lsdb_synch_interval(nbr)+1;	
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-
-		if (nnbr->last_lsdb_requested == 0)
-			time_diff=get_lsdb_synch_interval(nbr)+1;
-		else time_diff=get_current_time_sec() - get_nbr_last_lsdb_requested(nbr);
-
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return time_diff;
-}
-
-long int 
-get_nbr_last_lsdb_requested(char *nbr)
-{
-	if ( nlsr->debugging )
-		printf("get_timed_out_number called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_timed_out_number called\n");
-
-	long int last_lsdb_requested=0;
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		last_lsdb_requested=nnbr->last_lsdb_requested;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return last_lsdb_requested;
-}
-
-
-int 
-get_nbr_random_time_component(char *nbr)
-{
-	if ( nlsr->debugging )
-		printf("get_nbr_random_time_component called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr_random_time_component called\n");
-
-	int time=0;
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		time=nnbr->lsdb_random_time_component * (int)pow(-1,nnbr->lsdb_interest_timed_out+1);
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return time;
-}
-
-long int 
-get_lsdb_synch_interval(char *nbr)
-{
-	if ( nlsr->debugging )
-		printf("get_lsdb_synch_interval called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_lsdb_synch_interval called \n");
-
-	long int lsdb_synch_interval=300;	
-
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		lsdb_synch_interval=nnbr->lsdb_synch_interval;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return lsdb_synch_interval;
-
-}
-
-char *
-get_nbr_lsdb_version(char *nbr)
-{
-	if ( nlsr->debugging )
-		printf("get_nbr_lsdb_version called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr_lsdb_version called \n");
-
-	char *version=NULL;
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		version=(char *)malloc(strlen(nnbr->last_lsdb_version)+1);
-		memset(version,0,strlen(nnbr->last_lsdb_version)+1);
-		memcpy(version,nnbr->last_lsdb_version,strlen(nnbr->last_lsdb_version)+1);
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return version;
-}
-
-void 
-update_adjacent_last_lsdb_requested_to_adl(char *nbr, long int timestamp)
-{
-	if ( nlsr->debugging )
-		printf("update_adjacent_last_lsdb_requested_to_adl called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_last_lsdb_requested_to_adl called \n");
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		nnbr->last_lsdb_requested=timestamp;
-
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-void 
-set_is_lsdb_send_interest_scheduled_to_zero(char *nbr)
-{
-	if ( nlsr->debugging )
-		printf("set_is_lsdb_send_interest_scheduled_to_zero called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"set_is_lsdb_send_interest_scheduled_to_zero called\n");
-
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if (res == HT_OLD_ENTRY)
-	{
-		nnbr=e->data;
-		nnbr->is_lsdb_send_interest_scheduled=0;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-void 
-update_adjacent_lsdb_version_to_adl(struct name_prefix *nbr, char *version)
-{
-	if ( nlsr->debugging )
-		printf("update_adjacent_timed_out_to_adl called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_timed_out_to_adl called\n");
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr->name, nbr->length, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		free(nnbr->last_lsdb_version);
-		nnbr->last_lsdb_version=(char *)malloc(strlen(version)+1);
-		memset(nnbr->last_lsdb_version,0,strlen(version)+1);
-		memcpy(nnbr->last_lsdb_version,version,strlen(version)+1);
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-}
-
-void 
-adjust_adjacent_last_lsdb_requested_to_adl(char *nbr, long int sec)
-{
-	printf("update_adjacent_last_lsdb_requested_to_adl called \n");
-
-	if ( nlsr->debugging )
-		printf("update_adjacent_last_lsdb_requested_to_adl called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_adjacent_last_lsdb_requested_to_adl called\n");
-
-
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		nnbr->last_lsdb_requested=nnbr->last_lsdb_requested-sec;
-
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-}
-
-int 
-get_next_hop_face_from_adl(char *nbr)
-{
-	int res;
-	int connecting_face=NO_FACE;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		connecting_face=nnbr->face;
-		
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-	return connecting_face;
-}
-
-void
-update_face_to_adl_for_nbr(char *nbr, int face)
-{
-	int res;
-	struct ndn_neighbor *nnbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nnbr=e->data;
-		nnbr->face=face;
-		
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-int 
-is_neighbor(char *nbr)
-{
-	int ret=0;
-
-	int res;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		ret=1;	
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return ret;
-}
-
-int 
-is_active_neighbor(char *nbr)
-{
-	int ret=0;
-
-	int res;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->adl, e);
-	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		struct ndn_neighbor *nnbr;
-		nnbr=e->data;
-		if (nnbr->status == NBR_ACTIVE )
-		{
-			ret=1;	
-		}
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-
-	return ret;
-}
-
diff --git a/nlsr-sync-0.0/nlsr_adl.h b/nlsr-sync-0.0/nlsr_adl.h
deleted file mode 100755
index 1eb74d6..0000000
--- a/nlsr-sync-0.0/nlsr_adl.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef _NLSR_ADL_H_
-#define _NLSR_ADL_H_
-
-#define NBR_DOWN 0
-#define NBR_ACTIVE 1
-
-struct ndn_neighbor
-{
-	struct name_prefix *neighbor;
-	int face;
-	int status;
-	char * last_lsdb_version;
-	char * last_info_version;
-	char *ip_address;
-	int info_interest_timed_out;
-	int lsdb_interest_timed_out;
-	int lsdb_random_time_component;
-	long int lsdb_synch_interval;
-	long int last_lsdb_requested;
-	int is_lsdb_send_interest_scheduled;
-	int metric;
-};
-
-void add_nbr_to_adl(struct name_prefix *new_nbr,int face,char *ip);
-void delete_nbr_from_adl(struct name_prefix *nbr);
-void print_adjacent(struct ndn_neighbor *nbr);
-void print_adjacent_from_adl(void);
-int get_adjacent_status(struct name_prefix *nbr);
-int get_timed_out_number(struct name_prefix *nbr);
-int get_lsdb_interest_timed_out_number(struct name_prefix *nbr);
-void update_adjacent_timed_out_to_adl(struct name_prefix *nbr, int increment);
-void update_adjacent_timed_out_zero_to_adl(struct name_prefix *nbr);
-void update_lsdb_interest_timed_out_to_adl(struct name_prefix *nbr, int increment);
-void update_lsdb_interest_timed_out_zero_to_adl(struct name_prefix *nbr);
-void update_adjacent_status_to_adl(struct name_prefix *nbr, int status);
-void update_lsdb_synch_interval_to_adl(struct name_prefix *nbr, long int interval);
-int no_active_nbr(void);
-int is_adj_lsa_build(void);
-void get_active_nbr_adj_data(struct ccn_charbuf *c);
-long int get_nbr_time_diff_lsdb_req(char *nbr);
-long int get_nbr_last_lsdb_requested(char *nbr);
-long int get_nbr_last_lsdb_requested(char *nbr);
-long int get_lsdb_synch_interval(char *nbr);
-int get_nbr_random_time_component(char *nbr);
-char * get_nbr_lsdb_version(char *nbr);
-void update_adjacent_last_lsdb_requested_to_adl(char *nbr, long int timestamp);
-void set_is_lsdb_send_interest_scheduled_to_zero(char *nbr);
-void update_adjacent_lsdb_version_to_adl(struct name_prefix *nbr, char *version);
-void adjust_adjacent_last_lsdb_requested_to_adl(char *nbr, long int sec);
-int get_next_hop_face_from_adl(char *nbr);
-int is_neighbor(char *nbr);
-int is_active_neighbor(char *nbr);
-void update_face_to_adl_for_nbr(char *nbr, int face);
-#endif
diff --git a/nlsr-sync-0.0/nlsr_fib.c b/nlsr-sync-0.0/nlsr_fib.c
deleted file mode 100755
index 6ef81cb..0000000
--- a/nlsr-sync-0.0/nlsr_fib.c
+++ /dev/null
@@ -1,231 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/face_mgmt.h>
-#include <ccn/reg_mgmt.h>
-#include <ccn/charbuf.h>
-
-#include "nlsr_fib.h"
-#include "nlsr.h"
-
-
-static void 
-ccn_fib_warn(int lineno, const char *format, ...)
-{
-	struct timeval t;
-	va_list ap;
-	va_start(ap, format);
-	gettimeofday(&t, NULL);
-	fprintf(stderr, "%d.%06d ccn_fib[%d]:%d: ", (int)t.tv_sec, (unsigned)t.tv_usec, (int)getpid(), lineno);
-	vfprintf(stderr, format, ap);
-	va_end(ap);
-}
-
-#define ON_ERROR_CLEANUP(resval) \
-{           \
-    if ((resval) < 0) { \
-        ccn_fib_warn (__LINE__, "OnError cleanup\n"); \
-        goto cleanup; \
-    } \
-}
-
-#define ON_NULL_CLEANUP(resval) \
-{           \
-    if ((resval) == NULL) { \
-        ccn_fib_warn(__LINE__, "OnNull cleanup\n"); \
-        goto cleanup; \
-    } \
-}
-
-
-
-static int 
-register_unregister_prefix(struct ccn *h, struct ccn_charbuf *local_scope_template,
-        struct ccn_charbuf *no_name, struct ccn_charbuf *name_prefix,const unsigned char *ccndid, size_t ccnd_id_size, int faceid, int operation)
-{
-	struct ccn_charbuf *temp = NULL;
-	struct ccn_charbuf *resultbuf = NULL;
-	struct ccn_charbuf *signed_info = NULL;
-	struct ccn_charbuf *name = NULL;
-	struct ccn_charbuf *prefixreg = NULL;
-	struct ccn_parsed_ContentObject pcobuf = {0};
-	struct ccn_forwarding_entry forwarding_entry_storage = {0};
-	struct ccn_forwarding_entry *forwarding_entry = &forwarding_entry_storage;
-	struct ccn_forwarding_entry *new_forwarding_entry;
-	const unsigned char *ptr = NULL;
-	size_t length = 0;
-	int res;
-
-	/* Register or unregister the prefix */
-	forwarding_entry->action = (operation == OP_REG) ? "prefixreg" : "unreg";
-	forwarding_entry->name_prefix = name_prefix;
-	forwarding_entry->ccnd_id = ccndid;
-	forwarding_entry->ccnd_id_size =ccnd_id_size;
-	forwarding_entry->faceid = faceid;
-	forwarding_entry->flags = -1;
-	forwarding_entry->lifetime = 2100;
-
-	prefixreg = ccn_charbuf_create();
-	ccnb_append_forwarding_entry(prefixreg, forwarding_entry);
-	temp = ccn_charbuf_create();
-	res = ccn_sign_content(h, temp, no_name, NULL, prefixreg->buf, prefixreg->length);
-	resultbuf = ccn_charbuf_create();
-
-	/* construct Interest containing prefixreg request */
-	name = ccn_charbuf_create();
-	ccn_name_init(name);
-	ccn_name_append_str(name, "ccnx");
-	ccn_name_append(name, ccndid, ccnd_id_size);
-	ccn_name_append_str(name, (operation == OP_REG) ? "prefixreg" : "unreg");
-	ccn_name_append(name, temp->buf, temp->length);
-
-	/* send Interest, get Data */
-	res = ccn_get(h, name, local_scope_template, 1000, resultbuf, &pcobuf, NULL, 0);
-	ON_ERROR_CLEANUP(res);
-
-	res = ccn_content_get_value(resultbuf->buf, resultbuf->length, &pcobuf, &ptr, &length);
-	ON_ERROR_CLEANUP(res);
-    
-	/* extract new forwarding entry from Data */
-	new_forwarding_entry = ccn_forwarding_entry_parse(ptr, length);
-	ON_NULL_CLEANUP(new_forwarding_entry);
-
-	res = new_forwarding_entry->faceid;
-
-	ccn_forwarding_entry_destroy(&new_forwarding_entry);
-	ccn_charbuf_destroy(&signed_info);
-	ccn_charbuf_destroy(&temp);
-	ccn_charbuf_destroy(&resultbuf);
-	ccn_charbuf_destroy(&name);
-	ccn_charbuf_destroy(&prefixreg);
-
-	return res;
-
-	cleanup:
-		ccn_forwarding_entry_destroy(&new_forwarding_entry);
-		ccn_charbuf_destroy(&signed_info);
-		ccn_charbuf_destroy(&temp);
-		ccn_charbuf_destroy(&resultbuf);
-		ccn_charbuf_destroy(&name);
-		ccn_charbuf_destroy(&prefixreg);
-
-	return -1;
-}
-
-
-static int 
-get_ccndid(struct ccn *h, struct ccn_charbuf *local_scope_template,
-        unsigned char *ccndid)
-{
-	struct ccn_charbuf *name = NULL;
-	struct ccn_charbuf *resultbuf = NULL;
-	struct ccn_parsed_ContentObject pcobuf = {0};
-	char ccndid_uri[] = "ccnx:/%C1.M.S.localhost/%C1.M.SRV/ccnd/KEY";
-	const unsigned char *ccndid_result;
-	static size_t ccndid_result_size;
-	int res;
-
-	name = ccn_charbuf_create();
-	resultbuf = ccn_charbuf_create();
-
-	res = ccn_name_from_uri(name, ccndid_uri);
-	ON_ERROR_CLEANUP(res);
-
-	/* get Data */
-	res = ccn_get(h, name, local_scope_template, 4500, resultbuf, &pcobuf, NULL, 0);
-	ON_ERROR_CLEANUP(res);
-
-	/* extract from Data */
-	res = ccn_ref_tagged_BLOB(CCN_DTAG_PublisherPublicKeyDigest,
-            resultbuf->buf,
-            pcobuf.offset[CCN_PCO_B_PublisherPublicKeyDigest],
-            pcobuf.offset[CCN_PCO_E_PublisherPublicKeyDigest],
-            &ccndid_result, &ccndid_result_size);
-	ON_ERROR_CLEANUP(res);
-
-	memcpy((void *)ccndid, ccndid_result, ccndid_result_size);
-
-	ccn_charbuf_destroy(&name);
-	ccn_charbuf_destroy(&resultbuf);
-
-	return (ccndid_result_size);
-
-	cleanup:
-		ccn_charbuf_destroy(&name);
-		ccn_charbuf_destroy(&resultbuf);
-
-	return -1;
-}
-
-static void 
-init_data(struct ccn_charbuf *local_scope_template,
-        struct ccn_charbuf *no_name)
-{
-	ccn_charbuf_append_tt(local_scope_template, CCN_DTAG_Interest, CCN_DTAG);
-	ccn_charbuf_append_tt(local_scope_template, CCN_DTAG_Name, CCN_DTAG);
-	ccn_charbuf_append_closer(local_scope_template);    /* </Name> */
-	ccnb_tagged_putf(local_scope_template, CCN_DTAG_Scope, "1");
-	ccn_charbuf_append_closer(local_scope_template);    /* </Interest> */
-
-	ccn_name_init(no_name);
-}
-
-int 
-add_delete_ccn_face_by_face_id(struct ccn *h, const char *uri, int operation, int faceid)
-{
-	if ( nlsr->debugging )
-	{
-		printf("add_delete_ccn_face_by_face_id called\n");
-		printf("Uri: %s  Face: %d Operation: %s \n",(char *)uri , faceid, operation == OP_REG ? "Registration" : "Unregistration");
-	}
-
-	struct ccn_charbuf *prefix;
-	struct ccn_charbuf *local_scope_template = ccn_charbuf_create();
-	struct ccn_charbuf *no_name = ccn_charbuf_create();
-	unsigned char ccndid_storage[32] = {0};
-	unsigned char *ccndid = ccndid_storage;
-	size_t ccndid_size = 0;
-	int res;
-
-	prefix = ccn_charbuf_create();
-	res = ccn_name_from_uri(prefix, uri);
-	ON_ERROR_CLEANUP(res);
-
-
-	init_data(local_scope_template, no_name);
-
-	ccndid_size = get_ccndid(h, local_scope_template, ccndid);
-	if (ccndid_size != sizeof(ccndid_storage))
- 	{
-		fprintf(stderr, "Incorrect size for ccnd id in response\n");
-		ON_ERROR_CLEANUP(-1);
-	}
-
-	res = register_unregister_prefix(h, local_scope_template, no_name, prefix,ccndid, ccndid_size,faceid, operation);
-	
-	ON_ERROR_CLEANUP(res);
-
-	ccn_charbuf_destroy(&local_scope_template);
-	ccn_charbuf_destroy(&no_name);
-	ccn_charbuf_destroy(&prefix);
-
-	return 0;
-
-	cleanup:
-		ccn_charbuf_destroy(&prefix);
-		ccn_charbuf_destroy(&local_scope_template);
-		ccn_charbuf_destroy(&no_name);
-
-	return -1;
-}
-
-
diff --git a/nlsr-sync-0.0/nlsr_fib.h b/nlsr-sync-0.0/nlsr_fib.h
deleted file mode 100755
index ce5e6d1..0000000
--- a/nlsr-sync-0.0/nlsr_fib.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _NLSR_FIB_H_
-#define _NLSR_FIB_H_
-
-#define CCN_FIB_LIFETIME ((~0U) >> 1)
-#define CCN_FIB_MCASTTTL (-1)
-#define OP_REG  0
-#define OP_UNREG 1
-
-int add_delete_ccn_face_by_face_id(struct ccn *h, const char *uri, int operation, int faceid);
-
-#endif
diff --git a/nlsr-sync-0.0/nlsr_lsdb.c b/nlsr-sync-0.0/nlsr_lsdb.c
deleted file mode 100755
index e36a922..0000000
--- a/nlsr-sync-0.0/nlsr_lsdb.c
+++ /dev/null
@@ -1,2519 +0,0 @@
-#include<stdio.h>
-#include<string.h>
-#include<stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <assert.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-
-#include "nlsr.h"
-#include "nlsr_ndn.h"
-#include "nlsr_lsdb.h"
-#include "utility.h"
-#include "nlsr_npl.h"
-#include "nlsr_adl.h"
-#include "nlsr_route.h"
-#include "nlsr_npt.h"
-#include "nlsr_sync.h"
-
-void
-set_new_lsdb_version(void)
-{
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-	
-	free(nlsr->lsdb->lsdb_version);
-	nlsr->lsdb->lsdb_version=(char *)malloc(strlen(time_stamp)+1);
-	memset(nlsr->lsdb->lsdb_version,0,strlen(time_stamp)+1);
-	memcpy(nlsr->lsdb->lsdb_version,time_stamp,strlen(time_stamp)+1);
-
-	free(time_stamp);
-	
-}
-
-void 
-make_name_lsa_key(char *key, char *orig_router, int ls_type, long int ls_id)
-{
-	
-	char lst[2];
-	memset(lst,0,2);
-	sprintf(lst,"%d",ls_type);	
-
-	char lsid[10];
-	memset(lsid,0,10);
-	sprintf(lsid,"%ld",ls_id);
-	
-	memcpy(key+strlen(key),orig_router,strlen(orig_router));
-	memcpy(key+strlen(key),"/",1);
-	memcpy(key+strlen(key),lst,strlen(lst));
-	memcpy(key+strlen(key),"/",1);
-	memcpy(key+strlen(key),lsid,strlen(lsid));
-	
-	if ( nlsr->debugging )
-		printf("name LSA Key: %s\n", key);
-}
-
-
-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);
-	
-	if ( nlsr->debugging )
-		printf("Name LSA prefix for repo content: %s\n",key);
-}
-
-void 
-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);	
-
-	if ( nlsr->debugging )
-		printf("Name LSA prefix for repo content:%s\n",key);	
-}
-
-void 
-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);	
-
-	if ( nlsr->debugging )
-		printf("Cor LSA prefix for repo content:%s\n",key);	
-}
-
-void 
-build_and_install_name_lsas(void)
-{
-	if ( nlsr->debugging )
-		printf("build_and_install_name_lsas called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_name_lsas called\n");
-
-	int i, npl_element;
-	struct name_prefix_list_entry *npe;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npl, e);
-	npl_element=hashtb_n(nlsr->npl);
-
-	for(i=0;i<npl_element;i++)
-	{
-		npe=e->data;
-		struct nlsa *name_lsa=(struct nlsa *)malloc(sizeof( struct nlsa ));
-		build_name_lsa(name_lsa,npe->np);
-		
-		install_name_lsa(name_lsa);
-		update_nlsa_id_for_name_in_npl(npe->np,name_lsa->header->ls_id);
-		free(name_lsa->header->orig_router->name);
-		free(name_lsa->header->orig_router);
-		free(name_lsa->header);
-		free(name_lsa->name_prefix->name);
-		free(name_lsa->name_prefix);
-		free(name_lsa);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);	
-	
-	print_name_prefix_from_npl();
-
-}
-
-void 
-build_and_install_single_name_lsa(struct name_prefix *np)
-{
-	if ( nlsr->debugging )
-		printf("build_and_install_single_name_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_single_name_lsa called\n");
-	
-	struct nlsa *name_lsa=(struct nlsa *)malloc(sizeof( struct nlsa ));
-	build_name_lsa(name_lsa,np);
-		
-	install_name_lsa(name_lsa);
-	update_nlsa_id_for_name_in_npl(np,name_lsa->header->ls_id);
-
-	free(name_lsa->header->orig_router->name);
-	free(name_lsa->header->orig_router);
-	free(name_lsa->header);
-	free(name_lsa->name_prefix->name);
-	free(name_lsa->name_prefix);
-	free(name_lsa);
-	
-	print_name_prefix_from_npl();
-
-}
-
-void 
-build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np)
-{
-	name_lsa->header=(struct nlsa_header *)malloc(sizeof(struct nlsa_header ));
-	name_lsa->header->ls_type=LS_TYPE_NAME;
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-
-	name_lsa->header->orig_time=(char *)malloc(strlen(time_stamp)+1); //free 
-	memset(name_lsa->header->orig_time,0,strlen(time_stamp)+1);
-	memcpy(name_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);
-	
-	free(time_stamp);
-
-	name_lsa->header->ls_id=++nlsr->nlsa_id;
-	name_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	name_lsa->header->orig_router->name=(char *)malloc(strlen(nlsr->router_name)+1);
-	memset(name_lsa->header->orig_router->name,0,strlen(nlsr->router_name)+1);
-	memcpy(name_lsa->header->orig_router->name,nlsr->router_name,strlen(nlsr->router_name)+1);
-	name_lsa->header->orig_router->length=strlen(nlsr->router_name)+1;
-	name_lsa->header->isValid=1;
-
-	
-	name_lsa->name_prefix=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	name_lsa->name_prefix->name=(char *)malloc(np->length);
-	memcpy(name_lsa->name_prefix->name,np->name,np->length);
-	name_lsa->name_prefix->length=np->length;
-
-}
-
-void 
-install_name_lsa(struct nlsa *name_lsa)
-{
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-	
-
-		char lst[2];
-		memset(lst,0,2);
-		sprintf(lst,"%d",name_lsa->header->ls_type);	
-
-		char lsid[10];
-		memset(lsid,0,10);
-		sprintf(lsid,"%ld",name_lsa->header->ls_id);
-	
-	
-		char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-		memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-
-
-		make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
-		if ( nlsr->debugging )
-			printf("Key:%s Length:%d\n",key,(int)strlen(key));
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Key:%s Length:%d\n",key,(int)strlen(key));	
-		
-
-		struct nlsa *new_name_lsa=(struct nlsa*)malloc(sizeof(struct nlsa )); //free
-
-		struct hashtb_enumerator ee;
-    		struct hashtb_enumerator *e = &ee; 	
-    		int res;
-
-   		hashtb_start(nlsr->lsdb->name_lsdb, e);
-    		res = hashtb_seek(e, key, strlen(key), 0);
-
-		if(res == HT_NEW_ENTRY )
-		{
-		
-			if ( nlsr->debugging )
-				printf("New Name LSA... Adding to LSDB\n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Name LSA... Adding to LSDB\n");
-
-
-			new_name_lsa = e->data;
-
-			new_name_lsa->header=(struct nlsa_header *)malloc(sizeof(struct nlsa_header )); //free
-			new_name_lsa->header->ls_type=name_lsa->header->ls_type;
-
-			new_name_lsa->header->orig_time=(char *)malloc(strlen(name_lsa->header->orig_time)+1);
-			memset(new_name_lsa->header->orig_time,0,strlen(name_lsa->header->orig_time)+1);
-			memcpy(new_name_lsa->header->orig_time,name_lsa->header->orig_time,strlen(name_lsa->header->orig_time)+1);
-
-			new_name_lsa->header->ls_id=name_lsa->header->ls_id;
-			new_name_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix )); //free
-			new_name_lsa->header->orig_router->name=(char *)malloc(name_lsa->header->orig_router->length);
-			memcpy(new_name_lsa->header->orig_router->name,name_lsa->header->orig_router->name,name_lsa->header->orig_router->length);
-			new_name_lsa->header->orig_router->length=name_lsa->header->orig_router->length;
-			new_name_lsa->header->isValid=name_lsa->header->isValid;
-
-	
-			new_name_lsa->name_prefix=(struct name_prefix *)malloc(sizeof(struct name_prefix )); //free
-			new_name_lsa->name_prefix->name=(char *)malloc(name_lsa->name_prefix->length);
-			memcpy(new_name_lsa->name_prefix->name,name_lsa->name_prefix->name,name_lsa->name_prefix->length);
-			new_name_lsa->name_prefix->length=name_lsa->name_prefix->length;
-
-			if ( nlsr->debugging )
-			{
-				printf("New Name LSA Added....\n");	
-				printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-			}
-			if ( nlsr->detailed_logging )
-			{
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Name LSA Added....\n");	
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-			}
-			set_new_lsdb_version();	
-			if ( nlsr->debugging )
-				printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);	
-
-			
-			int num_next_hop=get_number_of_next_hop(new_name_lsa->header->orig_router->name);
-			if ( num_next_hop < 0 )
-			{
-				int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,NO_NEXT_HOP,NULL,NULL);
-				if ( check == HT_NEW_ENTRY )
-				{
-					if ( nlsr->debugging )
-						printf("Added in npt \n");
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
-				}
-			}
-			else 
-			{
-				int *faces=malloc(num_next_hop*sizeof(int));
-				int *route_costs=malloc(num_next_hop*sizeof(int));			
-				int next_hop=get_next_hop(new_name_lsa->header->orig_router->name,faces,route_costs);
-				if ( nlsr->debugging )
-				{
-					printf("Printing from install_name_lsa \n");
-					int j;
-					for(j=0;j<num_next_hop;j++)
-						printf("Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
-				}
-				if ( nlsr->detailed_logging )
-				{
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Printing from install_name_lsa \n");
-					int j;
-					for(j=0;j<num_next_hop;j++)
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
-				}
-				int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,next_hop,faces,route_costs);
-				if ( check == HT_NEW_ENTRY )
-				{
-					if ( nlsr->debugging )
-						printf("Added in npt \n");
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
-				}
-				free(faces);
-				free(route_costs);
-
-			}
-			
-			writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-			writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding name lsa\n");
-			write_log_for_name_lsa(new_name_lsa);
-			writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
-		
-			free(time_stamp);
-
-		}
-		else if(res == HT_OLD_ENTRY)
-		{
-			new_name_lsa=e->data;
-			if(strcmp(name_lsa->header->orig_time,new_name_lsa->header->orig_time)<0)
-			{
-				if ( nlsr->debugging )
-					printf("Older Adj LSA. Discarded... \n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Older Adj LSA. Discarded...\n");
-			}
-			else if( strcmp(name_lsa->header->orig_time,new_name_lsa->header->orig_time) == 0 )
-			{
-				if ( nlsr->debugging )
-					printf("Duplicate Adj LSA. Discarded... \n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Duplicate Adj LSA. Discarded...\n");
-			}
-			else 
-			{
-				if ( name_lsa->header->isValid == 0 )
-				{
-					// have to call to delete npt table entry
-					delete_npt_entry_by_router_and_name_prefix(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name);
-				
-					if ( strcmp(name_lsa->header->orig_router->name,nlsr->router_name)!= 0)
-					{
-						writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-						writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
-						write_log_for_name_lsa(new_name_lsa);
-						writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
-						
-						hashtb_delete(e);
-						if ( nlsr->debugging )
-							printf("isValid bit not set for Router %s so LSA Deleted from LSDB\n",name_lsa->header->orig_router->name);
-						if ( nlsr->detailed_logging )
-							writeLogg(__FILE__,__FUNCTION__,__LINE__,"isValid bit not set for Router %s so LSA Deleted from LSDB\n",name_lsa->header->orig_router->name);
-					}
-					else 
-					{
-						new_name_lsa->header->isValid=name_lsa->header->isValid;
-						free(new_name_lsa->header->orig_time);
-						new_name_lsa->header->orig_time=(char *)malloc(strlen(name_lsa->header->orig_time)+1);
-						memset(new_name_lsa->header->orig_time,0,strlen(name_lsa->header->orig_time)+1);
-						memcpy(new_name_lsa->header->orig_time,name_lsa->header->orig_time,strlen(name_lsa->header->orig_time)+1);
-					}
-					if ( nlsr->debugging )
-						printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-					set_new_lsdb_version();	
-					if ( nlsr->debugging )
-						printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				}
-				else
-				{
-					int is_npt_update=0;
-					if ( strcmp(new_name_lsa->name_prefix->name,name_lsa->name_prefix->name) != 0 )
-					{
-						is_npt_update=1;
-						delete_npt_entry_by_router_and_name_prefix(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name);
-					}
-
-					// copying LSA content with header
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
-					write_log_for_name_lsa(new_name_lsa);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");					
-
-
-					free(new_name_lsa->header->orig_time);
-					new_name_lsa->header->orig_time=(char *)malloc(strlen(name_lsa->header->orig_time)+1);
-					memset(new_name_lsa->header->orig_time,0,strlen(name_lsa->header->orig_time)+1);
-					memcpy(new_name_lsa->header->orig_time,name_lsa->header->orig_time,strlen(name_lsa->header->orig_time)+1);
-				
-					new_name_lsa->header->isValid=name_lsa->header->isValid;
-
-					free(new_name_lsa->name_prefix->name);
-					free(new_name_lsa->name_prefix);
-					new_name_lsa->name_prefix=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-					new_name_lsa->name_prefix->name=(char *)malloc(name_lsa->name_prefix->length);
-					memcpy(new_name_lsa->name_prefix->name,name_lsa->name_prefix->name,name_lsa->name_prefix->length);
-					new_name_lsa->name_prefix->length=name_lsa->name_prefix->length;
-
-
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding name lsa\n");
-					write_log_for_name_lsa(new_name_lsa);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
-
-					if ( nlsr->debugging )
-						printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-					set_new_lsdb_version();	
-
-					if ( nlsr->debugging )
-						printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-
-					if( is_npt_update == 1 )
-					{
-						//struct hashtb *face_list;
-						int num_next_hop=get_number_of_next_hop(new_name_lsa->header->orig_router->name);
-						if ( num_next_hop < 0 )
-						{
-							
-							int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,NO_NEXT_HOP,NULL,NULL);
-							if ( check == HT_NEW_ENTRY )
-							{
-								if ( nlsr->debugging )
-									printf("Added in npt \n");
-								if ( nlsr->detailed_logging )
-									writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
-							}
-						}
-						else 
-						{
-							int *faces=malloc(num_next_hop*sizeof(int));
-							int *route_costs=malloc(num_next_hop*sizeof(int));			
-							int next_hop=get_next_hop(new_name_lsa->header->orig_router->name,faces,route_costs);
-							
-							if ( nlsr->debugging )
-							{
-								printf("Printing from install_name_lsa \n");
-								int j;
-								for(j=0;j<num_next_hop;j++)
-								printf("Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
-							}
-							if ( nlsr->detailed_logging )
-							{
-								writeLogg(__FILE__,__FUNCTION__,__LINE__,"Printing from install_name_lsa \n");
-								int j;
-								for(j=0;j<num_next_hop;j++)
-									writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face: %d Route Cost: %d \n",faces[j],route_costs[j]);
-							}
-
-							
-							int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,next_hop,faces,route_costs);
-							if ( check == HT_NEW_ENTRY )
-							{
-								if ( nlsr->debugging )
-									printf("Added in npt \n");
-								if ( nlsr->detailed_logging )
-									writeLogg(__FILE__,__FUNCTION__,__LINE__,"Added in npt \n");
-							}
-							free(faces);
-							free(route_costs);
-							
-						}
-						
-					}
-				}
-			}
-		
-		}
-
-    		hashtb_end(e);
-
-		free(key);
-}
-
-void 
-write_log_for_name_lsa(struct nlsa *name_lsa)
-{
-	
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"-----------Name LSA Content---------------\n");
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router: %s\n",name_lsa->header->orig_router->name);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router Length:	%d\n",name_lsa->header->orig_router->length);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LS Type:	%d\n",name_lsa->header->ls_type);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LS Id:	%ld\n",name_lsa->header->ls_id);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Time:	%s\n",name_lsa->header->orig_time);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Is Valid:	%d\n",name_lsa->header->isValid);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LSA Data			\n");
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Name Prefix: %s\n",name_lsa->name_prefix->name);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Name Prefix Length:	%d\n",name_lsa->name_prefix->length);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");	
-}
-
-void 
-print_name_lsa(struct nlsa *name_lsa)
-{
-
-	if ( nlsr->debugging )
-	{
-		printf("-----------Name LSA Content---------------\n");
-		printf("	Origination Router       :	%s\n",name_lsa->header->orig_router->name);
-		printf("	Origination Router Length:	%d\n",name_lsa->header->orig_router->length);
-		printf("	LS Type			 :	%d\n",name_lsa->header->ls_type);
-		printf("	LS Id			 :	%ld\n",name_lsa->header->ls_id);
-		printf("	Origination Time	 :	%s\n",name_lsa->header->orig_time);
-		printf("	Is Valid 		 :	%d\n",name_lsa->header->isValid);
-		printf("	LSA Data			\n");
-		printf("		Name Prefix:	 	:	%s\n",name_lsa->name_prefix->name);
-		printf("		Name Prefix Length	:	%d\n",name_lsa->name_prefix->length);
-
-		printf("\n");	
-	}
-}
-
-void
-print_name_lsdb(void)
-{
-	if ( nlsr->debugging )
-		printf("print_name_lsdb called \n");	
-	int i, name_lsdb_element;
-	struct nlsa *name_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->name_lsdb, e);
-	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);
-
-	for(i=0;i<name_lsdb_element;i++)
-	{
-		if ( nlsr->debugging )
-			printf("-----------Name LSA (%d)---------------\n",i+1);
-		name_lsa=e->data;
-		print_name_lsa(name_lsa);	
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-}
-
-
-void
-build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np)
-{
-	if ( nlsr->debugging )
-		printf("build_and_install_others_name_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_others_name_lsa called \n");
-
-	struct nlsa *name_lsa=(struct nlsa *)malloc(sizeof( struct nlsa ));
-	build_others_name_lsa(name_lsa,orig_router,ls_type,ls_id,orig_time, isValid,np);
-	print_name_lsa(name_lsa);
-	install_name_lsa(name_lsa);
-	print_name_lsdb();
-	print_npt();
-	
-	free(name_lsa->header->orig_router->name);
-	free(name_lsa->header->orig_router);
-	free(name_lsa->header);
-	free(name_lsa->name_prefix->name);
-	free(name_lsa->name_prefix);
-	free(name_lsa);
-	
-}
-
-void
-build_others_name_lsa(struct nlsa *name_lsa, char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np)
-{
-	if ( nlsr->debugging )
-		printf("build_others_name_lsa called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_others_name_lsa called \n");
-
-	name_lsa->header=(struct nlsa_header *)malloc(sizeof(struct nlsa_header ));
-	name_lsa->header->ls_type=LS_TYPE_NAME;
-
-	name_lsa->header->orig_time=(char *)malloc(strlen(orig_time)+1);
-	memset(name_lsa->header->orig_time,0,strlen(orig_time)+1);
-	memcpy(name_lsa->header->orig_time,orig_time,strlen(orig_time)+1);
-
-	name_lsa->header->ls_id=ls_id;
-	name_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	name_lsa->header->orig_router->name=(char *)malloc(strlen(orig_router)+1);
-	memset(name_lsa->header->orig_router->name,0,strlen(orig_router)+1);
-	memcpy(name_lsa->header->orig_router->name,orig_router,strlen(orig_router)+1);
-	name_lsa->header->orig_router->length=strlen(orig_router)+1;
-	name_lsa->header->isValid=isValid;
-
-	name_lsa->name_prefix=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	name_lsa->name_prefix->name=(char *)malloc(strlen(np)+1);
-	memset(name_lsa->name_prefix->name,0,strlen(np)+1);
-	memcpy(name_lsa->name_prefix->name,np,strlen(np)+1);
-	name_lsa->name_prefix->length=strlen(np)+1;
-}
-
-
-void 
-make_cor_lsa_key(char *key,struct clsa *cor_lsa)
-{
-	memcpy(key+strlen(key),cor_lsa->header->orig_router->name,cor_lsa->header->orig_router->length);
-	memcpy(key+strlen(key),"/",1);
-	char ls_type[2];
-	sprintf(ls_type,"%d",cor_lsa->header->ls_type);
-	memcpy(key+strlen(key),ls_type,strlen(ls_type));
-	key[strlen(key)]='\0';
-}
-
-
-void 
-make_adj_lsa_key(char *key,struct alsa *adj_lsa)
-{
-	memcpy(key+strlen(key),adj_lsa->header->orig_router->name,adj_lsa->header->orig_router->length);
-	memcpy(key+strlen(key),"/",1);
-	char ls_type[2];
-	sprintf(ls_type,"%d",adj_lsa->header->ls_type);
-	memcpy(key+strlen(key),ls_type,strlen(ls_type));
-	key[strlen(key)]='\0';
-}
-
-int
-build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-
-	nlsr_lock();
-
-	if ( nlsr->debugging )
-		printf("build_and_install_adj_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_adj_lsa called \n");
-	
-	if ( nlsr->debugging )
-		printf("adj_build_flag = %d \n",nlsr->adj_build_flag);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"adj_build_flag = %d \n",nlsr->adj_build_flag);
-
-	if(nlsr->adj_build_flag > 0)
-	{
-		if ( nlsr->debugging )
-			printf("is_adj_lsa_build = %d \n",is_adj_lsa_build());
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"is_adj_lsa_build = %d \n",is_adj_lsa_build());
-
-		if ( is_adj_lsa_build()> 0)
-		{
-			struct alsa *adj_lsa=(struct alsa *)malloc(sizeof( struct alsa ));
-			build_adj_lsa(adj_lsa);
-			install_adj_lsa(adj_lsa);
-
-			char lst[2];
-			memset(lst,0,2);
-			sprintf(lst,"%d",LS_TYPE_ADJ);			
-
-			char *repo_key=(char *)malloc(strlen(nlsr->slice_prefix)+strlen(adj_lsa->header->orig_time)+strlen(adj_lsa->header->orig_router->name) + strlen(lst) + 5);
-			memset(repo_key, 0, strlen(nlsr->slice_prefix)+strlen(adj_lsa->header->orig_time)+strlen(adj_lsa->header->orig_router->name) + strlen(lst) + 5);	
-			make_adj_lsa_prefix_for_repo(repo_key, adj_lsa->header->orig_router->name,LS_TYPE_ADJ,adj_lsa->header->orig_time,nlsr->slice_prefix);
-		
-			if ( nlsr->debugging )
-				printf("Adj LSA Repo Key: %s \n",repo_key);
-
-			char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
-			memset(key,0,adj_lsa->header->orig_router->length+2+2);
-			make_adj_lsa_key(key,adj_lsa);
-			if ( nlsr->debugging )
-				printf("Adj LSA: %s \n",key);
-
-			struct name_prefix *lsaid=(struct name_prefix *)malloc(sizeof(struct name_prefix));
-			lsaid->name=(char *)malloc(strlen(key)+1);
-			memset(lsaid->name, 0, strlen(key)+1);
-			memcpy(lsaid->name,key,strlen(key));
-			lsaid->length=strlen(key)+1;
-
-		
-			write_adj_lsa_to_repo(repo_key, lsaid);
-
-			free(key);
-			free(repo_key);
-			free(lsaid->name);
-			free(lsaid);
-
-
-		
-			free(adj_lsa->header->orig_router->name);
-			free(adj_lsa->header->orig_router);
-			free(adj_lsa->header->orig_time);
-			free(adj_lsa->header);
-			free(adj_lsa->body);
-			free(adj_lsa);
-			nlsr->adj_build_flag=0;	
-			print_adj_lsdb();		
-		}
-		else
-		{
-			if ( nlsr->debugging )
-				printf("Can not build adj LSA now\n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Can not build adj LSA now\n");
-		}
-	}
-	nlsr->is_build_adj_lsa_sheduled=0;
-
-	nlsr_unlock();
-
-	return 0;
-}
-
-
-void
-build_adj_lsa(struct alsa * adj_lsa)
-{
-	if ( nlsr->debugging )
-		printf("build_adj_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_adj_lsa called  \n");
-
-	int no_link=no_active_nbr();
-	
-	adj_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
-	adj_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	adj_lsa->header->orig_router->name=(char *)malloc(strlen(nlsr->router_name)+1);
-	memset(adj_lsa->header->orig_router->name,0,strlen(nlsr->router_name)+1);
-	memcpy(adj_lsa->header->orig_router->name,nlsr->router_name,strlen(nlsr->router_name)+1);
-	adj_lsa->header->orig_router->length=strlen(nlsr->router_name)+1;
-
-	adj_lsa->header->ls_type=(unsigned)LS_TYPE_ADJ;	
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-
-	adj_lsa->header->orig_time=(char *)malloc(strlen(time_stamp)+1); 
-	memset(adj_lsa->header->orig_time,0,strlen(time_stamp)+1);
-	memcpy(adj_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);	
-	free(time_stamp);
-
-	adj_lsa->no_link=no_link;
-
-
-	struct ccn_charbuf *c=ccn_charbuf_create();
-	get_active_nbr_adj_data(c);
-	char *data=ccn_charbuf_as_string(c);
-
-	adj_lsa->body=(char *)malloc(strlen(data)+1);
-	memset(adj_lsa->body,0,strlen(data)+1);
-	memcpy(adj_lsa->body,(char *)data,strlen(data)+1);
-	ccn_charbuf_destroy(&c);
-
-	nlsr->adj_build_count++;
-
-
-}
-
-
-void
-install_adj_lsa(struct alsa * adj_lsa)
-{
-
-	if ( nlsr->debugging )
-		printf("install_adj_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"install_adj_lsa called  \n");
-	
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-
-
-		char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
-		memset(key,0,adj_lsa->header->orig_router->length+2);
-		make_adj_lsa_key(key,adj_lsa);
-
-		struct alsa *new_adj_lsa=(struct alsa*)malloc(sizeof(struct alsa ));
-
-		struct hashtb_enumerator ee;
-    		struct hashtb_enumerator *e = &ee; 	
-    		int res;
-
-   		hashtb_start(nlsr->lsdb->adj_lsdb, e);
-    		res = hashtb_seek(e, key, strlen(key), 0);
-
-
-
-		if(res == HT_NEW_ENTRY)
-		{
-			if ( adj_lsa->no_link > 0)
-			{
-				if ( nlsr->debugging )
-					printf("New ADJ LSA... Adding to LSDB\n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New ADJ LSA... Adding to LSDB\n");
-				new_adj_lsa = e->data;
-
-				new_adj_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
-				new_adj_lsa->header->ls_type=adj_lsa->header->ls_type;
-				new_adj_lsa->header->orig_time=(char *)malloc(strlen(adj_lsa->header->orig_time)+1);
-				memcpy(new_adj_lsa->header->orig_time,adj_lsa->header->orig_time,strlen(adj_lsa->header->orig_time)+1);		
-
-				new_adj_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-				new_adj_lsa->header->orig_router->name=(char *)malloc(adj_lsa->header->orig_router->length);
-				memcpy(new_adj_lsa->header->orig_router->name,adj_lsa->header->orig_router->name,adj_lsa->header->orig_router->length);
-				new_adj_lsa->header->orig_router->length=adj_lsa->header->orig_router->length;
-
-				new_adj_lsa->no_link=adj_lsa->no_link;
-		
-				new_adj_lsa->body=(char *)malloc(strlen(adj_lsa->body)+1);
-				memset(new_adj_lsa->body,0,strlen(adj_lsa->body)+1);
-				memcpy(new_adj_lsa->body,adj_lsa->body,strlen(adj_lsa->body)+1);
-			
-				add_next_hop_router(new_adj_lsa->header->orig_router->name);
-				add_next_hop_from_lsa_adj_body(new_adj_lsa->body,new_adj_lsa->no_link);
-
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
-				write_log_for_adj_lsa(new_adj_lsa);
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-			}
-			else 
-			{
-				hashtb_delete(e);
-			}
-
-			if ( nlsr->debugging )
-				printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-			set_new_lsdb_version();	
-
-			if ( nlsr->debugging )
-				printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-		}
-		else if(res == HT_OLD_ENTRY)
-		{
-			new_adj_lsa = e->data;
-			if(strcmp(adj_lsa->header->orig_time,new_adj_lsa->header->orig_time)<=0)
-			{
-				if ( nlsr->debugging )
-					printf("Older/Duplicate Adj LSA. Discarded...\n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Older/Duplicate Adj LSA. Discarded...\n");
-			}
-			else
-			{
-
-				if ( adj_lsa->no_link > 0)
-				{				
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
-					write_log_for_adj_lsa(new_adj_lsa);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-
-					free(new_adj_lsa->header->orig_time);
-					new_adj_lsa->header->orig_time=(char *)malloc(strlen(adj_lsa->header->orig_time)+1);
-					memcpy(new_adj_lsa->header->orig_time,adj_lsa->header->orig_time,strlen(adj_lsa->header->orig_time)+1);
-
-					new_adj_lsa->no_link=adj_lsa->no_link;
-				
-					new_adj_lsa->body=(char *)malloc(strlen(adj_lsa->body)+1);
-					memset(new_adj_lsa->body,0,strlen(adj_lsa->body)+1);
-					memcpy(new_adj_lsa->body,adj_lsa->body,strlen(adj_lsa->body)+1);
-
-					add_next_hop_from_lsa_adj_body(new_adj_lsa->body,new_adj_lsa->no_link);
-
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
-					write_log_for_adj_lsa(new_adj_lsa);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-				}
-				else
-				{
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
-					write_log_for_adj_lsa(new_adj_lsa);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-					
-					hashtb_delete(e);
-				}
-				
-				if ( nlsr->debugging )
-					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-				set_new_lsdb_version();	
-
-				if ( nlsr->debugging )
-					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-			}
-	
-		}
-	    	hashtb_end(e);
-
-		if ( !nlsr->is_route_calculation_scheduled )
-		{
-			nlsr->event_calculate_route = ccn_schedule_event(nlsr->sched, 1000000, &route_calculate, NULL, 0);
-			nlsr->is_route_calculation_scheduled=1;
-		}
-
-
-		free(key);
-
-	free(time_stamp);
-}
-
-void 
-write_log_for_adj_lsa_body(const char *body, int no_link)
-{
-	int i=0;
-	char *lsa_data=(char *)malloc(strlen(body)+1);
-	memset(	lsa_data,0,strlen(body)+1);
-	memcpy(lsa_data,body,strlen(body)+1);
-	char *sep="|";
-	char *rem;
-	char *rtr_id;
-	char *length;
-	char *face;
-	char *metric;
-
-	if(no_link >0 )
-	{
-		rtr_id=strtok_r(lsa_data,sep,&rem);
-		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
-		metric=strtok_r(NULL,sep,&rem);
-
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Link %d	 	\n",i+1);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router: %s	\n",rtr_id);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router Length: %s	\n",length);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Metric: %s	\n",metric);
-
-
-		for(i=1;i<no_link;i++)
-		{
-			rtr_id=strtok_r(NULL,sep,&rem);
-			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
-			metric=strtok_r(NULL,sep,&rem);
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Link %d	 	\n",i+1);
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router: %s	\n",rtr_id);
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router Length: %s	\n",length);
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Metric: %s	\n",metric);
-
-		}
-	}
-
-	free(lsa_data);
-}
-
-
-void
-write_log_for_adj_lsa(struct alsa * adj_lsa)
-{
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"-----------Adj LSA Content---------------\n");
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router: %s\n",adj_lsa->header->orig_router->name);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Router Length: %d\n",adj_lsa->header->orig_router->length);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	LS Type:	%d\n",adj_lsa->header->ls_type);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Origination Time: %s\n",adj_lsa->header->orig_time);
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"	Lsa Data:\n");
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"		No of Link: %d\n",adj_lsa->no_link);
-
-	write_log_for_adj_lsa_body(adj_lsa->body,adj_lsa->no_link);
-	
-	writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-
-}
-
-void 
-print_adj_lsa_body(const char *body, int no_link)
-{
-	int i=0;
-	char *lsa_data=(char *)malloc(strlen(body)+1);
-	memset(	lsa_data,0,strlen(body)+1);
-	memcpy(lsa_data,body,strlen(body)+1);
-	char *sep="|";
-	char *rem;
-	char *rtr_id;
-	char *length;
-	char *face;
-	char *metric;
-
-	if(no_link >0 )
-	{
-		rtr_id=strtok_r(lsa_data,sep,&rem);
-		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
-		metric=strtok_r(NULL,sep,&rem);
-
-		if ( nlsr->debugging ) {
-			printf("		Link %d	 	\n",i+1);
-			printf("		Neighbor		 : %s	\n",rtr_id);
-			printf("		Neighbor Length		 : %s	\n",length);
-			printf("		Connecting Face		 : %s	\n",face);
-			printf("		Metric			 : %s	\n",metric);
-		}
-
-		for(i=1;i<no_link;i++)
-		{
-			rtr_id=strtok_r(NULL,sep,&rem);
-			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
-			metric=strtok_r(NULL,sep,&rem);
-			printf("		Link %d	 	\n",i+1);
-			printf("		Neighbor		 : %s	\n",rtr_id);
-			printf("		Neighbor Length		 : %s	\n",length);
-			printf("		Connecting Face		 : %s	\n",face);
-			printf("		Metric			 : %s	\n",metric);
-
-		}
-	}
-
-	free(lsa_data);
-}
-
-void
-print_adj_lsa(struct alsa * adj_lsa)
-{
-	if ( nlsr->debugging )
-	{
-		printf("-----------ADJ LSA Content---------------\n");
-		printf("	Origination Router       :	%s\n",adj_lsa->header->orig_router->name);
-		printf("	Origination Router Length:	%d\n",adj_lsa->header->orig_router->length);
-		printf("	LS Type			 :	%d\n",adj_lsa->header->ls_type);
-		printf("	Origination Time	 :	%s\n",adj_lsa->header->orig_time);
-		printf("	Lsa Data:\n");
-		printf("		No of Link	: %d\n",adj_lsa->no_link);
-
-		print_adj_lsa_body(adj_lsa->body,adj_lsa->no_link);
-		printf("\n");
-	}
-
-}
-
-void
-print_adj_lsdb(void)
-{
-	if ( nlsr->debugging )
-		printf("print_name_lsdb called \n");	
-	int i, adj_lsdb_element;
-	struct alsa *adj_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-	adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);
-
-	for(i=0;i<adj_lsdb_element;i++)
-	{
-		if ( nlsr->debugging )
-			printf("-----------Adj LSA (%d)---------------\n",i+1);
-		adj_lsa=e->data;
-		print_adj_lsa(adj_lsa);	
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-}
-
-void 
-build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data)
-{
-	if ( nlsr->debugging )
-		printf("build_and_install_others_adj_lsa called \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_others_adj_lsa called \n");
-	struct alsa *adj_lsa=(struct alsa *)malloc(sizeof( struct alsa ));
-	build_others_adj_lsa(adj_lsa,orig_router,ls_type,orig_time,no_link,data);
-	install_adj_lsa(adj_lsa);
-	
-
-	free(adj_lsa->header->orig_router->name);
-	free(adj_lsa->header->orig_router);
-	free(adj_lsa->header->orig_time);
-	free(adj_lsa->header);
-	free(adj_lsa->body);
-	free(adj_lsa);
-
-	print_adj_lsdb();
-
-}
-
-
-void 
-build_others_adj_lsa(struct alsa *adj_lsa,char *orig_router,int ls_type,char *orig_time,int no_link,char *data)
-{
-	if ( nlsr->debugging )
-		printf("build_others_adj_lsa called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_others_adj_lsa called  \n");
-
-	/*Filling Up Header Data */
-	adj_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
-	adj_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	adj_lsa->header->orig_router->name=(char *)malloc(strlen(orig_router)+1);
-	memset(adj_lsa->header->orig_router->name,0,strlen(orig_router)+1);
-	memcpy(adj_lsa->header->orig_router->name,orig_router,strlen(orig_router)+1);
-
-	adj_lsa->header->orig_router->length=strlen(orig_router)+1;
-
-
-	adj_lsa->header->ls_type=(unsigned)LS_TYPE_ADJ;	
-
-	adj_lsa->header->orig_time=(char *)malloc(strlen(orig_time)+1);
-	memset(adj_lsa->header->orig_time,0,strlen(orig_time)+1);
-	memcpy(adj_lsa->header->orig_time,orig_time,strlen(orig_time)+1);
-
-	adj_lsa->no_link=no_link;
-
-	adj_lsa->body=(char *)malloc(strlen(data)+1);
-	memset(adj_lsa->body,0,strlen(data)+1);
-	memcpy(adj_lsa->body,(char *)data,strlen(data)+1);
-
-}
-
-
-long int
-get_name_lsdb_num_element(void)
-{
-	long int num_element;
-
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->name_lsdb, e);
-	num_element=hashtb_n(nlsr->lsdb->name_lsdb);
-	hashtb_end(e);
-
-	return num_element; 
-}
-
-long int
-get_adj_lsdb_num_element(void)
-{
-	long int num_element;
-
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-	num_element=hashtb_n(nlsr->lsdb->adj_lsdb);
-	hashtb_end(e);
-
-	return num_element; 
-}
-
-
-int 
-check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time)
-{
-	int ret=0;
-	struct ccn_charbuf *key=ccn_charbuf_create();
-	ccn_charbuf_append_string(key,orig_router);
-	ccn_charbuf_append_string(key,"/");
-	ccn_charbuf_append_string(key,lst);
-	ccn_charbuf_append_string(key,"/");
-	ccn_charbuf_append_string(key,lsid);
-
-	int res;
-	struct nlsa *name_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->lsdb->name_lsdb, e);
-	res = hashtb_seek(e, ccn_charbuf_as_string(key), key->length, 0);
-
-	if( res == HT_NEW_ENTRY )
-	{
-		hashtb_delete(e);
-		ret=1;
-
-	}
-	else if(res == HT_OLD_ENTRY)
-	{
-		name_lsa=e->data;
-		if( strcmp ( orig_time , name_lsa->header->orig_time ) > 0 )
-		{
-			ret=1;
-		}
-	}
-
-	hashtb_end(e);
-
-	ccn_charbuf_destroy(&key);
-	
-	return ret;
-}
-
-int 
-check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time)
-{
-	int ret=0;
-	struct ccn_charbuf *key=ccn_charbuf_create();
-	ccn_charbuf_append_string(key,orig_router);
-	ccn_charbuf_append_string(key,"/");
-	ccn_charbuf_append_string(key,lst);
-
-	int res;
-	struct alsa *adj_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-	res = hashtb_seek(e, ccn_charbuf_as_string(key), key->length, 0);
-
-	if( res == HT_NEW_ENTRY )
-	{
-		hashtb_delete(e);
-		ret=1;
-
-	}
-	else if(res == HT_OLD_ENTRY)
-	{
-		adj_lsa=e->data;
-		if( strcmp ( orig_time , adj_lsa->header->orig_time ) > 0 )
-		{
-			ret=1;
-		}
-	}
-
-	hashtb_end(e);
-	
-	ccn_charbuf_destroy(&key);
-
-	return ret;
-}
-
-int 
-check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time)
-{
-	int ret=0;
-	struct ccn_charbuf *key=ccn_charbuf_create();
-	ccn_charbuf_append_string(key,orig_router);
-	ccn_charbuf_append_string(key,"/");
-	ccn_charbuf_append_string(key,lst);
-
-	int res;
-	struct clsa *cor_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-
-	hashtb_start(nlsr->lsdb->cor_lsdb, e);
-	res = hashtb_seek(e, ccn_charbuf_as_string(key), key->length, 0);
-
-	if( res == HT_NEW_ENTRY )
-	{
-		hashtb_delete(e);
-		ret=1;
-
-	}
-	else if(res == HT_OLD_ENTRY)
-	{
-		cor_lsa=e->data;
-		if( strcmp ( orig_time , cor_lsa->header->orig_time ) > 0 )
-		{
-			ret=1;
-		}
-	}
-
-	hashtb_end(e);
-	
-	ccn_charbuf_destroy(&key);
-
-	return ret;
-}
-
-void 
-get_name_lsa_data(struct ccn_charbuf *lsa_data, struct name_prefix *lsaId)
-{
-	if ( nlsr->debugging )
-		printf("get_name_lsa_data called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_name_lsa_data called  \n");
-
-	struct nlsa *name_lsa=(struct nlsa*)malloc(sizeof(struct nlsa ));
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->name_lsdb, e);
-    	res = hashtb_seek(e, lsaId->name, lsaId->length-1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		name_lsa=e->data;
-		
-		if ( nlsr->debugging )
-			printf("NAME LSA found  \n");	
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Name LSA found  \n");
-
-		ccn_charbuf_append_string(lsa_data,name_lsa->header->orig_router->name);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_length=(char *)malloc(20);
-		memset(temp_length,0,20);
-		sprintf(temp_length,"%d",name_lsa->header->orig_router->length);
-		ccn_charbuf_append_string(lsa_data,temp_length);
-		free(temp_length);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_ltype=(char *)malloc(20);
-		memset(temp_ltype,0,20);
-		sprintf(temp_ltype,"%d",name_lsa->header->ls_type);
-		ccn_charbuf_append_string(lsa_data,temp_ltype);
-		free(temp_ltype);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_lsid=(char *)malloc(20);
-		memset(temp_lsid,0,20);
-		sprintf(temp_lsid,"%ld",name_lsa->header->ls_id);
-		ccn_charbuf_append_string(lsa_data,temp_lsid);
-		free(temp_lsid);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		ccn_charbuf_append_string(lsa_data,name_lsa->header->orig_time);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_valid=(char *)malloc(20);
-		memset(temp_valid,0,20);
-		sprintf(temp_valid,"%d",name_lsa->header->isValid);
-		ccn_charbuf_append_string(lsa_data,temp_valid);
-		free(temp_valid);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		ccn_charbuf_append_string(lsa_data,name_lsa->name_prefix->name);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_npl=(char *)malloc(20);
-		memset(temp_npl,0,20);
-		sprintf(temp_npl,"%d",name_lsa->name_prefix->length);
-		ccn_charbuf_append_string(lsa_data,temp_npl);
-		free(temp_npl);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-void 
-get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId)
-{
-	if ( nlsr->debugging )
-		printf("get_adj_lsa_data called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adj_lsa_data called  \n");
-
-	struct alsa *adj_lsa=(struct alsa*)malloc(sizeof(struct alsa ));
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-    	res = hashtb_seek(e, lsaId->name, lsaId->length-1, 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		adj_lsa=e->data;
-
-		if ( nlsr->debugging )
-			printf("Adj LSA found  \n");	
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adj LSA found  \n");
-
-		ccn_charbuf_append_string(lsa_data,adj_lsa->header->orig_router->name);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_length=(char *)malloc(20);
-		memset(temp_length,0,20);
-		sprintf(temp_length,"%d",adj_lsa->header->orig_router->length);
-		ccn_charbuf_append_string(lsa_data,temp_length);
-		ccn_charbuf_append_string(lsa_data,"|");
-		free(temp_length);
-
-		char *temp_ltype=(char *)malloc(20);
-		memset(temp_ltype,0,20);
-		sprintf(temp_ltype,"%d",adj_lsa->header->ls_type);
-		ccn_charbuf_append_string(lsa_data,temp_ltype);
-		ccn_charbuf_append_string(lsa_data,"|");
-		free(temp_ltype);
-
-		ccn_charbuf_append_string(lsa_data,adj_lsa->header->orig_time);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_nl=(char *)malloc(20);
-		memset(temp_nl,0,20);
-		sprintf(temp_nl,"%d",adj_lsa->no_link);
-		ccn_charbuf_append_string(lsa_data,temp_nl);
-		ccn_charbuf_append_string(lsa_data,"|");
-		free(temp_nl);
-
-		ccn_charbuf_append_string(lsa_data,adj_lsa->body);
-
-
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-void
-make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id)
-{
-
-	if ( nlsr->debugging )
-		printf("make_name_lsa_invalid called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"make_name_lsa_invalid called  \n");
-
-
-	char lst[2];
-	memset(lst,0,2);
-	sprintf(lst,"%d",ls_type);	
-
-	char lsid[10];
-	memset(lsid,0,10);
-	sprintf(lsid,"%ld",ls_id);
-	
-	
-	char *key=(char *)malloc(strlen(np->name)+1+strlen(lst)+1+strlen(lsid)+1);
-	memset(key,0,strlen(np->name)+1+strlen(lst)+1+strlen(lsid)+1);
-
-
-	make_name_lsa_key(key, np->name,ls_type,ls_id);	
-	
-	if ( nlsr->debugging )
-		printf("Key:%s Length:%d\n",key,(int)strlen(key));
-
-	struct nlsa *nlsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-	 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->name_lsdb, e);
-    	res = hashtb_seek(e, key,strlen(key) , 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nlsa=e->data;
-	
-		nlsa->header->isValid=0;
-
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
-		write_log_for_name_lsa(nlsa);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
-
-		hashtb_delete(e);
-	}
-	else if( res == HT_NEW_ENTRY )
-	{
-		hashtb_delete(e);
-	}
-	hashtb_end(e);
-	
-	if ( nlsr->debugging )
-		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-	set_new_lsdb_version();	
-
-	if ( nlsr->debugging )
-		printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-}
-
-int 
-delete_name_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	
-	if ( nlsr->debugging )
-		printf("delete_name_lsa called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_name_lsa called  \n");
-	
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-
-
-
-	nlsr_lock();
-
-	if ( nlsr->debugging )
-		printf("LSA Key: %s \n",(char *)ev->evdata);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Key: %s \n",(char *)ev->evdata);
-
-	struct nlsa *nlsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-	 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->name_lsdb, e);
-    	res = hashtb_seek(e, (char *)ev->evdata, strlen((char *)ev->evdata), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		nlsa=e->data;
-		delete_npt_entry_by_router_and_name_prefix(nlsa->header->orig_router->name, nlsa->name_prefix->name);
-
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
-		write_log_for_name_lsa(nlsa);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
-
-		hashtb_delete(e);
-	}
-	else if( res == HT_NEW_ENTRY )
-	{
-		hashtb_delete(e);
-	}
-	hashtb_end(e);
-	
-	if ( nlsr->debugging )
-		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-	set_new_lsdb_version();	
-
-	if ( nlsr->debugging )
-		printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-	
-	nlsr_unlock();
-
-	return 0;
-}
-
-int 
-delete_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	if ( nlsr->debugging )
-		printf("delete_adj_lsa called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_adj_lsa called  \n");
-	
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-	nlsr_lock();
-
-	if ( nlsr->debugging )
-		printf("LSA Key: %s \n",(char *)ev->evdata);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Key: %s \n",(char *)ev->evdata);
-
-	struct alsa *alsa;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-    	res = hashtb_seek(e, (char *)ev->evdata, strlen((char *)ev->evdata), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		alsa=e->data;
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
-		write_log_for_adj_lsa(alsa);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-		
-		hashtb_delete(e);
-	}
-	else if( res == HT_OLD_ENTRY )
-	{
-		hashtb_delete(e);
-	}
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-	set_new_lsdb_version();	
-
-	if ( nlsr->debugging )
-		printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-
-	if ( !nlsr->is_route_calculation_scheduled)
-	{
-		nlsr->event_calculate_route = ccn_schedule_event(nlsr->sched, 1000000, &route_calculate, NULL, 0);
-		nlsr->is_route_calculation_scheduled=1;
-	}
-
-	nlsr_unlock();
-
-	return 0;
-}
-
-void
-refresh_name_lsdb(void)
-{
-	if ( nlsr->debugging )
-		printf("refresh_name_lsdb called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_name_lsdb called  \n");
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-	
-	long int lsa_life_time;
-		
-	int i, name_lsdb_element;
-	struct nlsa *name_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->name_lsdb, e);
-	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);
-
-	for(i=0;i<name_lsdb_element;i++)
-	{
-		name_lsa=e->data;
-
-		lsa_life_time=get_time_diff(time_stamp,name_lsa->header->orig_time);
-		if ( nlsr->debugging )
-			printf("LSA Life Time: %ld \n",lsa_life_time);	
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Life Time: %ld \n",lsa_life_time);
-		
-		if ( strcmp(name_lsa->header->orig_router->name,nlsr->router_name) == 0)
-		{
-			if ( lsa_life_time > nlsr->lsa_refresh_time )
-			{
-				if ( name_lsa->header->isValid == NAME_LSA_VALID )					
-				{
-					if ( nlsr->debugging )
-						printf("Own Name LSA need to be refrshed\n");
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Own Name LSA need to be refrshed\n");
-
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
-					write_log_for_name_lsa(name_lsa);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
-					
-
-					char *current_time_stamp=(char *)malloc(20);
-					memset(current_time_stamp,0,20);
-					get_current_timestamp_micro(current_time_stamp);
-
-					free(name_lsa->header->orig_time);
-					name_lsa->header->orig_time=(char *)malloc(strlen(current_time_stamp)+1); //free 
-					memset(name_lsa->header->orig_time,0,strlen(current_time_stamp)+1);
-					memcpy(name_lsa->header->orig_time,current_time_stamp,strlen(current_time_stamp)+1);
-
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding name lsa\n");
-					write_log_for_name_lsa(name_lsa);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
-	
-					free(current_time_stamp);
-				}
-				else 
-				{
-					char lst[2];
-					memset(lst,0,2);
-					sprintf(lst,"%d",name_lsa->header->ls_type);	
-
-					char lsid[10];
-					memset(lsid,0,10);
-					sprintf(lsid,"%ld",name_lsa->header->ls_id);
-	
-	
-					char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-					memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-
-
-					make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);	
-				
-					nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
-				}
-
-				if ( nlsr->debugging )
-					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-				set_new_lsdb_version();	
-
-				if ( nlsr->debugging )
-					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-							
-
-				print_name_lsdb();
-			}	
-		}
-		else 
-		{
-			if ( lsa_life_time > nlsr->router_dead_interval )
-			{
-				if ( nlsr->debugging )
-				 	printf("Others Name LSA need to be deleted\n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Name LSA need to be deleted\n");
-
-				char lst[2];
-				memset(lst,0,2);
-				sprintf(lst,"%d",name_lsa->header->ls_type);	
-
-				char lsid[10];
-				memset(lsid,0,10);
-				sprintf(lsid,"%ld",name_lsa->header->ls_id);
-	
-	
-				char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-				memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-
-
-				make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);	
-				
-				nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
-			}
-		}
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-	
-	free(time_stamp);
-
-	
-}
-
-void
-refresh_adj_lsdb(void)
-{
-
-	if ( nlsr->debugging )
-		printf("refresh_adj_lsdb called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_adj_lsdb called  \n");
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-	
-	long int lsa_life_time;
-		
-	int i, adj_lsdb_element;
-	struct alsa *adj_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-	adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);
-
-	for(i=0;i<adj_lsdb_element;i++)
-	{
-		adj_lsa=e->data;
-
-		lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);	
-
-		if ( nlsr->debugging )
-			printf("LSA Life Time: %ld \n",lsa_life_time);	
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Life Time: %ld \n",lsa_life_time);		
-
-		if ( strcmp(adj_lsa->header->orig_router->name,nlsr->router_name) == 0)
-		{
-			if ( lsa_life_time > nlsr->lsa_refresh_time )
-			{
-				if ( nlsr->debugging )
-					printf("Own Adj LSA need to be refrshed\n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Own Adj LSA need to be refrshed\n");
-
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
-				write_log_for_adj_lsa(adj_lsa);
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-
-				char *current_time_stamp=(char *)malloc(20);
-				memset(current_time_stamp,0,20);
-				get_current_timestamp_micro(current_time_stamp);
-
-				free(adj_lsa->header->orig_time);
-				adj_lsa->header->orig_time=(char *)malloc(strlen(current_time_stamp)+1); //free 
-				memset(adj_lsa->header->orig_time,0,strlen(current_time_stamp)+1);
-				memcpy(adj_lsa->header->orig_time,current_time_stamp,strlen(current_time_stamp)+1);
-	
-				free(current_time_stamp);
-
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
-				write_log_for_adj_lsa(adj_lsa);
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-
-				if ( nlsr->debugging )
-					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-				set_new_lsdb_version();	
-
-				if ( nlsr->debugging )
-					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-				print_adj_lsdb();
-			}	
-		}
-		else 
-		{
-			if ( lsa_life_time > nlsr->router_dead_interval )
-			{
-
-				if ( nlsr->debugging )
-				 	printf("Others Adj LSA need to be deleted\n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Adj LSA need to be deleted\n");
-				
-				char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
-				memset(key,0,adj_lsa->header->orig_router->length+2);
-				make_adj_lsa_key(key,adj_lsa);
-				
-				nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_adj_lsa, (void *)key, 0);
-			}
-		}
-
-		
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-	
-	free(time_stamp);
-}
-
-
-void
-refresh_cor_lsdb(void)
-{
-
-	if ( nlsr->debugging )
-		printf("refresh_cor_lsdb called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_cor_lsdb called  \n");
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-	
-	long int lsa_life_time;
-		
-	int i, cor_lsdb_element;
-	struct clsa *cor_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->cor_lsdb, e);
-	cor_lsdb_element=hashtb_n(nlsr->lsdb->cor_lsdb);
-
-	for(i=0;i<cor_lsdb_element;i++)
-	{
-		cor_lsa=e->data;
-
-		lsa_life_time=get_time_diff(time_stamp,cor_lsa->header->orig_time);	
-
-		if ( nlsr->debugging )
-			printf("LSA Life Time: %ld \n",lsa_life_time);	
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Life Time: %ld \n",lsa_life_time);		
-
-		if ( strcmp(cor_lsa->header->orig_router->name,nlsr->router_name) == 0)
-		{
-			if ( lsa_life_time > nlsr->lsa_refresh_time )
-			{
-				if ( nlsr->debugging )
-					printf("Own Cor LSA need to be refrshed\n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Own Cor LSA need to be refrshed\n");
-
-				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
-				//write_log_for_adj_lsa(adj_lsa);
-				//writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-
-				char *current_time_stamp=(char *)malloc(20);
-				memset(current_time_stamp,0,20);
-				get_current_timestamp_micro(current_time_stamp);
-
-				free(cor_lsa->header->orig_time);
-				cor_lsa->header->orig_time=(char *)malloc(strlen(current_time_stamp)+1); //free 
-				memset(cor_lsa->header->orig_time,0,strlen(current_time_stamp)+1);
-				memcpy(cor_lsa->header->orig_time,current_time_stamp,strlen(current_time_stamp)+1);
-	
-				free(current_time_stamp);
-
-				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
-				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
-				//write_log_for_adj_lsa(adj_lsa);
-				//writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
-
-				if ( nlsr->debugging )
-					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-				set_new_lsdb_version();	
-
-				if ( nlsr->debugging )
-					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
-
-				print_adj_lsdb();
-			}	
-		}
-		else 
-		{
-			if ( lsa_life_time > nlsr->router_dead_interval )
-			{
-
-				if ( nlsr->debugging )
-				 	printf("Others Adj LSA need to be deleted\n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Adj LSA need to be deleted\n");
-				
-				hashtb_delete(e);
-				i++;
-			}
-		}
-
-		
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-	
-	free(time_stamp);
-}
-
-int
-refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-
-	nlsr_lock();
-
-	if ( nlsr->debugging )
-		printf("refresh_lsdb called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_lsdb called\n");
-	
-	refresh_name_lsdb();
-	refresh_adj_lsdb();
-	refresh_cor_lsdb();
-
-	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
-	
-	nlsr_unlock();
-	return 0;
-}
-
-void
-write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id)
-{
-	if ( nlsr->debugging )
-		printf("write_adj_lsa_to_repo called\n");
-	if ( nlsr->debugging )
-		printf("Content Prefix: %s\n",repo_content_prefix);
-	
-	struct ccn_charbuf *lsa_data=ccn_charbuf_create();		
-	get_adj_lsa_data(lsa_data,lsa_id);
-	if ( nlsr->debugging )
-		printf("Adj LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	
-
-	write_data_to_repo(ccn_charbuf_as_string(lsa_data), repo_content_prefix);
-
-	ccn_charbuf_destroy(&lsa_data);
-}
-
-void
-write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id)
-{
-	if ( nlsr->debugging )
-		printf("write_name_lsa_to_repo called\n");
-	if ( nlsr->debugging )
-		printf("Content Prefix: %s\n",repo_content_prefix);
-	
-	struct ccn_charbuf *lsa_data=ccn_charbuf_create();		
-	get_name_lsa_data(lsa_data,lsa_id);
-	
-	if ( nlsr->debugging )
-		printf("Name LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	
-
-	write_data_to_repo(ccn_charbuf_as_string(lsa_data), repo_content_prefix);
-
-	ccn_charbuf_destroy(&lsa_data);
-}
-
-
-void
-write_name_lsdb_to_repo(char *slice_prefix)
-{
-	int i, name_lsdb_element;
-
-	struct nlsa *name_lsa;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->name_lsdb, e);
-	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);
-
-	for(i=0;i<name_lsdb_element;i++)
-	{
-		name_lsa=e->data;
-
-		char lst[2];
-		memset(lst,0,2);
-		sprintf(lst,"%d",name_lsa->header->ls_type);	
-
-		char lsid[10];
-		memset(lsid,0,10);
-		sprintf(lsid,"%ld",name_lsa->header->ls_id);
-	
-	
-		char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-		memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
-
-
-		make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
-		
-		if ( nlsr->debugging )
-			printf("Name LSA Key: %s \n",key);
-
-
-		char *repo_key=(char *)malloc(strlen(slice_prefix)+1+strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1+strlen(name_lsa->header->orig_time)+1);
-		memset(repo_key,0,strlen(slice_prefix)+1+strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1+strlen(name_lsa->header->orig_time)+1);	
-		make_name_lsa_prefix_for_repo(repo_key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id,name_lsa->header->orig_time,slice_prefix);
-		
-		if ( nlsr->debugging )
-			printf("Name LSA Repo Key: %s \n",repo_key);
-
-		struct name_prefix *lsaid=(struct name_prefix *)malloc(sizeof(struct name_prefix));
-		lsaid->name=(char *)malloc(strlen(key)+1);
-		memset(lsaid->name, 0, strlen(key)+1);
-		memcpy(lsaid->name,key,strlen(key));
-		lsaid->length=strlen(key)+1;
-
-		
-		write_name_lsa_to_repo(repo_key, lsaid);
-
-		free(key);
-		free(repo_key);
-		free(lsaid->name);
-		free(lsaid);
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-	
-
-}
-
-void
-print_cor_lsa(struct clsa *cor_lsa)
-{
-	if ( nlsr->debugging )
-	{
-		printf("-----------Cor LSA Content---------------\n");
-		printf("	Origination Router       :	%s\n",cor_lsa->header->orig_router->name);
-		printf("	Origination Router Length:	%d\n",cor_lsa->header->orig_router->length);
-		printf("	LS Type			 :	%d\n",cor_lsa->header->ls_type);
-		printf("	Origination Time	 :	%s\n",cor_lsa->header->orig_time);
-		printf("	LSA Data			\n");
-		printf("		Cor R:	 	:	%f\n",cor_lsa->cor_r);
-		printf("		Cor Theta	:	%f\n",cor_lsa->cor_theta);
-
-		printf("\n");	
-	}
-}
-
-void 
-print_cor_lsdb()
-{
-	
-	if ( nlsr->debugging )
-		printf("print_cor_lsdb called \n");	
-	
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-	int i=1;
-
-	for (hashtb_start(nlsr->lsdb->cor_lsdb, e); e->key != NULL; hashtb_next(e)) 
-	{
-		if ( nlsr->debugging )
-			printf("-----------Cor LSA (%d)---------------\n",i);	
-		struct clsa *cor_lsa=e->data;
-		print_cor_lsa(cor_lsa);
-		i++;
-  	}
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-}
-
-void
-install_cor_lsa(struct clsa *cor_lsa)
-{
-	if ( nlsr->debugging )
-		printf("install_cor_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"install_cor_lsa called  \n");
-	
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-
-
-	char *key=(char *)malloc(cor_lsa->header->orig_router->length+2+2);
-	memset(key,0,cor_lsa->header->orig_router->length+2);
-	make_cor_lsa_key(key,cor_lsa);
-
-	if ( nlsr->debugging )
-		printf("Cor LSA key: %s \n",key);
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
-    	res = hashtb_seek(e, key, strlen(key), 0);
-
-	if ( res == HT_NEW_ENTRY )
-	{
-		if ( nlsr->debugging )
-			printf("New Cor LSA... \n");
-		
-		struct clsa *new_cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
-		new_cor_lsa=e->data;
-		new_cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
-
-		new_cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-		new_cor_lsa->header->orig_router->name=(char *)malloc(strlen(cor_lsa->header->orig_router->name)+1);
-		memset(new_cor_lsa->header->orig_router->name,0,strlen(cor_lsa->header->orig_router->name)+1);
-		memcpy(new_cor_lsa->header->orig_router->name,cor_lsa->header->orig_router->name,strlen(cor_lsa->header->orig_router->name)+1);
-		new_cor_lsa->header->orig_router->length=cor_lsa->header->orig_router->length;
-
-		new_cor_lsa->header->orig_time=(char *)malloc(strlen(cor_lsa->header->orig_time)+1); //free 
-		memset(new_cor_lsa->header->orig_time,0,strlen(cor_lsa->header->orig_time)+1);
-		memcpy(new_cor_lsa->header->orig_time,cor_lsa->header->orig_time,strlen(cor_lsa->header->orig_time)+1);
-
-		new_cor_lsa->header->ls_type=cor_lsa->header->ls_type;
-
-		new_cor_lsa->cor_r=cor_lsa->cor_r;
-		new_cor_lsa->cor_theta=cor_lsa->cor_theta;
-	}
-	else if ( res == HT_OLD_ENTRY )
-	{	
-		if ( nlsr->debugging )
-			printf("Cor LSA exists (Old)... \n");
-	}
-	hashtb_end(e);
-
-	free(key);
-
-}
-
-void 
-build_cor_lsa(struct clsa *cor_lsa, double cor_r, double cor_theta)
-{
-	cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
-	cor_lsa->header->ls_type=LS_TYPE_COR;
-
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
-	get_current_timestamp_micro(time_stamp);
-
-	cor_lsa->header->orig_time=(char *)malloc(strlen(time_stamp)+1); //free 
-	memset(cor_lsa->header->orig_time,0,strlen(time_stamp)+1);
-	memcpy(cor_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);
-	free(time_stamp);
-
-	cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	cor_lsa->header->orig_router->name=(char *)malloc(strlen(nlsr->router_name)+1);
-	memset(cor_lsa->header->orig_router->name,0,strlen(nlsr->router_name)+1);
-	memcpy(cor_lsa->header->orig_router->name,nlsr->router_name,strlen(nlsr->router_name)+1);
-	cor_lsa->header->orig_router->length=strlen(nlsr->router_name)+1;
-
-	cor_lsa->cor_r=cor_r;	
-	cor_lsa->cor_theta=cor_theta;
-
-}
-
-void 
-build_others_cor_lsa(struct clsa *cor_lsa,char *orig_router, int ls_type,char *orig_time, double cor_r, double cor_theta)
-{
-	cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
-	cor_lsa->header->ls_type=ls_type;
-
-	cor_lsa->header->orig_time=(char *)malloc(strlen(orig_time)+1); 
-	memset(cor_lsa->header->orig_time,0,strlen(orig_time)+1);
-	memcpy(cor_lsa->header->orig_time,orig_time,strlen(orig_time)+1);
-
-	cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	cor_lsa->header->orig_router->name=(char *)malloc(strlen(orig_router)+1);
-	memset(cor_lsa->header->orig_router->name,0,strlen(orig_router)+1);
-	memcpy(cor_lsa->header->orig_router->name,orig_router,strlen(orig_router)+1);
-	cor_lsa->header->orig_router->length=strlen(orig_router)+1;
-
-	cor_lsa->cor_r=cor_r;	
-	cor_lsa->cor_theta=cor_theta;
-
-}
-
-void
-build_and_install_others_cor_lsa(char *orig_router,int ls_type,char *orig_time, double cor_r, double cor_theta)
-{
-	struct clsa *cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
-	build_others_cor_lsa(cor_lsa,orig_router,ls_type, orig_time, cor_r, cor_theta);
-	install_cor_lsa(cor_lsa);
-
-	print_cor_lsdb();
-
-	free(cor_lsa->header->orig_router);
-	free(cor_lsa->header->orig_time);
-	free(cor_lsa->header);
-	free(cor_lsa);
-
-}
-
-
-void 
-build_and_install_cor_lsa()
-{
-
-	struct clsa *cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
-	
-	build_cor_lsa(cor_lsa,nlsr->cor_r,nlsr->cor_theta);
-	install_cor_lsa(cor_lsa);
-
-	write_cor_lsa_to_repo(cor_lsa);
-
-	print_cor_lsdb();	
-
-	free(cor_lsa->header->orig_router);
-	free(cor_lsa->header->orig_time);
-	free(cor_lsa->header);
-	free(cor_lsa);
-	
-}
-
-void 
-get_cor_lsa_data(struct ccn_charbuf *lsa_data,char *cor_lsa_key)
-{
-	if ( nlsr->debugging )
-		printf("get_cor_lsa_data called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adj_lsa_data called  \n");
-
-	struct clsa *cor_lsa=(struct clsa*)malloc(sizeof(struct clsa ));
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
-    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		cor_lsa=e->data;
-
-		if ( nlsr->debugging )
-			printf("Cor LSA found  \n");	
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Cor LSA found  \n");
-
-		ccn_charbuf_append_string(lsa_data,cor_lsa->header->orig_router->name);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *temp_length=(char *)malloc(20);
-		memset(temp_length,0,20);
-		sprintf(temp_length,"%d",cor_lsa->header->orig_router->length);
-		ccn_charbuf_append_string(lsa_data,temp_length);
-		ccn_charbuf_append_string(lsa_data,"|");
-		free(temp_length);
-
-		char *temp_ltype=(char *)malloc(20);
-		memset(temp_ltype,0,20);
-		sprintf(temp_ltype,"%d",cor_lsa->header->ls_type);
-		ccn_charbuf_append_string(lsa_data,temp_ltype);
-		ccn_charbuf_append_string(lsa_data,"|");
-		free(temp_ltype);
-
-		ccn_charbuf_append_string(lsa_data,cor_lsa->header->orig_time);
-		ccn_charbuf_append_string(lsa_data,"|");
-
-		char *cor_r=(char *)malloc(20);
-		memset(cor_r,0,20);
-		sprintf(cor_r,"%f",cor_lsa->cor_r);
-		ccn_charbuf_append_string(lsa_data,cor_r);
-		ccn_charbuf_append_string(lsa_data,"|");
-		free(cor_r);
-
-		char *cor_theta=(char *)malloc(20);
-		memset(cor_theta,0,20);
-		sprintf(cor_theta,"%f",cor_lsa->cor_theta);
-		ccn_charbuf_append_string(lsa_data,cor_theta);
-		ccn_charbuf_append_string(lsa_data,"|");
-		free(cor_theta);
-
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-}
-
-void
-write_cor_lsa_to_repo(struct clsa *cor_lsa)
-{
-	
-
-	if ( nlsr->debugging )
-		printf("write_cor_lsa_to_repo called\n");
-	
-	
-	char *key=(char *)malloc(cor_lsa->header->orig_router->length+2+2);
-	memset(key,0,cor_lsa->header->orig_router->length+2+2);
-	make_cor_lsa_key(key,cor_lsa);
-	
-	struct ccn_charbuf *lsa_data=ccn_charbuf_create();
-	get_cor_lsa_data(lsa_data,key);
-	
-	if ( nlsr->debugging )
-		printf("Cor LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	
-	char *lst=(char *)malloc(20);
-	memset(lst,0,20);
-	sprintf(lst,"%d",cor_lsa->header->ls_type);
-	char *repo_key=(char *)malloc(strlen(nlsr->slice_prefix)+strlen(cor_lsa->header->orig_time)+strlen(cor_lsa->header->orig_router->name) + strlen(lst) + 5);
-	memset(repo_key, 0, strlen(nlsr->slice_prefix)+strlen(cor_lsa->header->orig_time)+strlen(cor_lsa->header->orig_router->name) + strlen(lst) + 5);	
-	make_cor_lsa_prefix_for_repo(repo_key, cor_lsa->header->orig_router->name,LS_TYPE_COR,cor_lsa->header->orig_time,nlsr->slice_prefix);
-		
-	if ( nlsr->debugging )
-		printf("Cor LSA Repo Key: %s \n",repo_key);	
-
-	write_data_to_repo(ccn_charbuf_as_string(lsa_data), repo_key);
-
-	
-		
-	free(lst);
-	free(key);
-	free(repo_key);
-	ccn_charbuf_destroy(&lsa_data);
-}
-
-void 
-make_cor_lsa_key_by_router_name(char *key,char *router_name)
-{
-	memcpy(key+strlen(key),router_name,strlen(router_name));
-	memcpy(key+strlen(key),"/",1);
-	char ls_type[2];
-	sprintf(ls_type,"%d",LS_TYPE_COR);
-	memcpy(key+strlen(key),ls_type,strlen(ls_type));
-	key[strlen(key)]='\0';
-}
-
-
-double 
-get_hyperbolic_r(char *router)
-{
-	double ret=-1.0;
-	char *cor_lsa_key=(char *)calloc(strlen(router)+4,sizeof(char));
-	make_cor_lsa_key_by_router_name(cor_lsa_key,router);
-
-	
-	struct clsa *cor_lsa;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
-    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);
-
-	if ( res == HT_OLD_ENTRY)
-	{	
-		cor_lsa=e->data;
-		ret=cor_lsa->cor_r;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-	
-	free(cor_lsa_key);
-	return ret;
-}
-
-double 
-get_hyperbolic_theta(char *router)
-{
-		double ret=-1.0;
-	char *cor_lsa_key=(char *)calloc(strlen(router)+4,sizeof(char));
-	make_cor_lsa_key_by_router_name(cor_lsa_key,router);
-
-	struct clsa *cor_lsa;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
-    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);
-
-	if ( res == HT_OLD_ENTRY)
-	{	
-		cor_lsa=e->data;
-		ret=cor_lsa->cor_theta;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-
-	hashtb_end(e);
-	
-	free(cor_lsa_key);
-	return ret;
-}
diff --git a/nlsr-sync-0.0/nlsr_lsdb.h b/nlsr-sync-0.0/nlsr_lsdb.h
deleted file mode 100755
index c67348e..0000000
--- a/nlsr-sync-0.0/nlsr_lsdb.h
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifndef _NLSR_LSDB_H_
-#define _NLSR_LSDB_H_
-
-#define LS_TYPE_ADJ 1
-#define LS_TYPE_NAME 2
-#define LS_TYPE_COR 3
-
-struct link
-{
-	struct name_prefix *nbr;
-	int face;
-	int metric;
-};
-
-
-struct alsa_header 
-{
-	unsigned int ls_type;
-	char *orig_time;
-	struct name_prefix *orig_router;
-	
-};
-
-struct alsa
-{
-	struct alsa_header *header;	
-	int no_link;
-	struct link *links;
-	char * body;
-};
-
-struct nlsa_header
-{
-	unsigned int ls_type;
-	char *orig_time;
-	long int ls_id;
-	struct name_prefix *orig_router;
-	unsigned int isValid;
-
-};
-
-struct nlsa
-{
-	struct nlsa_header *header;
-	struct name_prefix *name_prefix;
-};
-
-struct clsa
-{
-	struct alsa_header *header;
-	double cor_r;
-	double cor_theta;
-};
-
-
-void set_new_lsdb_version(void);
-void build_and_install_name_lsas(void);
-void build_and_install_single_name_lsa(struct name_prefix *np);
-void build_name_lsa(struct nlsa *name_lsa, struct name_prefix *np);
-void install_name_lsa(struct nlsa *name_lsa);
-void print_name_lsa(struct nlsa *name_lsa);
-void write_log_for_name_lsa(struct nlsa *name_lsa);
-void print_name_lsdb(void);
-void build_and_install_others_name_lsa(char *orig_router,int ls_type,long int ls_id,char *orig_time, int isValid,char *np);
-void build_others_name_lsa(struct nlsa *name_lsa, char *orig_router,int ls_type,long int ls_id, char *orig_time, int isValid, char *np);
-void make_name_lsa_key(char *key, char *orig_router, int ls_type, long int ls_id);
-int refresh_lsdb(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
-
-int build_and_install_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
-void build_adj_lsa(struct alsa * adj_lsa);
-void install_adj_lsa(struct alsa * adj_lsa);
-void print_adj_lsa_body(const char *body, int no_link);
-void print_adj_lsa(struct alsa * adj_lsa);
-void write_log_for_adj_lsa(struct alsa * adj_lsa);
-void print_adj_lsdb(void);
-void make_adj_lsa_key(char *key,struct alsa *adj_lsa);
-void build_and_install_others_adj_lsa(char *orig_router,int ls_type,char *orig_time, int no_link,char *data);
-void build_others_adj_lsa(struct alsa *adj_lsa,char *orig_router,int ls_type,char *orig_time,int no_link,char *data);
-
-long int get_name_lsdb_num_element(void);
-long int get_adj_lsdb_num_element(void);
-
-int check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time);
-int check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time);
-int check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time);
-
-void get_name_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
-void get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
-
-void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id);
-
-void build_and_install_cor_lsa();
-void print_cor_lsdb();
-
-void write_name_lsdb_to_repo(char *slice_prefix);
-void write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id);
-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);
-void write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id);
-
-void write_cor_lsa_to_repo(struct clsa *cor_lsa);
-void build_and_install_others_cor_lsa(char *orig_router,int ls_type,char *orig_time, double cor_r, double cor_theta);
-double get_hyperbolic_r(char *router);
-double get_hyperbolic_theta(char *router);
-
-#endif
diff --git a/nlsr-sync-0.0/nlsr_ndn.c b/nlsr-sync-0.0/nlsr_ndn.c
deleted file mode 100755
index 6ad79d5..0000000
--- a/nlsr-sync-0.0/nlsr_ndn.c
+++ /dev/null
@@ -1,726 +0,0 @@
-#include<stdio.h>
-#include<string.h>
-#include<stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <assert.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-
-#include "nlsr.h"
-#include "nlsr_ndn.h"
-#include "nlsr_npl.h"
-#include "nlsr_adl.h"
-#include "nlsr_lsdb.h"
-#include "utility.h"
-
-int
-appendLifetime(struct ccn_charbuf *cb, int lifetime) 
-{
-	unsigned char buf[sizeof(int32_t)];
-	int32_t dreck = lifetime << 12;
-	int pos = sizeof(int32_t);
-	int res = 0;
-	while (dreck > 0 && pos > 0) 
-	{
-		pos--;
-		buf[pos] = dreck & 255;
-		dreck = dreck >> 8;
-	}
-	res |= ccnb_append_tagged_blob(cb, CCN_DTAG_InterestLifetime, buf+pos, sizeof(buf)-pos);
-	return res;
-}
-
-
-void 
-get_nbr(struct name_prefix *nbr,struct ccn_closure *selfp, struct ccn_upcall_info *info)
-{
-	if ( nlsr->debugging )
-		printf("get_nbr called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_nbr called\n");
-
-	int res,i;
-	int nlsr_position=0;
-	int name_comps=(int)info->interest_comps->n;
-	int len=0;
-
-	for(i=0;i<name_comps;i++)
-	{
-		res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr");
-		if( res == 0)
-		{
-			nlsr_position=i;
-			break;
-		}	
-	}
-
-
-	const unsigned char *comp_ptr1;
-	size_t comp_size;
-	for(i=0;i<nlsr_position;i++)
-	{
-		res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,i,&comp_ptr1, &comp_size);
-		len+=1;
-		len+=(int)comp_size;	
-	}
-	len++;
-
-	char *neighbor=(char *)malloc(len);
-	memset(neighbor,0,len);
-
-	for(i=0; i<nlsr_position;i++)
-	{
-		res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,i,&comp_ptr1, &comp_size);
-		memcpy(neighbor+strlen(neighbor),"/",1);
-		memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1));
-
-	}
-
-	nbr->name=(char *)malloc(strlen(neighbor)+1);
-	memcpy(nbr->name,neighbor,strlen(neighbor)+1);
-	nbr->length=strlen(neighbor)+1;
-
-	if ( nlsr->debugging )
-		printf("Neighbor: %s Length: %d\n",nbr->name,nbr->length);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Neighbor: %s Length: %d\n",nbr->name,nbr->length);
-
-	
-
-}
-
-void 
-get_lsa_identifier(struct name_prefix *lsaId,struct ccn_closure *selfp, struct ccn_upcall_info *info, int offset)
-{
-
-	//printf("get_lsa_identifier called\n");
-
-	if ( nlsr->debugging )
-		printf("get_lsa_identifier called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_lsa_identifier called\n");
-	
-	int res,i;
-	int nlsr_position=0;
-	int name_comps=(int)info->interest_comps->n;
-	int len=0;
-
-	for(i=0;i<name_comps;i++)
-	{
-		res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr");
-		if( res == 0)
-		{
-			nlsr_position=i;
-			break;
-		}	
-	}
-
-
-	const unsigned char *comp_ptr1;
-	size_t comp_size;
-	for(i=nlsr_position+3+offset;i<info->interest_comps->n-1;i++)
-	{
-		res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,i,&comp_ptr1, &comp_size);
-		len+=1;
-		len+=(int)comp_size;	
-	}
-	len++;
-
-	char *neighbor=(char *)malloc(len);
-	memset(neighbor,0,len);
-
-	for(i=nlsr_position+3+offset; i<info->interest_comps->n-1;i++)
-	{
-		res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,i,&comp_ptr1, &comp_size);
-		memcpy(neighbor+strlen(neighbor),"/",1);
-		memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1));
-
-	}
-
-	lsaId->name=(char *)malloc(strlen(neighbor)+1);
-	memset(lsaId->name,0,strlen(neighbor)+1);
-	memcpy(lsaId->name,neighbor,strlen(neighbor)+1);
-	lsaId->length=strlen(neighbor)+1;
-
-	if ( nlsr->debugging )
-		printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length-1);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length-1);
-
-	//printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length-1);
-
-
-}
-
-int 
-get_ls_type(struct ccn_closure *selfp, struct ccn_upcall_info *info)
-{
-	int res,i;
-	int nlsr_position=0;
-	int name_comps=(int)info->interest_comps->n;
-
-	int ret=0;
-
-	for(i=0;i<name_comps;i++)
-	{
-		res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr");
-		if( res == 0)
-		{
-			nlsr_position=i;
-			break;
-		}	
-	}
-
-
-	const unsigned char *comp_ptr1;
-	size_t comp_size;
-	res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+2,&comp_ptr1, &comp_size);
-
-	ret=atoi((char *)comp_ptr1);
-
-	return ret;	
-
-}
-
-void 
-get_lsdb_version(char *lsdb_version,struct ccn_closure *selfp, struct ccn_upcall_info *info )
-{
-	const unsigned char *comp_ptr1;
-	size_t comp_size;
-	ccn_name_comp_get(info->content_ccnb, info->content_comps,info->content_comps->n-2,&comp_ptr1, &comp_size);
-	memcpy(lsdb_version,(char *)comp_ptr1,(int)comp_size);
-
-}
-
-
-/* Call back function registered in ccnd to get all interest coming to NLSR application */
-
-enum ccn_upcall_res 
-incoming_interest(struct ccn_closure *selfp,
-        enum ccn_upcall_kind kind, struct ccn_upcall_info *info)
-{
-
-    nlsr_lock();    
-
-    switch (kind) {
-        case CCN_UPCALL_FINAL:
-            break;
-        case CCN_UPCALL_INTEREST:
-		// printing the name prefix for which it received interest
-		if ( nlsr->debugging )
-            		printf("Interest Received for name: "); 
-		if ( nlsr->detailed_logging )
-            		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Received for name: ");
-		
-	    	struct ccn_charbuf*c;
-		c=ccn_charbuf_create();
-		ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E_Name],0);
-
-		if ( nlsr->debugging )
-			printf("%s\n",ccn_charbuf_as_string(c));
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"%s\n",ccn_charbuf_as_string(c));
-
-		ccn_charbuf_destroy(&c);
-
-		process_incoming_interest(selfp, info);
-		
-		break;
-
-        default:
-            break;
-    }
-
-     nlsr_unlock();
-
-    return CCN_UPCALL_RESULT_OK;
-}
-
-/* Function for processing incoming interest and reply with content/NACK content */
-
-void 
-process_incoming_interest(struct ccn_closure *selfp, struct ccn_upcall_info *info)
-{
-	if ( nlsr->debugging )
-		printf("process_incoming_interest called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest called \n");
-	
-	const unsigned char *comp_ptr1;
-	size_t comp_size;
-	int res,i;
-	int nlsr_position=0;
-	int name_comps=(int)info->interest_comps->n;
-
-	for(i=0;i<name_comps;i++)
-	{
-		res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr");
-		if( res == 0)
-		{
-			nlsr_position=i;
-			break;
-		}	
-	}
-
-	res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size);
-
-
-	if(!strcmp((char *)comp_ptr1,"info"))
-	{
-		process_incoming_interest_info(selfp,info);
-	}
-
-}
-
-void 
-process_incoming_interest_info(struct ccn_closure *selfp, struct ccn_upcall_info *info)
-{
-	if ( nlsr->debugging )
-	{
-		printf("process_incoming_interest_info called \n");
-		printf("Sending Info Content back.....\n");
-	}
-	if ( nlsr->detailed_logging )
-	{
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest_info called \n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending Info Content back.....\n");
-	}
-	
-
-	int res;
-	struct ccn_charbuf *data=ccn_charbuf_create();
-    	struct ccn_charbuf *name=ccn_charbuf_create();
-    	struct ccn_signing_params sp=CCN_SIGNING_PARAMS_INIT;
-
-	res=ccn_charbuf_append(name, info->interest_ccnb + info->pi->offset[CCN_PI_B_Name],info->pi->offset[CCN_PI_E_Name] - info->pi->offset[CCN_PI_B_Name]);
-	if (res >= 0)
-	{
-		sp.template_ccnb=ccn_charbuf_create();
-		ccn_charbuf_append_tt(sp.template_ccnb,CCN_DTAG_SignedInfo, CCN_DTAG);
-		ccnb_tagged_putf(sp.template_ccnb, CCN_DTAG_FreshnessSeconds, "%ld", 10);
-       	 	sp.sp_flags |= CCN_SP_TEMPL_FRESHNESS;
-		ccn_charbuf_append_closer(sp.template_ccnb);
-
-
-		char *raw_data=(char *)malloc(16);
-		memset(raw_data,0,16);
-		sprintf(raw_data,"%ld", nlsr->lsdb_synch_interval);	
-
-		res= ccn_sign_content(nlsr->ccn, data, name, &sp, raw_data,strlen(raw_data)); 
-		if(res >= 0)
-		{
-			if ( nlsr->debugging )
-				printf("Signing info Content is successful \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing info Content is successful \n");
-
-		}
-    		res=ccn_put(nlsr->ccn,data->buf,data->length);		
-		if(res >= 0)
-		{
-			if ( nlsr->debugging )
-				printf("Sending Info Content is successful \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending info Content is successful \n");
-		}
-		
-
-
-		struct name_prefix *nbr=(struct name_prefix * )malloc(sizeof(struct name_prefix *));
-		get_lsa_identifier(nbr,selfp,info,-1);
-
-		if ( nlsr->debugging )
-			printf("Neighbor : %s Length : %d Status : %d\n",nbr->name,nbr->length,get_adjacent_status(nbr));
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Neighbor : %s Length : %d Status : %d\n",nbr->name,nbr->length,get_adjacent_status(nbr));		
-
-		//printf("Neighbor : %s Length : %d Status : %d\n",nbr->name,nbr->length,get_adjacent_status(nbr));
-
-
-		if( get_adjacent_status(nbr) == 0 && get_timed_out_number(nbr)>=nlsr->interest_retry )
-		{
-			update_adjacent_timed_out_zero_to_adl(nbr);
-			send_info_interest_to_neighbor(nbr);
-		}
-
-		free(nbr);
-		free(raw_data);
-		ccn_charbuf_destroy(&sp.template_ccnb);
-	}
-
-	ccn_charbuf_destroy(&data);
-	ccn_charbuf_destroy(&name);
-
-}
-
-
-/* Call back function registered in ccnd to get all content coming to NLSR application */
-
-enum ccn_upcall_res incoming_content(struct ccn_closure* selfp,
-        enum ccn_upcall_kind kind, struct ccn_upcall_info* info)
-{
-
-     nlsr_lock();
-
-    switch(kind) {
-        case CCN_UPCALL_FINAL:
-            break;
-        case CCN_UPCALL_CONTENT:
-		if ( nlsr->debugging )
-			printf("Content Received for Name: "); 
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Content Received for Name: ");
-    
-		struct ccn_charbuf*c;
-		c=ccn_charbuf_create();
-		ccn_uri_append(c,info->interest_ccnb,info->pi->offset[CCN_PI_E],0);
-		if ( nlsr->debugging )
-			printf("%s\n",ccn_charbuf_as_string(c));
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"%s\n",ccn_charbuf_as_string(c));
-
-		ccn_charbuf_destroy(&c);
-
-		process_incoming_content(selfp,info);
-
-	    break;
-        case CCN_UPCALL_INTEREST_TIMED_OUT:
-		//printf("Interest Timed Out Received for Name: ");
-		if ( nlsr->debugging )
-			printf("Interest Timed Out Received for Name:  "); 
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Timed Out Received for Name: ");
-		
-		struct ccn_charbuf*ito;
-		ito=ccn_charbuf_create();
-		ccn_uri_append(ito,info->interest_ccnb,info->pi->offset[CCN_PI_E],0);
-
-		if ( nlsr->debugging )
-			printf("%s\n",ccn_charbuf_as_string(ito));
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"%s\n",ccn_charbuf_as_string(ito));
-
-		//printf("%s\n",ccn_charbuf_as_string(ito));
-		ccn_charbuf_destroy(&ito);
-
-		process_incoming_timed_out_interest(selfp,info);
-
-	    break;
-        default:
-            fprintf(stderr, "Unexpected response of kind %d\n", kind);
-	    if ( nlsr->debugging )
-		printf("Unexpected response of kind %d\n", kind);
-	    if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Unexpected response of kind %d\n", kind);
-	    break;
-    }
-    
-     nlsr_unlock();
-
-    return CCN_UPCALL_RESULT_OK;
-}
-
-
-void 
-process_incoming_content(struct ccn_closure *selfp, struct ccn_upcall_info* info)
-{
-	if ( nlsr->debugging )
-		printf("process_incoming_content called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_content called \n");
-
-	const unsigned char *comp_ptr1;
-	size_t comp_size;
-	int res,i;
-	int nlsr_position=0;
-	int name_comps=(int)info->interest_comps->n;
-
-	for(i=0;i<name_comps;i++)
-	{
-		res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr");
-		if( res == 0)
-		{
-			nlsr_position=i;
-			break;
-		}	
-	}
-
-	res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size);
-
-
-	if(!strcmp((char *)comp_ptr1,"info"))
-	{
-		process_incoming_content_info(selfp,info);
-	}
-
-}
-
-
-void 
-process_incoming_content_info(struct ccn_closure *selfp, struct ccn_upcall_info* info)
-{
-	if ( nlsr->debugging )
-		printf("process_incoming_content_info called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_content_info called \n");
-
-	struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	get_nbr(nbr,selfp,info);
-
-	if ( nlsr->debugging )
-		printf("Info Content Received For Neighbor: %s Length:%d\n",nbr->name,nbr->length);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Info Content Received For Neighbor: %s Length:%d\n",nbr->name,nbr->length);
-
-
-	const unsigned char *ptr;
-	size_t length;
-	ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E_Content]-info->pco->offset[CCN_PCO_B_Content], info->pco, &ptr, &length);
-
-	long int interval=atoi((char *)ptr);
-
-
-
-	update_adjacent_timed_out_zero_to_adl(nbr);	
-	update_adjacent_status_to_adl(nbr,NBR_ACTIVE);
-	update_lsdb_synch_interval_to_adl(nbr,interval);
-	print_adjacent_from_adl();
-
-
-
-	if(!nlsr->is_build_adj_lsa_sheduled)
-	{
-		if ( nlsr->debugging )
-			printf("Scheduling Build and Install Adj LSA...\n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Scheduling Build and Install Adj LSA...\n");
-		nlsr->event_build_adj_lsa = ccn_schedule_event(nlsr->sched, 100000, &build_and_install_adj_lsa, NULL, 0);
-		nlsr->is_build_adj_lsa_sheduled=1;		
-	}
-	else
-	{
-		if ( nlsr->debugging )
-			printf("Build and Install Adj LSA already scheduled\n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Build and Install Adj LSA already scheduled\n");
-	}
-
-
-	free(nbr);
-
-
-}
-
-
-
-
-void
-process_incoming_timed_out_interest(struct ccn_closure* selfp, struct ccn_upcall_info* info)
-{
-	
-
-	if ( nlsr->debugging )
-		printf("process_incoming_timed_out_interest called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_timed_out_interest called \n");
-
-	int res,i;
-	int nlsr_position=0;
-	int name_comps=(int)info->interest_comps->n;
-
-	for(i=0;i<name_comps;i++)
-	{
-		res=ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,i,"nlsr");
-		if( res == 0)
-		{
-			nlsr_position=i;
-			break;
-		}	
-	}
-
-	if(ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,nlsr_position+1,"info") == 0)
-	{
-		process_incoming_timed_out_interest_info(selfp,info);
-	}
-}
-
-void
-process_incoming_timed_out_interest_info(struct ccn_closure* selfp, struct ccn_upcall_info* info)
-{
-	
-	if ( nlsr->debugging )
-		printf("process_incoming_timed_out_interest_info called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_timed_out_interest_info called \n");
-
-	struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	get_nbr(nbr,selfp,info);
-
-	if ( nlsr->debugging )
-		printf("Info Interest Timed Out for for Neighbor: %s Length:%d\n",nbr->name,nbr->length);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Info Interest Timed Out for for Neighbor: %s Length:%d\n",nbr->name,nbr->length);
-	
-
-
-	update_adjacent_timed_out_to_adl(nbr,1);
-	print_adjacent_from_adl();	
-	int timed_out=get_timed_out_number(nbr);
-
-	if ( nlsr->debugging )
-		printf("Neighbor: %s Info Interest Timed Out: %d times\n",nbr->name,timed_out);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Neighbor: %s Info Interest Timed Out: %d times\n",nbr->name,timed_out);
-
-
-	if(timed_out<nlsr->interest_retry && timed_out>0) // use configured variables 
-	{
-		send_info_interest_to_neighbor(nbr);
-	}
-	else
-	{		
-		update_adjacent_status_to_adl(nbr,NBR_DOWN);
-		if(!nlsr->is_build_adj_lsa_sheduled)
-		{
-			nlsr->event_build_adj_lsa = ccn_schedule_event(nlsr->sched, 1000, &build_and_install_adj_lsa, NULL, 0);
-			nlsr->is_build_adj_lsa_sheduled=1;		
-		}
-	}
-
-	free(nbr);
-
-
-}
-
-
-int
-send_info_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-
-         nlsr_lock();
-
-	if ( nlsr->debugging )
-		printf("send_info_interest called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"send_info_interest called \n");
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-
-	int adl_element,i;
-	struct ndn_neighbor *nbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-		send_info_interest_to_neighbor(nbr->neighbor);
-		hashtb_next(e);		
-	}
-	hashtb_end(e);
-
-	 nlsr_unlock();
-
-	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &send_info_interest, NULL, 0);
-
-	return 0;
-}
-
-void 
-send_info_interest_to_neighbor(struct name_prefix *nbr)
-{
-
-	if ( nlsr->debugging )
-		printf("send_info_interest_to_neighbor called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"send_info_interest_to_neighbor called \n");
-
-
-	int res;
-	char info_str[5];
-	char nlsr_str[5];
-	
-	memset(&nlsr_str,0,5);
-	sprintf(nlsr_str,"nlsr");
-	memset(&info_str,0,5);
-	sprintf(info_str,"info");
-	
-	
-	struct ccn_charbuf *name;	
-	name=ccn_charbuf_create();
-
-	char *int_name=(char *)malloc(strlen(nbr->name)+1+strlen(nlsr_str)+1+strlen(info_str)+strlen(nlsr->router_name)+1);
-	memset(int_name,0,strlen(nbr->name)+1+strlen(nlsr_str)+1+strlen(info_str)+strlen(nlsr->router_name)+1);
-	memcpy(int_name+strlen(int_name),nbr->name,strlen(nbr->name));
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),nlsr_str,strlen(nlsr_str));
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),info_str,strlen(info_str));
-	memcpy(int_name+strlen(int_name),nlsr->router_name,strlen(nlsr->router_name));
-	
-
-	res=ccn_name_from_uri(name,int_name);
-	if ( res >=0 )
-	{
-		/* adding InterestLifeTime and InterestScope filter */
-
-		struct ccn_charbuf *templ;
-		templ = ccn_charbuf_create();
-
-		ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
-		ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
-		ccn_charbuf_append_closer(templ); /* </Name> */
-		ccn_charbuf_append_tt(templ, CCN_DTAG_Scope, CCN_DTAG);
-		ccn_charbuf_append_tt(templ, 1, CCN_UDATA);
-		/* Adding InterestLifeTime and InterestScope filter done */		
-		ccn_charbuf_append(templ, "2", 1); //scope of interest: 2 (not further than next host)
-		ccn_charbuf_append_closer(templ); /* </Scope> */
-
-		appendLifetime(templ,nlsr->interest_resend_time);
-		unsigned int face_id=get_next_hop_face_from_adl(nbr->name);
-		ccnb_tagged_putf(templ, CCN_DTAG_FaceID, "%u", face_id);
-		ccn_charbuf_append_closer(templ); /* </Interest> */
-		
-	
-		if ( nlsr->debugging )
-			printf("Sending info interest on name prefix : %s through Face:%u\n",int_name,face_id);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending info interest on name prefix : %s through Face:%u\n",int_name,face_id);
-
-		res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ);
-
-		if ( res >= 0 )
-		{
-			if ( nlsr->debugging )
-				printf("Info interest sending Successfull .... \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Info interest sending Successfull .... \n");
-		}	
-		ccn_charbuf_destroy(&templ);
-	}
-	ccn_charbuf_destroy(&name);
-	free(int_name);
-
-}
diff --git a/nlsr-sync-0.0/nlsr_ndn.h b/nlsr-sync-0.0/nlsr_ndn.h
deleted file mode 100755
index 1e34284..0000000
--- a/nlsr-sync-0.0/nlsr_ndn.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef _NLSR_NDN_H_
-#define _NLSR_NDN_H_
-
-int appendLifetime(struct ccn_charbuf *cb, int lifetime);
-void get_nbr(struct name_prefix *nbr,struct ccn_closure *selfp, struct ccn_upcall_info *info);
-void get_lsa_identifier(struct name_prefix *lsaId,struct ccn_closure *selfp, struct ccn_upcall_info *info,int offset);
-void get_lsdb_version(char *lsdb_version,struct ccn_closure *selfp, struct ccn_upcall_info *info );
-int get_ls_type(struct ccn_closure *selfp, struct ccn_upcall_info *info);
-
-enum ccn_upcall_res incoming_interest(struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info); 
-void process_incoming_interest(struct ccn_closure *selfp, struct ccn_upcall_info *info);
-void process_incoming_interest_info(struct ccn_closure *selfp, struct ccn_upcall_info *info);
-
-enum ccn_upcall_res incoming_content(struct ccn_closure* selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info* info);
-void process_incoming_content(struct ccn_closure *selfp, struct ccn_upcall_info* info);
-void process_incoming_content_info(struct ccn_closure *selfp, struct ccn_upcall_info* info);
-
-void process_incoming_timed_out_interest(struct ccn_closure* selfp, struct ccn_upcall_info* info);
-void process_incoming_timed_out_interest_info(struct ccn_closure* selfp, struct ccn_upcall_info* info);
-
-int send_info_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
-void send_info_interest_to_neighbor(struct name_prefix *nbr);
-
-
-#endif
diff --git a/nlsr-sync-0.0/nlsr_npl.c b/nlsr-sync-0.0/nlsr_npl.c
deleted file mode 100755
index a2e2271..0000000
--- a/nlsr-sync-0.0/nlsr_npl.c
+++ /dev/null
@@ -1,174 +0,0 @@
-#include<stdio.h>
-#include<string.h>
-#include<stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <assert.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-
-#include "nlsr.h"
-#include "nlsr_npl.h"
-#include "utility.h"
-
-
-void 
-add_name_to_npl(struct name_prefix *np)
-{
-	struct name_prefix_list_entry *npe=(struct name_prefix_list_entry *)malloc(sizeof(struct name_prefix_list_entry));
-	//struct name_prefix *hnp=(struct name_prefix *)malloc(sizeof(struct name_prefix )); //free
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->npl, e);
-    	res = hashtb_seek(e, np->name, np->length, 0);
-
-	if(res == HT_NEW_ENTRY)
-	{   
-		npe=e->data;
-		npe->np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-		npe->np->length=np->length;
-		npe->np->name=(char *)malloc(np->length);
-		memcpy(npe->np->name,np->name,np->length);
-		npe->name_lsa_id=0;
-		//hnp = e->data;
-		//hnp->length=np->length;
-		//hnp->name=(char *)malloc(np->length); //free
-		//memcpy(hnp->name,np->name,np->length);
-	}
-    	
-	hashtb_end(e);
-
-}
-
-int  
-does_name_exist_in_npl(struct name_prefix *np)
-{
-	int ret=0;
-
-	//struct name_prefix_entry *npe;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->npl, e);
-    	res = hashtb_seek(e, np->name, np->length, 0);
-
-	if(res == HT_NEW_ENTRY)
-	{   
-		hashtb_delete(e);
-		ret=0;
-	}
-	else
-	{
-		ret=1;
-    	}
-	hashtb_end(e);
-
-	return ret;
-
-}
-
-
-long int  
-get_lsa_id_from_npl(struct name_prefix *np)
-{
-	int ret=0;
-
-	struct name_prefix_list_entry *npe;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->npl, e);
-    	res = hashtb_seek(e, np->name, np->length, 0);
-
-	if(res == HT_NEW_ENTRY)
-	{   
-		hashtb_delete(e);
-		ret=0;
-	}
-	else
-	{
-		npe=e->data;
-		ret=npe->name_lsa_id;
-    	}
-	hashtb_end(e);
-
-	return ret;
-
-}
-
-void
-print_name_prefix_from_npl(void)
-{
-	if ( nlsr->debugging )
-		printf("print_name_prefix_from_npl called \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_name_prefix_from_npl called\n");
-	int i, npl_element;
-	//struct name_prefix *np;
-	struct name_prefix_list_entry *npe;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npl, e);
-	npl_element=hashtb_n(nlsr->npl);
-
-	for(i=0;i<npl_element;i++)
-	{
-		npe=e->data;
-		if ( nlsr->debugging )
-			printf("Name Prefix: %s and Length: %d and LSA Id: %ld\n",npe->np->name,npe->np->length,npe->name_lsa_id);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Name Prefix: %s and Length: %d \n",npe->np->name,npe->np->length);	
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-}
-
-void 
-update_nlsa_id_for_name_in_npl(struct name_prefix *np, long int nlsa_id)
-{
-	struct name_prefix_list_entry *npe;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->npl, e);
-    	res = hashtb_seek(e, np->name, np->length, 0);
-
-	if(res == HT_OLD_ENTRY)
-	{   
-		npe=e->data;
-		npe->name_lsa_id=nlsa_id;
-	}
-	else
-	{
-		hashtb_delete(e);	
-	}
-    	
-	hashtb_end(e);
-}
-
diff --git a/nlsr-sync-0.0/nlsr_npl.h b/nlsr-sync-0.0/nlsr_npl.h
deleted file mode 100755
index 4fce119..0000000
--- a/nlsr-sync-0.0/nlsr_npl.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _NLSR_NPL_H_
-#define _NLSR_NPL_H_
-
-struct name_prefix_list_entry
-{
-	struct name_prefix *np;
-	long int name_lsa_id;
-};
-
-void add_name_to_npl(struct name_prefix *np);
-void print_name_prefix_from_npl(void);
-int does_name_exist_in_npl(struct name_prefix *np);
-void update_nlsa_id_for_name_in_npl(struct name_prefix *np, long int nlsa_id);
-long int get_lsa_id_from_npl(struct name_prefix *np);
-#endif
diff --git a/nlsr-sync-0.0/nlsr_npt.c b/nlsr-sync-0.0/nlsr_npt.c
deleted file mode 100755
index 64373fe..0000000
--- a/nlsr-sync-0.0/nlsr_npt.c
+++ /dev/null
@@ -1,1071 +0,0 @@
-#include<stdio.h>
-#include<string.h>
-#include<stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <assert.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <sys/types.h>
-#include <signal.h>
-
-
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-
-#include "nlsr.h"
-#include "nlsr_npt.h"
-#include "nlsr_fib.h"
-#include "nlsr_route.h"
-#include "nlsr_adl.h"
-#include "utility.h"
-
-int
-add_npt_entry(char *orig_router, char *name_prefix, int num_face, int *faces, int *route_costs)
-{
-	if ( strcmp(orig_router,nlsr->router_name)== 0)
-	{
-		return -1;
-	}
-
-	struct npt_entry *ne=(struct npt_entry*)malloc(sizeof(struct npt_entry ));
-	
-	int res,res_nle,res_fle;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    
-
-   	hashtb_start(nlsr->npt, e);
-    	res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
-
-	if(res == HT_NEW_ENTRY)
-	{
-		ne=e->data;
-
-		ne->orig_router=(char *)malloc(strlen(orig_router)+1);
-		memset(ne->orig_router,0,strlen(orig_router)+1);
-		memcpy(ne->orig_router,orig_router,strlen(orig_router));
-
-	
-		
-
-		struct hashtb_param param_nle = {0};
-		ne->name_list= hashtb_create(sizeof(struct name_list_entry ), &param_nle);
-
-		struct hashtb_enumerator eenle;
-    		struct hashtb_enumerator *enle = &eenle;
-
-		hashtb_start(ne->name_list, enle);
-		res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0);
-
-		if(res_nle == HT_NEW_ENTRY )
-		{
-			struct name_list_entry *nle=(struct name_list_entry *)malloc(sizeof(struct name_list_entry));
-			nle=enle->data;
-			nle->name=(char *)malloc(strlen(name_prefix)+1);
-			memset(nle->name,0,strlen(name_prefix)+1);
-			memcpy(nle->name,name_prefix,strlen(name_prefix));
-
-			
-
-		}
-		hashtb_end(enle);
-
-		struct hashtb_param param_fle = {0};
-		ne->face_list=hashtb_create(sizeof(struct face_list_entry), &param_fle);
-
-		if ( num_face > 0 )
-		{
-			struct hashtb_enumerator eef;
-    			struct hashtb_enumerator *ef = &eef;
-    	
-    			hashtb_start(ne->face_list, ef);
-			int i;						
-
-			for ( i=0; i < num_face ; i++)
-			{
-				int face=faces[i];
-				if ( face != NO_FACE && face != ZERO_FACE)
-				{
-					res_fle = hashtb_seek(ef, &face, sizeof(face), 0);
-				
-					if ( res_fle == HT_NEW_ENTRY )
-					{
-						struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry));
-						fle=ef->data;
-						fle->next_hop_face=face;
-						fle->route_cost=route_costs[i];
-					}
-				}
-		
-			}
-			hashtb_end(ef);
-		}
-		
-	}
-	else if (res == HT_OLD_ENTRY)
-	{
-		free(ne);
-		struct npt_entry *one;
-
-		one=e->data;
-		
-		struct hashtb_enumerator eenle;
-    		struct hashtb_enumerator *enle = &eenle;
-
-		hashtb_start(one->name_list, enle);
-		res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0);
-
-		if(res_nle == HT_NEW_ENTRY )
-		{
-			struct name_list_entry *nle=(struct name_list_entry *)malloc(sizeof(struct name_list_entry));
-			nle=enle->data;
-			nle->name=(char *)malloc(strlen(name_prefix)+1);
-			memset(nle->name,0,strlen(name_prefix)+1);
-			memcpy(nle->name,name_prefix,strlen(name_prefix));
-		}
-		else if(res_nle == HT_OLD_ENTRY )
-		{
-			
-		}
-		hashtb_end(enle);
-
-		if ( num_face > 0 )
-		{
-			struct hashtb_enumerator eef;
-    			struct hashtb_enumerator *ef = &eef;
-    	
-    			hashtb_start(one->face_list, ef);
-			int i;						
-
-			for ( i=0; i< num_face ; i ++)
-			{
-				int face=faces[i];
-				if ( face != NO_FACE && face != ZERO_FACE)
-				{
-					res_fle = hashtb_seek(ef, &face, sizeof(face), 0);
-				
-					if ( res_fle == HT_NEW_ENTRY )
-					{
-						struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry));
-						fle=ef->data;
-						fle->next_hop_face=face;
-						fle->route_cost=route_costs[i];
-					}
-				}
-			}
-			hashtb_end(ef);
-		}
-	
-
-	}
-	hashtb_end(e);
-
-	update_ccnd_fib_for_orig_router(orig_router);
-
-	return res;
-}
-
-void 
-update_ccnd_fib_for_orig_router(char *orig_router)
-{
-
-	if ( nlsr->debugging )
-	{
-		printf("update_ccnd_fib_for_orig_router called\n");
-	}
-
-	int res;	
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    
-
-   	hashtb_start(nlsr->npt, e);
-    	res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
-
-	if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-	else if ( res == HT_OLD_ENTRY )
-	{
-		struct npt_entry *ne;
-		ne=e->data;
-		int num_face=hashtb_n(ne->face_list);
-		int last_face,first_face;
-
-		int *faces=(int *)malloc(num_face*sizeof(int));
-		int *route_costs=(int *)malloc(num_face*sizeof(int));
-		
-		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);
-		
-		if ( nlsr->debugging )
-		{
-			int m;
-			for ( m =0 ; m< num_face ; m++)
-			{
-				printf("Dest_router: %s Next_Hop_Face: %d Route_cost: %d \n",orig_router,faces[m],route_costs[m]);
-			}
-		}
-
-		first_face=num_face-1;		
-	
-		if ( nlsr->multi_path_face_num == 0 )
-		{
-			last_face=first_face;
-		}
-		else 
-		{
-			if ( num_face <= nlsr->multi_path_face_num)
-			{
-				last_face=0;
-			}
-			else
-			{
-				last_face=num_face-nlsr->multi_path_face_num;
-			}
-			
-		}
-
-		int i,j, nl_element;
-		struct name_list_entry *nle;		
-		struct hashtb_enumerator eenle;
-    		struct hashtb_enumerator *enle = &eenle;
-
-		hashtb_start(ne->name_list, enle);
-		nl_element=hashtb_n(ne->name_list);	
-
-		for (i=0;i<nl_element;i++)
-		{
-			nle=enle->data;
-			
-			for( j=first_face; j>= last_face; j--)
-			{
-				if ( nlsr->debugging )
-				{
-					printf("Possible FIB Entry name: %s face: %d route cost: %d \n",nle->name,faces[j],route_costs[j]);
-				}
-				if ( is_active_neighbor(orig_router) == 0 )
-				{
-					if ( nlsr->debugging )
-						printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);	
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
-					add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);	
-				}
-				else 
-				{
-					if ( j == last_face &&  is_active_neighbor(nle->name)==0)
-					{
-						if ( nlsr->debugging )
-							printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);	
-						if ( nlsr->detailed_logging )
-							writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
-						add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);
-					}
-				}
-			}
-			
-			
-			hashtb_next(enle);
-		}
-		hashtb_end(enle);
-		
-
-
-		free(faces);
-		free(route_costs);
-
-	}
-	hashtb_end(e);
-
-}
-
-int 
-delete_npt_entry_by_router_and_name_prefix(char *orig_router, char *name_prefix)
-{
-	if ( strcmp(orig_router,nlsr->router_name)== 0)
-	{
-		return -1;
-	}
-
-	struct npt_entry *ne;
-	
-	int res,res_nle;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    
-
-   	hashtb_start(nlsr->npt, e);
-    	res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
-
-	if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-		return -1;
-	}
-	else if (res == HT_OLD_ENTRY)
-	{
-		ne=e->data;
-
-		struct hashtb_enumerator eenle;
-    		struct hashtb_enumerator *enle = &eenle;
-
-		hashtb_start(ne->name_list, enle);
-		res_nle = hashtb_seek(enle, name_prefix, strlen(name_prefix), 0);
-
-		if(res_nle == HT_NEW_ENTRY )
-		{
-			hashtb_delete(enle);
-		}
-		else if(res_nle == HT_OLD_ENTRY )
-		{
-			struct name_list_entry *nle;
-
-			nle=enle->data;
-	
-			int j;
-			int num_face=hashtb_n(ne->face_list);
-			int last_face,first_face;
-
-			int *faces=(int *)malloc(num_face*sizeof(int));
-			int *route_costs=(int *)malloc(num_face*sizeof(int));
-		
-			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 )
-			{
-				last_face=first_face;
-			}
-			else 
-			{
-				if ( num_face <= nlsr->multi_path_face_num)
-				{
-					last_face=0;
-				}
-				else
-				{
-					last_face=num_face-nlsr->multi_path_face_num;
-				}
-			}			
-
-			for( j=first_face; j>= last_face; j--)
-			{
-
-				if ( is_active_neighbor(orig_router) == 0 )
-				{
-					if ( nlsr->debugging )
-						printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);	
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
-					add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);	
-				}
-				else 
-				{
-					if ( j == last_face && is_active_neighbor(nle->name)==0)
-					{
-						if ( nlsr->debugging )
-							printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);	
-						if ( nlsr->detailed_logging )
-							writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
-						add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
-					}
-				}
-				
-			}
-			
-		}
-
-		hashtb_end(enle);
-	}
-	
-	hashtb_end(e);
-
-	return 0;
-}
-
-void 
-print_npt(void)
-{
-
-	if ( nlsr->debugging )
-	{
-		printf("\n");
-		printf("print_npt called\n");
-	}
-	if ( nlsr->detailed_logging )
-	{
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_npt called\n");
-	}
-	int i, npt_element;
-	
-	struct npt_entry *ne;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npt, e);
-	npt_element=hashtb_n(nlsr->npt);
-
-	for(i=0;i<npt_element;i++)
-	{
-		if ( nlsr->debugging )
-		{
-			printf("\n");
-			printf("----------NPT ENTRY %d------------------\n",i+1);
-		}
-		if ( nlsr->detailed_logging )
-		{
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"----------NPT ENTRY %d------------------\n",i+1);
-		}
-		ne=e->data;
-		if ( nlsr->debugging )
-			printf(" Origination Router: %s \n",ne->orig_router);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__," Origination Router: %s \n",ne->orig_router);
-		
-		int j, nl_element,face_list_element;
-		struct name_list_entry *nle;		
-		struct hashtb_enumerator eenle;
-    		struct hashtb_enumerator *enle = &eenle;
-
-		hashtb_start(ne->name_list, enle);
-		nl_element=hashtb_n(ne->name_list);	
-
-		for (j=0;j<nl_element;j++)
-		{
-			nle=enle->data;
-			if ( nlsr->debugging )
-				printf(" Name Prefix: %s \n",nle->name);
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Name Prefix: %s \n",nle->name);
-			hashtb_next(enle);
-		}
-		hashtb_end(enle);
-
-		struct face_list_entry *fle;
-
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(ne->face_list, ef);
-		face_list_element=hashtb_n(ne->face_list);
-		if ( face_list_element <= 0 )
-		{
-			if ( nlsr->debugging )
-				printf(" 	Face: No Face \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: No Face \n");
-			
-		}
-		else
-		{
-			for(j=0;j<face_list_element;j++)
-			{
-				fle=ef->data;
-				if ( nlsr->debugging )
-					printf(" 	Face: %d Route_Cost: %f \n",fle->next_hop_face,fle->route_cost);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
-				hashtb_next(ef);	
-			}
-		}
-		hashtb_end(ef);
-		
-			
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-}
-
-void
-delete_orig_router_from_npt(char *orig_router)
-{
-	int res,num_face,num_prefix;
-	struct npt_entry *ne;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npt, e);
-	res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
-
-	if ( res == HT_OLD_ENTRY )
-	{
-		ne=e->data;
-		num_prefix=hashtb_n(ne->name_list);
-		if ( num_prefix > 0 )
-		{
-			num_face=hashtb_n(ne->face_list);
-			
-			if ( num_face > 0  )
-			{
-				int j, nl_element;
-				struct name_list_entry *nle;		
-				struct hashtb_enumerator eenle;
-    				struct hashtb_enumerator *enle = &eenle;
-
-				hashtb_start(ne->name_list, enle);
-				nl_element=hashtb_n(ne->name_list);	
-
-				for (j=0;j<nl_element;j++)
-				{
-					nle=enle->data;
-					delete_npt_entry_by_router_and_name_prefix(ne->orig_router,nle->name);		
-					hashtb_next(enle);
-				}
-				hashtb_end(enle);				
-
-			} 
-
-		}
-		hashtb_destroy(&ne->name_list);
-		hashtb_destroy(&ne->face_list);
-		hashtb_delete(e);		
-	}
-	else if ( res == HT_NEW_ENTRY )
-	{
-		hashtb_delete(e);
-	}
-	hashtb_end(e);	
-}
-
-
-void
-add_face_to_npt_by_face_id(char *dest_router, int face_id, int route_cost)
-{
-	if ( nlsr->debugging )
-	{
-		printf("add_face_to_npt_by_face_id called\n");
-		printf("Dest Router: %s Face: %d Route_cost: %d \n",dest_router, face_id, route_cost);
-	}
-	if ( nlsr->detailed_logging )
-	{
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"add_face_to_npt_by_face_id called\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Dest Router: %s Face: %d Route_cost: %d \n",dest_router, face_id, route_cost);
-	}
-
-	
-	int res,res1;
-	struct npt_entry *ne;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npt, e);
-	res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
-
-	if ( res == HT_OLD_ENTRY )
-	{
-		if ( nlsr->debugging )
-			printf("Dest Router Found \n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Dest Router Found \n");
-	
-		ne=e->data;
-		
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(ne->face_list, ef);
-		res1=hashtb_seek(ef, &face_id, sizeof(face_id), 0);
-
-		if ( res1 == HT_OLD_ENTRY )
-		{
-			if ( nlsr->debugging )
-				printf("Face Found \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face Found \n");
-			struct face_list_entry *fle;
-			fle=ef->data;
-			fle->next_hop_face=face_id;
-			fle->route_cost=route_cost;
-		}
-		else if ( res1 == HT_NEW_ENTRY )
-		{
-			if ( nlsr->debugging )
-				printf("Face Not Found \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face Not Found \n");
-			struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry));
-			fle=ef->data;
-			fle->next_hop_face=face_id;
-			fle->route_cost=route_cost;
-
-			
-
-
-		}
-		hashtb_end(ef);
-	}
-	else if (res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-	
-	hashtb_end(e);
-}
-
-
-void
-add_new_fib_entries_to_npt(void)
-{
-	if ( nlsr->debugging )
-		printf("add_new_fib_entries_to_npt called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"add_new_fib_entries_to_npt called\n");
-	int i,j, rt_element,face_list_element;
-	
-	struct routing_table_entry *rte;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->routing_table, e);
-	rt_element=hashtb_n(nlsr->routing_table);
-
-	for(i=0;i<rt_element;i++)
-	{
-		rte=e->data;
-
-		struct face_list_entry *fle;
-
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(rte->face_list, ef);
-		face_list_element=hashtb_n(rte->face_list);
-		if ( face_list_element <= 0 )
-		{
-			if ( nlsr->debugging )
-				printf(" Face: No Face \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n");
-		}
-		else
-		{
-			for(j=0;j<face_list_element;j++)
-			{
-				fle=ef->data;
-				add_face_to_npt_by_face_id(rte->dest_router,fle->next_hop_face,fle->route_cost);
-				hashtb_next(ef);	
-			}
-		}
-		hashtb_end(ef);
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-
-void
-delete_face_from_npt_by_face_id(char *dest_router, int face_id)
-{
-	if ( nlsr->debugging )
-		printf("delete_face_from_npt_by_face_id\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_face_from_npt_by_face_id\n");
-
-	int res,res1;
-	struct npt_entry *ne;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npt, e);
-	res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
-
-	if ( res == HT_OLD_ENTRY )
-	{
-		ne=e->data;
-		
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(ne->face_list, ef);
-		res1=hashtb_seek(ef, &face_id, sizeof(face_id), 0);
-		if ( res1 == HT_OLD_ENTRY )
-		{
-			hashtb_delete(ef);
-		}
-		else if ( res1 == HT_NEW_ENTRY )
-		{
-			hashtb_delete(ef);
-		}
-		hashtb_end(ef);
-	}
-	else if (res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-	
-	hashtb_end(e);
-}
-
-
-void 
-clean_old_fib_entries_from_npt(void)
-{
-	
-	
-	if ( nlsr->debugging )
-		printf("clean_old_fib_entries_from_npt called\n\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"clean_old_fib_entries_from_npt called\n\n");
-	int i, npt_element;
-	
-	struct npt_entry *ne;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npt, e);
-	npt_element=hashtb_n(nlsr->npt);
-
-	for(i=0;i<npt_element;i++)
-	{
-		ne=e->data;
-		
-		int j,k, nl_element,face_list_element;
-		struct face_list_entry *fle;
-
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(ne->face_list, ef);
-		face_list_element=hashtb_n(ne->face_list);
-		if ( face_list_element <= 0 )
-		{
-			if ( nlsr->debugging )
-				printf(" Face: No Face \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: No Face \n");
-			
-		}
-		else
-		{
-			for(j=0;j<face_list_element;j++)
-			{
-				fle=ef->data;
-				int check=does_face_exist_for_router(ne->orig_router,fle->next_hop_face);
-				if ( check == 0 )
-				{
-					struct name_list_entry *nle;		
-					struct hashtb_enumerator eenle;
-    					struct hashtb_enumerator *enle = &eenle;
-
-					hashtb_start(ne->name_list, enle);
-					nl_element=hashtb_n(ne->name_list);	
-
-					for (k=0;k<nl_element;k++)
-					{
-						nle=enle->data;
-						if( is_neighbor(nle->name) == 0 )
-						{
-							if ( nlsr->debugging )
-								printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
-							if ( nlsr->detailed_logging )
-								writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);		
-							add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
-						}						
-		
-
-						hashtb_next(enle);
-					}
-					hashtb_end(enle);
-
-
-					hashtb_delete(ef);
-					j++;
-						
-				}
-				else 
-				{
-					struct name_list_entry *nle;		
-					struct hashtb_enumerator eenle;
-    					struct hashtb_enumerator *enle = &eenle;
-
-					hashtb_start(ne->name_list, enle);
-					nl_element=hashtb_n(ne->name_list);	
-
-					for (k=0;k<nl_element;k++)
-					{
-						nle=enle->data;
-						if(  is_active_neighbor(ne->orig_router) && get_next_hop_face_from_adl(	ne->orig_router ) != fle->next_hop_face )
-						{
-							if ( nlsr->debugging )
-								printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
-							if ( nlsr->detailed_logging )
-								writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);		
-							add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
-						}						
-		
-
-						hashtb_next(enle);
-					}
-					hashtb_end(enle);
-					
-					hashtb_next(ef);
-				}	
-			}
-		}
-		hashtb_end(ef);
-		
-			
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-void
-update_npt_with_new_route(void)
-{
-	if ( nlsr->debugging )
-		printf("update_npt_with_new_route called\n");
-		
-	clean_old_fib_entries_from_npt();
-	print_npt();
-	add_new_fib_entries_to_npt();
-	print_npt();	
-
-	int i, npt_element;
-	
-	struct npt_entry *ne;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npt, e);
-	npt_element=hashtb_n(nlsr->npt);
-
-	for(i=0;i<npt_element;i++)
-	{
-	
-		ne=e->data;
-		update_ccnd_fib_for_orig_router(ne->orig_router);
-		hashtb_next(e);
-	}
-	
-	hashtb_end(e);
-}
-
-
-
-void 
-sort_faces_by_distance(int *faces,int *route_costs,int start,int element)
-{
-	int i,j;
-	int temp_cost;
-	int temp_face;
-
-	for ( i=start ; i < element ; i ++) 
-	{
-		for( j=i+1; j<element; j ++)
-		{
-			if (route_costs[j] < route_costs[i] )
-			{
-				temp_cost=route_costs[j];
-				route_costs[j]=route_costs[i];
-				route_costs[i]=temp_cost;
-
-				temp_face=faces[j];
-				faces[j]=faces[i];
-				faces[i]=temp_face;
-			}
-		}
-	}
-	
-}
-
-void
-get_all_faces_for_orig_router_from_npt(char *orig_router, int *faces, int *route_costs, int num_faces)
-{
-
-	int res,face_list_element,j;	
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    
-
-   	hashtb_start(nlsr->npt, e);
-    	res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
-
-	if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-	else if ( res == HT_OLD_ENTRY )
-	{
-		struct npt_entry *ne;
-		ne=e->data;
-		
-		struct face_list_entry *fle;
-
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(ne->face_list, ef);
-		face_list_element=hashtb_n(ne->face_list);
-		for(j=0;j<face_list_element;j++)
-		{
-			fle=ef->data;
-			faces[j]=fle->next_hop_face;
-			route_costs[j]=fle->route_cost;
-			hashtb_next(ef);	
-		}
-		hashtb_end(ef);
-		
-
-	}
-	hashtb_end(e);
-
-}
-
-void 
-destroy_faces_by_orig_router(char *orig_router)
-{
-
-	int res;	
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    
-
-   	hashtb_start(nlsr->npt, e);
-    	res = hashtb_seek(e, orig_router, strlen(orig_router), 0);
-
-	if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-	}
-	else if ( res == HT_OLD_ENTRY )
-	{
-		struct npt_entry *ne;
-		ne=e->data;
-		int num_face=hashtb_n(ne->face_list);
-		int last_face,first_face;
-
-		int *faces=(int *)malloc(num_face*sizeof(int));
-		int *route_costs=(int *)malloc(num_face*sizeof(int));
-		
-		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 )
-		{
-			last_face=first_face;
-		}
-		else 
-		{
-			if ( num_face <= nlsr->multi_path_face_num)
-			{
-				last_face=0;
-			}
-			else if ( nlsr->multi_path_face_num == 0)
-			{
-				last_face=num_face-nlsr->multi_path_face_num;
-			}
-		}
-
-		int i,j, nl_element;
-		struct name_list_entry *nle;		
-		struct hashtb_enumerator eenle;
-    		struct hashtb_enumerator *enle = &eenle;
-
-		hashtb_start(ne->name_list, enle);
-		nl_element=hashtb_n(ne->name_list);	
-
-		for (i=0;i<nl_element;i++)
-		{
-			nle=enle->data;
-			
-			for( j=first_face; j>= last_face; j--)
-			{
-				if ( is_active_neighbor(orig_router) == 0 )
-				{
-					if ( nlsr->debugging )
-						printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
-					add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);	
-				}
-				else 
-				{
-					if ( j == last_face && is_active_neighbor(nle->name)==0)
-					{
-						if ( nlsr->debugging )
-							printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
-						if ( nlsr->detailed_logging )
-							writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
-						add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
-					}
-				}
-			}
-
-			hashtb_next(enle);
-		}
-		hashtb_end(enle);
-		
-
-
-		free(faces);
-		free(route_costs);
-
-	}
-	hashtb_end(e);
-
-}
-
-void 
-destroy_all_face_by_nlsr(void)
-{
-	int i, npt_element;
-	
-	struct npt_entry *ne;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->npt, e);
-	npt_element=hashtb_n(nlsr->npt);
-
-	for(i=0;i<npt_element;i++)
-	{
-		ne=e->data;
-		destroy_faces_by_orig_router(ne->orig_router);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-}
diff --git a/nlsr-sync-0.0/nlsr_npt.h b/nlsr-sync-0.0/nlsr_npt.h
deleted file mode 100755
index d339ede..0000000
--- a/nlsr-sync-0.0/nlsr_npt.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef _NLSR_NPT_H_
-#define _NLSR_NPT_H_
-
-#define NO_FACE -12345
-#define ZERO_FACE 0
-
-struct npt_entry
-{
-	char *orig_router;
-	struct hashtb *name_list;
-	//int next_hop_face;
-	struct hashtb *face_list;
-};
-
-struct name_list_entry
-{
-	char *name;
-};
-
-
-int add_npt_entry(char *orig_router, char *name_prefix, int num_face, int *faces, int *route_costs);
-int delete_npt_entry_by_router_and_name_prefix(char *orig_router, char *name_prefix);
-void print_npt(void);
-void delete_orig_router_from_npt(char *orig_router);
-void update_npt_with_new_route(void);
-void destroy_all_face_by_nlsr(void);
-void sort_faces_by_distance(int *faces,int *route_costs,int start,int element);
-void update_ccnd_fib_for_orig_router(char *orig_router);
-void get_all_faces_for_orig_router_from_npt(char *orig_router, int *faces, int *route_costs, int num_faces);
-
-#endif
diff --git a/nlsr-sync-0.0/nlsr_route.c b/nlsr-sync-0.0/nlsr_route.c
deleted file mode 100755
index 08a574e..0000000
--- a/nlsr-sync-0.0/nlsr_route.c
+++ /dev/null
@@ -1,1364 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/time.h>
-#include <assert.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <sys/types.h>
-
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-
-
-#include "nlsr.h"
-#include "nlsr_route.h"
-#include "nlsr_lsdb.h"
-#include "nlsr_npt.h"
-#include "nlsr_adl.h"
-#include "nlsr_fib.h"
-#include "utility.h"
-
-int
-route_calculate(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-
-	nlsr_lock();
-
-	if ( nlsr->debugging )
-		printf("route_calculate called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"route_calculate called\n");
-
-	if( ! nlsr->is_build_adj_lsa_sheduled )
-	{
-		/* Calculate Route here */
-		print_routing_table();
-		print_npt();		
-
-		struct hashtb_param param_me = {0};
-		nlsr->map = hashtb_create(sizeof(struct map_entry), &param_me);
-		nlsr->rev_map = hashtb_create(sizeof(struct map_entry), &param_me);
-		make_map();
-		assign_mapping_number();		
-		print_map();
-		print_rev_map();
-
-		do_old_routing_table_updates();
-		clear_old_routing_table();	
-		print_routing_table();
-		print_npt();
-
-		int i;
-		int **adj_matrix;
-		int map_element=hashtb_n(nlsr->map);
-		adj_matrix=malloc(map_element * sizeof(int *));
-		for(i = 0; i < map_element; i++)
-		{
-			adj_matrix[i] = malloc(map_element * sizeof(int));
-		}
-		make_adj_matrix(adj_matrix,map_element);
-		if ( nlsr->debugging )
-			print_adj_matrix(adj_matrix,map_element);
-
-		long int source=get_mapping_no(nlsr->router_name);
-		int num_link=get_no_link_from_adj_matrix(adj_matrix, map_element ,source);
-
-		if ( nlsr->is_hyperbolic_calc == 1)
-		{
-			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);
-
-			struct hashtb_enumerator ee;
-			struct hashtb_enumerator *e = &ee;
-			for (hashtb_start(nlsr->rev_map, e); e->key != NULL; hashtb_next(e)) 
-			{
-				struct map_entry *me=e->data;
-				if ( me->mapping != source )
-				{
-					long int *faces=(long int *)calloc(num_link,sizeof(long int));
-					double *nbr_dist=(double *)calloc(num_link,sizeof(double));
-					double *nbr_to_dest=(double *)calloc(num_link,sizeof(double));
-					for ( i=0 ; i < num_link; i++)
-					{
-						int face=get_next_hop_face_from_adl(get_router_from_rev_map(links[i]));
-						double dist_to_nbr=get_hyperbolic_distance(source,links[i]);
-						double dist_to_dest_from_nbr=get_hyperbolic_distance(links[i],me->mapping);
-						faces[i]=face;
-						nbr_dist[i]=dist_to_nbr;
-						nbr_to_dest[i]=	dist_to_dest_from_nbr;	
-
-						
-					}
-					sort_hyperbolic_route(nbr_to_dest,nbr_dist, faces,0,num_link);
-					if (nlsr->multi_path_face_num <= 1 )
-					{
-						update_routing_table_with_new_hyperbolic_route(me->mapping,faces[0],nbr_to_dest[0]);				
-					}
-					else
-					{
-						if ( num_link <= nlsr->multi_path_face_num )
-						{
-							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)
-						{
-							for ( i=0 ; i < nlsr->multi_path_face_num; i++)
-							{
-								update_routing_table_with_new_hyperbolic_route(me->mapping,faces[i],nbr_to_dest[i]);
-							}
-						}
-
-					}
-					free(faces);
-					free(nbr_dist);
-					free(nbr_to_dest);
-				}
-			}
-			hashtb_end(e);
-
-			
-			free(links);
-			free(link_costs);
-		}
-		else if (nlsr->is_hyperbolic_calc == 0 )
-		{
-
-			long int *parent=(long int *)malloc(map_element * sizeof(long int));
-			long int *dist=(long int *)malloc(map_element * sizeof(long int));
-			
-		
-			if ( (num_link == 0) || (nlsr->multi_path_face_num == 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 ) )
-			{
-				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);
-				}
-
-				free(links);
-				free(link_costs);
-			}
-			free(parent);
-			free(dist);
-		}
-		
-		print_routing_table();
-		print_npt();
-
-		update_npt_with_new_route();
-
-		print_routing_table();
-		print_npt();
-
-
-		for(i = 0; i < map_element; i++)
-		{
-			free(adj_matrix[i]);
-		}
-		
-		free(adj_matrix);
-		hashtb_destroy(&nlsr->map);
-		hashtb_destroy(&nlsr->rev_map);
-		
-	}
-	nlsr->is_route_calculation_scheduled=0;
-
-	nlsr_unlock();
-
-	return 0;
-}
-
-void 
-calculate_path(int **adj_matrix, long int *parent,long int *dist ,long int V, long int S)
-{
-	int i;
-	long int v,u;
-	//long int *dist=(long int *)malloc(V * sizeof(long int));
-	long int *Q=(long int *)malloc(V * sizeof(long int));
-	long int head=0;
-	/* Initiate the Parent */
-	for (i = 0 ; i < V; i++)
-	{
-		parent[i]=EMPTY_PARENT;
-		dist[i]=INF_DISTANCE;
-		Q[i]=i;
-	} 
-
-	if ( S != NO_MAPPING_NUM )
-	{
-		dist[S]=0;
-		sort_queue_by_distance(Q,dist,head,V);
-
-		while (head < V )
-		{
-			u=Q[head];
-			if(dist[u] == INF_DISTANCE)
-			{
-				break;
-			}
-
-			for(v=0 ; v <V; v++)
-			{
-				if( adj_matrix[u][v] > 0 ) //
-				{
-					if ( is_not_explored(Q,v,head+1,V) )
-					{
-					
-						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);
-		}
-	}
-	free(Q);	
-}
-
-void
-print_all_path_from_source(long int *parent,long int source)
-{
-	int i, map_element;
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->map, e);
-	map_element=hashtb_n(nlsr->map);
-
-	if ( source != NO_MAPPING_NUM)
-	{
-		for(i=0;i<map_element;i++)
-		{
-			me=e->data;
-			if(me->mapping != source)
-			{
-				
-				if ( nlsr->debugging )
-				{
-					print_path(parent,(long int)me->mapping);
-					printf("\n");
-				}
-				if ( nlsr->detailed_logging )
-				{
-					print_path(parent,(long int)me->mapping);
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-				}
-				
-			}
-			hashtb_next(e);		
-		}
-	}
-	hashtb_end(e);
-
-}
-
-void 
-print_all_next_hop(long int *parent,long int source)
-{
-	int i, map_element;
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->map, e);
-	map_element=hashtb_n(nlsr->map);
-
-	for(i=0;i<map_element;i++)
-	{
-		me=e->data;
-		if(me->mapping != source)
-		{
-			if ( nlsr->debugging )
-				printf("Dest: %d Next Hop: %ld\n",me->mapping,get_next_hop_from_calculation(parent,me->mapping,source));
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Dest: %d Next Hop: %ld\n",me->mapping,get_next_hop_from_calculation(parent,me->mapping,source));
-		}
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-long int
-get_next_hop_from_calculation(long int *parent, long int dest,long int source)
-{
-	long int next_hop;
-	while ( parent[dest] != EMPTY_PARENT )
-	{
-		next_hop=dest;
-		dest=parent[dest];
-
-	}
-
-	if ( dest != source )
-	{
-		next_hop=NO_NEXT_HOP;	
-	}
-	
-	return next_hop;
-	
-}
-
-void
-print_path(long int *parent, long int dest)
-{
-	if (parent[dest] != EMPTY_PARENT )
-		print_path(parent,parent[dest]);
-
-	if ( nlsr->debugging )
-		printf(" %ld",dest);
-}
-
-int 
-is_not_explored(long int *Q, long int u,long int start, long int element)
-{
-	int ret=0;
-	long int i;
-	for(i=start; i< element; i++)
-	{
-		if ( Q[i] == u )
-		{
-			ret=1;
-			break;
-		}
-	}
-	return ret;
-}
-
-void 
-sort_queue_by_distance(long int *Q,long int *dist,long int start,long int element)
-{
-	long int i,j;
-	long int temp_u;
-
-	for ( i=start ; i < element ; i ++) 
-	{
-		for( j=i+1; j<element; j ++)
-		{
-			if (dist[Q[j]] < dist[Q[i]])
-			{
-				temp_u=Q[j];
-				Q[j]=Q[i];
-				Q[i]=temp_u;
-			}
-		}
-	}
-	
-}
-
-void 
-sort_hyperbolic_route(double *dist_dest,double *dist_nbr, long int *faces,long int start,long int element)
-{
-	long int i,j;
-	double temp_dist;
-	long int temp_face;
-
-	for ( i=start ; i < element ; i ++) 
-	{
-		for( j=i+1; j<element; j ++)
-		{
-			if (dist_dest[i] < dist_dest[j])
-			{
-				temp_dist=dist_dest[j];
-				dist_dest[j]=dist_dest[i];
-				dist_dest[i]=temp_dist;
-
-				temp_dist=dist_nbr[j];
-				dist_nbr[j]=dist_nbr[i];
-				dist_nbr[i]=temp_dist;
-
-				temp_face=faces[j];
-				faces[j]=faces[i];
-				faces[i]=temp_face;
-			}
-			if ( (dist_dest[i] == dist_dest[j]) && (dist_nbr[i] < dist_nbr[j]) )
-			{
-				temp_dist=dist_dest[j];
-				dist_dest[j]=dist_dest[i];
-				dist_dest[i]=temp_dist;
-
-				temp_dist=dist_nbr[j];
-				dist_nbr[j]=dist_nbr[i];
-				dist_nbr[i]=temp_dist;
-
-				temp_face=faces[j];
-				faces[j]=faces[i];
-				faces[i]=temp_face;
-			}
-		}
-	}
-	
-}
-
-void
-print_map(void)
-{
-	int i, map_element;
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->map, e);
-	map_element=hashtb_n(nlsr->map);
-
-	for(i=0;i<map_element;i++)
-	{
-		me=e->data;
-		if ( nlsr->debugging )
-			printf("Router: %s Mapping Number: %d \n",me->router,me->mapping);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Router: %s Mapping Number: %d \n",me->router,me->mapping);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-}
-
-
-void
-assign_mapping_number(void)
-{
-	int i, map_element;
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->map, e);
-	map_element=hashtb_n(nlsr->map);
-
-	for(i=0;i<map_element;i++)
-	{
-		me=e->data;
-		me->mapping=i;
-		add_rev_map_entry(i,me->router);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-}
-
-void 
-make_map(void)
-{
-	
-
-	int i, adj_lsdb_element;
-	struct alsa *adj_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	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;
-		add_adj_data_to_map(adj_lsa->header->orig_router->name,adj_lsa->body,adj_lsa->no_link);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-void 
-add_map_entry(char *router)
-{
-
-	struct map_entry *me=(struct map_entry*)malloc(sizeof(struct map_entry ));
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->map, e);
-    	res = hashtb_seek(e, router, strlen(router), 0);
-
-	if(res == HT_NEW_ENTRY)
-	{
-		me=e->data;
-		me->router=(char *)malloc(strlen(router)+1);
-		memset(me->router,0,strlen(router)+1);
-		memcpy(me->router,router,strlen(router));
-		me->mapping=0;
-	}
-
-	hashtb_end(e);
-	
-}
-
-
-void 
-add_adj_data_to_map(char *orig_router, char *body, int no_link)
-{
-	add_map_entry(orig_router);
-	
-	int i=0;
-	char *lsa_data=(char *)malloc(strlen(body)+1);
-	memset(	lsa_data,0,strlen(body)+1);
-	memcpy(lsa_data,body,strlen(body)+1);
-	char *sep="|";
-	char *rem;
-	char *rtr_id;
-	char *length;
-	char *face;
-	char *metric;
-	
-	if(no_link >0 )
-	{
-		rtr_id=strtok_r(lsa_data,sep,&rem);
-		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
-		metric=strtok_r(NULL,sep,&rem);
-
-		add_map_entry(rtr_id);
-
-		for(i=1;i<no_link;i++)
-		{
-			rtr_id=strtok_r(NULL,sep,&rem);
-			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
-			metric=strtok_r(NULL,sep,&rem);
-
-			add_map_entry(rtr_id);
-
-		}
-	}
-	
-	free(lsa_data);
-}
-
-int 
-get_mapping_no(char *router)
-{
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-	int ret;
-
-	int n = hashtb_n(nlsr->map);
-
-	if ( n < 1)
-	{
-		return NO_MAPPING_NUM;
-	}
-
-   	hashtb_start(nlsr->map, e);
-    	res = hashtb_seek(e, router, strlen(router), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		me=e->data;
-		ret=me->mapping;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-		ret=NO_MAPPING_NUM;
-	}
-
-	hashtb_end(e);	
-
-	return ret;
-
-}
-
-
-void 
-add_rev_map_entry(long int mapping_number, char *router)
-{
-
-	struct map_entry *me=(struct map_entry*)malloc(sizeof(struct map_entry ));
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->rev_map, e);
-    	res = hashtb_seek(e, &mapping_number, sizeof(mapping_number), 0);
-
-	if(res == HT_NEW_ENTRY)
-	{
-		me=e->data;
-		me->router=(char *)malloc(strlen(router)+1);
-		memset(me->router,0,strlen(router)+1);
-		memcpy(me->router,router,strlen(router));
-		me->mapping=mapping_number;
-	}
-
-	hashtb_end(e);
-	
-}
-
-
-
-char * 
-get_router_from_rev_map(long int mapping_number)
-{
-
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->rev_map, e);
-    	res = hashtb_seek(e, &mapping_number, sizeof(mapping_number), 0);
-
-	if(res == HT_OLD_ENTRY)
-	{
-		me=e->data;
-		hashtb_end(e);
-		return me->router;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-		hashtb_end(e);
-	}
-	
-	return NULL;
-}
-
-void
-print_rev_map(void)
-{
-	int i, map_element;
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->map, e);
-	map_element=hashtb_n(nlsr->map);
-
-	for(i=0;i<map_element;i++)
-	{
-		me=e->data;
-		if ( nlsr->debugging )
-			printf("Mapping Number: %d Router: %s  \n",me->mapping,me->router);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Mapping Number: %d Router: %s  \n",me->mapping,me->router);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-}
-
-
-void
-assign_adj_matrix_for_lsa(struct alsa *adj_lsa, int **adj_matrix)
-{
-	int mapping_orig_router=get_mapping_no(adj_lsa->header->orig_router->name);
-	int mapping_nbr_router;
-
-	int i;
-	char *lsa_data=(char *)malloc(strlen(adj_lsa->body)+1);
-	memset(	lsa_data,0,strlen(adj_lsa->body)+1);
-	memcpy(lsa_data,adj_lsa->body,strlen(adj_lsa->body)+1);
-	char *sep="|";
-	char *rem;
-	char *rtr_id;
-	char *length;
-	char *face;
-	char *metric;
-	
-	if(adj_lsa->no_link >0 )
-	{
-		rtr_id=strtok_r(lsa_data,sep,&rem);
-		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
-		metric=strtok_r(NULL,sep,&rem);
-
-		mapping_nbr_router=get_mapping_no(rtr_id);
-		adj_matrix[mapping_orig_router][mapping_nbr_router]=atoi(metric);
-
-		for(i=1;i<adj_lsa->no_link;i++)
-		{
-			rtr_id=strtok_r(NULL,sep,&rem);
-			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
-			metric=strtok_r(NULL,sep,&rem);
-
-			mapping_nbr_router=get_mapping_no(rtr_id);
-			adj_matrix[mapping_orig_router][mapping_nbr_router]=atoi(metric);
-
-		}
-	}
-	
-	free(lsa_data);
-}
-
-void 
-make_adj_matrix(int **adj_matrix,int map_element)
-{
-
-	init_adj_matrix(adj_matrix,map_element);
-
-	int i, adj_lsdb_element;
-	struct alsa *adj_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-	adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);
-
-	for(i=0;i<adj_lsdb_element;i++)
-	{
-		adj_lsa=e->data;
-		assign_adj_matrix_for_lsa(adj_lsa,adj_matrix);
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-void 
-init_adj_matrix(int **adj_matrix,int map_element)
-{
-	int i, j;
-	for(i=0;i<map_element;i++)
-		for(j=0;j<map_element;j++)
-			adj_matrix[i][j]=0;
-}
-
-void print_adj_matrix(int **adj_matrix, int map_element)
-{
-	int i, j;
-	for(i=0;i<map_element;i++)
-	{
-		for(j=0;j<map_element;j++)
-			printf("%d ",adj_matrix[i][j]);
-		printf("\n");
-	}
-}
-
-
-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;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res,ret;
-
-   	hashtb_start(nlsr->routing_table, e);
-    	res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		rte=e->data;
-		ret=hashtb_n(rte->face_list);
-		//nhl=rte->face_list;
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-		ret=NO_NEXT_HOP;
-	}
-
-	hashtb_end(e);	
-
-	return ret;
-}
-
-
-int 
-get_next_hop(char *dest_router,int *faces, int *route_costs)
-{
-	struct routing_table_entry *rte;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res,ret;
-
-   	hashtb_start(nlsr->routing_table, e);
-    	res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		rte=e->data;
-		ret=hashtb_n(rte->face_list);
-		//nhl=rte->face_list;
-		int j,face_list_element;
-		struct face_list_entry *fle;
-
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(rte->face_list, ef);
-		face_list_element=hashtb_n(rte->face_list);
-		for(j=0;j<face_list_element;j++)
-		{
-			fle=ef->data;
-			//printf(" 	Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
-			faces[j]=fle->next_hop_face;
-			route_costs[j]=fle->route_cost;
-			hashtb_next(ef);	
-		}
-		hashtb_end(ef);
-		
-	}
-	else if(res == HT_NEW_ENTRY)
-	{
-		hashtb_delete(e);
-		ret=NO_NEXT_HOP;
-	}
-
-	hashtb_end(e);	
-
-	return ret;
-}
-
-void
-add_next_hop_router(char *dest_router)
-{
-	if ( strcmp(dest_router,nlsr->router_name)== 0)
-	{
-		return ;
-	}
-
-	struct routing_table_entry *rte=(struct routing_table_entry *)malloc(sizeof(struct routing_table_entry));
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee; 	
-    	int res;
-
-   	hashtb_start(nlsr->routing_table, e);
-    	res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
-
-	if( res == HT_NEW_ENTRY )
-	{
-		rte=e->data;
-		rte->dest_router=(char *)malloc(strlen(dest_router)+1);
-		memset(rte->dest_router,0,strlen(dest_router)+1);
-		memcpy(rte->dest_router,dest_router,strlen(dest_router));
-		//rte->next_hop_face=NO_NEXT_HOP;
-		struct hashtb_param param_fle = {0};
-		rte->face_list=hashtb_create(sizeof(struct face_list_entry), &param_fle);
-
-		add_npt_entry(dest_router, dest_router, 0, NULL, NULL);
-	}
-	hashtb_end(e);
-
-}
-
-void 
-add_next_hop_from_lsa_adj_body(char *body, int no_link)
-{
-
-	int i=0;
-	char *lsa_data=(char *)malloc(strlen(body)+1);
-	memset(	lsa_data,0,strlen(body)+1);
-	memcpy(lsa_data,body,strlen(body)+1);
-	char *sep="|";
-	char *rem;
-	char *rtr_id;
-	char *length;
-	char *face;
-	char *metric;
-
-	if(no_link >0 )
-	{
-		rtr_id=strtok_r(lsa_data,sep,&rem);
-		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
-		metric=strtok_r(NULL,sep,&rem);
-
-
-		add_next_hop_router(rtr_id);
-
-		for(i=1;i<no_link;i++)
-		{
-			rtr_id=strtok_r(NULL,sep,&rem);
-			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
-			metric=strtok_r(NULL,sep,&rem);
-
-			add_next_hop_router(rtr_id);
-	
-		}
-	}
-
-	free(lsa_data);
-
-
-}
-
-void 
-update_routing_table(char * dest_router,int next_hop_face, int route_cost)
-{
-	if ( nlsr->debugging )
-	{
-		printf("update_routing_table called \n");
-		printf("Dest Router: %s Next Hop face: %d Route Cost: %d \n",dest_router,next_hop_face,route_cost);
-	}
-
-	int res,res1;
-	struct routing_table_entry *rte;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->routing_table, e);
-	res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		rte=e->data;
-
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(rte->face_list, ef);
-		res1 = hashtb_seek(ef, &next_hop_face, sizeof(next_hop_face), 0);	
-		if( res1 == HT_NEW_ENTRY)
-		{
-			struct face_list_entry *fle=(struct face_list_entry *)malloc(sizeof(struct face_list_entry));
-			fle=ef->data;
-			fle->next_hop_face=next_hop_face;
-			fle->route_cost=route_cost;						
-		}
-		else if ( res1 == HT_OLD_ENTRY )
-		{
-			struct face_list_entry *fle;
-			fle=ef->data;
-			fle->route_cost=route_cost;
-		}
-		hashtb_end(ef);
-	}
-	else if ( res == HT_OLD_ENTRY )
-	{
-		hashtb_delete(e);
-	}
-	
-	hashtb_end(e);
-	
-}
-
-void 
-print_routing_table(void)
-{
-	if ( nlsr->debugging )
-		printf("print_routing_table called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_routing_table called\n");
-	int i,j, rt_element,face_list_element;
-	
-	struct routing_table_entry *rte;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->routing_table, e);
-	rt_element=hashtb_n(nlsr->routing_table);
-
-	for(i=0;i<rt_element;i++)
-	{
-		if ( nlsr->debugging )
-			printf("----------Routing Table Entry %d------------------\n",i+1);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"----------Routing Table Entry %d------------------\n",i+1);
-		
-		rte=e->data;
-
-		if ( nlsr->debugging )
-			printf(" Destination Router: %s \n",rte->dest_router);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__," Destination Router: %s \n",rte->dest_router);
-
-		
-		//rte->next_hop_face == NO_NEXT_HOP ? printf(" Next Hop Face: NO_NEXT_HOP \n") : printf(" Next Hop Face: %d \n", rte->next_hop_face);
-
-		struct face_list_entry *fle;
-
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(rte->face_list, ef);
-		face_list_element=hashtb_n(rte->face_list);
-		if ( face_list_element <= 0 )
-		{
-			if ( nlsr->debugging )
-				printf(" 	Face: No Face \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: No Face \n");
-		}
-		else
-		{
-			for(j=0;j<face_list_element;j++)
-			{
-				fle=ef->data;
-				if ( nlsr->debugging )
-					printf(" 	Face: %d Route_Cost: %f \n",fle->next_hop_face,fle->route_cost);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
-				hashtb_next(ef);	
-			}
-		}
-		hashtb_end(ef);
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-	if ( nlsr->debugging )
-		printf("\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
-}
-
-
-int
-delete_empty_rte(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	if ( nlsr->debugging )
-	{
-		printf("delete_empty_rte called\n");
-		printf("Router: %s \n",(char *)ev->evdata);
-	}
-	if ( nlsr->detailed_logging )
-	{
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_empty_rte called\n");
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Router: %s \n",(char *)ev->evdata);
-	}
-	
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-
-	nlsr_lock();
-	int res;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->routing_table, e);
-	res = hashtb_seek(e, (char *)ev->evdata, strlen((char *)ev->evdata), 0);
-	
-	if ( res == HT_OLD_ENTRY )
-	{
-		hashtb_delete(e);
-	}
-	else if ( res == HT_NEW_ENTRY )
-	{
-		hashtb_delete(e);
-	}
-
-	print_routing_table();
-
-	nlsr_unlock();
-	
-	return 0;
-}
-
-void 
-clear_old_routing_table(void)
-{
-	if ( nlsr->debugging )
-		printf("clear_old_routing_table called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"clear_old_routing_table called\n");
-	int i,rt_element;
-	
-	struct routing_table_entry *rte;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->routing_table, e);
-	rt_element=hashtb_n(nlsr->routing_table);
-
-	for(i=0;i<rt_element;i++)
-	{
-		rte=e->data;
-		hashtb_destroy(&rte->face_list);
-		struct hashtb_param param_fle = {0};
-		rte->face_list=hashtb_create(sizeof(struct face_list_entry), &param_fle);
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);	
-}
-
-
-void 
-do_old_routing_table_updates(void)
-{
-	if ( nlsr->debugging )
-		printf("do_old_routing_table_updates called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"do_old_routing_table_updates called\n");
-	
-	int i, rt_element;
-	int mapping_no;	
-
-	struct routing_table_entry *rte;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->routing_table, e);
-	rt_element=hashtb_n(nlsr->routing_table);
-
-	for(i=0;i<rt_element;i++)
-	{
-		rte=e->data;
-		mapping_no=get_mapping_no(rte->dest_router);
-		if ( mapping_no == NO_MAPPING_NUM)
-		{		
-			delete_orig_router_from_npt(rte->dest_router);
-			char *router=(char *)malloc(strlen(rte->dest_router)+1);
-			memset(router,0,strlen(rte->dest_router)+1);
-			memcpy(router,rte->dest_router,strlen(rte->dest_router)+1);
-			nlsr->event = ccn_schedule_event(nlsr->sched, 1, &delete_empty_rte, (void *)router , 0);
-		}
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);	
-}
-
-void 
-update_routing_table_with_new_hyperbolic_route(long int dest_router_rev_map_index, long int face, double nbr_to_dest_dist)
-{
-	if ( nlsr->debugging )
-		printf("update_routing_table_with_new_hyperbolic_route called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_routing_table_with_new_hyperbolic_route called\n");
-	
-	char *orig_router=get_router_from_rev_map(dest_router_rev_map_index);
-
-	if (face != NO_NEXT_HOP && face != NO_FACE )
-	{
-		update_routing_table(orig_router,face,nbr_to_dest_dist);
-		if ( nlsr->debugging )
-			printf ("Orig_router: %s Next Hop Face: %ld \n",orig_router,face);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Orig_router: %s Next Hop Face: %ld \n",orig_router,face);
-					
-	}
-	
-
-}
-
-
-void 
-update_routing_table_with_new_route(long int *parent, long int *dist,long int source)
-{
-	if ( nlsr->debugging )
-		printf("update_routing_table_with_new_route called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_routing_table_with_new_route called\n");
-	int i, map_element;
-	struct map_entry *me;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->rev_map, e);
-	map_element=hashtb_n(nlsr->rev_map);
-
-	for(i=0;i<map_element;i++)
-	{
-		me=e->data;
-		if(me->mapping != source)
-		{
-			
-			char *orig_router=get_router_from_rev_map(me->mapping);
-			if (orig_router != NULL )
-			{
-				int next_hop_router_num=get_next_hop_from_calculation(parent,me->mapping,source);
-				if ( next_hop_router_num == NO_NEXT_HOP )
-				{
-					if ( nlsr->debugging )
-						printf ("Orig_router: %s Next Hop Face: %d \n",orig_router,NO_FACE);
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Orig_router: %s Next Hop Face: %d \n",orig_router,NO_FACE);
-				}
-				else 
-				{
-					char *next_hop_router=get_router_from_rev_map(next_hop_router_num);
-					int next_hop_face=get_next_hop_face_from_adl(next_hop_router);
-					update_routing_table(orig_router,next_hop_face,dist[me->mapping]);
-					if ( nlsr->debugging )
-						printf ("Orig_router: %s Next Hop Face: %d \n",orig_router,next_hop_face);
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Orig_router: %s Next Hop Face: %d \n",orig_router,next_hop_face);
-					
-
-				}
-			}
-		}
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-}
-
-int 
-does_face_exist_for_router(char *dest_router, int face_id)
-{
-	if (nlsr->debugging)
-	{
-		printf("does_face_exist_for_router called\n");
-		printf("Dest Router: %s and Face id: %d \n",dest_router, face_id);
-	}
-
-	int ret=0;
-
-	int res;
-	struct routing_table_entry *rte;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->routing_table, e);
-	res = hashtb_seek(e, dest_router, strlen(dest_router), 0);
-
-	if( res == HT_OLD_ENTRY )
-	{
-		rte=e->data;
-		unsigned *v;
-		v = hashtb_lookup(rte->face_list, &face_id, sizeof(face_id));
-		if (v != NULL)
-			ret = 1;
-	}
-	else
-	{
-		hashtb_delete(e);
-	} 
-	
-	hashtb_end(e);
-
-	return ret;
-}
-
-double 
-get_hyperbolic_distance(long int source, long int dest)
-{
-	double distance;
-	char *src_router=get_router_from_rev_map(source);
-	char *dest_router=get_router_from_rev_map(dest);
-
-	double src_r=get_hyperbolic_r(src_router);
-	double src_theta=get_hyperbolic_r(src_router);	
-
-	double dest_r=get_hyperbolic_r(dest_router);
-	double dest_theta=get_hyperbolic_r(dest_router);
-	if ( src_r != -1 && dest_r != -1 )
-	{
-		distance=acosh(cosh(src_r)*cosh(dest_r)-sinh(src_r)*sinh(dest_r)*cos(src_theta-dest_theta));
-	}
-	else 
-	{
-		distance= -1.0;
-	}
-	
-	return distance;
-}
diff --git a/nlsr-sync-0.0/nlsr_route.h b/nlsr-sync-0.0/nlsr_route.h
deleted file mode 100755
index b6dff03..0000000
--- a/nlsr-sync-0.0/nlsr_route.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef _NLSR_ROUTE_H_
-#define _NLSR_ROUTE_H_
-
-#define EMPTY_PARENT -12345
-#define INF_DISTANCE 2147483647
-
-#define NO_NEXT_HOP -12345
-#define NO_MAPPING_NUM -1
-
-struct map_entry
-{
-	char *router;
-	int mapping;
-};
-
-
-struct routing_table_entry
-{
-	char *dest_router;
-	//int next_hop_face;
-	struct hashtb *face_list;
-};
-
-struct face_list_entry
-{
-	int next_hop_face;
-	double route_cost;
-};
-
-int route_calculate(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
-void make_map(void);
-void add_map_entry(char *router);
-void add_adj_data_to_map(char *orig_router, char *body, int no_link);
-void print_map(void);
-void assign_mapping_number(void);
-void make_adj_matrix(int **adj_matrix,int map_element);
-void init_adj_matrix(int **adj_matrix,int map_element);
-void print_adj_matrix(int **adj_matrix, int map_element);
-int get_mapping_no(char *router);
-void calculate_path(int **adj_matrix, long int *parent,long int *dist, long int V, long int S);
-void sort_queue_by_distance(long int *Q,long int *dist,long int start,long int element);
-int is_not_explored(long int *Q, long int u,long int start, long int element);
-void print_path(long int *parent, long int dest);
-void print_all_path_from_source(long int *parent,long int source);
-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 */
-
-int get_next_hop(char *dest_router,int *faces, int *route_costs);
-int get_number_of_next_hop(char *dest_router);
-void add_next_hop_router(char *dest_router);
-void add_next_hop_from_lsa_adj_body(char *body, int no_link);
-void print_routing_table(void);
-void do_old_routing_table_updates(void);
-void clear_old_routing_table(void);
-void update_routing_table_with_new_route(long int *parent,long int *dist, long int source);
-
-long int get_next_hop_from_calculation(long int *parent, long int dest,long int source);
-void print_all_next_hop(long int *parent,long int source);
-int does_face_exist_for_router(char *dest_router, int face_id);
-
-double get_hyperbolic_distance(long int source, long int dest);
-void sort_hyperbolic_route(double *dist_dest,double *dist_nbr, long int *faces,long int start,long int element);
-void update_routing_table_with_new_hyperbolic_route(long int dest_router_rev_map_index, long int face, double nbr_to_dest_dist);
-
-#endif
diff --git a/nlsr-sync-0.0/nlsrc.c b/nlsr-sync-0.0/nlsrc.c
deleted file mode 100755
index 91a1523..0000000
--- a/nlsr-sync-0.0/nlsrc.c
+++ /dev/null
@@ -1,109 +0,0 @@
-//1. Make the necessary includes and set up the variables:
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <sys/un.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <getopt.h>
-
-struct option longopts[] =
-{
-    { "server_ip",    required_argument, NULL, 's'},
-    { "server_port",    required_argument, NULL, 'p'},
-    { 0 }
-};
-
-static int 
-usage(char *progname)
-{
-	printf("Usage: %s [OPTIONS...]\n\
-        NLSR API client....\n\
-        nlsrc -s server_ip -p server_port add|del name|neighbor name_prefix [faceX] \n\
-        option -- description\n\n\
-        add|del -- specify whether you want to add or delete.\n\
-        name|neighbor -- specify whether you are adding a name or a neighbor.\n\
-        name_prefix -- name of the prefix for the name|neighbor.\n\
-        faceX -- face ID for neighbor if the third argument is neighbor.\n\n\
-        Examples:\n\
-        1) nlsrc -s 127.0.0.1 -p 9696 add name /ndn/memphis.edu/test \n", progname);
-
-    	exit(1);
-}
-
-int main(int argc, char *argv[])
-{
-	int sockfd;
-	int len;
-	struct sockaddr_in address;
-	int result;
-	int bytesSent;
-	char *server_address, *server_port;	
-
-	int command_len=0;
-	int i;
-
-	if (argc < 8)
-                usage(argv[0]);
-
-        if (strcmp(argv[6], "neighbor") == 0 && argc < 9)
-                usage(argv[0]);
-
-        if (strcmp(argv[6], "name") != 0 && strcmp(argv[6], "neighbor") != 0)
-                usage(argv[0]);
-
-	while ((result = getopt_long(argc, argv, "s:p:", longopts, 0)) != -1) 
-	{
-        	switch (result) 
-		{
-			case 's':
-				server_address = optarg;
-				break;
-			case 'p':
-				server_port = optarg;
-				break;
-		}
-    	}	
-
-
-	char recv_buffer[1024];
-	bzero(recv_buffer,1024);
-
-	for(i=5;i<argc;i++)
-		command_len+=(strlen(argv[i])+1);
-	char *command=malloc(command_len);
-	memset(command, 0, command_len);
-	for(i=5;i<argc;i++)
-	{
-		memcpy(command+strlen(command),argv[i],strlen(argv[i]));
-		if ( i < argc-1 )
-			memcpy(command+strlen(command)," ",1);	
-	}
-
-	sockfd = socket(AF_INET, SOCK_STREAM, 0);
-	//address.sun_family = AF_UNIX;
-	//strcpy(address.sun_path, "/tmp/nlsr_api_server_socket");
-	address.sin_family = AF_INET;
-	address.sin_addr.s_addr = inet_addr(server_address);
-	address.sin_port = htons(atoi(server_port));
-
-	len = sizeof(address);
-	result = connect(sockfd, (struct sockaddr *)&address, len);
-	if(result == -1) 
-	{
-		perror("oops nlsrc ");
-		exit(1);
-	}
-	printf("Command to send: %s \n",command);
-	bytesSent=send(sockfd, command, strlen(command),0);
-	printf("Command len: %d, Bytes sent: %d \n",(int)strlen(command), bytesSent);
-	recv(sockfd, recv_buffer, 1024, 0);
-	printf("%s\n",recv_buffer);
-	free(command);
-	close(sockfd);
-	exit(0);
-}
diff --git a/nlsr-sync-0.0/pollux.conf b/nlsr-sync-0.0/pollux.conf
deleted file mode 100755
index faaa597..0000000
--- a/nlsr-sync-0.0/pollux.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-#----configuration file for macbook----------
-#
-router-name /ndn/memphis.edu/cs/pollux
-ccnneighbor /ndn/memphis.edu/cs/sirius
-ccnname /ndn/memphis.edu/cs/pollux/name1
-#------lsdb-synch-interval-----
-lsdb-synch-interval 350
-interest-retry 2 
-interest-resend-time 5
-lsa-refresh-time 600
-router-dead-interval 900
-multi-path-face-num 2 
-#debug on
-
-topo-prefix /ndn/memphis.edu/nlsr/
-slice-prefix /ndn/memphis.edu/nlsr/LSA/
-
-logdir mylog/ 
diff --git a/nlsr-sync-0.0/simulation.h b/nlsr-sync-0.0/simulation.h
deleted file mode 100755
index 76c4861..0000000
--- a/nlsr-sync-0.0/simulation.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _SIMULATION_H_
-#define _SIMULATION_H_
-
-
-
-
-
-#endif
diff --git a/nlsr-sync-0.0/todo.txt b/nlsr-sync-0.0/todo.txt
deleted file mode 100755
index 77fccea..0000000
--- a/nlsr-sync-0.0/todo.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-To Do:
-
-1. Add commenting facility in .conf file -- done, commenting character # or !
-2. Adding configuration command of lsa-refresh-time and router-dead-interval  --- done
-3. Adding trailing "/" remover from the commands if has any -- done 
-4. Multi Path Route Calculation
-5. Writing Log so that need minimal change to status page script
-6. Adding a fib entry for origination router itself 
-6. Providing api to add/delete link/name prefix
diff --git a/nlsr-sync-0.0/transfer.sh b/nlsr-sync-0.0/transfer.sh
deleted file mode 100755
index e616d20..0000000
--- a/nlsr-sync-0.0/transfer.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-scp * mhoque@pollux.cs.memphis.edu:/home/mhoque/NLSR2.0/
-
-scp * mhoque@mira.cs.memphis.edu:/home/mhoque/NLSR2.0/
-
-scp * mhoque@castor.cs.memphis.edu:/home/mhoque/NLSR2.0/
diff --git a/nlsr-sync-0.0/utility.c b/nlsr-sync-0.0/utility.c
deleted file mode 100755
index cf7452a..0000000
--- a/nlsr-sync-0.0/utility.c
+++ /dev/null
@@ -1,276 +0,0 @@
-#include<stdio.h>
-#include<string.h>
-#include<stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include<ctype.h>
-#include<stdarg.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include<sys/socket.h>
-#include<arpa/inet.h>
-#include<errno.h>
-#include<netdb.h>
-#include <time.h>
-#include <assert.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-
-#include <ccn/ccn.h>
-#include <ccn/uri.h>
-#include <ccn/keystore.h>
-#include <ccn/signing.h>
-#include <ccn/schedule.h>
-#include <ccn/hashtb.h>
-
-
-#include "utility.h"
-
-
-char * getLocalTimeStamp(void)
-{
-	char *timestamp = (char *)malloc(sizeof(char) * 16);
-	time_t ltime;
-	ltime=time(NULL);
-	struct tm *tm;
-	tm=localtime(&ltime);
-  
-	sprintf(timestamp, "%04d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, 
-		tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
-
-	return timestamp;
-}
-
-char * getGmTimeStamp(void)
-{
-	char *timestamp = (char *)malloc(sizeof(char) * 16);
-	time_t gtime;
-	gtime=time(NULL);
-	struct tm *tm;
-	tm=gmtime(&gtime);
-  
-	sprintf(timestamp, "%04d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1, 
-		tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
-
-	return timestamp;
-}
-
-
-
-
-long int 
-get_current_time_sec(void)
-{
-	struct timeval now;
-	gettimeofday(&now,NULL);
-	return now.tv_sec;
-}
-
-
-void
-get_current_timestamp_micro(char * microSec)
-{
-	struct timeval now; 
-	gettimeofday(&now, NULL);
-	sprintf(microSec,"%ld%06ld",now.tv_sec,(long int)now.tv_usec);
-}
-
-
-long int
-get_time_diff(const char *time1, const char *time2)
-{
-	long int diff_secs;
-
-	long int time1_in_sec,	time2_in_sec;
-
-	char *time1_sec=(char *)malloc(strlen(time1)-6+1);
-	memset(time1_sec,0,strlen(time1)-6+1);
-	memcpy(time1_sec,time1,strlen(time1)-6);
-
-	char *time2_sec=(char *)malloc(strlen(time2)-6+1);
-	memset(time2_sec,0,strlen(time2)-6+1);
-	memcpy(time2_sec,time2,strlen(time2)-6);
-
-	time1_in_sec=strtol(time1_sec,NULL,10);
-	time2_in_sec=strtol(time2_sec,NULL,10);
-
-	diff_secs=time1_in_sec-time2_in_sec;
-
-	free(time1_sec);
-	free(time2_sec);
-
-	return diff_secs;
-}
-
-
-void  
-startLogging(char *loggingDir)
-{
-	struct passwd pd;
-	struct passwd* pwdptr=&pd;
-	struct passwd* tempPwdPtr;
-	char *pwdbuffer;
-	int  pwdlinelen = 200;
-	char *logDir;
-	char *logFileName;
-	char *ret;
-	char *logExt;
-	char *defaultLogDir;	
-	int status;
-	struct stat st;
-	int isLogDirExists=0;
-	char *time=getLocalTimeStamp();
-
-	pwdbuffer=(char *)malloc(sizeof(char)*200);
-	memset(pwdbuffer,0,200);		
-	logDir=(char *)malloc(sizeof(char)*200);
-	memset(logDir,0,200);
-	logFileName=(char *)malloc(sizeof(char)*200);
-	memset(logFileName,0,200);
-	logExt=(char *)malloc(sizeof(char)*5);
-	memset(logExt,0,5);
-	defaultLogDir=(char *)malloc(sizeof(char)*10);
-	memset(defaultLogDir,0,10);
-
-	memcpy(logExt,".log",4);
-	logExt[4]='\0';
-	memcpy(defaultLogDir,"/nlsrLog",9);
-	defaultLogDir[9]='\0';
-
-	if(loggingDir!=NULL)
- 	{
-		if( stat( loggingDir, &st)==0)
-		{
-			if ( st.st_mode & S_IFDIR )
-			{
-				if( st.st_mode & S_IWUSR)
-				{
-					isLogDirExists=1;
-					memcpy(logDir,loggingDir,strlen(loggingDir)+1);
-				}
-				else printf("User do not have write permission to %s \n",loggingDir);
-			}
-			else printf("Provided path for %s is not a directory!!\n",loggingDir);
-    		}
-  		else printf("Log directory: %s does not exists\n",loggingDir);
-	} 
-  
-	if(isLogDirExists == 0)
-  	{
-		if ((getpwuid_r(getuid(),pwdptr,pwdbuffer,pwdlinelen,&tempPwdPtr))!=0)
-     			perror("getpwuid_r() error.");
-  		else
-  		{
-			memcpy(logDir,pd.pw_dir,strlen(pd.pw_dir)+1);	
-			memcpy(logDir+strlen(logDir),defaultLogDir,strlen(defaultLogDir)+1);	
-			if(stat(logDir,&st) != 0)
-				status = mkdir(logDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);	
-		}
-	}	
- 	memcpy(logFileName,logDir,strlen(logDir)+1);	
-	if( logDir[strlen(logDir)-1]!='/')
-	{
-		memcpy(logFileName+strlen(logFileName),"/",1);
-		memcpy(logFileName+strlen(logFileName),"\0",1);	
-	}	
-	memcpy(logFileName+strlen(logFileName),time,strlen(time)+1);	
-	memcpy(logFileName+strlen(logFileName),logExt,strlen(logExt)+1);	
-	ret=(char *)malloc(strlen(logFileName)+1);
-	memset(ret,0,strlen(logFileName)+1);
-       	memcpy(ret,logFileName,strlen(logFileName)+1); 
-
-	setenv("NLSR_LOG_FILE",ret,1);
-
-	free(time);	
-	free(logDir);
-	free(logFileName);	
-	free(pwdbuffer);	
-	free(logExt);
-	free(defaultLogDir);
-	free(ret);	
-}
-
-
-void 
-writeLogg(const char *source_file, const char *function, const int line, const char *format, ...)
-{
-	char *file=getenv("NLSR_LOG_FILE");	
-	if (file != NULL)
-	{
-		FILE *fp = fopen(file, "a");
-
-		if (fp != NULL)
-		{            
-			struct timeval t;
-			gettimeofday(&t, NULL);
-			fprintf(fp,"%ld.%06u - %s, %s, %d :",(long)t.tv_sec , (unsigned)t.tv_usec , source_file , function , line);        
-			va_list args;
-			va_start(args, format);
-			vfprintf(fp, format, args);
-			fclose(fp);
-			va_end(args);	
-		}
-    	}
-}
-
-
-struct sockaddr_in *
-get_ip_from_hostname(char *hostname )
-{
- 
-
-    struct addrinfo hints, *servinfo, *p;
-    int res; 
-    struct sockaddr_in * ip;
-    memset(&hints, 0, sizeof hints);
-    hints.ai_family = AF_UNSPEC;
-    hints.ai_socktype = SOCK_STREAM;
-
-    if ( (res = getaddrinfo( hostname , "9696", &hints , &servinfo)) != 0)
-    {
-        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(res));
-        return NULL;
-    }
-    int i=0;
-    for(p = servinfo; p != NULL; p = p->ai_next)
-    {
-        ip = (struct sockaddr_in *) p->ai_addr;
-	i++;
-   
-    }
-    freeaddrinfo(servinfo);
-    return ip;
-
-
-}
-
-
-
-int 
-get_ip_from_hostname_02(char * hostname , char* ip)
-{
-    struct hostent *he;
-    struct in_addr **addr_list;
-    int i;
-    if ( (he = gethostbyname( hostname ) ) == NULL)
-    {
-        herror("gethostbyname");
-        return 1;
-    }
-    addr_list = (struct in_addr **) he->h_addr_list;
-    for(i = 0; addr_list[i] != NULL; i++)
-    {
-        strcpy(ip , inet_ntoa(*addr_list[i]) );
-        return 0;
-    }
-    return 1;
-}
-
-
-
diff --git a/nlsr-sync-0.0/utility.h b/nlsr-sync-0.0/utility.h
deleted file mode 100755
index f90c281..0000000
--- a/nlsr-sync-0.0/utility.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _UTILITY_H_
-#define _UTILITY_H_
-
-char * getLocalTimeStamp(void);
-char * getGmTimeStamp(void);
-long int get_current_time_sec(void);
-void get_current_timestamp_micro(char * microSec);
-long int get_time_diff(const char *time1, const char *time2);
-
-void startLogging(char *loggingDir);
-void writeLogg(const char *source_file, const char *function, const int line, const char *format, ...);
-struct sockaddr_in * get_ip_from_hostname(char *hostname);
-int get_ip_from_hostname_02(char * hostname , char* ip);
-#endif
diff --git a/nlsr.c b/nlsr.c
index bd2ac39..a498264 100644
--- a/nlsr.c
+++ b/nlsr.c
@@ -26,6 +26,9 @@
 #include <ccn/signing.h>
 #include <ccn/schedule.h>
 #include <ccn/hashtb.h>
+#include <ccn/sync.h>
+#include <ccn/seqwriter.h>
+#include <ccn/ccn_private.h>
 
 #include "nlsr.h"
 #include "nlsr_ndn.h"
@@ -35,6 +38,9 @@
 #include "nlsr_adl.h"
 #include "nlsr_npt.h"
 #include "nlsr_route.h"
+#include "nlsr_sync.h"
+#include "nlsr_face.h"
+#include "nlsr_fib.h"
 
 
 #define ON_ERROR_DESTROY(resval) \
@@ -114,7 +120,7 @@
 void  
 daemonize_nlsr(void)
 {
-	int ret;
+	//int ret;
 	pid_t process_id = 0;
 	pid_t sid = 0;
 	process_id = fork();
@@ -126,7 +132,7 @@
 	if (process_id > 0)
 	{
 		printf("Process daemonized. Process id: %d \n", process_id);
-		ret=process_id;
+		//ret=process_id;
 		exit(0);
 	}
 	
@@ -153,7 +159,12 @@
 	}
 	char *rem;
 	const char *sep=" \t\n";
-	char *rtr_name,*face;
+	char *rtr_name;
+	char *nbr_ip_addr;
+	int is_ip_configured=0;
+	//char *face;
+	char *ip_addr=(char *)calloc(20,sizeof(char));
+	//memset(ip_addr,0,12);
 
 	rtr_name=strtok_r(command,sep,&rem);
 	if(rtr_name==NULL)
@@ -161,36 +172,47 @@
 		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';
 	}
-	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);
+
+	if (rem != NULL )
+	{
+		nbr_ip_addr=strtok_r(NULL,sep,&rem);
+		if ( nbr_ip_addr != NULL)
+			is_ip_configured=1;
+	}
+	struct name_prefix *nbr=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
+	nbr->name=(char *)calloc(strlen(rtr_name)+1,sizeof(char));
+	//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);
+	
+	if ( !is_ip_configured )
+	{
+		struct name_prefix *nbr_name=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
+		get_host_name_from_command_string(nbr_name,nbr->name,0);
+		if ( nlsr->debugging)
+			printf("Hostname of neighbor: %s ",nbr_name->name);
+		get_ip_from_hostname_02(nbr_name->name,ip_addr);
+		if ( nlsr->debugging)
+			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));
+		if (nlsr->debugging)
+		{
+			printf("Name of neighbor: %s ",nbr->name);
+			printf("IP Address: %s \n",ip_addr);
+		}
+	}
+	add_nbr_to_adl(nbr,0,ip_addr);
+	
 
 	free(nbr->name);
 	free(nbr);
@@ -220,9 +242,9 @@
 	if ( name[strlen(name)-1] == '/' )
 		name[strlen(name)-1]='\0';
 
-	struct name_prefix *np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	np->name=(char *)malloc(strlen(name)+1);
-	memset(np->name,0,strlen(name)+1);
+	struct name_prefix *np=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
+	np->name=(char *)calloc(strlen(name)+1,sizeof(char));
+	//memset(np->name,0,strlen(name)+1);
 	memcpy(np->name,name,strlen(name)+1);
 	np->length=strlen(name)+1;
 
@@ -256,13 +278,14 @@
 	if ( rtr_name[strlen(rtr_name)-1] == '/' )
 		rtr_name[strlen(rtr_name)-1]='\0';
 
-	nlsr->router_name=(char *)malloc(strlen(rtr_name)+1);
-	memset(nlsr->router_name,0,strlen(rtr_name)+1);
+	nlsr->router_name=(char *)calloc(strlen(rtr_name)+1,sizeof(char));
+	//memset(nlsr->router_name,0,strlen(rtr_name)+1);
 	memcpy(nlsr->router_name,rtr_name,strlen(rtr_name)+1);
 
 
 }
 
+/*
 void 
 process_command_lsdb_synch_interval(char *command)
 {
@@ -290,7 +313,7 @@
 	}
 
 }
-
+*/
 
 void 
 process_command_interest_retry(char *command)
@@ -369,9 +392,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;
+		}
 	}
 
 }
@@ -397,19 +424,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;
@@ -420,14 +451,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;
 	}
 
 }
@@ -451,8 +482,8 @@
 		return;
 	}
 	
-	nlsr->logDir=(char *)malloc(strlen(dir)+1);
-	memset(nlsr->logDir,0,strlen(dir)+1);
+	nlsr->logDir=(char *)calloc(strlen(dir)+1,sizeof(char));
+	//memset(nlsr->logDir,0,strlen(dir)+1);
 	memcpy(nlsr->logDir,dir,strlen(dir));
 }
 
@@ -506,6 +537,159 @@
 	}
 }
 
+
+void 
+process_command_topo_prefix(char *command)
+{
+	if(command==NULL)
+	{
+		printf(" Wrong Command Format ( topo-prefix )\n");
+		return;
+	}
+	char *rem;
+	const char *sep=" \t\n";
+	char *topo_prefix;
+
+	topo_prefix=strtok_r(command,sep,&rem);
+	if(topo_prefix==NULL)
+	{
+		printf(" Wrong Command Format (  topo-prefix /name/prefix  )\n");
+		return;
+	}
+	else
+	{
+		if( nlsr->topo_prefix != NULL)	
+			free(nlsr->topo_prefix);
+		if ( topo_prefix[strlen(topo_prefix)-1] == '/' )
+			topo_prefix[strlen(topo_prefix)-1]='\0';
+
+		nlsr->topo_prefix=(char *)calloc(strlen(topo_prefix)+1,sizeof(char));
+		//memset(nlsr->topo_prefix,0,strlen(topo_prefix)+1);
+		puts(topo_prefix);
+		memcpy(nlsr->topo_prefix,topo_prefix,strlen(topo_prefix));
+
+	}
+}
+
+
+void 
+process_command_slice_prefix(char *command)
+{
+	if(command==NULL)
+	{
+		printf(" Wrong Command Format ( slice-prefix /name/prefix )\n");
+		return;
+	}
+	char *rem;
+	const char *sep=" \t\n";
+	char *slice_prefix;
+
+	slice_prefix=strtok_r(command,sep,&rem);
+	if(slice_prefix==NULL)
+	{
+		printf(" Wrong Command Format (  slice-prefix /name/prefix  )\n");
+		return;
+	}
+	else
+	{
+		if ( nlsr->slice_prefix != NULL)
+			free(nlsr->slice_prefix);
+		if ( slice_prefix[strlen(slice_prefix)-1] == '/' )
+			slice_prefix[strlen(slice_prefix)-1]='\0';
+
+		nlsr->slice_prefix=(char *)calloc(strlen(slice_prefix)+1,sizeof(char));
+		//memset(nlsr->slice_prefix,0,strlen(slice_prefix)+1);
+		memcpy(nlsr->slice_prefix,slice_prefix,strlen(slice_prefix));
+	}
+}
+
+void 
+process_command_hyperbolic_routing(char *command)
+{
+	if(command==NULL)
+	{
+		printf(" Wrong Command Format ( hyperbolic-routing on)\n");
+		return;
+	}
+	char *rem;
+	const char *sep=" \t\n";
+	char *on_off;
+
+	on_off=strtok_r(command,sep,&rem);
+	if(on_off==NULL)
+	{
+		printf(" Wrong Command Format ( hyperbolic-routing on )\n");
+		return;
+	}
+	
+	if ( strcmp(on_off,"ON") == 0 || strcmp(on_off,"on") == 0 )
+	{
+		nlsr->is_hyperbolic_calc=1;
+	}
+}
+
+void
+process_command_hyperbolic_cordinate(char *command)
+{
+	if(command==NULL)
+	{
+		printf(" Wrong Command Format ( hyperbolic r 0 )\n");
+		return;
+	}
+
+	char *rem;
+	const char *sep=" \t\n\r";
+	char *radious;
+	char *theta;
+
+	radious=strtok_r(command,sep,&rem);
+	if (radious == NULL )
+	{
+		printf(" Wrong Command Format ( hyperbolic r 0 )\n");
+		return;
+	}
+
+	theta=strtok_r(NULL,sep,&rem);
+	if (theta == NULL )
+	{
+		printf(" Wrong Command Format ( hyperbolic r 0 )\n");
+		return;
+	}
+
+	nlsr->cor_r=strtof(radious,NULL);
+	nlsr->cor_theta=strtof(theta,NULL);
+
+}
+
+void 
+process_command_tunnel_type(char *command)
+{
+	if(command==NULL)
+	{
+		printf(" Wrong Command Format ( tunnel-type udp/tcp)\n");
+		return;
+	}
+	char *rem;
+	const char *sep=" \t\n";
+	char *on_off;
+
+	on_off=strtok_r(command,sep,&rem);
+	if(on_off==NULL)
+	{
+		printf(" Wrong Command Format ( tunnel-type udp/tcp )\n");
+		return;
+	}
+	
+	if ( strcmp(on_off,"TCP") == 0 || strcmp(on_off,"tcp") == 0 )
+	{
+		nlsr->tunnel_type=IPPROTO_TCP;
+	}
+	else if ( strcmp(on_off,"UDP") == 0 || strcmp(on_off,"udp") == 0 )
+	{
+		nlsr->tunnel_type=IPPROTO_UDP;
+	}
+}
+
 void 
 process_conf_command(char *command)
 {
@@ -530,10 +714,10 @@
 	{
 		process_command_ccnname(remainder);
 	}
-	else if(!strcmp(cmd_type,"lsdb-synch-interval") )
+	/*else if(!strcmp(cmd_type,"lsdb-synch-interval") )
 	{
 		process_command_lsdb_synch_interval(remainder);
-	}
+	}*/
 	else if(!strcmp(cmd_type,"interest-retry") )
 	{
 		process_command_interest_retry(remainder);
@@ -550,9 +734,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") )
 	{
@@ -566,6 +750,26 @@
 	{
 			process_command_debug(remainder);
 	}
+	else if(!strcmp(cmd_type,"topo-prefix") )
+	{
+			process_command_topo_prefix(remainder);
+	}
+	else if(!strcmp(cmd_type,"slice-prefix") )
+	{
+			process_command_slice_prefix(remainder);
+	}
+	else if(!strcmp(cmd_type,"hyperbolic-cordinate") )
+	{
+		process_command_hyperbolic_cordinate(remainder);
+	}
+	else if(!strcmp(cmd_type,"hyperbolic-routing") )
+	{
+		process_command_hyperbolic_routing(remainder);
+	}
+	else if(!strcmp(cmd_type,"tunnel-type") )
+	{
+		process_command_tunnel_type(remainder);
+	}
 	else 
 	{
 		printf("Wrong configuration Command %s \n",cmd_type);
@@ -602,14 +806,68 @@
 	return 0;
 }
 
+
+void
+add_faces_for_nbrs(void)
+{	
+	int i, adl_element;
+	struct ndn_neighbor *nbr;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+    	
+    	hashtb_start(nlsr->adl, e);
+	adl_element=hashtb_n(nlsr->adl);
+
+	for(i=0;i<adl_element;i++)
+	{
+		nbr=e->data;
+		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);		
+	}
+
+	hashtb_end(e);
+
+}
+
+void
+destroy_faces_for_nbrs(void)
+{	
+	int i, adl_element;
+	struct ndn_neighbor *nbr;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+    	
+    	hashtb_start(nlsr->adl, e);
+	adl_element=hashtb_n(nlsr->adl);
+
+	for(i=0;i<adl_element;i++)
+	{
+		nbr=e->data;
+		if ( nbr->face > 0 )
+		{	
+			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);		
+	}
+
+	hashtb_end(e);
+
+}
+
 char *
 process_api_client_command(char *command)
 {
 	char *msg;
 	msg=(char *)malloc(100);	
-	memset(msg,100,0);
-	//strcpy(msg,"Action Carried Out for NLSR Api Client");
-
+	memset(msg,0,100);
+	
 	const char *sep=" \t\n";
 	char *rem=NULL;
 	char *cmd_type=NULL;
@@ -625,9 +883,9 @@
 	if ( name[strlen(name)-1] == '/' )
 		name[strlen(name)-1]='\0';
 
-	struct name_prefix *np=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	np->name=(char *)malloc(strlen(name)+1);
-	memset(np->name,0,strlen(name)+1);
+	struct name_prefix *np=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
+	np->name=(char *)calloc(strlen(name)+1,sizeof(char));
+	//memset(np->name,0,strlen(name)+1);
 	memcpy(np->name,name,strlen(name)+1);
 	np->length=strlen(name)+1;
 
@@ -687,6 +945,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)
 				{
@@ -701,8 +963,24 @@
 			res=is_neighbor(np->name);
 			if ( res == 0 )
 			{
-				add_nbr_to_adl(np,face_id);
+				struct name_prefix *nbr_name=(struct name_prefix *)calloc(1,sizeof(struct name_prefix ));
+				get_host_name_from_command_string(nbr_name,np->name,0);
+				printf("Hostname of neighbor: %s ",nbr_name->name);
+
+				char *ip_addr=(char *)calloc(20,sizeof(char));
+				//memset(ip_addr,0,20);
+				get_ip_from_hostname_02(nbr_name->name,ip_addr);
+				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->slice_prefix, OP_REG, face_id);				
+
+				add_nbr_to_adl(np,face_id,ip_addr);
+
 				sprintf(msg,"Neighbor %s has been added to adjacency list.",name);
+				free(ip_addr);
+
 			}
 			else
 			{
@@ -719,18 +997,16 @@
 nlsr_api_server_poll(long int time_out_micro_sec, int ccn_fd)
 {
 	struct timeval timeout;
-	if ( time_out_micro_sec < 0 )
+	if (time_out_micro_sec< 500000 && time_out_micro_sec> 0 )
 	{
-		timeout.tv_sec=1;
-		timeout.tv_usec=0;
+		timeout.tv_sec=0;
+		timeout.tv_usec=time_out_micro_sec;
 	}
-	else
+	else 
 	{
-		time_out_micro_sec=(long int)time_out_micro_sec*0.4;
-		timeout.tv_sec=time_out_micro_sec / 1000000;
-		timeout.tv_usec=time_out_micro_sec % 1000000;
+		timeout.tv_sec = 0;
+		timeout.tv_usec = 500000;
 	}
-
 	
 	int fd;
 	int nread;
@@ -745,7 +1021,7 @@
 	testfds=nlsr->readfds;
 	result = select(FD_SETSIZE, &testfds, NULL,NULL, &timeout);
 	
-	for(fd = 0; fd < FD_SETSIZE; fd++) 
+	for(fd = 0; fd < FD_SETSIZE && result > 0; fd++) 
 	{
 		if(FD_ISSET(fd,&testfds)) 
 		{
@@ -755,14 +1031,13 @@
 			}			
 			else if(fd == nlsr->nlsr_api_server_sock_fd)
 			{
-				printf("Setting up socket....\n");
 				client_len = sizeof(client_address);
 				client_sockfd = accept(nlsr->nlsr_api_server_sock_fd,(struct sockaddr *)&client_address, &client_len);
 				FD_SET(client_sockfd, &nlsr->readfds);
 			}
 			else
 			{   
-				printf("Else...\n");		
+					
 				ioctl(fd, FIONREAD, &nread);
 				if(nread == 0) 
 				{
@@ -772,7 +1047,7 @@
 				else 
 				{
 					recv(fd, recv_buffer, 1024, 0);
-					printf("Test Received Data from NLSR API cleint: %s \n",recv_buffer);
+					printf("Received Data from NLSR API cleint: %s \n",recv_buffer);
 					char *msg=process_api_client_command(recv_buffer);
 					send(fd, msg, strlen(msg),0);
 					free(msg);
@@ -786,6 +1061,23 @@
 	return 0;
 }
 
+int
+check_config_validity()
+{
+	if (nlsr->router_name == NULL )
+	{
+		fprintf(stderr,"Router name has not been configured :(\n");
+		return -1;
+	}
+	if ( nlsr->is_hyperbolic_calc == 1 && (nlsr->cor_r == -1.0 && nlsr->cor_theta== -1.0) ) 	
+	{
+		fprintf(stderr,"Hyperbolic codinate has not been defined :(\n");
+		return -1;
+	}
+	
+	return 0;
+}
+
 void 
 nlsr_destroy( void )
 {
@@ -796,20 +1088,16 @@
 	writeLogg(__FILE__,__FUNCTION__,__LINE__,"Freeing Allocated Memory....\n");	
 	/* Destroying all face created by nlsr in CCND */
 	destroy_all_face_by_nlsr();	
-
+	destroy_faces_for_nbrs();
 	/* Destroying every hash table attached to each neighbor in ADL before destorying ADL */	
-	hashtb_destroy(&nlsr->npl);
-	hashtb_destroy(&nlsr->adl);	
+	hashtb_destroy(&nlsr->adl);
+	hashtb_destroy(&nlsr->npl);	
+	hashtb_destroy(&nlsr->pit_alsa);
 	hashtb_destroy(&nlsr->lsdb->name_lsdb);
 	hashtb_destroy(&nlsr->lsdb->adj_lsdb);
-	hashtb_destroy(&nlsr->pit_alsa);
+	hashtb_destroy(&nlsr->lsdb->cor_lsdb);
 
-	//To Do: has to destroy the face_list one by one 	
-
-	hashtb_destroy(&nlsr->routing_table);
-
-
-	int i, npt_element;
+	int i, npt_element,rt_element;
 	struct npt_entry *ne;
 	struct hashtb_enumerator ee;
     	struct hashtb_enumerator *e = &ee;
@@ -825,26 +1113,43 @@
 
 	hashtb_end(e);
 	hashtb_destroy(&nlsr->npt);
+	
+	
+	struct routing_table_entry *rte;
+	hashtb_start(nlsr->routing_table, e);
+	rt_element=hashtb_n(nlsr->routing_table);
+	for(i=0;i<rt_element;i++)
+	{
+		rte=e->data;
+		hashtb_destroy(&rte->face_list);	
+		hashtb_next(e);		
+	}	
+	hashtb_end(e);
+	hashtb_destroy(&nlsr->routing_table);
+	
+	if ( nlsr->ccns != NULL )
+		ccns_close(&nlsr->ccns, NULL, NULL);
+	if ( nlsr->slice != NULL ) 
+		ccns_slice_destroy(&nlsr->slice);
 
+	close(nlsr->nlsr_api_server_sock_fd);
 
-	close(nlsr->nlsr_api_server_sock_fd);	
-
-	ccn_schedule_destroy(&nlsr->sched);
 	ccn_destroy(&nlsr->ccn);
-
 	free(nlsr->lsdb->lsdb_version);
 	free(nlsr->lsdb);
 	free(nlsr->router_name);
-	free(nlsr);
 	if ( nlsr->debugging )
 	{
 		printf("Finished freeing allocated memory\n");
 	}
 	writeLogg(__FILE__,__FUNCTION__,__LINE__,"Finished freeing allocated memory\n");
+	
+	free(nlsr);
 
 }
 
 
+
 void
 init_api_server(int ccn_fd)
 {
@@ -864,13 +1169,11 @@
        	}
 
 	server_address.sin_family = AF_INET;
-	//server_address.sin_addr.s_addr = inet_addr("127.0.0.1");
 	server_address.sin_addr.s_addr = INADDR_ANY;
 	server_address.sin_port = htons(nlsr->api_port);
 
 	server_len = sizeof(server_address);
 	bind(server_sockfd, (struct sockaddr *)&server_address, server_len);
-	//printf("port number %d\n", ntohs(server_address.sin_port));
 	listen(server_sockfd, 100);
 	FD_ZERO(&nlsr->readfds);
 	FD_SET(server_sockfd, &nlsr->readfds);
@@ -898,7 +1201,7 @@
 		return -1;
 	}
 
-	nlsr=(struct nlsr *)malloc(sizeof(struct nlsr));
+	nlsr=(struct nlsr *)calloc(1,sizeof(struct nlsr));
 	
 	struct hashtb_param param_adl = {0};
 	nlsr->adl=hashtb_create(sizeof(struct ndn_neighbor), &param_adl);
@@ -916,17 +1219,19 @@
 
 	nlsr->lsdb=(struct linkStateDatabase *)malloc(sizeof(struct linkStateDatabase));
 
-	char *time_stamp=(char *)malloc(20);
-	memset(time_stamp,0,20);
+	char *time_stamp=(char *)calloc(20,sizeof(char));
+	//memset(time_stamp,0,20);
 	get_current_timestamp_micro(time_stamp);
 	nlsr->lsdb->lsdb_version=(char *)malloc(strlen(time_stamp)+1);
-	memset(nlsr->lsdb->lsdb_version,'0',strlen(time_stamp));
+	memset(nlsr->lsdb->lsdb_version,0,strlen(time_stamp));
 	free(time_stamp);
 	
 	struct hashtb_param param_adj_lsdb = {0};
 	nlsr->lsdb->adj_lsdb = hashtb_create(sizeof(struct alsa), &param_adj_lsdb);
 	struct hashtb_param param_name_lsdb = {0};
 	nlsr->lsdb->name_lsdb = hashtb_create(sizeof(struct nlsa), &param_name_lsdb);
+	struct hashtb_param param_cor_lsdb = {0};
+	nlsr->lsdb->cor_lsdb = hashtb_create(sizeof(struct clsa), &param_cor_lsdb);
 	
 	
 
@@ -942,16 +1247,30 @@
 	nlsr->detailed_logging=0;
 	nlsr->debugging=0;
 
-	nlsr->lsdb_synch_interval = LSDB_SYNCH_INTERVAL;
+	//nlsr->lsdb_synch_interval = LSDB_SYNCH_INTERVAL;
 	nlsr->interest_retry = INTEREST_RETRY;
 	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;
 
+	nlsr->topo_prefix=(char *)calloc(strlen("/ndn/routing/nlsr")+1,sizeof(char));
+	//memset(nlsr->topo_prefix,0,strlen("/ndn/routing/nlsr")+1);
+	memcpy(nlsr->topo_prefix,"/ndn/routing/nlsr",strlen("/ndn/routing/nlsr"));
+
+	nlsr->slice_prefix=(char *)calloc(strlen("/ndn/routing/nlsr/LSA")+1,sizeof(char));
+	//memset(nlsr->slice_prefix, 0, strlen("/ndn/routing/nlsr/LSA")+1);
+	memcpy(nlsr->slice_prefix,"/ndn/routing/nlsr/LSA",strlen("/ndn/routing/nlsr/LSA"));
+
+	nlsr->is_hyperbolic_calc=0;
+	nlsr->cor_r=-1.0;
+	nlsr->cor_theta=-1.0;
+
+	nlsr->tunnel_type=IPPROTO_UDP;
+
 	return 0;
 }
 
@@ -992,8 +1311,14 @@
 		nlsr->api_port=port;
 
 	readConfigFile(config_file);
+
+	ON_ERROR_DESTROY(check_config_validity());
+
+	print_adjacent_from_adl();
+
 	if ( daemon_mode == 1 )
 	{
+		nlsr->debugging=0;
 		daemonize_nlsr();
 	}
 	
@@ -1009,7 +1334,14 @@
 	}
 
 	init_api_server(ccn_fd);
-	
+
+	res=create_sync_slice(nlsr->topo_prefix, nlsr->slice_prefix);
+	if(res<0)
+	{
+		fprintf(stderr, "Can not create slice for prefix %s\n",nlsr->slice_prefix);
+		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Can not create slice for prefix %s\n",nlsr->slice_prefix);
+		ON_ERROR_DESTROY(res);
+	}
 	struct ccn_charbuf *router_prefix;	
 	router_prefix=ccn_charbuf_create(); 
 	res=ccn_name_from_uri(router_prefix,nlsr->router_name);		
@@ -1038,14 +1370,25 @@
 		printf("lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
 	writeLogg(__FILE__,__FUNCTION__,__LINE__,"lsdb_version: %s\n",nlsr->lsdb->lsdb_version);
 
+	add_faces_for_nbrs();
 	print_name_prefix_from_npl();
 	print_adjacent_from_adl();
-	build_and_install_name_lsas();
-	print_name_lsdb();	
+	build_and_install_name_lsas();	
+
+	print_name_lsdb();
+	if ( nlsr->cor_r != -1.0 && nlsr->cor_theta != -1.0)
+	{
+		build_and_install_cor_lsa();
+	}
+	write_name_lsdb_to_repo(nlsr->slice_prefix);
 
 	nlsr->sched = ccn_schedule_create(nlsr, &ndn_rtr_ticker);
+	ccn_set_schedule(nlsr->ccn,nlsr->sched);
 	nlsr->event_send_info_interest = ccn_schedule_event(nlsr->sched, 1, &send_info_interest, NULL, 0);
 	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
+	
+	res=sync_monitor(nlsr->topo_prefix,nlsr->slice_prefix);
+	ON_ERROR_DESTROY(res);
 
 	
 	while(1)
@@ -1060,7 +1403,7 @@
 			}
 			if(nlsr->ccn != NULL)
 			{
-        			res = ccn_run(nlsr->ccn, 0);
+        			res = ccn_run(nlsr->ccn, 1);
 			}
 			if (!(nlsr->sched && nlsr->ccn))
 			{	      
diff --git a/nlsr.conf b/nlsr.conf
index 193bafc..ced844f 100644
--- a/nlsr.conf
+++ b/nlsr.conf
@@ -1,6 +1,6 @@
 router-name /ndn/memphis.edu/netlab/macbook
-ccnneighbor /ndn/memphis.edu/netlab/mira face14 10
-ccnneighbor /ndn/memphis.edu/netlab/castor face16 8
+ccnneighbor /ndn/memphis.edu/netlab/pollux face2 10
+ccnneighbor /ndn/memphis.edu/netlab/castor face3 8
 ccnname /ndn/memphis.edu/netlab/macbook/name1
 ccnname /ndn/memphis.edu/netlab/macbook/test
 lsdb-synch-interval 310
diff --git a/nlsr.h b/nlsr.h
index a53cc2b..681973b 100644
--- a/nlsr.h
+++ b/nlsr.h
@@ -9,14 +9,14 @@
 #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
 
 #define NAME_LSA_VALID 1
 #define NAME_LSA_INVALID 0
 
-#define API_PORT 9696
+#define API_PORT 9999
 
 
 struct name_prefix
@@ -29,6 +29,8 @@
 {
 	struct hashtb *name_lsdb;
 	struct hashtb *adj_lsdb;
+	struct hashtb *cor_lsdb;
+	
 	char *lsdb_version;
 };
 
@@ -43,6 +45,12 @@
 
 	struct ccn_closure in_interest;
 	struct ccn_closure in_content;
+
+	struct ccns_name_closure *closure;
+
+	struct ccns_slice *slice;
+    	struct ccns_handle *ccns;
+
 	struct ccn_schedule *sched;
     	struct ccn_scheduled_event *event;
 	struct ccn_scheduled_event *event_send_lsdb_interest;
@@ -59,6 +67,7 @@
 	struct hashtb *npt;
 	struct hashtb *routing_table;
 
+
 	struct linkStateDatabase *lsdb;
 
 	struct ccn *ccn;
@@ -74,12 +83,13 @@
 	int is_send_lsdb_interest_scheduled;
 	int is_route_calculation_scheduled;
 
-	long int lsdb_synch_interval;
+	//long int lsdb_synch_interval;
 	int interest_retry;
 	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;
@@ -89,6 +99,16 @@
 	int nlsr_api_server_sock_fd;
 	fd_set readfds;
 	int api_port;
+
+	char *topo_prefix;
+	char *slice_prefix;
+
+	int is_hyperbolic_calc;
+	double cor_r;
+	double cor_theta;
+
+	int tunnel_type;
+	
 	
 };
 
diff --git a/nlsr_adl.c b/nlsr_adl.c
index 54d8954..ad6254d 100644
--- a/nlsr_adl.c
+++ b/nlsr_adl.c
@@ -8,6 +8,10 @@
 #include <assert.h>
 #ifdef HAVE_CONFIG_H
 #include <config.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
 #endif
 
 
@@ -25,7 +29,7 @@
 #include "nlsr_npt.h"
 
 void 
-add_nbr_to_adl(struct name_prefix *new_nbr,int face)
+add_nbr_to_adl(struct name_prefix *new_nbr,int face,char *ip)
 {
 	struct ndn_neighbor *nbr=(struct ndn_neighbor *)malloc(sizeof(struct ndn_neighbor )); //free
 
@@ -54,6 +58,9 @@
 		nbr->metric=LINK_METRIC;
 		nbr->is_lsdb_send_interest_scheduled=0;
 		
+		nbr->ip_address=(char *)malloc(strlen(ip)+1);
+		memset(nbr->ip_address,0,strlen(ip)+1);
+		memcpy(nbr->ip_address,ip,strlen(ip));
 
 		char *time_stamp=(char *)malloc(20);
 		get_current_timestamp_micro(time_stamp);
@@ -81,6 +88,7 @@
 		printf("--------Neighbor---------------------------\n");
 		printf("	Neighbor: %s \n",nbr->neighbor->name);
 		printf("	Length  : %d \n",nbr->neighbor->length);
+		printf("	Ip Address: %s \n",nbr->ip_address);
 		printf("	Face    : %d \n",nbr->face);
 		printf("	Metric    : %d \n",nbr->metric);
 		printf("	Status  : %d \n",nbr->status);
@@ -310,23 +318,17 @@
 
 	hashtb_start(nlsr->adl, e);
 
-	//printf("Neighbor: %s , Length: %d \n",nbr->name, nbr->length);
-
 	res = hashtb_seek(e, nbr->name, nbr->length, 0);
 
 	if( res == HT_OLD_ENTRY )
 	{
-		//printf("Old Neighbor\n");
 		nnbr=e->data;
 		nnbr->lsdb_interest_timed_out += increment;
-		//printf("lsdb_interest_timed_out: %d \n",nnbr->lsdb_interest_timed_out);
 	}
 	else if(res == HT_NEW_ENTRY)
 	{
 		hashtb_delete(e);
-	}
-
-	//print_adjacent_from_adl();		
+	}		
 	hashtb_end(e);
 }
 
@@ -533,12 +535,13 @@
 			free(temp_length);
 			ccn_charbuf_append_string(c,"|");
 
-			char *temp_face=(char *)malloc(20);
+			/*char *temp_face=(char *)malloc(20);
 			memset(temp_face,0,20);
 			sprintf(temp_face,"%d",nbr->face);
 			ccn_charbuf_append_string(c,temp_face);
 			free(temp_face);
 			ccn_charbuf_append_string(c,"|");
+			*/
 
 			char *temp_metric=(char *)malloc(20);
 			memset(temp_metric,0,20);
@@ -891,6 +894,32 @@
 	return connecting_face;
 }
 
+void
+update_face_to_adl_for_nbr(char *nbr, int face)
+{
+	int res;
+	struct ndn_neighbor *nnbr;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+
+	hashtb_start(nlsr->adl, e);
+	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
+
+	if( res == HT_OLD_ENTRY )
+	{
+		nnbr=e->data;
+		nnbr->face=face;
+		
+	}
+	else if(res == HT_NEW_ENTRY)
+	{
+		hashtb_delete(e);
+	}
+
+	hashtb_end(e);
+}
+
 int 
 is_neighbor(char *nbr)
 {
@@ -917,3 +946,34 @@
 	return ret;
 }
 
+int 
+is_active_neighbor(char *nbr)
+{
+	int ret=0;
+
+	int res;
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+
+	hashtb_start(nlsr->adl, e);
+	res = hashtb_seek(e, nbr, strlen(nbr)+1, 0);
+
+	if( res == HT_OLD_ENTRY )
+	{
+		struct ndn_neighbor *nnbr;
+		nnbr=e->data;
+		if (nnbr->status == NBR_ACTIVE )
+		{
+			ret=1;	
+		}
+	}
+	else if(res == HT_NEW_ENTRY)
+	{
+		hashtb_delete(e);
+	}
+
+	hashtb_end(e);
+
+	return ret;
+}
+
diff --git a/nlsr_adl.h b/nlsr_adl.h
index 5e9fa5a..1eb74d6 100644
--- a/nlsr_adl.h
+++ b/nlsr_adl.h
@@ -11,6 +11,7 @@
 	int status;
 	char * last_lsdb_version;
 	char * last_info_version;
+	char *ip_address;
 	int info_interest_timed_out;
 	int lsdb_interest_timed_out;
 	int lsdb_random_time_component;
@@ -20,7 +21,7 @@
 	int metric;
 };
 
-void add_nbr_to_adl(struct name_prefix *new_nbr,int face);
+void add_nbr_to_adl(struct name_prefix *new_nbr,int face,char *ip);
 void delete_nbr_from_adl(struct name_prefix *nbr);
 void print_adjacent(struct ndn_neighbor *nbr);
 void print_adjacent_from_adl(void);
@@ -48,4 +49,6 @@
 void adjust_adjacent_last_lsdb_requested_to_adl(char *nbr, long int sec);
 int get_next_hop_face_from_adl(char *nbr);
 int is_neighbor(char *nbr);
+int is_active_neighbor(char *nbr);
+void update_face_to_adl_for_nbr(char *nbr, int face);
 #endif
diff --git a/nlsr-sync-0.0/nlsr_face.c b/nlsr_face.c
similarity index 100%
rename from nlsr-sync-0.0/nlsr_face.c
rename to nlsr_face.c
diff --git a/nlsr-sync-0.0/nlsr_face.h b/nlsr_face.h
similarity index 100%
rename from nlsr-sync-0.0/nlsr_face.h
rename to nlsr_face.h
diff --git a/nlsr_fib.c b/nlsr_fib.c
index e89e80d..6ef81cb 100644
--- a/nlsr_fib.c
+++ b/nlsr_fib.c
@@ -15,6 +15,7 @@
 #include <ccn/charbuf.h>
 
 #include "nlsr_fib.h"
+#include "nlsr.h"
 
 
 static void 
@@ -71,7 +72,7 @@
 	forwarding_entry->ccnd_id_size =ccnd_id_size;
 	forwarding_entry->faceid = faceid;
 	forwarding_entry->flags = -1;
-	forwarding_entry->lifetime = (~0U) >> 1;
+	forwarding_entry->lifetime = 2100;
 
 	prefixreg = ccn_charbuf_create();
 	ccnb_append_forwarding_entry(prefixreg, forwarding_entry);
@@ -181,6 +182,12 @@
 int 
 add_delete_ccn_face_by_face_id(struct ccn *h, const char *uri, int operation, int faceid)
 {
+	if ( nlsr->debugging )
+	{
+		printf("add_delete_ccn_face_by_face_id called\n");
+		printf("Uri: %s  Face: %d Operation: %s \n",(char *)uri , faceid, operation == OP_REG ? "Registration" : "Unregistration");
+	}
+
 	struct ccn_charbuf *prefix;
 	struct ccn_charbuf *local_scope_template = ccn_charbuf_create();
 	struct ccn_charbuf *no_name = ccn_charbuf_create();
diff --git a/nlsr_lsdb.c b/nlsr_lsdb.c
index bec9869..1798700 100644
--- a/nlsr_lsdb.c
+++ b/nlsr_lsdb.c
@@ -25,11 +25,11 @@
 #include "nlsr_adl.h"
 #include "nlsr_route.h"
 #include "nlsr_npt.h"
+#include "nlsr_sync.h"
 
 void
 set_new_lsdb_version(void)
 {
-	
 	char *time_stamp=(char *)malloc(20);
 	memset(time_stamp,0,20);
 	get_current_timestamp_micro(time_stamp);
@@ -47,9 +47,6 @@
 make_name_lsa_key(char *key, char *orig_router, int ls_type, long int ls_id)
 {
 	
-	
-	//printf("Orig Router: %s LS Type: %d LS Id: %ld\n",orig_router,ls_type,ls_id);
-
 	char lst[2];
 	memset(lst,0,2);
 	sprintf(lst,"%d",ls_type);	
@@ -63,9 +60,39 @@
 	memcpy(key+strlen(key),lst,strlen(lst));
 	memcpy(key+strlen(key),"/",1);
 	memcpy(key+strlen(key),lsid,strlen(lsid));
-
-	//printf("Key: %s\n",key);
 	
+	if ( nlsr->debugging )
+		printf("name LSA Key: %s\n", key);
+}
+
+
+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%s/lsType.%d/lsId.%ld/%s",slice_prefix, orig_router, ls_type, ls_id, orig_time);
+	
+	if ( nlsr->debugging )
+		printf("Name LSA prefix for repo content: %s\n",key);
+}
+
+void 
+make_adj_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, char *orig_time,char *slice_prefix)
+{
+		
+	sprintf(key,"%s%s/lsType.%d/%s",slice_prefix,orig_router,ls_type, orig_time );	
+
+	if ( nlsr->debugging )
+		printf("Name LSA prefix for repo content:%s\n",key);	
+}
+
+void 
+make_cor_lsa_prefix_for_repo(char *key, char *orig_router, int ls_type, char *orig_time,char *slice_prefix)
+{
+		
+	sprintf(key,"%s%s/lsType.%d/%s",slice_prefix,orig_router,ls_type, orig_time );	
+
+	if ( nlsr->debugging )
+		printf("Cor LSA prefix for repo content:%s\n",key);	
 }
 
 void 
@@ -77,7 +104,6 @@
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_name_lsas called\n");
 
 	int i, npl_element;
-	//struct name_prefix *np;
 	struct name_prefix_list_entry *npe;
 
 	struct hashtb_enumerator ee;
@@ -173,9 +199,6 @@
 	char *time_stamp=(char *)malloc(20);
 	memset(time_stamp,0,20);
 	get_current_timestamp_micro(time_stamp);
-	//long int lsa_life_time=get_time_diff(time_stamp,name_lsa->header->orig_time);
-
-	//printf("time difference: %ld \n",lsa_life_time);
 	
 
 		char lst[2];
@@ -452,7 +475,6 @@
 							int check=add_npt_entry(new_name_lsa->header->orig_router->name,new_name_lsa->name_prefix->name,next_hop,faces,route_costs);
 							if ( check == HT_NEW_ENTRY )
 							{
-								//printf("Added in npt \n");
 								if ( nlsr->debugging )
 									printf("Added in npt \n");
 								if ( nlsr->detailed_logging )
@@ -599,6 +621,16 @@
 }
 
 
+void 
+make_cor_lsa_key(char *key,struct clsa *cor_lsa)
+{
+	memcpy(key+strlen(key),cor_lsa->header->orig_router->name,cor_lsa->header->orig_router->length);
+	memcpy(key+strlen(key),"/",1);
+	char ls_type[2];
+	sprintf(ls_type,"%d",cor_lsa->header->ls_type);
+	memcpy(key+strlen(key),ls_type,strlen(ls_type));
+	key[strlen(key)]='\0';
+}
 
 
 void 
@@ -645,6 +677,39 @@
 			build_adj_lsa(adj_lsa);
 			install_adj_lsa(adj_lsa);
 
+			char lst[2];
+			memset(lst,0,2);
+			sprintf(lst,"%d",LS_TYPE_ADJ);			
+
+			char *repo_key=(char *)malloc(strlen(nlsr->slice_prefix)+strlen(adj_lsa->header->orig_time)+strlen(adj_lsa->header->orig_router->name) + strlen(lst) + 5+15);
+			memset(repo_key, 0, strlen(nlsr->slice_prefix)+strlen(adj_lsa->header->orig_time)+strlen(adj_lsa->header->orig_router->name) + strlen(lst) + 5+15);	
+			make_adj_lsa_prefix_for_repo(repo_key, adj_lsa->header->orig_router->name,LS_TYPE_ADJ,adj_lsa->header->orig_time,nlsr->slice_prefix);
+		
+			if ( nlsr->debugging )
+				printf("Adj LSA Repo Key: %s \n",repo_key);
+
+			char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
+			memset(key,0,adj_lsa->header->orig_router->length+2+2);
+			make_adj_lsa_key(key,adj_lsa);
+			if ( nlsr->debugging )
+				printf("Adj LSA: %s \n",key);
+
+			struct name_prefix *lsaid=(struct name_prefix *)malloc(sizeof(struct name_prefix));
+			lsaid->name=(char *)malloc(strlen(key)+1);
+			memset(lsaid->name, 0, strlen(key)+1);
+			memcpy(lsaid->name,key,strlen(key));
+			lsaid->length=strlen(key)+1;
+
+		
+			write_adj_lsa_to_repo(repo_key, lsaid);
+
+			free(key);
+			free(repo_key);
+			free(lsaid->name);
+			free(lsaid);
+
+
+		
 			free(adj_lsa->header->orig_router->name);
 			free(adj_lsa->header->orig_router);
 			free(adj_lsa->header->orig_time);
@@ -680,9 +745,6 @@
 
 	int no_link=no_active_nbr();
 	
-	//printf("Number of link in Adjacent LSA: %d\n",no_link);
-
-	/*Filling Up Header Data */
 	adj_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
 	adj_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
 	adj_lsa->header->orig_router->name=(char *)malloc(strlen(nlsr->router_name)+1);
@@ -701,9 +763,6 @@
 	memcpy(adj_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);	
 	free(time_stamp);
 
-
-	/* Filling Up Body Data */
-
 	adj_lsa->no_link=no_link;
 
 
@@ -716,14 +775,6 @@
 	memcpy(adj_lsa->body,(char *)data,strlen(data)+1);
 	ccn_charbuf_destroy(&c);
 
-
-
-	if( !nlsr->is_send_lsdb_interest_scheduled )
-	{	
-		nlsr->event_send_lsdb_interest= ccn_schedule_event(nlsr->sched, 1000, &send_lsdb_interest, NULL, 0);
-		nlsr->is_send_lsdb_interest_scheduled=1;
-	}
-
 	nlsr->adj_build_count++;
 
 
@@ -743,15 +794,11 @@
 	char *time_stamp=(char *)malloc(20);
 	memset(time_stamp,0,20);
 	get_current_timestamp_micro(time_stamp);
-	//long int lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);
-
-	//printf("time difference: %ld \n",lsa_life_time);
 
 
 		char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
 		memset(key,0,adj_lsa->header->orig_router->length+2);
 		make_adj_lsa_key(key,adj_lsa);
-		//printf("Adjacent LSA key: %s \n",key);
 
 		struct alsa *new_adj_lsa=(struct alsa*)malloc(sizeof(struct alsa ));
 
@@ -831,8 +878,6 @@
 
 				if ( adj_lsa->no_link > 0)
 				{				
-					//new_adj_lsa = e->data;
-
 					writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
 					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
 					write_log_for_adj_lsa(new_adj_lsa);
@@ -904,20 +949,20 @@
 	char *rem;
 	char *rtr_id;
 	char *length;
-	char *face;
+	//char *face;
 	char *metric;
 
 	if(no_link >0 )
 	{
 		rtr_id=strtok_r(lsa_data,sep,&rem);
 		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
+		//face=strtok_r(NULL,sep,&rem);
 		metric=strtok_r(NULL,sep,&rem);
 
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Link %d	 	\n",i+1);
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router: %s	\n",rtr_id);
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router Length: %s	\n",length);
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
+		//writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Metric: %s	\n",metric);
 
 
@@ -925,12 +970,12 @@
 		{
 			rtr_id=strtok_r(NULL,sep,&rem);
 			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
+			//face=strtok_r(NULL,sep,&rem);
 			metric=strtok_r(NULL,sep,&rem);
 			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Link %d	 	\n",i+1);
 			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router: %s	\n",rtr_id);
 			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Adjacent Router Length: %s	\n",length);
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
+			//writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Connecting Face: %s	\n",face);
 			writeLogg(__FILE__,__FUNCTION__,__LINE__,"		Metric: %s	\n",metric);
 
 		}
@@ -968,33 +1013,34 @@
 	char *rem;
 	char *rtr_id;
 	char *length;
-	char *face;
+	//char *face;
 	char *metric;
 
 	if(no_link >0 )
 	{
 		rtr_id=strtok_r(lsa_data,sep,&rem);
 		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
+		//face=strtok_r(NULL,sep,&rem);
 		metric=strtok_r(NULL,sep,&rem);
 
-		printf("		Link %d	 	\n",i+1);
-		printf("		Neighbor		 : %s	\n",rtr_id);
-		printf("		Neighbor Length		 : %s	\n",length);
-		printf("		Connecting Face		 : %s	\n",face);
-		printf("		Metric			 : %s	\n",metric);
-
+		if ( nlsr->debugging ) {
+			printf("		Link %d	 	\n",i+1);
+			printf("		Neighbor		 : %s	\n",rtr_id);
+			printf("		Neighbor Length		 : %s	\n",length);
+			//printf("		Connecting Face		 : %s	\n",face);
+			printf("		Metric			 : %s	\n",metric);
+		}
 
 		for(i=1;i<no_link;i++)
 		{
 			rtr_id=strtok_r(NULL,sep,&rem);
 			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
+			//face=strtok_r(NULL,sep,&rem);
 			metric=strtok_r(NULL,sep,&rem);
 			printf("		Link %d	 	\n",i+1);
 			printf("		Neighbor		 : %s	\n",rtr_id);
 			printf("		Neighbor Length		 : %s	\n",length);
-			printf("		Connecting Face		 : %s	\n",face);
+			//printf("		Connecting Face		 : %s	\n",face);
 			printf("		Metric			 : %s	\n",metric);
 
 		}
@@ -1062,7 +1108,6 @@
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"build_and_install_others_adj_lsa called \n");
 	struct alsa *adj_lsa=(struct alsa *)malloc(sizeof( struct alsa ));
 	build_others_adj_lsa(adj_lsa,orig_router,ls_type,orig_time,no_link,data);
-	//print_adj_lsa(adj_lsa);
 	install_adj_lsa(adj_lsa);
 	
 
@@ -1081,7 +1126,6 @@
 void 
 build_others_adj_lsa(struct alsa *adj_lsa,char *orig_router,int ls_type,char *orig_time,int no_link,char *data)
 {
-	//printf("build_others_adj_lsa called \n");
 	if ( nlsr->debugging )
 		printf("build_others_adj_lsa called  \n");	
 	if ( nlsr->detailed_logging )
@@ -1144,130 +1188,6 @@
 	return num_element; 
 }
 
-void 
-get_name_lsdb_summary(struct ccn_charbuf *name_lsdb_data)
-{
-	//printf("get_name_lsdb_summary called \n");
-	if ( nlsr->debugging )
-		printf("get_name_lsdb_summary called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_name_lsdb_summary called  \n");
-	
-	int i, name_lsdb_element;
-
-	struct nlsa *name_lsa;
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->name_lsdb, e);
-	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);
-
-	for(i=0;i<name_lsdb_element;i++)
-	{
-		name_lsa=e->data;
-
-		ccn_charbuf_append_string(name_lsdb_data,name_lsa->header->orig_router->name);
-		ccn_charbuf_append_string(name_lsdb_data,"|");
-
-		char *lst=(char *)malloc(20);
-		memset(lst,0,20);
-		sprintf(lst,"%d",name_lsa->header->ls_type);
-		ccn_charbuf_append_string(name_lsdb_data,lst);
-		free(lst);
-		ccn_charbuf_append_string(name_lsdb_data,"|");
-
-		char *lsid=(char *)malloc(20);
-		memset(lsid,0,20);
-		sprintf(lsid,"%ld",name_lsa->header->ls_id);
-		ccn_charbuf_append_string(name_lsdb_data,lsid);
-		free(lsid);
-		ccn_charbuf_append_string(name_lsdb_data,"|");
-
-		ccn_charbuf_append_string(name_lsdb_data,name_lsa->header->orig_time);
-		ccn_charbuf_append_string(name_lsdb_data,"|");
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-
-}
-
-
-void 
-get_adj_lsdb_summary(struct ccn_charbuf *adj_lsdb_data)
-{
-	if ( nlsr->debugging )
-		printf("get_adj_lsdb_summary called  \n");	
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adj_lsdb_summary called  \n");
-	int i, adj_lsdb_element;
-	struct alsa *adj_lsa;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->lsdb->adj_lsdb, e);
-	adj_lsdb_element=hashtb_n(nlsr->lsdb->adj_lsdb);
-
-	for(i=0;i<adj_lsdb_element;i++)
-	{
-		adj_lsa=e->data;
-
-		ccn_charbuf_append_string(adj_lsdb_data,adj_lsa->header->orig_router->name);
-		ccn_charbuf_append_string(adj_lsdb_data,"|");
-		
-		char *lst=(char *)malloc(20);
-		memset(lst,0,20);
-		sprintf(lst,"%d",adj_lsa->header->ls_type);
-		ccn_charbuf_append_string(adj_lsdb_data,lst);
-		free(lst);
-		ccn_charbuf_append_string(adj_lsdb_data,"|");
-
-		ccn_charbuf_append_string(adj_lsdb_data,adj_lsa->header->orig_time);
-		ccn_charbuf_append_string(adj_lsdb_data,"|");
-
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-}
-
-
-void 
-get_lsdb_summary(struct ccn_charbuf *lsdb_data)
-{
-	struct ccn_charbuf *name_lsdb_data=ccn_charbuf_create();
-	struct ccn_charbuf *adj_lsdb_data=ccn_charbuf_create();
-
-	get_name_lsdb_summary(name_lsdb_data);
-	get_adj_lsdb_summary(adj_lsdb_data);
-
-	long int num_lsa=get_name_lsdb_num_element() + get_adj_lsdb_num_element();
-	char *num_element=(char *)malloc(15);
-	memset(num_element,0,15);
-	sprintf(num_element,"%ld",num_lsa);
-
-	if( num_lsa > 0)
-	{
-		ccn_charbuf_append_string(lsdb_data,num_element);
-		ccn_charbuf_append_string(lsdb_data,"|");
-	}
-	if(name_lsdb_data->length>0)
-	{
-		char *data1=ccn_charbuf_as_string(name_lsdb_data);
-		ccn_charbuf_append_string(lsdb_data,(char *)data1);
-	}
-	if(adj_lsdb_data->length>0)
-	{
-		char *data2=ccn_charbuf_as_string(adj_lsdb_data);
-		ccn_charbuf_append_string(lsdb_data,(char *)data2);
-	}
-	ccn_charbuf_destroy(&name_lsdb_data);
-	ccn_charbuf_destroy(&adj_lsdb_data);
-	free(num_element);
-
-}
 
 int 
 check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time)
@@ -1351,10 +1271,49 @@
 	return ret;
 }
 
+int 
+check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time)
+{
+	int ret=0;
+	struct ccn_charbuf *key=ccn_charbuf_create();
+	ccn_charbuf_append_string(key,orig_router);
+	ccn_charbuf_append_string(key,"/");
+	ccn_charbuf_append_string(key,lst);
+
+	int res;
+	struct clsa *cor_lsa;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+
+	hashtb_start(nlsr->lsdb->cor_lsdb, e);
+	res = hashtb_seek(e, ccn_charbuf_as_string(key), key->length, 0);
+
+	if( res == HT_NEW_ENTRY )
+	{
+		hashtb_delete(e);
+		ret=1;
+
+	}
+	else if(res == HT_OLD_ENTRY)
+	{
+		cor_lsa=e->data;
+		if( strcmp ( orig_time , cor_lsa->header->orig_time ) > 0 )
+		{
+			ret=1;
+		}
+	}
+
+	hashtb_end(e);
+	
+	ccn_charbuf_destroy(&key);
+
+	return ret;
+}
+
 void 
 get_name_lsa_data(struct ccn_charbuf *lsa_data, struct name_prefix *lsaId)
 {
-	//printf("get_name_lsa_data called \n");
 	if ( nlsr->debugging )
 		printf("get_name_lsa_data called  \n");	
 	if ( nlsr->detailed_logging )
@@ -1372,8 +1331,7 @@
 	if( res == HT_OLD_ENTRY )
 	{
 		name_lsa=e->data;
-		//printf("NAME LSA found\n");
-
+		
 		if ( nlsr->debugging )
 			printf("NAME LSA found  \n");	
 		if ( nlsr->detailed_logging )
@@ -1452,7 +1410,6 @@
 	if( res == HT_OLD_ENTRY )
 	{
 		adj_lsa=e->data;
-		//printf("Adj LSA found\n");
 
 		if ( nlsr->debugging )
 			printf("Adj LSA found  \n");	
@@ -1466,15 +1423,15 @@
 		memset(temp_length,0,20);
 		sprintf(temp_length,"%d",adj_lsa->header->orig_router->length);
 		ccn_charbuf_append_string(lsa_data,temp_length);
-		free(temp_length);
 		ccn_charbuf_append_string(lsa_data,"|");
+		free(temp_length);
 
 		char *temp_ltype=(char *)malloc(20);
 		memset(temp_ltype,0,20);
 		sprintf(temp_ltype,"%d",adj_lsa->header->ls_type);
 		ccn_charbuf_append_string(lsa_data,temp_ltype);
-		free(temp_ltype);
 		ccn_charbuf_append_string(lsa_data,"|");
+		free(temp_ltype);
 
 		ccn_charbuf_append_string(lsa_data,adj_lsa->header->orig_time);
 		ccn_charbuf_append_string(lsa_data,"|");
@@ -1483,8 +1440,8 @@
 		memset(temp_nl,0,20);
 		sprintf(temp_nl,"%d",adj_lsa->no_link);
 		ccn_charbuf_append_string(lsa_data,temp_nl);
-		free(temp_nl);
 		ccn_charbuf_append_string(lsa_data,"|");
+		free(temp_nl);
 
 		ccn_charbuf_append_string(lsa_data,adj_lsa->body);
 
@@ -1522,7 +1479,9 @@
 
 
 	make_name_lsa_key(key, np->name,ls_type,ls_id);	
-	printf("Key:%s Length:%d\n",key,(int)strlen(key));
+	
+	if ( nlsr->debugging )
+		printf("Key:%s Length:%d\n",key,(int)strlen(key));
 
 	struct nlsa *nlsa;
 
@@ -1567,16 +1526,17 @@
 
 }
 
-int 
-delete_name_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+//int 
+//delete_name_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+int
+delete_name_lsa(char *orig_router, char *name_prefix)
 {
-	//printf("delete_name_lsa called \n");
-
+	
 	if ( nlsr->debugging )
 		printf("delete_name_lsa called  \n");	
 	if ( nlsr->detailed_logging )
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_name_lsa called  \n");
-	
+	/*
 	if(flags == CCN_SCHEDULE_CANCEL)
 	{
  	 	return -1;
@@ -1604,8 +1564,9 @@
 	if( res == HT_OLD_ENTRY )
 	{
 		nlsa=e->data;
-		delete_npt_entry_by_router_and_name_prefix(nlsa->header->orig_router->name, nlsa->name_prefix->name);
-
+	*/
+		delete_npt_entry_by_router_and_name_prefix(orig_router, name_prefix);
+	/*
 		writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
 		writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
 		write_log_for_name_lsa(nlsa);
@@ -1618,6 +1579,7 @@
 		hashtb_delete(e);
 	}
 	hashtb_end(e);
+	*/
 	
 	if ( nlsr->debugging )
 		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
@@ -1631,31 +1593,28 @@
 	if ( nlsr->detailed_logging )
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
 	
-	//print_name_lsdb();
-	
-	nlsr_unlock();
+	//nlsr_unlock();
 
 	return 0;
 }
 
-int 
-delete_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+//int 
+//delete_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+int delete_adj_lsa()
 {
-	//printf("delete_adj_lsa called \n");
-
+	
 	if ( nlsr->debugging )
 		printf("delete_adj_lsa called  \n");	
 	if ( nlsr->detailed_logging )
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_adj_lsa called  \n");
-	
+
+	/*	
 	if(flags == CCN_SCHEDULE_CANCEL)
 	{
  	 	return -1;
 	}
 	nlsr_lock();
 
-	//printf("LSA Key: %s \n",(char *)ev->evdata);
-
 	if ( nlsr->debugging )
 		printf("LSA Key: %s \n",(char *)ev->evdata);
 	if ( nlsr->detailed_logging )
@@ -1684,6 +1643,7 @@
 		hashtb_delete(e);
 	}
 	hashtb_end(e);
+	*/
 
 	if ( nlsr->debugging )
 		printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
@@ -1704,9 +1664,7 @@
 		nlsr->is_route_calculation_scheduled=1;
 	}
 
-	//print_adj_lsdb();
-
-	nlsr_unlock();
+	//nlsr_unlock();
 
 	return 0;
 }
@@ -1714,15 +1672,11 @@
 void
 refresh_name_lsdb(void)
 {
-	//printf("refresh_name_lsdb called \n");
-
 	if ( nlsr->debugging )
 		printf("refresh_name_lsdb called  \n");	
 	if ( nlsr->detailed_logging )
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_name_lsdb called  \n");
 
-	//int lsa_change_count=0;
-
 	char *time_stamp=(char *)malloc(20);
 	memset(time_stamp,0,20);
 	get_current_timestamp_micro(time_stamp);
@@ -1780,9 +1734,11 @@
 					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
 	
 					free(current_time_stamp);
+					
+					hashtb_next(e);
 				}
 				else 
-				{
+				{	/*
 					char lst[2];
 					memset(lst,0,2);
 					sprintf(lst,"%d",name_lsa->header->ls_type);	
@@ -1791,15 +1747,22 @@
 					memset(lsid,0,10);
 					sprintf(lsid,"%ld",name_lsa->header->ls_id);
 	
-	
+					
 					char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
 					memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
 
 
 					make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);	
-					//printf("Key:%s Length:%d\n",key,(int)strlen(key));
 				
 					nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
+					*/
+					delete_name_lsa(name_lsa->header->orig_router->name, name_lsa->name_prefix->name);
+					writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
+					writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
+					write_log_for_name_lsa(name_lsa);
+					writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
+					hashtb_delete(e);
+					i++;
 				}
 
 				if ( nlsr->debugging )
@@ -1817,7 +1780,10 @@
 							
 
 				print_name_lsdb();
-				//lsa_change_count++;
+			}
+			else 
+			{
+				hashtb_next(e);
 			}	
 		}
 		else 
@@ -1829,7 +1795,7 @@
 				if ( nlsr->detailed_logging )
 					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Name LSA need to be deleted\n");
 
-				char lst[2];
+				/*char lst[2];
 				memset(lst,0,2);
 				sprintf(lst,"%d",name_lsa->header->ls_type);	
 
@@ -1843,14 +1809,26 @@
 
 
 				make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);	
-				//printf("Key:%s Length:%d\n",key,(int)strlen(key));
 				
 				nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_name_lsa, (void *)key, 0);
-				//lsa_change_count++;
+				*/
+				delete_name_lsa(name_lsa->header->orig_router->name, name_lsa->name_prefix->name);
+				writeLogg(__FILE__,__FUNCTION__,__LINE__," Name-LSA\n");
+				writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting name lsa\n");
+				write_log_for_name_lsa(name_lsa);
+				writeLogg(__FILE__,__FUNCTION__,__LINE__," name_lsa_end\n");
+				hashtb_delete(e);
+				i++;
+			}
+			else 
+			{
+				hashtb_next(e);
 			}
 		}
-
-		hashtb_next(e);		
+		/*else
+		{
+			hashtb_next(e);	
+		}*/	
 	}
 
 	hashtb_end(e);
@@ -1863,7 +1841,6 @@
 void
 refresh_adj_lsdb(void)
 {
-	//printf("refresh_adj_lsdb called \n");
 
 	if ( nlsr->debugging )
 		printf("refresh_adj_lsdb called  \n");	
@@ -1889,8 +1866,7 @@
 	{
 		adj_lsa=e->data;
 
-		lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);
-		//printf("LSA Life Time: %ld \n",lsa_life_time);	
+		lsa_life_time=get_time_diff(time_stamp,adj_lsa->header->orig_time);	
 
 		if ( nlsr->debugging )
 			printf("LSA Life Time: %ld \n",lsa_life_time);	
@@ -1901,7 +1877,6 @@
 		{
 			if ( lsa_life_time > nlsr->lsa_refresh_time )
 			{
-				//printf("Own Adj LSA need to be refrshed\n");
 				if ( nlsr->debugging )
 					printf("Own Adj LSA need to be refrshed\n");
 				if ( nlsr->detailed_logging )
@@ -1941,30 +1916,158 @@
 					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
 
 				print_adj_lsdb();
+				
+				
 			}	
+			
+			hashtb_next(e);
 		}
 		else 
 		{
 			if ( lsa_life_time > nlsr->router_dead_interval )
 			{
-				//printf("Others Adj LSA need to be deleted\n");
+
+				if ( nlsr->debugging )
+				 	printf("Others Adj LSA need to be deleted\n");
+				if ( nlsr->detailed_logging )
+					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Adj LSA need to be deleted\n");
+				/*
+				char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
+				memset(key,0,adj_lsa->header->orig_router->length+2);
+				make_adj_lsa_key(key,adj_lsa);
+				
+				nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_adj_lsa, (void *)key, 0);
+				*/
+				
+				writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
+				writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
+				write_log_for_adj_lsa(adj_lsa);
+				writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
+				delete_adj_lsa();
+				hashtb_delete(e);
+				i++;
+				
+			}
+			else
+			{
+				hashtb_next(e);
+			}
+		}
+
+		
+
+		//hashtb_next(e);		
+	}
+
+	hashtb_end(e);
+	
+	free(time_stamp);
+}
+
+
+void
+refresh_cor_lsdb(void)
+{
+
+	if ( nlsr->debugging )
+		printf("refresh_cor_lsdb called  \n");	
+	if ( nlsr->detailed_logging )
+		writeLogg(__FILE__,__FUNCTION__,__LINE__,"refresh_cor_lsdb called  \n");
+
+	char *time_stamp=(char *)malloc(20);
+	memset(time_stamp,0,20);
+	get_current_timestamp_micro(time_stamp);
+	
+	long int lsa_life_time;
+		
+	int i, cor_lsdb_element;
+	struct clsa *cor_lsa;
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+    	
+    	hashtb_start(nlsr->lsdb->cor_lsdb, e);
+	cor_lsdb_element=hashtb_n(nlsr->lsdb->cor_lsdb);
+
+	for(i=0;i<cor_lsdb_element;i++)
+	{
+		cor_lsa=e->data;
+
+		lsa_life_time=get_time_diff(time_stamp,cor_lsa->header->orig_time);	
+
+		if ( nlsr->debugging )
+			printf("LSA Life Time: %ld \n",lsa_life_time);	
+		if ( nlsr->detailed_logging )
+			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Life Time: %ld \n",lsa_life_time);		
+
+		if ( strcmp(cor_lsa->header->orig_router->name,nlsr->router_name) == 0)
+		{
+			if ( lsa_life_time > nlsr->lsa_refresh_time )
+			{
+				if ( nlsr->debugging )
+					printf("Own Cor LSA need to be refrshed\n");
+				if ( nlsr->detailed_logging )
+					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Own Cor LSA need to be refrshed\n");
+
+				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
+				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Deleting adj lsa\n");
+				//write_log_for_adj_lsa(adj_lsa);
+				//writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
+
+				char *current_time_stamp=(char *)malloc(20);
+				memset(current_time_stamp,0,20);
+				get_current_timestamp_micro(current_time_stamp);
+
+				free(cor_lsa->header->orig_time);
+				cor_lsa->header->orig_time=(char *)malloc(strlen(current_time_stamp)+1); //free 
+				memset(cor_lsa->header->orig_time,0,strlen(current_time_stamp)+1);
+				memcpy(cor_lsa->header->orig_time,current_time_stamp,strlen(current_time_stamp)+1);
+	
+				free(current_time_stamp);
+
+				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Adj-LSA\n");
+				//writeLogg(__FILE__,__FUNCTION__,__LINE__," Adding adj lsa\n");
+				//write_log_for_adj_lsa(adj_lsa);
+				//writeLogg(__FILE__,__FUNCTION__,__LINE__," adj_lsa_end\n");
+
+				if ( nlsr->debugging )
+					printf("Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+				if ( nlsr->detailed_logging )
+					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+
+				set_new_lsdb_version();	
+
+				if ( nlsr->debugging )
+					printf("New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+				if ( nlsr->detailed_logging )
+					writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Version Number of LSDB: %s \n",nlsr->lsdb->lsdb_version);
+
+				print_adj_lsdb();
+			}
+
+			hashtb_next(e);		
+		}
+		else 
+		{
+			if ( lsa_life_time > nlsr->router_dead_interval )
+			{
 
 				if ( nlsr->debugging )
 				 	printf("Others Adj LSA need to be deleted\n");
 				if ( nlsr->detailed_logging )
 					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Others Adj LSA need to be deleted\n");
 				
-				char *key=(char *)malloc(adj_lsa->header->orig_router->length+2+2);
-				memset(key,0,adj_lsa->header->orig_router->length+2);
-				make_adj_lsa_key(key,adj_lsa);
-				//printf("Adjacent LSA key: %s \n",key);				
-				nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_adj_lsa, (void *)key, 0);
+				hashtb_delete(e);
+				i++;
+			}
+			else 
+			{
+				hashtb_next(e);	
 			}
 		}
 
 		
-
-		hashtb_next(e);		
+	
 	}
 
 	hashtb_end(e);
@@ -1982,8 +2085,6 @@
 
 	nlsr_lock();
 
-	//printf("refresh_lsdb called \n");
-
 	if ( nlsr->debugging )
 		printf("refresh_lsdb called\n");
 	if ( nlsr->detailed_logging )
@@ -1991,9 +2092,489 @@
 	
 	refresh_name_lsdb();
 	refresh_adj_lsdb();
+	refresh_cor_lsdb();
 
 	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
 	
 	nlsr_unlock();
 	return 0;
 }
+
+void
+write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id)
+{
+	if ( nlsr->debugging )
+		printf("write_adj_lsa_to_repo called\n");
+	if ( nlsr->debugging )
+		printf("Content Prefix: %s\n",repo_content_prefix);
+	
+	struct ccn_charbuf *lsa_data=ccn_charbuf_create();		
+	get_adj_lsa_data(lsa_data,lsa_id);
+	if ( nlsr->debugging )
+		printf("Adj LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	
+
+	write_data_to_repo(ccn_charbuf_as_string(lsa_data), repo_content_prefix);
+
+	ccn_charbuf_destroy(&lsa_data);
+}
+
+void
+write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id)
+{
+	if ( nlsr->debugging )
+		printf("write_name_lsa_to_repo called\n");
+	if ( nlsr->debugging )
+		printf("Content Prefix: %s\n",repo_content_prefix);
+	
+	struct ccn_charbuf *lsa_data=ccn_charbuf_create();		
+	get_name_lsa_data(lsa_data,lsa_id);
+	
+	if ( nlsr->debugging )
+		printf("Name LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	
+
+	write_data_to_repo(ccn_charbuf_as_string(lsa_data), repo_content_prefix);
+
+	ccn_charbuf_destroy(&lsa_data);
+}
+
+
+void
+write_name_lsdb_to_repo(char *slice_prefix)
+{
+	int i, name_lsdb_element;
+
+	struct nlsa *name_lsa;
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+    	
+    	hashtb_start(nlsr->lsdb->name_lsdb, e);
+	name_lsdb_element=hashtb_n(nlsr->lsdb->name_lsdb);
+
+	for(i=0;i<name_lsdb_element;i++)
+	{
+		name_lsa=e->data;
+
+		char lst[2];
+		memset(lst,0,2);
+		sprintf(lst,"%d",name_lsa->header->ls_type);	
+
+		char lsid[10];
+		memset(lsid,0,10);
+		sprintf(lsid,"%ld",name_lsa->header->ls_id);
+	
+	
+		char *key=(char *)malloc(strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
+		memset(key,0,strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1);
+
+
+		make_name_lsa_key(key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id);
+		
+		if ( nlsr->debugging )
+			printf("Name LSA Key: %s \n",key);
+
+
+		char *repo_key=(char *)malloc(strlen(slice_prefix)+1+strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1+strlen(name_lsa->header->orig_time)+1+15);
+		memset(repo_key,0,strlen(slice_prefix)+1+strlen(name_lsa->header->orig_router->name)+1+strlen(lst)+1+strlen(lsid)+1+strlen(name_lsa->header->orig_time)+1+15);	
+		make_name_lsa_prefix_for_repo(repo_key, name_lsa->header->orig_router->name,name_lsa->header->ls_type,name_lsa->header->ls_id,name_lsa->header->orig_time,slice_prefix);
+		
+		if ( nlsr->debugging )
+			printf("Name LSA Repo Key: %s \n",repo_key);
+
+		struct name_prefix *lsaid=(struct name_prefix *)malloc(sizeof(struct name_prefix));
+		lsaid->name=(char *)malloc(strlen(key)+1);
+		memset(lsaid->name, 0, strlen(key)+1);
+		memcpy(lsaid->name,key,strlen(key));
+		lsaid->length=strlen(key)+1;
+
+		
+		write_name_lsa_to_repo(repo_key, lsaid);
+
+		free(key);
+		free(repo_key);
+		free(lsaid->name);
+		free(lsaid);
+
+		hashtb_next(e);		
+	}
+
+	hashtb_end(e);
+	
+
+}
+
+void
+print_cor_lsa(struct clsa *cor_lsa)
+{
+	if ( nlsr->debugging )
+	{
+		printf("-----------Cor LSA Content---------------\n");
+		printf("	Origination Router       :	%s\n",cor_lsa->header->orig_router->name);
+		printf("	Origination Router Length:	%d\n",cor_lsa->header->orig_router->length);
+		printf("	LS Type			 :	%d\n",cor_lsa->header->ls_type);
+		printf("	Origination Time	 :	%s\n",cor_lsa->header->orig_time);
+		printf("	LSA Data			\n");
+		printf("		Cor R:	 	:	%f\n",cor_lsa->cor_r);
+		printf("		Cor Theta	:	%f\n",cor_lsa->cor_theta);
+
+		printf("\n");	
+	}
+}
+
+void 
+print_cor_lsdb()
+{
+	
+	if ( nlsr->debugging )
+		printf("print_cor_lsdb called \n");	
+	
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee;
+    	
+	int i=1;
+
+	for (hashtb_start(nlsr->lsdb->cor_lsdb, e); e->key != NULL; hashtb_next(e)) 
+	{
+		if ( nlsr->debugging )
+			printf("-----------Cor LSA (%d)---------------\n",i);	
+		struct clsa *cor_lsa=e->data;
+		print_cor_lsa(cor_lsa);
+		i++;
+  	}
+	hashtb_end(e);
+
+	if ( nlsr->debugging )
+		printf("\n");
+	if ( nlsr->detailed_logging )
+		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
+}
+
+void
+install_cor_lsa(struct clsa *cor_lsa)
+{
+	if ( nlsr->debugging )
+		printf("install_cor_lsa called \n");
+	if ( nlsr->detailed_logging )
+		writeLogg(__FILE__,__FUNCTION__,__LINE__,"install_cor_lsa called  \n");
+	
+
+	char *time_stamp=(char *)malloc(20);
+	memset(time_stamp,0,20);
+	get_current_timestamp_micro(time_stamp);
+
+
+	char *key=(char *)malloc(cor_lsa->header->orig_router->length+2+2);
+	memset(key,0,cor_lsa->header->orig_router->length+2);
+	make_cor_lsa_key(key,cor_lsa);
+
+	if ( nlsr->debugging )
+		printf("Cor LSA key: %s \n",key);
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee; 	
+    	int res;
+
+   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
+    	res = hashtb_seek(e, key, strlen(key), 0);
+
+	if ( res == HT_NEW_ENTRY )
+	{
+		if ( nlsr->debugging )
+			printf("New Cor LSA... \n");
+		
+		struct clsa *new_cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
+		new_cor_lsa=e->data;
+		new_cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
+
+		new_cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
+		new_cor_lsa->header->orig_router->name=(char *)malloc(strlen(cor_lsa->header->orig_router->name)+1);
+		memset(new_cor_lsa->header->orig_router->name,0,strlen(cor_lsa->header->orig_router->name)+1);
+		memcpy(new_cor_lsa->header->orig_router->name,cor_lsa->header->orig_router->name,strlen(cor_lsa->header->orig_router->name)+1);
+		new_cor_lsa->header->orig_router->length=cor_lsa->header->orig_router->length;
+
+		new_cor_lsa->header->orig_time=(char *)malloc(strlen(cor_lsa->header->orig_time)+1); //free 
+		memset(new_cor_lsa->header->orig_time,0,strlen(cor_lsa->header->orig_time)+1);
+		memcpy(new_cor_lsa->header->orig_time,cor_lsa->header->orig_time,strlen(cor_lsa->header->orig_time)+1);
+
+		new_cor_lsa->header->ls_type=cor_lsa->header->ls_type;
+
+		new_cor_lsa->cor_r=cor_lsa->cor_r;
+		new_cor_lsa->cor_theta=cor_lsa->cor_theta;
+	}
+	else if ( res == HT_OLD_ENTRY )
+	{	
+		if ( nlsr->debugging )
+			printf("Cor LSA exists (Old)... \n");
+	}
+	hashtb_end(e);
+
+	free(key);
+
+}
+
+void 
+build_cor_lsa(struct clsa *cor_lsa, double cor_r, double cor_theta)
+{
+	cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
+	cor_lsa->header->ls_type=LS_TYPE_COR;
+
+	char *time_stamp=(char *)malloc(20);
+	memset(time_stamp,0,20);
+	get_current_timestamp_micro(time_stamp);
+
+	cor_lsa->header->orig_time=(char *)malloc(strlen(time_stamp)+1); //free 
+	memset(cor_lsa->header->orig_time,0,strlen(time_stamp)+1);
+	memcpy(cor_lsa->header->orig_time,time_stamp,strlen(time_stamp)+1);
+	free(time_stamp);
+
+	cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
+	cor_lsa->header->orig_router->name=(char *)malloc(strlen(nlsr->router_name)+1);
+	memset(cor_lsa->header->orig_router->name,0,strlen(nlsr->router_name)+1);
+	memcpy(cor_lsa->header->orig_router->name,nlsr->router_name,strlen(nlsr->router_name)+1);
+	cor_lsa->header->orig_router->length=strlen(nlsr->router_name)+1;
+
+	cor_lsa->cor_r=cor_r;	
+	cor_lsa->cor_theta=cor_theta;
+
+}
+
+void 
+build_others_cor_lsa(struct clsa *cor_lsa,char *orig_router, int ls_type,char *orig_time, double cor_r, double cor_theta)
+{
+	cor_lsa->header=(struct alsa_header *)malloc(sizeof(struct alsa_header ));
+	cor_lsa->header->ls_type=ls_type;
+
+	cor_lsa->header->orig_time=(char *)malloc(strlen(orig_time)+1); 
+	memset(cor_lsa->header->orig_time,0,strlen(orig_time)+1);
+	memcpy(cor_lsa->header->orig_time,orig_time,strlen(orig_time)+1);
+
+	cor_lsa->header->orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
+	cor_lsa->header->orig_router->name=(char *)malloc(strlen(orig_router)+1);
+	memset(cor_lsa->header->orig_router->name,0,strlen(orig_router)+1);
+	memcpy(cor_lsa->header->orig_router->name,orig_router,strlen(orig_router)+1);
+	cor_lsa->header->orig_router->length=strlen(orig_router)+1;
+
+	cor_lsa->cor_r=cor_r;	
+	cor_lsa->cor_theta=cor_theta;
+
+}
+
+void
+build_and_install_others_cor_lsa(char *orig_router,int ls_type,char *orig_time, double cor_r, double cor_theta)
+{
+	struct clsa *cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
+	build_others_cor_lsa(cor_lsa,orig_router,ls_type, orig_time, cor_r, cor_theta);
+	install_cor_lsa(cor_lsa);
+
+	print_cor_lsdb();
+
+	free(cor_lsa->header->orig_router);
+	free(cor_lsa->header->orig_time);
+	free(cor_lsa->header);
+	free(cor_lsa);
+
+}
+
+
+void 
+build_and_install_cor_lsa()
+{
+
+	
+
+	struct clsa *cor_lsa=(struct clsa *)malloc(sizeof( struct clsa ));
+	
+	build_cor_lsa(cor_lsa,nlsr->cor_r,nlsr->cor_theta);
+	install_cor_lsa(cor_lsa);
+
+	write_cor_lsa_to_repo(cor_lsa);
+
+	print_cor_lsdb();	
+
+	free(cor_lsa->header->orig_router);
+	free(cor_lsa->header->orig_time);
+	free(cor_lsa->header);
+	free(cor_lsa);
+	
+}
+
+void 
+get_cor_lsa_data(struct ccn_charbuf *lsa_data,char *cor_lsa_key)
+{
+	if ( nlsr->debugging )
+		printf("get_cor_lsa_data called  \n");	
+	if ( nlsr->detailed_logging )
+		writeLogg(__FILE__,__FUNCTION__,__LINE__,"get_adj_lsa_data called  \n");
+
+	struct clsa *cor_lsa=(struct clsa*)malloc(sizeof(struct clsa ));
+
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee; 	
+    	int res;
+
+   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
+    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);
+
+	if( res == HT_OLD_ENTRY )
+	{
+		cor_lsa=e->data;
+
+		if ( nlsr->debugging )
+			printf("Cor LSA found  \n");	
+		if ( nlsr->detailed_logging )
+			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Cor LSA found  \n");
+
+		ccn_charbuf_append_string(lsa_data,cor_lsa->header->orig_router->name);
+		ccn_charbuf_append_string(lsa_data,"|");
+
+		char *temp_length=(char *)malloc(20);
+		memset(temp_length,0,20);
+		sprintf(temp_length,"%d",cor_lsa->header->orig_router->length);
+		ccn_charbuf_append_string(lsa_data,temp_length);
+		ccn_charbuf_append_string(lsa_data,"|");
+		free(temp_length);
+
+		char *temp_ltype=(char *)malloc(20);
+		memset(temp_ltype,0,20);
+		sprintf(temp_ltype,"%d",cor_lsa->header->ls_type);
+		ccn_charbuf_append_string(lsa_data,temp_ltype);
+		ccn_charbuf_append_string(lsa_data,"|");
+		free(temp_ltype);
+
+		ccn_charbuf_append_string(lsa_data,cor_lsa->header->orig_time);
+		ccn_charbuf_append_string(lsa_data,"|");
+
+		char *cor_r=(char *)malloc(20);
+		memset(cor_r,0,20);
+		sprintf(cor_r,"%f",cor_lsa->cor_r);
+		ccn_charbuf_append_string(lsa_data,cor_r);
+		ccn_charbuf_append_string(lsa_data,"|");
+		free(cor_r);
+
+		char *cor_theta=(char *)malloc(20);
+		memset(cor_theta,0,20);
+		sprintf(cor_theta,"%f",cor_lsa->cor_theta);
+		ccn_charbuf_append_string(lsa_data,cor_theta);
+		ccn_charbuf_append_string(lsa_data,"|");
+		free(cor_theta);
+
+	}
+	else if(res == HT_NEW_ENTRY)
+	{
+		hashtb_delete(e);
+	}
+
+	hashtb_end(e);
+}
+
+void
+write_cor_lsa_to_repo(struct clsa *cor_lsa)
+{
+	
+
+	if ( nlsr->debugging )
+		printf("write_cor_lsa_to_repo called\n");
+	
+	
+	char *key=(char *)malloc(cor_lsa->header->orig_router->length+2+2);
+	memset(key,0,cor_lsa->header->orig_router->length+2+2);
+	make_cor_lsa_key(key,cor_lsa);
+	
+	struct ccn_charbuf *lsa_data=ccn_charbuf_create();
+	get_cor_lsa_data(lsa_data,key);
+	
+	if ( nlsr->debugging )
+		printf("Cor LSA Data: %s \n",ccn_charbuf_as_string(lsa_data));	
+	char *lst=(char *)malloc(20);
+	memset(lst,0,20);
+	sprintf(lst,"%d",cor_lsa->header->ls_type);
+	char *repo_key=(char *)malloc(strlen(nlsr->slice_prefix)+strlen(cor_lsa->header->orig_time)+strlen(cor_lsa->header->orig_router->name) + strlen(lst) + 5+15);
+	memset(repo_key, 0, strlen(nlsr->slice_prefix)+strlen(cor_lsa->header->orig_time)+strlen(cor_lsa->header->orig_router->name) + strlen(lst) + 5+15);	
+	make_cor_lsa_prefix_for_repo(repo_key, cor_lsa->header->orig_router->name,LS_TYPE_COR,cor_lsa->header->orig_time,nlsr->slice_prefix);
+		
+	if ( nlsr->debugging )
+		printf("Cor LSA Repo Key: %s \n",repo_key);	
+
+	write_data_to_repo(ccn_charbuf_as_string(lsa_data), repo_key);
+
+	
+		
+	free(lst);
+	free(key);
+	free(repo_key);
+	ccn_charbuf_destroy(&lsa_data);
+}
+
+void 
+make_cor_lsa_key_by_router_name(char *key,char *router_name)
+{
+	memcpy(key+strlen(key),router_name,strlen(router_name));
+	memcpy(key+strlen(key),"/",1);
+	char ls_type[2];
+	sprintf(ls_type,"%d",LS_TYPE_COR);
+	memcpy(key+strlen(key),ls_type,strlen(ls_type));
+	key[strlen(key)]='\0';
+}
+
+
+double 
+get_hyperbolic_r(char *router)
+{
+	double ret=-1.0;
+	char *cor_lsa_key=(char *)calloc(strlen(router)+4,sizeof(char));
+	make_cor_lsa_key_by_router_name(cor_lsa_key,router);
+
+	
+	struct clsa *cor_lsa;
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee; 	
+    	int res;
+
+   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
+    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);
+
+	if ( res == HT_OLD_ENTRY)
+	{	
+		cor_lsa=e->data;
+		ret=cor_lsa->cor_r;
+	}
+	else if(res == HT_NEW_ENTRY)
+	{
+		hashtb_delete(e);
+	}
+
+	hashtb_end(e);
+	
+	free(cor_lsa_key);
+	return ret;
+}
+
+double 
+get_hyperbolic_theta(char *router)
+{
+		double ret=-1.0;
+	char *cor_lsa_key=(char *)calloc(strlen(router)+4,sizeof(char));
+	make_cor_lsa_key_by_router_name(cor_lsa_key,router);
+
+	struct clsa *cor_lsa;
+	struct hashtb_enumerator ee;
+    	struct hashtb_enumerator *e = &ee; 	
+    	int res;
+
+   	hashtb_start(nlsr->lsdb->cor_lsdb, e);
+    	res = hashtb_seek(e, cor_lsa_key, strlen(cor_lsa_key), 0);
+
+	if ( res == HT_OLD_ENTRY)
+	{	
+		cor_lsa=e->data;
+		ret=cor_lsa->cor_theta;
+	}
+	else if(res == HT_NEW_ENTRY)
+	{
+		hashtb_delete(e);
+	}
+
+	hashtb_end(e);
+	
+	free(cor_lsa_key);
+	return ret;
+}
diff --git a/nlsr_lsdb.h b/nlsr_lsdb.h
index 0383954..c67348e 100644
--- a/nlsr_lsdb.h
+++ b/nlsr_lsdb.h
@@ -3,6 +3,7 @@
 
 #define LS_TYPE_ADJ 1
 #define LS_TYPE_NAME 2
+#define LS_TYPE_COR 3
 
 struct link
 {
@@ -44,6 +45,13 @@
 	struct name_prefix *name_prefix;
 };
 
+struct clsa
+{
+	struct alsa_header *header;
+	double cor_r;
+	double cor_theta;
+};
+
 
 void set_new_lsdb_version(void);
 void build_and_install_name_lsas(void);
@@ -72,16 +80,26 @@
 long int get_name_lsdb_num_element(void);
 long int get_adj_lsdb_num_element(void);
 
-void get_name_lsdb_summary(struct ccn_charbuf *name_lsdb_data);
-void get_adj_lsdb_summary(struct ccn_charbuf *adj_lsdb_data);
-void get_lsdb_summary(struct ccn_charbuf *lsdb_data);
-
 int check_is_new_name_lsa(char *orig_router,char *lst,char *lsid,char *orig_time);
 int check_is_new_adj_lsa(char *orig_router,char *lst,char *orig_time);
+int check_is_new_cor_lsa(char *orig_router,char *lst,char *orig_time);
 
 void get_name_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
 void get_adj_lsa_data(struct ccn_charbuf *lsa_data,struct name_prefix *lsaId);
 
 void make_name_lsa_invalid(struct name_prefix *np,int ls_type, long int ls_id);
 
+void build_and_install_cor_lsa();
+void print_cor_lsdb();
+
+void write_name_lsdb_to_repo(char *slice_prefix);
+void write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id);
+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);
+void write_adj_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id);
+
+void write_cor_lsa_to_repo(struct clsa *cor_lsa);
+void build_and_install_others_cor_lsa(char *orig_router,int ls_type,char *orig_time, double cor_r, double cor_theta);
+double get_hyperbolic_r(char *router);
+double get_hyperbolic_theta(char *router);
+
 #endif
diff --git a/nlsr_ndn.c b/nlsr_ndn.c
index 9af0a05..258c954 100644
--- a/nlsr_ndn.c
+++ b/nlsr_ndn.c
@@ -275,20 +275,12 @@
 
 	res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size);
 
-	//printf("Det= %s \n",comp_ptr1);
 
 	if(!strcmp((char *)comp_ptr1,"info"))
 	{
 		process_incoming_interest_info(selfp,info);
 	}
-	if(!strcmp((char *)comp_ptr1,"lsdb"))
-	{
-		process_incoming_interest_lsdb(selfp,info);
-	}
-	if(!strcmp((char *)comp_ptr1,"lsa"))
-	{
-		process_incoming_interest_lsa(selfp,info);
-	}
+
 }
 
 void 
@@ -321,9 +313,9 @@
 		ccn_charbuf_append_closer(sp.template_ccnb);
 
 
-		char *raw_data=(char *)malloc(16);
-		memset(raw_data,0,16);
-		sprintf(raw_data,"%ld", nlsr->lsdb_synch_interval);	
+		char *raw_data=(char *)malloc(20);
+		memset(raw_data,0,20);
+		sprintf(raw_data,"%s", nlsr->lsdb->lsdb_version);	
 
 		res= ccn_sign_content(nlsr->ccn, data, name, &sp, raw_data,strlen(raw_data)); 
 		if(res >= 0)
@@ -373,264 +365,6 @@
 }
 
 
-void 
-process_incoming_interest_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info *info)
-{
-	//printf("process_incoming_interest_lsdb called \n");
-
-	if ( nlsr->debugging )
-		printf("process_incoming_interest_lsdb called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest_lsdb called \n");
-	
-
-	int l,res;
-	const unsigned char *exclbase;
-	size_t size;
-	struct ccn_buf_decoder decoder;
-	struct ccn_buf_decoder *d;
-	const unsigned char *comp;
-	int dbcmp=0;
-
-	l = info->pi->offset[CCN_PI_E_Exclude] - info->pi->offset[CCN_PI_B_Exclude];
-	if (l > 0) 
-	{
-		comp = NULL;
-		size = 0;
-		exclbase = info->interest_ccnb + info->pi->offset[CCN_PI_B_Exclude];
-		d = ccn_buf_decoder_start(&decoder, exclbase, l);
-		if (ccn_buf_match_dtag(d, CCN_DTAG_Exclude)) 
-		{
-			ccn_buf_advance(d);
-			if (ccn_buf_match_dtag(d, CCN_DTAG_Any))
-				ccn_buf_advance_past_element(d);
-			if (ccn_buf_match_dtag(d, CCN_DTAG_Component)) 
-			{
-				ccn_buf_advance(d);
-				ccn_buf_match_blob(d, &comp, &size);
-				ccn_buf_check_close(d);			
-
-
-			}
-			ccn_buf_check_close(d);
-		}
-		if (comp != NULL)
-		{
-			if ( nlsr->debugging )
-			{
-				printf("LSDB Version in Exclusion Filter is %s\n",comp);
-				printf("LSDB Version of own NLSR is: %s \n",nlsr->lsdb->lsdb_version);
-			}
-			if ( nlsr->detailed_logging )
-			{
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSDB Version in Exclusion Filter is %s\n",comp);
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSDB Version of own NLSR is: %s \n",nlsr->lsdb->lsdb_version);
-			}
-			dbcmp=strcmp(nlsr->lsdb->lsdb_version,(char *)comp);
-		}
-		/* Now comp points to the start of your potential number, and size is its length */
-	}
-	else
-	{
-		if ( nlsr->debugging )
-			printf("LSDB Version in Exclusion Filter is: None Added\n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSDB Version in Exclusion Filter is: None Added\n");
-		dbcmp=1;		
-
-	}
-
-	struct ccn_charbuf *data=ccn_charbuf_create();
-	struct ccn_charbuf *name=ccn_charbuf_create();
-	struct ccn_signing_params sp=CCN_SIGNING_PARAMS_INIT;
-	
-	ccn_charbuf_append(name, info->interest_ccnb + info->pi->offset[CCN_PI_B_Name],info->pi->offset[CCN_PI_E_Name] - info->pi->offset[CCN_PI_B_Name]);
-
-	sp.template_ccnb=ccn_charbuf_create();
-	ccn_charbuf_append_tt(sp.template_ccnb,CCN_DTAG_SignedInfo, CCN_DTAG);
-	ccnb_tagged_putf(sp.template_ccnb, CCN_DTAG_FreshnessSeconds, "%ld", 10);
-        sp.sp_flags |= CCN_SP_TEMPL_FRESHNESS;
-        ccn_charbuf_append_closer(sp.template_ccnb);
-
-
-	if(dbcmp>0)
-	{
-		if ( nlsr->debugging )
-		{
-			printf("Has Updated Database than Neighbor\n");
-			printf("Sending LSDB Summary of Updated LSDB Content...\n");			
-		}
-		if ( nlsr->detailed_logging )
-		{
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Has Updated Database than Neighbor\n");
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending LSDB Summary of Updated LSDB Content...\n");	
-		}
-		ccn_name_append_str(name,nlsr->lsdb->lsdb_version);
-
-		struct ccn_charbuf *lsdb_data=ccn_charbuf_create();
-		get_lsdb_summary(lsdb_data);
-
-		char *raw_data=ccn_charbuf_as_string(lsdb_data);
-
-		//printf("Content Data to be sent: %s \n",raw_data);		
-
-		if( nlsr->is_build_adj_lsa_sheduled == 1 || strlen((char *)raw_data) == 0 )
-		{
-			 res= ccn_sign_content(nlsr->ccn, data, name, &sp, "WAIT" , strlen("WAIT"));
-		}
-		else
-		{
-			res= ccn_sign_content(nlsr->ccn, data, name, &sp, raw_data , strlen(raw_data));
-		}
-
-		if(res >= 0)
-		{
-			if ( nlsr->debugging )
-				printf("Signing LSDB Summary of Updated LSDB Content is successful  \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing LSDB Summary of Updated LSDB Content is successful  \n");
-		}		
-
-	    	res=ccn_put(nlsr->ccn,data->buf,data->length);
-
-		if(res >= 0)
-		{
-			if ( nlsr->debugging )
-				printf("Sending LSDB Summary of Updated LSDB Content is successful  \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending LSDB Summary of Updated LSDB Content is successful  \n");
-		}
-		
-		ccn_charbuf_destroy(&lsdb_data);
-	}
-	else
-	{
-		if ( nlsr->debugging )
-		{
-			printf("Does not have Updated Database than Neighbor\n");		
-			printf("Sending NACK Content.....\n");	
-		}
-		if ( nlsr->detailed_logging )
-		{
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Does not have Updated Database than Neighbor\n");		
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending NACK Content.....\n");
-		}
-
-		res= ccn_sign_content(nlsr->ccn, data, name, &sp, "NACK", strlen("NACK")); 
-
-		if(res >= 0)
-		{
-			if ( nlsr->debugging )
-				printf("Signing NACK Content is successful  \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing NACK Content is successful  \n");
-		}
-
-	    	res=ccn_put(nlsr->ccn,data->buf,data->length);
-
-		if(res >= 0)
-		{
-			if ( nlsr->debugging )
-				printf("Sending NACK Content is successful  \n");
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending NACK Content is successful  \n");
-		}
-
-		
-	}
-
-	ccn_charbuf_destroy(&data);
-	ccn_charbuf_destroy(&name);
-	ccn_charbuf_destroy(&sp.template_ccnb);
-
-
-}
-
-
-void 
-process_incoming_interest_lsa(struct ccn_closure *selfp, struct ccn_upcall_info *info)
-{
-	if ( nlsr->debugging )
-		printf("process_incoming_interest_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_interest_lsa called \n");
-
-	int res;
-
-	struct name_prefix *lsaId=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	get_lsa_identifier(lsaId,selfp,info,0);
-
-	//printf("LSA Identifier: %s Length: %d\n",lsaId->name,lsaId->length);
-	int ls_type=get_ls_type(selfp, info);
-
-	struct ccn_charbuf *lsa_data=ccn_charbuf_create();
-
-	if ( ls_type == LS_TYPE_NAME )
-	{
-		if ( nlsr->debugging )
-			printf("Interest Received for NAME LSA \n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Received for NAME LSA \n");
-		get_name_lsa_data(lsa_data,lsaId);
-	}
-	else if ( ls_type == LS_TYPE_ADJ )
-	{
-		if ( nlsr->debugging )
-			printf("Interest Received for ADJ LSA \n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Received for ADJ LSA \n");
-		get_adj_lsa_data(lsa_data,lsaId);
-	}
-
-	char *rdata=ccn_charbuf_as_string(lsa_data);
-	char *raw_data=(char *)malloc(strlen(rdata)+1);
-	memset(raw_data,0,strlen(rdata)+1);
-	memcpy(raw_data,(char *)rdata,strlen(rdata)+1);
-	//printf("Content Data to be sent: %s\n",raw_data);
-
-	struct ccn_charbuf *data=ccn_charbuf_create();
-	struct ccn_charbuf *name=ccn_charbuf_create();
-	struct ccn_signing_params sp=CCN_SIGNING_PARAMS_INIT;
-
-	ccn_charbuf_append(name, info->interest_ccnb + info->pi->offset[CCN_PI_B_Name],info->pi->offset[CCN_PI_E_Name] - info->pi->offset[CCN_PI_B_Name]); 
-
-	sp.template_ccnb=ccn_charbuf_create();
-	ccn_charbuf_append_tt(sp.template_ccnb,CCN_DTAG_SignedInfo, CCN_DTAG);
-	ccnb_tagged_putf(sp.template_ccnb, CCN_DTAG_FreshnessSeconds, "%ld", 10);
-        sp.sp_flags |= CCN_SP_TEMPL_FRESHNESS;
-        ccn_charbuf_append_closer(sp.template_ccnb);
-
-	res= ccn_sign_content(nlsr->ccn, data, name, &sp, raw_data , strlen(raw_data)); 
-
-	if(res >= 0)
-	{
-		if ( nlsr->debugging )
-			printf("Signing LSA Content is successful  \n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Signing LSA Content is successful  \n");
-	}
-
-	res=ccn_put(nlsr->ccn,data->buf,data->length);
-
-	if(res >= 0)
-	{
-		if ( nlsr->debugging )
-			printf("Sending LSA Content is successful  \n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending LSA Content is successful  \n");
-	}
-
-
-
-	ccn_charbuf_destroy(&data);
-	ccn_charbuf_destroy(&name);
-	ccn_charbuf_destroy(&sp.template_ccnb);
-	ccn_charbuf_destroy(&lsa_data);
-
-	free(raw_data);
-	free(lsaId);
-}
-
 /* Call back function registered in ccnd to get all content coming to NLSR application */
 
 enum ccn_upcall_res incoming_content(struct ccn_closure* selfp,
@@ -701,7 +435,6 @@
 void 
 process_incoming_content(struct ccn_closure *selfp, struct ccn_upcall_info* info)
 {
-	//printf("process_incoming_content called \n");
 	if ( nlsr->debugging )
 		printf("process_incoming_content called \n");
 	if ( nlsr->detailed_logging )
@@ -725,20 +458,11 @@
 
 	res=ccn_name_comp_get(info->interest_ccnb, info->interest_comps,nlsr_position+1,&comp_ptr1, &comp_size);
 
-	//printf("Det= %s \n",comp_ptr1);
 
 	if(!strcmp((char *)comp_ptr1,"info"))
 	{
 		process_incoming_content_info(selfp,info);
 	}
-	if(!strcmp((char *)comp_ptr1,"lsdb"))
-	{
-		process_incoming_content_lsdb(selfp,info);
-	}
-	if(!strcmp((char *)comp_ptr1,"lsa"))
-	{
-		process_incoming_content_lsa(selfp,info);
-	}
 
 }
 
@@ -746,7 +470,6 @@
 void 
 process_incoming_content_info(struct ccn_closure *selfp, struct ccn_upcall_info* info)
 {
-	//printf("process_incoming_content_info called \n");
 	if ( nlsr->debugging )
 		printf("process_incoming_content_info called \n");
 	if ( nlsr->detailed_logging )
@@ -761,18 +484,17 @@
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Info Content Received For Neighbor: %s Length:%d\n",nbr->name,nbr->length);
 
 
-	const unsigned char *ptr;
-	size_t length;
-	ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E_Content]-info->pco->offset[CCN_PCO_B_Content], info->pco, &ptr, &length);
-	//printf("Content data: %s\n",ptr);
+	//const unsigned char *ptr;
+	//size_t length;
+	//ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E_Content]-info->pco->offset[CCN_PCO_B_Content], info->pco, &ptr, &length);
 
-	long int interval=atoi((char *)ptr);
+	//long int interval=atoi((char *)ptr);
 
 
 
 	update_adjacent_timed_out_zero_to_adl(nbr);	
 	update_adjacent_status_to_adl(nbr,NBR_ACTIVE);
-	update_lsdb_synch_interval_to_adl(nbr,interval);
+	//update_lsdb_synch_interval_to_adl(nbr,interval);
 	print_adjacent_from_adl();
 
 
@@ -801,257 +523,6 @@
 }
 
 
-void 
-process_incoming_content_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info* info)
-{
-	if ( nlsr->debugging )
-		printf("process_incoming_content_lsdb called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_content_lsdb called \n");
-
-	const unsigned char *ptr;
-	size_t length;
-	ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E_Content]-info->pco->offset[CCN_PCO_B_Content], info->pco, &ptr, &length);
-	//printf("Content data: %s\n",ptr);
-
-	if( (strcmp("NACK",(char *)ptr) != 0 ) && (strcmp("WAIT",(char *)ptr) != 0 ) )
-	{
-		struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-		get_nbr(nbr,selfp,info);
-
-		char *nl;
-		int num_element;
-		int i;
-		char *rem;
-		const char *sep="|";
-		char *orig_router;
-		char *lst;
-		int ls_type;
-		char *lsid;
-		long int ls_id;
-		char *orig_time;
-
-		nl=strtok_r((char *)ptr,sep,&rem);
-		num_element=atoi(nl);		
-
-		for(i = 0 ; i < num_element ; i++)
-		{
-			orig_router=strtok_r(NULL,sep,&rem);
-			lst=strtok_r(NULL,sep,&rem);
-			ls_type=atoi(lst);
-
-			if ( nlsr->debugging )
-				printf("Orig Router: %s ls Type: %d",orig_router,ls_type);
-			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Orig Router: %s ls Type: %d",orig_router,ls_type);
-		
-
-			if(ls_type == LS_TYPE_NAME)
-			{
-				lsid=strtok_r(NULL,sep,&rem);
-				ls_id=atoi(lsid);
-				orig_time=strtok_r(NULL,sep,&rem);
-
-				if ( nlsr->debugging )
-					printf(" LS Id: %ld  Orig Time: %s\n",ls_id ,orig_time);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," LS Id: %ld  Orig Time: %s\n",ls_id ,orig_time);
-
-				
-				int is_new_name_lsa=check_is_new_name_lsa(orig_router,lst,lsid,orig_time);
-				if ( is_new_name_lsa == 1 )
-				{
-					if ( nlsr->debugging )
-						printf("New NAME LSA.....\n");
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"New NAME LSA.....\n");
-					
-					send_interest_for_name_lsa(nbr,orig_router,lst,lsid);	
-				}
-				else 
-				{
-					if ( nlsr->debugging )
-						printf("Name LSA already exists in LSDB\n");
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Name LSA already exists in LSDB\n");
-					
-				}
-			}
-			else
-			{
-				orig_time=strtok_r(NULL,sep,&rem);
-
-				if ( nlsr->debugging )
-					printf(" Orig Time: %s\n",orig_time);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__," Orig Time: %s\n",orig_time);
-				
-
-				int is_new_adj_lsa=check_is_new_adj_lsa(orig_router,lst,orig_time);
-				if ( is_new_adj_lsa == 1 )
-				{
-					if ( nlsr->debugging )
-						printf("New Adj LSA.....\n");
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"New Adj LSA.....\n");
-					send_interest_for_adj_lsa(nbr,orig_router,lst);
-				}
-				else
-				{
-					if ( nlsr->debugging )
-						printf("Adj LSA already exists in LSDB\n");
-					if ( nlsr->detailed_logging )
-						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adj LSA already exists in LSDB\n");
-				}
-			}
-
-		}
-
-		char *lsdb_version=(char *)malloc(20);
-		memset(lsdb_version,0,20);
-		get_lsdb_version(lsdb_version,selfp,info);
-
-		if ( nlsr->debugging )
-			printf("Old LSDB Version of Neighbor: %s is :%s\n",nbr->name,get_nbr_lsdb_version(nbr->name));
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Old LSDB Version of Neighbor: %s is :%s\n",nbr->name,get_nbr_lsdb_version(nbr->name));
-
-		update_adjacent_lsdb_version_to_adl(nbr,lsdb_version);
-		
-		if ( nlsr->debugging )
-			printf("New LSDB Version of Neighbor: %s is :%s\n",nbr->name,get_nbr_lsdb_version(nbr->name));
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"New LSDB Version of Neighbor: %s is :%s\n",nbr->name,get_nbr_lsdb_version(nbr->name));
-
-		update_lsdb_interest_timed_out_zero_to_adl(nbr);
-
-		free(lsdb_version);
-		free(nbr);	
-	}
-	else if (strcmp("WAIT",(char *)ptr) == 0)
-	{
-		struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-		get_nbr(nbr,selfp,info);
-		long int interval=get_lsdb_synch_interval(nbr->name);
-		adjust_adjacent_last_lsdb_requested_to_adl(nbr->name,(long int)interval/2);
-
-		update_lsdb_interest_timed_out_zero_to_adl(nbr);
-		free(nbr);
-	}
-	else 
-	{
-		
-		if ( nlsr->debugging )
-			printf("NACK Content Received\n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"NACK Content Received\n");
-		struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-		get_nbr(nbr,selfp,info);
-		update_lsdb_interest_timed_out_zero_to_adl(nbr);
-		free(nbr);
-	}
-}
-
-
-void 
-process_incoming_content_lsa(struct ccn_closure *selfp, struct ccn_upcall_info* info)
-{
-	
-
-	if ( nlsr->debugging )
-		printf("process_incoming_content_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_content_lsa called \n");	
-
-	char *sep="|";
-	char *rem;
-	char *orig_router;
-	char *orl;
-	int orig_router_length;
-	char *lst;
-	int ls_type;
-	char *lsid;
-	long int ls_id;
-	char *isvld;
-	int isValid;
-	char *num_link;
-	int no_link;
-	char *np;
-	char *np_length;
-	int name_length;
-	char *data;
-	char *orig_time;
-
-	const unsigned char *ptr;
-	size_t length;
-	ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E_Content]-info->pco->offset[CCN_PCO_B_Content], info->pco, &ptr, &length);
-	//printf("Content data Received: %s\n",ptr);
-
-	
-
-	
-	if ( nlsr->debugging )
-		printf("LSA Data \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSA Data\n");	
-
-	if( strlen((char *) ptr ) > 0 )
-	{
-
-		orig_router=strtok_r((char *)ptr,sep,&rem);
-		orl=strtok_r(NULL,sep,&rem);
-		orig_router_length=atoi(orl);
-
-		if ( nlsr->debugging )
-		{
-			printf("	Orig Router Name  : %s\n",orig_router);
-			printf("	Orig Router Length: %d\n",orig_router_length);
-		}
-
-		lst=strtok_r(NULL,sep,&rem);		
-		ls_type=atoi(lst);
-
-		if ( nlsr->debugging )
-			printf("	LS Type  : %d\n",ls_type);
-
-		if ( ls_type == LS_TYPE_NAME )
-		{
-			lsid=strtok_r(NULL,sep,&rem);
-			ls_id=atoi(lsid);
-			orig_time=strtok_r(NULL,sep,&rem);
-			isvld=strtok_r(NULL,sep,&rem);
-			isValid=atoi(isvld);
-			np=strtok_r(NULL,sep,&rem);
-			np_length=strtok_r(NULL,sep,&rem);
-			name_length=atoi(np_length);
-			if ( nlsr->debugging )
-			{
-				printf("	LS ID  : %ld\n",ls_id);
-				printf("	isValid  : %d\n",isValid);
-				printf("	Name Prefix : %s\n",np);
-				printf("	Orig Time   : %s\n",orig_time);
-				printf("	Name Prefix length: %d\n",name_length);
-			}
-
-			build_and_install_others_name_lsa(orig_router,ls_type,ls_id,orig_time,isValid,np);
-
-		}
-		else if ( ls_type == LS_TYPE_ADJ )
-		{
-			orig_time=strtok_r(NULL,sep,&rem);
-			num_link=strtok_r(NULL,sep,&rem);
-			no_link=atoi(num_link);
-			data=rem;
-
-			if ( nlsr->debugging )
-			{
-				printf("	No Link  : %d\n",no_link);
-				printf("	Data  : %s\n",data);
-			}
-			build_and_install_others_adj_lsa(orig_router,ls_type,orig_time,no_link,data);
-		}
-	}
-}
 
 
 void
@@ -1082,14 +553,6 @@
 	{
 		process_incoming_timed_out_interest_info(selfp,info);
 	}
-	if(ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,nlsr_position+1,"lsdb") == 0)
-	{
-		process_incoming_timed_out_interest_lsdb(selfp,info);
-	}
-	if(ccn_name_comp_strcmp(info->interest_ccnb,info->interest_comps,nlsr_position+1,"lsa") == 0)
-	{
-		process_incoming_timed_out_interest_lsa(selfp,info);
-	}
 }
 
 void
@@ -1140,56 +603,6 @@
 
 }
 
-void
-process_incoming_timed_out_interest_lsdb(struct ccn_closure* selfp, struct ccn_upcall_info* info)
-{
-	if ( nlsr->debugging )
-		printf("process_incoming_timed_out_interest_lsdb called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_timed_out_interest_lsdb called \n");
-
-	struct name_prefix *nbr=(struct name_prefix *)malloc(sizeof(struct name_prefix ));
-	get_nbr(nbr,selfp,info);
-
-	if ( nlsr->debugging )
-		printf("LSDB Interest Timed Out for for Neighbor: %s Length:%d\n",nbr->name,nbr->length);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"LSDB Interest Timed Out for for Neighbor: %s Length:%d\n",nbr->name,nbr->length);
-	
-
-	update_lsdb_interest_timed_out_to_adl(nbr,1);
-
-	int interst_timed_out_num=get_lsdb_interest_timed_out_number(nbr);
-
-	if ( nlsr->debugging )
-		printf("Interest Timed out number : %d Interest Retry: %d \n",interst_timed_out_num,nlsr->interest_retry);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest Timed out number : %d Interest Retry: %d \n",interst_timed_out_num,nlsr->interest_retry);
-
-	
-
-	if( interst_timed_out_num >= nlsr->interest_retry )
-	{
-		update_adjacent_status_to_adl(nbr,NBR_DOWN);
-		if(!nlsr->is_build_adj_lsa_sheduled)
-		{
-			nlsr->event_build_adj_lsa = ccn_schedule_event(nlsr->sched, 1000, &build_and_install_adj_lsa, NULL, 0);
-			nlsr->is_build_adj_lsa_sheduled=1;		
-		}
-	}
-	free(nbr->name);
-	free(nbr);
-}
-
-void
-process_incoming_timed_out_interest_lsa(struct ccn_closure* selfp, struct ccn_upcall_info* info)
-{
-	if ( nlsr->debugging )
-		printf("process_incoming_timed_out_interest_lsa called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"process_incoming_timed_out_interest_lsa called \n");
-	
-}
 
 int
 send_info_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
@@ -1281,17 +694,20 @@
 		ccn_charbuf_append_closer(templ); /* </Name> */
 		ccn_charbuf_append_tt(templ, CCN_DTAG_Scope, CCN_DTAG);
 		ccn_charbuf_append_tt(templ, 1, CCN_UDATA);
+		/* Adding InterestLifeTime and InterestScope filter done */		
 		ccn_charbuf_append(templ, "2", 1); //scope of interest: 2 (not further than next host)
 		ccn_charbuf_append_closer(templ); /* </Scope> */
 
 		appendLifetime(templ,nlsr->interest_resend_time);
+		unsigned int face_id=get_next_hop_face_from_adl(nbr->name);
+		ccnb_tagged_putf(templ, CCN_DTAG_FaceID, "%u", face_id);
 		ccn_charbuf_append_closer(templ); /* </Interest> */
-		/* Adding InterestLifeTime and InterestScope filter done */
+		
 	
 		if ( nlsr->debugging )
-			printf("Sending info interest on name prefix : %s \n",int_name);
+			printf("Sending info interest on name prefix : %s through Face:%u\n",int_name,face_id);
 		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending info interest on name prefix : %s \n",int_name);
+			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending info interest on name prefix : %s through Face:%u\n",int_name,face_id);
 
 		res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ);
 
@@ -1308,306 +724,3 @@
 	free(int_name);
 
 }
-
-
-int 
-send_lsdb_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	if ( nlsr->debugging )
-		printf("send_lsdb_interest called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"send_lsdb_interest called \n");	
-
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-
-	 nlsr_lock();
-
-	int i, adl_element;
-	struct ndn_neighbor *nbr;
-
-	struct hashtb_enumerator ee;
-    	struct hashtb_enumerator *e = &ee;
-    	
-    	hashtb_start(nlsr->adl, e);
-	adl_element=hashtb_n(nlsr->adl);
-
-	for(i=0;i<adl_element;i++)
-	{
-		nbr=e->data;
-
-		if(nbr->status == NBR_ACTIVE)
-		{	
-			if(nbr->is_lsdb_send_interest_scheduled == 0)
-			{
-				long int time_diff=get_nbr_time_diff_lsdb_req(nbr->neighbor->name);
-				if ( nlsr->debugging )
-					printf("Time since last time LSDB requested : %ld Seconds for Neighbor: %s \n",time_diff,nbr->neighbor->name);
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Time since last time LSDB requested : %ld Seconds for Neighbor: %s \n",time_diff,nbr->neighbor->name);	
-						
-
-				if( time_diff >= ( get_lsdb_synch_interval(nbr->neighbor->name) + get_nbr_random_time_component(nbr->neighbor->name) ) )
-				{
-					nbr->is_lsdb_send_interest_scheduled=1;
-					send_lsdb_interest_to_nbr(nbr->neighbor);
-				}
-			}
-		}
-		hashtb_next(e);		
-	}
-
-	hashtb_end(e);
-	nlsr->event_send_lsdb_interest= ccn_schedule_event(nlsr->sched, 30000000, &send_lsdb_interest, NULL, 0);
-
-	 nlsr_unlock();
-
-	return 0;
-}
-
-void 
-send_lsdb_interest_to_nbr(struct name_prefix *nbr)
-{
-	if ( nlsr->debugging )
-		printf("send_lsdb_interest_to_nbr called \n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"send_lsdb_interest_to_nbr called \n");
-
-	char *last_lsdb_version=get_nbr_lsdb_version(nbr->name);
-
-	if(last_lsdb_version !=NULL)
-	{
-		
-
-		if ( nlsr->debugging )
-			printf("Last LSDB Version: %s \n",last_lsdb_version);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Last LSDB Version: %s \n",last_lsdb_version);
-
-		struct ccn_charbuf *name;
-		int res;
-		char lsdb_str[5];
-		char nlsr_str[5];
-
-		memset(&nlsr_str,0,5);
-		sprintf(nlsr_str,"nlsr");
-		memset(&lsdb_str,0,5);
-		sprintf(lsdb_str,"lsdb");		
-		//make and send interest with exclusion filter as last_lsdb_version
-		if ( nlsr->debugging )
-			printf("Sending interest for name prefix:%s/%s/%s\n",nbr->name,nlsr_str,lsdb_str);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending interest for name prefix:%s/%s/%s\n",nbr->name,nlsr_str,lsdb_str);
-			
-		name=ccn_charbuf_create();
-		res=ccn_name_from_uri(name,nbr->name);
-
-		if( res >= 0)
-		{
-			ccn_name_append_str(name,nlsr_str);
-			ccn_name_append_str(name,lsdb_str);
-			/* adding Exclusion filter */
-
-			struct ccn_charbuf *templ;
-			templ = ccn_charbuf_create();
-
-			struct ccn_charbuf *c;
-			c = ccn_charbuf_create();
-
-
-			ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
-			ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
-			ccn_charbuf_append_closer(templ); /* </Name> */
-			ccn_charbuf_append_tt(templ, CCN_DTAG_Exclude, CCN_DTAG);
-			ccnb_tagged_putf(templ, CCN_DTAG_Any, "");
-			ccn_charbuf_reset(c);
-			ccn_charbuf_putf(c, "%s", last_lsdb_version);
-			
-			ccnb_append_tagged_blob(templ, CCN_DTAG_Component, c->buf, c->length);
-			ccn_charbuf_append_closer(templ); /* </Exclude> */
-			ccn_charbuf_append_tt(templ, CCN_DTAG_Scope, CCN_DTAG);
-			ccn_charbuf_append_tt(templ, 1, CCN_UDATA);
-			ccn_charbuf_append(templ, "2", 1);
-			ccn_charbuf_append_closer(templ); /* </Scope> */
-
-			appendLifetime(templ,nlsr->interest_resend_time);
-
-			ccn_charbuf_append_closer(templ); /* </Interest> */
-
-
-			/* Adding Exclusion filter done */
-
-			res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ);
-
-			if ( res >= 0 )
-			{
-				if ( nlsr->debugging )
-					printf("Interest sending Successfull .... \n");
-				if ( nlsr->detailed_logging )
-					writeLogg(__FILE__,__FUNCTION__,__LINE__,"Interest sending Successfull .... \n");	
-				update_adjacent_last_lsdb_requested_to_adl(nbr->name,get_current_time_sec());
-
-			}
-			ccn_charbuf_destroy(&c);
-			ccn_charbuf_destroy(&templ);
-		}
-		ccn_charbuf_destroy(&name);
-	}	
-	set_is_lsdb_send_interest_scheduled_to_zero(nbr->name);
-}
-
-void 
-send_interest_for_name_lsa(struct name_prefix *nbr, char *orig_router, char *ls_type, char *ls_id)
-{
-	if ( nlsr->debugging )
-		printf("send_interest_for_name_lsa called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"send_interest_for_name_lsa called\n");
-
-	int res;
-	char lsa_str[5];
-	char nlsr_str[5];
-
-	memset(&nlsr_str,0,5);
-	sprintf(nlsr_str,"nlsr");
-	memset(&lsa_str,0,5);
-	sprintf(lsa_str,"lsa");
-
-	char *int_name=(char *)malloc(nbr->length + strlen(ls_type)+strlen(orig_router)+strlen(nlsr_str)+strlen(lsa_str)+3);
-	memset(int_name,0,nbr->length +strlen(ls_type)+ strlen(orig_router)+strlen(nlsr_str)+strlen(lsa_str)+3);
-
-	memcpy(int_name+strlen(int_name),nbr->name,nbr->length);
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),nlsr_str,strlen(nlsr_str));
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),lsa_str,strlen(lsa_str));
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),ls_type,strlen(ls_type));
-	memcpy(int_name+strlen(int_name),orig_router,strlen(orig_router));
-
-
-	struct ccn_charbuf *name;	
-	name=ccn_charbuf_create();
-
-
-	res=ccn_name_from_uri(name,int_name);
-	ccn_name_append_str(name,ls_type);
-	ccn_name_append_str(name,ls_id);
-
-
-	/* adding InterestLifeTime and InterestScope filter */
-
-	struct ccn_charbuf *templ;
-	templ = ccn_charbuf_create();
-
-	ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
-	ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
-	ccn_charbuf_append_closer(templ); /* </Name> */
-	//ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope);
-	ccn_charbuf_append_tt(templ, CCN_DTAG_Scope, CCN_DTAG);
-	ccn_charbuf_append_tt(templ, 1, CCN_UDATA);
-	ccn_charbuf_append(templ, "2", 1); //scope of interest: 2 (not further than next host)
-	ccn_charbuf_append_closer(templ); /* </Scope> */
-
-	appendLifetime(templ,nlsr->interest_resend_time);
-	ccn_charbuf_append_closer(templ); /* </Interest> */
-	/* Adding InterestLifeTime and InterestScope filter done */
-
-	if ( nlsr->debugging )
-		printf("Sending NAME LSA interest on name prefix : %s/%s/%s\n",int_name,ls_type,ls_id);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending NAME LSA interest on name prefix : %s/%s/%s\n",int_name,ls_type,ls_id);
-
-
-	res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ);
-
-	if ( res >= 0 )
-	{
-		if ( nlsr->debugging )
-			printf("NAME LSA interest sending Successfull .... \n");
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"NAME LSA interest sending Successfull .... \n");
-	
-	}	
-	ccn_charbuf_destroy(&templ);
-	ccn_charbuf_destroy(&name);
-	free(int_name);
-
-
-}
-
-void 
-send_interest_for_adj_lsa(struct name_prefix *nbr, char *orig_router, char *ls_type)
-{
-	if ( nlsr->debugging )
-		printf("send_interest_for_name_lsa called\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"send_interest_for_name_lsa called\n");
-
-	int res;
-	char lsa_str[5];
-	char nlsr_str[5];
-
-	memset(&nlsr_str,0,5);
-	sprintf(nlsr_str,"nlsr");
-	memset(&lsa_str,0,5);
-	sprintf(lsa_str,"lsa");
-
-	char *int_name=(char *)malloc(nbr->length + strlen(ls_type)+strlen(orig_router)+strlen(nlsr_str)+strlen(lsa_str)+3+strlen(ls_type)+1);
-	memset(int_name,0,nbr->length +strlen(ls_type)+ strlen(orig_router)+strlen(nlsr_str)+strlen(lsa_str)+3+strlen(ls_type)+1);
-
-	memcpy(int_name+strlen(int_name),nbr->name,nbr->length);
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),nlsr_str,strlen(nlsr_str));
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),lsa_str,strlen(lsa_str));
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),ls_type,strlen(ls_type));
-	memcpy(int_name+strlen(int_name),orig_router,strlen(orig_router));
-	memcpy(int_name+strlen(int_name),"/",1);
-	memcpy(int_name+strlen(int_name),ls_type,strlen(ls_type));
-
-	struct ccn_charbuf *name;	
-	name=ccn_charbuf_create();
-
-
-	ccn_name_from_uri(name,int_name);
-	
-	/* adding InterestLifeTime and InterestScope filter */
-
-	struct ccn_charbuf *templ;
-	templ = ccn_charbuf_create();
-
-	ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
-	ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
-	ccn_charbuf_append_closer(templ); /* </Name> */
-	ccn_charbuf_append_tt(templ, CCN_DTAG_Scope, CCN_DTAG);
-	ccn_charbuf_append_tt(templ, 1, CCN_UDATA);
-	ccn_charbuf_append(templ, "2", 1); //scope of interest: 2 (not further than next host)
-	ccn_charbuf_append_closer(templ); /* </Scope> */
-
-	appendLifetime(templ,nlsr->interest_resend_time);
-	ccn_charbuf_append_closer(templ); /* </Interest> */
-	/* Adding InterestLifeTime and InterestScope filter done */
-
-	if ( nlsr->debugging )
-		printf("Sending ADJ LSA interest on name prefix : %s\n",int_name);
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending ADJ LSA interest on name prefix : %s\n",int_name);
-
-	res=ccn_express_interest(nlsr->ccn,name,&(nlsr->in_content),templ);
-
-	if ( res >= 0 )
-	{
-		if ( nlsr->debugging )
-			printf("ADJ LSA interest sending Successfull .... \n");	
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"ADJ LSA interest sending Successfull .... \n");	
-	}
-	
-	ccn_charbuf_destroy(&templ);
-	ccn_charbuf_destroy(&name);
-	free(int_name);
-}
diff --git a/nlsr_ndn.h b/nlsr_ndn.h
index 1feab1e..1e34284 100644
--- a/nlsr_ndn.h
+++ b/nlsr_ndn.h
@@ -7,31 +7,19 @@
 void get_lsdb_version(char *lsdb_version,struct ccn_closure *selfp, struct ccn_upcall_info *info );
 int get_ls_type(struct ccn_closure *selfp, struct ccn_upcall_info *info);
 
-enum ccn_upcall_res incoming_interest(struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info);
- 
+enum ccn_upcall_res incoming_interest(struct ccn_closure *selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info *info); 
 void process_incoming_interest(struct ccn_closure *selfp, struct ccn_upcall_info *info);
 void process_incoming_interest_info(struct ccn_closure *selfp, struct ccn_upcall_info *info);
-void process_incoming_interest_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info *info);
-void process_incoming_interest_lsa(struct ccn_closure *selfp, struct ccn_upcall_info *info);
-
 
 enum ccn_upcall_res incoming_content(struct ccn_closure* selfp, enum ccn_upcall_kind kind, struct ccn_upcall_info* info);
 void process_incoming_content(struct ccn_closure *selfp, struct ccn_upcall_info* info);
 void process_incoming_content_info(struct ccn_closure *selfp, struct ccn_upcall_info* info);
-void process_incoming_content_lsdb(struct ccn_closure *selfp, struct ccn_upcall_info* info);
-void process_incoming_content_lsa(struct ccn_closure *selfp, struct ccn_upcall_info* info);
 
 void process_incoming_timed_out_interest(struct ccn_closure* selfp, struct ccn_upcall_info* info);
 void process_incoming_timed_out_interest_info(struct ccn_closure* selfp, struct ccn_upcall_info* info);
-void process_incoming_timed_out_interest_lsdb(struct ccn_closure* selfp, struct ccn_upcall_info* info);
-void process_incoming_timed_out_interest_lsa(struct ccn_closure* selfp, struct ccn_upcall_info* info);
 
 int send_info_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
 void send_info_interest_to_neighbor(struct name_prefix *nbr);
 
-int send_lsdb_interest(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
-void send_lsdb_interest_to_nbr(struct name_prefix *nbr);
-void send_interest_for_name_lsa(struct name_prefix *nbr, char *orig_router, char *ls_type, char *ls_id);
-void send_interest_for_adj_lsa(struct name_prefix *nbr, char *orig_router, char *ls_type);
 
 #endif
diff --git a/nlsr_npt.c b/nlsr_npt.c
index e3c8483..6eb9c69 100644
--- a/nlsr_npt.c
+++ b/nlsr_npt.c
@@ -177,6 +177,11 @@
 update_ccnd_fib_for_orig_router(char *orig_router)
 {
 
+	if ( nlsr->debugging )
+	{
+		printf("update_ccnd_fib_for_orig_router called\n");
+	}
+
 	int res;	
 	struct hashtb_enumerator ee;
     	struct hashtb_enumerator *e = &ee; 	
@@ -202,23 +207,31 @@
 		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 )
+		if ( nlsr->debugging )
 		{
-			last_face=first_face;
+			int m;
+			for ( m =0 ; m< num_face ; m++)
+			{
+				printf("Dest_router: %s Next_Hop_Face: %d Route_cost: %d \n",orig_router,faces[m],route_costs[m]);
+			}
 		}
-		else 
+
+		last_face=0;
+		if ( nlsr->max_faces_per_prefix == 0) // add all faces available in routing table
 		{
-			if ( num_face <= nlsr->multi_path_face_num)
+			first_face=num_face-1;
+		}
+		else if( nlsr->max_faces_per_prefix > 0)
+		{
+			if ( nlsr->max_faces_per_prefix >= num_face)
 			{
-				last_face=0;
+				first_face=num_face-1;
 			}
-			else if ( nlsr->multi_path_face_num == 0)
+			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;
@@ -227,6 +240,34 @@
     		struct hashtb_enumerator *enle = &eenle;
 
 		hashtb_start(ne->name_list, enle);
+		nl_element=hashtb_n(ne->name_list);
+
+		for (i=0;i<nl_element;i++)
+		{
+			nle=enle->data;
+			
+			for( j=num_face-1; j>= 0; j--)
+			{
+
+				if ( !( is_neighbor(nle->name) == 1 && get_next_hop_face_from_adl(nle->name) == faces[j] ) )
+				{
+					add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, faces[j]);
+				}
+			}
+			
+			
+			hashtb_next(enle);
+		}
+
+
+		hashtb_end(enle);
+
+		if ( nlsr->debugging )
+		{
+			printf("First Face Index: %d Last Face Index: %d\n",first_face,last_face);
+		}
+
+		hashtb_start(ne->name_list, enle);
 		nl_element=hashtb_n(ne->name_list);	
 
 		for (i=0;i<nl_element;i++)
@@ -235,30 +276,26 @@
 			
 			for( j=first_face; j>= last_face; j--)
 			{
-				//printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
-				//printf("Orig Router: %s \n",orig_router);
-				//printf("Name Prefix: %s \n",nle->name);
-				//printf("Is neighbor Orig Router: %d \n",is_neighbor(orig_router));
-				//printf("Is neighbor Name Prefix: %d \n",is_neighbor(nle->name));
-
-				if ( is_neighbor(orig_router) == 0 )
+				if ( nlsr->debugging )
+				{
+					printf("Possible FIB Entry name: %s face: %d route cost: %d \n",nle->name,faces[j],route_costs[j]);
+				}
+				if ( is_active_neighbor(orig_router) == 0 )
 				{
 					if ( nlsr->debugging )
 						printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);	
 					if ( nlsr->detailed_logging )
 						writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
-					//printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
 					add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);	
 				}
 				else 
 				{
-					if ( j == last_face && is_neighbor(nle->name)==0)
+					if ( j == last_face &&  is_active_neighbor(nle->name)==0)
 					{
 						if ( nlsr->debugging )
 							printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);	
 						if ( nlsr->detailed_logging )
 							writeLogg(__FILE__,__FUNCTION__,__LINE__,"Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
-						//printf("Adding face: Name:%s Face: %d\n",nle->name,faces[j]);
 						add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_REG, faces[j]);
 					}
 				}
@@ -333,28 +370,27 @@
 			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 if ( nlsr->multi_path_face_num == 0)
+				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--)
 			{
 
-				if ( is_neighbor(orig_router) == 0 )
+				if ( is_active_neighbor(orig_router) == 0 )
 				{
 					if ( nlsr->debugging )
 						printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);	
@@ -364,7 +400,7 @@
 				}
 				else 
 				{
-					if ( j == last_face && is_neighbor(nle->name)==0)
+					if ( j == last_face && is_active_neighbor(nle->name)==0)
 					{
 						if ( nlsr->debugging )
 							printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);	
@@ -376,10 +412,6 @@
 				
 			}
 			
-			
-			
-
-			//hashtb_delete(enle); has to delete later
 		}
 
 		hashtb_end(enle);
@@ -431,7 +463,6 @@
 			printf(" Origination Router: %s \n",ne->orig_router);
 		if ( nlsr->detailed_logging )
 			writeLogg(__FILE__,__FUNCTION__,__LINE__," Origination Router: %s \n",ne->orig_router);
-		//ne->next_hop_face == NO_FACE ? printf(" Next Hop Face: NO_NEXT_HOP \n") : printf(" Next Hop Face: %d \n", ne->next_hop_face);
 		
 		int j, nl_element,face_list_element;
 		struct name_list_entry *nle;		
@@ -473,7 +504,7 @@
 			{
 				fle=ef->data;
 				if ( nlsr->debugging )
-					printf(" 	Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
+					printf(" 	Face: %d Route_Cost: %f \n",fle->next_hop_face,fle->route_cost);
 				if ( nlsr->detailed_logging )
 					writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
 				hashtb_next(ef);	
@@ -591,7 +622,7 @@
 				printf("Face Found \n");
 			if ( nlsr->detailed_logging )
 				writeLogg(__FILE__,__FUNCTION__,__LINE__,"Face Found \n");
-			struct face_list_entry *fle;//=(struct face_list_entry *)malloc(sizeof(struct face_list_entry));
+			struct face_list_entry *fle;
 			fle=ef->data;
 			fle->next_hop_face=face_id;
 			fle->route_cost=route_cost;
@@ -606,7 +637,10 @@
 			fle=ef->data;
 			fle->next_hop_face=face_id;
 			fle->route_cost=route_cost;
-			//hashtb_delete(ef);
+
+			
+
+
 		}
 		hashtb_end(ef);
 	}
@@ -650,9 +684,9 @@
 		if ( face_list_element <= 0 )
 		{
 			if ( nlsr->debugging )
-				printf(" 	Face: No Face \n");
+				printf(" Face: No Face \n");
 			if ( nlsr->detailed_logging )
-				writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: No Face \n");
+				writeLogg(__FILE__,__FUNCTION__,__LINE__," Face: No Face \n");
 		}
 		else
 		{
@@ -699,7 +733,6 @@
     	
     		hashtb_start(ne->face_list, ef);
 		res1=hashtb_seek(ef, &face_id, sizeof(face_id), 0);
-
 		if ( res1 == HT_OLD_ENTRY )
 		{
 			hashtb_delete(ef);
@@ -718,53 +751,6 @@
 	hashtb_end(e);
 }
 
-int
-delete_old_face_from_npt(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
-{
-	if(flags == CCN_SCHEDULE_CANCEL)
-	{
- 	 	return -1;
-	}
-	
-	nlsr_lock();
-
-	if ( nlsr->debugging )
-		printf("delete_old_face_from_npt\n");
-	if ( nlsr->detailed_logging )
-		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_old_face_from_npt\n");
-	
-	if ( ev->evdata != NULL )
-	{		
-		if ( nlsr->debugging )
-			printf("Event Data: %s \n",(char *)ev->evdata);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Event Data: %s \n",(char *)ev->evdata);
-		char *sep="|";
-		char *rem;
-		char *orig_router;
-		char *faceid;
-		int face_id;
-
-		char *face_data=(char *)malloc(strlen((char *)ev->evdata)+1);
-		memset(face_data,0,strlen((char *)ev->evdata)+1);
-		memcpy(face_data+strlen(face_data),(char *)ev->evdata,strlen((char *)ev->evdata));
-
-		orig_router=strtok_r(face_data,sep,&rem);
-		faceid=strtok_r(NULL,sep,&rem);
-		face_id=atoi(faceid);
-
-		if ( nlsr->debugging )
-			printf("Orig Router: %s Face: %d \n",orig_router,face_id);
-		if ( nlsr->detailed_logging )
-			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Orig Router: %s Face: %d \n",orig_router,face_id);
-
-		delete_face_from_npt_by_face_id(orig_router,face_id);		
-	}
-
-	nlsr_unlock();
-	
-	return 0;
-}
 
 void 
 clean_old_fib_entries_from_npt(void)
@@ -800,7 +786,7 @@
 		if ( face_list_element <= 0 )
 		{
 			if ( nlsr->debugging )
-				printf(" 	Face: No Face \n");
+				printf(" Face: No Face \n");
 			if ( nlsr->detailed_logging )
 				writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: No Face \n");
 			
@@ -823,17 +809,12 @@
 					for (k=0;k<nl_element;k++)
 					{
 						nle=enle->data;
-
-						//delete all the fib entries here
-
-						//printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
-
 						if( is_neighbor(nle->name) == 0 )
 						{
 							if ( nlsr->debugging )
 								printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
 							if ( nlsr->detailed_logging )
-								writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
+								writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);		
 							add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
 						}						
 		
@@ -842,20 +823,39 @@
 					}
 					hashtb_end(enle);
 
-					char faceid[20];
-					memset(faceid,0,20);
-					sprintf(faceid,"%d",fle->next_hop_face);
-					char *evdata=(char *)malloc(strlen(ne->orig_router)+strlen(faceid)+2);
-					memset(evdata,0,strlen(ne->orig_router)+strlen(faceid)+2);					
-					memcpy(evdata+strlen(evdata),ne->orig_router,strlen(ne->orig_router));	
-					memcpy(evdata+strlen(evdata),"|",1);
-					memcpy(evdata+strlen(evdata),faceid,strlen(faceid));					
-	
-					nlsr->event = ccn_schedule_event(nlsr->sched, 1, &delete_old_face_from_npt, (void *)evdata, 0);					
-					
+
+					hashtb_delete(ef);
+					j++;
+						
 				}
-				
-				hashtb_next(ef);	
+				else 
+				{
+					struct name_list_entry *nle;		
+					struct hashtb_enumerator eenle;
+    					struct hashtb_enumerator *enle = &eenle;
+
+					hashtb_start(ne->name_list, enle);
+					nl_element=hashtb_n(ne->name_list);	
+
+					for (k=0;k<nl_element;k++)
+					{
+						nle=enle->data;
+						if(  is_active_neighbor(ne->orig_router) && get_next_hop_face_from_adl(	ne->orig_router ) != fle->next_hop_face )
+						{
+							if ( nlsr->debugging )
+								printf("Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);
+							if ( nlsr->detailed_logging )
+								writeLogg(__FILE__,__FUNCTION__,__LINE__,"Deleting face: Name:%s Face: %d\n",nle->name,fle->next_hop_face);		
+							add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)nle->name, OP_UNREG, fle->next_hop_face);
+						}						
+		
+
+						hashtb_next(enle);
+					}
+					hashtb_end(enle);
+					
+					hashtb_next(ef);
+				}	
 			}
 		}
 		hashtb_end(ef);
@@ -871,9 +871,14 @@
 void
 update_npt_with_new_route(void)
 {
+	if ( nlsr->debugging )
+		printf("update_npt_with_new_route called\n");
+		
 	clean_old_fib_entries_from_npt();
+	print_npt();
 	add_new_fib_entries_to_npt();
-	
+	print_npt();	
+
 	int i, npt_element;
 	
 	struct npt_entry *ne;
@@ -995,7 +1000,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 )
@@ -1013,6 +1018,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;		
@@ -1028,7 +1052,7 @@
 			
 			for( j=first_face; j>= last_face; j--)
 			{
-				if ( is_neighbor(orig_router) == 0 )
+				if ( is_active_neighbor(orig_router) == 0 )
 				{
 					if ( nlsr->debugging )
 						printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
@@ -1038,7 +1062,7 @@
 				}
 				else 
 				{
-					if ( j == last_face && is_neighbor(nle->name)==0)
+					if ( j == last_face && is_active_neighbor(nle->name)==0)
 					{
 						if ( nlsr->debugging )
 							printf("Deleting face: Name:%s Face: %d\n",nle->name,faces[j]);
diff --git a/nlsr_npt.h b/nlsr_npt.h
index 587c8be..d339ede 100644
--- a/nlsr_npt.h
+++ b/nlsr_npt.h
@@ -22,7 +22,6 @@
 int delete_npt_entry_by_router_and_name_prefix(char *orig_router, char *name_prefix);
 void print_npt(void);
 void delete_orig_router_from_npt(char *orig_router);
-//void update_npt_with_new_route(char * orig_router,int next_hop_face);
 void update_npt_with_new_route(void);
 void destroy_all_face_by_nlsr(void);
 void sort_faces_by_distance(int *faces,int *route_costs,int start,int element);
diff --git a/nlsr_route.c b/nlsr_route.c
index 8537b2e..6b45ed2 100644
--- a/nlsr_route.c
+++ b/nlsr_route.c
@@ -1,6 +1,7 @@
-#include<stdio.h>
-#include<string.h>
-#include<stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <getopt.h>
 #include <sys/time.h>
@@ -75,47 +76,121 @@
 			print_adj_matrix(adj_matrix,map_element);
 
 		long int source=get_mapping_no(nlsr->router_name);
-		long int *parent=(long int *)malloc(map_element * sizeof(long int));
-		long int *dist=(long int *)malloc(map_element * sizeof(long int));
-
 		int num_link=get_no_link_from_adj_matrix(adj_matrix, map_element ,source);
-		
-		if ( (num_link == 0) || (nlsr->multi_path_face_num <= 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 ) )
+
+		if ( nlsr->is_hyperbolic_calc == 1)
 		{
 			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++)
+
+			struct hashtb_enumerator ee;
+			struct hashtb_enumerator *e = &ee;
+			for (hashtb_start(nlsr->rev_map, e); e->key != NULL; hashtb_next(e)) 
 			{
-				adjust_adj_matrix(adj_matrix, map_element,source,links[i],link_costs[i]);
+				struct map_entry *me=e->data;
+				if ( me->mapping != source )
+				{
+					long int *faces=(long int *)calloc(num_link,sizeof(long int));
+					double *nbr_dist=(double *)calloc(num_link,sizeof(double));
+					double *nbr_to_dest=(double *)calloc(num_link,sizeof(double));
+					for ( i=0 ; i < num_link; i++)
+					{
+						int face=get_next_hop_face_from_adl(get_router_from_rev_map(links[i]));
+						double dist_to_nbr=get_hyperbolic_distance(source,links[i]);
+						double dist_to_dest_from_nbr=get_hyperbolic_distance(links[i],me->mapping);
+						faces[i]=face;
+						nbr_dist[i]=dist_to_nbr;
+						nbr_to_dest[i]=	dist_to_dest_from_nbr;	
+
+						
+					}
+					sort_hyperbolic_route(nbr_to_dest,nbr_dist, faces,0,num_link);
+					if (nlsr->max_faces_per_prefix == 0 )
+					{
+						for ( i=0 ; i < num_link; i++)
+						{
+							update_routing_table_with_new_hyperbolic_route(me->mapping,faces[i],nbr_to_dest[i]);
+						}				
+					}
+					else if ( nlsr->max_faces_per_prefix > 0 )
+					{
+						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->max_faces_per_prefix)
+						{
+							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]);
+							}
+						}
+
+					}
+					free(faces);
+					free(nbr_dist);
+					free(nbr_to_dest);
+				}
+			}
+			hashtb_end(e);
+
+			
+			free(links);
+			free(link_costs);
+		}
+		else if (nlsr->is_hyperbolic_calc == 0 )
+		{
+
+			long int *parent=(long int *)malloc(map_element * sizeof(long int));
+			long int *dist=(long int *)malloc(map_element * sizeof(long int));
+			
+		
+			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->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));
+				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);
+				}
 
-			free(links);
-			free(link_costs);
+				free(links);
+				free(link_costs);
+			}
+			free(parent);
+			free(dist);
 		}
+		
+		print_routing_table();
+		print_npt();
 
 		update_npt_with_new_route();
 
 		print_routing_table();
 		print_npt();
 
+
 		for(i = 0; i < map_element; i++)
 		{
 			free(adj_matrix[i]);
 		}
-		free(parent);
-		free(dist);
+		
 		free(adj_matrix);
 		hashtb_destroy(&nlsr->map);
 		hashtb_destroy(&nlsr->rev_map);
@@ -136,7 +211,7 @@
 	//long int *dist=(long int *)malloc(V * sizeof(long int));
 	long int *Q=(long int *)malloc(V * sizeof(long int));
 	long int head=0;
-	/* Initial the Parent */
+	/* Initiate the Parent */
 	for (i = 0 ; i < V; i++)
 	{
 		parent[i]=EMPTY_PARENT;
@@ -180,8 +255,7 @@
 			sort_queue_by_distance(Q,dist,head,V);
 		}
 	}
-	free(Q);
-	//free(dist);	
+	free(Q);	
 }
 
 void
@@ -277,7 +351,9 @@
 {
 	if (parent[dest] != EMPTY_PARENT )
 		print_path(parent,parent[dest]);
-	printf(" %ld",dest);
+
+	if ( nlsr->debugging )
+		printf(" %ld",dest);
 }
 
 int 
@@ -317,6 +393,50 @@
 	
 }
 
+void 
+sort_hyperbolic_route(double *dist_dest,double *dist_nbr, long int *faces,long int start,long int element)
+{
+	long int i,j;
+	double temp_dist;
+	long int temp_face;
+
+	for ( i=start ; i < element ; i ++) 
+	{
+		for( j=i+1; j<element; j ++)
+		{
+			if (dist_dest[i] < dist_dest[j])
+			{
+				temp_dist=dist_dest[j];
+				dist_dest[j]=dist_dest[i];
+				dist_dest[i]=temp_dist;
+
+				temp_dist=dist_nbr[j];
+				dist_nbr[j]=dist_nbr[i];
+				dist_nbr[i]=temp_dist;
+
+				temp_face=faces[j];
+				faces[j]=faces[i];
+				faces[i]=temp_face;
+			}
+			if ( (dist_dest[i] == dist_dest[j]) && (dist_nbr[i] < dist_nbr[j]) )
+			{
+				temp_dist=dist_dest[j];
+				dist_dest[j]=dist_dest[i];
+				dist_dest[i]=temp_dist;
+
+				temp_dist=dist_nbr[j];
+				dist_nbr[j]=dist_nbr[i];
+				dist_nbr[i]=temp_dist;
+
+				temp_face=faces[j];
+				faces[j]=faces[i];
+				faces[i]=temp_face;
+			}
+		}
+	}
+	
+}
+
 void
 print_map(void)
 {
@@ -433,24 +553,32 @@
 	char *rem;
 	char *rtr_id;
 	char *length;
-	char *face;
+	//char *face;
 	char *metric;
 	
 	if(no_link >0 )
 	{
 		rtr_id=strtok_r(lsa_data,sep,&rem);
 		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
+		//face=strtok_r(NULL,sep,&rem);
 		metric=strtok_r(NULL,sep,&rem);
 
+		if ( !nlsr->debugging && nlsr->debugging)
+		{
+			printf("Metric: %s Length:%s\n",metric,length);
+		}
 		add_map_entry(rtr_id);
 
 		for(i=1;i<no_link;i++)
 		{
 			rtr_id=strtok_r(NULL,sep,&rem);
 			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
+			//face=strtok_r(NULL,sep,&rem);
 			metric=strtok_r(NULL,sep,&rem);
+			if ( !nlsr->debugging && nlsr->debugging)
+			{
+				printf("Metric: %s Length:%s\n",metric,length);
+			}
 
 			add_map_entry(rtr_id);
 
@@ -594,15 +722,20 @@
 	char *rem;
 	char *rtr_id;
 	char *length;
-	char *face;
+	//char *face;
 	char *metric;
 	
 	if(adj_lsa->no_link >0 )
 	{
 		rtr_id=strtok_r(lsa_data,sep,&rem);
 		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
+		//face=strtok_r(NULL,sep,&rem);
 		metric=strtok_r(NULL,sep,&rem);
+	
+		if ( !nlsr->debugging && nlsr->debugging)
+		{
+				printf("Metric: %s Length:%s\n",metric,length);
+		}
 
 		mapping_nbr_router=get_mapping_no(rtr_id);
 		adj_matrix[mapping_orig_router][mapping_nbr_router]=atoi(metric);
@@ -611,9 +744,14 @@
 		{
 			rtr_id=strtok_r(NULL,sep,&rem);
 			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
+			//face=strtok_r(NULL,sep,&rem);
 			metric=strtok_r(NULL,sep,&rem);
 
+			if ( !nlsr->debugging && nlsr->debugging)
+			{
+				printf("Metric: %s Length:%s\n",metric,length);
+			}
+
 			mapping_nbr_router=get_mapping_no(rtr_id);
 			adj_matrix[mapping_orig_router][mapping_nbr_router]=atoi(metric);
 
@@ -841,15 +979,19 @@
 	char *rem;
 	char *rtr_id;
 	char *length;
-	char *face;
+	//char *face;
 	char *metric;
 
 	if(no_link >0 )
 	{
 		rtr_id=strtok_r(lsa_data,sep,&rem);
 		length=strtok_r(NULL,sep,&rem);
-		face=strtok_r(NULL,sep,&rem);
+		//face=strtok_r(NULL,sep,&rem);
 		metric=strtok_r(NULL,sep,&rem);
+		if ( !nlsr->debugging && nlsr->debugging)
+		{
+			printf("Metric: %s Length:%s\n",metric,length);
+		}
 
 
 		add_next_hop_router(rtr_id);
@@ -858,8 +1000,12 @@
 		{
 			rtr_id=strtok_r(NULL,sep,&rem);
 			length=strtok_r(NULL,sep,&rem);
-			face=strtok_r(NULL,sep,&rem);
+			//face=strtok_r(NULL,sep,&rem);
 			metric=strtok_r(NULL,sep,&rem);
+			if ( !nlsr->debugging && nlsr->debugging)
+			{
+				printf("Metric: %s Length:%s\n",metric,length);
+			}
 
 			add_next_hop_router(rtr_id);
 	
@@ -874,6 +1020,12 @@
 void 
 update_routing_table(char * dest_router,int next_hop_face, int route_cost)
 {
+	if ( nlsr->debugging )
+	{
+		printf("update_routing_table called \n");
+		printf("Dest Router: %s Next Hop face: %d Route Cost: %d \n",dest_router,next_hop_face,route_cost);
+	}
+
 	int res,res1;
 	struct routing_table_entry *rte;
 
@@ -906,20 +1058,6 @@
 			fle->route_cost=route_cost;
 		}
 		hashtb_end(ef);
-		
-		/*
-		//updating the face for the router prefix itself
-		if ( (rte->next_hop_face != NO_FACE  || rte->next_hop_face != NO_NEXT_HOP ) && is_neighbor(dest_router)==0 )
-		{
-			add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)dest_router, OP_UNREG, rte->next_hop_face);
-		}
-		if ( (next_hop_face != NO_FACE  || next_hop_face != NO_NEXT_HOP ) && is_neighbor(dest_router)==0 )
-		{
-			add_delete_ccn_face_by_face_id(nlsr->ccn, (const char *)dest_router, OP_REG, next_hop_face);
-		}
-
-		rte->next_hop_face=next_hop_face;
-		*/
 	}
 	else if ( res == HT_OLD_ENTRY )
 	{
@@ -984,7 +1122,7 @@
 			{
 				fle=ef->data;
 				if ( nlsr->debugging )
-					printf(" 	Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
+					printf(" 	Face: %d Route_Cost: %f \n",fle->next_hop_face,fle->route_cost);
 				if ( nlsr->detailed_logging )
 					writeLogg(__FILE__,__FUNCTION__,__LINE__," 	Face: %d Route_Cost: %d \n",fle->next_hop_face,fle->route_cost);
 				hashtb_next(ef);	
@@ -1003,7 +1141,7 @@
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"\n");
 }
 
-
+/*
 int
 delete_empty_rte(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
 {
@@ -1016,13 +1154,14 @@
 	{
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"delete_empty_rte called\n");
 		writeLogg(__FILE__,__FUNCTION__,__LINE__,"Router: %s \n",(char *)ev->evdata);
-		//writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_routing_table called\n");
 	}
 	
 	if(flags == CCN_SCHEDULE_CANCEL)
 	{
  	 	return -1;
 	}
+
+	nlsr_lock();
 	int res;
 	struct hashtb_enumerator ee;
     	struct hashtb_enumerator *e = &ee;
@@ -1040,9 +1179,12 @@
 	}
 
 	print_routing_table();
+
+	nlsr_unlock();
 	
 	return 0;
 }
+*/
 
 void 
 clear_old_routing_table(void)
@@ -1101,17 +1243,46 @@
 		if ( mapping_no == NO_MAPPING_NUM)
 		{		
 			delete_orig_router_from_npt(rte->dest_router);
+			/*
 			char *router=(char *)malloc(strlen(rte->dest_router)+1);
 			memset(router,0,strlen(rte->dest_router)+1);
 			memcpy(router,rte->dest_router,strlen(rte->dest_router)+1);
 			nlsr->event = ccn_schedule_event(nlsr->sched, 1, &delete_empty_rte, (void *)router , 0);
+			*/
+			hashtb_delete(e);
+			i++;
 		}
-		hashtb_next(e);		
+		else
+		{
+			hashtb_next(e);
+		}		
 	}
 
 	hashtb_end(e);	
 }
 
+void 
+update_routing_table_with_new_hyperbolic_route(long int dest_router_rev_map_index, long int face, double nbr_to_dest_dist)
+{
+	if ( nlsr->debugging )
+		printf("update_routing_table_with_new_hyperbolic_route called\n");
+	if ( nlsr->detailed_logging )
+		writeLogg(__FILE__,__FUNCTION__,__LINE__,"update_routing_table_with_new_hyperbolic_route called\n");
+	
+	char *orig_router=get_router_from_rev_map(dest_router_rev_map_index);
+
+	if (face != NO_NEXT_HOP && face != NO_FACE )
+	{
+		update_routing_table(orig_router,face,nbr_to_dest_dist);
+		if ( nlsr->debugging )
+			printf ("Orig_router: %s Next Hop Face: %ld \n",orig_router,face);
+		if ( nlsr->detailed_logging )
+			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Orig_router: %s Next Hop Face: %ld \n",orig_router,face);
+					
+	}
+	
+
+}
 
 
 void 
@@ -1140,10 +1311,8 @@
 			if (orig_router != NULL )
 			{
 				int next_hop_router_num=get_next_hop_from_calculation(parent,me->mapping,source);
-				//printf(" Next hop router Num: %d ",next_hop_router_num);
 				if ( next_hop_router_num == NO_NEXT_HOP )
 				{
-					//update_npt_with_new_route(orig_router,NO_FACE);
 					if ( nlsr->debugging )
 						printf ("Orig_router: %s Next Hop Face: %d \n",orig_router,NO_FACE);
 					if ( nlsr->detailed_logging )
@@ -1152,9 +1321,7 @@
 				else 
 				{
 					char *next_hop_router=get_router_from_rev_map(next_hop_router_num);
-					//printf("Next hop router name: %s \n",next_hop_router);
 					int next_hop_face=get_next_hop_face_from_adl(next_hop_router);
-					//update_npt_with_new_route(orig_router,next_hop_face);
 					update_routing_table(orig_router,next_hop_face,dist[me->mapping]);
 					if ( nlsr->debugging )
 						printf ("Orig_router: %s Next Hop Face: %d \n",orig_router,next_hop_face);
@@ -1174,9 +1341,15 @@
 int 
 does_face_exist_for_router(char *dest_router, int face_id)
 {
+	if (nlsr->debugging)
+	{
+		printf("does_face_exist_for_router called\n");
+		printf("Dest Router: %s and Face id: %d \n",dest_router, face_id);
+	}
+
 	int ret=0;
 
-	int res,res1;
+	int res;
 	struct routing_table_entry *rte;
 
 	struct hashtb_enumerator ee;
@@ -1188,22 +1361,12 @@
 	if( res == HT_OLD_ENTRY )
 	{
 		rte=e->data;
-		struct hashtb_enumerator eef;
-    		struct hashtb_enumerator *ef = &eef;
-    	
-    		hashtb_start(rte->face_list, ef);
-		res1 = hashtb_seek(ef, &face_id, sizeof(face_id), 0);	
-		if( res1 == HT_OLD_ENTRY)
-		{
-			ret=1;									
-		}
-		else if ( res1 == HT_OLD_ENTRY )
-		{
-			hashtb_delete(ef);
-		}
-		hashtb_end(ef);
+		unsigned *v;
+		v = hashtb_lookup(rte->face_list, &face_id, sizeof(face_id));
+		if (v != NULL)
+			ret = 1;
 	}
-	else if( res == HT_NEW_ENTRY )
+	else
 	{
 		hashtb_delete(e);
 	} 
@@ -1212,3 +1375,27 @@
 
 	return ret;
 }
+
+double 
+get_hyperbolic_distance(long int source, long int dest)
+{
+	double distance;
+	char *src_router=get_router_from_rev_map(source);
+	char *dest_router=get_router_from_rev_map(dest);
+
+	double src_r=get_hyperbolic_r(src_router);
+	double src_theta=get_hyperbolic_r(src_router);	
+
+	double dest_r=get_hyperbolic_r(dest_router);
+	double dest_theta=get_hyperbolic_r(dest_router);
+	if ( src_r != -1 && dest_r != -1 )
+	{
+		distance=acosh(cosh(src_r)*cosh(dest_r)-sinh(src_r)*sinh(dest_r)*cos(src_theta-dest_theta));
+	}
+	else 
+	{
+		distance= -1.0;
+	}
+	
+	return distance;
+}
diff --git a/nlsr_route.h b/nlsr_route.h
index b0eef14..b6dff03 100644
--- a/nlsr_route.h
+++ b/nlsr_route.h
@@ -24,7 +24,7 @@
 struct face_list_entry
 {
 	int next_hop_face;
-	int route_cost;
+	double route_cost;
 };
 
 int route_calculate(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags);
@@ -64,4 +64,8 @@
 void print_all_next_hop(long int *parent,long int source);
 int does_face_exist_for_router(char *dest_router, int face_id);
 
+double get_hyperbolic_distance(long int source, long int dest);
+void sort_hyperbolic_route(double *dist_dest,double *dist_nbr, long int *faces,long int start,long int element);
+void update_routing_table_with_new_hyperbolic_route(long int dest_router_rev_map_index, long int face, double nbr_to_dest_dist);
+
 #endif
diff --git a/nlsr-sync-0.0/nlsr_sync.c b/nlsr_sync.c
similarity index 73%
rename from nlsr-sync-0.0/nlsr_sync.c
rename to nlsr_sync.c
index ee72d79..7ae108a 100644
--- a/nlsr-sync-0.0/nlsr_sync.c
+++ b/nlsr_sync.c
@@ -79,25 +79,60 @@
 
 
 	//--Doing our thing from here
- 	struct ccn_indexbuf cid={0};
+ 	//struct ccn_indexbuf cid={0};
 
-    	struct ccn_indexbuf *components=&cid;
-    	ccn_name_split (name, components);
+    	//struct ccn_indexbuf *components=&cid;
+	struct ccn_indexbuf *components=ccn_indexbuf_create();
+    	res=ccn_name_split (name, components);
+	if ( res < 0 )
+		return 0;
     	//ccn_name_chop(name,components,-3);
 	//process_content_from_sync(name,components);
 
 	struct ccn_charbuf *content_name = ccn_charbuf_create();
 	ccn_name_init(content_name);
+	if (components->n < 2)
+		return 0;
 	res = ccn_name_append_components(content_name, name->buf, components->buf[0], components->buf[components->n - 1]);
 
-	struct ccn_indexbuf cid1={0};
-    	struct ccn_indexbuf *components1=&cid1;
-    	res=ccn_name_split (content_name, components1);
+	if ( res < 0)
+		return 0;
+
+
+	// debugging purpose
+	struct ccn_charbuf *temp=ccn_charbuf_create();
+	ccn_uri_append(temp, content_name->buf, content_name->length, 0);
 	if ( nlsr->debugging )
-		printf("Number of components in name = %d \n",res);
+		printf("Name before chopping: %s \n",ccn_charbuf_as_string(temp));
+	ccn_charbuf_destroy(&temp);
+
+	//struct ccn_indexbuf cid1={0};
+    	//struct ccn_indexbuf *components1=&cid1;
+	struct ccn_indexbuf *components1=ccn_indexbuf_create();
+    	res=ccn_name_split (content_name, components1);
+	if ( res < 0)
+		return 0;		
+
+	if ( nlsr->debugging )
+		{
+			printf("Number of components in name = %d \n",res);
+			printf("Number of components in name as indexbuf->n = %d \n",(int)components1->n);
+		}
 	ccn_name_chop(content_name,components1,-3);
+	if ( nlsr->debugging )
+		printf("Number of components in name as indexbuf->n after chopping= %d \n",(int)components1->n);	
+
+	//debugging purpose
+	struct ccn_charbuf *temp1=ccn_charbuf_create();
+	ccn_uri_append(temp1, content_name->buf, content_name->length, 0);
+	if ( nlsr->debugging )
+		printf("Name after chopping: %s \n",ccn_charbuf_as_string(temp1));
+	ccn_charbuf_destroy(&temp1);
+
 	process_content_from_sync(content_name,components1);
 	ccn_charbuf_destroy(&content_name);
+	ccn_indexbuf_destroy(&components);
+	ccn_indexbuf_destroy(&components1);
 
   return(0);
 }
@@ -133,7 +168,7 @@
 
 	
 	
-	int res,i;
+	int i;
 	int lsa_position=0;
 	int len=0;
 
@@ -152,7 +187,7 @@
 	size_t comp_size;
 	for(i=lsa_position+1+offset;i<interest_comps->n-1;i++)
 	{
-		res=ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size);
+		ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size);
 		len+=1;
 		len+=(int)comp_size;	
 	}
@@ -163,7 +198,7 @@
 
 	for(i=lsa_position+1+offset; i<interest_comps->n-1;i++)
 	{
-		res=ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size);
+		ccn_name_comp_get(interest_ccnb->buf, interest_comps,i,&comp_ptr1, &comp_size);
 		memcpy(neighbor+strlen(neighbor),"/",1);
 		memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1));
 
@@ -425,12 +460,17 @@
 void
 process_content_from_sync(struct ccn_charbuf *content_name, struct ccn_indexbuf *components)
 {
-	int lsa_position;
-	int res;
+	//int lsa_position;
+	//int res;
 	size_t comp_size;
-	const unsigned char *lst;
-	const unsigned char *lsid;
+	char *lst;
+	char *lsid;
+	const unsigned char *second_last_comp;
+	const unsigned char *third_last_comp;
 	const unsigned char *origtime;
+	char *sep=".";
+	char *rem;
+	char *second_comp_type;
 
 	int ls_type;
 	long int ls_id=0;
@@ -452,20 +492,31 @@
 	struct ccn_charbuf *name=ccn_charbuf_create();
 	ccn_name_from_uri(name,nlsr->slice_prefix);
     	ccn_name_split (name, temp_components);
-	lsa_position=temp_components->n-2;
+	//lsa_position=temp_components->n-2;
     	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);
+	ccn_name_comp_get(content_name->buf, components,components->n-2-1,&second_last_comp, &comp_size);	
+	//ls_type=atoi((char *)lst);
+	if (nlsr->debugging)
+		printf("2nd Last Component: %s \n",second_last_comp);
 	
-	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);
-		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);
+	second_comp_type=strtok_r((char *)second_last_comp,sep,&rem);		
+	if ( strcmp( second_comp_type, "lsId" ) == 0 )
+	{	
+		lsid=rem;
+		ls_id=atoi(rem);
+		ccn_name_comp_get(content_name->buf, components,components->n-2-2,&third_last_comp, &comp_size);
+		lst=strtok_r((char *)third_last_comp,sep,&rem);
+		lst=rem;
+		ls_type=atoi(lst);
+		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);
 
@@ -497,95 +548,101 @@
 				printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
 		}
 	}
-	else if(ls_type == LS_TYPE_ADJ)
+	else
 	{
-		res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&origtime, &comp_size);
-		get_name_part(orig_router,content_name,components,2);
-		
-		if ( nlsr->debugging )
-			printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name);
-
-		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) )	
+		ls_type=atoi(rem);
+		lst=rem;
+		if(ls_type == LS_TYPE_ADJ)
 		{
-			int is_new_adj_lsa=check_is_new_adj_lsa(orig_router->name,(char *)lst,(char *)origtime);
-			if ( is_new_adj_lsa == 1 )
+			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 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) )	
 			{
-				if ( nlsr->debugging )
-					printf("New Adj LSA.....\n");	
-				get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
+				int is_new_adj_lsa=check_is_new_adj_lsa(orig_router->name,(char *)lst,(char *)origtime);
+				if ( is_new_adj_lsa == 1 )
+				{
+					if ( nlsr->debugging )
+						printf("New Adj LSA.....\n");	
+					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
 				
-				if ( nlsr->debugging )
-					printf("Content Data: %s \n",content_data);
-				process_incoming_sync_content_lsa(content_data);			
+					if ( nlsr->debugging )
+						printf("Content Data: %s \n",content_data);
+					process_incoming_sync_content_lsa(content_data);			
+				}
+				else
+				{
+					if ( nlsr->debugging )
+						printf("Adj LSA / Newer Adj LSA already exists in LSDB\n");
+					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
+					if ( nlsr->debugging )
+						printf("Content Data: %s \n",content_data);
+				}
 			}
-			else
+			else 
 			{
 				if ( nlsr->debugging )
-					printf("Adj LSA / Newer Adj LSA already exists in LSDB\n");
-				get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
-				if ( nlsr->debugging )
-					printf("Content Data: %s \n",content_data);
+					printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
 			}
 		}
-		else 
+		else if(ls_type == LS_TYPE_COR)
 		{
+			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("Lsa is older than Router LSA refresh time/ Dead Interval\n");
+				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) )	
+			{
+				int is_new_cor_lsa=check_is_new_cor_lsa(orig_router->name,(char *)lst,(char *)origtime);
+				if ( is_new_cor_lsa == 1 )
+				{
+					if ( nlsr->debugging )
+						printf("New Cor LSA.....\n");	
+					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
+				
+					if ( nlsr->debugging )
+						printf("Content Data: %s \n",content_data);
+					process_incoming_sync_content_lsa(content_data);			
+				}
+				else
+				{
+					if ( nlsr->debugging )
+						printf("Cor LSA / Newer Cor LSA already exists in LSDB\n");
+					get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
+					if ( nlsr->debugging )
+						printf("Content Data: %s \n",content_data);
+				}
+			}
+			else 
+			{	
+				if ( nlsr->debugging )
+					printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
+			}
+
 		}
 	}
-	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);
-		
-		if ( nlsr->debugging )
-			printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name);
 
-		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) )	
-		{
-			int is_new_cor_lsa=check_is_new_cor_lsa(orig_router->name,(char *)lst,(char *)origtime);
-			if ( is_new_cor_lsa == 1 )
-			{
-				if ( nlsr->debugging )
-					printf("New Cor LSA.....\n");	
-				get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
-				
-				if ( nlsr->debugging )
-					printf("Content Data: %s \n",content_data);
-				process_incoming_sync_content_lsa(content_data);			
-			}
-			else
-			{
-				if ( nlsr->debugging )
-					printf("Cor LSA / Newer Cor LSA already exists in LSDB\n");
-				get_content_by_content_name(ccn_charbuf_as_string(uri), &content_data);
-				if ( nlsr->debugging )
-					printf("Content Data: %s \n",content_data);
-			}
-		}
-		else 
-		{
-			if ( nlsr->debugging )
-				printf("Lsa is older than Router LSA refresh time/ Dead Interval\n");
-		}
-
-	}
-
-	if (content_data != NULL)
-		free(content_data);
+	//if (content_data != NULL)
+		//free(content_data);
 	ccn_charbuf_destroy(&uri);
 	//01/31/2013	
 	free(time_stamp);
 }
 
-void
+int
 sync_monitor(char *topo_prefix, char *slice_prefix)
 {
 
-    static struct ccns_name_closure nc={0};	
-
+    static struct ccns_name_closure nc={0};
     nlsr->closure = &nc;
     struct ccn_charbuf *prefix = ccn_charbuf_create();
     struct ccn_charbuf *roothash = NULL;
@@ -600,7 +657,6 @@
     ccn_charbuf_reset(topo);
     ccn_name_from_uri(topo, topo_prefix);
     
-
     ccns_slice_set_topo_prefix(nlsr->slice, topo, prefix);
     nlsr->closure->callback = &sync_cb;
     nlsr->ccns = ccns_open(nlsr->ccn, nlsr->slice, nlsr->closure, roothash, NULL);
@@ -608,6 +664,8 @@
     //01/31/2013
     ccn_charbuf_destroy(&prefix);
     ccn_charbuf_destroy(&topo);
+    ccn_charbuf_destroy(&roothash);
+	return 0;
 }
 
 struct ccn_charbuf *
@@ -714,6 +772,7 @@
 create_sync_slice(char *topo_prefix, char *slice_prefix)
 {
     int res;
+    struct ccn *handle;
     struct ccns_slice *slice;
     struct ccn_charbuf *prefix = ccn_charbuf_create();
     struct ccn_charbuf *topo = ccn_charbuf_create();
@@ -727,7 +786,13 @@
 	return -1;
     }
     
-    
+     handle = ccn_create();
+     res = ccn_connect(handle, NULL);
+     if (0 > res) {
+         fprintf(stderr, "Unable to connect to ccnd.\n");
+         return -1;
+     }    
+
     slice = ccns_slice_create();
     
     ccn_charbuf_reset(topo);
@@ -737,10 +802,11 @@
     ccns_slice_set_topo_prefix(slice, topo, prefix);
  
   
-    res = ccns_write_slice(nlsr->ccn, slice, slice_name);
+    res = ccns_write_slice(handle, slice, slice_name);
  
     //01/31/2013
     ccns_slice_destroy(&slice);
+    ccn_destroy(&handle);
     ccn_charbuf_destroy(&prefix);
     ccn_charbuf_destroy(&topo);
     ccn_charbuf_destroy(&clause);
diff --git a/nlsr-sync-0.0/nlsr_sync.h b/nlsr_sync.h
similarity index 86%
rename from nlsr-sync-0.0/nlsr_sync.h
rename to nlsr_sync.h
index 68fc767..d2fe9e5 100644
--- a/nlsr-sync-0.0/nlsr_sync.h
+++ b/nlsr_sync.h
@@ -1,7 +1,7 @@
 #ifndef _NLSR_SYNC_H_
 #define _NLSR_SYNC_H_
 
-void sync_monitor(char *topo_prefix, char *slice_prefix);
+int sync_monitor(char *topo_prefix, char *slice_prefix);
 int write_data_to_repo(char *data,char *name_prefix);
 int create_sync_slice(char *topo_prefix, char *slice_prefix);
 void get_host_name_from_command_string(struct name_prefix *name_part,char *nbr_name_uri, int offset);
diff --git a/nlsrc.c b/nlsrc.c
index 5e35b8c..91a1523 100755
--- a/nlsrc.c
+++ b/nlsrc.c
@@ -21,18 +21,18 @@
 static int 
 usage(char *progname)
 {
-    printf("Usage: %s [OPTIONS...]\n\
-	NLSR API client....\n\
-	nlsrc -s server_ip -p server_port add|del name|neighbor name_prefix [faceX] \n\
-	option -- description\n\n\
-	add|del -- specify whether you want to add or delete.\n\
-	name|neighbor -- specify whether you are adding a name or a neighbor.\n\
-	name_prefix -- name of the prefix for the name|neighbor.\n\
-	faceX -- face ID for neighbor if the third argument is neighbor.\n\n\
-	Examples:\n\
-	1) nlsrc -s 127.0.0.1 -p 9696 add name /ndn/memphis.edu/test \n", progname);
+	printf("Usage: %s [OPTIONS...]\n\
+        NLSR API client....\n\
+        nlsrc -s server_ip -p server_port add|del name|neighbor name_prefix [faceX] \n\
+        option -- description\n\n\
+        add|del -- specify whether you want to add or delete.\n\
+        name|neighbor -- specify whether you are adding a name or a neighbor.\n\
+        name_prefix -- name of the prefix for the name|neighbor.\n\
+        faceX -- face ID for neighbor if the third argument is neighbor.\n\n\
+        Examples:\n\
+        1) nlsrc -s 127.0.0.1 -p 9696 add name /ndn/memphis.edu/test \n", progname);
 
-    exit(1);
+    	exit(1);
 }
 
 int main(int argc, char *argv[])
@@ -41,20 +41,20 @@
 	int len;
 	struct sockaddr_in address;
 	int result;
-	int byteSend;
+	int bytesSent;
 	char *server_address, *server_port;	
 
-	int command_len = 0;
+	int command_len=0;
 	int i;
 
 	if (argc < 8)
-		usage(argv[0]);
+                usage(argv[0]);
 
-	if (strcmp(argv[6], "neighbor") == 0 && argc < 9)
-		usage(argv[0]);
+        if (strcmp(argv[6], "neighbor") == 0 && argc < 9)
+                usage(argv[0]);
 
-	if (strcmp(argv[6], "name") != 0 && strcmp(argv[6], "neighbor") != 0)
-		usage(argv[0]);
+        if (strcmp(argv[6], "name") != 0 && strcmp(argv[6], "neighbor") != 0)
+                usage(argv[0]);
 
 	while ((result = getopt_long(argc, argv, "s:p:", longopts, 0)) != -1) 
 	{
@@ -73,17 +73,14 @@
 	char recv_buffer[1024];
 	bzero(recv_buffer,1024);
 
-	for(i = 5; i < argc; i++)
-		command_len += (strlen(argv[i]) + 1);
-
-	char *command = malloc(command_len);
-	memset(command, 0, command_len + 1);
-
-	for(i = 5; i < argc; i++)
+	for(i=5;i<argc;i++)
+		command_len+=(strlen(argv[i])+1);
+	char *command=malloc(command_len);
+	memset(command, 0, command_len);
+	for(i=5;i<argc;i++)
 	{
-		memcpy(command+strlen(command), argv[i], strlen(argv[i]));
-		
-		if (i < argc - 1)
+		memcpy(command+strlen(command),argv[i],strlen(argv[i]));
+		if ( i < argc-1 )
 			memcpy(command+strlen(command)," ",1);	
 	}
 
@@ -96,21 +93,17 @@
 
 	len = sizeof(address);
 	result = connect(sockfd, (struct sockaddr *)&address, len);
-	
 	if(result == -1) 
 	{
 		perror("oops nlsrc ");
 		exit(1);
 	}
-
 	printf("Command to send: %s \n",command);
-	byteSend=send(sockfd, command, strlen(command),0);
-
+	bytesSent=send(sockfd, command, strlen(command),0);
+	printf("Command len: %d, Bytes sent: %d \n",(int)strlen(command), bytesSent);
 	recv(sockfd, recv_buffer, 1024, 0);
 	printf("%s\n",recv_buffer);
-
 	free(command);
 	close(sockfd);
-
-	return 0;
+	exit(0);
 }
diff --git a/pollux.conf b/pollux.conf
deleted file mode 100644
index 495378e..0000000
--- a/pollux.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-router-name /ndn/memphis.edu/netlab/pollux
-ccnneighbor /ndn/memphis.edu/netlab/macbook face2 10
-ccnneighbor /ndn/memphis.edu/netlab/castor face3 8
-ccnname /ndn/memphis.edu/netlab/pollux/name1
-ccnname /ndn/memphis.edu/netlab/pollux/test
-lsdb-synch-interval 320
-interest-retry 3 
-interest-resend-time 5
-
-
diff --git a/utility.c b/utility.c
index b136c67..f04ba39 100644
--- a/utility.c
+++ b/utility.c
@@ -10,6 +10,10 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include<sys/socket.h>
+#include<arpa/inet.h>
+#include<errno.h>
+#include<netdb.h>
 #include <time.h>
 #include <assert.h>
 #ifdef HAVE_CONFIG_H
@@ -17,6 +21,7 @@
 #endif
 
 
+
 #include <ccn/ccn.h>
 #include <ccn/uri.h>
 #include <ccn/keystore.h>
@@ -117,7 +122,7 @@
 	char *ret;
 	char *logExt;
 	char *defaultLogDir;	
-	int status;
+	//int status;
 	struct stat st;
 	int isLogDirExists=0;
 	char *time=getLocalTimeStamp();
@@ -165,7 +170,8 @@
 			memcpy(logDir,pd.pw_dir,strlen(pd.pw_dir)+1);	
 			memcpy(logDir+strlen(logDir),defaultLogDir,strlen(defaultLogDir)+1);	
 			if(stat(logDir,&st) != 0)
-				status = mkdir(logDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);	
+				mkdir(logDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);	
+			//printf("Status: %d\n",status);
 		}
 	}	
  	memcpy(logFileName,logDir,strlen(logDir)+1);	
@@ -214,3 +220,58 @@
     	}
 }
 
+
+struct sockaddr_in *
+get_ip_from_hostname(char *hostname )
+{
+ 
+
+    struct addrinfo hints, *servinfo, *p;
+    int res; 
+    struct sockaddr_in * ip;
+    memset(&hints, 0, sizeof hints);
+    hints.ai_family = AF_UNSPEC;
+    hints.ai_socktype = SOCK_STREAM;
+
+    if ( (res = getaddrinfo( hostname , "9696", &hints , &servinfo)) != 0)
+    {
+        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(res));
+        return NULL;
+    }
+    int i=0;
+    for(p = servinfo; p != NULL; p = p->ai_next)
+    {
+        ip = (struct sockaddr_in *) p->ai_addr;
+	i++;
+   
+    }
+    freeaddrinfo(servinfo);
+    return ip;
+
+
+}
+
+
+
+int 
+get_ip_from_hostname_02(char * hostname , char* ip)
+{
+    struct hostent *he;
+    struct in_addr **addr_list;
+    int i;
+    if ( (he = gethostbyname( hostname ) ) == NULL)
+    {
+        herror("gethostbyname");
+        return 1;
+    }
+    addr_list = (struct in_addr **) he->h_addr_list;
+    for(i = 0; addr_list[i] != NULL; i++)
+    {
+        strcpy(ip , inet_ntoa(*addr_list[i]) );
+        return 0;
+    }
+    return 1;
+}
+
+
+
diff --git a/utility.h b/utility.h
index 6ae550a..f90c281 100644
--- a/utility.h
+++ b/utility.h
@@ -9,4 +9,6 @@
 
 void startLogging(char *loggingDir);
 void writeLogg(const char *source_file, const char *function, const int line, const char *format, ...);
+struct sockaddr_in * get_ip_from_hostname(char *hostname);
+int get_ip_from_hostname_02(char * hostname , char* ip);
 #endif