diff --git a/src/adjacency-list.cpp b/src/adjacency-list.cpp
index a529b17..117ba76 100644
--- a/src/adjacency-list.cpp
+++ b/src/adjacency-list.cpp
@@ -1,6 +1,6 @@
 #include <iostream>
 #include <algorithm>
-
+#include <ndn-cxx/common.hpp>
 #include "adjacency-list.hpp"
 #include "adjacent.hpp"
 #include "nlsr.hpp"
@@ -41,7 +41,7 @@
 }
 
 int32_t
-AdjacencyList::updateAdjacentStatus(const string& adjName, int32_t s)
+AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, int32_t s)
 {
   std::list<Adjacent>::iterator it = find(adjName);
   if (it == m_adjList.end())
@@ -53,7 +53,7 @@
 }
 
 Adjacent
-AdjacencyList::getAdjacent(const string& adjName)
+AdjacencyList::getAdjacent(const ndn::Name& adjName)
 {
   Adjacent adj(adjName);
   std::list<Adjacent>::iterator it = find(adjName);
@@ -96,7 +96,7 @@
 }
 
 int32_t
-AdjacencyList::updateAdjacentLinkCost(const string& adjName, double lc)
+AdjacencyList::updateAdjacentLinkCost(const ndn::Name& adjName, double lc)
 {
   std::list<Adjacent>::iterator it = find(adjName);
   if (it == m_adjList.end())
@@ -108,7 +108,7 @@
 }
 
 bool
-AdjacencyList::isNeighbor(const string& adjName)
+AdjacencyList::isNeighbor(const ndn::Name& adjName)
 {
   std::list<Adjacent>::iterator it = find(adjName);
   if (it == m_adjList.end())
@@ -119,7 +119,7 @@
 }
 
 void
-AdjacencyList::incrementTimedOutInterestCount(const string& neighbor)
+AdjacencyList::incrementTimedOutInterestCount(const ndn::Name& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it == m_adjList.end())
@@ -130,7 +130,8 @@
 }
 
 void
-AdjacencyList::setTimedOutInterestCount(const string& neighbor, uint32_t count)
+AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor,
+                                        uint32_t count)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it != m_adjList.end())
@@ -140,7 +141,7 @@
 }
 
 int32_t
-AdjacencyList::getTimedOutInterestCount(const string& neighbor)
+AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it == m_adjList.end())
@@ -151,7 +152,7 @@
 }
 
 uint32_t
-AdjacencyList::getStatusOfNeighbor(const string& neighbor)
+AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it == m_adjList.end())
@@ -162,7 +163,7 @@
 }
 
 void
-AdjacencyList::setStatusOfNeighbor(const string& neighbor, int32_t status)
+AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, int32_t status)
 {
   std::list<Adjacent>::iterator it = find(neighbor);
   if (it != m_adjList.end())
@@ -220,12 +221,12 @@
 }
 
 std::list<Adjacent>::iterator
-AdjacencyList::find(std::string adjName)
+AdjacencyList::find(const ndn::Name& adjName)
 {
-  Adjacent adj(adjName);
   std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
                                                   m_adjList.end(),
-                                                  bind(&Adjacent::compareName, &adj, _1));
+                                                  ndn::bind(&Adjacent::compare,
+                                                            _1, ndn::cref(adjName)));
   return it;
 }
 
diff --git a/src/adjacency-list.hpp b/src/adjacency-list.hpp
index a88a6ba..c3c2195 100644
--- a/src/adjacency-list.hpp
+++ b/src/adjacency-list.hpp
@@ -21,31 +21,31 @@
   insert(Adjacent& adjacent);
 
   int32_t
-  updateAdjacentStatus(const std::string& adjName, int32_t s);
+  updateAdjacentStatus(const ndn::Name& adjName, int32_t s);
 
   int32_t
-  updateAdjacentLinkCost(const std::string& adjName, double lc);
+  updateAdjacentLinkCost(const ndn::Name& adjName, double lc);
 
   std::list<Adjacent>&
   getAdjList();
 
   bool
-  isNeighbor(const std::string& adjName);
+  isNeighbor(const ndn::Name& adjName);
 
   void
-  incrementTimedOutInterestCount(const std::string& neighbor);
+  incrementTimedOutInterestCount(const ndn::Name& neighbor);
 
   int32_t
-  getTimedOutInterestCount(const std::string& neighbor);
+  getTimedOutInterestCount(const ndn::Name& neighbor);
 
   uint32_t
-  getStatusOfNeighbor(const std::string& neighbor);
+  getStatusOfNeighbor(const ndn::Name& neighbor);
 
   void
-  setStatusOfNeighbor(const std::string& neighbor, int32_t status);
+  setStatusOfNeighbor(const ndn::Name& neighbor, int32_t status);
 
   void
-  setTimedOutInterestCount(const std::string& neighbor, uint32_t count);
+  setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
 
   void
   addAdjacents(AdjacencyList& adl);
@@ -57,7 +57,7 @@
   getNumOfActiveNeighbor();
 
   Adjacent
-  getAdjacent(const std::string& adjName);
+  getAdjacent(const ndn::Name& adjName);
 
   bool
   operator==(AdjacencyList& adl);
@@ -82,7 +82,7 @@
 
 private:
   std::list<Adjacent>::iterator
-  find(std::string adjName);
+  find(const ndn::Name& adjName);
 
 private:
   std::list<Adjacent> m_adjList;
diff --git a/src/adjacent.cpp b/src/adjacent.cpp
index f5a2c8e..94dceee 100644
--- a/src/adjacent.cpp
+++ b/src/adjacent.cpp
@@ -10,7 +10,8 @@
 
 using namespace std;
 
-Adjacent::Adjacent(const string& an, uint32_t cf, double lc, uint32_t s, uint32_t iton)
+Adjacent::Adjacent(const ndn::Name& an, uint32_t cf, double lc, uint32_t s,
+                   uint32_t iton)
 {
   m_name = an;
   m_connectingFace = cf;
@@ -29,9 +30,9 @@
 }
 
 bool
-Adjacent::compareName(const Adjacent& adjacent)
+Adjacent::compare(const ndn::Name& adjacencyName)
 {
-  return m_name == adjacent.getName();
+  return m_name == adjacencyName;
 }
 
 std::ostream&
diff --git a/src/adjacent.hpp b/src/adjacent.hpp
index b8b6695..bb043f8 100644
--- a/src/adjacent.hpp
+++ b/src/adjacent.hpp
@@ -1,5 +1,6 @@
 #include <string>
 #include <boost/cstdint.hpp>
+#include <ndn-cxx/face.hpp>
 
 #ifndef NLSR_ADJACENT_HPP
 #define NLSR_ADJACENT_HPP
@@ -10,7 +11,7 @@
 
 public:
   Adjacent()
-    : m_name("")
+    : m_name()
     , m_connectingFace(0)
     , m_linkCost(10.0)
     , m_status(0)
@@ -18,7 +19,7 @@
   {
   }
 
-  Adjacent(const std::string& an)
+  Adjacent(const ndn::Name& an)
     : m_connectingFace(0)
     , m_linkCost(0.0)
     , m_status(0)
@@ -27,16 +28,17 @@
     m_name = an;
   }
 
-  Adjacent(const std::string& an, uint32_t cf, double lc, uint32_t s, uint32_t iton);
+  Adjacent(const ndn::Name& an, uint32_t cf, double lc, uint32_t s,
+           uint32_t iton);
 
-  std::string
+  const ndn::Name&
   getName() const
   {
     return m_name;
   }
 
   void
-  setName(const std::string& an)
+  setName(const ndn::Name& an)
   {
     m_name = an;
   }
@@ -93,10 +95,10 @@
   operator==(const Adjacent& adjacent) const;
 
   bool
-  compareName(const Adjacent& adjacent);
-  
+  compare(const ndn::Name& adjacencyName);
+
 private:
-  std::string m_name;
+  ndn::Name m_name;
   uint32_t m_connectingFace;
   double m_linkCost;
   uint32_t m_status;
diff --git a/src/communication/data-manager.cpp b/src/communication/data-manager.cpp
deleted file mode 100644
index 3a153a3..0000000
--- a/src/communication/data-manager.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-#include <iostream>
-#include <cstdlib>
-
-#include <ndn-cxx/security/signature-sha256-with-rsa.hpp>
-#include <ndn-cxx/security/identity-certificate.hpp>
-#include <ndn-cxx/util/io.hpp>
-
-#include "nlsr.hpp"
-#include "data-manager.hpp"
-#include "utility/tokenizer.hpp"
-#include "lsdb.hpp"
-// #include "security/key-manager.hpp"
-
-namespace nlsr {
-
-using namespace std;
-using namespace ndn;
-
-void
-DataManager::processContent(const ndn::Interest& interest,
-                            const ndn::Data& data, InterestManager& im)
-{
-  std::cout << "I: " << interest.toUri() << std::endl;
-  string dataName(data.getName().toUri());
-  Tokenizer nt(dataName, "/");
-  std::string chkString("keys");
-  if (nt.doesTokenExist(chkString))
-  {
-    processContentKeys(data);
-  }
-  else
-  {
-    // if (m_nlsr.getKeyManager().verify(data))
-    {
-      std::cout << "Verified Data Content" << std::endl;
-      chkString = "info";
-      if (nt.doesTokenExist(chkString))
-      {
-        string dataContent((char*)data.getContent().value());
-        processContentInfo(dataName, dataContent);
-      }
-      chkString = "LSA";
-      if (nt.doesTokenExist(chkString))
-      {
-        string dataContent((char*)data.getContent().value());
-        processContentLsa(dataName, dataContent);
-      }
-    }
-    // else
-    // {
-    //   std::cout << "Unverified Data Content. Discarded" << std::endl;
-    // }
-  }
-}
-
-void
-DataManager::processContentInfo(const string& dataName,
-                                string& dataContent)
-{
-  Tokenizer nt(dataName, "/");
-  string chkString("info");
-  string neighbor = nt.getTokenString(0, nt.getTokenPosition(chkString) - 1);
-  int oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
-  int infoIntTimedOutCount = m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor);
-  //debugging purpose start
-  std::cout << "Before Updates: " << std::endl;
-  std::cout << "Neighbor : " << neighbor << std::endl;
-  std::cout << "Status: " << oldStatus << std::endl;
-  std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
-  //debugging purpose end
-  m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 1);
-  m_nlsr.getAdjacencyList().setTimedOutInterestCount(neighbor, 0);
-  int newStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
-  infoIntTimedOutCount = m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor);
-  //debugging purpose
-  std::cout << "After Updates: " << std::endl;
-  std::cout << "Neighbor : " << neighbor << std::endl;
-  std::cout << "Status: " << newStatus << std::endl;
-  std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
-  //debugging purpose end
-  if ((oldStatus - newStatus) != 0)  // change in Adjacency list
-  {
-    m_nlsr.incrementAdjBuildCount();
-    /* Need to schedule event for Adjacency LSA building */
-    if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
-    {
-      m_nlsr.setIsBuildAdjLsaSheduled(1);
-      // event here
-      m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
-                                          ndn::bind(&Lsdb::scheduledAdjLsaBuild, m_nlsr.getLsdb(),
-                                                    boost::ref(m_nlsr)));
-    }
-  }
-}
-
-void
-DataManager::processContentLsa(const string& dataName, string& dataContent)
-{
-  Tokenizer nt(dataName, "/");
-  string chkString("LSA");
-  string origRouter = nt.getTokenString(nt.getTokenPosition(chkString) + 1,
-                                        nt.getTokenNumber() - 4);
-  string lsTypeString = nt.getToken(nt.getTokenNumber() - 3);
-  string lsSeNoString = nt.getToken(nt.getTokenNumber() - 2);
-  uint32_t interestedLsSeqNo;
-  try
-  {
-    interestedLsSeqNo = boost::lexical_cast<uint32_t>(lsSeNoString);
-  }
-  catch (std::exception& e)
-  {
-    return;
-  }
-  if (lsTypeString == "1")  //Name Lsa
-  {
-    processContentNameLsa(origRouter + "/" + lsTypeString,
-                          interestedLsSeqNo, dataContent);
-  }
-  else if (lsTypeString == "2")  //Adj Lsa
-  {
-    processContentAdjLsa(origRouter + "/" + lsTypeString,
-                         interestedLsSeqNo, dataContent);
-  }
-  else if (lsTypeString == "3")  //Cor Lsa
-  {
-    processContentCorLsa(origRouter + "/" + lsTypeString,
-                         interestedLsSeqNo, dataContent);
-  }
-  else
-  {
-    cout << "Unrecognized LSA Type :(" << endl;
-  }
-}
-
-void
-DataManager::processContentNameLsa(const string& lsaKey,
-                                   uint32_t lsSeqNo, string& dataContent)
-{
-  if (m_nlsr.getLsdb().isNameLsaNew(lsaKey, lsSeqNo))
-  {
-    NameLsa nameLsa;
-    if (nameLsa.initializeFromContent(dataContent))
-    {
-      m_nlsr.getLsdb().installNameLsa(m_nlsr, nameLsa);
-    }
-    else
-    {
-      std::cout << "LSA data decoding error :(" << std::endl;
-    }
-  }
-}
-
-void
-DataManager::processContentAdjLsa(const string& lsaKey,
-                                  uint32_t lsSeqNo, string& dataContent)
-{
-  if (m_nlsr.getLsdb().isAdjLsaNew(lsaKey, lsSeqNo))
-  {
-    AdjLsa adjLsa;
-    if (adjLsa.initializeFromContent(dataContent))
-    {
-      m_nlsr.getLsdb().installAdjLsa(m_nlsr, adjLsa);
-    }
-    else
-    {
-      std::cout << "LSA data decoding error :(" << std::endl;
-    }
-  }
-}
-
-void
-DataManager::processContentCorLsa(const string& lsaKey,
-                                  uint32_t lsSeqNo, string& dataContent)
-{
-  if (m_nlsr.getLsdb().isCoordinateLsaNew(lsaKey, lsSeqNo))
-  {
-    CoordinateLsa corLsa;
-    if (corLsa.initializeFromContent(dataContent))
-    {
-      m_nlsr.getLsdb().installCoordinateLsa(m_nlsr, corLsa);
-    }
-    else
-    {
-      std::cout << "LSA data decoding error :(" << std::endl;
-    }
-  }
-}
-
-void
-DataManager::processContentKeys(const ndn::Data& data)
-{
-  std::cout << " processContentKeys called " << std::endl;
-  ndn::shared_ptr<ndn::IdentityCertificate> cert =
-    ndn::make_shared<ndn::IdentityCertificate>();
-  cert->wireDecode(data.getContent().blockFromValue());
-  std::cout << *(cert) << std::endl;
-  std::string dataName = data.getName().toUri();
-  Tokenizer nt(dataName, "/");
-  std::string certName = nt.getTokenString(0, nt.getTokenNumber() - 3);
-  uint32_t seqNum = boost::lexical_cast<uint32_t>(nt.getToken(
-                                                    nt.getTokenNumber() - 2));
-  std::cout << "Cert Name: " << certName << " Seq Num: " << seqNum << std::endl;
-  // if (m_nlsr.getKeyManager().verify(m_nlsr, *(cert)))
-  // {
-  //   m_nlsr.getKeyManager().addCertificate(cert, seqNum, true);
-  // }
-  // else
-  // {
-  //   m_nlsr.getKeyManager().addCertificate(cert, seqNum, false);
-  // }
-  // m_nlsr.getKeyManager().printCertStore();
-}
-}//namespace nlsr
diff --git a/src/communication/data-manager.hpp b/src/communication/data-manager.hpp
deleted file mode 100644
index ce10b88..0000000
--- a/src/communication/data-manager.hpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef NLSR_DATA_MANAGER_HPP
-#define NLSR_DATA_MANAGER_HPP
-
-#include <boost/cstdint.hpp>
-
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/util/scheduler.hpp>
-
-#include "interest-manager.hpp"
-
-namespace nlsr {
-class Nlsr;
-
-class DataManager
-{
-public:
-  DataManager(Nlsr& nlsr)
-    : m_nlsr(nlsr)
-  {}
-  void
-  processContent(const ndn::Interest& interest,
-                 const ndn::Data& data, InterestManager& im);
-private:
-  void
-  processContentInfo(const std::string& dataName,
-                     std::string& dataContent);
-
-  void
-  processContentLsa(const std::string& dataName, std::string& dataContent);
-
-  void
-  processContentNameLsa(const std::string& lsaKey,
-                        uint32_t lsSeqNo, std::string& dataContent);
-
-  void
-  processContentAdjLsa(const std::string& lsaKey,
-                       uint32_t lsSeqNo, std::string& dataContent);
-
-  void
-  processContentCorLsa(const std::string& lsaKey,
-                       uint32_t lsSeqNo, std::string& dataContent);
-
-  void
-  processContentKeys(const ndn::Data& data);
-
-private:
-  Nlsr& m_nlsr;
-
-
-};
-
-}//namespace nlsr
-
-#endif //NLSR_DATA_MANAGER_HPP
diff --git a/src/communication/interest-manager.cpp b/src/communication/interest-manager.cpp
deleted file mode 100644
index 23ce579..0000000
--- a/src/communication/interest-manager.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
-#include <iostream>
-#include <cstdlib>
-
-#include <ndn-cxx/security/identity-certificate.hpp>
-#include <ndn-cxx/util/io.hpp>
-
-#include "nlsr.hpp"
-#include "interest-manager.hpp"
-#include "data-manager.hpp"
-#include "utility/tokenizer.hpp"
-#include "lsdb.hpp"
-
-namespace nlsr {
-
-using namespace std;
-using namespace ndn;
-
-void
-InterestManager::processInterest(const ndn::Name& name,
-                                 const ndn::Interest& interest)
-{
-  cout << "<< I: " << interest << endl;
-  string intName = interest.getName().toUri();
-  cout << "Interest Received for Name: " << intName << endl;
-  Tokenizer nt(intName, "/");
-  string chkString("info");
-  if (nt.doesTokenExist(chkString))
-  {
-    string nbr = nt.getTokenString(nt.getTokenPosition(chkString) + 1);
-    cout << "Neighbor: " << nbr << endl;
-    processInterestInfo(nbr, interest);
-  }
-  chkString = "LSA";
-  if (nt.doesTokenExist(chkString))
-  {
-    processInterestLsa(interest);
-  }
-  chkString = "keys";
-  if (nt.doesTokenExist(chkString))
-  {
-    processInterestKeys(interest);
-  }
-}
-
-void
-InterestManager::processInterestInfo(const string& neighbor,
-                                     const ndn::Interest& interest)
-{
-  if (m_nlsr.getAdjacencyList().isNeighbor(neighbor))
-  {
-    Data data(ndn::Name(interest.getName()).appendVersion());
-    data.setFreshnessPeriod(time::seconds(10)); // 10 sec
-    data.setContent((const uint8_t*)"info", sizeof("info"));
-    // m_nlsr.getKeyManager().signData(data);
-    m_keyChain.sign(data);
-    cout << ">> D: " << data << endl;
-    m_nlsr.getNlsrFace().put(data);
-    int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
-    if (status == 0)
-    {
-      string intName = neighbor + "/" + "info" +
-                       m_nlsr.getConfParameter().getRouterPrefix();
-      expressInterest(intName, 2,
-                      m_nlsr.getConfParameter().getInterestResendTime());
-    }
-  }
-}
-
-void
-InterestManager::processInterestLsa(const ndn::Interest& interest)
-{
-  string intName = interest.getName().toUri();
-  Tokenizer nt(intName, "/");
-  string chkString("LSA");
-  string origRouter = nt.getTokenString(nt.getTokenPosition(chkString) + 1,
-                                        nt.getTokenNumber() - 3);
-  string lsTypeString = nt.getToken(nt.getTokenNumber() - 2);
-  string lsSeqString = nt.getToken(nt.getTokenNumber() - 1);
-  std::cout << "Router Name: " << origRouter << std::endl;
-  std::cout << "Ls Type    : " << lsTypeString << std::endl;
-  std::cout << "Ls Seq     : " << lsSeqString << endl;
-  uint8_t interestedLsType;
-  uint32_t interestedLsSeqNo;
-  try
-  {
-    interestedLsType = boost::lexical_cast<uint8_t>(lsTypeString);
-    interestedLsSeqNo = boost::lexical_cast<uint32_t>(lsSeqString);
-  }
-  catch (std::exception& e)
-  {
-    return;
-  }
-  std::cout << "Ls Type: " << interestedLsType << std::endl;
-  if (lsTypeString == "1") //Name Lsa
-  {
-    processInterestForNameLsa(interest,
-                              origRouter + "/" + lsTypeString, interestedLsSeqNo);
-  }
-  else if (lsTypeString == "2") //Adj Lsa
-  {
-    processInterestForAdjLsa(interest,
-                             origRouter + "/" + lsTypeString, interestedLsSeqNo);
-  }
-  else if (lsTypeString == "3") //Cor Lsa
-  {
-    processInterestForCorLsa(interest,
-                             origRouter + "/" + lsTypeString, interestedLsSeqNo);
-  }
-  else
-  {
-    cout << "Unrecognized LSA Type :(" << endl;
-  }
-}
-
-void
-InterestManager::processInterestForNameLsa(const ndn::Interest& interest,
-                                           const string& lsaKey, uint32_t interestedlsSeqNo)
-{
-  NameLsa*  nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
-  if (nameLsa != 0)
-  {
-    if (nameLsa->getLsSeqNo() >= interestedlsSeqNo)
-    {
-      Data data(ndn::Name(interest.getName()).appendVersion());
-      data.setFreshnessPeriod(time::seconds(10)); // 10 sec
-      string content = nameLsa->getData();
-      data.setContent((const uint8_t*)content.c_str(), content.size());
-      // m_nlsr.getKeyManager().signData(data);
-      m_keyChain.sign(data);
-      std::cout << ">> D: " << data << std::endl;
-      m_nlsr.getNlsrFace().put(data);
-    }
-  }
-}
-
-void
-InterestManager::processInterestForAdjLsa(const ndn::Interest& interest,
-                                          const string& lsaKey, uint32_t interestedlsSeqNo)
-{
-  AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
-  if (adjLsa != 0)
-  {
-    if (adjLsa->getLsSeqNo() >= interestedlsSeqNo)
-    {
-      Data data(ndn::Name(interest.getName()).appendVersion());
-      data.setFreshnessPeriod(time::seconds(10)); // 10 sec
-      string content = adjLsa->getData();
-      data.setContent((const uint8_t*)content.c_str(), content.size());
-      // m_nlsr.getKeyManager().signData(data);
-      m_keyChain.sign(data);
-      std::cout << ">> D: " << data << std::endl;
-      m_nlsr.getNlsrFace().put(data);
-    }
-  }
-}
-
-void
-InterestManager::processInterestForCorLsa(const ndn::Interest& interest,
-                                          const string& lsaKey, uint32_t interestedlsSeqNo)
-{
-  CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
-  if (corLsa != 0)
-  {
-    if (corLsa->getLsSeqNo() >= interestedlsSeqNo)
-    {
-      Data data(ndn::Name(interest.getName()).appendVersion());
-      data.setFreshnessPeriod(time::seconds(10)); // 10 sec
-      string content = corLsa->getData();
-      data.setContent((const uint8_t*)content.c_str(), content.size());
-      // m_nlsr.getKeyManager().signData(data);
-      m_keyChain.sign(data);
-      std::cout << ">> D: " << data << std::endl;
-      m_nlsr.getNlsrFace().put(data);
-    }
-  }
-}
-
-void
-InterestManager::processInterestKeys(const ndn::Interest& interest)
-{
-  std::cout << "processInterestKeys called " << std::endl;
-  // string intName = interest.getName().toUri();
-  // std::cout << "Interest Name for Key: " << intName << std::endl;
-  // Tokenizer nt(intName, "/");
-  // std::string chkString("ID-CERT");
-  // std::string certName;
-  // uint32_t seqNum;
-  // ndn::Name dataName;
-  // std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> chkCert;
-  // if (nt.getTokenPosition(chkString) == nt.getTokenNumber() - 1)
-  // {
-  //   certName = nt.getTokenString(0, nt.getTokenNumber() - 1);
-  //   cout << "Cert Name: " << certName << std::endl;
-  //   chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName);
-  // }
-  // else
-  // {
-  //   certName = nt.getTokenString(0, nt.getTokenNumber() - 2);
-  //   seqNum = boost::lexical_cast<uint32_t>(nt.getToken(nt.getTokenNumber() - 1));
-  //   std::cout << "Cert Name: " << certName << " Seq Num: " << seqNum << std::endl;
-  //   chkCert = m_nlsr.getKeyManager().getCertificateFromStore(certName, seqNum);
-  // }
-  // if (chkCert.second)
-  // {
-  //   if (nt.getTokenPosition(chkString) == nt.getTokenNumber() - 1)
-  //   {
-  //     std::string dn;
-  //     dataName = ndn::Name(interest.getName()).appendVersion();
-  //     std::pair<uint32_t, bool> seqChk =
-  //       m_nlsr.getKeyManager().getCertificateSeqNum(certName);
-  //     if (seqChk.second)
-  //     {
-  //       dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(seqChk.first);
-  //       dataName = ndn::Name(dn);
-  //     }
-  //     else
-  //     {
-  //       dn = dataName.toUri() + "/" + boost::lexical_cast<std::string>(10);
-  //       dataName = ndn::Name(dn);
-  //     }
-  //   }
-  //   else
-  //   {
-  //     dataName = ndn::Name(interest.getName());
-  //   }
-  //   Data data(dataName.appendVersion());
-  //   data.setFreshnessPeriod(time::seconds(10)); //10 sec
-  //   data.setContent(chkCert.first->wireEncode());
-  //   m_nlsr.getKeyManager().signData(data);
-  //   m_nlsr.getNlsrFace()->put(data);
-  // }
-}
-
-
-void
-InterestManager::processInterestTimedOut(const ndn::Interest& interest)
-{
-  std::cout << "Timed out interest : " << interest.getName().toUri() << std::endl;
-  string intName = interest.getName().toUri();
-  Tokenizer nt(intName, "/");
-  string chkString("info");
-  if (nt.doesTokenExist(chkString))
-  {
-    string nbr = nt.getTokenString(0, nt.getTokenPosition(chkString) - 1);
-    processInterestTimedOutInfo(nbr , interest);
-  }
-  chkString = "LSA";
-  if (nt.doesTokenExist(chkString))
-  {
-    processInterestTimedOutLsa(interest);
-  }
-}
-
-void
-InterestManager::processInterestTimedOutInfo(const string& neighbor,
-                                             const ndn::Interest& interest)
-{
-  m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
-  int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
-  uint32_t infoIntTimedOutCount = m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor);
-  std::cout << "Neighbor: " << neighbor << std::endl;
-  std::cout << "Status: " << status << std::endl;
-  std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
-  if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber()))
-  {
-    string intName = neighbor + "/" + "info" +
-                     m_nlsr.getConfParameter().getRouterPrefix();
-    expressInterest(intName, 2,
-                    m_nlsr.getConfParameter().getInterestResendTime());
-  }
-  else if ((status == 1) &&
-           (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()))
-  {
-    m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 0);
-    m_nlsr.incrementAdjBuildCount();
-    if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
-    {
-      m_nlsr.setIsBuildAdjLsaSheduled(1);
-      // event here
-      m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
-                                          ndn::bind(&Lsdb::scheduledAdjLsaBuild,
-                                                    &m_nlsr.getLsdb(),
-                                                    boost::ref(m_nlsr)));
-    }
-  }
-}
-
-void
-InterestManager::processInterestTimedOutLsa(const ndn::Interest& interest)
-{
-}
-
-void
-InterestManager::expressInterest(const string& interestNamePrefix,
-                                 int32_t scope, int32_t seconds)
-{
-  std::cout << "Expressing Interest :" << interestNamePrefix << std::endl;
-  ndn::Interest i((ndn::Name(interestNamePrefix)));
-  i.setInterestLifetime(time::seconds(seconds));
-  i.setMustBeFresh(true);
-  m_nlsr.getNlsrFace().expressInterest(i,
-                                       ndn::bind(&DataManager::processContent,
-                                                 &m_nlsr.getDataManager(),
-                                                 _1, _2, boost::ref(*this)),
-                                       ndn::bind(&InterestManager::processInterestTimedOut,
-                                                 this, _1));
-}
-
-
-void
-InterestManager::sendScheduledInfoInterest(int32_t seconds)
-{
-  std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList();
-  for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
-       ++it)
-  {
-    string adjName = (*it).getName() + "/" + "info" +
-                     m_nlsr.getConfParameter().getRouterPrefix();
-    expressInterest(adjName, 2,
-                    m_nlsr.getConfParameter().getInterestResendTime());
-  }
-  scheduleInfoInterest(m_nlsr.getConfParameter().getInfoInterestInterval());
-}
-
-void
-InterestManager::scheduleInfoInterest(int32_t seconds)
-{
-  EventId eid = m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
-                                                    ndn::bind(&InterestManager::sendScheduledInfoInterest, this,
-                                                              seconds));
-}
-
-
-} //namespace nlsr
diff --git a/src/communication/interest-manager.hpp b/src/communication/interest-manager.hpp
deleted file mode 100644
index 00c798b..0000000
--- a/src/communication/interest-manager.hpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef NLSR_INTEREST_MANAGER_HPP
-#define NLSR_INTEREST_MANAGER_HPP
-
-#include <boost/cstdint.hpp>
-
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/util/scheduler.hpp>
-
-namespace nlsr {
-
-class Nlsr;
-
-class InterestManager
-{
-public:
-  InterestManager(Nlsr& nlsr)
-    : m_nlsr(nlsr)
-  {
-  }
-  void
-  processInterest(const ndn::Name& name, const ndn::Interest& interest);
-
-  void
-  processInterestInfo(const std::string& neighbor, const ndn::Interest& interest);
-
-  void
-  processInterestLsa(const ndn::Interest& interest);
-
-  void
-  processInterestForNameLsa(const ndn::Interest& interest,
-                            const std::string& lsaKey, uint32_t interestedlsSeqNo);
-
-  void
-  processInterestForAdjLsa(const ndn::Interest& interest,
-                           const std::string& lsaKey, uint32_t interestedlsSeqNo);
-
-  void
-  processInterestForCorLsa(const ndn::Interest& interest,
-                           const std::string& lsaKey, uint32_t interestedlsSeqNo);
-
-  void
-  processInterestKeys(const ndn::Interest& interest);
-
-  void
-  processInterestTimedOut(const ndn::Interest& interest);
-
-  void
-  processInterestTimedOutInfo(const std::string& neighbor,
-                              const ndn::Interest& interest);
-
-  void
-  processInterestTimedOutLsa(const ndn::Interest& interest);
-
-  void
-  expressInterest(const std::string& interestNamePrefix, int32_t scope, int32_t seconds);
-
-  void
-  sendScheduledInfoInterest(int32_t seconds);
-
-  void
-  scheduleInfoInterest(int32_t seconds);
-
-private:
-  Nlsr& m_nlsr;
-
-  ndn::KeyChain m_keyChain;
-};
-
-}//namespace nlsr
-
-#endif //NLSR_INTEREST_MANAGER_HPP
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index c8b5ec9..10a40ec 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -1,7 +1,7 @@
 #include "nlsr.hpp"
 #include "sync-logic-handler.hpp"
-// #include "security/key-manager.hpp"
-#include "utility/tokenizer.hpp"
+#include "utility/name-helper.hpp"
+#include "lsa.hpp"
 
 
 namespace nlsr {
@@ -13,7 +13,7 @@
 SyncLogicHandler::createSyncSocket(Nlsr& pnlsr)
 {
   std::cout << "Creating Sync socket ......" << std::endl;
-  std::cout << "Sync prefix: " << m_syncPrefix.toUri() << std::endl;
+  std::cout << "Sync prefix: " << m_syncPrefix << std::endl;
   m_syncSocket = make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator,
                                                m_syncFace,
                                                bind(&SyncLogicHandler::nsyncUpdateCallBack, this,
@@ -43,116 +43,97 @@
 }
 
 void
-SyncLogicHandler::removeRouterFromSyncing(const string& routerPrefix)
+SyncLogicHandler::removeRouterFromSyncing(const ndn::Name& routerPrefix)
 {
 }
 
 void
-SyncLogicHandler::processUpdateFromSync(const std::string& updateName,
+SyncLogicHandler::processUpdateFromSync(const ndn::Name& updateName,
                                         uint64_t seqNo,  Nlsr& pnlsr)
 {
-  Tokenizer nt(updateName, "/");
+  //const ndn::Name name(updateName);
   string chkString("LSA");
-  if (nt.doesTokenExist(chkString))
+  int32_t lasPosition = util::getNameComponentPosition(updateName, chkString);
+  if (lasPosition >= 0)
   {
-    //process LSA Update here
-    string routerName = nt.getTokenString(nt.getTokenPosition(chkString) + 1);
+    ndn::Name routerName = updateName.getSubName(lasPosition + 1);
     processRoutingUpdateFromSync(routerName, seqNo, pnlsr);
-  }
-  chkString = "keys";
-  if (nt.doesTokenExist(chkString))
-  {
-    //process keys update here
-    std::string certName = nt.getTokenString(0);
-    // processKeysUpdateFromSync(certName, seqNo, pnlsr);
+    return;
   }
 }
 
 void
-SyncLogicHandler::processRoutingUpdateFromSync(const std::string& routerName,
+SyncLogicHandler::processRoutingUpdateFromSync(const ndn::Name& routerName,
                                                uint64_t seqNo,  Nlsr& pnlsr)
 {
+  ndn::Name rName = routerName;
   if (routerName != pnlsr.getConfParameter().getRouterPrefix())
   {
     SequencingManager sm(seqNo);
     std::cout << sm;
     std::cout << "Router Name: " << routerName << endl;
-    if (pnlsr.getLsdb().isNameLsaNew(routerName + "/1", sm.getNameLsaSeq()))
+    try
     {
-      std::cout << "Updated Name LSA. Need to fetch it" << std::endl;
-      string lsaPrefix =
-        pnlsr.getConfParameter().getChronosyncLsaPrefix() +
-        routerName + "/1/" +
-        boost::lexical_cast<std::string>(sm.getNameLsaSeq());
-      pnlsr.getInterestManager().expressInterest(lsaPrefix, 3,
-                                                 pnlsr.getConfParameter().getInterestResendTime());
+      if (pnlsr.getLsdb().isNameLsaNew(rName.append("name"), sm.getNameLsaSeq()))
+      {
+        std::cout << "Updated Name LSA. Need to fetch it" << std::endl;
+        ndn::Name interestName(pnlsr.getConfParameter().getChronosyncLsaPrefix());
+        interestName.append(routerName);
+        interestName.append("name");
+        interestName.appendNumber(sm.getNameLsaSeq());
+        pnlsr.getLsdb().expressInterest(interestName,
+                                        pnlsr.getConfParameter().getInterestResendTime());
+      }
+      if (pnlsr.getLsdb().isAdjLsaNew(rName.append("adjacency"),
+                                      sm.getAdjLsaSeq()))
+      {
+        std::cout << "Updated Adj LSA. Need to fetch it" << std::endl;
+        ndn::Name interestName(pnlsr.getConfParameter().getChronosyncLsaPrefix());
+        interestName.append(routerName);
+        interestName.append("adjacency");
+        interestName.appendNumber(sm.getAdjLsaSeq());
+        pnlsr.getLsdb().expressInterest(interestName,
+                                        pnlsr.getConfParameter().getInterestResendTime());
+      }
+      if (pnlsr.getLsdb().isCoordinateLsaNew(rName.append("coordinate"),
+                                             sm.getCorLsaSeq()))
+      {
+        std::cout << "Updated Cor LSA. Need to fetch it" << std::endl;
+        ndn::Name interestName(pnlsr.getConfParameter().getChronosyncLsaPrefix());
+        interestName.append(routerName);
+        interestName.append("coordinate");
+        interestName.appendNumber(sm.getCorLsaSeq());
+        pnlsr.getLsdb().expressInterest(interestName,
+                                        pnlsr.getConfParameter().getInterestResendTime());
+      }
     }
-    if (pnlsr.getLsdb().isAdjLsaNew(routerName + "/2", sm.getAdjLsaSeq()))
+    catch (std::exception& e)
     {
-      std::cout << "Updated Adj LSA. Need to fetch it" << std::endl;
-      string lsaPrefix =
-        pnlsr.getConfParameter().getChronosyncLsaPrefix() +
-        routerName + "/2/" +
-        boost::lexical_cast<std::string>(sm.getAdjLsaSeq());
-      pnlsr.getInterestManager().expressInterest(lsaPrefix, 3,
-                                                 pnlsr.getConfParameter().getInterestResendTime());
-    }
-    if (pnlsr.getLsdb().isCoordinateLsaNew(routerName + "/3", sm.getCorLsaSeq()))
-    {
-      std::cout << "Updated Cor LSA. Need to fetch it" << std::endl;
-      string lsaPrefix =
-        pnlsr.getConfParameter().getChronosyncLsaPrefix() +
-        routerName + "/3/" +
-        boost::lexical_cast<std::string>(sm.getCorLsaSeq());
-      pnlsr.getInterestManager().expressInterest(lsaPrefix, 3,
-                                                 pnlsr.getConfParameter().getInterestResendTime());
+      std::cerr << e.what() << std::endl;
+      return;
     }
   }
 }
 
-// void
-// SyncLogicHandler::processKeysUpdateFromSync(std::string certName,
-//                                             uint64_t seqNo, Nlsr& pnlsr)
-// {
-//   std::cout << "Cert Name: " << certName << std::endl;
-//   // if (pnlsr.getKeyManager().isNewCertificate(certName, seqNo))
-//   {
-//     string certNamePrefix = certName + "/" +
-//                             boost::lexical_cast<string>(seqNo);
-//     pnlsr.getIm().expressInterest(certNamePrefix, 3,
-//                                   pnlsr.getConfParameter().getInterestResendTime());
-//   }
-// }
-
 void
 SyncLogicHandler::publishRoutingUpdate(SequencingManager& sm,
-                                       const string& updatePrefix)
+                                       const ndn::Name& updatePrefix)
 {
   sm.writeSeqNoToFile();
   publishSyncUpdate(updatePrefix, sm.getCombinedSeqNo());
 }
 
-// void
-// SyncLogicHandler::publishKeyUpdate(KeyManager& km)
-// {
-//   publishSyncUpdate(km.getProcessCertName().toUri(), km.getCertSeqNo());
-// }
-
 void
-SyncLogicHandler::publishIdentityUpdate(const string& identityName)
-{
-  publishSyncUpdate(identityName, 0);
-}
-
-void
-SyncLogicHandler::publishSyncUpdate(const string& updatePrefix, uint64_t seqNo)
+SyncLogicHandler::publishSyncUpdate(const ndn::Name& updatePrefix,
+                                    uint64_t seqNo)
 {
   std::cout << "Publishing Sync Update ......" << std::endl;
   std::cout << "Update in prefix: " << updatePrefix << std::endl;
   std::cout << "Seq No: " << seqNo << std::endl;
   ndn::Name updateName(updatePrefix);
   string data("NoData");
-  m_syncSocket->publishData(updateName, 0, data.c_str(), data.size(), 1000,
+  m_syncSocket->publishData(updateName.toUri(), 0, data.c_str(), data.size(),
+                            1000,
                             seqNo);
 }
 
diff --git a/src/communication/sync-logic-handler.hpp b/src/communication/sync-logic-handler.hpp
index 9f6badd..1f62554 100644
--- a/src/communication/sync-logic-handler.hpp
+++ b/src/communication/sync-logic-handler.hpp
@@ -11,8 +11,6 @@
 
 #include "sequencing-manager.hpp"
 
-// class KeyManager;
-
 extern "C" {
 #include <unistd.h>
 }
@@ -42,16 +40,10 @@
   nsyncRemoveCallBack(const std::string& prefix, Nlsr& pnlsr);
 
   void
-  removeRouterFromSyncing(const std::string& routerPrefix);
+  removeRouterFromSyncing(const ndn::Name& routerPrefix);
 
   void
-  publishRoutingUpdate(SequencingManager& sm, const std::string& updatePrefix);
-
-  // void
-  // publishKeyUpdate(KeyManager& km);
-
-  void
-  publishIdentityUpdate(const std::string& identityName);
+  publishRoutingUpdate(SequencingManager& sm, const ndn::Name& updatePrefix);
 
   void
   setSyncPrefix(const std::string& sp)
@@ -62,17 +54,15 @@
 
 private:
   void
-  processUpdateFromSync(const std::string& updateName, uint64_t seqNo, Nlsr& pnlsr);
+  processUpdateFromSync(const ndn::Name& updateName, uint64_t seqNo,
+                        Nlsr& pnlsr);
 
   void
-  processRoutingUpdateFromSync(const std::string& routerName, uint64_t seqNo,
+  processRoutingUpdateFromSync(const ndn::Name& routerName, uint64_t seqNo,
                                Nlsr& pnlsr);
 
-  // void
-  // processKeysUpdateFromSync(std::string certName, uint64_t seqNo, Nlsr& pnlsr);
-
   void
-  publishSyncUpdate(const std::string& updatePrefix, uint64_t seqNo);
+  publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
 
 private:
   ndn::shared_ptr<ndn::ValidatorNull> m_validator;
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index fcb8d33..18ae0a5 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -503,7 +503,7 @@
       stringstream sst(nt.getRestOfLine().c_str());
       int faceId;
       sst >> faceId;
-      Adjacent adj(nt.getFirstToken(), faceId, 0.0, 0, 0);
+      Adjacent adj(nt.getFirstToken(), faceId, 10, 0, 0);
       m_nlsr.getAdjacencyList().insert(adj);
     }
   }
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index 49a8a4d..5b5b560 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -3,6 +3,8 @@
 
 #include <iostream>
 #include <boost/cstdint.hpp>
+#include <ndn-cxx/common.hpp>
+#include <ndn-cxx/face.hpp>
 
 namespace nlsr {
 class ConfParameter
@@ -32,10 +34,10 @@
   void
   setRouterName(const std::string& rn)
   {
-    m_routerName = rn;
+    m_routerName = ndn::Name(rn);
   }
 
-  const std::string&
+  const ndn::Name&
   getRouterName()
   {
     return m_routerName;
@@ -44,10 +46,10 @@
   void
   setSiteName(const std::string& sn)
   {
-    m_siteName = sn;
+    m_siteName = ndn::Name(sn);
   }
 
-  const std::string&
+  const ndn::Name&
   getSiteName()
   {
     return m_siteName;
@@ -56,10 +58,10 @@
   void
   setNetwork(const std::string& nn)
   {
-    m_network = nn;
+    m_network = ndn::Name(nn);
   }
 
-  const std::string&
+  const ndn::Name&
   getNetwork()
   {
     return m_network;
@@ -68,16 +70,19 @@
   void
   buildRouterPrefix()
   {
-    m_routerPrefix = "/" + m_network + "/" + m_siteName + "/" + m_routerName;
+    //m_routerPrefix = "/" + m_network + "/" + m_siteName + "/" + m_routerName;
+    m_routerPrefix = m_network;
+    m_routerPrefix.append(m_siteName);
+    m_routerPrefix.append(m_routerName);
   }
 
-  const std::string&
+  const ndn::Name&
   getRouterPrefix()
   {
     return m_routerPrefix;
   }
 
-  const std::string&
+  const ndn::Name&
   getRootKeyPrefix()
   {
     return m_rootKeyPrefix;
@@ -86,7 +91,7 @@
   void
   setRootKeyPrefix(std::string rkp)
   {
-    m_rootKeyPrefix = rkp;
+    m_rootKeyPrefix = ndn::Name(rkp);
   }
 
   void
@@ -261,10 +266,10 @@
   void
   setChronosyncSyncPrefix(const std::string& csp)
   {
-    m_chronosyncSyncPrefix = csp;
+    m_chronosyncSyncPrefix = ndn::Name(csp);
   }
 
-  const std::string&
+  const ndn::Name&
   getChronosyncSyncPrefix()
   {
     return m_chronosyncSyncPrefix;
@@ -273,10 +278,10 @@
   void
   setChronosyncLsaPrefix(const std::string& clp)
   {
-    m_chronosyncLsaPrefix = clp;
+    m_chronosyncLsaPrefix = ndn::Name(clp);
   }
 
-  const std::string&
+  const ndn::Name&
   getChronosyncLsaPrefix()
   {
     return m_chronosyncLsaPrefix;
@@ -295,16 +300,16 @@
   }
 
 private:
-  std::string m_routerName;
-  std::string m_siteName;
-  std::string m_network;
+  ndn::Name m_routerName;
+  ndn::Name m_siteName;
+  ndn::Name m_network;
 
-  std::string m_routerPrefix;
-  std::string m_lsaRouterPrefix;
+  ndn::Name m_routerPrefix;
+  ndn::Name m_lsaRouterPrefix;
 
-  std::string m_chronosyncSyncPrefix;
-  std::string m_chronosyncLsaPrefix;
-  std::string m_rootKeyPrefix;
+  ndn::Name m_chronosyncSyncPrefix;
+  ndn::Name m_chronosyncLsaPrefix;
+  ndn::Name m_rootKeyPrefix;
 
   uint32_t m_interestRetryNumber;
   int32_t m_interestResendTime;
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
new file mode 100644
index 0000000..ccc2f5b
--- /dev/null
+++ b/src/hello-protocol.cpp
@@ -0,0 +1,173 @@
+#include "nlsr.hpp"
+#include "lsdb.hpp"
+#include "hello-protocol.hpp"
+#include "utility/name-helper.hpp"
+
+namespace nlsr {
+
+void
+HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
+{
+  std::cout << "Expressing Interest :" << interestName << std::endl;
+  ndn::Interest i(interestName);
+  i.setInterestLifetime(ndn::time::seconds(seconds));
+  i.setMustBeFresh(true);
+  m_nlsr.getNlsrFace().expressInterest(i,
+                                       ndn::bind(&HelloProtocol::processContent,
+                                                 this,
+                                                 _1, _2),
+                                       ndn::bind(&HelloProtocol::processInterestTimedOut,
+                                                 this, _1));
+}
+
+void
+HelloProtocol::sendScheduledInterest(uint32_t seconds)
+{
+  std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList();
+  for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
+       ++it)
+  {
+    ndn::Name interestName = (*it).getName() ;
+    interestName.append("info");
+    interestName.append(ndn::Name(m_nlsr.getConfParameter().getRouterPrefix()));
+    expressInterest(interestName,
+                    m_nlsr.getConfParameter().getInterestResendTime());
+  }
+  scheduleInterest(m_nlsr.getConfParameter().getInfoInterestInterval());
+}
+
+void
+HelloProtocol::scheduleInterest(uint32_t seconds)
+{
+  m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
+                                      ndn::bind(&HelloProtocol::sendScheduledInterest,
+                                                this, seconds));
+}
+
+void
+HelloProtocol::processInterest(const ndn::Name& name,
+                               const ndn::Interest& interest)
+{
+  const ndn::Name interestName = interest.getName();
+  std::cout << "Interest Received for Name: " << interestName << std::endl;
+  std::string chkString("info");
+  int32_t infoPosition = util::getNameComponentPosition(interestName, chkString);
+  if (infoPosition < 0)
+  {
+    return;
+  }
+  ndn::Name neighbor = interestName.getSubName(infoPosition + 1);
+  std::cout << "Neighbor: " << neighbor << std::endl;
+  if (m_nlsr.getAdjacencyList().isNeighbor(neighbor))
+  {
+    ndn::Data data(ndn::Name(interest.getName()).appendVersion());
+    data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
+    data.setContent((const uint8_t*)"info", sizeof("info"));
+    m_keyChain.sign(data);
+    std::cout << ">> D: " << data << std::endl;
+    m_nlsr.getNlsrFace().put(data);
+    int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
+    if (status == 0)
+    {
+      ndn::Name interestName(neighbor);
+      interestName.append("info");
+      interestName.append(m_nlsr.getConfParameter().getRouterPrefix());
+      expressInterest(interestName,
+                      m_nlsr.getConfParameter().getInterestResendTime());
+    }
+  }
+}
+
+void
+HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
+{
+  const ndn::Name interestName(interest.getName());
+  std::cout << "Interest timed out for Name: " << interestName << std::endl;
+  std::string chkString("info");
+  int32_t infoPosition = util::getNameComponentPosition(interestName, chkString);
+  if (infoPosition < 0)
+  {
+    return;
+  }
+  ndn::Name neighbor = interestName.getSubName(0, infoPosition);
+  std::cout << "Neighbor: " << neighbor << std::endl;
+  m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
+  int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
+  uint32_t infoIntTimedOutCount =
+    m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor);
+  std::cout << "Neighbor: " << neighbor << std::endl;
+  std::cout << "Status: " << status << std::endl;
+  std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
+  if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber()))
+  {
+    ndn::Name interestName(neighbor);
+    interestName.append("info");
+    interestName.append(m_nlsr.getConfParameter().getRouterPrefix());
+    expressInterest(interestName,
+                    m_nlsr.getConfParameter().getInterestResendTime());
+  }
+  else if ((status == 1) &&
+           (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()))
+  {
+    m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 0);
+    m_nlsr.incrementAdjBuildCount();
+    if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
+    {
+      m_nlsr.setIsBuildAdjLsaSheduled(1);
+      // event here
+      m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+                                          ndn::bind(&Lsdb::scheduledAdjLsaBuild,
+                                                    &m_nlsr.getLsdb()));
+    }
+  }
+}
+
+
+void
+HelloProtocol::processContent(const ndn::Interest& interest,
+                              const ndn::Data& data)
+{
+  ndn::Name dataName = data.getName();
+  std::cout << "Data received for name: " << dataName << std::endl;
+  std::string chkString("info");
+  int32_t infoPosition = util::getNameComponentPosition(dataName, chkString);
+  if (infoPosition >= 0)
+  {
+    ndn::Name neighbor = dataName.getSubName(0, infoPosition);
+    int oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
+    int infoIntTimedOutCount = m_nlsr.getAdjacencyList().getTimedOutInterestCount(
+                                 neighbor);
+    //debugging purpose start
+    std::cout << "Before Updates: " << std::endl;
+    std::cout << "Neighbor : " << neighbor << std::endl;
+    std::cout << "Status: " << oldStatus << std::endl;
+    std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
+    //debugging purpose end
+    m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 1);
+    m_nlsr.getAdjacencyList().setTimedOutInterestCount(neighbor, 0);
+    int newStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
+    infoIntTimedOutCount = m_nlsr.getAdjacencyList().getTimedOutInterestCount(
+                             neighbor);
+    //debugging purpose
+    std::cout << "After Updates: " << std::endl;
+    std::cout << "Neighbor : " << neighbor << std::endl;
+    std::cout << "Status: " << newStatus << std::endl;
+    std::cout << "Info Interest Timed out: " << infoIntTimedOutCount << std::endl;
+    //debugging purpose end
+    if ((oldStatus - newStatus) != 0)  // change in Adjacency list
+    {
+      m_nlsr.incrementAdjBuildCount();
+      /* Need to schedule event for Adjacency LSA building */
+      if (m_nlsr.getIsBuildAdjLsaSheduled() == 0)
+      {
+        m_nlsr.setIsBuildAdjLsaSheduled(1);
+        // event here
+        m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
+                                            ndn::bind(&Lsdb::scheduledAdjLsaBuild,
+                                                      boost::ref(m_nlsr.getLsdb())));
+      }
+    }
+  }
+}
+
+} //namespace nlsr
diff --git a/src/hello-protocol.hpp b/src/hello-protocol.hpp
new file mode 100644
index 0000000..984413d
--- /dev/null
+++ b/src/hello-protocol.hpp
@@ -0,0 +1,48 @@
+#ifndef NLSR_HELLO_PROTOCOL_HPP
+#define NLSR_HELLO_PROTOCOL_HPP
+
+#include <boost/cstdint.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
+
+namespace nlsr {
+
+class Nlsr;
+
+class HelloProtocol
+{
+
+public:
+  HelloProtocol(Nlsr& nlsr)
+    : m_nlsr(nlsr)
+  {
+  }
+
+public:
+  void
+  scheduleInterest(uint32_t seconds);
+
+  void
+  expressInterest(const ndn::Name& interestNamePrefix, uint32_t seconds);
+
+  void
+  sendScheduledInterest(uint32_t seconds);
+
+  void
+  processInterest(const ndn::Name& name, const ndn::Interest& interest);
+
+private:
+  void
+  processInterestTimedOut(const ndn::Interest& interest);
+
+  void
+  processContent(const ndn::Interest& interest, const ndn::Data& data);
+
+private:
+  Nlsr& m_nlsr;
+  ndn::KeyChain m_keyChain;
+};
+
+} //namespace nlsr
+
+#endif // NLSR_HELLO_PROTOCOL_HPP
diff --git a/src/lsa.cpp b/src/lsa.cpp
index 5f76eda..2ad95c5 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -4,6 +4,8 @@
 #include <algorithm>
 #include <cmath>
 #include <limits>
+#include <boost/tokenizer.hpp>
+#include <boost/algorithm/string.hpp>
 
 #include "nlsr.hpp"
 #include "lsa.hpp"
@@ -17,23 +19,24 @@
 using namespace std;
 
 
-string
+const ndn::Name
 NameLsa::getKey() const
 {
-  string key;
-  key = m_origRouter + "/" + boost::lexical_cast<std::string>(1);
+  ndn::Name key = m_origRouter;
+  key.append("name");
   return key;
 }
 
-NameLsa::NameLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt,
+NameLsa::NameLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
+                 uint32_t lt,
                  NamePrefixList& npl)
 {
   m_origRouter = origR;
   m_lsType = lst;
   m_lsSeqNo = lsn;
   m_lifeTime = lt;
-  std::list<string> nl = npl.getNameList();
-  for (std::list<string>::iterator it = nl.begin(); it != nl.end(); it++)
+  std::list<ndn::Name>& nl = npl.getNameList();
+  for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++)
   {
     addName((*it));
   }
@@ -43,44 +46,45 @@
 NameLsa::getData()
 {
   string nameLsaData;
-  nameLsaData = m_origRouter + "|" + boost::lexical_cast<std::string>(1) + "|"
+  nameLsaData = m_origRouter.toUri() + "|" + "name" + "|"
                 + boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
                 + boost::lexical_cast<std::string>(m_lifeTime);
   nameLsaData += "|";
   nameLsaData += boost::lexical_cast<std::string>(m_npl.getSize());
-  std::list<string> nl = m_npl.getNameList();
-  for (std::list<string>::iterator it = nl.begin(); it != nl.end(); it++)
+  std::list<ndn::Name> nl = m_npl.getNameList();
+  for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++)
   {
     nameLsaData += "|";
-    nameLsaData += (*it);
+    nameLsaData += (*it).toUri();
   }
   return nameLsaData + "|";
 }
 
 bool
-NameLsa::initializeFromContent(string content)
+NameLsa::initializeFromContent(const std::string& content)
 {
   uint32_t numName = 0;
-  Tokenizer nt(content, "|");
-  m_origRouter = nt.getNextToken();
-  if (m_origRouter.empty())
+  boost::char_separator<char> sep("|");
+  boost::tokenizer<boost::char_separator<char> >tokens(content, sep);
+  boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
+                                               tokens.begin();
+  m_origRouter = ndn::Name(*tok_iter++);
+  if (!(m_origRouter.size() > 0))
   {
     return false;
   }
-  try
-  {
-    m_lsType = boost::lexical_cast<uint8_t>(nt.getNextToken());
-    m_lsSeqNo = boost::lexical_cast<uint32_t>(nt.getNextToken());
-    m_lifeTime = boost::lexical_cast<uint32_t>(nt.getNextToken());
-    numName = boost::lexical_cast<uint32_t>(nt.getNextToken());
+  try {
+    m_lsType = *tok_iter++;
+    m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
+    m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++);
+    numName = boost::lexical_cast<uint32_t>(*tok_iter++);
   }
-  catch (std::exception& e)
-  {
+  catch (std::exception& e) {
     return false;
   }
   for (uint32_t i = 0; i < numName; i++)
   {
-    string name = nt.getNextToken();
+    string name(*tok_iter++);
     addName(name);
   }
   return true;
@@ -96,13 +100,13 @@
 {
   os << "Name Lsa: " << endl;
   os << "  Origination Router: " << nLsa.getOrigRouter() << endl;
-  os << "  Ls Type: " << (unsigned short)nLsa.getLsType() << endl;
+  os << "  Ls Type: " << nLsa.getLsType() << endl;
   os << "  Ls Seq No: " << (unsigned int)nLsa.getLsSeqNo() << endl;
   os << "  Ls Lifetime: " << (unsigned int)nLsa.getLifeTime() << endl;
   os << "  Names: " << endl;
   int i = 1;
-  std::list<string> nl = nLsa.getNpl().getNameList();
-  for (std::list<string>::iterator it = nl.begin(); it != nl.end(); it++)
+  std::list<ndn::Name> nl = nLsa.getNpl().getNameList();
+  for (std::list<ndn::Name>::iterator it = nl.begin(); it != nl.end(); it++)
   {
     os << "    Name " << i << ": " << (*it) << endl;
   }
@@ -111,7 +115,8 @@
 
 
 
-CoordinateLsa::CoordinateLsa(string origR, uint8_t lst, uint32_t lsn,
+CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst,
+                             uint32_t lsn,
                              uint32_t lt
                              , double r, double theta)
 {
@@ -123,11 +128,11 @@
   m_corTheta = theta;
 }
 
-string
+const ndn::Name
 CoordinateLsa::getKey() const
 {
-  string key;
-  key = m_origRouter + "/" + boost::lexical_cast<std::string>(3);
+  ndn::Name key = m_origRouter;
+  key.append("coordinate");
   return key;
 }
 
@@ -144,8 +149,9 @@
 CoordinateLsa::getData()
 {
   string corLsaData;
-  corLsaData = m_origRouter + "|";
-  corLsaData += (boost::lexical_cast<std::string>(3) + "|");
+  corLsaData = m_origRouter.toUri() + "|";
+  corLsaData += "coordinate";
+  corLsaData += "|";
   corLsaData += (boost::lexical_cast<std::string>(m_lsSeqNo) + "|");
   corLsaData += (boost::lexical_cast<std::string>(m_lifeTime) + "|");
   corLsaData += (boost::lexical_cast<std::string>(m_corRad) + "|");
@@ -154,24 +160,25 @@
 }
 
 bool
-CoordinateLsa::initializeFromContent(string content)
+CoordinateLsa::initializeFromContent(const std::string& content)
 {
-  Tokenizer nt(content, "|");
-  m_origRouter = nt.getNextToken();
-  if (m_origRouter.empty())
+  boost::char_separator<char> sep("|");
+  boost::tokenizer<boost::char_separator<char> >tokens(content, sep);
+  boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
+                                               tokens.begin();
+  m_origRouter = ndn::Name(*tok_iter++);
+  if (!(m_origRouter.size() > 0))
   {
     return false;
   }
-  try
-  {
-    m_lsType   = boost::lexical_cast<uint8_t>(nt.getNextToken());
-    m_lsSeqNo  = boost::lexical_cast<uint32_t>(nt.getNextToken());
-    m_lifeTime = boost::lexical_cast<uint32_t>(nt.getNextToken());
-    m_corRad   = boost::lexical_cast<double>(nt.getNextToken());
-    m_corTheta = boost::lexical_cast<double>(nt.getNextToken());
+  try {
+    m_lsType   = *tok_iter++;
+    m_lsSeqNo  = boost::lexical_cast<uint32_t>(*tok_iter++);
+    m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++);
+    m_corRad   = boost::lexical_cast<double>(*tok_iter++);
+    m_corTheta = boost::lexical_cast<double>(*tok_iter++);
   }
-  catch (std::exception& e)
-  {
+  catch (std::exception& e) {
     return false;
   }
   return true;
@@ -182,7 +189,7 @@
 {
   os << "Cor Lsa: " << endl;
   os << "  Origination Router: " << cLsa.getOrigRouter() << endl;
-  os << "  Ls Type: " << (unsigned short)cLsa.getLsType() << endl;
+  os << "  Ls Type: " << cLsa.getLsType() << endl;
   os << "  Ls Seq No: " << (unsigned int)cLsa.getLsSeqNo() << endl;
   os << "  Ls Lifetime: " << (unsigned int)cLsa.getLifeTime() << endl;
   os << "    Hyperbolic Radius: " << cLsa.getCorRadius() << endl;
@@ -191,7 +198,8 @@
 }
 
 
-AdjLsa::AdjLsa(string origR, uint8_t lst, uint32_t lsn, uint32_t lt,
+AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
+               uint32_t lt,
                uint32_t nl , AdjacencyList& adl)
 {
   m_origRouter = origR;
@@ -209,11 +217,11 @@
   }
 }
 
-string
-AdjLsa::getKey()
+const ndn::Name
+AdjLsa::getKey() const
 {
-  string key;
-  key = m_origRouter + "/" + boost::lexical_cast<std::string>(2);
+  ndn::Name key = m_origRouter;
+  key.append("adjacency");
   return key;
 }
 
@@ -228,7 +236,7 @@
 AdjLsa::getData()
 {
   string adjLsaData;
-  adjLsaData = m_origRouter + "|" + boost::lexical_cast<std::string>(2) + "|"
+  adjLsaData = m_origRouter.toUri() + "|" + "adjacency" + "|"
                + boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
                + boost::lexical_cast<std::string>(m_lifeTime);
   adjLsaData += "|";
@@ -237,7 +245,7 @@
   for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++)
   {
     adjLsaData += "|";
-    adjLsaData += (*it).getName();
+    adjLsaData += (*it).getName().toUri();
     adjLsaData += "|";
     adjLsaData += boost::lexical_cast<std::string>((*it).getConnectingFace());
     adjLsaData += "|";
@@ -247,38 +255,37 @@
 }
 
 bool
-AdjLsa::initializeFromContent(string content)
+AdjLsa::initializeFromContent(const std::string& content)
 {
   uint32_t numLink = 0;
-  Tokenizer nt(content, "|");
-  m_origRouter = nt.getNextToken();
-  if (m_origRouter.empty())
+  boost::char_separator<char> sep("|");
+  boost::tokenizer<boost::char_separator<char> >tokens(content, sep);
+  boost::tokenizer<boost::char_separator<char> >::iterator tok_iter =
+                                               tokens.begin();
+  m_origRouter = ndn::Name(*tok_iter++);
+  if (!(m_origRouter.size() > 0))
   {
     return false;
   }
-  try
-  {
-    m_lsType   = boost::lexical_cast<uint8_t>(nt.getNextToken());
-    m_lsSeqNo  = boost::lexical_cast<uint32_t>(nt.getNextToken());
-    m_lifeTime = boost::lexical_cast<uint32_t>(nt.getNextToken());
-    numLink    = boost::lexical_cast<uint32_t>(nt.getNextToken());
+  try {
+    m_lsType   = *tok_iter++;
+    m_lsSeqNo  = boost::lexical_cast<uint32_t>(*tok_iter++);
+    m_lifeTime = boost::lexical_cast<uint32_t>(*tok_iter++);
+    numLink    = boost::lexical_cast<uint32_t>(*tok_iter++);
   }
-  catch (std::exception& e)
-  {
+  catch (std::exception& e) {
     return false;
   }
   for (uint32_t 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());
+    try {
+      string adjName(*tok_iter++);
+      int connectingFace = boost::lexical_cast<int>(*tok_iter++);
+      double linkCost = boost::lexical_cast<double>(*tok_iter++);
       Adjacent adjacent(adjName, connectingFace, linkCost, 0, 0);
       addAdjacent(adjacent);
     }
-    catch (std::exception& e)
-    {
+    catch (std::exception& e) {
       return false;
     }
   }
@@ -291,8 +298,7 @@
 {
   if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
   {
-    pnlsr.getNamePrefixTable().addEntry(getOrigRouter(), getOrigRouter(),
-                                                 pnlsr);
+    pnlsr.getNamePrefixTable().addEntry(getOrigRouter(), getOrigRouter());
   }
 }
 
@@ -302,7 +308,7 @@
 {
   if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
   {
-    pnlsr.getNamePrefixTable().removeEntry(getOrigRouter(), getOrigRouter(), pnlsr);
+    pnlsr.getNamePrefixTable().removeEntry(getOrigRouter(), getOrigRouter());
   }
 }
 
@@ -313,7 +319,7 @@
 {
   os << "Adj Lsa: " << endl;
   os << "  Origination Router: " << aLsa.getOrigRouter() << endl;
-  os << "  Ls Type: " << (unsigned short)aLsa.getLsType() << endl;
+  os << "  Ls Type: " << aLsa.getLsType() << endl;
   os << "  Ls Seq No: " << (unsigned int)aLsa.getLsSeqNo() << endl;
   os << "  Ls Lifetime: " << (unsigned int)aLsa.getLifeTime() << endl;
   os << "  No Link: " << (unsigned int)aLsa.getNoLink() << endl;
diff --git a/src/lsa.hpp b/src/lsa.hpp
index 3a86c09..0220897 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -8,6 +8,7 @@
 #include "adjacency-list.hpp"
 
 namespace nlsr {
+
 class Lsa
 {
 public:
@@ -21,12 +22,12 @@
 
 
   void
-  setLsType(uint8_t lst)
+  setLsType(const std::string& lst)
   {
     m_lsType = lst;
   }
 
-  uint8_t
+  const std::string&
   getLsType() const
   {
     return m_lsType;
@@ -44,14 +45,14 @@
     return m_lsSeqNo;
   }
 
-  std::string
+  const ndn::Name&
   getOrigRouter() const
   {
     return m_origRouter;
   }
 
   void
-  setOrigRouter(const std::string& org)
+  setOrigRouter(const ndn::Name& org)
   {
     m_origRouter = org;
   }
@@ -81,8 +82,8 @@
   }
 
 protected:
-  std::string m_origRouter;
-  uint8_t m_lsType;
+  ndn::Name m_origRouter;
+  std::string m_lsType;
   uint32_t m_lsSeqNo;
   uint32_t m_lifeTime;
   ndn::EventId m_expiringEventId;
@@ -95,10 +96,11 @@
     : Lsa()
     , m_npl()
   {
-    setLsType(1);
+    setLsType("name");
   }
 
-  NameLsa(std::string origR, uint8_t lst, uint32_t lsn, uint32_t lt,
+  NameLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
+          uint32_t lt,
           NamePrefixList& npl);
 
   NamePrefixList&
@@ -108,25 +110,25 @@
   }
 
   void
-  addName(std::string& name)
+  addName(const ndn::Name& name)
   {
     m_npl.insert(name);
   }
 
   void
-  removeName(std::string& name)
+  removeName(const ndn::Name& name)
   {
     m_npl.remove(name);
   }
 
-  std::string
+  const ndn::Name
   getKey() const;
 
   std::string
   getData();
 
   bool
-  initializeFromContent(std::string content);
+  initializeFromContent(const std::string& content);
 
   void
   writeLog();
@@ -146,10 +148,11 @@
     : Lsa()
     , m_adl()
   {
-    setLsType(2);
+    setLsType("adjacency");
   }
 
-  AdjLsa(std::string origR, uint8_t lst, uint32_t lsn, uint32_t lt,
+  AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
+         uint32_t lt,
          uint32_t nl , AdjacencyList& adl);
 
   AdjacencyList&
@@ -164,14 +167,14 @@
     m_adl.insert(adj);
   }
 
-  std::string
-  getKey();
+  const ndn::Name
+  getKey() const;
 
   std::string
   getData();
 
   bool
-  initializeFromContent(std::string content);
+  initializeFromContent(const std::string& content);
 
   uint32_t
   getNoLink()
@@ -204,20 +207,21 @@
     , m_corRad(0)
     , m_corTheta(0)
   {
-    setLsType(3);
+    setLsType("coordinate");
   }
 
-  CoordinateLsa(std::string origR, uint8_t lst, uint32_t lsn, uint32_t lt
+  CoordinateLsa(const ndn::Name& origR, const std::string lst, uint32_t lsn,
+                uint32_t lt
                 , double r, double theta);
 
-  std::string
+  const ndn::Name
   getKey() const;
 
   std::string
   getData();
 
   bool
-  initializeFromContent(std::string content);
+  initializeFromContent(const std::string& content);
 
   double
   getCorRadius() const
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 7cdd4b6..a5eb2b2 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -2,38 +2,39 @@
 #include <utility>
 #include "lsdb.hpp"
 #include "nlsr.hpp"
+#include "utility/name-helper.hpp"
 
 namespace nlsr {
 
 using namespace std;
 
 void
-Lsdb::cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, ndn::EventId eid)
+Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
 {
-  pnlsr.getScheduler().cancelEvent(eid);
+  m_nlsr.getScheduler().cancelEvent(eid);
 }
 
 static bool
-nameLsaCompareByKey(const NameLsa& nlsa1, const string& key)
+nameLsaCompareByKey(const NameLsa& nlsa1, const ndn::Name& key)
 {
   return nlsa1.getKey() == key;
 }
 
 
 bool
-Lsdb::buildAndInstallOwnNameLsa(Nlsr& pnlsr)
+Lsdb::buildAndInstallOwnNameLsa()
 {
-  NameLsa nameLsa(pnlsr.getConfParameter().getRouterPrefix(),
-                  1,
-                  pnlsr.getSequencingManager().getNameLsaSeq() + 1,
-                  pnlsr.getConfParameter().getRouterDeadInterval(),
-                  pnlsr.getNamePrefixList());
-  pnlsr.getSequencingManager().increaseNameLsaSeq();
-  return installNameLsa(pnlsr, nameLsa);
+  NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
+                  "name",
+                  m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
+                  m_nlsr.getConfParameter().getRouterDeadInterval(),
+                  m_nlsr.getNamePrefixList());
+  m_nlsr.getSequencingManager().increaseNameLsaSeq();
+  return installNameLsa(nameLsa);
 }
 
 NameLsa*
-Lsdb::findNameLsa(const string key)
+Lsdb::findNameLsa(const ndn::Name& key)
 {
   std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
                                                  m_nameLsdb.end(),
@@ -46,7 +47,7 @@
 }
 
 bool
-Lsdb::isNameLsaNew(string key, uint64_t seqNo)
+Lsdb::isNameLsaNew(const ndn::Name& key, uint64_t seqNo)
 {
   NameLsa* nameLsaCheck = findNameLsa(key);
   if (nameLsaCheck != 0)
@@ -64,15 +65,15 @@
 }
 
 ndn::EventId
-Lsdb::scheduleNameLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime)
+Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo, int expTime)
 {
-  return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
-                                            ndn::bind(&Lsdb::exprireOrRefreshNameLsa,
-                                                      this, boost::ref(pnlsr), key, seqNo));
+  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+                                             ndn::bind(&Lsdb::exprireOrRefreshNameLsa,
+                                                       this, key, seqNo));
 }
 
 bool
-Lsdb::installNameLsa(Nlsr& pnlsr, NameLsa& nlsa)
+Lsdb::installNameLsa(NameLsa& nlsa)
 {
   int timeToExpire = m_lsaRefreshTime;
   NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
@@ -81,26 +82,25 @@
     addNameLsa(nlsa);
     nlsa.writeLog();
     printNameLsdb();
-    if (nlsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+    if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
     {
-      pnlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
-                                          nlsa.getOrigRouter(), pnlsr);
-      std::list<string> nameList = nlsa.getNpl().getNameList();
-      for (std::list<string>::iterator it = nameList.begin(); it != nameList.end();
+      m_nlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
+                                           nlsa.getOrigRouter());
+      std::list<ndn::Name> nameList = nlsa.getNpl().getNameList();
+      for (std::list<ndn::Name>::iterator it = nameList.begin(); it != nameList.end();
            it++)
       {
-        if ((*it) != pnlsr.getConfParameter().getRouterPrefix())
+        if ((*it) != m_nlsr.getConfParameter().getRouterPrefix())
         {
-          pnlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter(), pnlsr);
+          m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
         }
       }
     }
-    if (nlsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+    if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
     {
       timeToExpire = nlsa.getLifeTime();
     }
-    nlsa.setExpiringEventId(scheduleNameLsaExpiration(pnlsr,
-                                                      nlsa.getKey(),
+    nlsa.setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
                                                       nlsa.getLsSeqNo(),
                                                       timeToExpire));
   }
@@ -113,50 +113,49 @@
       chkNameLsa->setLifeTime(nlsa.getLifeTime());
       chkNameLsa->getNpl().sort();
       nlsa.getNpl().sort();
-      std::list<string> nameToAdd;
+      std::list<ndn::Name> nameToAdd;
       std::set_difference(nlsa.getNpl().getNameList().begin(),
                           nlsa.getNpl().getNameList().end(),
                           chkNameLsa->getNpl().getNameList().begin(),
                           chkNameLsa->getNpl().getNameList().end(),
                           std::inserter(nameToAdd, nameToAdd.begin()));
-      for (std::list<string>::iterator it = nameToAdd.begin(); it != nameToAdd.end();
+      for (std::list<ndn::Name>::iterator it = nameToAdd.begin();
+           it != nameToAdd.end();
            ++it)
       {
         chkNameLsa->addName((*it));
-        if (nlsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+        if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
         {
-          if ((*it) != pnlsr.getConfParameter().getRouterPrefix())
+          if ((*it) != m_nlsr.getConfParameter().getRouterPrefix())
           {
-            pnlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter(), pnlsr);
+            m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
           }
         }
       }
-      std::list<string> nameToRemove;
+      std::list<ndn::Name> nameToRemove;
       std::set_difference(chkNameLsa->getNpl().getNameList().begin(),
                           chkNameLsa->getNpl().getNameList().end(),
                           nlsa.getNpl().getNameList().begin(),
                           nlsa.getNpl().getNameList().end(),
                           std::inserter(nameToRemove, nameToRemove.begin()));
-      for (std::list<string>::iterator it = nameToRemove.begin();
+      for (std::list<ndn::Name>::iterator it = nameToRemove.begin();
            it != nameToRemove.end(); ++it)
       {
         chkNameLsa->removeName((*it));
-        if (nlsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+        if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
         {
-          if ((*it) != pnlsr.getConfParameter().getRouterPrefix())
+          if ((*it) != m_nlsr.getConfParameter().getRouterPrefix())
           {
-            pnlsr.getNamePrefixTable().removeEntry((*it), nlsa.getOrigRouter(), pnlsr);
+            m_nlsr.getNamePrefixTable().removeEntry((*it), nlsa.getOrigRouter());
           }
         }
       }
-      if (nlsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+      if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
       {
         timeToExpire = nlsa.getLifeTime();
       }
-      cancelScheduleLsaExpiringEvent(pnlsr,
-                                     chkNameLsa->getExpiringEventId());
-      chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(pnlsr,
-                                                               nlsa.getKey(),
+      cancelScheduleLsaExpiringEvent(chkNameLsa->getExpiringEventId());
+      chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
                                                                nlsa.getLsSeqNo(),
                                                                timeToExpire));
       chkNameLsa->writeLog();
@@ -181,7 +180,7 @@
 }
 
 bool
-Lsdb::removeNameLsa(Nlsr& pnlsr, string& key)
+Lsdb::removeNameLsa(const ndn::Name& key)
 {
   std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
                                                  m_nameLsdb.end(),
@@ -189,16 +188,17 @@
   if (it != m_nameLsdb.end())
   {
     (*it).writeLog();
-    if ((*it).getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+    if ((*it).getOrigRouter() !=
+        m_nlsr.getConfParameter().getRouterPrefix())
     {
-      pnlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
-                                             (*it).getOrigRouter(), pnlsr);
-      for (std::list<string>::iterator nit = (*it).getNpl().getNameList().begin();
+      m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
+                                              (*it).getOrigRouter());
+      for (std::list<ndn::Name>::iterator nit = (*it).getNpl().getNameList().begin();
            nit != (*it).getNpl().getNameList().end(); ++nit)
       {
-        if ((*nit) != pnlsr.getConfParameter().getRouterPrefix())
+        if ((*nit) != m_nlsr.getConfParameter().getRouterPrefix())
         {
-          pnlsr.getNamePrefixTable().removeEntry((*nit), (*it).getOrigRouter(), pnlsr);
+          m_nlsr.getNamePrefixTable().removeEntry((*nit), (*it).getOrigRouter());
         }
       }
     }
@@ -209,7 +209,7 @@
 }
 
 bool
-Lsdb::doesNameLsaExist(string key)
+Lsdb::doesNameLsaExist(const ndn::Name& key)
 {
   std::list<NameLsa>::iterator it = std::find_if(m_nameLsdb.begin(),
                                                  m_nameLsdb.end(),
@@ -236,27 +236,27 @@
 
 
 static bool
-corLsaCompareByKey(const CoordinateLsa& clsa, const string& key)
+corLsaCompareByKey(const CoordinateLsa& clsa, const ndn::Name& key)
 {
   return clsa.getKey() == key;
 }
 
 bool
-Lsdb::buildAndInstallOwnCoordinateLsa(Nlsr& pnlsr)
+Lsdb::buildAndInstallOwnCoordinateLsa()
 {
-  CoordinateLsa corLsa(pnlsr.getConfParameter().getRouterPrefix(),
-                       3,
-                       pnlsr.getSequencingManager().getCorLsaSeq() + 1,
-                       pnlsr.getConfParameter().getRouterDeadInterval(),
-                       pnlsr.getConfParameter().getCorR(),
-                       pnlsr.getConfParameter().getCorTheta());
-  pnlsr.getSequencingManager().increaseCorLsaSeq();
-  installCoordinateLsa(pnlsr, corLsa);
+  CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
+                       "coordinate",
+                       m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
+                       m_nlsr.getConfParameter().getRouterDeadInterval(),
+                       m_nlsr.getConfParameter().getCorR(),
+                       m_nlsr.getConfParameter().getCorTheta());
+  m_nlsr.getSequencingManager().increaseCorLsaSeq();
+  installCoordinateLsa(corLsa);
   return true;
 }
 
 CoordinateLsa*
-Lsdb::findCoordinateLsa(const string& key)
+Lsdb::findCoordinateLsa(const ndn::Name& key)
 {
   std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
                                                        m_corLsdb.end(),
@@ -269,7 +269,7 @@
 }
 
 bool
-Lsdb::isCoordinateLsaNew(const string& key, uint64_t seqNo)
+Lsdb::isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo)
 {
   CoordinateLsa* clsa = findCoordinateLsa(key);
   if (clsa != 0)
@@ -287,17 +287,16 @@
 }
 
 ndn::EventId
-Lsdb::scheduleCoordinateLsaExpiration(Nlsr& pnlsr, const string& key, int seqNo,
+Lsdb::scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
                                       int expTime)
 {
-  return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
-                                            ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
-                                                      this, boost::ref(pnlsr),
-                                                      key, seqNo));
+  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+                                             ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
+                                                       this, key, seqNo));
 }
 
 bool
-Lsdb::installCoordinateLsa(Nlsr& pnlsr, CoordinateLsa& clsa)
+Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
 {
   int timeToExpire = m_lsaRefreshTime;
   CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
@@ -305,20 +304,20 @@
   {
     addCoordinateLsa(clsa);
     printCorLsdb(); //debugging purpose
-    if (clsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+    if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
     {
-      pnlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
-                                          clsa.getOrigRouter(), pnlsr);
+      m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
+                                           clsa.getOrigRouter());
     }
-    if (pnlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
+    if (m_nlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
     {
-      pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
+      m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
     }
-    if (clsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+    if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
     {
       timeToExpire = clsa.getLifeTime();
     }
-    scheduleCoordinateLsaExpiration(pnlsr, clsa.getKey(),
+    scheduleCoordinateLsaExpiration(clsa.getKey(),
                                     clsa.getLsSeqNo(), timeToExpire);
   }
   else
@@ -331,19 +330,17 @@
       {
         chkCorLsa->setCorRadius(clsa.getCorRadius());
         chkCorLsa->setCorTheta(clsa.getCorTheta());
-        if (pnlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
+        if (m_nlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
         {
-          pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
+          m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
         }
       }
-      if (clsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+      if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
       {
         timeToExpire = clsa.getLifeTime();
       }
-      cancelScheduleLsaExpiringEvent(pnlsr,
-                                     chkCorLsa->getExpiringEventId());
-      chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(pnlsr,
-                                                                    clsa.getKey(),
+      cancelScheduleLsaExpiringEvent(chkCorLsa->getExpiringEventId());
+      chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(clsa.getKey(),
                                                                     clsa.getLsSeqNo(),
                                                                     timeToExpire));
     }
@@ -367,17 +364,18 @@
 }
 
 bool
-Lsdb::removeCoordinateLsa(Nlsr& pnlsr, const string& key)
+Lsdb::removeCoordinateLsa(const ndn::Name& key)
 {
   std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
                                                        m_corLsdb.end(),
                                                        bind(corLsaCompareByKey, _1, key));
   if (it != m_corLsdb.end())
   {
-    if ((*it).getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+    if ((*it).getOrigRouter() !=
+        m_nlsr.getConfParameter().getRouterPrefix())
     {
-      pnlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
-                                             (*it).getOrigRouter(), pnlsr);
+      m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
+                                              (*it).getOrigRouter());
     }
     m_corLsdb.erase(it);
     return true;
@@ -386,7 +384,7 @@
 }
 
 bool
-Lsdb::doesCoordinateLsaExist(const string& key)
+Lsdb::doesCoordinateLsaExist(const ndn::Name& key)
 {
   std::list<CoordinateLsa>::iterator it = std::find_if(m_corLsdb.begin(),
                                                        m_corLsdb.end(),
@@ -413,43 +411,44 @@
 // Adj LSA and LSDB related function starts here
 
 static bool
-adjLsaCompareByKey(AdjLsa& alsa, string& key)
+adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
 {
   return alsa.getKey() == key;
 }
 
 
 void
-Lsdb::scheduledAdjLsaBuild(Nlsr& pnlsr)
+Lsdb::scheduledAdjLsaBuild()
 {
   cout << "scheduledAdjLsaBuild Called" << endl;
-  pnlsr.setIsBuildAdjLsaSheduled(0);
-  if (pnlsr.getAdjacencyList().isAdjLsaBuildable(pnlsr))
+  m_nlsr.setIsBuildAdjLsaSheduled(0);
+  if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr))
   {
-    int adjBuildCount = pnlsr.getAdjBuildCount();
+    int adjBuildCount = m_nlsr.getAdjBuildCount();
     if (adjBuildCount > 0)
     {
-      if (pnlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0)
+      if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0)
       {
-        buildAndInstallOwnAdjLsa(pnlsr);
+        buildAndInstallOwnAdjLsa();
       }
       else
       {
-        string key = pnlsr.getConfParameter().getRouterPrefix() + "/2";
-        removeAdjLsa(pnlsr, key);
-        pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
+        ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
+        key.append("adjacency");
+        removeAdjLsa(key);
+        m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
       }
-      pnlsr.setAdjBuildCount(pnlsr.getAdjBuildCount() - adjBuildCount);
+      m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
     }
   }
   else
   {
-    pnlsr.setIsBuildAdjLsaSheduled(1);
-    int schedulingTime = pnlsr.getConfParameter().getInterestRetryNumber() *
-                         pnlsr.getConfParameter().getInterestResendTime();
-    pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(schedulingTime),
-                                       ndn::bind(&Lsdb::scheduledAdjLsaBuild,
-                                                 pnlsr.getLsdb(), boost::ref(pnlsr)));
+    m_nlsr.setIsBuildAdjLsaSheduled(1);
+    int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
+                         m_nlsr.getConfParameter().getInterestResendTime();
+    m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(schedulingTime),
+                                        ndn::bind(&Lsdb::scheduledAdjLsaBuild,
+                                                  this));
   }
 }
 
@@ -470,7 +469,7 @@
 }
 
 AdjLsa*
-Lsdb::findAdjLsa(const string key)
+Lsdb::findAdjLsa(const ndn::Name& key)
 {
   std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
                                                 m_adjLsdb.end(),
@@ -484,7 +483,7 @@
 
 
 bool
-Lsdb::isAdjLsaNew(string key, uint64_t seqNo)
+Lsdb::isAdjLsaNew(const ndn::Name& key, uint64_t seqNo)
 {
   AdjLsa*  adjLsaCheck = findAdjLsa(key);
   if (adjLsaCheck != 0)
@@ -503,29 +502,28 @@
 
 
 ndn::EventId
-Lsdb::scheduleAdjLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime)
+Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo, int expTime)
 {
-  return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
-                                            ndn::bind(&Lsdb::exprireOrRefreshAdjLsa,
-                                                      this, boost::ref(pnlsr),
-                                                      key, seqNo));
+  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(expTime),
+                                             ndn::bind(&Lsdb::exprireOrRefreshAdjLsa,
+                                                       this, key, seqNo));
 }
 
 bool
-Lsdb::installAdjLsa(Nlsr& pnlsr, AdjLsa& alsa)
+Lsdb::installAdjLsa(AdjLsa& alsa)
 {
   int timeToExpire = m_lsaRefreshTime;
   AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
   if (chkAdjLsa == 0)
   {
     addAdjLsa(alsa);
-    alsa.addNptEntries(pnlsr);
-    pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
-    if (alsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+    alsa.addNptEntries(m_nlsr);
+    m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
+    if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
     {
       timeToExpire = alsa.getLifeTime();
     }
-    scheduleAdjLsaExpiration(pnlsr, alsa.getKey(),
+    scheduleAdjLsaExpiration(alsa.getKey(),
                              alsa.getLsSeqNo(), timeToExpire);
   }
   else
@@ -538,15 +536,14 @@
       {
         chkAdjLsa->getAdl().reset();
         chkAdjLsa->getAdl().addAdjacents(alsa.getAdl());
-        pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
+        m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
       }
-      if (alsa.getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix())
+      if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix())
       {
         timeToExpire = alsa.getLifeTime();
       }
-      cancelScheduleLsaExpiringEvent(pnlsr, chkAdjLsa->getExpiringEventId());
-      chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
-                                                             alsa.getKey(),
+      cancelScheduleLsaExpiringEvent(chkAdjLsa->getExpiringEventId());
+      chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(alsa.getKey(),
                                                              alsa.getLsSeqNo(),
                                                              timeToExpire));
     }
@@ -555,31 +552,32 @@
 }
 
 bool
-Lsdb::buildAndInstallOwnAdjLsa(Nlsr& pnlsr)
+Lsdb::buildAndInstallOwnAdjLsa()
 {
-  AdjLsa adjLsa(pnlsr.getConfParameter().getRouterPrefix(),
-                2,
-                pnlsr.getSequencingManager().getAdjLsaSeq() + 1,
-                pnlsr.getConfParameter().getRouterDeadInterval(),
-                pnlsr.getAdjacencyList().getNumOfActiveNeighbor(),
-                pnlsr.getAdjacencyList());
-  pnlsr.getSequencingManager().increaseAdjLsaSeq();
-  string lsaPrefix = pnlsr.getConfParameter().getChronosyncLsaPrefix() +
-                     pnlsr.getConfParameter().getRouterPrefix();
-  pnlsr.getSyncLogicHandler().publishRoutingUpdate(pnlsr.getSequencingManager(),
-                                                   lsaPrefix);
-  return pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
+  AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
+                "adjacency",
+                m_nlsr.getSequencingManager().getAdjLsaSeq() + 1,
+                m_nlsr.getConfParameter().getRouterDeadInterval(),
+                m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
+                m_nlsr.getAdjacencyList());
+  m_nlsr.getSequencingManager().increaseAdjLsaSeq();
+  // publish routing update
+  ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+  lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+  m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
+                                                    lsaPrefix);
+  return installAdjLsa(adjLsa);
 }
 
 bool
-Lsdb::removeAdjLsa(Nlsr& pnlsr, string& key)
+Lsdb::removeAdjLsa(const ndn::Name& key)
 {
   std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
                                                 m_adjLsdb.end(),
                                                 bind(adjLsaCompareByKey, _1, key));
   if (it != m_adjLsdb.end())
   {
-    (*it).removeNptEntries(pnlsr);
+    (*it).removeNptEntries(m_nlsr);
     m_adjLsdb.erase(it);
     return true;
   }
@@ -587,7 +585,7 @@
 }
 
 bool
-Lsdb::doesAdjLsaExist(string key)
+Lsdb::doesAdjLsaExist(const ndn::Name& key)
 {
   std::list<AdjLsa>::iterator it = std::find_if(m_adjLsdb.begin(),
                                                 m_adjLsdb.end(),
@@ -618,7 +616,7 @@
 }
 
 void
-Lsdb::exprireOrRefreshNameLsa(Nlsr& pnlsr, string lsaKey, uint64_t seqNo)
+Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
 {
   cout << "Lsdb::exprireOrRefreshNameLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
@@ -633,30 +631,29 @@
         chkNameLsa->writeLog();
         cout << "Own Name LSA, so refreshing name LSA" << endl;
         chkNameLsa->setLsSeqNo(chkNameLsa->getLsSeqNo() + 1);
-        pnlsr.getSequencingManager().setNameLsaSeq(chkNameLsa->getLsSeqNo());
+        m_nlsr.getSequencingManager().setNameLsaSeq(chkNameLsa->getLsSeqNo());
         chkNameLsa->writeLog();
         // schedule refreshing event again
-        chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(pnlsr,
-                                                                 chkNameLsa->getKey(),
+        chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(chkNameLsa->getKey(),
                                                                  chkNameLsa->getLsSeqNo(),
                                                                  m_lsaRefreshTime));
         // publish routing update
-        string lsaPrefix = pnlsr.getConfParameter().getChronosyncLsaPrefix()
-                           + pnlsr.getConfParameter().getRouterPrefix();
-        pnlsr.getSyncLogicHandler().publishRoutingUpdate(pnlsr.getSequencingManager(),
-                                                         lsaPrefix);
+        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+        lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+        m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
+                                                          lsaPrefix);
       }
       else
       {
         cout << "Other's Name LSA, so removing form LSDB" << endl;
-        removeNameLsa(pnlsr, lsaKey);
+        removeNameLsa(lsaKey);
       }
     }
   }
 }
 
 void
-Lsdb::exprireOrRefreshAdjLsa(Nlsr& pnlsr, string lsaKey, uint64_t seqNo)
+Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
 {
   cout << "Lsdb::exprireOrRefreshAdjLsa Called " << endl;
   cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
@@ -670,31 +667,30 @@
       {
         cout << "Own Adj LSA, so refreshing Adj LSA" << endl;
         chkAdjLsa->setLsSeqNo(chkAdjLsa->getLsSeqNo() + 1);
-        pnlsr.getSequencingManager().setAdjLsaSeq(chkAdjLsa->getLsSeqNo());
+        m_nlsr.getSequencingManager().setAdjLsaSeq(chkAdjLsa->getLsSeqNo());
         // schedule refreshing event again
-        chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(pnlsr,
-                                                               chkAdjLsa->getKey(),
+        chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(chkAdjLsa->getKey(),
                                                                chkAdjLsa->getLsSeqNo(),
                                                                m_lsaRefreshTime));
         // publish routing update
-        string lsaPrefix = pnlsr.getConfParameter().getChronosyncLsaPrefix()
-                           + pnlsr.getConfParameter().getRouterPrefix();
-        pnlsr.getSyncLogicHandler().publishRoutingUpdate(pnlsr.getSequencingManager(),
-                                                         lsaPrefix);
+        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+        lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+        m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
+                                                          lsaPrefix);
       }
       else
       {
         cout << "Other's Adj LSA, so removing form LSDB" << endl;
-        removeAdjLsa(pnlsr, lsaKey);
+        removeAdjLsa(lsaKey);
       }
       // schedule Routing table calculaiton
-      pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
+      m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
     }
   }
 }
 
 void
-Lsdb::exprireOrRefreshCoordinateLsa(Nlsr& pnlsr, const string& lsaKey,
+Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
                                     uint64_t seqNo)
 {
   cout << "Lsdb::exprireOrRefreshCorLsa Called " << endl;
@@ -709,26 +705,26 @@
       {
         cout << "Own Cor LSA, so refreshing Cor LSA" << endl;
         chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
-        pnlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
+        m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
         // schedule refreshing event again
-        chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(pnlsr,
-                                                                      chkCorLsa->getKey(),
-                                                                      chkCorLsa->getLsSeqNo(),
-                                                                      m_lsaRefreshTime));
+        chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(
+                                        chkCorLsa->getKey(),
+                                        chkCorLsa->getLsSeqNo(),
+                                        m_lsaRefreshTime));
         // publish routing update
-        string lsaPrefix = pnlsr.getConfParameter().getChronosyncLsaPrefix()
-                           + pnlsr.getConfParameter().getRouterPrefix();
-        pnlsr.getSyncLogicHandler().publishRoutingUpdate(pnlsr.getSequencingManager(),
-                                                         lsaPrefix);
+        ndn::Name lsaPrefix = m_nlsr.getConfParameter().getChronosyncLsaPrefix();
+        lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
+        m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
+                                                          lsaPrefix);
       }
       else
       {
         cout << "Other's Cor LSA, so removing form LSDB" << endl;
-        removeCoordinateLsa(pnlsr, lsaKey);
+        removeCoordinateLsa(lsaKey);
       }
-      if (pnlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
+      if (m_nlsr.getConfParameter().getIsHyperbolicCalc() >= 1)
       {
-        pnlsr.getRoutingTable().scheduleRoutingTableCalculation(pnlsr);
+        m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
       }
     }
   }
@@ -736,6 +732,240 @@
 
 
 void
+Lsdb::expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime)
+{
+  std::cout << "Expressing Interest :" << interestName << std::endl;
+  ndn::Interest interest(interestName);
+  interest.setInterestLifetime(ndn::time::seconds(interestLifeTime));
+  interest.setMustBeFresh(true);
+  m_nlsr.getNlsrFace().expressInterest(interest,
+                                       ndn::bind(&Lsdb::processContent,
+                                                 this, _1, _2),
+                                       ndn::bind(&Lsdb::processInterestTimedOut,
+                                                 this, _1));
+}
+
+void
+Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
+{
+  const ndn::Name& intName(interest.getName());
+  std::cout << "Interest recevied for LSA: " << intName << std::endl;
+  string chkString("LSA");
+  int32_t lsaPosition = util::getNameComponentPosition(interest.getName(),
+                                                       chkString);
+  if (lsaPosition >= 0)
+  {
+    std::string interestedLsType;
+    uint64_t interestedLsSeqNo;
+    ndn::Name origRouter = intName.getSubName(lsaPosition + 1,
+                                              interest.getName().size() - lsaPosition - 3);
+    interestedLsType  = intName[-2].toEscapedString();
+    interestedLsSeqNo = intName[-1].toNumber();
+    std::cout << "Router Name: " << origRouter << std::endl;
+    std::cout << "Ls Type    : " << interestedLsType << std::endl;
+    std::cout << "Ls Seq     : " << interestedLsSeqNo << endl;
+    std::cout << "Ls Type: " << interestedLsType << std::endl;
+    if (interestedLsType == "name")
+    {
+      processInterestForNameLsa(interest,
+                                origRouter.append(interestedLsType),
+                                interestedLsSeqNo);
+      return;
+    }
+    else if (interestedLsType == "adjacency")
+    {
+      processInterestForAdjacencyLsa(interest,
+                                     origRouter.append(interestedLsType),
+                                     interestedLsSeqNo);
+      return;
+    }
+    else if (interestedLsType == "coordinate")
+    {
+      processInterestForCoordinateLsa(interest,
+                                      origRouter.append(interestedLsType),
+                                      interestedLsSeqNo);
+      return;
+    }
+    else
+    {
+      cout << "Unrecognized LSA Type :(" << endl;
+    }
+  }
+}
+
+void
+Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
+                                const ndn::Name& lsaKey,
+                                uint32_t interestedlsSeqNo)
+{
+  NameLsa*  nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
+  if (nameLsa != 0)
+  {
+    if (nameLsa->getLsSeqNo() >= interestedlsSeqNo)
+    {
+      ndn::Data data(ndn::Name(interest.getName()).appendVersion());
+      data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
+      std::string content = nameLsa->getData();
+      data.setContent(reinterpret_cast<const uint8_t*>(content.c_str()),
+                      content.size());
+      m_keyChain.sign(data);
+      std::cout << ">> D: " << data << std::endl;
+      m_nlsr.getNlsrFace().put(data);
+    }
+  }
+}
+
+void
+Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
+                                     const ndn::Name& lsaKey,
+                                     uint32_t interestedlsSeqNo)
+{
+  AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
+  if (adjLsa != 0)
+  {
+    if (adjLsa->getLsSeqNo() >= interestedlsSeqNo)
+    {
+      ndn::Data data(ndn::Name(interest.getName()).appendVersion());
+      data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
+      std::string content = adjLsa->getData();
+      data.setContent(reinterpret_cast<const uint8_t*>(content.c_str()),
+                      content.size());
+      m_keyChain.sign(data);
+      std::cout << ">> D: " << data << std::endl;
+      m_nlsr.getNlsrFace().put(data);
+    }
+  }
+}
+
+void
+Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
+                                      const ndn::Name& lsaKey,
+                                      uint32_t interestedlsSeqNo)
+{
+  CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
+  if (corLsa != 0)
+  {
+    if (corLsa->getLsSeqNo() >= interestedlsSeqNo)
+    {
+      ndn::Data data(ndn::Name(interest.getName()).appendVersion());
+      data.setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
+      std::string content = corLsa->getData();
+      data.setContent(reinterpret_cast<const uint8_t*>(content.c_str()),
+                      content.size());
+      m_keyChain.sign(data);
+      std::cout << ">> D: " << data << std::endl;
+      m_nlsr.getNlsrFace().put(data);
+    }
+  }
+}
+
+void
+Lsdb::processContent(const ndn::Interest& interest, const ndn::Data& data)
+{
+  const ndn::Name& dataName = data.getName();
+  std::cout << "Data received for name: " << dataName << std::endl;
+  string dataContent(reinterpret_cast<const char*>(data.getContent().value()));
+  string chkString("LSA");
+  int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
+  if (lsaPosition >= 0)
+  {
+    std::string interestedLsType;
+    uint64_t interestedLsSeqNo;
+    ndn::Name origRouter = dataName.getSubName(lsaPosition + 1,
+                                               dataName.size() - lsaPosition - 4);
+    interestedLsType  = dataName[-3].toEscapedString();
+    interestedLsSeqNo = dataName[-2].toNumber();
+    std::cout << "Ls Type    : " << interestedLsType << std::endl;
+    std::cout << "Ls Seq     : " << interestedLsSeqNo << std::endl;
+    std::cout << "Ls Type: " << interestedLsType << std::endl;
+    if (interestedLsType == "name")
+    {
+      processContentNameLsa(origRouter.append(interestedLsType),
+                            interestedLsSeqNo, dataContent);
+      return;
+    }
+    else if (interestedLsType == "adjacency")
+    {
+      processContentAdjacencyLsa(origRouter.append(interestedLsType),
+                                 interestedLsSeqNo, dataContent);
+      return;
+    }
+    else if (interestedLsType == "coordinate")
+    {
+      processContentCoordinateLsa(origRouter.append(interestedLsType),
+                                  interestedLsSeqNo, dataContent);
+      return;
+    }
+    else
+    {
+      cout << "Unrecognized LSA Type :(" << endl;
+    }
+  }
+}
+
+void
+Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
+                            uint32_t lsSeqNo, std::string& dataContent)
+{
+  if (isNameLsaNew(lsaKey, lsSeqNo))
+  {
+    NameLsa nameLsa;
+    if (nameLsa.initializeFromContent(dataContent))
+    {
+      installNameLsa(nameLsa);
+    }
+    else
+    {
+      std::cout << "LSA data decoding error :(" << std::endl;
+    }
+  }
+}
+
+void
+Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
+                                 uint32_t lsSeqNo, std::string& dataContent)
+{
+  if (isAdjLsaNew(lsaKey, lsSeqNo))
+  {
+    AdjLsa adjLsa;
+    if (adjLsa.initializeFromContent(dataContent))
+    {
+      installAdjLsa(adjLsa);
+    }
+    else
+    {
+      std::cout << "LSA data decoding error :(" << std::endl;
+    }
+  }
+}
+
+void
+Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
+                                  uint32_t lsSeqNo, std::string& dataContent)
+{
+  if (isCoordinateLsaNew(lsaKey, lsSeqNo))
+  {
+    CoordinateLsa corLsa;
+    if (corLsa.initializeFromContent(dataContent))
+    {
+      installCoordinateLsa(corLsa);
+    }
+    else
+    {
+      std::cout << "LSA data decoding error :(" << std::endl;
+    }
+  }
+}
+
+void
+Lsdb::processInterestTimedOut(const ndn::Interest& interest)
+{
+  const ndn::Name& interestName(interest.getName());
+  cout << "Interest timed out for Name: " << interestName << endl;
+}
+
+
+void
 Lsdb::printAdjLsdb()
 {
   cout << "---------------Adj LSDB-------------------" << endl;
@@ -748,17 +978,17 @@
 
 //-----utility function -----
 bool
-Lsdb::doesLsaExist(string key, int lsType)
+Lsdb::doesLsaExist(const ndn::Name& key, const std::string& lsType)
 {
-  if (lsType == 1)
+  if (lsType == "name")
   {
     return doesNameLsaExist(key);
   }
-  else if (lsType == 2)
+  else if (lsType == "adjacency")
   {
     return doesAdjLsaExist(key);
   }
-  else if (lsType == 3)
+  else if (lsType == "coordinate")
   {
     return doesCoordinateLsaExist(key);
   }
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 9e8c207..3ad3007 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -3,6 +3,7 @@
 
 #include <utility>
 #include <boost/cstdint.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
 
 #include "lsa.hpp"
 
@@ -12,70 +13,71 @@
 class Lsdb
 {
 public:
-  Lsdb()
-    : m_lsaRefreshTime(0)
+  Lsdb(Nlsr& nlsr)
+    : m_nlsr(nlsr)
+    , m_lsaRefreshTime(0)
   {
   }
 
 
   bool
-  doesLsaExist(std::string key, int lsType);
+  doesLsaExist(const ndn::Name& key, const std::string& lsType);
   // function related to Name LSDB
 
   bool
-  buildAndInstallOwnNameLsa(Nlsr& pnlsr);
+  buildAndInstallOwnNameLsa();
 
   NameLsa*
-  findNameLsa(const std::string key);
+  findNameLsa(const ndn::Name& key);
 
   bool
-  installNameLsa(Nlsr& pnlsr, NameLsa& nlsa);
+  installNameLsa(NameLsa& nlsa);
 
   bool
-  removeNameLsa(Nlsr& pnlsr, std::string& key);
+  removeNameLsa(const ndn::Name& key);
 
   bool
-  isNameLsaNew(std::string key, uint64_t seqNo);
+  isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
 
   void
   printNameLsdb(); //debugging
 
   //function related to Cor LSDB
   bool
-  buildAndInstallOwnCoordinateLsa(Nlsr& pnlsr);
+  buildAndInstallOwnCoordinateLsa();
 
   CoordinateLsa*
-  findCoordinateLsa(const std::string& key);
+  findCoordinateLsa(const ndn::Name& key);
 
   bool
-  installCoordinateLsa(Nlsr& pnlsr, CoordinateLsa& clsa);
+  installCoordinateLsa(CoordinateLsa& clsa);
 
   bool
-  removeCoordinateLsa(Nlsr& pnlsr, const std::string& key);
+  removeCoordinateLsa(const ndn::Name& key);
 
   bool
-  isCoordinateLsaNew(const std::string& key, uint64_t seqNo);
+  isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
 
   void
   printCorLsdb(); //debugging
 
   //function related to Adj LSDB
   void
-  scheduledAdjLsaBuild(Nlsr& pnlsr);
+  scheduledAdjLsaBuild();
 
   bool
-  buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
+  buildAndInstallOwnAdjLsa();
 
   bool
-  removeAdjLsa(Nlsr& pnlsr, std::string& key);
+  removeAdjLsa(const ndn::Name& key);
 
   bool
-  isAdjLsaNew(std::string key, uint64_t seqNo);
+  isAdjLsaNew(const ndn::Name& key, uint64_t seqNo);
   bool
-  installAdjLsa(Nlsr& pnlsr, AdjLsa& alsa);
+  installAdjLsa(AdjLsa& alsa);
 
   AdjLsa*
-  findAdjLsa(std::string key);
+  findAdjLsa(const ndn::Name& key);
 
   std::list<AdjLsa>&
   getAdjLsdb();
@@ -95,46 +97,87 @@
   addNameLsa(NameLsa& nlsa);
 
   bool
-  doesNameLsaExist(std::string key);
+  doesNameLsaExist(const ndn::Name& key);
 
 
   bool
   addCoordinateLsa(CoordinateLsa& clsa);
 
   bool
-  doesCoordinateLsaExist(const std::string& key);
+  doesCoordinateLsaExist(const ndn::Name& key);
 
   bool
   addAdjLsa(AdjLsa& alsa);
 
   bool
-  doesAdjLsaExist(std::string key);
+  doesAdjLsaExist(const ndn::Name& key);
 
   ndn::EventId
-  scheduleNameLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
+  scheduleNameLsaExpiration(const ndn::Name& key, int seqNo, int expTime);
 
   void
-  exprireOrRefreshNameLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
+  exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
 
   ndn::EventId
-  scheduleAdjLsaExpiration(Nlsr& pnlsr, std::string key, int seqNo, int expTime);
+  scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo, int expTime);
 
   void
-  exprireOrRefreshAdjLsa(Nlsr& pnlsr, std::string lsaKey, uint64_t seqNo);
+  exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
 
   ndn::EventId
-  scheduleCoordinateLsaExpiration(Nlsr& pnlsr, const std::string& key, int seqNo,
+  scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
                                   int expTime);
 
   void
-  exprireOrRefreshCoordinateLsa(Nlsr& pnlsr, const std::string& lsaKey,
+  exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
                                 uint64_t seqNo);
+public:
+  void
+  expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime);
 
+  void
+  processInterest(const ndn::Name& name, const ndn::Interest& interest);
 
 private:
   void
-  cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, ndn::EventId eid);
+  processInterestForNameLsa(const ndn::Interest& interest,
+                            const ndn::Name& lsaKey,
+                            uint32_t interestedlsSeqNo);
 
+  void
+  processInterestForAdjacencyLsa(const ndn::Interest& interest,
+                                 const ndn::Name& lsaKey,
+                                 uint32_t interestedlsSeqNo);
+
+  void
+  processInterestForCoordinateLsa(const ndn::Interest& interest,
+                                  const ndn::Name& lsaKey,
+                                  uint32_t interestedlsSeqNo);
+
+  void
+  processContent(const ndn::Interest& interest, const ndn::Data& data);
+
+  void
+  processContentNameLsa(const ndn::Name& lsaKey,
+                        uint32_t lsSeqNo, std::string& dataContent);
+
+  void
+  processContentAdjacencyLsa(const ndn::Name& lsaKey,
+                             uint32_t lsSeqNo, std::string& dataContent);
+
+  void
+  processContentCoordinateLsa(const ndn::Name& lsaKey,
+                              uint32_t lsSeqNo, std::string& dataContent);
+
+  void
+  processInterestTimedOut(const ndn::Interest& interest);
+
+private:
+  void
+  cancelScheduleLsaExpiringEvent(ndn::EventId eid);
+
+  Nlsr& m_nlsr;
+  ndn::KeyChain m_keyChain;
   std::list<NameLsa> m_nameLsdb;
   std::list<AdjLsa> m_adjLsdb;
   std::list<CoordinateLsa> m_corLsdb;
diff --git a/src/main.cpp b/src/main.cpp
index d7657fa..59829b1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -66,9 +66,9 @@
   try {
     nlsr.startEventLoop();
   }
-  catch (std::exception& e){
+  catch (std::exception& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;
-    nlsr.getFib().clean(nlsr);
+    nlsr.getFib().clean();
   }
   return EXIT_SUCCESS;
 }
diff --git a/src/name-prefix-list.cpp b/src/name-prefix-list.cpp
index 496a0e7..c8d9285 100644
--- a/src/name-prefix-list.cpp
+++ b/src/name-prefix-list.cpp
@@ -18,17 +18,18 @@
 }
 
 static bool
-nameCompare(const string& s1, const string& s2)
+nameCompare(const ndn::Name& name1, const ndn::Name& name2)
 {
-  return s1 == s2;
+  return name1 == name2;
 }
 
 int32_t
-NamePrefixList::insert(const string& name)
+NamePrefixList::insert(const ndn::Name& name)
 {
-  std::list<string>::iterator it = std::find_if(m_nameList.begin(),
-                                                m_nameList.end(),
-                                                ndn::bind(&nameCompare, _1 , name));
+  std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
+                                                   m_nameList.end(),
+                                                   ndn::bind(&nameCompare, _1 ,
+                                                             ndn::cref(name)));
   if (it != m_nameList.end())
   {
     return -1;
@@ -38,11 +39,12 @@
 }
 
 int32_t
-NamePrefixList::remove(const string& name)
+NamePrefixList::remove(const ndn::Name& name)
 {
-  std::list<string>::iterator it = std::find_if(m_nameList.begin(),
-                                                m_nameList.end(),
-                                                ndn::bind(&nameCompare, _1 , name));
+  std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
+                                                   m_nameList.end(),
+                                                   ndn::bind(&nameCompare, _1 ,
+                                                   ndn::cref(name)));
   if (it != m_nameList.end())
   {
     m_nameList.erase(it);
@@ -60,7 +62,7 @@
 NamePrefixList::print()
 {
   int i = 1;
-  for (std::list<string>::iterator it = m_nameList.begin();
+  for (std::list<ndn::Name>::iterator it = m_nameList.begin();
        it != m_nameList.end();
        it++)
   {
diff --git a/src/name-prefix-list.hpp b/src/name-prefix-list.hpp
index dda4508..7b7eba1 100644
--- a/src/name-prefix-list.hpp
+++ b/src/name-prefix-list.hpp
@@ -4,6 +4,7 @@
 #include <list>
 #include <string>
 #include <boost/cstdint.hpp>
+#include <ndn-cxx/name.hpp>
 
 
 namespace nlsr {
@@ -16,21 +17,21 @@
   ~NamePrefixList();
 
   int32_t
-  insert(const std::string& name);
+  insert(const ndn::Name& name);
 
   int32_t
-  remove(const std::string& name);
+  remove(const ndn::Name& name);
 
   void
   sort();
 
-  int32_t
+  size_t
   getSize()
   {
     return m_nameList.size();
   }
 
-  std::list<std::string>&
+  std::list<ndn::Name>&
   getNameList()
   {
     return m_nameList;
@@ -40,7 +41,7 @@
   print();
 
 private:
-  std::list<std::string> m_nameList;
+  std::list<ndn::Name> m_nameList;
 
 };
 
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 22e7dc8..91b4c25 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -20,11 +20,25 @@
 
 
 void
-Nlsr::setInterestFilter(const string& name)
+Nlsr::setInfoInterestFilter()
 {
+  ndn::Name name(m_confParam.getRouterPrefix());
   getNlsrFace().setInterestFilter(name,
-                                  ndn::bind(&InterestManager::processInterest,
-                                            &m_interestManager, _1, _2),
+                                  ndn::bind(&HelloProtocol::processInterest,
+                                            &m_helloProtocol, _1, _2),
+                                  ndn::bind(&Nlsr::registrationFailed, this, _1));
+}
+
+void
+Nlsr::setLsaInterestFilter()
+{
+  // ndn::Name name(m_confParam.getChronosyncLsaPrefix() +
+  //                m_confParam.getRouterPrefix());
+  ndn::Name name = m_confParam.getChronosyncLsaPrefix();
+  name.append(m_confParam.getRouterPrefix());
+  getNlsrFace().setInterestFilter(name,
+                                  ndn::bind(&Lsdb::processInterest,
+                                            &m_nlsrLsdb, _1, _2),
                                   ndn::bind(&Nlsr::registrationFailed, this, _1));
 }
 
@@ -33,12 +47,8 @@
 {
   m_confParam.buildRouterPrefix();
   m_nlsrLsdb.setLsaRefreshTime(m_confParam.getLsaRefreshTime());
-  m_nlsrLsdb.setThisRouterPrefix(m_confParam.getRouterPrefix());
+  m_nlsrLsdb.setThisRouterPrefix(m_confParam.getRouterPrefix().toUri());
   m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
-  // if (!m_km.initialize(m_confParam))
-  // {
-  //   std::cerr << "Can not initiate/load certificate" << endl;
-  // }
   m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
   m_sequencingManager.initiateSeqNoFromFile();
   /* debugging purpose start */
@@ -46,16 +56,14 @@
   m_adjacencyList.print();
   m_namePrefixList.print();
   /* debugging purpose end */
-  m_nlsrLsdb.buildAndInstallOwnNameLsa(boost::ref(*this));
-  m_nlsrLsdb.buildAndInstallOwnCoordinateLsa(boost::ref(*this));
-  setInterestFilter(m_confParam.getRouterPrefix());
-  setInterestFilter(m_confParam.getChronosyncLsaPrefix() +
-                    m_confParam.getRouterPrefix());
-  setInterestFilter(m_confParam.getRootKeyPrefix());
-  m_syncLogicHandler.setSyncPrefix(m_confParam.getChronosyncSyncPrefix());
+  m_nlsrLsdb.buildAndInstallOwnNameLsa();
+  m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
+  setInfoInterestFilter();
+  setLsaInterestFilter();
+  m_syncLogicHandler.setSyncPrefix(m_confParam.getChronosyncSyncPrefix().toUri());
   m_syncLogicHandler.createSyncSocket(boost::ref(*this));
-  // m_slh.publishKeyUpdate(m_km);
-  m_interestManager.scheduleInfoInterest(10);
+  //m_interestManager.scheduleInfoInterest(10);
+  m_helloProtocol.scheduleInterest(10);
 }
 
 void
diff --git a/src/nlsr.hpp b/src/nlsr.hpp
index 0e59adc..6bf45bd 100644
--- a/src/nlsr.hpp
+++ b/src/nlsr.hpp
@@ -11,15 +11,13 @@
 #include "conf-parameter.hpp"
 #include "adjacency-list.hpp"
 #include "name-prefix-list.hpp"
-#include "communication/interest-manager.hpp"
-#include "communication/data-manager.hpp"
 #include "lsdb.hpp"
 #include "sequencing-manager.hpp"
 #include "route/routing-table.hpp"
 #include "route/name-prefix-table.hpp"
 #include "route/fib.hpp"
-// #include "security/key-manager.hpp"
 #include "communication/sync-logic-handler.hpp"
+#include "hello-protocol.hpp"
 
 
 namespace nlsr {
@@ -42,28 +40,29 @@
     , m_confParam()
     , m_adjacencyList()
     , m_namePrefixList()
-    , m_interestManager(*this)
-    , m_dataManager(*this)
     , m_sequencingManager()
-    // , m_km()
     , m_isDaemonProcess(false)
     , m_configFileName("nlsr.conf")
-    , m_nlsrLsdb()
+    , m_nlsrLsdb(*this)
     , m_adjBuildCount(0)
     , m_isBuildAdjLsaSheduled(false)
     , m_isRouteCalculationScheduled(false)
     , m_isRoutingTableCalculating(false)
     , m_routingTable()
-    , m_namePrefixTable()
-    , m_fib(m_nlsrFace)
+    , m_fib(*this, m_nlsrFace)
+    , m_namePrefixTable(*this)
     , m_syncLogicHandler(m_nlsrFace.getIoService())
+    , m_helloProtocol(*this)
   {}
 
   void
   registrationFailed(const ndn::Name& name);
 
   void
-  setInterestFilter(const std::string& name);
+  setInfoInterestFilter();
+
+  void
+  setLsaInterestFilter();
 
   void
   startEventLoop();
@@ -125,25 +124,6 @@
     return m_nlsrFace;
   }
 
-  // KeyManager&
-  // getKeyManager()
-  // {
-  //   return m_km;
-  // }
-
-
-  InterestManager&
-  getInterestManager()
-  {
-    return m_interestManager;
-  }
-
-  DataManager&
-  getDataManager()
-  {
-    return m_dataManager;
-  }
-
   SequencingManager&
   getSequencingManager()
   {
@@ -256,10 +236,7 @@
   ConfParameter m_confParam;
   AdjacencyList m_adjacencyList;
   NamePrefixList m_namePrefixList;
-  InterestManager m_interestManager;
-  DataManager m_dataManager;
   SequencingManager m_sequencingManager;
-  // KeyManager m_km;
   bool m_isDaemonProcess;
   std::string m_configFileName;
   Lsdb m_nlsrLsdb;
@@ -268,10 +245,11 @@
   bool m_isRouteCalculationScheduled;
   bool m_isRoutingTableCalculating;
   RoutingTable m_routingTable;
-  NamePrefixTable m_namePrefixTable;
   Fib m_fib;
+  NamePrefixTable m_namePrefixTable;
   SyncLogicHandler m_syncLogicHandler;
   int32_t m_apiPort;
+  HelloProtocol m_helloProtocol;
 };
 
 } //namespace nlsr
diff --git a/src/route/fib-entry.hpp b/src/route/fib-entry.hpp
index 88de53e..71ecb04 100644
--- a/src/route/fib-entry.hpp
+++ b/src/route/fib-entry.hpp
@@ -23,7 +23,7 @@
   {
   }
 
-  FibEntry(const std::string& name)
+  FibEntry(const ndn::Name& name)
     : m_timeToRefresh(0)
     , m_seqNo(0)
     , m_nexthopList()
@@ -31,7 +31,7 @@
     m_name = name;
   }
 
-  const std::string&
+  const ndn::Name&
   getName() const
   {
     return m_name;
@@ -83,7 +83,7 @@
   isEqualNextHops(NexthopList& nhlOther);
 
 private:
-  std::string m_name;
+  ndn::Name m_name;
   int32_t m_timeToRefresh;
   ndn::EventId m_expiringEventId;
   int32_t m_seqNo;
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 1272ab1..fc823c1 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -14,32 +14,31 @@
 using namespace ndn;
 
 static bool
-fibEntryNameCompare(const FibEntry& fibEntry, const string& name)
+fibEntryNameCompare(const FibEntry& fibEntry, const ndn::Name& name)
 {
   return fibEntry.getName() == name ;
 }
 
 void
-Fib::cancelScheduledExpiringEvent(Nlsr& pnlsr, EventId eid)
+Fib::cancelScheduledExpiringEvent(EventId eid)
 {
-  pnlsr.getScheduler().cancelEvent(eid);
+  m_nlsr.getScheduler().cancelEvent(eid);
 }
 
 
 ndn::EventId
-Fib::scheduleEntryRefreshing(Nlsr& pnlsr, const string& name, int32_t feSeqNum,
+Fib::scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
                              int32_t refreshTime)
 {
   std::cout << "Fib::scheduleEntryRefreshing Called" << std::endl;
   std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
-  return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
-                                            ndn::bind(&Fib::refreshEntry, this,
-                                                      boost::ref(pnlsr), 
-                                                      name, feSeqNum));
+  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
+                                             ndn::bind(&Fib::refreshEntry, this,
+                                                       name, feSeqNum));
 }
 
 void
-Fib::refreshEntry(Nlsr& nlsr, const string& name, int32_t feSeqNum)
+Fib::refreshEntry(const ndn::Name& name, int32_t feSeqNum)
 {
   std::cout << "Fib::refreshEntry Called" << std::endl;
   std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
@@ -53,26 +52,24 @@
     {
       std::cout << "Refreshing the FIB entry" << std::endl;
       for (std::list<NextHop>::iterator nhit =
-           (*it).getNexthopList().getNextHops().begin();
-         nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
+             (*it).getNexthopList().getNextHops().begin();
+           nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
       {
         // add entry to NDN-FIB
-        registerPrefixInNfd(it->getName(), nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+        registerPrefixInNfd(it->getName(), nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
       }
-      
       // increase sequence number and schedule refresh again
       it->setSeqNo(feSeqNum + 1);
-      it->setExpiringEventId(scheduleEntryRefreshing(nlsr,
-                                                     it->getName() ,
-                                                     it->getSeqNo(), 
+      it->setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
+                                                     it->getSeqNo(),
                                                      m_refreshTime));
-      
     }
   }
 }
 
 void
-Fib::remove(Nlsr& pnlsr, const std::string& name)
+Fib::remove(const ndn::Name& name)
 {
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
@@ -84,14 +81,14 @@
          nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
     {
       //remove entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(it->getName()))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
       {
         unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() != 
-           nhit->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
+            nhit->getConnectingFace())
         {
           unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
         }
@@ -99,19 +96,19 @@
     }
     std::cout << "Cancellling Scheduled event" << std::endl;
     std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
-    cancelScheduledExpiringEvent(pnlsr, (*it).getExpiringEventId());
+    cancelScheduledExpiringEvent((*it).getExpiringEventId());
     m_table.erase(it);
   }
 }
 
 
 void
-Fib::update(Nlsr& pnlsr, const string& name, NexthopList& nextHopList)
+Fib::update(const ndn::Name& name, NexthopList& nextHopList)
 {
   std::cout << "Fib::updateFib Called" << std::endl;
   int startFace = 0;
   int endFace = getNumberOfFacesForName(nextHopList,
-                                        pnlsr.getConfParameter().getMaxFacesPerPrefix());
+                                        m_nlsr.getConfParameter().getMaxFacesPerPrefix());
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
                                                   bind(&fibEntryNameCompare, _1, name));
@@ -127,13 +124,13 @@
       {
         newEntry.getNexthopList().addNextHop((*nhit));
         //Add entry to NDN-FIB
-        registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+        registerPrefixInNfd(name, nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
       }
       newEntry.getNexthopList().sort();
       newEntry.setTimeToRefresh(m_refreshTime);
       newEntry.setSeqNo(1);
-      newEntry.setExpiringEventId(scheduleEntryRefreshing(pnlsr,
-                                                          name , 1, m_refreshTime));
+      newEntry.setExpiringEventId(scheduleEntryRefreshing(name , 1, m_refreshTime));
       m_table.push_back(newEntry);
     }
   }
@@ -148,8 +145,9 @@
         std::list<NextHop> nhl = nextHopList.getNextHops();
         std::list<NextHop>::iterator nhit = nhl.begin();
         // Add first Entry to NDN-FIB
-        registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
-        removeHop(pnlsr, it->getNexthopList(), nhit->getConnectingFace(), name);
+        registerPrefixInNfd(name, nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
+        removeHop(it->getNexthopList(), nhit->getConnectingFace(), name);
         it->getNexthopList().reset();
         it->getNexthopList().addNextHop((*nhit));
         ++startFace;
@@ -158,21 +156,21 @@
         {
           it->getNexthopList().addNextHop((*nhit));
           //Add Entry to NDN_FIB
-          registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+          registerPrefixInNfd(name, nhit->getConnectingFace(),
+                              std::ceil(nhit->getRouteCost()));
         }
       }
       it->setTimeToRefresh(m_refreshTime);
       std::cout << "Cancellling Scheduled event" << std::endl;
       std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
-      cancelScheduledExpiringEvent(pnlsr, it->getExpiringEventId());
+      cancelScheduledExpiringEvent(it->getExpiringEventId());
       it->setSeqNo(it->getSeqNo() + 1);
-      (*it).setExpiringEventId(scheduleEntryRefreshing(pnlsr,
-                                                       it->getName() ,
+      (*it).setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
                                                        it->getSeqNo(), m_refreshTime));
     }
     else
     {
-      remove(pnlsr, name);
+      remove(name);
     }
   }
 }
@@ -180,27 +178,28 @@
 
 
 void
-Fib::clean(Nlsr& pnlsr)
+Fib::clean()
 {
   for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
        ++it)
   {
     std::cout << "Cancellling Scheduled event" << std::endl;
-    std::cout << "Name: " << it->getName() << "Seq num: " << it->getSeqNo() << std::endl;
-    cancelScheduledExpiringEvent(pnlsr, (*it).getExpiringEventId());
+    std::cout << "Name: " << it->getName() << "Seq num: " << it->getSeqNo() <<
+              std::endl;
+    cancelScheduledExpiringEvent((*it).getExpiringEventId());
     for (std::list<NextHop>::iterator nhit =
            (*it).getNexthopList().getNextHops().begin();
          nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
     {
       //Remove entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(it->getName()))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
       {
         unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() != 
-           nhit->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
+            nhit->getConnectingFace())
         {
           unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
         }
@@ -214,7 +213,8 @@
 }
 
 int
-Fib::getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix)
+Fib::getNumberOfFacesForName(NexthopList& nextHopList,
+                             uint32_t maxFacesPerPrefix)
 {
   int endFace = 0;
   if ((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix))
@@ -229,8 +229,8 @@
 }
 
 void
-Fib::removeHop(Nlsr& pnlsr, NexthopList& nl, uint32_t doNotRemoveHopFaceId,
-               const std::string& name)
+Fib::removeHop(NexthopList& nl, uint32_t doNotRemoveHopFaceId,
+               const ndn::Name& name)
 {
   for (std::list<NextHop>::iterator it = nl.getNextHops().begin();
        it != nl.getNextHops().end();   ++it)
@@ -238,14 +238,14 @@
     if (it->getConnectingFace() != doNotRemoveHopFaceId)
     {
       //Remove FIB Entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(name))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(name))
       {
         unregisterPrefixFromNfd(name, it->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(name).getConnectingFace() != 
-           it->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(name).getConnectingFace() !=
+            it->getConnectingFace())
         {
           unregisterPrefixFromNfd(name, it->getConnectingFace());
         }
@@ -255,32 +255,31 @@
 }
 
 void
-Fib::registerPrefixInNfd(const std::string& namePrefix, uint64_t faceId, uint64_t faceCost)
+Fib::registerPrefixInNfd(const ndn::Name& namePrefix, uint64_t faceId,
+                         uint64_t faceCost)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
-    .setName(namePrefix)
-    .setCost(faceCost)
-    .setFaceId(faceId)
-    .setExpirationPeriod(ndn::time::milliseconds(m_refreshTime*1000))
-    .setOrigin(128);
-
+  .setName(namePrefix)
+  .setCost(faceCost)
+  .setFaceId(faceId)
+  .setExpirationPeriod(ndn::time::milliseconds(m_refreshTime * 1000))
+  .setOrigin(128);
   m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
                                                    ndn::bind(&Fib::onSuccess, this, _1,
                                                              "Successful in name registration"),
                                                    ndn::bind(&Fib::onFailure, this, _1, _2,
                                                              "Failed in name registration"));
 }
-  
+
 void
-Fib::unregisterPrefixFromNfd(const std::string& namePrefix, uint64_t faceId)
+Fib::unregisterPrefixFromNfd(const ndn::Name& namePrefix, uint64_t faceId)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
-    .setName(namePrefix)
-    .setFaceId(faceId)
-    .setOrigin(128);
-
+  .setName(namePrefix)
+  .setFaceId(faceId)
+  .setOrigin(128);
   m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
                                                      ndn::bind(&Fib::onSuccess, this, _1,
                                                                "Successful in unregistering name"),
@@ -289,13 +288,15 @@
 }
 
 void
-Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, const std::string& message)
+Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
+               const std::string& message)
 {
   std::cout << message << ": " << commandSuccessResult << std::endl;
 }
 
 void
-Fib::onFailure(uint32_t code, const std::string& error, const std::string& message)
+Fib::onFailure(uint32_t code, const std::string& error,
+               const std::string& message)
 {
   std::cout << message << ": " << error << " (code: " << code << ")";
 }
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index 2a90fc1..0f58351 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -16,8 +16,9 @@
 class Fib
 {
 public:
-  Fib(ndn::Face& face)
-    : m_table()
+  Fib(Nlsr& nlsr, ndn::Face& face)
+    : m_nlsr(nlsr)
+    , m_table()
     , m_refreshTime(0)
     , m_controller(face)
   {
@@ -27,13 +28,13 @@
   }
 
   void
-  remove(Nlsr& pnlsr, const std::string& name);
+  remove(const ndn::Name& name);
 
   void
-  update(Nlsr& pnlsr, const std::string& name, NexthopList& nextHopList);
+  update(const ndn::Name& name, NexthopList& nextHopList);
 
   void
-  clean(Nlsr& pnlsr);
+  clean();
 
   void
   setEntryRefreshTime(int32_t fert)
@@ -46,35 +47,38 @@
 
 private:
   void
-  removeHop(Nlsr& pnlsr, NexthopList& nl, uint32_t doNotRemoveHopFaceId,
-            const std::string& name);
+  removeHop(NexthopList& nl, uint32_t doNotRemoveHopFaceId,
+            const ndn::Name& name);
 
   int
   getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix);
 
   ndn::EventId
-  scheduleEntryRefreshing(Nlsr& pnlsr, const std::string& name, int32_t feSeqNum,
+  scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
                           int32_t refreshTime);
 
   void
-  cancelScheduledExpiringEvent(Nlsr& pnlsr, ndn::EventId eid);
+  cancelScheduledExpiringEvent(ndn::EventId eid);
 
   void
-  refreshEntry(Nlsr& nlsr, const std::string& name, int32_t feSeqNum);
+  refreshEntry(const ndn::Name& name, int32_t feSeqNum);
 
   void
-  registerPrefixInNfd(const std::string& namePrefix, uint64_t faceId, uint64_t faceCost);
+  registerPrefixInNfd(const ndn::Name& namePrefix, uint64_t faceId,
+                      uint64_t faceCost);
 
   void
-  unregisterPrefixFromNfd(const std::string& namePrefix, uint64_t faceId);
-  
+  unregisterPrefixFromNfd(const ndn::Name& namePrefix, uint64_t faceId);
+
   void
-  onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, const std::string& message);
+  onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
+            const std::string& message);
 
   void
   onFailure(uint32_t code, const std::string& error, const std::string& message);
 
 private:
+  Nlsr& m_nlsr;
   std::list<FibEntry> m_table;
   int32_t m_refreshTime;
   ndn::nfd::Controller m_controller;
diff --git a/src/route/map-entry.hpp b/src/route/map-entry.hpp
index 9174345..0c54145 100644
--- a/src/route/map-entry.hpp
+++ b/src/route/map-entry.hpp
@@ -2,8 +2,9 @@
 #define NLSR_MAP_ENTRY_HPP
 
 #include <boost/cstdint.hpp>
+#include <ndn-cxx/name.hpp>
 
-namespace nlsr{
+namespace nlsr {
 
 class MapEntry
 {
@@ -18,13 +19,13 @@
   {
   }
 
-  MapEntry(const std::string& rtr, int32_t mn)
+  MapEntry(const ndn::Name& rtr, int32_t mn)
   {
     m_router = rtr;
     m_mappingNumber = mn;
   }
 
-  const std::string&
+  const ndn::Name&
   getRouter() const
   {
     return m_router;
@@ -37,7 +38,7 @@
   }
 
 private:
-  std::string m_router;
+  ndn::Name m_router;
   int32_t m_mappingNumber;
 };
 
diff --git a/src/route/map.cpp b/src/route/map.cpp
index 4701a05..07310e7 100644
--- a/src/route/map.cpp
+++ b/src/route/map.cpp
@@ -12,7 +12,7 @@
 using namespace std;
 
 static bool
-mapEntryCompareByRouter(MapEntry& mpe1, const string& rtrName)
+mapEntryCompareByRouter(MapEntry& mpe1, const ndn::Name& rtrName)
 {
   return mpe1.getRouter() == rtrName;
 }
@@ -24,7 +24,7 @@
 }
 
 void
-Map::addEntry(const string& rtrName)
+Map::addEntry(const ndn::Name& rtrName)
 {
   MapEntry me(rtrName, m_mappingIndex);
   if (addEntry(me))
@@ -48,7 +48,7 @@
   return false;
 }
 
-string
+const ndn::Name
 Map::getRouterNameByMappingNo(int32_t mn)
 {
   std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
@@ -59,11 +59,11 @@
   {
     return (*it).getRouter();
   }
-  return "";
+  return ndn::Name();
 }
 
 int32_t
-Map::getMappingNoByRouterName(string& rName)
+Map::getMappingNoByRouterName(const ndn::Name& rName)
 {
   std::list<MapEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
@@ -83,14 +83,14 @@
   for (std::list<AdjLsa>::iterator it = adjLsdb.begin();
        it != adjLsdb.end() ; it++)
   {
-    string linkStartRouter = (*it).getOrigRouter();
-    addEntry(linkStartRouter);
+    //ndn::Name& linkStartRouter = (*it).getOrigRouter();
+    addEntry((*it).getOrigRouter());
     std::list<Adjacent> adl = (*it).getAdl().getAdjList();
     for (std::list<Adjacent>::iterator itAdl = adl.begin();
          itAdl != adl.end() ; itAdl++)
     {
-      string linkEndRouter = (*itAdl).getName();
-      addEntry(linkEndRouter);
+      //ndn::Name& linkEndRouter = (*itAdl).getName();
+      addEntry((*itAdl).getName());
     }
   }
 }
diff --git a/src/route/map.hpp b/src/route/map.hpp
index cc08771..1c8da32 100644
--- a/src/route/map.hpp
+++ b/src/route/map.hpp
@@ -23,16 +23,16 @@
 
 
   void
-  addEntry(const std::string& rtrName);
+  addEntry(const ndn::Name& rtrName);
 
   void
   createFromAdjLsdb(Nlsr& pnlsr);
 
-  std::string
+  const ndn::Name
   getRouterNameByMappingNo(int32_t mn);
 
   int32_t
-  getMappingNoByRouterName(std::string& rName);
+  getMappingNoByRouterName(const ndn::Name& rName);
 
   void
   reset();
@@ -43,7 +43,7 @@
     return m_table;
   }
 
-  int
+  size_t
   getMapSize() const
   {
     return m_table.size();
diff --git a/src/route/name-prefix-table-entry.cpp b/src/route/name-prefix-table-entry.cpp
index 01eea0d..0ca9bcb 100644
--- a/src/route/name-prefix-table-entry.cpp
+++ b/src/route/name-prefix-table-entry.cpp
@@ -27,7 +27,7 @@
 
 
 static bool
-rteCompare(RoutingTableEntry& rte, string& destRouter)
+rteCompare(RoutingTableEntry& rte, ndn::Name& destRouter)
 {
   return rte.getDestination() == destRouter;
 }
@@ -57,7 +57,8 @@
   else
   {
     (*it).getNexthopList().reset(); // reseting existing routing table's next hop
-    for (std::list<NextHop>::iterator nhit = rte.getNexthopList().getNextHops().begin();
+    for (std::list<NextHop>::iterator nhit =
+           rte.getNexthopList().getNextHops().begin();
          nhit != rte.getNexthopList().getNextHops().end(); ++nhit)
     {
       (*it).getNexthopList().addNextHop((*nhit));
diff --git a/src/route/name-prefix-table-entry.hpp b/src/route/name-prefix-table-entry.hpp
index 0ee28fa..ab507d7 100644
--- a/src/route/name-prefix-table-entry.hpp
+++ b/src/route/name-prefix-table-entry.hpp
@@ -16,13 +16,13 @@
   {
   }
 
-  NamePrefixTableEntry(const std::string& namePrefix)
-    : m_nexthopList()
+  NamePrefixTableEntry(const ndn::Name& namePrefix)
+    : m_namePrefix(namePrefix)
+    , m_nexthopList()
   {
-    m_namePrefix = namePrefix;
   }
 
-  const std::string&
+  const ndn::Name&
   getNamePrefix() const
   {
     return m_namePrefix;
@@ -69,7 +69,7 @@
   addRoutingTableEntry(RoutingTableEntry& rte);
 
 private:
-  std::string m_namePrefix;
+  ndn::Name m_namePrefix;
   std::list<RoutingTableEntry> m_rteList;
   NexthopList m_nexthopList;
 };
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index e6a7ccf..f791d0a 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -5,6 +5,7 @@
 #include "nlsr.hpp"
 #include "name-prefix-table.hpp"
 #include "name-prefix-table-entry.hpp"
+#include "routing-table.hpp"
 
 
 
@@ -13,7 +14,7 @@
 using namespace std;
 
 static bool
-npteCompare(NamePrefixTableEntry& npte, const string& name)
+npteCompare(NamePrefixTableEntry& npte, const ndn::Name& name)
 {
   return npte.getNamePrefix() == name;
 }
@@ -21,7 +22,7 @@
 
 
 void
-NamePrefixTable::addEntry(const string& name, RoutingTableEntry& rte, Nlsr& pnlsr)
+NamePrefixTable::addEntry(const ndn::Name& name, RoutingTableEntry& rte)
 {
   std::list<NamePrefixTableEntry>::iterator it = std::find_if(m_table.begin(),
                                                               m_table.end(), bind(&npteCompare, _1, name));
@@ -34,7 +35,7 @@
     m_table.push_back(newEntry);
     if (rte.getNexthopList().getSize() > 0)
     {
-      pnlsr.getFib().update(pnlsr, name, newEntry.getNexthopList());
+      m_nlsr.getFib().update(name, newEntry.getNexthopList());
     }
   }
   else
@@ -44,77 +45,82 @@
       (*it).addRoutingTableEntry(rte);
       (*it).generateNhlfromRteList();
       (*it).getNexthopList().sort();
-      pnlsr.getFib().update(pnlsr, name, (*it).getNexthopList());
+      m_nlsr.getFib().update(name, (*it).getNexthopList());
     }
     else
     {
       (*it).resetRteListNextHop();
       (*it).getNexthopList().reset();
-      pnlsr.getFib().remove(pnlsr, name);
+      m_nlsr.getFib().remove(name);
     }
   }
 }
 
 void
-NamePrefixTable::removeEntry(const string& name, RoutingTableEntry& rte, Nlsr& pnlsr)
+NamePrefixTable::removeEntry(const ndn::Name& name, RoutingTableEntry& rte)
 {
   std::list<NamePrefixTableEntry>::iterator it = std::find_if(m_table.begin(),
                                                               m_table.end(), bind(&npteCompare, _1, name));
   if (it != m_table.end())
   {
-    string destRouter = rte.getDestination();
+    ndn::Name 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)))
+        (!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/name"),
+                                        std::string("name"))) &&
+        (!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/adjacency"),
+                                        std::string("adjacency"))) &&
+        (!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/coordinate"),
+                                        std::string("coordinate"))))
     {
       m_table.erase(it);
-      pnlsr.getFib().remove(pnlsr, name);
+      m_nlsr.getFib().remove(name);
     }
     else
     {
       (*it).generateNhlfromRteList();
-      pnlsr.getFib().update(pnlsr, name, (*it).getNexthopList());
+      m_nlsr.getFib().update(name, (*it).getNexthopList());
     }
   }
 }
 
 
 void
-NamePrefixTable::addEntry(const string& name, const string& destRouter, Nlsr& pnlsr)
+NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
 {
+  //
   RoutingTableEntry* rteCheck =
-    pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
+    m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
   if (rteCheck != 0)
   {
-    addEntry(name, *(rteCheck) , pnlsr);
+    addEntry(name, *(rteCheck));
   }
   else
   {
     RoutingTableEntry rte(destRouter);
-    addEntry(name, rte, pnlsr);
+    addEntry(name, rte);
   }
 }
 
 void
-NamePrefixTable::removeEntry(const string& name, const string& destRouter, Nlsr& pnlsr)
+NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
 {
+  //
   RoutingTableEntry* rteCheck =
-    pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
+    m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
   if (rteCheck != 0)
   {
-    removeEntry(name, *(rteCheck), pnlsr);
+    removeEntry(name, *(rteCheck));
   }
   else
   {
     RoutingTableEntry rte(destRouter);
-    removeEntry(name, rte, pnlsr);
+    removeEntry(name, rte);
   }
 }
 
 void
-NamePrefixTable::updateWithNewRoute(Nlsr& pnlsr)
+NamePrefixTable::updateWithNewRoute()
 {
   for (std::list<NamePrefixTableEntry>::iterator it = m_table.begin();
        it != m_table.end(); ++it)
@@ -124,15 +130,15 @@
          rteit != rteList.end(); ++rteit)
     {
       RoutingTableEntry* rteCheck =
-        pnlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
+        m_nlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
       if (rteCheck != 0)
       {
-        addEntry((*it).getNamePrefix(), *(rteCheck), pnlsr);
+        addEntry((*it).getNamePrefix(), *(rteCheck));
       }
       else
       {
         RoutingTableEntry rte((*rteit).getDestination());
-        addEntry((*it).getNamePrefix(), rte, pnlsr);
+        addEntry((*it).getNamePrefix(), rte);
       }
     }
   }
diff --git a/src/route/name-prefix-table.hpp b/src/route/name-prefix-table.hpp
index 4f7fbb4..b872161 100644
--- a/src/route/name-prefix-table.hpp
+++ b/src/route/name-prefix-table.hpp
@@ -13,30 +13,32 @@
 class NamePrefixTable
 {
 public:
-  NamePrefixTable()
+  NamePrefixTable(Nlsr& nlsr)
+    : m_nlsr(nlsr)
   {
   }
 
   void
-  addEntry(const std::string& name, const std::string& destRouter, Nlsr& pnlsr);
+  addEntry(const ndn::Name& name, const ndn::Name& destRouter);
 
   void
-  removeEntry(const std::string& name, const std::string& destRouter, Nlsr& pnlsr);
+  removeEntry(const ndn::Name& name, const ndn::Name& destRouter);
 
   void
-  updateWithNewRoute(Nlsr& pnlsr);
+  updateWithNewRoute();
 
   void
   print();
 
 private:
   void
-  addEntry(const std::string& name, RoutingTableEntry& rte, Nlsr& pnlsr);
+  addEntry(const ndn::Name& name, RoutingTableEntry& rte);
 
   void
-  removeEntry(const std::string& name, RoutingTableEntry& rte, Nlsr& pnlsr);
+  removeEntry(const ndn::Name& name, RoutingTableEntry& rte);
 
 private:
+  Nlsr& m_nlsr;
   std::list<NamePrefixTableEntry> m_table;
 };
 
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 7ec8a23..33a703d 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -38,14 +38,12 @@
   for (std::list<AdjLsa>::iterator it = adjLsdb.begin();
        it != adjLsdb.end() ; it++)
   {
-    string linkStartRouter = (*it).getOrigRouter();
-    int row = pMap.getMappingNoByRouterName(linkStartRouter);
+    int row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
     std::list<Adjacent> adl = (*it).getAdl().getAdjList();
     for (std::list<Adjacent>::iterator itAdl = adl.begin();
          itAdl != adl.end() ; itAdl++)
     {
-      string linkEndRouter = (*itAdl).getName();
-      int col = pMap.getMappingNoByRouterName(linkEndRouter);
+      int col = pMap.getMappingNoByRouterName((*itAdl).getName());
       double cost = (*itAdl).getLinkCost();
       if ((row >= 0 && row < numOfRouter) && (col >= 0 && col < numOfRouter))
       {
@@ -158,8 +156,7 @@
   makeAdjMatrix(pnlsr, pMap);
   std::cout << pMap;
   printAdjMatrix();
-  string routerName = pnlsr.getConfParameter().getRouterPrefix();
-  int sourceRouter = pMap.getMappingNoByRouterName(routerName);
+  int sourceRouter = pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix());
   //int noLink=getNumOfLinkfromAdjMatrix(sourceRouter);
   allocateParent();
   allocateDistance();
@@ -259,8 +256,7 @@
       if (nextHopRouter != NO_NEXT_HOP)
       {
         double routeCost = m_distance[i];
-        string nextHopRouterName =
-          pMap.getRouterNameByMappingNo(nextHopRouter);
+        ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
         int nxtHopFace =
           pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFace();
         std::cout << "Dest Router: " << pMap.getRouterNameByMappingNo(i) << std::endl;
@@ -382,7 +378,7 @@
                                          RoutingTable& rt, Nlsr& pnlsr)
 {
   makeAdjMatrix(pnlsr, pMap);
-  string routerName = pnlsr.getConfParameter().getRouterPrefix();
+  ndn::Name routerName = pnlsr.getConfParameter().getRouterPrefix();
   int sourceRouter = pMap.getMappingNoByRouterName(routerName);
   int noLink = getNumOfLinkfromAdjMatrix(sourceRouter);
   setNoLink(noLink);
@@ -399,7 +395,7 @@
       allocateDistFromNbrToDest();
       for (int j = 0; j < vNoLink; j++)
       {
-        string nextHopRouterName = pMap.getRouterNameByMappingNo(links[j]);
+        ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(links[j]);
         int nextHopFace =
           pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFace();
         double distToNbr = getHyperbolicDistance(pnlsr, pMap,
@@ -431,7 +427,7 @@
 {
   for (int i = 0 ; i < noFaces ; ++i)
   {
-    string destRouter = pMap.getRouterNameByMappingNo(dest);
+    ndn::Name destRouter = pMap.getRouterNameByMappingNo(dest);
     NextHop nh(m_linkFaces[i], m_distFromNbrToDest[i]);
     rt.addNextHop(destRouter, nh);
     if (m_isDryRun)
@@ -446,8 +442,10 @@
                                                  Map& pMap, int src, int dest)
 {
   double distance = 0.0;
-  string srcRouterKey = pMap.getRouterNameByMappingNo(src) + "/3";
-  string destRouterKey = pMap.getRouterNameByMappingNo(dest) + "/3";
+  ndn::Name srcRouterKey = pMap.getRouterNameByMappingNo(src);
+  srcRouterKey.append("coordinate");
+  ndn::Name destRouterKey = pMap.getRouterNameByMappingNo(dest);
+  destRouterKey.append("coordinate");
   double srcRadius = (pnlsr.getLsdb().findCoordinateLsa(
                         srcRouterKey))->getCorRadius();
   double srcTheta = (pnlsr.getLsdb().findCoordinateLsa(
diff --git a/src/route/routing-table-entry.hpp b/src/route/routing-table-entry.hpp
index 0d0b662..fbba243 100644
--- a/src/route/routing-table-entry.hpp
+++ b/src/route/routing-table-entry.hpp
@@ -2,7 +2,7 @@
 #define NLSR_ROUTING_TABLE_ENTRY_HPP
 
 #include <iostream>
-
+#include <ndn-cxx/name.hpp>
 #include "nexthop-list.hpp"
 
 namespace nlsr {
@@ -18,13 +18,13 @@
   {
   }
 
-  RoutingTableEntry(const std::string& dest)
+  RoutingTableEntry(const ndn::Name& dest)
   {
     m_destination = dest;
   }
 
-  std::string
-  getDestination()
+  const ndn::Name&
+  getDestination() const
   {
     return m_destination;
   }
@@ -36,7 +36,7 @@
   }
 
 private:
-  std::string m_destination;
+  ndn::Name m_destination;
   NexthopList m_nexthopList;
 };
 
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index bb7d3fa..7664b89 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -17,7 +17,6 @@
 RoutingTable::calculate(Nlsr& pnlsr)
 {
   //debugging purpose
-  std::cout << pnlsr.getConfParameter() << std::endl;
   pnlsr.getNamePrefixTable().print();
   pnlsr.getLsdb().printAdjLsdb();
   pnlsr.getLsdb().printCorLsdb();
@@ -26,7 +25,8 @@
   {
     pnlsr.setIsRoutingTableCalculating(1); //setting routing table calculation
     if (pnlsr.getLsdb().doesLsaExist(
-          pnlsr.getConfParameter().getRouterPrefix() + "/" + "2", 2))
+          pnlsr.getConfParameter().getRouterPrefix().toUri() + "/" + "adjacency",
+          std::string("adjacency")))
     {
       if (pnlsr.getIsBuildAdjLsaSheduled() != 1)
       {
@@ -50,7 +50,7 @@
           calculateHypDryRoutingTable(pnlsr);
         }
         //need to update NPT here
-        pnlsr.getNamePrefixTable().updateWithNewRoute(pnlsr);
+        pnlsr.getNamePrefixTable().updateWithNewRoute();
         //debugging purpose
         printRoutingTable();
         pnlsr.getNamePrefixTable().print();
@@ -71,7 +71,7 @@
       clearDryRoutingTable(); // for dry run options
       // need to update NPT here
       std::cout << "Calling Update NPT With new Route" << std::endl;
-      pnlsr.getNamePrefixTable().updateWithNewRoute(pnlsr);
+      pnlsr.getNamePrefixTable().updateWithNewRoute();
       //debugging purpose
       printRoutingTable();
       pnlsr.getNamePrefixTable().print();
@@ -131,14 +131,14 @@
 }
 
 static bool
-routingTableEntryCompare(RoutingTableEntry& rte, string& destRouter)
+routingTableEntryCompare(RoutingTableEntry& rte, ndn::Name& destRouter)
 {
   return rte.getDestination() == destRouter;
 }
 
 // function related to manipulation of routing table
 void
-RoutingTable::addNextHop(string destRouter, NextHop& nh)
+RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh)
 {
   RoutingTableEntry* rteChk = findRoutingTableEntry(destRouter);
   if (rteChk == 0)
@@ -154,7 +154,7 @@
 }
 
 RoutingTableEntry*
-RoutingTable::findRoutingTableEntry(const string destRouter)
+RoutingTable::findRoutingTableEntry(const ndn::Name& destRouter)
 {
   std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
                                                            m_rTable.end(),
@@ -180,7 +180,7 @@
 
 //function related to manipulation of dry routing table
 void
-RoutingTable::addNextHopToDryTable(string destRouter, NextHop& nh)
+RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
 {
   std::list<RoutingTableEntry>::iterator it = std::find_if(m_dryTable.begin(),
                                                            m_dryTable.end(),
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index 35f563e..983596b 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -24,19 +24,19 @@
   calculate(Nlsr& pnlsr);
 
   void
-  addNextHop(std::string destRouter, NextHop& nh);
+  addNextHop(const ndn::Name& destRouter, NextHop& nh);
 
   void
   printRoutingTable();
 
   void
-  addNextHopToDryTable(std::string destRouter, NextHop& nh);
+  addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
 
   void
   printDryRoutingTable();
 
   RoutingTableEntry*
-  findRoutingTableEntry(const std::string destRouter);
+  findRoutingTableEntry(const ndn::Name& destRouter);
 
   void
   scheduleRoutingTableCalculation(Nlsr& pnlsr);
diff --git a/src/utility/name-helper.hpp b/src/utility/name-helper.hpp
new file mode 100644
index 0000000..5a01a1a
--- /dev/null
+++ b/src/utility/name-helper.hpp
@@ -0,0 +1,37 @@
+#ifndef NLSR_NAME_HELPER_HPP
+#define NLSR_NAME_HELPER_HPP
+
+#include <boost/cstdint.hpp>
+#include <ndn-cxx/name-component.hpp>
+#include <ndn-cxx/name.hpp>
+
+namespace nlsr {
+namespace util {
+/**
+ * @brief search a name component in ndn::Name and return the position of the component
+ * @param name where to search the searchString
+ * @param searchString, the string to search in name
+ * @retrun int32_t -1 if searchString not found else return the position
+ * starting from 0
+ */
+
+inline static int32_t
+getNameComponentPosition(const ndn::Name& name, const std::string& searchString)
+{
+  ndn::name::Component component(searchString);
+  size_t nameSize = name.size();
+  for (uint32_t i = 0; i < nameSize; i++)
+  {
+    if (component == name[i])
+    {
+      return (int32_t)i;
+    }
+  }
+  return -1;
+}
+
+} //namespace util
+
+} // namespace nlsr
+
+#endif //NLSR_NAME_HELPER_HPP
