First Commit with CCN Sync
diff --git a/nlsr-sync-0.0/1 b/nlsr-sync-0.0/1
new file mode 100755
index 0000000..dfc274e
--- /dev/null
+++ b/nlsr-sync-0.0/1
@@ -0,0 +1,8 @@
+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
new file mode 100755
index 0000000..d92ec7c
--- /dev/null
+++ b/nlsr-sync-0.0/Makefile
@@ -0,0 +1,34 @@
+CC = cc
+CFLAGS = -g -Wall -Wpointer-arith -Wreturn-type -Wstrict-prototypes
+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 utility.c
+NLSRC_SRCS=nlsrc.c
+
+all: $(PROGRAMS)
+
+nlsr: $(NLSR_SRCS)
+	$(CC) $(CFLAGS) $(NLSR_SRCS) -o nlsr $(LIBS) -lm
+
+nlsrc: $(NLSRC_SRCS)
+	$(CC) $(CFLAGS) $(NLSRC_SRCS) -o nlsrc $(LIBS) -lm
+
+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 $(PROGRAMS).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
new file mode 100755
index 0000000..c9070c6
--- /dev/null
+++ b/nlsr-sync-0.0/NLSR_Design.docx
Binary files differ
diff --git a/nlsr-sync-0.0/NLSR_Timing_Diagram.odg b/nlsr-sync-0.0/NLSR_Timing_Diagram.odg
new file mode 100755
index 0000000..820b307
--- /dev/null
+++ b/nlsr-sync-0.0/NLSR_Timing_Diagram.odg
Binary files differ
diff --git a/nlsr-sync-0.0/README.md b/nlsr-sync-0.0/README.md
new file mode 100755
index 0000000..18880a1
--- /dev/null
+++ b/nlsr-sync-0.0/README.md
@@ -0,0 +1,111 @@
+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/macbook.conf b/nlsr-sync-0.0/macbook.conf
new file mode 100755
index 0000000..19b6c30
--- /dev/null
+++ b/nlsr-sync-0.0/macbook.conf
@@ -0,0 +1,17 @@
+#----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/
+#------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
+
+logdir /Users/akmhoque/NLSR2.0
diff --git a/nlsr-sync-0.0/nlsr.c b/nlsr-sync-0.0/nlsr.c
new file mode 100755
index 0000000..e3b43ae
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr.c
@@ -0,0 +1,1099 @@
+#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"
+
+
+#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,*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);
+
+	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_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 
+	{
+		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;
+}
+
+char *
+process_api_client_command(char *command)
+{
+	char *msg;
+	msg=(char *)malloc(100);	
+	memset(msg,100,0);
+	
+	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 )
+			{
+				add_nbr_to_adl(np,face_id);
+				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 < 0 )
+	{
+		timeout.tv_sec=1;
+		timeout.tv_usec=0;
+	}
+	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;
+	}
+
+	
+	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; 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();	
+
+	/* 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);
+
+	//To Do: has to destroy the face_list one by one 	
+
+	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 = inet_addr("127.0.0.1");
+	server_address.sin_port = 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);
+	
+	
+
+
+	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;
+
+	//create_sync_slice();
+
+	nlsr->topo_prefix=(char *)malloc(strlen("/ndn/routing/nlsr")+1);
+	memset(nlsr->topo_prefix,strlen("/ndn/routing/nlsr")+1,0);
+	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,strlen("/ndn/routing/nlsr/LSA")+1,0);
+	memcpy(nlsr->slice_prefix,"/ndn/routing/nlsr/LSA",strlen("/ndn/routing/nlsr/LSA"));
+
+	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 ( daemon_mode == 1 )
+	{
+		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);
+
+	create_sync_slice(nlsr->topo_prefix, nlsr->slice_prefix);	
+
+	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);
+
+	print_name_prefix_from_npl();
+	print_adjacent_from_adl();
+	build_and_install_name_lsas();
+	print_name_lsdb();	
+
+	sync_monitor(nlsr->topo_prefix,nlsr->slice_prefix);
+
+	write_name_lsdb_to_repo(nlsr->slice_prefix);
+
+	//write_data_to_repo();
+
+	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, 0);
+			}
+			if (!(nlsr->sched && nlsr->ccn))
+			{	      
+				break;
+			}
+		}
+
+	}
+	
+
+	return 0;
+}
+
diff --git a/nlsr-sync-0.0/nlsr.conf b/nlsr-sync-0.0/nlsr.conf
new file mode 100755
index 0000000..ced844f
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr.conf
@@ -0,0 +1,10 @@
+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
new file mode 100755
index 0000000..095e128
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr.h
@@ -0,0 +1,121 @@
+#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 9696
+
+
+struct name_prefix
+{
+	char *name;
+	int length;
+};
+
+struct linkStateDatabase
+{
+	struct hashtb *name_lsdb;
+	struct hashtb *adj_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;
+	
+};
+
+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
new file mode 100755
index 0000000..54d8954
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_adl.c
@@ -0,0 +1,919 @@
+#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>
+#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)
+{
+	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;
+		
+
+		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("	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);
+
+	//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);
+}
+
+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;
+}
+
+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;
+}
+
diff --git a/nlsr-sync-0.0/nlsr_adl.h b/nlsr-sync-0.0/nlsr_adl.h
new file mode 100755
index 0000000..5e9fa5a
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_adl.h
@@ -0,0 +1,51 @@
+#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;
+	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);
+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);
+#endif
diff --git a/nlsr-sync-0.0/nlsr_fib.c b/nlsr-sync-0.0/nlsr_fib.c
new file mode 100755
index 0000000..e89e80d
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_fib.c
@@ -0,0 +1,224 @@
+#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"
+
+
+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 = (~0U) >> 1;
+
+	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)
+{
+	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
new file mode 100755
index 0000000..ce5e6d1
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_fib.h
@@ -0,0 +1,11 @@
+#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
new file mode 100755
index 0000000..d6d24ae
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_lsdb.c
@@ -0,0 +1,2099 @@
+#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));
+
+}
+
+
+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)
+{
+	
+	
+	//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);	
+
+	char lsid[10];
+	memset(lsid,0,10);
+	sprintf(lsid,"%ld",ls_id);
+	memcpy(key+strlen(key),slice_prefix,strlen(slice_prefix));
+	memcpy(key+strlen(key),"/",1);
+	memcpy(key+strlen(key),lst,strlen(lst));
+	memcpy(key+strlen(key),"/",1);
+	memcpy(key+strlen(key),lsid,strlen(lsid));
+	memcpy(key+strlen(key),"/",1);
+	memcpy(key+strlen(key),orig_time,strlen(orig_time));
+	memcpy(key+strlen(key),orig_router,strlen(orig_router));
+	
+	//printf("Key: %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 *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;
+		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);
+	//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];
+		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 )
+							{
+								//printf("Added in npt \n");
+								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_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);
+
+			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();
+	
+	//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);
+	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);
+
+
+	/* Filling Up Body Data */
+
+	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);
+
+
+
+	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++;
+
+
+}
+
+
+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);
+	//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 ));
+
+		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)
+				{				
+					//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);
+					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);
+
+		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);
+	//print_adj_lsa(adj_lsa);
+	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)
+{
+	//printf("build_others_adj_lsa called \n");
+	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; 
+}
+
+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)
+{
+	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;
+}
+
+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 )
+		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;
+		//printf("NAME LSA found\n");
+
+		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;
+		//printf("Adj LSA found\n");
+
+		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);
+		free(temp_length);
+		ccn_charbuf_append_string(lsa_data,"|");
+
+		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,"|");
+
+		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);
+		free(temp_nl);
+		ccn_charbuf_append_string(lsa_data,"|");
+
+		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);	
+	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)
+{
+	//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;
+	}
+
+
+
+	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);
+	
+	//print_name_lsdb();
+	
+	nlsr_unlock();
+
+	return 0;
+}
+
+int 
+delete_adj_lsa(struct ccn_schedule *sched, void *clienth, struct ccn_scheduled_event *ev, int flags)
+{
+	//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 )
+		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;
+	}
+
+	//print_adj_lsdb();
+
+	nlsr_unlock();
+
+	return 0;
+}
+
+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);
+	
+	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);	
+					//printf("Key:%s Length:%d\n",key,(int)strlen(key));
+				
+					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();
+				//lsa_change_count++;
+			}	
+		}
+		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);	
+				//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++;
+			}
+		}
+
+		hashtb_next(e);		
+	}
+
+	hashtb_end(e);
+	
+	free(time_stamp);
+
+	
+}
+
+void
+refresh_adj_lsdb(void)
+{
+	//printf("refresh_adj_lsdb called \n");
+
+	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);
+		//printf("LSA Life Time: %ld \n",lsa_life_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 )
+			{
+				//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 )
+					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 )
+			{
+				//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);
+				//printf("Adjacent LSA key: %s \n",key);				
+				nlsr->event = ccn_schedule_event(nlsr->sched, 10, &delete_adj_lsa, (void *)key, 0);
+			}
+		}
+
+		
+
+		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();
+
+	//printf("refresh_lsdb called \n");
+
+	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();
+
+	nlsr->event = ccn_schedule_event(nlsr->sched, 60000000, &refresh_lsdb, NULL, 0);
+	
+	nlsr_unlock();
+	return 0;
+}
+
+void
+write_name_lsa_to_repo(char *repo_content_prefix, struct name_prefix *lsa_id)
+{
+	printf("Content Preifx: %s\n",repo_content_prefix);
+
+	
+	struct ccn_charbuf *lsa_data=ccn_charbuf_create();		
+	get_name_lsa_data(lsa_data,lsa_id);
+	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);
+		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);
+		
+		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,strlen(key)+1,0);
+		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);
+	
+
+}
diff --git a/nlsr-sync-0.0/nlsr_lsdb.h b/nlsr-sync-0.0/nlsr_lsdb.h
new file mode 100755
index 0000000..4e8a8d1
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_lsdb.h
@@ -0,0 +1,91 @@
+#ifndef _NLSR_LSDB_H_
+#define _NLSR_LSDB_H_
+
+#define LS_TYPE_ADJ 1
+#define LS_TYPE_NAME 2
+
+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;
+};
+
+
+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);
+
+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);
+
+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 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);
+
+#endif
diff --git a/nlsr-sync-0.0/nlsr_ndn.c b/nlsr-sync-0.0/nlsr_ndn.c
new file mode 100755
index 0000000..9af0a05
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_ndn.c
@@ -0,0 +1,1613 @@
+#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);
+
+	//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 
+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);
+
+}
+
+
+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,
+        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)
+{
+	//printf("process_incoming_content called \n");
+	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);
+
+	//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);
+	}
+
+}
+
+
+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 )
+		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);
+	//printf("Content data: %s\n",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);
+	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_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
+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);
+	}
+	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
+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);
+
+
+}
+
+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)
+{
+	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);
+		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 info interest on name prefix : %s \n",int_name);
+		if ( nlsr->detailed_logging )
+			writeLogg(__FILE__,__FUNCTION__,__LINE__,"Sending info 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("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);
+
+}
+
+
+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-sync-0.0/nlsr_ndn.h b/nlsr-sync-0.0/nlsr_ndn.h
new file mode 100755
index 0000000..1feab1e
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_ndn.h
@@ -0,0 +1,37 @@
+#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);
+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-sync-0.0/nlsr_npl.c b/nlsr-sync-0.0/nlsr_npl.c
new file mode 100755
index 0000000..a2e2271
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_npl.c
@@ -0,0 +1,174 @@
+#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
new file mode 100755
index 0000000..4fce119
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_npl.h
@@ -0,0 +1,15 @@
+#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
new file mode 100755
index 0000000..e3c8483
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_npt.c
@@ -0,0 +1,1092 @@
+#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)
+{
+
+	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--)
+			{
+				//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("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 ( 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]);
+					}
+				}
+			}
+			
+			
+			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 if ( nlsr->multi_path_face_num == 0)
+				{
+					last_face=num_face-nlsr->multi_path_face_num;
+				}
+			}			
+
+			for( j=first_face; j>= last_face; j--)
+			{
+
+				if ( is_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_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_delete(enle); has to delete later
+		}
+
+		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);
+		//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;		
+		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: %d \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;//=(struct face_list_entry *)malloc(sizeof(struct face_list_entry));
+			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_delete(ef);
+		}
+		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);
+}
+
+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)
+{
+	
+	
+	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;
+
+						//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);
+							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);
+
+					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_next(ef);	
+			}
+		}
+		hashtb_end(ef);
+		
+			
+		hashtb_next(e);		
+	}
+
+	hashtb_end(e);
+
+}
+
+void
+update_npt_with_new_route(void)
+{
+	clean_old_fib_entries_from_npt();
+	add_new_fib_entries_to_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_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_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
new file mode 100755
index 0000000..587c8be
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_npt.h
@@ -0,0 +1,32 @@
+#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(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);
+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
new file mode 100755
index 0000000..8537b2e
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_route.c
@@ -0,0 +1,1214 @@
+#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 <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);
+		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 ) )
+		{
+			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);
+		}
+
+		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);
+		
+	}
+	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;
+	/* Initial 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);
+	//free(dist);	
+}
+
+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]);
+	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
+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)
+{
+	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);
+		
+		/*
+		//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 )
+	{
+		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: %d \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);
+		//writeLogg(__FILE__,__FUNCTION__,__LINE__,"print_routing_table called\n");
+	}
+	
+	if(flags == CCN_SCHEDULE_CANCEL)
+	{
+ 	 	return -1;
+	}
+	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();
+	
+	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_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);
+				//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 )
+						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);
+					//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);
+					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)
+{
+	int ret=0;
+
+	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, &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);
+	}
+	else if( res == HT_NEW_ENTRY )
+	{
+		hashtb_delete(e);
+	} 
+	
+	hashtb_end(e);
+
+	return ret;
+}
diff --git a/nlsr-sync-0.0/nlsr_route.h b/nlsr-sync-0.0/nlsr_route.h
new file mode 100755
index 0000000..b0eef14
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_route.h
@@ -0,0 +1,67 @@
+#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;
+	int 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);
+
+#endif
diff --git a/nlsr-sync-0.0/nlsr_sync.c b/nlsr-sync-0.0/nlsr_sync.c
new file mode 100644
index 0000000..3839f67
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_sync.c
@@ -0,0 +1,422 @@
+#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>
+
+#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_sync.h"
+#include "nlsr_lsdb.h"
+
+int 
+get_lsa_position(struct ccn_charbuf * ccnb, struct ccn_indexbuf *comps)
+{
+
+	
+	
+	int res,i;
+	int lsa_position=0;
+	int name_comps=(int)comps->n;
+
+	for(i=0;i<name_comps;i++)
+	{
+		res=ccn_name_comp_strcmp(ccnb->buf,comps,i,"LSA");
+		if( res == 0)
+		{
+			lsa_position=i;
+			break;
+		}	
+	}
+
+	return lsa_position;
+
+}
+
+void 
+get_name_part(struct name_prefix *name_part,struct ccn_charbuf * interest_ccnb, struct ccn_indexbuf *interest_comps, int offset)
+{
+
+	
+	
+	int res,i;
+	int lsa_position=0;
+	int len=0;
+
+	lsa_position=get_lsa_position(interest_ccnb,interest_comps);
+
+	const unsigned char *comp_ptr1;
+	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);
+		len+=1;
+		len+=(int)comp_size;	
+	}
+	len++;
+
+	char *neighbor=(char *)malloc(len);
+	memset(neighbor,0,len);
+
+	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);
+		memcpy(neighbor+strlen(neighbor),"/",1);
+		memcpy(neighbor+strlen(neighbor),(char *)comp_ptr1,strlen((char *)comp_ptr1));
+
+	}
+
+	name_part->name=(char *)malloc(strlen(neighbor)+1);
+	memset(name_part->name,0,strlen(neighbor)+1);
+	memcpy(name_part->name,neighbor,strlen(neighbor)+1);
+	name_part->length=strlen(neighbor)+1;
+
+	
+}
+
+
+char *
+get_content_by_content_name(char *content_name)
+{
+
+    struct ccn_charbuf *name = NULL;
+    struct ccn_charbuf *templ = NULL;
+    struct ccn_charbuf *resultbuf = NULL;
+    struct ccn_parsed_ContentObject pcobuf = { 0 };
+    int res;
+    int allow_stale = 0;
+    int content_only = 1;
+    int scope = -1;
+    const unsigned char *ptr;
+    size_t length;
+    int resolve_version = CCN_V_HIGHEST;
+    int timeout_ms = 3000;
+    const unsigned lifetime_default = CCN_INTEREST_LIFETIME_SEC << 12;
+    unsigned lifetime_l12 = lifetime_default;
+    int get_flags = 0;
+    
+
+    name = ccn_charbuf_create();
+    res = ccn_name_from_uri(name,content_name);
+    if (res < 0) {
+        fprintf(stderr, "Bad ccn URI: %s\n", content_name);
+        exit(1);
+    }
+  
+   
+	if (allow_stale || lifetime_l12 != lifetime_default || scope != -1) {
+        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> */
+		if (allow_stale) {
+			ccn_charbuf_append_tt(templ, CCN_DTAG_AnswerOriginKind, CCN_DTAG);
+			ccnb_append_number(templ,
+							   CCN_AOK_DEFAULT | CCN_AOK_STALE);
+			ccn_charbuf_append_closer(templ); /* </AnswerOriginKind> */
+		}
+        if (scope != -1) {
+            ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope);
+        }
+		if (lifetime_l12 != lifetime_default) {
+			/*
+			 * Choose the interest lifetime so there are at least 3
+			 * expressions (in the unsatisfied case).
+			 */
+			unsigned char buf[3] = { 0 };
+			int i;
+			for (i = sizeof(buf) - 1; i >= 0; i--, lifetime_l12 >>= 8)
+				buf[i] = lifetime_l12 & 0xff;
+			ccnb_append_tagged_blob(templ, CCN_DTAG_InterestLifetime, buf, sizeof(buf));
+		}
+        ccn_charbuf_append_closer(templ); /* </Interest> */
+    }
+    resultbuf = ccn_charbuf_create();
+    if (resolve_version != 0) {
+        res = ccn_resolve_version(nlsr->ccn, name, resolve_version, 500);
+        if (res >= 0) {
+            ccn_uri_append(resultbuf, name->buf, name->length, 1);
+            //fprintf(stderr, "== %s\n",ccn_charbuf_as_string(resultbuf));
+            resultbuf->length = 0;
+        }
+    }
+    res = ccn_get(nlsr->ccn, name, templ, timeout_ms, resultbuf, &pcobuf, NULL, get_flags);
+    if (res >= 0) {
+        ptr = resultbuf->buf;
+        length = resultbuf->length;
+        if (content_only)
+            ccn_content_get_value(ptr, length, &pcobuf, &ptr, &length);
+    }
+    ccn_charbuf_destroy(&resultbuf);
+    ccn_charbuf_destroy(&templ);
+    ccn_charbuf_destroy(&name);   
+	return (char *)ptr;
+}
+
+void
+process_content_from_sync(struct ccn_charbuf *content_name, struct ccn_indexbuf *components)
+{
+	int lsa_position;
+	int res;
+	size_t comp_size;
+	const unsigned char *lst;
+	const unsigned char *lsid;
+	const unsigned char *origtime;
+
+	int ls_type;
+	long int ls_id=0;
+
+	struct ccn_charbuf *uri = ccn_charbuf_create();
+	ccn_uri_append(uri, content_name->buf, content_name->length, 0);	
+
+	struct name_prefix *orig_router=(struct name_prefix *)malloc(sizeof(struct name_prefix));
+	
+	lsa_position=get_lsa_position(content_name, components);
+
+	res=ccn_name_comp_get(content_name->buf, components,lsa_position+1,&lst, &comp_size);
+	
+	printf("Ls Type: %s\n",lst);
+	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);
+		printf("Ls ID: %s\nOrig Time: %s\nOrig Router: %s\n",lsid,origtime,orig_router->name);
+
+		int is_new_name_lsa=check_is_new_name_lsa(orig_router->name,(char *)lst,(char *)lsid,(char *)origtime);
+		if ( is_new_name_lsa == 1 )
+		{
+			printf("New NAME LSA.....\n");	
+			char *content_data=get_content_by_content_name(ccn_charbuf_as_string(uri));
+			printf("Content Data: %s \n",content_data);
+		}
+		else 
+		{
+			printf("Name LSA / Newer Name LSA already xists in LSDB\n");
+			char *content_data=get_content_by_content_name(ccn_charbuf_as_string(uri));
+			printf("Content Data: %s \n",content_data);
+		}
+	}
+	else if(ls_type == LS_TYPE_ADJ)
+	{
+		res=ccn_name_comp_get(content_name->buf, components,lsa_position+2,&origtime, &comp_size);
+		get_name_part(orig_router,content_name,components,2);
+		printf("Orig Time: %s\nOrig Router: %s\n",origtime,orig_router->name);
+	
+		int is_new_adj_lsa=check_is_new_adj_lsa(orig_router->name,(char *)lst,(char *)origtime);
+		if ( is_new_adj_lsa == 1 )
+		{
+			printf("New Adj LSA.....\n");	
+			char *content_data=get_content_by_content_name(ccn_charbuf_as_string(uri));
+			printf("Content Data: %s \n",content_data);			
+		}
+		else
+		{
+
+			printf("Adj LSA / Newer Adj LSA already exists in LSDB\n");
+			char *content_data=get_content_by_content_name(ccn_charbuf_as_string(uri));
+			printf("Content Data: %s \n",content_data);
+		}
+
+	}
+
+	ccn_charbuf_destroy(&uri);
+
+}
+
+int
+sync_callback(struct ccns_name_closure *nc,
+        struct ccn_charbuf *lhash,
+        struct ccn_charbuf *rhash,
+        struct ccn_charbuf *name)
+{
+
+
+    	struct ccn_indexbuf cid={0};
+
+    	struct ccn_indexbuf *components=&cid;
+    	ccn_name_split (name, components);
+    	ccn_name_chop(name,components,-3);
+
+	process_content_from_sync(name,components);
+
+    	return(0);
+}
+
+
+void
+sync_monitor(char *topo_prefix, char *slice_prefix)
+{
+
+    static struct ccns_name_closure nc={0};	
+
+    nlsr->closure = &nc;
+    struct ccn_charbuf *prefix = ccn_charbuf_create();
+    struct ccn_charbuf *roothash = NULL;
+    struct ccn_charbuf *topo = ccn_charbuf_create(); 
+    nlsr->slice = ccns_slice_create();
+    ccn_charbuf_reset(prefix);
+    ccn_charbuf_reset(topo);
+ 
+    ccn_charbuf_reset(prefix);
+    ccn_name_from_uri(prefix, slice_prefix);
+            
+    ccn_charbuf_reset(topo);
+    ccn_name_from_uri(topo, topo_prefix);
+    
+
+    ccns_slice_set_topo_prefix(nlsr->slice, topo, prefix);
+    nlsr->closure->callback = &sync_callback;
+    nlsr->ccns = ccns_open(nlsr->ccn, nlsr->slice, nlsr->closure, roothash, NULL);
+
+}
+
+struct ccn_charbuf *
+make_template(int scope)
+{
+    struct ccn_charbuf *templ = NULL;
+    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> */
+    if (0 <= scope && scope <= 2)
+        ccnb_tagged_putf(templ, CCN_DTAG_Scope, "%d", scope);
+    ccn_charbuf_append_closer(templ); /* </Interest> */
+    return(templ);
+}
+
+void
+write_data_to_repo(char *data, char *name_prefix)
+{
+
+    struct ccn_charbuf *name = NULL;
+    struct ccn_seqwriter *w = NULL;
+    int blocksize = 1024;
+    int freshness = -1;
+    int torepo = 1;
+    int scope = 1;
+    int res;
+    size_t blockread;
+    struct ccn_charbuf *templ;
+    
+    name = ccn_charbuf_create();
+    res = ccn_name_from_uri(name, name_prefix);
+    if (res < 0) {
+        fprintf(stderr, "bad CCN URI: %s\n",name_prefix);
+        exit(1);
+    }
+  
+    
+    w = ccn_seqw_create(nlsr->ccn, name);
+    if (w == NULL) {
+        fprintf(stderr, "ccn_seqw_create failed\n");
+        exit(1);
+    }
+    ccn_seqw_set_block_limits(w, blocksize, blocksize);
+    if (freshness > -1)
+        ccn_seqw_set_freshness(w, freshness);
+    if (torepo) {
+        struct ccn_charbuf *name_v = ccn_charbuf_create();
+        ccn_seqw_get_name(w, name_v);
+        ccn_name_from_uri(name_v, "%C1.R.sw");
+        ccn_name_append_nonce(name_v);
+        templ = make_template(scope);
+        res = ccn_get(nlsr->ccn, name_v, templ, 60000, NULL, NULL, NULL, 0);
+        ccn_charbuf_destroy(&templ);
+        ccn_charbuf_destroy(&name_v);
+        if (res < 0) {
+            fprintf(stderr, "No response from repository\n");
+            exit(1);
+        }
+    }
+
+
+
+
+	blockread = 0;
+	//struct ccn_charbuf *buf=ccn_charbuf_create();
+	//get_name_lsdb_summary(buf);	
+	//blockread=buf->length;
+
+	blockread=strlen(data);
+
+	if (blockread > 0) {
+        	//res = ccn_seqw_write(w, ccn_charbuf_as_string(buf), blockread);
+		res = ccn_seqw_write(w, data, blockread);	
+        while (res == -1) {
+            ccn_run(nlsr->ccn, 100);
+            	//res = ccn_seqw_write(w, ccn_charbuf_as_string(buf), blockread);
+	       res = ccn_seqw_write(w, data, blockread);
+           }
+    	}
+
+	
+	ccn_run(nlsr->ccn, 1);
+   
+    ccn_seqw_close(w);
+    //ccn_charbuf_destroy(&buf);
+    ccn_charbuf_destroy(&name);
+}
+
+
+int
+create_sync_slice(char *topo_prefix, char *slice_prefix)
+{
+    int res;
+    struct ccns_slice *slice;
+    struct ccn_charbuf *prefix = ccn_charbuf_create();
+    struct ccn_charbuf *topo = ccn_charbuf_create();
+    struct ccn_charbuf *clause = ccn_charbuf_create();
+    struct ccn_charbuf *slice_name = ccn_charbuf_create();
+    struct ccn_charbuf *slice_uri = ccn_charbuf_create();
+    
+    if (prefix == NULL || topo == NULL || clause == NULL ||
+        slice_name == NULL || slice_uri == NULL) {
+        fprintf(stderr, "Unable to allocate required memory.\n");
+        exit(1);
+    }
+    
+    
+    slice = ccns_slice_create();
+    
+    ccn_charbuf_reset(topo);
+    ccn_name_from_uri(topo, topo_prefix);
+    ccn_charbuf_reset(prefix);
+    ccn_name_from_uri(prefix,slice_prefix );
+    ccns_slice_set_topo_prefix(slice, topo, prefix);
+ 
+  
+    res = ccns_write_slice(nlsr->ccn, slice, slice_name);
+  
+    ccns_slice_destroy(&slice);
+    ccn_charbuf_destroy(&prefix);
+    ccn_charbuf_destroy(&topo);
+    ccn_charbuf_destroy(&clause);
+    ccn_charbuf_destroy(&slice_name);
+    ccn_charbuf_destroy(&slice_uri);
+	
+    return 0;
+}
+
diff --git a/nlsr-sync-0.0/nlsr_sync.h b/nlsr-sync-0.0/nlsr_sync.h
new file mode 100644
index 0000000..5fe9a52
--- /dev/null
+++ b/nlsr-sync-0.0/nlsr_sync.h
@@ -0,0 +1,8 @@
+#ifndef _NLSR_SYNC_H_
+#define _NLSR_SYNC_H_
+
+void sync_monitor(char *topo_prefix, char *slice_prefix);
+void write_data_to_repo(char *data,char *name_prefix);
+int create_sync_slice(char *topo_prefix, char *slice_prefix);
+
+#endif
diff --git a/nlsr-sync-0.0/nlsrc.c b/nlsr-sync-0.0/nlsrc.c
new file mode 100755
index 0000000..44ce2ad
--- /dev/null
+++ b/nlsr-sync-0.0/nlsrc.c
@@ -0,0 +1,101 @@
+//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\
+	add/del, -- adding/deleting operation\n\
+	name/neighbor, -- Operation for name/neighbor\n\
+	name_name, -- Name prefix for name/neighbor\n\
+	faceX, -- Face Id for neighbor if third argument is neighbor\n", progname);
+
+    exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+	int sockfd;
+	int len;
+	struct sockaddr_in address;
+	int result;
+	int byteSend;
+	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]);
+
+	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,command_len+1,0);
+	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 = 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);
+	byteSend=send(sockfd, command, strlen(command),0);
+	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
new file mode 100755
index 0000000..495378e
--- /dev/null
+++ b/nlsr-sync-0.0/pollux.conf
@@ -0,0 +1,10 @@
+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/nlsr-sync-0.0/simulation.h b/nlsr-sync-0.0/simulation.h
new file mode 100755
index 0000000..76c4861
--- /dev/null
+++ b/nlsr-sync-0.0/simulation.h
@@ -0,0 +1,8 @@
+#ifndef _SIMULATION_H_
+#define _SIMULATION_H_
+
+
+
+
+
+#endif
diff --git a/nlsr-sync-0.0/todo.txt b/nlsr-sync-0.0/todo.txt
new file mode 100755
index 0000000..77fccea
--- /dev/null
+++ b/nlsr-sync-0.0/todo.txt
@@ -0,0 +1,9 @@
+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
new file mode 100755
index 0000000..e616d20
--- /dev/null
+++ b/nlsr-sync-0.0/transfer.sh
@@ -0,0 +1,5 @@
+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
new file mode 100755
index 0000000..b136c67
--- /dev/null
+++ b/nlsr-sync-0.0/utility.c
@@ -0,0 +1,216 @@
+#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 <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);	
+		}
+    	}
+}
+
diff --git a/nlsr-sync-0.0/utility.h b/nlsr-sync-0.0/utility.h
new file mode 100755
index 0000000..6ae550a
--- /dev/null
+++ b/nlsr-sync-0.0/utility.h
@@ -0,0 +1,12 @@
+#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, ...);
+#endif