diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 3ca2279..84b5e6d 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -6,12 +6,9 @@
 #include <sstream>
 
 #include "nlsr.hpp"
-#include "nlsr_conf_param.hpp"
 #include "nlsr_conf_processor.hpp"
-#include "nlsr_lsdb.hpp"
-#include "nlsr_logger.hpp"
-//test purpose of NLSR
-#include "nlsr_test.hpp"
+#include "utility/nlsr_logger.hpp"
+
 
 namespace nlsr
 {
@@ -23,24 +20,37 @@
     Nlsr::nlsrRegistrationFailed(const ndn::Name& name)
     {
         cerr << "ERROR: Failed to register prefix in local hub's daemon" << endl;
-        getNlsrFace().shutdown();
+        getNlsrFace()->shutdown();
     }
 
 
     void
     Nlsr::setInterestFilterNlsr(const string& name)
     {
-        getNlsrFace().setInterestFilter(name,
-                                        func_lib::bind(&interestManager::processInterest, &im,
-                                                boost::ref(*this), _1, _2),
-                                        func_lib::bind(&Nlsr::nlsrRegistrationFailed, this, _1));
+        getNlsrFace()->setInterestFilter(name,
+                                         func_lib::bind(&interestManager::processInterest, &im,
+                                                 boost::ref(*this), _1, _2),
+                                         func_lib::bind(&Nlsr::nlsrRegistrationFailed, this, _1));
     }
 
+    void
+    Nlsr::initNlsr()
+    {
+        confParam.buildRouterPrefix();
+        nlsrLogger.initNlsrLogger(confParam.getLogDir());
+        nlsrLsdb.setLsaRefreshTime(confParam.getLsaRefreshTime());
+        nlsrLsdb.setThisRouterPrefix(confParam.getRouterPrefix());
+        fib.setFibEntryRefreshTime(2*confParam.getLsaRefreshTime());
+        km.initKeyManager(confParam);
+        sm.setSeqFileName(confParam.getSeqFileDir());
+        sm.initiateSeqNoFromFile();
+        slh.setSyncPrefix(confParam.getChronosyncSyncPrefix());
+    }
 
     void
     Nlsr::startEventLoop()
     {
-        getNlsrFace().processEvents();
+        io->run();
     }
 
     int
@@ -97,19 +107,7 @@
     {
         return EXIT_FAILURE;
     }
-    nlsr_.getConfParameter().buildRouterPrefix();
-    nlsr_.getNlsrLogger().initNlsrLogger(nlsr_.getConfParameter().getLogDir());
-    //src::logger lg;
-    //BOOST_LOG(lg) << "Some log record from nlsr.cpp";
-    //for(int j=0; j< 1000; j++)
-    //{
-    //	BOOST_LOG(lg) << "Some log record from nlsr.cpp "<<j;
-    //}
-    nlsr_.getLsdb().setLsaRefreshTime(nlsr_.getConfParameter().getLsaRefreshTime());
-    nlsr_.getFib().setFibEntryRefreshTime(
-                                    2*nlsr_.getConfParameter().getLsaRefreshTime());
-    nlsr_.getLsdb().setThisRouterPrefix(nlsr_.getConfParameter().getRouterPrefix());
-    nlsr_.getKeyManager().initKeyManager(nlsr_.getConfParameter());
+    nlsr_.initNlsr();
     /* debugging purpose start */
     cout <<	nlsr_.getConfParameter();
     nlsr_.getAdl().printAdl();
@@ -118,9 +116,15 @@
     nlsr_.getLsdb().buildAndInstallOwnNameLsa(nlsr_);
     nlsr_.getLsdb().buildAndInstallOwnCorLsa(nlsr_);
     nlsr_.setInterestFilterNlsr(nlsr_.getConfParameter().getRouterPrefix());
+    nlsr_.setInterestFilterNlsr(nlsr_.getConfParameter().getChronosyncLsaPrefix()+
+                                nlsr_.getConfParameter().getRouterPrefix());
+    nlsr_.setInterestFilterNlsr(nlsr_.getConfParameter().getRootKeyPrefix());
+    nlsr_.getSlh().createSyncSocket(nlsr_);
+    nlsr_.getSlh().publishKeyUpdate(nlsr_.getKeyManager());
+    nlsr_.getSlh().publishRoutingUpdate(nlsr_.getSm(),
+                                        nlsr_.getConfParameter().getChronosyncLsaPrefix()
+                                        + nlsr_.getConfParameter().getRouterPrefix());
     nlsr_.getIm().scheduleInfoInterest(nlsr_,1);
-    //testing purpose
-    nlsr_.getNlsrTesting().schedlueAddingLsas(nlsr_);
     try
     {
         nlsr_.startEventLoop();
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index cbf2af9..51218f0 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -8,17 +8,18 @@
 #include "nlsr_conf_param.hpp"
 #include "nlsr_adl.hpp"
 #include "nlsr_npl.hpp"
-#include "nlsr_im.hpp"
-#include "nlsr_dm.hpp"
+#include "communication/nlsr_im.hpp"
+#include "communication/nlsr_dm.hpp"
 #include "nlsr_lsdb.hpp"
 #include "nlsr_sm.hpp"
-#include "nlsr_rt.hpp"
-#include "nlsr_npt.hpp"
-#include "nlsr_fib.hpp"
-#include "nlsr_logger.hpp"
-#include "nlsr_km.hpp"
-//testing
-#include "nlsr_test.hpp"
+#include "route/nlsr_rt.hpp"
+#include "route/nlsr_npt.hpp"
+#include "route/nlsr_fib.hpp"
+#include "utility/nlsr_logger.hpp"
+#include "security/nlsr_km.hpp"
+#include "communication/nlsr_slh.hpp"
+
+
 
 namespace nlsr
 {
@@ -31,9 +32,8 @@
     public:
         Nlsr()
             : io(ndn::make_shared<boost::asio::io_service>())
-            , nlsrFace(io)
+            , nlsrFace(make_shared<ndn::Face>(io))
             , scheduler(*io)
-            , configFileName()
             , confParam()
             , adl()
             , npl()
@@ -41,6 +41,8 @@
             , dm()
             , sm()
             , km()
+            , isDaemonProcess(false)
+            , configFileName("nlsr.conf")
             , nlsrLsdb()
             , adjBuildCount(0)
             , isBuildAdjLsaSheduled(0)
@@ -49,12 +51,9 @@
             , routingTable()
             , npt()
             , fib()
+            , slh(io)
             , nlsrLogger()
-            , nlsrTesting()
-        {
-            isDaemonProcess=false;
-            configFileName="nlsr.conf";
-        }
+        {}
 
         void nlsrRegistrationFailed(const ndn::Name& name);
 
@@ -108,20 +107,16 @@
             return scheduler;
         }
 
-        ndn::Face& getNlsrFace()
+        ndn::shared_ptr<ndn::Face> getNlsrFace()
         {
             return nlsrFace;
         }
 
         KeyManager& getKeyManager()
         {
-        	return km;
+            return km;
         }
 
-//		ndn::KeyChain& getKeyChain()
-//        {
-//            return kChain;
-//        }
 
         interestManager& getIm()
         {
@@ -183,10 +178,6 @@
             isBuildAdjLsaSheduled=iabls;
         }
 
-        NlsrTest& getNlsrTesting()
-        {
-            return nlsrTesting;
-        }
 
         void setApiPort(int ap)
         {
@@ -218,19 +209,25 @@
             isRouteCalculationScheduled=ircs;
         }
 
+        SyncLogicHandler& getSlh()
+        {
+            return slh;
+        }
+
         NlsrLogger& getNlsrLogger()
         {
             return nlsrLogger;
         }
 
+        void initNlsr();
+
     private:
         ConfParameter confParam;
         Adl adl;
         Npl npl;
         ndn::shared_ptr<boost::asio::io_service> io;
         ndn::Scheduler scheduler;
-        ndn::Face nlsrFace;
-//      ndn::KeyChain kChain;
+        ndn::shared_ptr<ndn::Face> nlsrFace;
         interestManager im;
         DataManager dm;
         SequencingManager sm;
@@ -243,6 +240,7 @@
         RoutingTable routingTable;
         Npt npt;
         Fib fib;
+        SyncLogicHandler slh;
         NlsrLogger nlsrLogger;
 
         long int adjBuildCount;
@@ -250,7 +248,6 @@
         int isRouteCalculationScheduled;
         int isRoutingTableCalculating;
 
-        NlsrTest nlsrTesting;
 
 
     };
diff --git a/src/nlsr_conf_param.hpp b/src/nlsr_conf_param.hpp
index b2413ba..7fc51f2 100644
--- a/src/nlsr_conf_param.hpp
+++ b/src/nlsr_conf_param.hpp
@@ -13,21 +13,24 @@
 
     public:
         ConfParameter()
-            :chronosyncSyncPrefix("ndn/nlsr/sync")
-            ,chronosyncLsaPrefix("/ndn/nlsr/LSA")
-        {
-            isStrictHierchicalKeyCheck=0;
-            interestRetryNumber=3;
-            interestResendTime=5;
-            infoInterestInterval=60;
-            lsaRefreshTime=1800;
-            routerDeadInterval=3600;
-            maxFacesPerPrefix=0;
-            tunnelType=0;
-            detailedLogging=0;
-            debugging=0;
-            isHyperbolicCalc=0;
-        }
+            : chronosyncSyncPrefix("ndn/nlsr/sync")
+            , chronosyncLsaPrefix("/ndn/nlsr/LSA")
+            , rootKeyPrefix("/ndn/keys")
+            , isStrictHierchicalKeyCheck(0)
+            , interestRetryNumber(3)
+            , interestResendTime(5)
+            , infoInterestInterval(60)
+            , lsaRefreshTime(1800)
+            , routerDeadInterval(3600)
+            , maxFacesPerPrefix(0)
+            , tunnelType(0)
+            , detailedLogging(0)
+            , debugging(0)
+            , isHyperbolicCalc(0)
+            , seqFileDir()
+            , corR(0)
+            , corTheta(0)
+        {}
 
         void setRouterName(const string& rn)
         {
@@ -69,6 +72,16 @@
             return routerPrefix;
         }
 
+        string getRootKeyPrefix()
+        {
+            return rootKeyPrefix;
+        }
+
+        void setRootKeyPrefix(string rkp)
+        {
+            rootKeyPrefix=rkp;
+        }
+
         void setInterestRetryNumber(int irn)
         {
             interestRetryNumber=irn;
@@ -130,6 +143,16 @@
             return logDir;
         }
 
+        void setSeqFileDir(string ssfd)
+        {
+            seqFileDir=ssfd;
+        }
+
+        string getSeqFileDir()
+        {
+            return seqFileDir;
+        }
+
         void setDetailedLogging(int dl)
         {
             detailedLogging=dl;
@@ -200,6 +223,16 @@
             return chronosyncSyncPrefix;
         }
 
+        void setChronosyncLsaPrefix(string clp)
+        {
+            chronosyncLsaPrefix=clp;
+        }
+
+        string getChronosyncLsaPrefix()
+        {
+            return chronosyncLsaPrefix;
+        }
+
         int getInfoInterestInterval()
         {
             return infoInterestInterval;
@@ -221,6 +254,8 @@
         string chronosyncSyncPrefix;
         string chronosyncLsaPrefix;
 
+        string rootKeyPrefix;
+
         int interestRetryNumber;
         int interestResendTime;
         int infoInterestInterval;
@@ -229,6 +264,7 @@
 
         int maxFacesPerPrefix;
         string logDir;
+        string seqFileDir;
         string logFile;
         int detailedLogging;
         int debugging;
diff --git a/src/nlsr_conf_processor.cpp b/src/nlsr_conf_processor.cpp
index fd9e217..e6067f9 100644
--- a/src/nlsr_conf_processor.cpp
+++ b/src/nlsr_conf_processor.cpp
@@ -6,7 +6,7 @@
 
 #include "nlsr_conf_processor.hpp"
 #include "nlsr_conf_param.hpp"
-#include "nlsr_tokenizer.hpp"
+#include "utility/nlsr_tokenizer.hpp"
 #include "nlsr_adjacent.hpp"
 
 
@@ -63,6 +63,10 @@
         {
             ret=processConfCommandSiteName(pnlsr,nt.getRestOfLine());
         }
+        else if ( (nt.getFirstToken() == "root-key-prefix"))
+        {
+            ret=processConfCommandRootKeyPrefix(pnlsr,nt.getRestOfLine());
+        }
         else if ( (nt.getFirstToken() == "router-name"))
         {
             ret=processConfCommandRouterName(pnlsr,nt.getRestOfLine());
@@ -177,6 +181,30 @@
     }
 
     int
+    ConfFileProcessor::processConfCommandRootKeyPrefix(Nlsr& pnlsr, string command)
+    {
+        if(command.empty() )
+        {
+            cerr <<"Root Key Prefix can not be null or empty :( !"<<endl;
+            return -1;
+        }
+        else
+        {
+            if(command[command.size()-1] == '/' )
+            {
+                command.erase(command.size() - 1);
+            }
+            if(command[0] == '/' )
+            {
+                command.erase(0,1);
+            }
+            pnlsr.getConfParameter().setRootKeyPrefix(command);
+        }
+        return 0;
+    }
+
+
+    int
     ConfFileProcessor::processConfCommandRouterName(Nlsr& pnlsr, string command)
     {
         if(command.empty() )
diff --git a/src/nlsr_conf_processor.hpp b/src/nlsr_conf_processor.hpp
index c49e3c2..e97261e 100644
--- a/src/nlsr_conf_processor.hpp
+++ b/src/nlsr_conf_processor.hpp
@@ -24,6 +24,7 @@
         int processConfCommand(Nlsr& pnlsr, string command);
         int processConfCommandNetwork(Nlsr& pnlsr, string command);
         int processConfCommandSiteName(Nlsr& pnlsr, string command);
+        int processConfCommandRootKeyPrefix(Nlsr& pnlsr, string command);
         int processConfCommandRouterName(Nlsr& pnlsr, string command);
         int processConfCommandInterestRetryNumber(Nlsr& pnlsr, string command);
         int processConfCommandInterestResendTime(Nlsr& pnlsr, string command);
diff --git a/src/nlsr_dm.cpp b/src/nlsr_dm.cpp
deleted file mode 100644
index a88951b..0000000
--- a/src/nlsr_dm.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-#include<iostream>
-#include<cstdlib>
-
-#include "nlsr.hpp"
-#include "nlsr_dm.hpp"
-#include "nlsr_tokenizer.hpp"
-#include "nlsr_lsdb.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-    using namespace ndn;
-
-    void
-    DataManager::processContent(Nlsr& pnlsr, const ndn::Interest &interest,
-                                const ndn::Data & data)
-    {
-        cout << "I: " << interest.toUri() << endl;
-        string dataName(data.getName().toUri());
-        string dataContent((char *)data.getContent().value());
-        cout << "D: " << dataName << endl;
-        cout << "Data Content: " << dataContent << endl;
-        nlsrTokenizer nt(dataName,"/");
-        string chkString("info");
-        if( nt.doesTokenExist(chkString) )
-        {
-            processContentInfo(pnlsr,dataName,dataContent);
-        }
-    }
-
-    void
-    DataManager::processContentInfo(Nlsr& pnlsr, string& dataName,
-                                    string& dataContent)
-    {
-        nlsrTokenizer nt(dataName,"/");
-        string chkString("info");
-        string neighbor="/" + nt.getFirstToken()
-                        +nt.getTokenString(0,nt.getTokenPosition(chkString)-1);
-        int oldStatus=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-        int infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
-        //debugging purpose start
-        cout <<"Before Updates: " <<endl;
-        cout <<"Neighbor : "<<neighbor<<endl;
-        cout<<"Status: "<< oldStatus << endl;
-        cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
-        //debugging purpose end
-        pnlsr.getAdl().setStatusOfNeighbor(neighbor,1);
-        pnlsr.getAdl().setTimedOutInterestCount(neighbor,0);
-        int newStatus=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-        infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
-        //debugging purpose
-        cout <<"After Updates: " <<endl;
-        cout <<"Neighbor : "<<neighbor<<endl;
-        cout<<"Status: "<< newStatus << endl;
-        cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
-        //debugging purpose end
-        if ( ( oldStatus-newStatus)!= 0 ) // change in Adjacency list
-        {
-            pnlsr.incrementAdjBuildCount();
-            /* Need to schedule event for Adjacency LSA building */
-            if ( pnlsr.getIsBuildAdjLsaSheduled() == 0 )
-            {
-                pnlsr.setIsBuildAdjLsaSheduled(1);
-                // event here
-                pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
-                                                   ndn::bind(&Lsdb::scheduledAdjLsaBuild, pnlsr.getLsdb(),
-                                                           boost::ref(pnlsr)));
-            }
-        }
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_dm.hpp b/src/nlsr_dm.hpp
deleted file mode 100644
index 64b9006..0000000
--- a/src/nlsr_dm.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef NLSR_DM_HPP
-#define NLSR_DM_HPP
-
-#include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/key-chain.hpp>
-#include <ndn-cpp-dev/util/scheduler.hpp>
-
-namespace nlsr
-{
-
-    using namespace ndn;
-    using namespace std;
-
-    class Nlsr;
-
-    class DataManager
-    {
-    public:
-        void processContent(Nlsr& pnlsr, const ndn::Interest &interest,
-                            const ndn::Data& data);
-        void processContentInfo(Nlsr& pnlsr, string& dataName,
-                                string& dataContent);
-    private:
-
-    };
-
-}//namespace nlsr
-#endif
diff --git a/src/nlsr_fe.cpp b/src/nlsr_fe.cpp
deleted file mode 100644
index 5f4811c..0000000
--- a/src/nlsr_fe.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <list>
-#include "nlsr_fe.hpp"
-#include "nlsr_nexthop.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    bool
-    FibEntry::isEqualNextHops(Nhl &nhlOther)
-    {
-        if ( nhl.getNhlSize() != nhlOther.getNhlSize() )
-        {
-            return false;
-        }
-        else
-        {
-            int nhCount=0;
-            std::list<NextHop>::iterator it1, it2;
-            for ( it1=nhl.getNextHopList().begin(),
-                    it2 = nhlOther.getNextHopList().begin() ;
-                    it1 != nhl.getNextHopList().end() ; it1++, it2++)
-            {
-                if ((*it1).getConnectingFace() == (*it2).getConnectingFace() )
-                {
-                    (*it1).setRouteCost((*it2).getRouteCost());
-                    nhCount++;
-                }
-                else
-                {
-                    break;
-                }
-            }
-            return nhCount == nhl.getNhlSize();
-        }
-    }
-
-    ostream&
-    operator<<(ostream& os, FibEntry& fe)
-    {
-        os<<"Name Prefix: "<<fe.getName()<<endl;
-        os<<"Time to Refresh: "<<fe.getTimeToRefresh()<<endl;
-        os<<fe.getNhl()<<endl;
-        return os;
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_fe.hpp b/src/nlsr_fe.hpp
deleted file mode 100644
index c85e045..0000000
--- a/src/nlsr_fe.hpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef NLSR_FE_HPP
-#define NLSR_FE_HPP
-
-#include<list>
-#include <iostream>
-#include <ndn-cpp-dev/util/scheduler.hpp>
-
-#include "nlsr_nexthop.hpp"
-#include "nlsr_nhl.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    class FibEntry
-    {
-    public:
-        FibEntry()
-            : name()
-            , timeToRefresh(0)
-            , feSeqNo(0)
-        {
-        }
-
-        FibEntry(string n)
-        {
-            name=n;
-        }
-
-        string getName()
-        {
-            return name;
-        }
-
-        Nhl& getNhl()
-        {
-            return nhl;
-        }
-
-        int getTimeToRefresh()
-        {
-            return timeToRefresh;
-        }
-
-        void setTimeToRefresh(int ttr)
-        {
-            timeToRefresh=ttr;
-        }
-
-        void setFeExpiringEventId(ndn::EventId feid)
-        {
-            feExpiringEventId=feid;
-        }
-
-        ndn::EventId getFeExpiringEventId()
-        {
-            return feExpiringEventId;
-        }
-
-        void setFeSeqNo(int fsn)
-        {
-            feSeqNo=fsn;
-        }
-
-        int getFeSeqNo()
-        {
-            return feSeqNo;
-        }
-
-        bool isEqualNextHops(Nhl &nhlOther);
-
-    private:
-        string name;
-        int timeToRefresh;
-        ndn::EventId feExpiringEventId;
-        int feSeqNo;
-        Nhl nhl;
-    };
-
-    ostream& operator<<(ostream& os, FibEntry& fe);
-
-} //namespace nlsr
-
-#endif
diff --git a/src/nlsr_fib.cpp b/src/nlsr_fib.cpp
deleted file mode 100644
index 8fb7928..0000000
--- a/src/nlsr_fib.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-#include<list>
-#include "nlsr_fe.hpp"
-#include "nlsr_fib.hpp"
-#include "nlsr_nhl.hpp"
-#include "nlsr.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-    using namespace ndn;
-
-    static bool
-    fibEntryNameCompare(FibEntry& fe, string name)
-    {
-        return fe.getName() == name ;
-    }
-
-    void
-    Fib::cancelScheduledFeExpiringEvent(Nlsr& pnlsr, EventId eid)
-    {
-        pnlsr.getScheduler().cancelEvent(eid);
-    }
-
-
-    ndn::EventId
-    Fib::scheduleFibEntryRefreshing(Nlsr& pnlsr, string name, int feSeqNum,
-                                    int refreshTime)
-    {
-        return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
-                ndn::bind(&Fib::refreshFibEntry,this,name,feSeqNum));
-    }
-
-    void
-    Fib::refreshFibEntry(string name, int feSeqNum)
-    {
-    }
-
-    void
-    Fib::removeFromFib(Nlsr& pnlsr, string name)
-    {
-        std::list<FibEntry >::iterator it = std::find_if( fibTable.begin(),
-                                            fibTable.end(), bind(&fibEntryNameCompare, _1, name));
-        if( it != fibTable.end() )
-        {
-            for(std::list<NextHop>::iterator nhit=(*it).getNhl().getNextHopList().begin();
-                    nhit != (*it).getNhl().getNextHopList().begin(); nhit++)
-            {
-                //remove entry from NDN-FIB
-            }
-            cancelScheduledFeExpiringEvent(pnlsr, (*it).getFeExpiringEventId());
-            fibTable.erase(it);
-        }
-    }
-
-
-    void
-    Fib::updateFib(Nlsr& pnlsr,string name, Nhl& nextHopList, int maxFacesPerPrefix)
-    {
-        int startFace=0;
-        int endFace=getNumberOfFacesForName(nextHopList,maxFacesPerPrefix);
-        std::list<FibEntry >::iterator it = std::find_if( fibTable.begin(),
-                                            fibTable.end(), bind(&fibEntryNameCompare, _1, name));
-        if( it != fibTable.end() )
-        {
-            nextHopList.sortNhl();
-            if ( !(*it).isEqualNextHops(nextHopList) )
-            {
-                std::list<NextHop>::iterator nhit=nextHopList.getNextHopList().begin();
-                (*it).getNhl().addNextHop((*nhit));
-                removeFibEntryHop((*it).getNhl(),(*nhit).getConnectingFace());
-                startFace++;
-                nhit++;
-                for( int i=startFace; i< endFace; nhit++,i++)
-                {
-                    (*it).getNhl().addNextHop((*nhit));
-                }
-                (*it).setTimeToRefresh(fibEntryRefreshTime);
-            }
-            (*it).getNhl().sortNhl();
-            cancelScheduledFeExpiringEvent(pnlsr, (*it).getFeExpiringEventId());
-            (*it).setFeSeqNo((*it).getFeSeqNo()+1);
-            (*it).setFeExpiringEventId(scheduleFibEntryRefreshing(pnlsr,
-                                       (*it).getName() ,
-                                       (*it).getFeSeqNo(),fibEntryRefreshTime));
-            //update NDN-FIB
-        }
-        else
-        {
-            nextHopList.sortNhl();
-            FibEntry newEntry(name);
-            std::list<NextHop>::iterator nhit=nextHopList.getNextHopList().begin();
-            for(int i=startFace; i< endFace ; i++)
-            {
-                newEntry.getNhl().addNextHop((*nhit));
-                ++nhit;
-            }
-            newEntry.getNhl().sortNhl();
-            newEntry.setTimeToRefresh(fibEntryRefreshTime);
-            newEntry.setFeSeqNo(1);
-            fibTable.push_back(newEntry);
-            //cancelScheduledFeExpiringEvent(pnlsr, newEntry().getFeExpiringEventId());
-            //Update NDN-FIB
-        }
-    }
-
-
-
-    void Fib::cleanFib(Nlsr& pnlsr)
-    {
-        for( std::list<FibEntry >::iterator it=fibTable.begin(); it != fibTable.end();
-                ++it)
-        {
-            for(std::list<NextHop>::iterator nhit=(*it).getNhl().getNextHopList().begin();
-                    nhit != (*it).getNhl().getNextHopList().begin(); nhit++)
-            {
-                cancelScheduledFeExpiringEvent(pnlsr,(*it).getFeExpiringEventId());
-                //remove entry from NDN-FIB
-            }
-        }
-        if ( fibTable.size() > 0 )
-        {
-            fibTable.clear();
-        }
-    }
-
-
-    void
-    Fib::removeFibEntryHop(Nhl& nl, int doNotRemoveHopFaceId)
-    {
-        for( std::list<NextHop >::iterator it=nl.getNextHopList().begin();
-                it != nl.getNextHopList().end();   ++it)
-        {
-            if ( (*it).getConnectingFace() != doNotRemoveHopFaceId )
-            {
-                nl.getNextHopList().erase(it);
-            }
-        }
-    }
-
-
-    int
-    Fib::getNumberOfFacesForName(Nhl& nextHopList, int maxFacesPerPrefix)
-    {
-        int endFace=0;
-        if((maxFacesPerPrefix == 0) || (nextHopList.getNhlSize() <= maxFacesPerPrefix))
-        {
-            return nextHopList.getNhlSize();
-        }
-        else
-        {
-            return maxFacesPerPrefix;
-        }
-        return endFace;
-    }
-
-    void
-    Fib::printFib()
-    {
-        cout<<"-------------------FIB-----------------------------"<<endl;
-        for(std::list<FibEntry>::iterator it = fibTable.begin(); it!=fibTable.end();
-                ++it)
-        {
-            cout<<(*it);
-        }
-    }
-
-} //namespace nlsr
diff --git a/src/nlsr_fib.hpp b/src/nlsr_fib.hpp
deleted file mode 100644
index d93d972..0000000
--- a/src/nlsr_fib.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef NLSR_FIB_HPP
-#define NLSR_FIB_HPP
-
-#include <list>
-#include "nlsr_fe.hpp"
-
-namespace nlsr
-{
-
-    class Nlsr;
-
-    using namespace std;
-    using namespace ndn;
-
-    class Fib
-    {
-    public:
-        Fib()
-        {
-        }
-
-        void removeFromFib(Nlsr& pnlsr, string name);
-        void updateFib(Nlsr& pnlsr, string name, Nhl& nextHopList,
-                       int maxFacesPerPrefix);
-        void cleanFib(Nlsr& pnlsr);
-        void setFibEntryRefreshTime(int fert)
-        {
-            fibEntryRefreshTime=fert;
-        }
-
-        void printFib();
-
-    private:
-        void removeFibEntryHop(Nhl& nl, int doNotRemoveHopFaceId);
-        int getNumberOfFacesForName(Nhl& nextHopList, int maxFacesPerPrefix);
-        ndn::EventId
-        scheduleFibEntryRefreshing(Nlsr& pnlsr, string name, int feSeqNum,
-                                   int refreshTime);
-        void cancelScheduledFeExpiringEvent(Nlsr& pnlsr, EventId eid);
-        void refreshFibEntry(string name, int feSeqNum);
-
-    private:
-        std::list<FibEntry> fibTable;
-        int fibEntryRefreshTime;
-    };
-
-}//namespace nlsr
-#endif
diff --git a/src/nlsr_im.cpp b/src/nlsr_im.cpp
deleted file mode 100644
index 2e6d6d1..0000000
--- a/src/nlsr_im.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-#include<iostream>
-#include<cstdlib>
-
-
-
-#include "nlsr.hpp"
-#include "nlsr_im.hpp"
-#include "nlsr_dm.hpp"
-#include "nlsr_tokenizer.hpp"
-#include "nlsr_lsdb.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-    using namespace ndn;
-
-    void
-    interestManager::processInterest( Nlsr& pnlsr,
-                                      const ndn::Name &name,
-                                      const ndn::Interest &interest)
-    {
-        cout << "<< I: " << interest << endl;
-        string intName=interest.getName().toUri();
-        cout << "Interest Received for Name: "<< intName <<endl;
-        nlsrTokenizer nt(intName,"/");
-        string chkString("info");
-        if( nt.doesTokenExist(chkString) )
-        {
-            string nbr=nt.getTokenString(nt.getTokenPosition(chkString)+1);
-            cout <<"Neighbor: " << nbr <<endl;
-            processInterestInfo(pnlsr,nbr,interest);
-        }
-        //Data data(ndn::Name(interest->getName()).append("testApp").appendVersion());
-        //data.setFreshnessPeriod(1000); // 10 sec
-        //data.setContent((const uint8_t*)"HELLO KITTY", sizeof("HELLO KITTY"));
-        //pnlsr.getKeyChain().sign(data);
-        //cout << ">> D: " << data << endl;
-        //pnlsr.getNlsrFace().put(data);
-    }
-
-    void
-    interestManager::processInterestInfo(Nlsr& pnlsr, string& neighbor,
-                                         const ndn::Interest &interest)
-    {
-        if ( pnlsr.getAdl().isNeighbor(neighbor) )
-        {
-            Data data(ndn::Name(interest.getName()).appendVersion());
-            data.setFreshnessPeriod(1000); // 10 sec
-            data.setContent((const uint8_t*)"info", sizeof("info"));
-            pnlsr.getKeyManager().getKeyChain().sign(data);
-            cout << ">> D: " << data << endl;
-            pnlsr.getNlsrFace().put(data);
-            int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-            if ( status == 0 )
-            {
-                string intName=neighbor +"/"+"info"+
-                               pnlsr.getConfParameter().getRouterPrefix();
-                expressInterest(	pnlsr,intName,2,
-                                    pnlsr.getConfParameter().getInterestResendTime());
-            }
-        }
-    }
-
-    void
-    interestManager::processInterestTimedOut(Nlsr& pnlsr,
-            const ndn::Interest &interest)
-    {
-        cout << "Timed out interest : " << interest.getName().toUri() << endl;
-        string intName=	interest.getName().toUri();
-        nlsrTokenizer nt(intName,"/");
-        string chkString("info");
-        if( nt.doesTokenExist(chkString) )
-        {
-            string nbr="/" + nt.getFirstToken()
-                       +nt.getTokenString(0,nt.getTokenPosition(chkString)-1);
-            processInterestTimedOutInfo( pnlsr , nbr , interest);
-        }
-    }
-
-    void
-    interestManager::processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
-            const ndn::Interest &interest)
-    {
-        pnlsr.getAdl().incrementTimedOutInterestCount(neighbor);
-        int status=pnlsr.getAdl().getStatusOfNeighbor(neighbor);
-        int infoIntTimedOutCount=pnlsr.getAdl().getTimedOutInterestCount(neighbor);
-        cout<<"Neighbor: "<< neighbor << endl;
-        cout<<"Status: "<< status << endl;
-        cout<<"Info Interest Timed out: "<< infoIntTimedOutCount <<endl;
-        if((infoIntTimedOutCount < pnlsr.getConfParameter().getInterestRetryNumber()))
-        {
-            string intName=neighbor +"/"+"info"+
-                           pnlsr.getConfParameter().getRouterPrefix();
-            expressInterest(	pnlsr,intName,2,
-                                pnlsr.getConfParameter().getInterestResendTime());
-        }
-        else if ( (status == 1) &&
-                  (infoIntTimedOutCount == pnlsr.getConfParameter().getInterestRetryNumber()))
-        {
-            pnlsr.getAdl().setStatusOfNeighbor(neighbor,0);
-            pnlsr.incrementAdjBuildCount();
-            if ( pnlsr.getIsBuildAdjLsaSheduled() == 0 )
-            {
-                pnlsr.setIsBuildAdjLsaSheduled(1);
-                // event here
-                pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
-                                                   ndn::bind(&Lsdb::scheduledAdjLsaBuild,pnlsr.getLsdb(),
-                                                           boost::ref(pnlsr)));
-            }
-        }
-    }
-
-    void
-    interestManager::expressInterest(Nlsr& pnlsr,const string& interestNamePrefix,
-                                     int scope, int seconds)
-    {
-        Interest i((ndn::Name(interestNamePrefix)));
-        //i.setScope(scope);
-        i.setInterestLifetime(seconds*1000);
-        i.setMustBeFresh(true);
-        pnlsr.getNlsrFace().expressInterest(i,
-                                            ndn::func_lib::bind(&DataManager::processContent,
-                                                    &pnlsr.getDm(), boost::ref(pnlsr),_1, _2),
-                                            ndn::func_lib::bind(&interestManager::processInterestTimedOut,
-                                                    this,boost::ref(pnlsr),_1));
-    }
-
-
-    void
-    interestManager::sendScheduledInfoInterest(Nlsr& pnlsr, int seconds)
-    {
-        std::list<Adjacent> adjList=pnlsr.getAdl().getAdjList();
-        for(std::list<Adjacent>::iterator it=adjList.begin(); it!=adjList.end(); ++it)
-        {
-            string adjName=(*it).getAdjacentName()+"/"+"info"+
-                           pnlsr.getConfParameter().getRouterPrefix();
-            expressInterest(	pnlsr,adjName,2,
-                                pnlsr.getConfParameter().getInterestResendTime());
-        }
-        scheduleInfoInterest(pnlsr, pnlsr.getConfParameter().getInfoInterestInterval());
-    }
-
-    void
-    interestManager::scheduleInfoInterest(Nlsr& pnlsr, int seconds)
-    {
-        EventId eid=pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
-                    ndn::bind(&interestManager::sendScheduledInfoInterest, this,
-                              boost::ref(pnlsr),seconds));
-    }
-
-
-} //namespace nlsr
diff --git a/src/nlsr_im.hpp b/src/nlsr_im.hpp
deleted file mode 100644
index ccfe78f..0000000
--- a/src/nlsr_im.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef NLSR_IM_HPP
-#define NLSR_IM_HPP
-
-#include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/key-chain.hpp>
-#include <ndn-cpp-dev/util/scheduler.hpp>
-
-namespace nlsr
-{
-
-    using namespace ndn;
-    using namespace std;
-
-    class Nlsr;
-
-    class interestManager
-    {
-    public:
-        interestManager()
-        {
-        }
-        void processInterest(Nlsr& pnlsr, const ndn::Name &name,
-                             const ndn::Interest &interest);
-        void processInterestInfo(Nlsr& pnlsr, string& neighbor,
-                                 const ndn::Interest &interest);
-        void processInterestTimedOut(Nlsr& pnlsr, const ndn::Interest &interest);
-        void processInterestTimedOutInfo(Nlsr& pnlsr, string& neighbor,
-                                         const ndn::Interest &interest);
-        void expressInterest(Nlsr& pnlsr,const string& interestNamePrefix, int scope,
-                             int seconds);
-        void sendScheduledInfoInterest(Nlsr& pnlsr, int seconds);
-        void scheduleInfoInterest(Nlsr& pnlsr, int seconds);
-
-    private:
-
-
-    };
-
-}//namespace nlsr
-
-#endif
diff --git a/src/nlsr_km.cpp b/src/nlsr_km.cpp
deleted file mode 100644
index fb4efaa..0000000
--- a/src/nlsr_km.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <ndn-cpp-dev/security/identity-certificate.hpp>
-#include <ndn-cpp-dev/encoding/block.hpp>
-#include "nlsr_km.hpp"
-
-namespace nlsr
-{
-    void
-    KeyManager::initKeyManager(ConfParameter &cp)
-    {
-        ndn::Name identityName(cp.getRouterPrefix()+"/nlsr");
-        kChain.deleteIdentity(identityName);
-        ndn::Name certName = kChain.createIdentity(identityName);
-        cout<<"Certificate Name: "<<certName.toUri()<<endl;
-        ndn::Name keyName=
-            ndn::IdentityCertificate::certificateNameToPublicKeyName(certName);
-        cout<<"Key Name: "<<keyName.toUri()<<endl;
-    }
-
-}
-
-
-
diff --git a/src/nlsr_km.hpp b/src/nlsr_km.hpp
deleted file mode 100644
index e93e996..0000000
--- a/src/nlsr_km.hpp
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef NLSR_KM_HPP
-#define NLSR_KM_HPP
-
-#include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/key-chain.hpp>
-#include <ndn-cpp-dev/util/scheduler.hpp>
-
-#include "nlsr_conf_param.hpp"
-
-namespace nlsr
-{
-    class KeyManager
-    {
-    public:
-        KeyManager()
-            :kChain()
-        {
-        }
-
-        ndn::KeyChain& getKeyChain()
-        {
-            return kChain;
-        }
-
-        void initKeyManager(ConfParameter &cp);
-
-    private:
-        ndn::KeyChain kChain;
-    };
-}
-
-#endif
diff --git a/src/nlsr_logger.cpp b/src/nlsr_logger.cpp
deleted file mode 100644
index 804ef98..0000000
--- a/src/nlsr_logger.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "nlsr_logger.hpp"
-
-namespace nlsr
-{
-
-    string
-    NlsrLogger::getEpochTime()
-    {
-        std::stringstream ss;
-        boost::posix_time::ptime time_t_epoch(boost::gregorian::date(1970,1,1));
-        boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time();
-        boost::posix_time::time_duration diff = now - time_t_epoch;
-        ss<<diff.total_seconds()<<"."<<boost::format("%06i")%(diff.total_microseconds()
-                %1000000);
-        return ss.str();
-    }
-
-    string
-    NlsrLogger::getUserHomeDirectory()
-    {
-        string homeDirPath(getpwuid(getuid())->pw_dir);
-        if( homeDirPath.empty() )
-        {
-            homeDirPath = getenv("HOME");
-        }
-        return homeDirPath;
-    }
-
-    void
-    NlsrLogger::initNlsrLogger(std::string dirPath)
-    {
-        string logDirPath(dirPath);
-        if( dirPath.empty() )
-        {
-            logDirPath=getUserHomeDirectory()+"/nlsrLog";
-        }
-        cout<<"Log Dir Path: "<< logDirPath<<endl;
-        typedef sinks::synchronous_sink< sinks::text_file_backend > file_sink;
-        shared_ptr< file_sink > sink(new file_sink(
-                                         keywords::file_name = logDirPath
-                                                 +"/NLSR%Y%m%d%H%M%S_%3N.log",
-                                         keywords::rotation_size = 128 * 1024 * 1024,
-                                         keywords::time_based_rotation = sinks::file::rotation_at_time_point(12, 0, 0),
-                                         keywords::auto_flush = true
-                                     ));
-        sink->locked_backend()->set_file_collector(sinks::file::make_collector(
-                    keywords::target = logDirPath,
-                    keywords::max_size = 16 * 1024 * 1024 * 1024,
-                    keywords::min_free_space = 128 * 1024 * 1024
-                ));
-        sink->set_formatter(
-            expr::format("%1%: %2%")
-            % getEpochTime()
-            % expr::smessage
-        );
-        logging::core::get()->add_sink(sink);
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_logger.hpp b/src/nlsr_logger.hpp
deleted file mode 100644
index 222ac52..0000000
--- a/src/nlsr_logger.hpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef NLSR_LOGGER_HPP
-#define NLSR_LOGGER_HPP
-
-#define BOOST_LOG_DYN_LINK 1
-
-#include <stdexcept>
-#include <string>
-#include <iostream>
-#include <sstream>
-#include <pwd.h>
-#include <cstdlib>
-#include <string>
-#include <unistd.h>
-#include <boost/format.hpp>
-#include <boost/smart_ptr/shared_ptr.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-#include <boost/date_time/local_time/local_time.hpp>
-#include <boost/log/common.hpp>
-#include <boost/log/expressions.hpp>
-#include <boost/log/attributes.hpp>
-#include <boost/log/sources/logger.hpp>
-#include <boost/log/sinks/sync_frontend.hpp>
-#include <boost/log/sinks/text_file_backend.hpp>
-
-namespace nlsr
-{
-
-    namespace logging = boost::log;
-    namespace attrs = boost::log::attributes;
-    namespace src = boost::log::sources;
-    namespace sinks = boost::log::sinks;
-    namespace expr = boost::log::expressions;
-    namespace keywords = boost::log::keywords;
-
-    using boost::shared_ptr;
-    using namespace std;
-
-
-    class NlsrLogger
-    {
-    public:
-        NlsrLogger()
-        {
-        }
-
-        void initNlsrLogger(std::string dirPath);
-
-        src::logger& getLogger()
-        {
-            return mLogger;
-        }
-
-    private:
-        string getEpochTime();
-        string getUserHomeDirectory();
-
-    private:
-        src::logger mLogger;
-    };
-
-}//namespace nlsr
-#endif
diff --git a/src/nlsr_lsa.cpp b/src/nlsr_lsa.cpp
index f238bce..2a11e41 100644
--- a/src/nlsr_lsa.cpp
+++ b/src/nlsr_lsa.cpp
@@ -1,13 +1,16 @@
 #include<string>
 #include<iostream>
+#include<sstream>
 #include<algorithm>
 #include<cmath>
 #include<limits>
 
+#include "nlsr.hpp"
 #include "nlsr_lsa.hpp"
 #include "nlsr_npl.hpp"
 #include "nlsr_adjacent.hpp"
-#include "nlsr.hpp"
+#include "utility/nlsr_tokenizer.hpp"
+
 
 namespace nlsr
 {
@@ -40,7 +43,7 @@
     NameLsa::getNameLsaData()
     {
         string nameLsaData;
-        nameLsaData=origRouter + "|" + boost::lexical_cast<std::string>(lsType) + "|"
+        nameLsaData=origRouter + "|" + boost::lexical_cast<std::string>(1) + "|"
                     + boost::lexical_cast<std::string>(lsSeqNo) + "|"
                     + boost::lexical_cast<std::string>(lifeTime);
         nameLsaData+="|";
@@ -51,7 +54,36 @@
             nameLsaData+="|";
             nameLsaData+=(*it);
         }
-        return nameLsaData;
+        return nameLsaData+"|";
+    }
+
+    bool
+    NameLsa::initNameLsaFromContent(string content)
+    {
+        uint32_t numName=0;
+        nlsrTokenizer nt(content, "|");
+        origRouter=nt.getNextToken();
+        if(origRouter.empty())
+        {
+            return false;
+        }
+        try
+        {
+            lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
+            lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
+            lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
+            numName=boost::lexical_cast<uint32_t>(nt.getNextToken());
+        }
+        catch(std::exception &e)
+        {
+            return false;
+        }
+        for(int i=0; i<numName; i++)
+        {
+            string name=nt.getNextToken();
+            addNameToLsa(name);
+        }
+        return true;
     }
 
     std::ostream&
@@ -107,7 +139,7 @@
     {
         string corLsaData;
         corLsaData=origRouter + "|";
-        corLsaData+=(boost::lexical_cast<std::string>(lsType) + "|");
+        corLsaData+=(boost::lexical_cast<std::string>(3) + "|");
         corLsaData+=(boost::lexical_cast<std::string>(lsSeqNo) + "|");
         corLsaData+=(boost::lexical_cast<std::string>(lifeTime) + "|");
         corLsaData+=(boost::lexical_cast<std::string>(corRad) + "|");
@@ -115,6 +147,30 @@
         return corLsaData;
     }
 
+    bool
+    CorLsa::initCorLsaFromContent(string content)
+    {
+        nlsrTokenizer nt(content, "|");
+        origRouter=nt.getNextToken();
+        if(origRouter.empty())
+        {
+            return false;
+        }
+        try
+        {
+            lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
+            lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
+            lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
+            corRad=boost::lexical_cast<double>(nt.getNextToken());
+            corTheta=boost::lexical_cast<double>(nt.getNextToken());
+        }
+        catch(std::exception &e)
+        {
+            return false;
+        }
+        return true;
+    }
+
     std::ostream&
     operator<<(std::ostream& os, CorLsa& cLsa)
     {
@@ -166,7 +222,7 @@
     AdjLsa::getAdjLsaData()
     {
         string adjLsaData;
-        adjLsaData=origRouter + "|" + boost::lexical_cast<std::string>(lsType) + "|"
+        adjLsaData=origRouter + "|" + boost::lexical_cast<std::string>(2) + "|"
                    + boost::lexical_cast<std::string>(lsSeqNo) + "|"
                    + boost::lexical_cast<std::string>(lifeTime);
         adjLsaData+="|";
@@ -181,7 +237,46 @@
             adjLsaData+="|";
             adjLsaData+=boost::lexical_cast<std::string>((*it).getLinkCost());
         }
-        return adjLsaData;
+        return adjLsaData+"|";
+    }
+
+    bool
+    AdjLsa::initAdjLsaFromContent(string content)
+    {
+        uint32_t numLink=0;
+        nlsrTokenizer nt(content, "|");
+        origRouter=nt.getNextToken();
+        if(origRouter.empty())
+        {
+            return false;
+        }
+        try
+        {
+            lsType=boost::lexical_cast<uint8_t>(nt.getNextToken());
+            lsSeqNo=boost::lexical_cast<uint32_t>(nt.getNextToken());
+            lifeTime=boost::lexical_cast<uint32_t>(nt.getNextToken());
+            numLink=boost::lexical_cast<uint32_t>(nt.getNextToken());
+        }
+        catch(std::exception &e)
+        {
+            return false;
+        }
+        for(int i=0; i< numLink; i++)
+        {
+            try
+            {
+                string adjName=nt.getNextToken();
+                int connectingFace=boost::lexical_cast<int>(nt.getNextToken());
+                double linkCost=boost::lexical_cast<double>(nt.getNextToken());
+                Adjacent adjacent(adjName, connectingFace, linkCost, 0, 0);
+                addAdjacentToLsa(adjacent);
+            }
+            catch( std::exception &e )
+            {
+                return false;
+            }
+        }
+        return true;
     }
 
 
diff --git a/src/nlsr_lsa.hpp b/src/nlsr_lsa.hpp
index 24bf73d..a0968f1 100644
--- a/src/nlsr_lsa.hpp
+++ b/src/nlsr_lsa.hpp
@@ -113,6 +113,7 @@
         string getNameLsaKey();
 
         string getNameLsaData();
+        bool initNameLsaFromContent(string content);
 
     private:
         Npl npl;
@@ -145,6 +146,7 @@
         }
         string getAdjLsaKey();
         string getAdjLsaData();
+        bool initAdjLsaFromContent(string content);
         uint32_t getNoLink()
         {
             return noLink;
@@ -166,7 +168,9 @@
     {
     public:
         CorLsa()
-            :Lsa()
+            : Lsa()
+            , corRad(0)
+            , corTheta(0)
         {
             setLsType(3);
         }
@@ -175,7 +179,7 @@
                , double r, double theta);
         string getCorLsaKey();
         string getCorLsaData();
-
+        bool initCorLsaFromContent(string content);
         double getCorRadius()
         {
             if ( corRad >= 0 )
diff --git a/src/nlsr_lsdb.cpp b/src/nlsr_lsdb.cpp
index cd80809..cada99d 100644
--- a/src/nlsr_lsdb.cpp
+++ b/src/nlsr_lsdb.cpp
@@ -47,6 +47,23 @@
         return std::make_pair(boost::ref(nlsa),false);
     }
 
+    bool
+    Lsdb::isNameLsaNew(string key, uint64_t seqNo)
+    {
+        std::pair<NameLsa& , bool>  nameLsaCheck=getNameLsa(key);
+        if(nameLsaCheck.second)
+        {
+            if(nameLsaCheck.first.getLsSeqNo() < seqNo)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+        return true;
+    }
 
     ndn::EventId
     Lsdb::scheduleNameLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime)
@@ -241,6 +258,24 @@
         return std::make_pair(boost::ref(clsa),false);
     }
 
+    bool
+    Lsdb::isCorLsaNew(string key, uint64_t seqNo)
+    {
+        std::pair<CorLsa& , bool>  corLsaCheck=getCorLsa(key);
+        if(corLsaCheck.second)
+        {
+            if(corLsaCheck.first.getLsSeqNo() < seqNo)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
     ndn::EventId
     Lsdb::scheduleCorLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime)
     {
@@ -432,6 +467,24 @@
     }
 
 
+    bool
+    Lsdb::isAdjLsaNew(string key, uint64_t seqNo)
+    {
+        std::pair<AdjLsa& , bool>  adjLsaCheck=getAdjLsa(key);
+        if(adjLsaCheck.second)
+        {
+            if(adjLsaCheck.first.getLsSeqNo() < seqNo)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
 
     ndn::EventId
     Lsdb::scheduleAdjLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime)
@@ -480,7 +533,6 @@
                                                       alsa.getAdjLsaKey(), alsa.getLsSeqNo(),timeToExpire));
             }
         }
-        printAdjLsdb();
         return true;
     }
 
@@ -494,7 +546,10 @@
                       , pnlsr.getAdl().getNumOfActiveNeighbor()
                       , pnlsr.getAdl() );
         pnlsr.getSm().setAdjLsaSeq(pnlsr.getSm().getAdjLsaSeq()+1);
-        return installAdjLsa(pnlsr, adjLsa);
+        string lsaPrefix=pnlsr.getConfParameter().getChronosyncLsaPrefix()
+                         + pnlsr.getConfParameter().getRouterPrefix();
+        pnlsr.getSlh().publishRoutingUpdate(pnlsr.getSm(),lsaPrefix);
+        return pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
     }
 
     bool
@@ -547,7 +602,7 @@
     Lsdb::exprireOrRefreshNameLsa(Nlsr& pnlsr, string lsaKey, int seqNo)
     {
         cout<<"Lsdb::exprireOrRefreshNameLsa Called "<<endl;
-        cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<endl;
+        cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<seqNo<<endl;
         std::pair<NameLsa& , bool> chkNameLsa=getNameLsa(lsaKey);
         if( chkNameLsa.second )
         {
@@ -560,6 +615,9 @@
                     chkNameLsa.first.setLsSeqNo(chkNameLsa.first.getLsSeqNo()+1);
                     pnlsr.getSm().setNameLsaSeq(chkNameLsa.first.getLsSeqNo());
                     // publish routing update
+                    string lsaPrefix=pnlsr.getConfParameter().getChronosyncLsaPrefix()
+                                     + pnlsr.getConfParameter().getRouterPrefix();
+                    pnlsr.getSlh().publishRoutingUpdate(pnlsr.getSm(),lsaPrefix);
                 }
                 else
                 {
@@ -574,7 +632,7 @@
     Lsdb::exprireOrRefreshAdjLsa(Nlsr& pnlsr, string lsaKey, int seqNo)
     {
         cout<<"Lsdb::exprireOrRefreshAdjLsa Called "<<endl;
-        cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<endl;
+        cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<seqNo<<endl;
         std::pair<AdjLsa& , bool> chkAdjLsa=getAdjLsa(lsaKey);
         if( chkAdjLsa.second )
         {
@@ -587,6 +645,9 @@
                     chkAdjLsa.first.setLsSeqNo(chkAdjLsa.first.getLsSeqNo()+1);
                     pnlsr.getSm().setAdjLsaSeq(chkAdjLsa.first.getLsSeqNo());
                     // publish routing update
+                    string lsaPrefix=pnlsr.getConfParameter().getChronosyncLsaPrefix()
+                                     + pnlsr.getConfParameter().getRouterPrefix();
+                    pnlsr.getSlh().publishRoutingUpdate(pnlsr.getSm(),lsaPrefix);
                 }
                 else
                 {
@@ -603,7 +664,7 @@
     Lsdb::exprireOrRefreshCorLsa(Nlsr& pnlsr, string lsaKey, int seqNo)
     {
         cout<<"Lsdb::exprireOrRefreshCorLsa Called "<<endl;
-        cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<endl;
+        cout<<"LSA Key : "<<lsaKey<<" Seq No: "<<seqNo<<endl;
         std::pair<CorLsa& , bool> chkCorLsa=getCorLsa(lsaKey);
         if( chkCorLsa.second )
         {
@@ -616,6 +677,9 @@
                     chkCorLsa.first.setLsSeqNo(chkCorLsa.first.getLsSeqNo()+1);
                     pnlsr.getSm().setCorLsaSeq(chkCorLsa.first.getLsSeqNo());
                     // publish routing update
+                    string lsaPrefix=pnlsr.getConfParameter().getChronosyncLsaPrefix()
+                                     + pnlsr.getConfParameter().getRouterPrefix();
+                    pnlsr.getSlh().publishRoutingUpdate(pnlsr.getSm(),lsaPrefix);
                 }
                 else
                 {
diff --git a/src/nlsr_lsdb.hpp b/src/nlsr_lsdb.hpp
index 93b2f10..6862224 100644
--- a/src/nlsr_lsdb.hpp
+++ b/src/nlsr_lsdb.hpp
@@ -26,6 +26,7 @@
         std::pair<NameLsa&, bool>  getNameLsa(string key);
         bool installNameLsa(Nlsr& pnlsr, NameLsa &nlsa);
         bool removeNameLsa(Nlsr& pnlsr, string& key);
+        bool isNameLsaNew(string key, uint64_t seqNo);
         void printNameLsdb(); //debugging
 
         //function related to Cor LSDB
@@ -33,12 +34,14 @@
         std::pair<CorLsa&, bool> getCorLsa(string key);
         bool installCorLsa(Nlsr& pnlsr, CorLsa &clsa);
         bool removeCorLsa(Nlsr& pnlsr, string& key);
+        bool isCorLsaNew(string key, uint64_t seqNo);
         void printCorLsdb(); //debugging
 
         //function related to Adj LSDB
         void scheduledAdjLsaBuild(Nlsr& pnlsr);
         bool buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
         bool removeAdjLsa(Nlsr& pnlsr, string& key);
+        bool isAdjLsaNew(string key, uint64_t seqNo);
         bool installAdjLsa(Nlsr& pnlsr, AdjLsa &alsa);
         std::pair<AdjLsa& , bool> getAdjLsa(string key);
         std::list<AdjLsa>& getAdjLsdb();
diff --git a/src/nlsr_map.cpp b/src/nlsr_map.cpp
deleted file mode 100644
index 47b02ec..0000000
--- a/src/nlsr_map.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-#include<iostream>
-#include<list>
-
-#include "nlsr.hpp"
-#include "nlsr_adjacent.hpp"
-#include "nlsr_lsa.hpp"
-#include "nlsr_lsdb.hpp"
-#include "nlsr_map.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    ostream&
-    operator<<(ostream& os, MapEntry& mpe)
-    {
-        os<<"MapEntry: ( Router: "<<mpe.getRouter()<<" Mapping No: ";
-        os<<mpe.getMappingNumber()<<" )"<<endl;
-        return os;
-    }
-
-    static bool
-    mapEntryCompareByRouter(MapEntry& mpe1, string& rtrName)
-    {
-        return mpe1.getRouter()==rtrName;
-    }
-
-    static bool
-    mapEntryCompareByMappingNo(MapEntry& mpe1, int mappingNo)
-    {
-        return mpe1.getMappingNumber()==mappingNo;
-    }
-
-    void
-    Map::addMapElement(string& rtrName)
-    {
-        MapEntry me(rtrName,mappingIndex);
-        if (  addMapElement(me) )
-        {
-            mappingIndex++;
-        }
-    }
-
-    bool
-    Map::addMapElement(MapEntry& mpe)
-    {
-        //cout << mpe;
-        std::list<MapEntry >::iterator it = std::find_if( rMap.begin(),
-                                            rMap.end(),
-                                            bind(&mapEntryCompareByRouter, _1, mpe.getRouter()));
-        if ( it == rMap.end() )
-        {
-            rMap.push_back(mpe);
-            return true;
-        }
-        return false;
-    }
-
-    string
-    Map::getRouterNameByMappingNo(int mn)
-    {
-        std::list<MapEntry >::iterator it = std::find_if( rMap.begin(),
-                                            rMap.end(),
-                                            bind(&mapEntryCompareByMappingNo, _1, mn));
-        if ( it != rMap.end() )
-        {
-            return (*it).getRouter();
-        }
-        return "";
-    }
-
-    int
-    Map::getMappingNoByRouterName(string& rName)
-    {
-        std::list<MapEntry >::iterator it = std::find_if( rMap.begin(),
-                                            rMap.end(),
-                                            bind(&mapEntryCompareByRouter, _1, rName));
-        if ( it != rMap.end() )
-        {
-            return (*it).getMappingNumber();
-        }
-        return -1;
-    }
-
-    void
-    Map::createMapFromAdjLsdb(Nlsr& pnlsr)
-    {
-        std::list<AdjLsa> adjLsdb=pnlsr.getLsdb().getAdjLsdb();
-        for( std::list<AdjLsa>::iterator it=adjLsdb.begin();
-                it!= adjLsdb.end() ; it++)
-        {
-            string linkStartRouter=(*it).getOrigRouter();
-            addMapElement(linkStartRouter);
-            std::list<Adjacent> adl=(*it).getAdl().getAdjList();
-            for( std::list<Adjacent>::iterator itAdl=adl.begin();
-                    itAdl!= adl.end() ; itAdl++)
-            {
-                string linkEndRouter=(*itAdl).getAdjacentName();
-                addMapElement(linkEndRouter);
-            }
-        }
-    }
-
-    void
-    Map::resetMap()
-    {
-        rMap.clear();
-        mappingIndex=0;
-    }
-
-    ostream&
-    operator<<(ostream& os, Map& rMap)
-    {
-        os<<"---------------Map----------------------"<<endl;
-        std::list< MapEntry > ml=rMap.getMapList();
-        for( std::list<MapEntry>::iterator it=ml.begin(); it!= ml.end() ; it++)
-        {
-            os<< (*it);
-        }
-        return os;
-    }
-
-} //namespace nlsr
diff --git a/src/nlsr_map.hpp b/src/nlsr_map.hpp
deleted file mode 100644
index 0352d1d..0000000
--- a/src/nlsr_map.hpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef NLSR_MAP_HPP
-#define NLSR_MAP_HPP
-
-#include <iostream>
-#include <list>
-
-#include <ndn-cpp-dev/face.hpp>
-
-namespace nlsr
-{
-
-    class Nlsr;
-
-    using namespace std;
-
-    class MapEntry
-    {
-    public:
-        MapEntry()
-            : router()
-            , mappingNumber(-1)
-        {
-        }
-
-        ~MapEntry()
-        {
-        }
-
-        MapEntry(string rtr, int mn)
-        {
-            router=rtr;
-            mappingNumber=mn;
-        }
-
-        string getRouter()
-        {
-            return router;
-        }
-
-        int getMappingNumber()
-        {
-            return mappingNumber;
-        }
-    private:
-        string router;
-        int mappingNumber;
-    };
-
-    ostream&
-    operator<<(ostream& os, MapEntry& mpe);
-
-    class Map
-    {
-    public:
-        Map()
-            : mappingIndex(0)
-        {
-        }
-
-
-        void addMapElement(string& rtrName);
-        void createMapFromAdjLsdb(Nlsr& pnlsr);
-        string getRouterNameByMappingNo(int mn);
-        int getMappingNoByRouterName(string& rName);
-        void resetMap();
-        std::list< MapEntry >& getMapList()
-        {
-            return rMap;
-        }
-
-        int getMapSize()
-        {
-            return rMap.size();
-        }
-
-
-    private:
-        bool addMapElement(MapEntry& mpe);
-
-        int mappingIndex;
-        std::list< MapEntry > rMap;
-    };
-
-    ostream&
-    operator<<(ostream& os, Map& rMap);
-
-} // namespace nlsr
-#endif
diff --git a/src/nlsr_nexthop.cpp b/src/nlsr_nexthop.cpp
deleted file mode 100644
index e58b23c..0000000
--- a/src/nlsr_nexthop.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "nlsr_nexthop.hpp"
-
-namespace nlsr
-{
-
-    ostream&
-    operator<<(ostream& os, NextHop& nh)
-    {
-        os<<"Face: "<<nh.getConnectingFace()<<"  Route Cost: "<<nh.getRouteCost();
-        return os;
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_nexthop.hpp b/src/nlsr_nexthop.hpp
deleted file mode 100644
index 1361d52..0000000
--- a/src/nlsr_nexthop.hpp
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef NLSR_NEXTHOP_HPP
-#define NLSR_NEXTHOP_HPP
-
-#include<iostream>
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    class NextHop
-    {
-    public:
-        NextHop()
-            : connectingFace(0)
-            , routeCost(0)
-        {
-        }
-
-        NextHop(int cf, double rc)
-        {
-            connectingFace=cf;
-            routeCost=rc;
-        }
-
-        int getConnectingFace()
-        {
-            return connectingFace;
-        }
-
-        void setConnectingFace(int cf)
-        {
-            connectingFace=cf;
-        }
-
-        double getRouteCost()
-        {
-            return routeCost;
-        }
-
-        void setRouteCost(double rc)
-        {
-            routeCost=rc;
-        }
-    private:
-        int connectingFace;
-        double routeCost;
-    };
-
-
-    ostream&
-    operator<<(ostream& os, NextHop& nh);
-
-}//namespace nlsr
-
-#endif
diff --git a/src/nlsr_nhl.cpp b/src/nlsr_nhl.cpp
deleted file mode 100644
index 2aaa2a6..0000000
--- a/src/nlsr_nhl.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-#include <iostream>
-
-#include "nlsr_nhl.hpp"
-#include "nlsr_nexthop.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    static bool
-    nexthopCompare(NextHop& nh1, NextHop& nh2)
-    {
-        return nh1.getConnectingFace()==nh2.getConnectingFace();
-    }
-
-    static bool
-    nexthopRemoveCompare(NextHop& nh1, NextHop& nh2)
-    {
-        return (nh1.getConnectingFace()==nh2.getConnectingFace() &&
-                nh1.getRouteCost() == nh2.getRouteCost()) ;
-    }
-
-    static bool
-    nextHopSortingComparator(NextHop& nh1, NextHop& nh2)
-    {
-        return nh1.getRouteCost() < nh2.getRouteCost();
-    }
-
-    /**
-    Add next hop to the Next Hop list
-    If next hop is new it is added
-    If next hop already exists in next
-    hop list then updates the route
-    cost with new next hop's route cost
-    */
-
-    void
-    Nhl::addNextHop(NextHop& nh)
-    {
-        std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(),
-                                           nexthopList.end(),
-                                           bind(&nexthopCompare, _1, nh));
-        if ( it == nexthopList.end() )
-        {
-            nexthopList.push_back(nh);
-        }
-        if ( (*it).getRouteCost() > nh.getRouteCost() )
-        {
-            (*it).setRouteCost(nh.getRouteCost());
-        }
-    }
-
-    /**
-    Remove a next hop only if both next hop face and route cost are same
-
-    */
-
-    void
-    Nhl::removeNextHop(NextHop &nh)
-    {
-        std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(),
-                                           nexthopList.end(),
-                                           bind(&nexthopRemoveCompare, _1, nh));
-        if ( it != nexthopList.end() )
-        {
-            nexthopList.erase(it);
-        }
-    }
-
-    void
-    Nhl::sortNhl()
-    {
-        nexthopList.sort(nextHopSortingComparator);
-    }
-
-    ostream&
-    operator<<(ostream& os, Nhl& nhl)
-    {
-        std::list< NextHop > nexthopList = nhl.getNextHopList();
-        int i=1;
-        for( std::list<NextHop>::iterator it=nexthopList.begin();
-                it!= nexthopList.end() ; it++,i++)
-        {
-            os << "Nexthop "<<i<<": "<<(*it)<<endl;
-        }
-        return os;
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_nhl.hpp b/src/nlsr_nhl.hpp
deleted file mode 100644
index 9f6bd76..0000000
--- a/src/nlsr_nhl.hpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef NLSR_NHL_HPP
-#define NLSR_NHL_HPP
-
-#include <ndn-cpp-dev/face.hpp>
-#include "nlsr_adjacent.hpp"
-#include <list>
-#include <iostream>
-
-#include "nlsr_nexthop.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    class Nhl
-    {
-    public:
-        Nhl()
-        {
-        }
-
-        ~Nhl()
-        {
-        }
-        void addNextHop(NextHop &nh);
-        void removeNextHop(NextHop &nh);
-        void sortNhl();
-        int getNhlSize()
-        {
-            return nexthopList.size();
-        }
-        void resetNhl()
-        {
-            if (nexthopList.size() > 0 )
-            {
-                nexthopList.clear();
-            }
-        }
-        std::list< NextHop >& getNextHopList()
-        {
-            return nexthopList;
-        }
-
-    private:
-        std::list< NextHop > nexthopList;
-    };
-
-    ostream&
-    operator<<(ostream& os, Nhl& nhl);
-
-}//namespace nlsr
-
-#endif
diff --git a/src/nlsr_npt.cpp b/src/nlsr_npt.cpp
deleted file mode 100644
index 9c4d4cb..0000000
--- a/src/nlsr_npt.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-#include <list>
-#include <utility>
-#include <algorithm>
-
-#include "nlsr_npt.hpp"
-#include "nlsr_npte.hpp"
-#include "nlsr.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    static bool
-    npteCompare(Npte& npte, string& name)
-    {
-        return npte.getNamePrefix()==name;
-    }
-
-// Following two methods will update FIB with response to change in NPT
-
-    void
-    Npt::addNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
-    {
-        std::list<Npte >::iterator it = std::find_if( npteList.begin(),
-                                        npteList.end(), bind(&npteCompare, _1, name));
-        if ( it == npteList.end() )
-        {
-            Npte newEntry(	name);
-            newEntry.addRoutingTableEntry(rte);
-            newEntry.generateNhlfromRteList();
-            npteList.push_back(newEntry);
-            // update FIB here with nhl list newEntry.getNhl()
-            pnlsr.getFib().updateFib(pnlsr, name,newEntry.getNhl(),
-                                     pnlsr.getConfParameter().getMaxFacesPerPrefix());
-        }
-        else
-        {
-            (*it).addRoutingTableEntry(rte);
-            (*it).generateNhlfromRteList();
-            // update FIB here with nhl list from (*it).getNhl()
-            pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl() ,
-                                     pnlsr.getConfParameter().getMaxFacesPerPrefix());
-        }
-    }
-
-    void
-    Npt::removeNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr)
-    {
-        std::list<Npte >::iterator it = std::find_if( npteList.begin(),
-                                        npteList.end(), bind(&npteCompare, _1, name));
-        if ( it != npteList.end() )
-        {
-            string destRouter=rte.getDestination();
-            (*it).removeRoutingTableEntry(rte);
-            if ( ((*it).getRteListSize() == 0 ) &&
-                    (!pnlsr.getLsdb().doesLsaExist(destRouter+"/1",1) ) &&
-                    (!pnlsr.getLsdb().doesLsaExist(destRouter+"/2",2) ) &&
-                    (!pnlsr.getLsdb().doesLsaExist(destRouter+"/3",3) )   )
-            {
-                npteList.erase(it); // remove entry from NPT
-                // remove FIB entry with this name
-                pnlsr.getFib().removeFromFib(pnlsr,name);
-            }
-            else
-            {
-                (*it).generateNhlfromRteList();
-                // update FIB entry with new NHL
-                pnlsr.getFib().updateFib(pnlsr, name,(*it).getNhl(),
-                                         pnlsr.getConfParameter().getMaxFacesPerPrefix());
-            }
-        }
-    }
-
-
-    void
-    Npt::addNpte(string name, string destRouter, Nlsr& pnlsr)
-    {
-        std::pair<RoutingTableEntry& , bool> rteCheck=
-            pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
-        if(rteCheck.second)
-        {
-            addNpte(name,rteCheck.first,pnlsr);
-        }
-        else
-        {
-            RoutingTableEntry rte(destRouter);
-            addNpte(name, rte,pnlsr);
-        }
-    }
-
-    void
-    Npt::removeNpte(string name, string destRouter, Nlsr& pnlsr)
-    {
-        std::pair<RoutingTableEntry& , bool> rteCheck=
-            pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
-        if(rteCheck.second)
-        {
-            removeNpte(name,rteCheck.first,pnlsr);
-        }
-        else
-        {
-            RoutingTableEntry rte(destRouter);
-            removeNpte(name, rte,pnlsr);
-        }
-    }
-
-    void
-    Npt::updateNptWithNewRoute(Nlsr& pnlsr)
-    {
-        for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
-        {
-            std::list<RoutingTableEntry> rteList=(*it).getRteList();
-            for(std::list<RoutingTableEntry >::iterator rteit=rteList.begin();
-                    rteit !=rteList.end(); ++rteit)
-            {
-                std::pair<RoutingTableEntry& , bool> rteCheck=
-                    pnlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
-                if(rteCheck.second)
-                {
-                    addNpte((*it).getNamePrefix(),rteCheck.first,pnlsr);
-                }
-                else
-                {
-                    RoutingTableEntry rte((*rteit).getDestination());
-                    addNpte((*it).getNamePrefix(), rte,pnlsr);
-                }
-            }
-        }
-    }
-
-    void
-    Npt::printNpt()
-    {
-        cout<<"----------------NPT----------------------"<<endl;
-        for(std::list<Npte >::iterator it=npteList.begin(); it!=npteList.end(); ++it)
-        {
-            cout <<(*it)<<endl;
-        }
-    }
-
-}
diff --git a/src/nlsr_npt.hpp b/src/nlsr_npt.hpp
deleted file mode 100644
index f4ddbf9..0000000
--- a/src/nlsr_npt.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef NLSR_NPT_HPP
-#define NLSR_NPT_HPP
-
-#include <list>
-#include "nlsr_npte.hpp"
-#include "nlsr_rte.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    class Nlsr;
-
-    class Npt
-    {
-    public:
-        Npt()
-        {
-        }
-        void addNpte(string name, string destRouter, Nlsr& pnlsr);
-        void removeNpte(string name, string destRouter, Nlsr& pnlsr);
-        void updateNptWithNewRoute(Nlsr& pnlsr);
-        void printNpt();
-    private:
-        void addNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr);
-        void removeNpte(string name, RoutingTableEntry& rte, Nlsr& pnlsr);
-    private:
-        std::list<Npte> npteList;
-    };
-
-}//namespace nlsr
-
-#endif
diff --git a/src/nlsr_npte.cpp b/src/nlsr_npte.cpp
deleted file mode 100644
index 60013ff..0000000
--- a/src/nlsr_npte.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <list>
-#include <utility>
-#include "nlsr_npte.hpp"
-#include "nlsr_rte.hpp"
-#include "nlsr_nexthop.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    void
-    Npte::generateNhlfromRteList()
-    {
-        nhl.resetNhl();
-        for( std::list<RoutingTableEntry>::iterator it=rteList.begin();
-                it != rteList.end(); ++it )
-        {
-            for(std::list< NextHop >::iterator nhit=(*it).getNhl().getNextHopList().begin();
-                    nhit != (*it).getNhl().getNextHopList().end(); ++nhit)
-            {
-                nhl.addNextHop((*nhit));
-            }
-        }
-    }
-
-
-
-    static bool
-    rteCompare(RoutingTableEntry& rte, string& destRouter)
-    {
-        return rte.getDestination()==destRouter;
-    }
-
-    void
-    Npte::removeRoutingTableEntry(RoutingTableEntry& rte)
-    {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
-                rteList.end(),
-                bind(&rteCompare, _1, rte.getDestination()));
-        if ( it != rteList.end() )
-        {
-            rteList.erase(it);
-        }
-    }
-
-    void
-    Npte::addRoutingTableEntry(RoutingTableEntry &rte)
-    {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( rteList.begin(),
-                rteList.end(),
-                bind(&rteCompare, _1, rte.getDestination()));
-        if ( it == rteList.end() )
-        {
-            rteList.push_back(rte);
-        }
-        else
-        {
-            (*it).getNhl().resetNhl(); // reseting existing routing table's next hop
-            for(std::list< NextHop >::iterator nhit=rte.getNhl().getNextHopList().begin();
-                    nhit != rte.getNhl().getNextHopList().end(); ++nhit)
-            {
-                (*it).getNhl().addNextHop((*nhit));
-            }
-        }
-    }
-
-//debugging purpose
-    ostream&
-    operator<<(ostream& os, Npte& npte)
-    {
-        os<<"Name: "<<npte.getNamePrefix()<<endl;
-        std::list<RoutingTableEntry> rteList=npte.getRteList();
-        for(std::list<RoutingTableEntry >::iterator it=rteList.begin();
-                it !=rteList.end(); ++it)
-        {
-            cout<<(*it);
-        }
-        os<<npte.getNhl();
-        return os;
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_npte.hpp b/src/nlsr_npte.hpp
deleted file mode 100644
index e64328c..0000000
--- a/src/nlsr_npte.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef NLSR_NPTE_HPP
-#define NLSR_NPTE_HPP
-
-#include <list>
-#include <utility>
-#include "nlsr_rte.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    class Npte
-    {
-    public:
-        Npte()
-            : namePrefix()
-            , nhl()
-        {
-        }
-        Npte(string np)
-            : nhl()
-        {
-            namePrefix=np;
-        }
-
-        string getNamePrefix()
-        {
-            return namePrefix;
-        }
-
-        std::list<RoutingTableEntry>& getRteList()
-        {
-            return rteList;
-        }
-
-        int getRteListSize()
-        {
-            return rteList.size();
-        }
-
-        Nhl& getNhl()
-        {
-            return nhl;
-        }
-        void generateNhlfromRteList();
-        void removeRoutingTableEntry(RoutingTableEntry& rte);
-        void addRoutingTableEntry(RoutingTableEntry &rte);
-
-    private:
-        string namePrefix;
-        std::list<RoutingTableEntry> rteList;
-        Nhl nhl;
-    };
-
-    ostream&
-    operator<<(ostream& os, Npte& npte);
-
-}//namespace nlsr
-
-#endif
diff --git a/src/nlsr_rt.cpp b/src/nlsr_rt.cpp
deleted file mode 100644
index 87dcd26..0000000
--- a/src/nlsr_rt.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-#include<iostream>
-#include<string>
-#include<list>
-
-#include "nlsr_rt.hpp"
-#include "nlsr.hpp"
-#include "nlsr_map.hpp"
-#include "nlsr_rtc.hpp"
-#include "nlsr_rte.hpp"
-#include "nlsr_npt.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    void
-    RoutingTable::calculate(Nlsr& pnlsr)
-    {
-        //debugging purpose
-        pnlsr.getNpt().printNpt();
-        if ( 	pnlsr.getIsRoutingTableCalculating() == 0 )
-        {
-            pnlsr.setIsRoutingTableCalculating(1); //setting routing table calculation
-            if ( pnlsr.getLsdb().doesLsaExist(
-                        pnlsr.getConfParameter().getRouterPrefix()+"/"+"2",2) )
-            {
-                if(pnlsr.getIsBuildAdjLsaSheduled() != 1)
-                {
-                    cout<<"CLearing old routing table ....."<<endl;
-                    clearRoutingTable();
-                    clearDryRoutingTable(); // for dry run options
-                    // calculate Link State routing
-                    if( (pnlsr.getConfParameter().getIsHyperbolicCalc() == 0 )
-                            || (pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 ) )
-                    {
-                        calculateLsRoutingTable(pnlsr);
-                    }
-                    //calculate hyperbolic routing
-                    if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 1 )
-                    {
-                        calculateHypRoutingTable(pnlsr);
-                    }
-                    //calculate dry hyperbolic routing
-                    if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 )
-                    {
-                        calculateHypDryRoutingTable(pnlsr);
-                    }
-                    //need to update NPT here
-                    pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
-                    //debugging purpose
-                    printRoutingTable();
-                    pnlsr.getNpt().printNpt();
-                    pnlsr.getFib().printFib();
-                    //debugging purpose end
-                }
-                else
-                {
-                    cout<<"Adjacency building is scheduled, so ";
-                    cout<<"routing table can not be calculated :("<<endl;
-                }
-            }
-            else
-            {
-                cout<<"No Adj LSA of router itself,";
-                cout<<	" so Routing table can not be calculated :("<<endl;
-                clearRoutingTable();
-                clearDryRoutingTable(); // for dry run options
-                // need to update NPT here
-                pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
-                //debugging purpose
-                printRoutingTable();
-                pnlsr.getNpt().printNpt();
-                pnlsr.getFib().printFib();
-                //debugging purpose end
-            }
-            pnlsr.setIsRouteCalculationScheduled(0); //clear scheduled flag
-            pnlsr.setIsRoutingTableCalculating(0); //unsetting routing table calculation
-        }
-        else
-        {
-            scheduleRoutingTableCalculation(pnlsr);
-        }
-    }
-
-
-    void
-    RoutingTable::calculateLsRoutingTable(Nlsr& pnlsr)
-    {
-        cout<<"RoutingTable::calculateLsRoutingTable Called"<<endl;
-        Map vMap;
-        vMap.createMapFromAdjLsdb(pnlsr);
-        int numOfRouter=vMap.getMapSize();
-        LinkStateRoutingTableCalculator lsrtc(numOfRouter);
-        lsrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
-    }
-
-    void
-    RoutingTable::calculateHypRoutingTable(Nlsr& pnlsr)
-    {
-        Map vMap;
-        vMap.createMapFromAdjLsdb(pnlsr);
-        int numOfRouter=vMap.getMapSize();
-        HypRoutingTableCalculator hrtc(numOfRouter,0);
-        hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
-    }
-
-    void
-    RoutingTable::calculateHypDryRoutingTable(Nlsr& pnlsr)
-    {
-        Map vMap;
-        vMap.createMapFromAdjLsdb(pnlsr);
-        int numOfRouter=vMap.getMapSize();
-        HypRoutingTableCalculator hrtc(numOfRouter,1);
-        hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
-    }
-
-    void
-    RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
-    {
-        if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
-        {
-            pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
-                                               ndn::bind(&RoutingTable::calculate,this,boost::ref(pnlsr)));
-            pnlsr.setIsRouteCalculationScheduled(1);
-        }
-    }
-
-    static bool
-    routingTableEntryCompare(RoutingTableEntry& rte, string& destRouter)
-    {
-        return rte.getDestination()==destRouter;
-    }
-
-// function related to manipulation of routing table
-    void
-    RoutingTable::addNextHop(string destRouter, NextHop& nh)
-    {
-        std::pair<RoutingTableEntry&, bool> rte=findRoutingTableEntry(destRouter);
-        if( !rte.second )
-        {
-            RoutingTableEntry rte(destRouter);
-            rte.getNhl().addNextHop(nh);
-            rTable.push_back(rte);
-        }
-        else
-        {
-            (rte.first).getNhl().addNextHop(nh);
-        }
-    }
-
-    std::pair<RoutingTableEntry&, bool>
-    RoutingTable::findRoutingTableEntry(string destRouter)
-    {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( rTable.begin(),
-                rTable.end(),
-                bind(&routingTableEntryCompare, _1, destRouter));
-        if ( it != rTable.end() )
-        {
-            return std::make_pair(boost::ref((*it)),true);
-        }
-        RoutingTableEntry rteEmpty;
-        return std::make_pair(boost::ref(rteEmpty),false);
-    }
-
-    void
-    RoutingTable::printRoutingTable()
-    {
-        cout<<"---------------Routing Table------------------"<<endl;
-        for(std::list<RoutingTableEntry>::iterator it=rTable.begin() ;
-                it != rTable.end(); ++it)
-        {
-            cout<<(*it)<<endl;
-        }
-    }
-
-
-//function related to manipulation of dry routing table
-    void
-    RoutingTable::addNextHopToDryTable(string destRouter, NextHop& nh)
-    {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( dryTable.begin(),
-                dryTable.end(),
-                bind(&routingTableEntryCompare, _1, destRouter));
-        if ( it == dryTable.end() )
-        {
-            RoutingTableEntry rte(destRouter);
-            rte.getNhl().addNextHop(nh);
-            dryTable.push_back(rte);
-        }
-        else
-        {
-            (*it).getNhl().addNextHop(nh);
-        }
-    }
-
-    void
-    RoutingTable::printDryRoutingTable()
-    {
-        cout<<"--------Dry Run's Routing Table--------------"<<endl;
-        for(std::list<RoutingTableEntry>::iterator it=dryTable.begin() ;
-                it != dryTable.end(); ++it)
-        {
-            cout<<(*it)<<endl;
-        }
-    }
-
-
-    void
-    RoutingTable::clearRoutingTable()
-    {
-        if( rTable.size() > 0 )
-        {
-            rTable.clear();
-        }
-    }
-
-    void
-    RoutingTable::clearDryRoutingTable()
-    {
-        if (dryTable.size()>0 )
-        {
-            dryTable.clear();
-        }
-    }
-
-}//namespace nlsr
-
diff --git a/src/nlsr_rt.hpp b/src/nlsr_rt.hpp
deleted file mode 100644
index fb9a060..0000000
--- a/src/nlsr_rt.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef NLSR_RT_HPP
-#define NLSR_RT_HPP
-
-#include<iostream>
-#include<utility>
-#include<string>
-
-#include "nlsr_rte.hpp"
-
-namespace nlsr
-{
-
-    class Nlsr;
-    class NextHop;
-
-    using namespace std;
-
-    class RoutingTable
-    {
-    public:
-        RoutingTable()
-            : NO_NEXT_HOP(-12345)
-        {
-        }
-        void calculate(Nlsr& pnlsr);
-        void addNextHop(string destRouter, NextHop& nh);
-        void printRoutingTable();
-
-        void addNextHopToDryTable(string destRouter, NextHop& nh);
-        void printDryRoutingTable();
-        std::pair<RoutingTableEntry&, bool> findRoutingTableEntry(string destRouter);
-        void scheduleRoutingTableCalculation(Nlsr& pnlsr);
-
-    private:
-        void calculateLsRoutingTable(Nlsr& pnlsr);
-        void calculateHypRoutingTable(Nlsr& pnlsr);
-        void calculateHypDryRoutingTable(Nlsr&pnlsr);
-
-        void clearRoutingTable();
-        void clearDryRoutingTable();
-
-        const int NO_NEXT_HOP;
-
-        std::list< RoutingTableEntry > rTable;
-        std::list< RoutingTableEntry > dryTable;
-    };
-
-}//namespace nlsr
-
-#endif
diff --git a/src/nlsr_rtc.cpp b/src/nlsr_rtc.cpp
deleted file mode 100644
index acdf6d5..0000000
--- a/src/nlsr_rtc.cpp
+++ /dev/null
@@ -1,504 +0,0 @@
-#include <iostream>
-#include <cmath>
-#include "nlsr_lsdb.hpp"
-#include "nlsr_rtc.hpp"
-#include "nlsr_map.hpp"
-#include "nlsr_lsa.hpp"
-#include "nlsr_nexthop.hpp"
-#include "nlsr.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    void
-    RoutingTableCalculator::allocateAdjMatrix()
-    {
-        adjMatrix = new double*[numOfRouter];
-        for(int i = 0; i < numOfRouter; ++i)
-        {
-            adjMatrix[i] = new double[numOfRouter];
-        }
-    }
-
-    void
-    RoutingTableCalculator::initMatrix()
-    {
-        for(int i=0; i<numOfRouter; i++)
-        {
-            for(int j=0; j<numOfRouter; j++)
-                adjMatrix[i][j]=0;
-        }
-    }
-
-    void
-    RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
-    {
-        std::list<AdjLsa> adjLsdb=pnlsr.getLsdb().getAdjLsdb();
-        for( std::list<AdjLsa>::iterator it=adjLsdb.begin();
-                it!= adjLsdb.end() ; it++)
-        {
-            string linkStartRouter=(*it).getOrigRouter();
-            int row=pMap.getMappingNoByRouterName(linkStartRouter);
-            std::list<Adjacent> adl=(*it).getAdl().getAdjList();
-            for( std::list<Adjacent>::iterator itAdl=adl.begin();
-                    itAdl!= adl.end() ; itAdl++)
-            {
-                string linkEndRouter=(*itAdl).getAdjacentName();
-                int col=pMap.getMappingNoByRouterName(linkEndRouter);
-                double cost=(*itAdl).getLinkCost();
-                if ( (row >= 0 && row<numOfRouter) && (col >= 0 && col<numOfRouter) )
-                {
-                    adjMatrix[row][col]=cost;
-                }
-            }
-        }
-    }
-
-    void
-    RoutingTableCalculator::printAdjMatrix()
-    {
-        for(int i=0; i<numOfRouter; i++)
-        {
-            for(int j=0; j<numOfRouter; j++)
-                printf("%f ",adjMatrix[i][j]);
-            printf("\n");
-        }
-    }
-
-    void
-    RoutingTableCalculator::adjustAdMatrix(int source, int link, double linkCost)
-    {
-        for ( int i = 0; i < numOfRouter; i++ )
-        {
-            if ( i == link )
-            {
-                adjMatrix[source][i]=linkCost;
-            }
-            else
-            {
-                adjMatrix[source][i]=0;
-            }
-        }
-    }
-
-    int
-    RoutingTableCalculator::getNumOfLinkfromAdjMatrix(int sRouter)
-    {
-        int noLink=0;
-        for(int i=0; i<numOfRouter; i++)
-        {
-            if ( adjMatrix[sRouter][i] > 0 )
-            {
-                noLink++;
-            }
-        }
-        return noLink;
-    }
-
-    void
-    RoutingTableCalculator::getLinksFromAdjMatrix(int *links,
-            double *linkCosts, int source)
-    {
-        int j=0;
-        for (int i=0; i <numOfRouter; i++)
-        {
-            if ( adjMatrix[source][i] > 0 )
-            {
-                links[j]=i;
-                linkCosts[j]=adjMatrix[source][i];
-                j++;
-            }
-        }
-    }
-
-    void
-    RoutingTableCalculator::freeAdjMatrix()
-    {
-        for(int i = 0; i < numOfRouter; ++i)
-        {
-            delete [] adjMatrix[i];
-        }
-        delete [] adjMatrix;
-    }
-
-
-    void
-    RoutingTableCalculator::allocateLinks()
-    {
-        links=new int[vNoLink];
-    }
-
-    void RoutingTableCalculator::allocateLinkCosts()
-    {
-        linkCosts=new double[vNoLink];
-    }
-
-
-    void
-    RoutingTableCalculator::freeLinks()
-    {
-        delete [] links;
-    }
-    void
-    RoutingTableCalculator::freeLinksCosts()
-    {
-        delete [] linkCosts;
-    }
-
-    void
-    LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
-            RoutingTable& rt, Nlsr& pnlsr)
-    {
-        cout<<"LinkStateRoutingTableCalculator::calculatePath Called"<<endl;
-        allocateAdjMatrix();
-        initMatrix();
-        makeAdjMatrix(pnlsr,pMap);
-        cout<<pMap;
-        printAdjMatrix();
-        string routerName=pnlsr.getConfParameter().getRouterPrefix();
-        int sourceRouter=pMap.getMappingNoByRouterName(routerName);
-        int noLink=getNumOfLinkfromAdjMatrix(sourceRouter);
-        allocateParent();
-        allocateDistance();
-        if ( pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1 )
-        {
-            // Single Path
-            doDijkstraPathCalculation(sourceRouter);
-            // print all ls path -- debugging purpose
-            printAllLsPath(sourceRouter);
-            // update routing table
-            addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
-        }
-        else
-        {
-            // Multi Path
-            setNoLink(getNumOfLinkfromAdjMatrix(sourceRouter));
-            allocateLinks();
-            allocateLinkCosts();
-            getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
-            for (int i=0 ; i < vNoLink; i++)
-            {
-                adjustAdMatrix(sourceRouter,links[i], linkCosts[i]);
-                printAdjMatrix();
-                doDijkstraPathCalculation(sourceRouter);
-                // print all ls path -- debugging purpose
-                printAllLsPath(sourceRouter);
-                //update routing table
-                addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
-            }
-            freeLinks();
-            freeLinksCosts();
-        }
-        freeParent();
-        freeDistance();
-        freeAdjMatrix();
-    }
-
-    void
-    LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter)
-    {
-        int i;
-        int v,u;
-        int *Q=new int[numOfRouter];
-        int head=0;
-        /* Initiate the Parent */
-        for (i = 0 ; i < numOfRouter; i++)
-        {
-            parent[i]=EMPTY_PARENT;
-            distance[i]=INF_DISTANCE;
-            Q[i]=i;
-        }
-        if ( sourceRouter != NO_MAPPING_NUM )
-        {
-            distance[sourceRouter]=0;
-            sortQueueByDistance(Q,distance,head,numOfRouter);
-            while (head < numOfRouter )
-            {
-                u=Q[head];
-                if(distance[u] == INF_DISTANCE)
-                {
-                    break;
-                }
-                for(v=0 ; v <numOfRouter; v++)
-                {
-                    if( adjMatrix[u][v] > 0 )
-                    {
-                        if ( isNotExplored(Q,v,head+1,numOfRouter) )
-                        {
-                            if( distance[u] + adjMatrix[u][v] <  distance[v])
-                            {
-                                distance[v]=distance[u] + adjMatrix[u][v] ;
-                                parent[v]=u;
-                            }
-                        }
-                    }
-                }
-                head++;
-                sortQueueByDistance(Q,distance,head,numOfRouter);
-            }
-        }
-        delete [] Q;
-    }
-
-    void
-    LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr,
-            RoutingTable& rt, Map& pMap, int sourceRouter)
-    {
-        cout<<"LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called";
-        cout<<endl;
-        for(int i=0; i < numOfRouter ; i++)
-        {
-            if ( i!= sourceRouter )
-            {
-                int nextHopRouter=getLsNextHop(i,sourceRouter);
-                double routeCost=distance[i];
-                string nextHopRouterName=pMap.getRouterNameByMappingNo(nextHopRouter);
-                int nxtHopFace=
-                    pnlsr.getAdl().getAdjacent(nextHopRouterName).getConnectingFace();
-                cout<<"Dest Router: "<<pMap.getRouterNameByMappingNo(i)<<endl;
-                cout<<"Next hop Router: "<<nextHopRouterName<<endl;
-                cout<<"Next hop Face: "<<nxtHopFace<<endl;
-                cout<<"Route Cost: "<<routeCost<<endl;
-                cout<<endl;
-                // Add next hop to routing table
-                NextHop nh(nxtHopFace,routeCost);
-                rt.addNextHop(pMap.getRouterNameByMappingNo(i),nh);
-            }
-        }
-    }
-
-    int
-    LinkStateRoutingTableCalculator::getLsNextHop(int dest, int source)
-    {
-        int nextHop;
-        while ( parent[dest] != EMPTY_PARENT )
-        {
-            nextHop=dest;
-            dest=parent[dest];
-        }
-        if ( dest != source )
-        {
-            nextHop=NO_NEXT_HOP;
-        }
-        return nextHop;
-    }
-
-    void
-    LinkStateRoutingTableCalculator::printAllLsPath(int sourceRouter)
-    {
-        cout<<"LinkStateRoutingTableCalculator::printAllLsPath Called"<<endl;
-        cout<<"Source Router: "<<sourceRouter<<endl;
-        for(int i=0; i < numOfRouter ; i++)
-        {
-            if ( i!= sourceRouter )
-            {
-                printLsPath(i);
-                cout<<endl;
-            }
-        }
-    }
-
-    void
-    LinkStateRoutingTableCalculator::printLsPath(int destRouter)
-    {
-        if (parent[destRouter] != EMPTY_PARENT )
-        {
-            printLsPath(parent[destRouter]);
-        }
-        cout<<" "<<destRouter;
-    }
-
-    void
-    LinkStateRoutingTableCalculator::sortQueueByDistance(int *Q,
-            double *dist,int start,int element)
-    {
-        for ( int i=start ; i < element ; i ++)
-        {
-            for( int j=i+1; j<element; j ++)
-            {
-                if (dist[Q[j]] < dist[Q[i]])
-                {
-                    int tempU=Q[j];
-                    Q[j]=Q[i];
-                    Q[i]=tempU;
-                }
-            }
-        }
-    }
-
-    int
-    LinkStateRoutingTableCalculator::isNotExplored(int *Q,
-            int u,int start, int element)
-    {
-        int ret=0;
-        for(int i=start; i< element; i++)
-        {
-            if ( Q[i] == u )
-            {
-                ret=1;
-                break;
-            }
-        }
-        return ret;
-    }
-
-    void
-    LinkStateRoutingTableCalculator::allocateParent()
-    {
-        parent=new int[numOfRouter];
-    }
-
-    void
-    LinkStateRoutingTableCalculator::allocateDistance()
-    {
-        distance= new double[numOfRouter];
-    }
-
-    void
-    LinkStateRoutingTableCalculator::freeParent()
-    {
-        delete [] parent;
-    }
-
-    void LinkStateRoutingTableCalculator::freeDistance()
-    {
-        delete [] distance;
-    }
-
-
-
-    void
-    HypRoutingTableCalculator::calculatePath(Map& pMap,
-            RoutingTable& rt, Nlsr& pnlsr)
-    {
-        makeAdjMatrix(pnlsr,pMap);
-        string routerName=pnlsr.getConfParameter().getRouterPrefix();
-        int sourceRouter=pMap.getMappingNoByRouterName(routerName);
-        int noLink=getNumOfLinkfromAdjMatrix(sourceRouter);
-        setNoLink(noLink);
-        allocateLinks();
-        allocateLinkCosts();
-        getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
-        for(int i=0 ; i < numOfRouter ; ++i)
-        {
-            int k=0;
-            if ( i != sourceRouter)
-            {
-                allocateLinkFaces();
-                allocateDistanceToNeighbor();
-                allocateDistFromNbrToDest();
-                for(int j=0; j<vNoLink; j++)
-                {
-                    string nextHopRouterName=pMap.getRouterNameByMappingNo(links[j]);
-                    int nextHopFace=
-                        pnlsr.getAdl().getAdjacent(nextHopRouterName).getConnectingFace();
-                    double distToNbr=getHyperbolicDistance(pnlsr,pMap,
-                                                           sourceRouter,links[j]);
-                    double distToDestFromNbr=getHyperbolicDistance(pnlsr,
-                                             pMap,links[j],i);
-                    if ( distToDestFromNbr >= 0 )
-                    {
-                        linkFaces[k] = nextHopFace;
-                        distanceToNeighbor[k] = distToNbr;
-                        distFromNbrToDest[k] = distToDestFromNbr;
-                        k++;
-                    }
-                }
-                addHypNextHopsToRoutingTable(pnlsr,pMap,rt,k,i);
-                freeLinkFaces();
-                freeDistanceToNeighbor();
-                freeDistFromNbrToDest();
-            }
-        }
-        freeLinks();
-        freeLinksCosts();
-        freeAdjMatrix();
-    }
-
-    void
-    HypRoutingTableCalculator::addHypNextHopsToRoutingTable(Nlsr& pnlsr,Map& pMap,
-            RoutingTable& rt, int noFaces, int dest)
-    {
-        for(int i=0 ; i < noFaces ; ++i)
-        {
-            string destRouter=pMap.getRouterNameByMappingNo(dest);
-            NextHop nh(linkFaces[i],distFromNbrToDest[i]);
-            rt.addNextHop(destRouter,nh);
-            if( isDryRun == 1 )
-            {
-                rt.addNextHopToDryTable(destRouter,nh);
-            }
-        }
-    }
-
-    double
-    HypRoutingTableCalculator::getHyperbolicDistance(Nlsr& pnlsr,
-            Map& pMap, int src, int dest)
-    {
-        double distance=0.0;
-        string srcRouterKey=pMap.getRouterNameByMappingNo(src)+"/3";
-        string destRouterKey=pMap.getRouterNameByMappingNo(dest)+"/3";
-        double srcRadius=(pnlsr.getLsdb().getCorLsa(srcRouterKey).first).getCorRadius();
-        double srcTheta=(pnlsr.getLsdb().getCorLsa(srcRouterKey).first).getCorTheta();
-        double destRadius=(pnlsr.getLsdb().getCorLsa(
-                               destRouterKey).first).getCorRadius();
-        double destTheta=(pnlsr.getLsdb().getCorLsa(destRouterKey).first).getCorTheta();
-        double diffTheta = fabs (srcTheta - destTheta);
-        if (diffTheta > MATH_PI)
-        {
-            diffTheta = 2 * MATH_PI - diffTheta;
-        }
-        if ( srcRadius != -1 && destRadius != -1 )
-        {
-            if (diffTheta == 0)
-                distance = fabs (srcRadius - destRadius);
-            else
-                distance = acosh((cosh(srcRadius)*cosh(destRadius))-
-                                 (sinh(srcRadius)*sinh(destRadius)*cos(diffTheta)));
-        }
-        else
-        {
-            distance = -1;
-        }
-        return distance;
-    }
-
-    void
-    HypRoutingTableCalculator::allocateLinkFaces()
-    {
-        linkFaces=new int[vNoLink];
-    }
-
-    void
-    HypRoutingTableCalculator::allocateDistanceToNeighbor()
-    {
-        distanceToNeighbor=new double[vNoLink];
-    }
-
-    void
-    HypRoutingTableCalculator::allocateDistFromNbrToDest()
-    {
-        distFromNbrToDest=new double[vNoLink];
-    }
-
-    void
-    HypRoutingTableCalculator::freeLinkFaces()
-    {
-        delete [] linkFaces;
-    }
-
-    void
-    HypRoutingTableCalculator::freeDistanceToNeighbor()
-    {
-        delete [] distanceToNeighbor;
-    }
-
-    void
-    HypRoutingTableCalculator::freeDistFromNbrToDest()
-    {
-        delete [] distFromNbrToDest;
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_rtc.hpp b/src/nlsr_rtc.hpp
deleted file mode 100644
index 987686e..0000000
--- a/src/nlsr_rtc.hpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#ifndef NLSR_RTC_HPP
-#define NLSR_RTC_HPP
-
-#include <list>
-#include <iostream>
-
-namespace nlsr
-{
-
-    class Map;
-    class RoutingTable;
-    class Nlsr;
-
-
-    using namespace std;
-
-    class RoutingTableCalculator
-    {
-    public:
-        RoutingTableCalculator()
-        {
-        }
-        RoutingTableCalculator(int rn)
-        {
-            numOfRouter=rn;
-        }
-    protected:
-        void allocateAdjMatrix();
-        void initMatrix();
-        void makeAdjMatrix(Nlsr& pnlsr,Map pMap);
-        void printAdjMatrix();
-        int getNumOfLinkfromAdjMatrix(int sRouter);
-        void freeAdjMatrix();
-        void adjustAdMatrix(int source, int link, double linkCost);
-        void getLinksFromAdjMatrix(int *links, double *linkCosts, int source);
-
-        void allocateLinks();
-        void allocateLinkCosts();
-        void freeLinks();
-        void freeLinksCosts();
-
-        void setNoLink(int nl)
-        {
-            vNoLink=nl;
-        }
-
-    protected:
-        double ** adjMatrix;
-        int numOfRouter;
-
-        int vNoLink;
-        int *links;
-        double *linkCosts;
-    };
-
-    class LinkStateRoutingTableCalculator: public RoutingTableCalculator
-    {
-    public:
-        LinkStateRoutingTableCalculator(int rn)
-            : EMPTY_PARENT(-12345)
-            , INF_DISTANCE(2147483647)
-            , NO_MAPPING_NUM(-1)
-            , NO_NEXT_HOP(-12345)
-        {
-            numOfRouter=rn;
-        }
-
-
-        void calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);
-
-
-    private:
-        void doDijkstraPathCalculation(int sourceRouter);
-        void sortQueueByDistance(int *Q, double *dist,int start,int element);
-        int isNotExplored(int *Q, int u,int start, int element);
-        void printAllLsPath(int sourceRouter);
-        void printLsPath(int destRouter);
-        void addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
-                                            Map& pMap,int sourceRouter);
-        int getLsNextHop(int dest, int source);
-
-        void allocateParent();
-        void allocateDistance();
-        void freeParent();
-        void freeDistance();
-
-
-
-
-    private:
-        int *parent;
-        double *distance;
-
-
-        const int EMPTY_PARENT;
-        const double INF_DISTANCE;
-        const int NO_MAPPING_NUM;
-        const int NO_NEXT_HOP;
-
-    };
-
-    class HypRoutingTableCalculator: public RoutingTableCalculator
-    {
-    public:
-        HypRoutingTableCalculator(int rn)
-            :  MATH_PI(3.141592654)
-        {
-            numOfRouter=rn;
-            isDryRun=0;
-        }
-        HypRoutingTableCalculator(int rn, int idr)
-            :  MATH_PI(3.141592654)
-        {
-            numOfRouter=rn;
-            isDryRun=idr;
-        }
-
-        void calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);
-
-    private:
-        void allocateLinkFaces();
-        void allocateDistanceToNeighbor();
-        void allocateDistFromNbrToDest();
-        void freeLinkFaces();
-        void freeDistanceToNeighbor();
-        void freeDistFromNbrToDest();
-
-        double getHyperbolicDistance(Nlsr& pnlsr,Map& pMap, int src, int dest);
-        void addHypNextHopsToRoutingTable(Nlsr& pnlsr,Map& pMap,
-                                          RoutingTable& rt, int noFaces,int dest);
-
-    private:
-        int isDryRun;
-
-        int *linkFaces;
-        double *distanceToNeighbor;
-        double *distFromNbrToDest;
-
-        const double MATH_PI;
-
-    };
-
-}//namespace nlsr
-
-#endif
diff --git a/src/nlsr_rte.cpp b/src/nlsr_rte.cpp
deleted file mode 100644
index f96da11..0000000
--- a/src/nlsr_rte.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <iostream>
-#include <string>
-
-#include "nlsr_rte.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    ostream&
-    operator<<(ostream& os, RoutingTableEntry &rte)
-    {
-        os<<"Destination: "<<rte.getDestination()<<endl;
-        os<<"Nexthops: "<<endl;
-        int i=1;
-        std::list< NextHop > nhl = rte.getNhl().getNextHopList();
-        for( std::list<NextHop>::iterator it=nhl.begin();
-                it!= nhl.end() ; it++,i++)
-        {
-            os <<"  Nexthop "<<i<<": "<<(*it)<<endl;
-        }
-        return os;
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_rte.hpp b/src/nlsr_rte.hpp
deleted file mode 100644
index 27d3601..0000000
--- a/src/nlsr_rte.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef NLSR_RTE_HPP
-#define NLSR_RTE_HPP
-
-#include<iostream>
-
-#include "nlsr_nhl.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    class RoutingTableEntry
-    {
-    public:
-        RoutingTableEntry()
-            : destination()
-            , nhl()
-        {
-        }
-
-        ~RoutingTableEntry()
-        {
-        }
-
-        RoutingTableEntry(string dest)
-            : nhl()
-        {
-            destination=dest;
-        }
-
-        string getDestination()
-        {
-            return destination;
-        }
-
-        Nhl& getNhl()
-        {
-            return nhl;
-        }
-
-    private:
-        string destination;
-        Nhl nhl;
-    };
-
-    ostream&
-    operator<<(ostream& os, RoutingTableEntry &rte);
-
-}
-
-#endif
diff --git a/src/nlsr_sm.cpp b/src/nlsr_sm.cpp
index d9f3a95..cae7f60 100644
--- a/src/nlsr_sm.cpp
+++ b/src/nlsr_sm.cpp
@@ -1,5 +1,10 @@
 #include <string>
 #include <iostream>
+#include <fstream>
+#include <pwd.h>
+#include <cstdlib>
+#include <unistd.h>
+
 #include "nlsr_sm.hpp"
 
 namespace nlsr
@@ -7,7 +12,85 @@
 
     using namespace std;
 
-    class Nlsr;
+    void
+    SequencingManager::splittSequenceNo(uint64_t seqNo)
+    {
+        combinedSeqNo=seqNo;
+        adjLsaSeq = (combinedSeqNo & 0xFFFFF);
+        corLsaSeq = ((combinedSeqNo >> 20) & 0xFFFFF);
+        nameLsaSeq = ((combinedSeqNo >> 40) & 0xFFFFF);
+    }
+
+    void
+    SequencingManager::combineSequenceNo()
+    {
+        combinedSeqNo=0;
+        combinedSeqNo = combinedSeqNo | adjLsaSeq;
+        combinedSeqNo = combinedSeqNo | (corLsaSeq<<20);
+        combinedSeqNo = combinedSeqNo | (nameLsaSeq<<40);
+    }
+
+    void
+    SequencingManager::writeSeqNoToFile()
+    {
+        std::ofstream outputFile(seqFileNameWithPath.c_str(),ios::binary);
+        outputFile<<combinedSeqNo;
+        outputFile.close();
+    }
+
+    void
+    SequencingManager::initiateSeqNoFromFile()
+    {
+        cout<<"Seq File Name: "<< seqFileNameWithPath<<endl;
+        std::ifstream inputFile(seqFileNameWithPath.c_str(),ios::binary);
+        if ( inputFile.good() )
+        {
+            inputFile>>combinedSeqNo;
+            splittSequenceNo(combinedSeqNo);
+            adjLsaSeq+=10;
+            corLsaSeq+=10;
+            nameLsaSeq+=10;
+            combineSequenceNo();
+            inputFile.close();
+        }
+        else
+        {
+            splittSequenceNo(0);
+        }
+    }
+
+    void
+    SequencingManager::setSeqFileName(string filePath)
+    {
+        seqFileNameWithPath=filePath;
+        if( seqFileNameWithPath.empty() )
+        {
+            seqFileNameWithPath=getUserHomeDirectory();
+        }
+        seqFileNameWithPath=seqFileNameWithPath+"/nlsrSeqNo.txt";
+    }
+
+    string
+    SequencingManager::getUserHomeDirectory()
+    {
+        string homeDirPath(getpwuid(getuid())->pw_dir);
+        if( homeDirPath.empty() )
+        {
+            homeDirPath = getenv("HOME");
+        }
+        return homeDirPath;
+    }
+
+    ostream&
+    operator <<(ostream& os, const SequencingManager& sm)
+    {
+        std::cout<<"----SequencingManager----"<<std::endl;
+        std::cout<<"Adj LSA seq no: "<<sm.getAdjLsaSeq()<<endl;
+        std::cout<<"Cor LSA Seq no: "<<sm.getCorLsaSeq()<<endl;
+        std::cout<<"Name LSA Seq no: "<<sm.getNameLsaSeq()<<endl;
+        std::cout<<"Combined LSDB Seq no: "<<sm.getCombinedSeqNo()<<endl;
+        return os;
+    }
 
 }//namespace nlsr
 
diff --git a/src/nlsr_sm.hpp b/src/nlsr_sm.hpp
index 7dfe1b0..b1b1b39 100644
--- a/src/nlsr_sm.hpp
+++ b/src/nlsr_sm.hpp
@@ -17,52 +17,81 @@
             : nameLsaSeq(0)
             , adjLsaSeq(0)
             , corLsaSeq(0)
+            , combinedSeqNo(0)
+            , seqFileNameWithPath()
         {
         }
 
-        SequencingManager(uint32_t nlsn, uint32_t alsn, uint32_t clsn)
+        SequencingManager(uint64_t seqNo)
+        {
+            splittSequenceNo(seqNo);
+        }
+
+        SequencingManager(uint64_t nlsn, uint64_t alsn, uint64_t clsn)
         {
             nameLsaSeq=nlsn;
             adjLsaSeq=alsn;
             corLsaSeq=clsn;
+            combineSequenceNo();
         }
 
-        uint32_t getNameLsaSeq()
+        uint64_t getNameLsaSeq() const
         {
             return nameLsaSeq;
         }
 
-        void setNameLsaSeq(uint32_t nlsn)
+        void setNameLsaSeq(uint64_t nlsn)
         {
             nameLsaSeq=nlsn;
+            combineSequenceNo();
         }
 
-        uint32_t getAdjLsaSeq()
+        uint64_t getAdjLsaSeq() const
         {
             return adjLsaSeq;
         }
 
-        void setAdjLsaSeq(uint32_t alsn)
+        void setAdjLsaSeq(uint64_t alsn)
         {
             adjLsaSeq=alsn;
+            combineSequenceNo();
         }
 
-        uint32_t getCorLsaSeq()
+        uint64_t getCorLsaSeq() const
         {
             return corLsaSeq;
         }
 
-        void setCorLsaSeq(uint32_t clsn)
+        void setCorLsaSeq(uint64_t clsn)
         {
             corLsaSeq=clsn;
+            combineSequenceNo();
         }
 
+        uint64_t getCombinedSeqNo() const
+        {
+            return combinedSeqNo;
+        }
+
+        void writeSeqNoToFile();
+        void initiateSeqNoFromFile();
+        void setSeqFileName(string filePath);
+        string getUserHomeDirectory();
+
     private:
-        uint32_t nameLsaSeq;
-        uint32_t adjLsaSeq;
-        uint32_t corLsaSeq;
+        void splittSequenceNo(uint64_t seqNo);
+        void combineSequenceNo();
+
+
+    private:
+        uint64_t nameLsaSeq;
+        uint64_t adjLsaSeq;
+        uint64_t corLsaSeq;
+        uint64_t combinedSeqNo;
+        string seqFileNameWithPath;
     };
 
 
+    ostream& operator <<(ostream& os, const SequencingManager& sm);
 }//namespace nlsr
 #endif
diff --git a/src/nlsr_test.cpp b/src/nlsr_test.cpp
deleted file mode 100644
index c04fd77..0000000
--- a/src/nlsr_test.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/key-chain.hpp>
-#include <ndn-cpp-dev/util/scheduler.hpp>
-
-#include "nlsr.hpp"
-#include "nlsr_test.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-    using namespace ndn;
-
-    void
-    NlsrTest::schedlueAddingLsas(Nlsr& pnlsr)
-    {
-        // scheduling adding two name lsas, two Cor Lsas and three Adj LSAs
-        //Scheduling Adding LSAs for router altair
-        string router("/ndn/memphis.edu/cs/altair");
-        string name1("/ndn/memphis.edu/cs/altair/name1");
-        string name2("/ndn/memphis.edu/cs/altair/name2");
-        string name3("/ndn/memphis.edu/cs/broadcast");
-        Adjacent adj1("/ndn/memphis.edu/cs/pollux",7,17,1,0);
-        Adjacent adj2("/ndn/memphis.edu/cs/maia",15,27,1,0);
-        pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(30),
-                                           ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
-                                                   boost::ref(pnlsr)
-                                                   ,router,name1,name2,name3));
-        pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(37),
-                                           ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
-                                                   boost::ref(pnlsr)
-                                                   ,router,123.098,1.875));
-        pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(47),
-                                           ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
-                                                   boost::ref(pnlsr)
-                                                   ,router,adj1,adj2));
-        //Scheduling Adding LSAs for router Maia
-        string routerMaia("/ndn/memphis.edu/cs/maia");
-        string maiaName1("/ndn/memphis.edu/maia/name1");
-        string maiaName2("/ndn/memphis.edu/maia/name2");
-        string maiaName3("/ndn/memphis.edu/cs/broadcast");
-        Adjacent maiaAdj1("/ndn/memphis.edu/cs/pollux",8,25,1,0);
-        Adjacent maiaAdj2("/ndn/memphis.edu/cs/altair",11,15,1,0);
-        pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(55),
-                                           ndn::bind(&NlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
-                                                   boost::ref(pnlsr)
-                                                   ,routerMaia,maiaName1,maiaName2,maiaName3));
-        pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(65),
-                                           ndn::bind(&NlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
-                                                   boost::ref(pnlsr)
-                                                   ,routerMaia,12.098,0.875));
-        pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(75),
-                                           ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
-                                                   boost::ref(pnlsr)
-                                                   ,routerMaia,maiaAdj1,maiaAdj2));
-        //sheduling Adding LSAs for Router itself
-        string routerPollux("/ndn/memphis.edu/cs/pollux");
-        Adjacent polluxAdj1("/ndn/memphis.edu/cs/maia",9,13,1,0);
-        Adjacent polluxAdj2("/ndn/memphis.edu/cs/altair",12,23,1,0);
-        pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(90),
-                                           ndn::bind(&NlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
-                                                   boost::ref(pnlsr)
-                                                   ,routerPollux,polluxAdj1,polluxAdj2));
-    }
-
-
-
-    void
-    NlsrTest::secheduledAddNameLsa(Nlsr& pnlsr, string router,
-                                   string name1, string name2, string name3)
-    {
-        Npl npl;
-        npl.insertIntoNpl(name1);
-        npl.insertIntoNpl(name2);
-        npl.insertIntoNpl(name3);
-        NameLsa nameLsa(router,1,1,3600,npl);
-        pnlsr.getLsdb().installNameLsa(pnlsr, nameLsa);
-    }
-
-    void
-    NlsrTest::secheduledAddCorLsa(Nlsr& pnlsr,string router, double r, double angle)
-    {
-        CorLsa corLsa(router,3,1,3600,r,angle);
-        pnlsr.getLsdb().installCorLsa(pnlsr, corLsa);
-    }
-
-    void
-    NlsrTest::scheduledAddAdjacentLsa(Nlsr& pnlsr, string router,
-                                      Adjacent adj1, Adjacent adj2)
-    {
-        Adl adl;
-        adl.insert(adj1);
-        adl.insert(adj2);
-        AdjLsa adjLsa(router,2,1,3600,2,adl);
-        pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
-    }
-
-}//namespace nlsr
-
diff --git a/src/nlsr_test.hpp b/src/nlsr_test.hpp
deleted file mode 100644
index 9963b3b..0000000
--- a/src/nlsr_test.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef NLSR_TEST_HPP
-#define NLSR_TEST_HPP
-
-#include <iostream>
-#include <string>
-
-#include "nlsr_lsdb.hpp"
-#include "nlsr_lsa.hpp"
-#include "nlsr_adl.hpp"
-#include "nlsr_npl.hpp"
-#include "nlsr_adjacent.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-
-    class Nlsr;
-
-    class NlsrTest
-    {
-    public:
-        NlsrTest()
-        {
-        }
-        void schedlueAddingLsas(Nlsr& pnlsr);
-    private:
-        void secheduledAddNameLsa(Nlsr& pnlsr, string router,
-                                  string name1, string name2, string name3);
-        void secheduledAddCorLsa(Nlsr& pnlsr,string router, double r, double angle);
-
-        void scheduledAddAdjacentLsa(Nlsr& pnlsr, string router,
-                                     Adjacent adj1, Adjacent adj2);
-
-    };
-
-} //namespace nlsr
-#endif
diff --git a/src/nlsr_tokenizer.cpp b/src/nlsr_tokenizer.cpp
deleted file mode 100644
index d64a600..0000000
--- a/src/nlsr_tokenizer.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <iostream>
-#include <boost/tokenizer.hpp>
-#include <boost/algorithm/string.hpp>
-#include <string>
-#include <algorithm>
-
-#include "nlsr_tokenizer.hpp"
-
-namespace nlsr
-{
-
-    using namespace std;
-    using namespace boost;
-
-    void
-    nlsrTokenizer::makeToken()
-    {
-        char_separator<char> sep(seps.c_str());
-        tokenizer< char_separator<char> >tokens(originalString, sep);
-        tokenizer< char_separator<char> >::iterator tok_iter = tokens.begin();
-        string ft(*tok_iter);
-        firstToken=ft;
-        ++tok_iter;
-        for ( ; tok_iter != tokens.end(); ++tok_iter)
-        {
-            string oneToken(*tok_iter);
-            this->insertToken(oneToken);
-            restOfTheLine+=oneToken;
-            restOfTheLine+=seps;
-        }
-        trim(restOfTheLine);
-    }
-
-    void
-    nlsrTokenizer::insertToken(const string& token)
-    {
-        tokenList.push_back(token);
-    }
-
-    int
-    nlsrTokenizer::getTokenPosition(string& token)
-    {
-        int pos=-1;
-        int i=1;
-        for(std::list<string>::iterator it=tokenList.begin(); it!=tokenList.end(); it++)
-        {
-            if( (*it) == token )
-            {
-                break;
-            }
-            i++;
-        }
-        if( i < tokenList.size() )
-        {
-            pos=i;
-        }
-        return pos;
-    }
-
-    string
-    nlsrTokenizer::getTokenString(int from , int to)
-    {
-        string returnString;
-        if ( from >=0 && to < tokenList.size())
-        {
-            int i=0;
-            for(std::list<string>::iterator it=tokenList.begin();
-                    it!=tokenList.end(); it++)
-            {
-                i++;
-                if( i >= from && i<= to )
-                {
-                    string oneToken((*it));
-                    returnString+=seps;
-                    returnString+=oneToken;
-                }
-            }
-        }
-        trim(returnString);
-        return returnString;
-    }
-
-    string
-    nlsrTokenizer::getTokenString(int from)
-    {
-        string returnString;
-        if ( from >=0 && from < tokenList.size())
-        {
-            int i=0;
-            for(std::list<string>::iterator it=tokenList.begin();
-                    it!=tokenList.end(); it++)
-            {
-                i++;
-                if( i >= from)
-                {
-                    string oneToken((*it));
-                    returnString+=seps;
-                    returnString+=oneToken;
-                }
-            }
-        }
-        trim(returnString);
-        return returnString;
-    }
-
-    static bool
-    tokenCompare(string& s1, string& s2)
-    {
-        return s1==s2;
-    }
-
-    bool
-    nlsrTokenizer::doesTokenExist(string token)
-    {
-        std::list<string >::iterator it = std::find_if( tokenList.begin(),
-                                          tokenList.end(),
-                                          bind(&tokenCompare, _1 , token));
-        if( it != tokenList.end() )
-        {
-            return true;
-        }
-        return false;
-    }
-
-}//namespace nlsr
diff --git a/src/nlsr_tokenizer.hpp b/src/nlsr_tokenizer.hpp
deleted file mode 100644
index 4818952..0000000
--- a/src/nlsr_tokenizer.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#ifndef NLSR_TOKENIZER_HPP
-#define NLSR_TOKENIZER_HPP
-
-#include <iostream>
-#include <boost/tokenizer.hpp>
-#include <boost/algorithm/string.hpp>
-#include <string>
-#include <list>
-#include <ndn-cpp-dev/face.hpp>
-
-namespace nlsr
-{
-
-    using namespace std;
-    using namespace boost;
-
-    class nlsrTokenizer
-    {
-    public:
-        nlsrTokenizer(const string& inputString)
-            :firstToken(),
-             restOfTheLine()
-        {
-            seps = " ";
-            originalString = inputString;
-            makeToken();
-        }
-
-        nlsrTokenizer(const string& inputString, const string& separator)
-            :firstToken(),
-             restOfTheLine()
-        {
-            seps = separator;
-            originalString = inputString;
-            makeToken();
-        }
-
-        string getFirstToken()
-        {
-            return firstToken;
-        }
-
-        string getRestOfLine()
-        {
-            return restOfTheLine;
-        }
-
-        int getTokenPosition(string& token);
-        string getTokenString(int from , int to);
-        string getTokenString(int from);
-        bool doesTokenExist(string token);
-
-    private:
-
-        void makeToken();
-        void insertToken(const string& token);
-
-        string seps;
-        string originalString;
-        string firstToken;
-        string restOfTheLine;
-        std::list<string> tokenList;
-    };
-
-}//namespace nlsr
-#endif
