NLSR - (Hello Protocol + FIB Update)
diff --git a/src/route/nlsr_rt.cpp b/src/route/nlsr_rt.cpp
index cc60650..2cd9b28 100644
--- a/src/route/nlsr_rt.cpp
+++ b/src/route/nlsr_rt.cpp
@@ -12,221 +12,222 @@
 namespace nlsr
 {
 
-    using namespace std;
+  using namespace std;
 
-    void
-    RoutingTable::calculate(Nlsr& pnlsr)
+  void
+  RoutingTable::calculate(Nlsr& pnlsr)
+  {
+    //debugging purpose
+    std::cout<<pnlsr.getConfParameter()<<std::endl;
+    pnlsr.getNpt().printNpt();
+    pnlsr.getLsdb().printAdjLsdb();
+    pnlsr.getLsdb().printCorLsdb();
+    pnlsr.getLsdb().printNameLsdb();
+    if ( 	pnlsr.getIsRoutingTableCalculating() == 0 )
     {
-        //debugging purpose
-        pnlsr.getNpt().printNpt();
-        pnlsr.getLsdb().printAdjLsdb();
-        pnlsr.getLsdb().printCorLsdb();
-        pnlsr.getLsdb().printNameLsdb();
-        if ( 	pnlsr.getIsRoutingTableCalculating() == 0 )
+      pnlsr.setIsRoutingTableCalculating(1); //setting routing table calculation
+      if ( pnlsr.getLsdb().doesLsaExist(
+             pnlsr.getConfParameter().getRouterPrefix()+"/"+"2",2) )
+      {
+        if(pnlsr.getIsBuildAdjLsaSheduled() != 1)
         {
-            pnlsr.setIsRoutingTableCalculating(1); //setting routing table calculation
-            if ( pnlsr.getLsdb().doesLsaExist(
-                        pnlsr.getConfParameter().getRouterPrefix()+"/"+"2",2) )
-            {
-                if(pnlsr.getIsBuildAdjLsaSheduled() != 1)
-                {
-                    cout<<"CLearing old routing table ....."<<endl;
-                    clearRoutingTable();
-                    clearDryRoutingTable(); // for dry run options
-                    // calculate Link State routing
-                    if( (pnlsr.getConfParameter().getIsHyperbolicCalc() == 0 )
-                            || (pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 ) )
-                    {
-                        calculateLsRoutingTable(pnlsr);
-                    }
-                    //calculate hyperbolic routing
-                    if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 1 )
-                    {
-                        calculateHypRoutingTable(pnlsr);
-                    }
-                    //calculate dry hyperbolic routing
-                    if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 )
-                    {
-                        calculateHypDryRoutingTable(pnlsr);
-                    }
-                    //need to update NPT here
-                    pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
-                    //debugging purpose
-                    printRoutingTable();
-                    pnlsr.getNpt().printNpt();
-                    pnlsr.getFib().printFib();
-                    //debugging purpose end
-                }
-                else
-                {
-                    cout<<"Adjacency building is scheduled, so ";
-                    cout<<"routing table can not be calculated :("<<endl;
-                }
-            }
-            else
-            {
-                cout<<"No Adj LSA of router itself,";
-                cout<<	" so Routing table can not be calculated :("<<endl;
-                clearRoutingTable();
-                clearDryRoutingTable(); // for dry run options
-                // need to update NPT here
-                std::cout<<"Calling Update NPT With new Route"<<std::endl;
-                pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
-                //debugging purpose
-                printRoutingTable();
-                pnlsr.getNpt().printNpt();
-                pnlsr.getFib().printFib();
-                //debugging purpose end
-            }
-            pnlsr.setIsRouteCalculationScheduled(0); //clear scheduled flag
-            pnlsr.setIsRoutingTableCalculating(0); //unsetting routing table calculation
+          cout<<"CLearing old routing table ....."<<endl;
+          clearRoutingTable();
+          clearDryRoutingTable(); // for dry run options
+          // calculate Link State routing
+          if( (pnlsr.getConfParameter().getIsHyperbolicCalc() == 0 )
+              || (pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 ) )
+          {
+            calculateLsRoutingTable(pnlsr);
+          }
+          //calculate hyperbolic routing
+          if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 1 )
+          {
+            calculateHypRoutingTable(pnlsr);
+          }
+          //calculate dry hyperbolic routing
+          if ( pnlsr.getConfParameter().getIsHyperbolicCalc() == 2 )
+          {
+            calculateHypDryRoutingTable(pnlsr);
+          }
+          //need to update NPT here
+          pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
+          //debugging purpose
+          printRoutingTable();
+          pnlsr.getNpt().printNpt();
+          pnlsr.getFib().printFib();
+          //debugging purpose end
         }
         else
         {
-            scheduleRoutingTableCalculation(pnlsr);
+          cout<<"Adjacency building is scheduled, so ";
+          cout<<"routing table can not be calculated :("<<endl;
         }
+      }
+      else
+      {
+        cout<<"No Adj LSA of router itself,";
+        cout<<	" so Routing table can not be calculated :("<<endl;
+        clearRoutingTable();
+        clearDryRoutingTable(); // for dry run options
+        // need to update NPT here
+        std::cout<<"Calling Update NPT With new Route"<<std::endl;
+        pnlsr.getNpt().updateNptWithNewRoute(pnlsr);
+        //debugging purpose
+        printRoutingTable();
+        pnlsr.getNpt().printNpt();
+        pnlsr.getFib().printFib();
+        //debugging purpose end
+      }
+      pnlsr.setIsRouteCalculationScheduled(0); //clear scheduled flag
+      pnlsr.setIsRoutingTableCalculating(0); //unsetting routing table calculation
     }
-
-
-    void
-    RoutingTable::calculateLsRoutingTable(Nlsr& pnlsr)
+    else
     {
-        cout<<"RoutingTable::calculateLsRoutingTable Called"<<endl;
-        Map vMap;
-        vMap.createMapFromAdjLsdb(pnlsr);
-        int numOfRouter=vMap.getMapSize();
-        LinkStateRoutingTableCalculator lsrtc(numOfRouter);
-        lsrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
+      scheduleRoutingTableCalculation(pnlsr);
     }
+  }
 
-    void
-    RoutingTable::calculateHypRoutingTable(Nlsr& pnlsr)
-    {
-        Map vMap;
-        vMap.createMapFromAdjLsdb(pnlsr);
-        int numOfRouter=vMap.getMapSize();
-        HypRoutingTableCalculator hrtc(numOfRouter,0);
-        hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
-    }
 
-    void
-    RoutingTable::calculateHypDryRoutingTable(Nlsr& pnlsr)
-    {
-        Map vMap;
-        vMap.createMapFromAdjLsdb(pnlsr);
-        int numOfRouter=vMap.getMapSize();
-        HypRoutingTableCalculator hrtc(numOfRouter,1);
-        hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
-    }
+  void
+  RoutingTable::calculateLsRoutingTable(Nlsr& pnlsr)
+  {
+    cout<<"RoutingTable::calculateLsRoutingTable Called"<<endl;
+    Map vMap;
+    vMap.createMapFromAdjLsdb(pnlsr);
+    int numOfRouter=vMap.getMapSize();
+    LinkStateRoutingTableCalculator lsrtc(numOfRouter);
+    lsrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
+  }
 
-    void
-    RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
-    {
-        if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
-        {
-            pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
-                                               ndn::bind(&RoutingTable::calculate,this,boost::ref(pnlsr)));
-            pnlsr.setIsRouteCalculationScheduled(1);
-        }
-    }
+  void
+  RoutingTable::calculateHypRoutingTable(Nlsr& pnlsr)
+  {
+    Map vMap;
+    vMap.createMapFromAdjLsdb(pnlsr);
+    int numOfRouter=vMap.getMapSize();
+    HypRoutingTableCalculator hrtc(numOfRouter,0);
+    hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
+  }
 
-    static bool
-    routingTableEntryCompare(RoutingTableEntry& rte, string& destRouter)
+  void
+  RoutingTable::calculateHypDryRoutingTable(Nlsr& pnlsr)
+  {
+    Map vMap;
+    vMap.createMapFromAdjLsdb(pnlsr);
+    int numOfRouter=vMap.getMapSize();
+    HypRoutingTableCalculator hrtc(numOfRouter,1);
+    hrtc.calculatePath(vMap,boost::ref(*this),pnlsr);
+  }
+
+  void
+  RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
+  {
+    if ( pnlsr.getIsRouteCalculationScheduled() != 1 )
     {
-        return rte.getDestination()==destRouter;
+      pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
+                                         ndn::bind(&RoutingTable::calculate,this,boost::ref(pnlsr)));
+      pnlsr.setIsRouteCalculationScheduled(1);
     }
+  }
+
+  static bool
+  routingTableEntryCompare(RoutingTableEntry& rte, string& destRouter)
+  {
+    return rte.getDestination()==destRouter;
+  }
 
 // function related to manipulation of routing table
-    void
-    RoutingTable::addNextHop(string destRouter, NextHop& nh)
+  void
+  RoutingTable::addNextHop(string destRouter, NextHop& nh)
+  {
+    std::pair<RoutingTableEntry&, bool> rte=findRoutingTableEntry(destRouter);
+    if( !rte.second )
     {
-        std::pair<RoutingTableEntry&, bool> rte=findRoutingTableEntry(destRouter);
-        if( !rte.second )
-        {
-            RoutingTableEntry rte(destRouter);
-            rte.getNhl().addNextHop(nh);
-            rTable.push_back(rte);
-        }
-        else
-        {
-            (rte.first).getNhl().addNextHop(nh);
-        }
+      RoutingTableEntry rte(destRouter);
+      rte.getNhl().addNextHop(nh);
+      rTable.push_back(rte);
     }
+    else
+    {
+      (rte.first).getNhl().addNextHop(nh);
+    }
+  }
 
-    std::pair<RoutingTableEntry&, bool>
-    RoutingTable::findRoutingTableEntry(string destRouter)
+  std::pair<RoutingTableEntry&, bool>
+  RoutingTable::findRoutingTableEntry(string destRouter)
+  {
+    std::list<RoutingTableEntry >::iterator it = std::find_if( rTable.begin(),
+        rTable.end(),
+        bind(&routingTableEntryCompare, _1, destRouter));
+    if ( it != rTable.end() )
     {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( rTable.begin(),
-                rTable.end(),
-                bind(&routingTableEntryCompare, _1, destRouter));
-        if ( it != rTable.end() )
-        {
-            return std::make_pair(boost::ref((*it)),true);
-        }
-        RoutingTableEntry rteEmpty;
-        return std::make_pair(boost::ref(rteEmpty),false);
+      return std::make_pair(boost::ref((*it)),true);
     }
+    RoutingTableEntry rteEmpty;
+    return std::make_pair(boost::ref(rteEmpty),false);
+  }
 
-    void
-    RoutingTable::printRoutingTable()
+  void
+  RoutingTable::printRoutingTable()
+  {
+    cout<<"---------------Routing Table------------------"<<endl;
+    for(std::list<RoutingTableEntry>::iterator it=rTable.begin() ;
+        it != rTable.end(); ++it)
     {
-        cout<<"---------------Routing Table------------------"<<endl;
-        for(std::list<RoutingTableEntry>::iterator it=rTable.begin() ;
-                it != rTable.end(); ++it)
-        {
-            cout<<(*it)<<endl;
-        }
+      cout<<(*it)<<endl;
     }
+  }
 
 
 //function related to manipulation of dry routing table
-    void
-    RoutingTable::addNextHopToDryTable(string destRouter, NextHop& nh)
+  void
+  RoutingTable::addNextHopToDryTable(string destRouter, NextHop& nh)
+  {
+    std::list<RoutingTableEntry >::iterator it = std::find_if( dryTable.begin(),
+        dryTable.end(),
+        bind(&routingTableEntryCompare, _1, destRouter));
+    if ( it == dryTable.end() )
     {
-        std::list<RoutingTableEntry >::iterator it = std::find_if( dryTable.begin(),
-                dryTable.end(),
-                bind(&routingTableEntryCompare, _1, destRouter));
-        if ( it == dryTable.end() )
-        {
-            RoutingTableEntry rte(destRouter);
-            rte.getNhl().addNextHop(nh);
-            dryTable.push_back(rte);
-        }
-        else
-        {
-            (*it).getNhl().addNextHop(nh);
-        }
+      RoutingTableEntry rte(destRouter);
+      rte.getNhl().addNextHop(nh);
+      dryTable.push_back(rte);
     }
+    else
+    {
+      (*it).getNhl().addNextHop(nh);
+    }
+  }
 
-    void
-    RoutingTable::printDryRoutingTable()
+  void
+  RoutingTable::printDryRoutingTable()
+  {
+    cout<<"--------Dry Run's Routing Table--------------"<<endl;
+    for(std::list<RoutingTableEntry>::iterator it=dryTable.begin() ;
+        it != dryTable.end(); ++it)
     {
-        cout<<"--------Dry Run's Routing Table--------------"<<endl;
-        for(std::list<RoutingTableEntry>::iterator it=dryTable.begin() ;
-                it != dryTable.end(); ++it)
-        {
-            cout<<(*it)<<endl;
-        }
+      cout<<(*it)<<endl;
     }
+  }
 
 
-    void
-    RoutingTable::clearRoutingTable()
+  void
+  RoutingTable::clearRoutingTable()
+  {
+    if( rTable.size() > 0 )
     {
-        if( rTable.size() > 0 )
-        {
-            rTable.clear();
-        }
+      rTable.clear();
     }
+  }
 
-    void
-    RoutingTable::clearDryRoutingTable()
+  void
+  RoutingTable::clearDryRoutingTable()
+  {
+    if (dryTable.size()>0 )
     {
-        if (dryTable.size()>0 )
-        {
-            dryTable.clear();
-        }
+      dryTable.clear();
     }
+  }
 
 }//namespace nlsr