Adding rt, rte, nh
diff --git a/nlsr.cpp b/nlsr.cpp
index a21aa3f..99cc450 100644
--- a/nlsr.cpp
+++ b/nlsr.cpp
@@ -3,12 +3,15 @@
#include <ndn-cpp-dev/util/scheduler.hpp>
#include <cstdlib>
+#include<string>
+#include <sstream>
#include "nlsr.hpp"
#include "nlsr_conf_param.hpp"
#include "nlsr_conf_processor.hpp"
#include "nlsr_lsdb.hpp"
-
+//test purpose of NLSR
+#include "nlsr_test.hpp"
using namespace ndn;
using namespace std;
@@ -52,25 +55,57 @@
}
int
-main(){
+main(int argc, char **argv){
nlsr nlsr;
+ string programName(argv[0]);
nlsr.setConfFileName("nlsr.conf");
+
+ int opt;
+ while ((opt = getopt(argc, argv, "df:p:h")) != -1) {
+ switch (opt) {
+ case 'f':
+ nlsr.setConfFileName(optarg);
+ break;
+ case 'd':
+ nlsr.setIsDaemonProcess(optarg);
+ break;
+ case 'p':
+ {
+ stringstream sst(optarg);
+ int ap;
+ sst>>ap;
+ nlsr.setApiPort(ap);
+ }
+ break;
+ case 'h':
+ default:
+ nlsr.usage(programName);
+ return EXIT_FAILURE;
+ }
+ }
+
+
ConfFileProcessor cfp(nlsr.getConfFileName());
- cfp.processConfFile(nlsr);
+ int res=cfp.processConfFile(nlsr);
+ if ( res < 0 )
+ {
+ return EXIT_FAILURE;
+ }
nlsr.getConfParameter().buildRouterPrefix();
- nlsr.getLsdb().buildAndInstallOwnNameLsa(nlsr);
- nlsr.getLsdb().buildAndInstallOwnCorLsa(nlsr);
-
-
-/* debugging purpose start */
+ /* debugging purpose start */
cout << nlsr.getConfParameter();
nlsr.getAdl().printAdl();
nlsr.getNpl().printNpl();
- nlsr.getLsdb().printNameLsdb();
- nlsr.getLsdb().printCorLsdb();
-/* debugging purpose end */
+ /* debugging purpose end */
+
+ nlsr.getLsdb().buildAndInstallOwnNameLsa(nlsr);
+ nlsr.getLsdb().buildAndInstallOwnCorLsa(nlsr);
+
+ //testing purpose
+ nlsr.getNlsrTesting().schedlueAddingLsas(nlsr);
+
nlsr.setInterestFilterNlsr(nlsr.getConfParameter().getRouterPrefix());
nlsr.getIm().scheduleInfoInterest(nlsr,1);
@@ -83,5 +118,5 @@
std::cerr << "ERROR: " << e.what() << std::endl;
}
- return 0;
+ return EXIT_SUCCESS;
}
diff --git a/nlsr.hpp b/nlsr.hpp
index 8b325fe..f131ab6 100644
--- a/nlsr.hpp
+++ b/nlsr.hpp
@@ -11,6 +11,11 @@
#include "nlsr_im.hpp"
#include "nlsr_dm.hpp"
#include "nlsr_lsdb.hpp"
+#include "nlsr_sm.hpp"
+#include "nlsr_rt.hpp"
+//testing
+#include "nlsr_test.hpp"
+
using namespace ndn;
@@ -29,42 +34,19 @@
, npl()
, im()
, dm()
+ , sm()
, nlsrLsdb()
- , nameLsaSeq(0)
- , adjLsaSeq(0)
- , corLsaSeq(0)
, adjBuildCount(0)
, isBuildAdjLsaSheduled(0)
, isRouteCalculationScheduled(0)
, isRoutingTableCalculating(0)
+ , routingTable()
+ , nlsrTesting()
{
isDaemonProcess=false;
configFileName="nlsr.conf";
}
- nlsr(string confFile, uint32_t nlsn, uint32_t alsn, uint32_t clsn)
- : io(ndn::make_shared<boost::asio::io_service>())
- , nlsrFace(io)
- , scheduler(*io)
- , configFileName()
- , confParam()
- , adl()
- , npl()
- , im()
- , dm()
- , nlsrLsdb()
- , adjBuildCount(0)
- , isBuildAdjLsaSheduled(0)
- , isRouteCalculationScheduled(0)
- , isRoutingTableCalculating(0)
- {
- isDaemonProcess=false;
- configFileName=confFile;
- nameLsaSeq=nlsn;
- adjLsaSeq=alsn;
- corLsaSeq=clsn;
- }
-
void nlsrRegistrationFailed(const ptr_lib::shared_ptr<const Name>&);
void setInterestFilterNlsr(const string& name);
@@ -129,35 +111,16 @@
return dm;
}
+ SequencingManager& getSm(){
+ return sm;
+ }
+
Lsdb& getLsdb(){
return nlsrLsdb;
}
- uint32_t getNameLsaSeq()
- {
- return nameLsaSeq;
- }
-
- void setNameLsaSeq(uint32_t nlsn){
- nameLsaSeq=nlsn;
- }
-
- uint32_t getAdjLsaSeq()
- {
- return adjLsaSeq;
- }
-
- void setAdjLsaSeq(uint32_t alsn){
- adjLsaSeq=alsn;
- }
-
- uint32_t getCorLsaSeq()
- {
- return corLsaSeq;
- }
-
- void setCorLsaSeq(uint32_t clsn){
- corLsaSeq=clsn;
+ RoutingTable& getRoutingTable(){
+ return routingTable;
}
long int getAdjBuildCount()
@@ -184,6 +147,21 @@
{
isBuildAdjLsaSheduled=iabls;
}
+
+ nlsrTest& getNlsrTesting()
+ {
+ return nlsrTesting;
+ }
+
+ void setApiPort(int ap)
+ {
+ apiPort=ap;
+ }
+
+ int getApiPort()
+ {
+ return apiPort;
+ }
private:
ConfParameter confParam;
@@ -195,17 +173,22 @@
ndn::KeyChain kChain;
interestManager im;
DataManager dm;
+ SequencingManager sm;
bool isDaemonProcess;
string configFileName;
+ int apiPort;
+
Lsdb nlsrLsdb;
- uint32_t nameLsaSeq;
- uint32_t adjLsaSeq;
- uint32_t corLsaSeq;
+ RoutingTable routingTable;
+
+
long int adjBuildCount;
int isBuildAdjLsaSheduled;
int isRouteCalculationScheduled;
int isRoutingTableCalculating;
+
+ nlsrTest nlsrTesting;
};
diff --git a/nlsr_adl.hpp b/nlsr_adl.hpp
index d6923e1..eac8245 100644
--- a/nlsr_adl.hpp
+++ b/nlsr_adl.hpp
@@ -1,5 +1,5 @@
-#ifndef ADL_HPP
-#define ADL_HPP
+#ifndef NLSR_ADL_HPP
+#define NLSR_ADL_HPP
#include <ndn-cpp-dev/face.hpp>
#include "nlsr_adjacent.hpp"
diff --git a/nlsr_conf_processor.cpp b/nlsr_conf_processor.cpp
index 691a285..939aa56 100644
--- a/nlsr_conf_processor.cpp
+++ b/nlsr_conf_processor.cpp
@@ -18,16 +18,23 @@
if ( !confFileName.empty()){
std::ifstream inputFile(confFileName.c_str());
- for( string line; getline( inputFile, line ); ){
- if (!line.empty() ){
- if(line[0]!= '#' && line[0]!='!'){
- ret=processConfCommand(pnlsr, line);
- if( ret == -1 ){
- break;
+ if ( inputFile.is_open()){
+ for( string line; getline( inputFile, line ); ){
+ if (!line.empty() ){
+ if(line[0]!= '#' && line[0]!='!'){
+ ret=processConfCommand(pnlsr, line);
+ if( ret == -1 ){
+ break;
+ }
}
}
}
}
+ else{
+ std::cerr <<"Configuration file: ("<<confFileName<<") does not exist :(";
+ std::cerr <<endl;
+ ret=-1;
+ }
}
return ret;
@@ -326,11 +333,22 @@
int
ConfFileProcessor::processConfCommandNdnNeighbor(nlsr& pnlsr, string command){
if(command.empty() ){
- cerr <<" Wrong command format ! [ndnneighbor /nbr/name/]!"<<endl;
+ cerr <<" Wrong command format ! [ndnneighbor /nbr/name/ FaceId]!"<<endl;
}else{
nlsrTokenizer nt(command," ");
- Adjacent adj(nt.getFirstToken(),0,0.0,0,0);
- pnlsr.getAdl().insert(adj);
+ if( nt.getRestOfLine().empty())
+ {
+ cerr <<" Wrong command format ! [ndnneighbor /nbr/name/ FaceId]!"<<endl;
+ return 0;
+ }
+ else
+ {
+ stringstream sst(nt.getRestOfLine().c_str());
+ int faceId;
+ sst>>faceId;
+ Adjacent adj(nt.getFirstToken(),faceId,0.0,0,0);
+ pnlsr.getAdl().insert(adj);
+ }
}
return 0;
}
diff --git a/nlsr_lsdb.cpp b/nlsr_lsdb.cpp
index b4cbe91..062a2b1 100644
--- a/nlsr_lsdb.cpp
+++ b/nlsr_lsdb.cpp
@@ -30,10 +30,6 @@
//Name LSA and LSDB related functions start here
-static bool
-nameLsaCompare(NameLsa& nlsa1, NameLsa& nlsa2){
- return nlsa1.getLsaKey()==nlsa1.getLsaKey();
-}
static bool
nameLsaCompareByKey(NameLsa& nlsa1, string& key){
@@ -46,11 +42,10 @@
{
NameLsa nameLsa(pnlsr.getConfParameter().getRouterPrefix()
, 1
- , pnlsr.getNameLsaSeq()+1
+ , pnlsr.getSm().getNameLsaSeq()+1
, pnlsr.getConfParameter().getRouterDeadInterval()
, pnlsr.getNpl() );
- pnlsr.setNameLsaSeq(pnlsr.getNameLsaSeq()+1);
- //cout<<nameLsa;
+ pnlsr.getSm().setNameLsaSeq(pnlsr.getSm().getNameLsaSeq()+1);
return installNameLsa(nameLsa);
}
@@ -66,7 +61,7 @@
{
return (*it);
}
-
+
}
@@ -81,6 +76,7 @@
addNameLsa(nlsa);
// update NPT and FIB
// if its not own LSA
+ printNameLsdb();
}
else
{
@@ -98,9 +94,10 @@
{
std::list<NameLsa >::iterator it = std::find_if( nameLsdb.begin(),
nameLsdb.end(),
- bind(nameLsaCompare, _1, nlsa));
+ bind(nameLsaCompareByKey, _1, nlsa.getLsaKey()));
- if( it == nameLsdb.end()){
+ if( it == nameLsdb.end())
+ {
nameLsdb.push_back(nlsa);
return true;
}
@@ -138,6 +135,7 @@
void
Lsdb::printNameLsdb()
{
+ cout<<"---------------Name LSDB-------------------"<<endl;
for( std::list<NameLsa>::iterator it=nameLsdb.begin();
it!= nameLsdb.end() ; it++)
{
@@ -146,12 +144,12 @@
}
// Cor LSA and LSDB related Functions start here
-
+/*
static bool
corLsaCompare(CorLsa& clsa1, CorLsa& clsa2){
return clsa1.getLsaKey()==clsa1.getLsaKey();
}
-
+*/
static bool
corLsaCompareByKey(CorLsa& clsa, string& key){
return clsa.getLsaKey()==key;
@@ -161,12 +159,11 @@
Lsdb::buildAndInstallOwnCorLsa(nlsr& pnlsr){
CorLsa corLsa(pnlsr.getConfParameter().getRouterPrefix()
, 3
- , pnlsr.getCorLsaSeq()+1
+ , pnlsr.getSm().getCorLsaSeq()+1
, pnlsr.getConfParameter().getRouterDeadInterval()
, pnlsr.getConfParameter().getCorR()
, pnlsr.getConfParameter().getCorTheta() );
- pnlsr.setCorLsaSeq(pnlsr.getCorLsaSeq()+1);
- //cout<<corLsa;
+ pnlsr.getSm().setCorLsaSeq(pnlsr.getSm().getCorLsaSeq()+1);
installCorLsa(corLsa);
return true;
@@ -194,6 +191,7 @@
addCorLsa(clsa);
//schedule routing table calculation only if
//hyperbolic calculation is scheduled
+ printCorLsdb();
}
else
{
@@ -210,9 +208,10 @@
{
std::list<CorLsa >::iterator it = std::find_if( corLsdb.begin(),
corLsdb.end(),
- bind(corLsaCompare, _1, clsa));
+ bind(corLsaCompareByKey, _1, clsa.getLsaKey()));
- if( it == corLsdb.end()){
+ if( it == corLsdb.end())
+ {
corLsdb.push_back(clsa);
return true;
}
@@ -251,6 +250,7 @@
void
Lsdb::printCorLsdb() //debugging
{
+ cout<<"---------------Cor LSDB-------------------"<<endl;
for( std::list<CorLsa>::iterator it=corLsdb.begin();
it!= corLsdb.end() ; it++)
{
@@ -260,12 +260,12 @@
// Adj LSA and LSDB related function starts here
-
+/*
static bool
adjLsaCompare(AdjLsa& alsa1, AdjLsa& alsa2){
return alsa1.getLsaKey()==alsa1.getLsaKey();
}
-
+*/
static bool
adjLsaCompareByKey(AdjLsa& alsa, string& key){
return alsa.getLsaKey()==key;
@@ -315,7 +315,7 @@
{
std::list<AdjLsa >::iterator it = std::find_if( adjLsdb.begin(),
adjLsdb.end(),
- bind(adjLsaCompare, _1, alsa));
+ bind(adjLsaCompareByKey, _1, alsa.getLsaKey()));
if( it == adjLsdb.end()){
adjLsdb.push_back(alsa);
@@ -338,7 +338,7 @@
}
bool
-Lsdb::installAdjLsa(AdjLsa &alsa)
+Lsdb::installAdjLsa(nlsr& pnlsr, AdjLsa &alsa)
{
bool doesLsaExist_ = doesAdjLsaExist(alsa.getLsaKey());
if ( !doesLsaExist_ )
@@ -346,6 +346,8 @@
// add Adj LSA
addAdjLsa(alsa);
// schedule routing table calculation
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(15),
+ ndn::bind(&RoutingTable::calculate, &pnlsr.getRoutingTable()));
}
else
{
@@ -364,12 +366,12 @@
{
AdjLsa adjLsa(pnlsr.getConfParameter().getRouterPrefix()
, 2
- , pnlsr.getAdjLsaSeq()+1
+ , pnlsr.getSm().getAdjLsaSeq()+1
, pnlsr.getConfParameter().getRouterDeadInterval()
, pnlsr.getAdl().getNumOfActiveNeighbor()
, pnlsr.getAdl() );
- pnlsr.setAdjLsaSeq(pnlsr.getAdjLsaSeq()+1);
- return installAdjLsa(adjLsa);
+ pnlsr.getSm().setAdjLsaSeq(pnlsr.getSm().getAdjLsaSeq()+1);
+ return installAdjLsa(pnlsr, adjLsa);
}
bool
@@ -404,6 +406,7 @@
void
Lsdb::printAdjLsdb()
{
+ cout<<"---------------Adj LSDB-------------------"<<endl;
for( std::list<AdjLsa>::iterator it=adjLsdb.begin();
it!= adjLsdb.end() ; it++)
{
diff --git a/nlsr_lsdb.hpp b/nlsr_lsdb.hpp
index 58e0d53..3451c71 100644
--- a/nlsr_lsdb.hpp
+++ b/nlsr_lsdb.hpp
@@ -33,7 +33,7 @@
void scheduledAdjLsaBuild(nlsr& pnlsr);
bool buildAndInstallOwnAdjLsa(nlsr& pnlsr);
bool removeAdjLsa(string& key);
- bool installAdjLsa(AdjLsa &alsa);
+ bool installAdjLsa(nlsr& pnlsr, AdjLsa &alsa);
AdjLsa& getAdjLsa(string key);
void printAdjLsdb();
diff --git a/nlsr_nexthop.cpp b/nlsr_nexthop.cpp
new file mode 100644
index 0000000..7af0bd4
--- /dev/null
+++ b/nlsr_nexthop.cpp
@@ -0,0 +1,8 @@
+#include "nlsr_nexthop.hpp"
+
+ostream&
+operator<<(ostream& os, NextHop& nh)
+{
+ os<<"Face: "<<nh.getConnectingFace()<<" Route Cost: "<<nh.getRouteCost();
+ return os;
+}
diff --git a/nlsr_nexthop.hpp b/nlsr_nexthop.hpp
new file mode 100644
index 0000000..17393c6
--- /dev/null
+++ b/nlsr_nexthop.hpp
@@ -0,0 +1,51 @@
+#ifndef NLSR_NEXTHOP_HPP
+#define NLSR_NEXTHOP_HPP
+
+#include<iostream>
+
+using namespace std;
+
+class NextHop
+{
+public:
+ NextHop()
+ : connectingFace(0)
+ , routeCost(0)
+ {
+ }
+
+ NextHop(int cf, double rc)
+ {
+ connectingFace=cf;
+ routeCost=rc;
+ }
+
+ int getConnectingFace()
+ {
+ return connectingFace;
+ }
+
+ void setConnectingFace(int cf)
+ {
+ connectingFace=cf;
+ }
+
+ double getRouteCost()
+ {
+ return routeCost;
+ }
+
+ void setRouteCost(double rc)
+ {
+ routeCost=rc;
+ }
+private:
+ int connectingFace;
+ double routeCost;
+};
+
+
+ostream&
+operator<<(ostream& os, NextHop& nh);
+
+#endif
diff --git a/nlsr_nhl.cpp b/nlsr_nhl.cpp
new file mode 100644
index 0000000..9675467
--- /dev/null
+++ b/nlsr_nhl.cpp
@@ -0,0 +1,46 @@
+#include <iostream>
+
+#include "nlsr_nhl.hpp"
+#include "nlsr_nexthop.hpp"
+
+using namespace std;
+
+static bool
+nexthopCompare(NextHop& nh1, NextHop& nh2){
+ return nh1.getConnectingFace()==nh2.getConnectingFace();
+}
+
+/**
+Add next hop to the Next Hop list
+If next hop is new it is added
+If next hop already exists in next
+hop list then updates the route
+cost with new next hop's route cost
+*/
+
+void
+Nhl::addNextHop(NextHop& nh)
+{
+ std::list<NextHop >::iterator it = std::find_if( nexthopList.begin(),
+ nexthopList.end(),
+ bind(&nexthopCompare, _1, nh));
+ if ( it == nexthopList.end() ){
+ nexthopList.push_back(nh);
+ }
+
+ (*it).setRouteCost(nh.getRouteCost());
+}
+
+
+ostream&
+operator<<(ostream& os, Nhl& nhl)
+{
+ std::list< NextHop > nexthopList = nhl.getNextHopList();
+ int i=1;
+ for( std::list<NextHop>::iterator it=nexthopList.begin();
+ it!= nexthopList.end() ; it++,i++)
+ {
+ os << "Nexthop "<<i<<": "<<(*it)<<endl;
+ }
+ return os;
+}
diff --git a/nlsr_nhl.hpp b/nlsr_nhl.hpp
new file mode 100644
index 0000000..94b77e0
--- /dev/null
+++ b/nlsr_nhl.hpp
@@ -0,0 +1,36 @@
+#ifndef NLSR_NHL_HPP
+#define NLSR_NHL_HPP
+
+#include <ndn-cpp-dev/face.hpp>
+#include "nlsr_adjacent.hpp"
+#include <list>
+#include <iostream>
+
+#include "nlsr_nexthop.hpp"
+
+using namespace std;
+
+class Nhl
+{
+public:
+ Nhl()
+ {
+ }
+
+ ~Nhl()
+ {
+ }
+ void addNextHop(NextHop &nh);
+ std::list< NextHop >& getNextHopList()
+ {
+ return nexthopList;
+ }
+
+private:
+ std::list< NextHop > nexthopList;
+};
+
+ostream&
+operator<<(ostream& os, Nhl& nhl);
+
+#endif
diff --git a/nlsr_rt.cpp b/nlsr_rt.cpp
new file mode 100644
index 0000000..bcf5af0
--- /dev/null
+++ b/nlsr_rt.cpp
@@ -0,0 +1,10 @@
+#include<iostream>
+#include<string>
+
+#include "nlsr_rt.hpp"
+#include "nlsr.hpp"
+
+using namespace std;
+
+
+
diff --git a/nlsr_rt.hpp b/nlsr_rt.hpp
new file mode 100644
index 0000000..ac9ccfa
--- /dev/null
+++ b/nlsr_rt.hpp
@@ -0,0 +1,26 @@
+#ifndef NLSR_RT_HPP
+#define NLSR_RT_HPP
+
+#include<iostream>
+#include<string>
+
+#include "nlsr_rte.hpp"
+
+using namespace std;
+
+class RoutingTable
+{
+public:
+ RoutingTable()
+ {
+ }
+ void calculate()
+ {
+ cout<<"Routing Table Calculating......"<<endl;
+ }
+
+private:
+ std::list< RoutingTableEntry > rTable;
+};
+
+#endif
diff --git a/nlsr_rte.cpp b/nlsr_rte.cpp
new file mode 100644
index 0000000..cc9feab
--- /dev/null
+++ b/nlsr_rte.cpp
@@ -0,0 +1,21 @@
+#include <iostream>
+#include <string>
+
+#include "nlsr_rte.hpp"
+
+using namespace std;
+
+ostream&
+operator<<(ostream& os, RoutingTableEntry &rte)
+{
+ os<<"Destination: "<<rte.getDestination()<<endl;
+ os<<"Nexthops: "<<endl;
+ int i=1;
+ std::list< NextHop > nhl = rte.getNhl().getNextHopList();
+ for( std::list<NextHop>::iterator it=nhl.begin();
+ it!= nhl.end() ; it++,i++)
+ {
+ os <<" Nexthop "<<i<<": "<<(*it)<<endl;
+ }
+ return os;
+}
diff --git a/nlsr_rte.hpp b/nlsr_rte.hpp
new file mode 100644
index 0000000..eeaf48c
--- /dev/null
+++ b/nlsr_rte.hpp
@@ -0,0 +1,44 @@
+#ifndef NLSR_RTE_HPP
+#define NLSR_RTE_HPP
+
+#include<iostream>
+
+#include "nlsr_nhl.hpp"
+
+using namespace std;
+
+class RoutingTableEntry
+{
+public:
+ RoutingTableEntry()
+ : destination()
+ , nhl()
+ {
+
+ }
+
+ RoutingTableEntry(string dest)
+ : nhl()
+ {
+ destination=dest;
+ }
+
+ string getDestination()
+ {
+ return destination;
+ }
+
+ Nhl& getNhl()
+ {
+ return nhl;
+ }
+
+private:
+ string destination;
+ Nhl nhl;
+};
+
+ostream&
+operator<<(ostream& os, RoutingTableEntry &rte);
+
+#endif
diff --git a/nlsr_sm.cpp b/nlsr_sm.cpp
new file mode 100644
index 0000000..4a1706d
--- /dev/null
+++ b/nlsr_sm.cpp
@@ -0,0 +1,9 @@
+#include <string>
+#include <iostream>
+#include "nlsr_sm.hpp"
+
+using namespace std;
+
+class nlsr;
+
+
diff --git a/nlsr_sm.hpp b/nlsr_sm.hpp
new file mode 100644
index 0000000..eaae848
--- /dev/null
+++ b/nlsr_sm.hpp
@@ -0,0 +1,54 @@
+#ifndef NLSR_SM_HPP
+#define NLSR_SM_HPP
+
+class SequencingManager
+{
+public:
+ SequencingManager()
+ : nameLsaSeq(0)
+ , adjLsaSeq(0)
+ , corLsaSeq(0)
+ {
+ }
+
+ SequencingManager(uint32_t nlsn, uint32_t alsn, uint32_t clsn)
+ {
+ nameLsaSeq=nlsn;
+ adjLsaSeq=alsn;
+ corLsaSeq=clsn;
+ }
+
+ uint32_t getNameLsaSeq()
+ {
+ return nameLsaSeq;
+ }
+
+ void setNameLsaSeq(uint32_t nlsn){
+ nameLsaSeq=nlsn;
+ }
+
+ uint32_t getAdjLsaSeq()
+ {
+ return adjLsaSeq;
+ }
+
+ void setAdjLsaSeq(uint32_t alsn){
+ adjLsaSeq=alsn;
+ }
+
+ uint32_t getCorLsaSeq()
+ {
+ return corLsaSeq;
+ }
+
+ void setCorLsaSeq(uint32_t clsn){
+ corLsaSeq=clsn;
+ }
+
+private:
+ uint32_t nameLsaSeq;
+ uint32_t adjLsaSeq;
+ uint32_t corLsaSeq;
+};
+
+#endif
diff --git a/nlsr_test.cpp b/nlsr_test.cpp
new file mode 100644
index 0000000..4303f89
--- /dev/null
+++ b/nlsr_test.cpp
@@ -0,0 +1,95 @@
+#include <ndn-cpp-dev/face.hpp>
+#include <ndn-cpp-dev/security/key-chain.hpp>
+#include <ndn-cpp-dev/util/scheduler.hpp>
+
+#include "nlsr.hpp"
+#include "nlsr_test.hpp"
+
+using namespace std;
+using namespace ndn;
+
+void
+nlsrTest::schedlueAddingLsas(nlsr& pnlsr)
+{
+ // scheduling adding two name lsas, two Cor Lsas and three Adj LSAs
+
+ //Scheduling Adding LSAs for router altair
+ string router("/ndn/memphis.edu/cs/altair");
+ string name1("/ndn/memphis.edu/cs/altair/name1");
+ string name2("/ndn/memphis.edu/cs/altair/name2");
+ string name3("/ndn/memphis.edu/cs/altair/name3");
+ Adjacent adj1("/ndn/memphis.edu/cs/pollux",7,17,1,0);
+ Adjacent adj2("/ndn/memphis.edu/cs/maia",15,27,1,0);
+
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(30),
+ ndn::bind(&nlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
+ boost::ref(pnlsr)
+ ,router,name1,name2,name3));
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(37),
+ ndn::bind(&nlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
+ boost::ref(pnlsr)
+ ,router,123.098,1.875));
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(47),
+ ndn::bind(&nlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
+ boost::ref(pnlsr)
+ ,router,adj1,adj2));
+
+ //Scheduling Adding LSAs for router Maia
+ string routerMaia("/ndn/memphis.edu/cs/maia");
+ string maiaName1("/ndn/memphis.edu/maia/name1");
+ string maiaName2("/ndn/memphis.edu/maia/name2");
+ string maiaName3("/ndn/memphis.edu/maia/name3");
+ Adjacent maiaAdj1("/ndn/memphis.edu/cs/pollux",8,25,1,0);
+ Adjacent maiaAdj2("/ndn/memphis.edu/cs/altair",11,15,1,0);
+
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(55),
+ ndn::bind(&nlsrTest::secheduledAddNameLsa,pnlsr.getNlsrTesting(),
+ boost::ref(pnlsr)
+ ,routerMaia,maiaName1,maiaName2,maiaName3));
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(65),
+ ndn::bind(&nlsrTest::secheduledAddCorLsa,pnlsr.getNlsrTesting(),
+ boost::ref(pnlsr)
+ ,routerMaia,12.098,0.875));
+ pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(75),
+ ndn::bind(&nlsrTest::scheduledAddAdjacentLsa,pnlsr.getNlsrTesting(),
+ boost::ref(pnlsr)
+ ,routerMaia,maiaAdj1,maiaAdj2));
+
+
+
+}
+
+
+
+void
+nlsrTest::secheduledAddNameLsa(nlsr& pnlsr, string router,
+ string name1, string name2, string name3)
+{
+ Npl npl;
+ npl.insertIntoNpl(name1);
+ npl.insertIntoNpl(name2);
+ npl.insertIntoNpl(name3);
+ NameLsa nameLsa(router,1,1,3600,npl);
+ pnlsr.getLsdb().installNameLsa(nameLsa);
+
+}
+
+void
+nlsrTest::secheduledAddCorLsa(nlsr& pnlsr,string router, double r, double angle)
+{
+ CorLsa corLsa(router,3,1,3600,r,angle);
+ pnlsr.getLsdb().installCorLsa(corLsa);
+}
+
+void
+nlsrTest::scheduledAddAdjacentLsa(nlsr& pnlsr, string router,
+ Adjacent adj1, Adjacent adj2)
+{
+ Adl adl;
+ adl.insert(adj1);
+ adl.insert(adj2);
+ AdjLsa adjLsa(router,2,1,3600,2,adl);
+ pnlsr.getLsdb().installAdjLsa(pnlsr, adjLsa);
+
+}
+
diff --git a/nlsr_test.hpp b/nlsr_test.hpp
new file mode 100644
index 0000000..e6e7dfd
--- /dev/null
+++ b/nlsr_test.hpp
@@ -0,0 +1,34 @@
+#ifndef NLSR_TEST_HPP
+#define NLSR_TEST_HPP
+
+#include <iostream>
+#include <string>
+
+#include "nlsr_lsdb.hpp"
+#include "nlsr_lsa.hpp"
+#include "nlsr_adl.hpp"
+#include "nlsr_npl.hpp"
+#include "nlsr_adjacent.hpp"
+
+using namespace std;
+
+class nlsr;
+
+class nlsrTest
+{
+public:
+ nlsrTest()
+ {
+ }
+ void schedlueAddingLsas(nlsr& pnlsr);
+private:
+ void secheduledAddNameLsa(nlsr& pnlsr, string router,
+ string name1, string name2, string name3);
+ void secheduledAddCorLsa(nlsr& pnlsr,string router, double r, double angle);
+
+ void scheduledAddAdjacentLsa(nlsr& pnlsr, string router,
+ Adjacent adj1, Adjacent adj2);
+
+};
+
+#endif