Browse Source

src: Replace std::cout with log message

Change-Id: Idf49992711b4bb4a45d8f9665963feebf3b0a887
pull/1/head
akmhoque 11 years ago
parent
commit
2f4233531e
  1. 10
      src/adjacency-list.cpp
  2. 3
      src/adjacency-list.hpp
  3. 11
      src/adjacent.cpp
  4. 3
      src/adjacent.hpp
  5. 21
      src/communication/sync-logic-handler.cpp
  6. 1
      src/conf-file-processor.cpp
  7. 22
      src/conf-parameter.hpp
  8. 29
      src/hello-protocol.cpp
  9. 58
      src/lsa.cpp
  10. 10
      src/lsa.hpp
  11. 105
      src/lsdb.cpp
  12. 9
      src/lsdb.hpp
  13. 11
      src/name-prefix-list.cpp
  14. 3
      src/name-prefix-list.hpp
  15. 5
      src/nlsr.cpp
  16. 44
      src/route/face-map.cpp
  17. 21
      src/route/face-map.hpp
  18. 9
      src/route/fib-entry.cpp
  19. 3
      src/route/fib-entry.hpp
  20. 34
      src/route/fib.cpp
  21. 3
      src/route/fib.hpp
  22. 8
      src/route/map-entry.hpp
  23. 17
      src/route/map.cpp
  24. 5
      src/route/map.hpp
  25. 14
      src/route/name-prefix-table-entry.cpp
  26. 3
      src/route/name-prefix-table-entry.hpp
  27. 11
      src/route/name-prefix-table.cpp
  28. 3
      src/route/name-prefix-table.hpp
  29. 12
      src/route/nexthop-list.cpp
  30. 3
      src/route/nexthop-list.hpp
  31. 9
      src/route/nexthop.hpp
  32. 59
      src/route/routing-table-calculator.cpp
  33. 11
      src/route/routing-table-calculator.hpp
  34. 14
      src/route/routing-table-entry.hpp
  35. 52
      src/route/routing-table.cpp
  36. 6
      src/route/routing-table.hpp
  37. 17
      src/sequencing-manager.cpp
  38. 7
      src/sequencing-manager.hpp

10
src/adjacency-list.cpp

@ -243,14 +243,4 @@ AdjacencyList::writeLog()
}
}
// used for debugging purpose
void
AdjacencyList::print()
{
for (std::list<Adjacent>::iterator it = m_adjList.begin();
it != m_adjList.end(); it++) {
cout << (*it) << endl;
}
}
} //namespace nlsr

3
src/adjacency-list.hpp

@ -98,9 +98,6 @@ public:
}
}
void
print();
void
writeLog();

11
src/adjacent.cpp

@ -90,15 +90,4 @@ Adjacent::writeLog()
_LOG_DEBUG("Interest Timed out: " << m_interestTimedOutNo);
}
std::ostream&
operator<<(std::ostream& os, const Adjacent& adj)
{
os << "Adjacent : " << adj.getName() << endl;
os << "Connecting FaceUri: " << adj.getConnectingFaceUri() << endl;
os << "Link Cost: " << adj.getLinkCost() << endl;
os << "Status: " << adj.getStatus() << endl;
os << "Interest Timed out: " << adj.getInterestTimedOutNo() << endl;
return os;
}
} //namespace nlsr

3
src/adjacent.hpp

@ -125,9 +125,6 @@ private:
uint32_t m_interestTimedOutNo;
};
std::ostream&
operator<<(std::ostream& os, const Adjacent& adj);
} // namespace nlsr
#endif //NLSR_ADJACENT_HPP

21
src/communication/sync-logic-handler.cpp

@ -37,8 +37,6 @@ void
SyncLogicHandler::createSyncSocket(Nlsr& pnlsr)
{
_LOG_DEBUG("Creating Sync socket. Sync Prefix: " << m_syncPrefix);
std::cout << "Creating Sync socket ......" << std::endl;
std::cout << "Sync prefix: " << m_syncPrefix << std::endl;
m_syncSocket = ndn::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator,
m_syncFace,
ndn::bind(&SyncLogicHandler::nsyncUpdateCallBack,
@ -52,12 +50,9 @@ SyncLogicHandler::nsyncUpdateCallBack(const vector<Sync::MissingDataInfo>& v,
Sync::SyncSocket* socket, Nlsr& pnlsr)
{
_LOG_DEBUG("nsyncUpdateCallBack called ....");
std::cout << "nsyncUpdateCallBack called ...." << std::endl;
int32_t n = v.size();
for (int32_t i = 0; i < n; i++){
_LOG_DEBUG("Data Name: " << v[i].prefix << " Seq: " << v[i].high.getSeq());
std::cout << "Data Name: " << v[i].prefix << " Seq: " << v[i].high.getSeq() <<
endl;
_LOG_DEBUG("Update Name: " << v[i].prefix << " Seq: " << v[i].high.getSeq());
processUpdateFromSync(v[i].prefix, v[i].high.getSeq(), pnlsr);
}
}
@ -66,7 +61,6 @@ void
SyncLogicHandler::nsyncRemoveCallBack(const string& prefix, Nlsr& pnlsr)
{
_LOG_DEBUG("nsyncRemoveCallBack called ....");
std::cout << "nsyncRemoveCallBack called ...." << std::endl;
}
void
@ -94,11 +88,10 @@ SyncLogicHandler::processRoutingUpdateFromSync(const ndn::Name& routerName,
ndn::Name rName = routerName;
if (routerName != pnlsr.getConfParameter().getRouterPrefix()) {
SequencingManager sm(seqNo);
std::cout << sm;
//std::cout << "Router Name: " << routerName << endl;
sm.writeLog();
_LOG_DEBUG(routerName);
try {
if (pnlsr.getLsdb().isNameLsaNew(rName.append("name"), sm.getNameLsaSeq())) {
std::cout << "Updated Name LSA. Need to fetch it" << std::endl;
_LOG_DEBUG("Updated Name LSA. Need to fetch it");
ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
interestName.append(routerName);
@ -108,9 +101,7 @@ SyncLogicHandler::processRoutingUpdateFromSync(const ndn::Name& routerName,
pnlsr.getConfParameter().getInterestResendTime(),
0);
}
if (pnlsr.getLsdb().isAdjLsaNew(rName.append("adjacency"),
sm.getAdjLsaSeq())) {
std::cout << "Updated Adj LSA. Need to fetch it" << std::endl;
if (pnlsr.getLsdb().isAdjLsaNew(rName.append("adjacency"), sm.getAdjLsaSeq())) {
_LOG_DEBUG("Updated Adj LSA. Need to fetch it");
ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
interestName.append(routerName);
@ -122,7 +113,6 @@ SyncLogicHandler::processRoutingUpdateFromSync(const ndn::Name& routerName,
}
if (pnlsr.getLsdb().isCoordinateLsaNew(rName.append("coordinate"),
sm.getCorLsaSeq())) {
std::cout << "Updated Cor LSA. Need to fetch it" << std::endl;
_LOG_DEBUG("Updated Cor LSA. Need to fetch it");
ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
interestName.append(routerName);
@ -152,9 +142,6 @@ void
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;
_LOG_DEBUG("Publishing Sync Update. Prefix: " << updatePrefix << "Seq no: " << seqNo);
ndn::Name updateName(updatePrefix);
string data("NoData");

1
src/conf-file-processor.cpp

@ -405,7 +405,6 @@ ConfFileProcessor::processConfSectionFib(boost::property_tree::ptree
}
else {
std::cerr << "Wrong value for max-faces-per-prefix. ";
std::cerr << "NLSR will user default value";
std::cerr << MAX_FACES_PER_PREFIX_MIN << std::endl;
return false;
}

22
src/conf-parameter.hpp

@ -338,28 +338,6 @@ private:
};
inline std::ostream&
operator<<(std::ostream& os, ConfParameter& cfp)
{
os << "Router Name: " << cfp.getRouterName() << std::endl;
os << "Site Name: " << cfp.getSiteName() << std::endl;
os << "Network: " << cfp.getNetwork() << std::endl;
os << "Router Prefix: " << cfp.getRouterPrefix() << std::endl;
os << "ChronoSync sync Prifex: " << cfp.getChronosyncPrefix() << std::endl;
os << "ChronoSync LSA prefix: " << cfp.getLsaPrefix() << std::endl;
os << "Interest Retry number: " << cfp.getInterestRetryNumber() << std::endl;
os << "Interest Resend second: " << cfp.getInterestResendTime() << std::endl;
os << "Info Interest Interval: " << cfp.getInfoInterestInterval() << std::endl;
os << "LSA refresh time: " << cfp.getLsaRefreshTime() << std::endl;
os << "Max Faces Per Prefix: " << cfp.getMaxFacesPerPrefix() << std::endl;
os << "Hyperbolic ROuting: " << cfp.getHyperbolicState() << std::endl;
os << "Hyp R: " << cfp.getCorR() << std::endl;
os << "Hyp theta: " << cfp.getCorTheta() << std::endl;
os << "Log Directory: " << cfp.getLogDir() << std::endl;
os << "Seq Directory: " << cfp.getSeqFileDir() << std::endl;
return os;
}
} // namespace nlsr
#endif //CONF_PARAMETER_HPP

29
src/hello-protocol.cpp

@ -35,7 +35,6 @@ const std::string HelloProtocol::INFO_COMPONENT="info";
void
HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
{
std::cout << "Expressing Interest :" << interestName << std::endl;
_LOG_DEBUG("Expressing Interest :" << interestName);
ndn::Interest i(interestName);
i.setInterestLifetime(ndn::time::seconds(seconds));
@ -76,14 +75,12 @@ 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;
_LOG_DEBUG("Interest Received for Name: " << interestName);
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
return;
}
ndn::Name neighbor;
neighbor.wireDecode(interestName.get(-1).blockFromValue());
std::cout << "Neighbor: " << neighbor << std::endl;
_LOG_DEBUG("Neighbor: " << neighbor);
if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) {
ndn::Data data(ndn::Name(interest.getName()).appendVersion());
@ -91,7 +88,6 @@ HelloProtocol::processInterest(const ndn::Name& name,
data.setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
INFO_COMPONENT.size());
m_nlsr.getKeyChain().sign(data, m_nlsr.getDefaultCertName());
std::cout << ">> D: " << data << std::endl;
_LOG_DEBUG("Sending out data for name: " << data.getName());
m_nlsr.getNlsrFace().put(data);
int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
@ -109,21 +105,16 @@ void
HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
{
const ndn::Name interestName(interest.getName());
std::cout << "Interest timed out for Name: " << interestName << std::endl;
_LOG_DEBUG("Interest timed out for Name: " << interestName);
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
return;
}
ndn::Name neighbor = interestName.getPrefix(-2);
std::cout << "Neighbor: " << neighbor << std::endl;
_LOG_DEBUG("Neighbor: " << neighbor);
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;
_LOG_DEBUG("Status: " << status);
_LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount);
if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) {
@ -161,35 +152,19 @@ void
HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
{
ndn::Name dataName = data->getName();
std::cout << "Data received for name: " << dataName << std::endl;
_LOG_DEBUG("Data received for name: " << dataName);
if (dataName.get(-3).toUri() == INFO_COMPONENT) {
ndn::Name neighbor = dataName.getPrefix(-3);
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;
_LOG_DEBUG("Neighbor : " << neighbor);
_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
//debugging purpose end
// change in Adjacency list
if ((oldStatus - newStatus) != 0) {
m_nlsr.incrementAdjBuildCount();
/* Need to schedule event for Adjacency LSA building */
// Need to schedule event for Adjacency LSA building
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
_LOG_DEBUG("Scheduling scheduledAdjLsaBuild");
m_nlsr.setIsBuildAdjLsaSheduled(true);

58
src/lsa.cpp

@ -124,28 +124,9 @@ NameLsa::writeLog()
{
_LOG_DEBUG(" Name " << i << ": " << (*it));
}
_LOG_DEBUG("name_lsa_end");
}
std::ostream&
operator<<(std::ostream& os, NameLsa& nLsa)
{
os << "Name Lsa: " << endl;
os << " Origination Router: " << nLsa.getOrigRouter() << endl;
os << " Ls Type: " << nLsa.getLsType() << endl;
os << " Ls Seq No: " << nLsa.getLsSeqNo() << endl;
os << " Ls Lifetime: " << nLsa.getExpirationTimePoint() << endl;
os << " Names: " << endl;
int i = 1;
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;
}
return os;
}
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst,
uint32_t lsn,
const ndn::time::system_clock::TimePoint& lt,
@ -226,20 +207,6 @@ CoordinateLsa::writeLog()
_LOG_DEBUG(" Hyperbolic Theta: " << m_corRad);
}
std::ostream&
operator<<(std::ostream& os, const CoordinateLsa& cLsa)
{
os << "Cor Lsa: " << endl;
os << " Origination Router: " << cLsa.getOrigRouter() << endl;
os << " Ls Type: " << cLsa.getLsType() << endl;
os << " Ls Seq No: " << cLsa.getLsSeqNo() << endl;
os << " Ls Lifetime: " << cLsa.getExpirationTimePoint() << endl;
os << " Hyperbolic Radius: " << cLsa.getCorRadius() << endl;
os << " Hyperbolic Theta: " << cLsa.getCorTheta() << endl;
return os;
}
AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
const ndn::time::system_clock::TimePoint& lt,
uint32_t nl , AdjacencyList& adl)
@ -365,28 +332,7 @@ AdjLsa::writeLog()
_LOG_DEBUG(" Connecting FaceUri: " << (*it).getConnectingFaceUri());
_LOG_DEBUG(" Link Cost: " << (*it).getLinkCost());
}
}
std::ostream&
operator<<(std::ostream& os, AdjLsa& aLsa)
{
os << "Adj Lsa: " << endl;
os << " Origination Router: " << aLsa.getOrigRouter() << endl;
os << " Ls Type: " << aLsa.getLsType() << endl;
os << " Ls Seq No: " << aLsa.getLsSeqNo() << endl;
os << " Ls Lifetime: " << aLsa.getExpirationTimePoint() << endl;
os << " No Link: " << aLsa.getNoLink() << endl;
os << " Adjacents: " << endl;
int i = 1;
std::list<Adjacent> al = aLsa.getAdl().getAdjList();
for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++)
{
os << " Adjacent " << i << ": " << endl;
os << " Adjacent Name: " << (*it).getName() << endl;
os << " Connecting FaceUri: " << (*it).getConnectingFaceUri() << endl;
os << " Link Cost: " << (*it).getLinkCost() << endl;
}
return os;
_LOG_DEBUG("adj_lsa_end");
}
}//namespace nlsr

10
src/lsa.hpp

@ -162,9 +162,6 @@ private:
};
std::ostream&
operator<<(std::ostream& os, NameLsa& nLsa);
class AdjLsa: public Lsa
{
public:
@ -223,9 +220,6 @@ private:
AdjacencyList m_adl;
};
std::ostream&
operator<<(std::ostream& os, AdjLsa& aLsa);
class CoordinateLsa: public Lsa
{
public:
@ -286,10 +280,6 @@ private:
};
std::ostream&
operator<<(std::ostream& os, const CoordinateLsa& cLsa);
}//namespace nlsr
#endif //NLSR_LSA_HPP

105
src/lsdb.cpp

@ -103,10 +103,10 @@ Lsdb::installNameLsa(NameLsa& nlsa)
NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
if (chkNameLsa == 0) {
addNameLsa(nlsa);
_LOG_DEBUG("New Name LSA. Adding to LSDB");
_LOG_DEBUG("New Name LSA");
_LOG_DEBUG("Adding Name Lsa");
nlsa.writeLog();
printNameLsdb();
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
m_nlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
nlsa.getOrigRouter());
@ -130,7 +130,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
else {
if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo()) {
_LOG_DEBUG("Updated Name LSA. Updating LSDB");
_LOG_DEBUG("Old Name LSA ");
_LOG_DEBUG("Deleting Name Lsa");
chkNameLsa->writeLog();
chkNameLsa->setLsSeqNo(nlsa.getLsSeqNo());
chkNameLsa->setExpirationTimePoint(nlsa.getExpirationTimePoint());
@ -175,7 +175,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
nlsa.getLsSeqNo(),
timeToExpire));
_LOG_DEBUG("Updated Name LSA");
_LOG_DEBUG("Adding Name Lsa");
chkNameLsa->writeLog();
}
}
@ -203,7 +203,7 @@ Lsdb::removeNameLsa(const ndn::Name& key)
m_nameLsdb.end(),
ndn::bind(nameLsaCompareByKey, _1, key));
if (it != m_nameLsdb.end()) {
_LOG_DEBUG("Removing Name LSA");
_LOG_DEBUG("Deleting Name Lsa");
(*it).writeLog();
if ((*it).getOrigRouter() !=
m_nlsr.getConfParameter().getRouterPrefix()) {
@ -235,18 +235,17 @@ Lsdb::doesNameLsaExist(const ndn::Name& key)
}
void
Lsdb::printNameLsdb()
Lsdb::writeNameLsdbLog()
{
cout << "---------------Name LSDB-------------------" << endl;
_LOG_DEBUG("---------------Name LSDB-------------------");
for (std::list<NameLsa>::iterator it = m_nameLsdb.begin();
it != m_nameLsdb.end() ; it++) {
cout << (*it) << endl;
(*it).writeLog();
}
}
// Cor LSA and LSDB related Functions start here
static bool
corLsaCompareByKey(const CoordinateLsa& clsa, const ndn::Name& key)
{
@ -310,10 +309,10 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
if (chkCorLsa == 0) {
_LOG_DEBUG("New Coordinate LSA. Adding to LSDB");
_LOG_DEBUG("Adding Coordinate Lsa");
clsa.writeLog();
addCoordinateLsa(clsa);
//debugging purpose
printCorLsdb();
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
clsa.getOrigRouter());
@ -332,7 +331,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
else {
if (chkCorLsa->getLsSeqNo() < clsa.getLsSeqNo()) {
_LOG_DEBUG("Updated Coordinate LSA. Updating LSDB");
_LOG_DEBUG("Old Coordinate LSA");
_LOG_DEBUG("Deleting Coordinate Lsa");
chkCorLsa->writeLog();
chkCorLsa->setLsSeqNo(clsa.getLsSeqNo());
chkCorLsa->setExpirationTimePoint(clsa.getExpirationTimePoint());
@ -352,7 +351,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(clsa.getKey(),
clsa.getLsSeqNo(),
timeToExpire));
_LOG_DEBUG("Updated Coordinate LSA");
_LOG_DEBUG("Adding Coordinate Lsa");
chkCorLsa->writeLog();
}
}
@ -381,7 +380,7 @@ Lsdb::removeCoordinateLsa(const ndn::Name& key)
ndn::bind(corLsaCompareByKey,
_1, key));
if (it != m_corLsdb.end()) {
_LOG_DEBUG("Removing Coordinate LSA");
_LOG_DEBUG("Deleting Coordinate Lsa");
(*it).writeLog();
if ((*it).getOrigRouter() !=
m_nlsr.getConfParameter().getRouterPrefix()) {
@ -407,18 +406,16 @@ Lsdb::doesCoordinateLsaExist(const ndn::Name& key)
return true;
}
//debugging
void
Lsdb::printCorLsdb()
Lsdb::writeCorLsdbLog()
{
cout << "---------------Cor LSDB-------------------" << endl;
_LOG_DEBUG("---------------Cor LSDB-------------------");
for (std::list<CoordinateLsa>::iterator it = m_corLsdb.begin();
it != m_corLsdb.end() ; it++) {
cout << (*it) << endl;
(*it).writeLog();
}
}
// Adj LSA and LSDB related function starts here
static bool
@ -427,11 +424,9 @@ adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
return alsa.getKey() == key;
}
void
Lsdb::scheduledAdjLsaBuild()
{
std::cout << "scheduledAdjLsaBuild Called" << endl;
_LOG_DEBUG("scheduledAdjLsaBuild Called");
m_nlsr.setIsBuildAdjLsaSheduled(false);
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
@ -520,6 +515,7 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
if (chkAdjLsa == 0) {
_LOG_DEBUG("New Adj LSA. Adding to LSDB");
_LOG_DEBUG("Adding Adj Lsa");
alsa.writeLog();
addAdjLsa(alsa);
alsa.addNptEntries(m_nlsr);
@ -535,7 +531,7 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
else {
if (chkAdjLsa->getLsSeqNo() < alsa.getLsSeqNo()) {
_LOG_DEBUG("Updated Adj LSA. Updating LSDB");
_LOG_DEBUG("Old Adj LSA");
_LOG_DEBUG("Deleting Adj Lsa");
chkAdjLsa->writeLog();
chkAdjLsa->setLsSeqNo(alsa.getLsSeqNo());
chkAdjLsa->setExpirationTimePoint(alsa.getExpirationTimePoint());
@ -553,7 +549,7 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(alsa.getKey(),
alsa.getLsSeqNo(),
timeToExpire));
_LOG_DEBUG("Updated Adj LSA");
_LOG_DEBUG("Adding Adj Lsa");
chkAdjLsa->writeLog();
}
}
@ -585,7 +581,7 @@ Lsdb::removeAdjLsa(const ndn::Name& key)
m_adjLsdb.end(),
ndn::bind(adjLsaCompareByKey, _1, key));
if (it != m_adjLsdb.end()) {
_LOG_DEBUG("Removing Adj LSA");
_LOG_DEBUG("Deleting Adj Lsa");
(*it).writeLog();
(*it).removeNptEntries(m_nlsr);
m_adjLsdb.erase(it);
@ -627,22 +623,20 @@ Lsdb::setThisRouterPrefix(string trp)
void
Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
{
std::cout << "Lsdb::exprireOrRefreshNameLsa Called " << std::endl;
std::cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << std::endl;
_LOG_DEBUG("Lsdb::exprireOrRefreshNameLsa Called");
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
NameLsa* chkNameLsa = findNameLsa(lsaKey);
if (chkNameLsa != 0) {
std::cout << "LSA Exists with seq no: " << chkNameLsa->getLsSeqNo() << std::endl;
_LOG_DEBUG("LSA Exists with seq no: " << chkNameLsa->getLsSeqNo());
if (chkNameLsa->getLsSeqNo() == seqNo) {
if (chkNameLsa->getOrigRouter() == m_thisRouterPrefix) {
_LOG_DEBUG("Own Name LSA, so refreshing it");
_LOG_DEBUG("Deleting Name Lsa");
chkNameLsa->writeLog();
std::cout << "Own Name LSA, so refreshing name LSA" << std::endl;
_LOG_DEBUG("Own Name LSA, so refreshing name LSA");
chkNameLsa->setLsSeqNo(chkNameLsa->getLsSeqNo() + 1);
m_nlsr.getSequencingManager().setNameLsaSeq(chkNameLsa->getLsSeqNo());
chkNameLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
_LOG_DEBUG("Adding Name Lsa");
chkNameLsa->writeLog();
// schedule refreshing event again
chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(chkNameLsa->getKey(),
@ -655,7 +649,6 @@ Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
lsaPrefix);
}
else {
std::cout << "Other's Name LSA, so removing form LSDB" << std::endl;
_LOG_DEBUG("Other's Name LSA, so removing form LSDB");
removeNameLsa(lsaKey);
}
@ -666,21 +659,21 @@ Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
void
Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
{
cout << "Lsdb::exprireOrRefreshAdjLsa Called " << endl;
cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
_LOG_DEBUG("Lsdb::exprireOrRefreshAdjLsa Called");
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
AdjLsa* chkAdjLsa = findAdjLsa(lsaKey);
if (chkAdjLsa != 0) {
cout << "LSA Exists with seq no: " << chkAdjLsa->getLsSeqNo() << endl;
_LOG_DEBUG("LSA Exists with seq no: ");
_LOG_DEBUG("LSA Exists with seq no: " << chkAdjLsa->getLsSeqNo());
if (chkAdjLsa->getLsSeqNo() == seqNo) {
if (chkAdjLsa->getOrigRouter() == m_thisRouterPrefix) {
cout << "Own Adj LSA, so refreshing Adj LSA" << endl;
_LOG_DEBUG("Own Adj LSA, so refreshing Adj LSA");
_LOG_DEBUG("Own Adj LSA, so refreshing it");
_LOG_DEBUG("Deleting Adj Lsa");
chkAdjLsa->writeLog();
chkAdjLsa->setLsSeqNo(chkAdjLsa->getLsSeqNo() + 1);
m_nlsr.getSequencingManager().setAdjLsaSeq(chkAdjLsa->getLsSeqNo());
chkAdjLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
_LOG_DEBUG("Adding Adj Lsa");
chkAdjLsa->writeLog();
// schedule refreshing event again
chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(chkAdjLsa->getKey(),
chkAdjLsa->getLsSeqNo(),
@ -692,7 +685,6 @@ Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
lsaPrefix);
}
else {
cout << "Other's Adj LSA, so removing form LSDB" << endl;
_LOG_DEBUG("Other's Adj LSA, so removing form LSDB");
removeAdjLsa(lsaKey);
}
@ -706,21 +698,21 @@ void
Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
uint64_t seqNo)
{
cout << "Lsdb::exprireOrRefreshCorLsa Called " << endl;
cout << "LSA Key : " << lsaKey << " Seq No: " << seqNo << endl;
_LOG_DEBUG("Lsdb::exprireOrRefreshCorLsa Called ");
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
CoordinateLsa* chkCorLsa = findCoordinateLsa(lsaKey);
if (chkCorLsa != 0) {
cout << " LSA Exists with seq no: " << chkCorLsa->getLsSeqNo() << endl;
_LOG_DEBUG("LSA Exists with seq no: " << chkCorLsa->getLsSeqNo());
if (chkCorLsa->getLsSeqNo() == seqNo) {
if (chkCorLsa->getOrigRouter() == m_thisRouterPrefix) {
cout << "Own Cor LSA, so refreshing Cor LSA" << endl;
_LOG_DEBUG("Own Cor LSA, so refreshing Cor LSA");
_LOG_DEBUG("Own Cor LSA, so refreshing it");
_LOG_DEBUG("Deleting Coordinate Lsa");
chkCorLsa->writeLog();
chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
_LOG_DEBUG("Adding Coordinate Lsa");
chkCorLsa->writeLog();
// schedule refreshing event again
chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(
chkCorLsa->getKey(),
@ -733,7 +725,6 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
lsaPrefix);
}
else {
cout << "Other's Cor LSA, so removing form LSDB" << endl;
_LOG_DEBUG("Other's Cor LSA, so removing form LSDB");
removeCoordinateLsa(lsaKey);
}
@ -749,7 +740,6 @@ void
Lsdb::expressInterest(const ndn::Name& interestName, uint32_t interestLifeTime,
uint32_t timeoutCount)
{
std::cout << "Expressing Interest :" << interestName << std::endl;
_LOG_DEBUG("Expressing Interest for LSA(name): " << interestName);
ndn::Interest interest(interestName);
interest.setInterestLifetime(ndn::time::seconds(interestLifeTime));
@ -765,7 +755,6 @@ 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;
_LOG_DEBUG("Interest recevied for LSA(name): " << intName);
string chkString("LSA");
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(),
@ -777,10 +766,6 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
interest.getName().size() - lsaPosition - 3);
interestedLsType = intName[-2].toUri();
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),
@ -800,7 +785,7 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
return;
}
else {
cout << "Unrecognized LSA Type :(" << endl;
_LOG_DEBUG("Unrecognized LSA Type :(");
}
}
}
@ -878,7 +863,6 @@ void
Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
{
const ndn::Name& dataName = data->getName();
std::cout << "Data received for name: " << dataName << std::endl;
_LOG_DEBUG("Data received for LSA(name): " << dataName);
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
string chkString("LSA");
@ -890,9 +874,6 @@ Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
dataName.size() - lsaPosition - 4);
interestedLsType = dataName[-3].toUri();
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);
@ -909,7 +890,7 @@ Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
return;
}
else {
cout << "Unrecognized LSA Type :(" << endl;
_LOG_DEBUG("Unrecognized LSA Type :(");
}
}
}
@ -917,7 +898,7 @@ Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
void
Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, const std::string& msg)
{
std::cerr << "Validation Error: " << msg << std::endl;
_LOG_DEBUG("Validation Error: " << msg);
}
void
@ -930,7 +911,7 @@ Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
installNameLsa(nameLsa);
}
else {
std::cout << "LSA data decoding error :(" << std::endl;
_LOG_DEBUG("LSA data decoding error :(");
}
}
}
@ -945,7 +926,7 @@ Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
installAdjLsa(adjLsa);
}
else {
std::cout << "LSA data decoding error :(" << std::endl;
_LOG_DEBUG("LSA data decoding error :(");
}
}
}
@ -960,7 +941,7 @@ Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
installCoordinateLsa(corLsa);
}
else {
std::cout << "LSA data decoding error :(" << std::endl;
_LOG_DEBUG("LSA data decoding error :(");
}
}
}
@ -989,12 +970,12 @@ Lsdb::getLsaExpirationTimePoint()
}
void
Lsdb::printAdjLsdb()
Lsdb::writeAdjLsdbLog()
{
cout << "---------------Adj LSDB-------------------" << endl;
_LOG_DEBUG("---------------Adj LSDB-------------------");
for (std::list<AdjLsa>::iterator it = m_adjLsdb.begin();
it != m_adjLsdb.end() ; it++) {
cout << (*it) << endl;
(*it).writeLog();
}
}

9
src/lsdb.hpp

@ -62,9 +62,8 @@ public:
bool
isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
//debugging
void
printNameLsdb();
writeNameLsdbLog();
//function related to Cor LSDB
bool
@ -82,9 +81,8 @@ public:
bool
isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
//debugging
void
printCorLsdb();
writeCorLsdbLog();
//function related to Adj LSDB
void
@ -108,9 +106,8 @@ public:
getAdjLsdb();
void
printAdjLsdb();
writeAdjLsdbLog();
//void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
void
setLsaRefreshTime(int lrt);

11
src/name-prefix-list.cpp

@ -93,15 +93,4 @@ NamePrefixList::writeLog()
}
}
void
NamePrefixList::print()
{
int i = 1;
for (std::list<ndn::Name>::iterator it = m_nameList.begin();
it != m_nameList.end(); it++) {
cout << "Name " << i << " : " << (*it) << endl;
i++;
}
}
}//namespace nlsr

3
src/name-prefix-list.hpp

@ -62,9 +62,6 @@ public:
void
writeLog();
void
print();
private:
std::list<ndn::Name> m_nameList;

5
src/nlsr.cpp

@ -104,11 +104,6 @@ Nlsr::initialize()
m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
m_sequencingManager.initiateSeqNoFromFile();
/* debugging purpose start */
cout << m_confParam;
m_adjacencyList.print();
m_namePrefixList.print();
/* debugging purpose end */
/* Logging start */
m_confParam.writeLog();
m_adjacencyList.writeLog();

44
src/route/face-map.cpp

@ -0,0 +1,44 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
* See AUTHORS.md for complete list of NLSR authors and contributors.
*
* NLSR is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
*
**/
#include <iostream>
#include <list>
#include <utility>
#include "logger.hpp"
#include "face-map.hpp"
namespace nlsr {
INIT_LOGGER("FaceMap");
void
FaceMap::writeLog()
{
_LOG_DEBUG("------- Face Map-----------");
for(std::list<FaceMapEntry>::iterator it = m_table.begin();
it != m_table.end(); ++it) {
_LOG_DEBUG("Face Map Entry (FaceUri: " << (*it).getFaceUri() << " Face Id: "
<< (*it).getFaceId() << ")");
}
}
} // namespace NLSR

21
src/route/face-map.hpp

@ -23,6 +23,8 @@
#ifndef NLSR_FACE_MAP_HPP
#define NLSR_FACE_MAP_HPP
#include <ndn-cxx/common.hpp>
namespace nlsr {
class FaceMapEntry {
@ -69,14 +71,6 @@ private:
uint32_t m_faceId;
};
inline std::ostream&
operator<<(std::ostream& os, const FaceMapEntry& fme)
{
os << "Face Map Entry (FaceUri: " << fme.getFaceUri() << " Face Id: ";
os << fme.getFaceId() << ")" << std::endl;
return os;
}
class FaceMap {
public:
@ -118,15 +112,8 @@ public:
return 0;
}
inline void
print()
{
std::cout << "------- Face Map-----------" << std::endl;
for(std::list<FaceMapEntry>::iterator it = m_table.begin();
it != m_table.end(); ++it) {
std::cout << (*it);
}
}
void
writeLog();
private:
std::list<FaceMapEntry> m_table;

9
src/route/fib-entry.cpp

@ -64,13 +64,4 @@ FibEntry::writeLog()
m_nexthopList.writeLog();
}
ostream&
operator<<(ostream& os, FibEntry fe)
{
os << "Name Prefix: " << fe.getName() << endl;
os << "Time to Refresh: " << fe.getExpirationTimePoint() << endl;
os << fe.getNexthopList() << endl;
return os;
}
}//namespace nlsr

3
src/route/fib-entry.hpp

@ -116,9 +116,6 @@ private:
NexthopList m_nexthopList;
};
std::ostream&
operator<<(std::ostream& os, FibEntry fe);
} //namespace nlsr
#endif //NLSR_FIB_ENTRY_HPP

34
src/route/fib.cpp

@ -56,8 +56,6 @@ ndn::EventId
Fib::scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
const ndn::time::seconds& expTime)
{
std::cout << "Fib::scheduleEntryRefreshing Called" << std::endl;
std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
_LOG_DEBUG("Fib::scheduleEntryRefreshing Called");
_LOG_DEBUG("Name: " << name << " Seq Num: " << feSeqNum);
return m_nlsr.getScheduler().scheduleEvent(expTime,
@ -68,15 +66,13 @@ Fib::scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
void
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;
_LOG_DEBUG("Fib::refreshEntry Called");
_LOG_DEBUG("Name: " << name << " Seq Num: " << feSeqNum);
std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
m_table.end(),
bind(&fibEntryNameCompare, _1, name));
if (it != m_table.end()) {
std::cout << "Entry found with Seq Num: " << feSeqNum << std::endl;
if (it->getSeqNo() == feSeqNum) {
std::cout << "Refreshing the FIB entry" << std::endl;
_LOG_DEBUG("Refreshing the FIB entry. Name: " << name);
for (std::list<NextHop>::iterator nhit =
(*it).getNexthopList().getNextHops().begin();
@ -117,8 +113,6 @@ Fib::remove(const ndn::Name& name)
}
}
}
std::cout << "Cancellling Scheduled event" << std::endl;
std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
_LOG_DEBUG("Cancelling Scheduled event. Name: " << name);
cancelScheduledExpiringEvent((*it).getExpiringEventId());
m_table.erase(it);
@ -129,7 +123,6 @@ Fib::remove(const ndn::Name& name)
void
Fib::update(const ndn::Name& name, NexthopList& nextHopList)
{
std::cout << "Fib::updateFib Called" << std::endl;
_LOG_DEBUG("Fib::updateFib Called");
int startFace = 0;
int endFace = getNumberOfFacesForName(nextHopList,
@ -160,7 +153,7 @@ Fib::update(const ndn::Name& name, NexthopList& nextHopList)
}
}
else {
std::cout << "Old FIB Entry" << std::endl;
_LOG_DEBUG("Old FIB Entry");
if (nextHopList.getSize() > 0) {
nextHopList.sort();
if (!it->isEqualNextHops(nextHopList)) {
@ -184,8 +177,6 @@ Fib::update(const ndn::Name& name, NexthopList& nextHopList)
ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
expirationTimePoint = expirationTimePoint + ndn::time::seconds(m_refreshTime);
it->setExpirationTimePoint(expirationTimePoint);
std::cout << "Cancellling Scheduled event" << std::endl;
std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
_LOG_DEBUG("Cancelling Scheduled event. Name: " << name);
cancelScheduledExpiringEvent(it->getExpiringEventId());
it->setSeqNo(it->getSeqNo() + 1);
@ -207,9 +198,6 @@ Fib::clean()
_LOG_DEBUG("Fib::clean called");
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;
_LOG_DEBUG("Cancelling Scheduled event. Name: " << it->getName());
cancelScheduledExpiringEvent((*it).getExpiringEventId());
for (std::list<NextHop>::iterator nhit =
@ -339,9 +327,8 @@ void
Fib::onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
const std::string& message, const std::string& faceUri)
{
//std::cout << message << ": " << commandSuccessResult << std::endl;
m_faceMap.update(faceUri, commandSuccessResult.getFaceId());
m_faceMap.print();
m_faceMap.writeLog();
}
@ -349,14 +336,13 @@ void
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)
{
std::cout << message << ": " << error << " (code: " << code << ")";
_LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
}
void
@ -369,14 +355,4 @@ Fib::writeLog()
}
}
void
Fib::print()
{
cout << "-------------------FIB-----------------------------" << endl;
for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
++it) {
cout << (*it);
}
}
} //namespace nlsr

3
src/route/fib.hpp

@ -66,9 +66,6 @@ public:
m_refreshTime = fert;
}
void
print();
private:
void
removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,

8
src/route/map-entry.hpp

@ -64,14 +64,6 @@ private:
int32_t m_mappingNumber;
};
inline std::ostream&
operator<<(std::ostream& os, const MapEntry& mpe)
{
os << "MapEntry: ( Router: " << mpe.getRouter() << " Mapping No: ";
os << mpe.getMappingNumber() << " )" << std::endl;
return os;
}
} // namespace nlsr
#endif // NLSR_MAP_ENTRY_HPP

17
src/route/map.cpp

@ -28,9 +28,11 @@
#include "lsa.hpp"
#include "lsdb.hpp"
#include "map.hpp"
#include "logger.hpp"
namespace nlsr {
INIT_LOGGER("Map");
using namespace std;
static bool
@ -117,15 +119,14 @@ Map::reset()
m_mappingIndex = 0;
}
ostream&
operator<<(ostream& os, Map& map)
void
Map::writeLog()
{
os << "---------------Map----------------------" << endl;
std::list<MapEntry> ml = map.getMapList();
for (std::list<MapEntry>::iterator it = ml.begin(); it != ml.end() ; it++) {
os << (*it);
_LOG_DEBUG("---------------Map----------------------");
for (std::list<MapEntry>::iterator it = m_table.begin(); it != m_table.end() ; it++) {
_LOG_DEBUG("MapEntry: ( Router: " << (*it).getRouter() << " Mapping No: "
<< (*it).getMappingNumber() << " )");
}
return os;
}
} //namespace nlsr

5
src/route/map.hpp

@ -71,6 +71,8 @@ public:
return m_table.size();
}
void
writeLog();
private:
bool
@ -80,8 +82,5 @@ private:
std::list<MapEntry> m_table;
};
std::ostream&
operator<<(std::ostream& os, Map& map);
} // namespace nlsr
#endif //NLSR_MAP_HPP

14
src/route/name-prefix-table-entry.cpp

@ -103,18 +103,4 @@ NamePrefixTableEntry::writeLog()
m_nexthopList.writeLog();
}
//debugging purpose
ostream&
operator<<(ostream& os, NamePrefixTableEntry& npte)
{
os << "Name: " << npte.getNamePrefix() << endl;
std::list<RoutingTableEntry> rteList = npte.getRteList();
for (std::list<RoutingTableEntry>::iterator it = rteList.begin();
it != rteList.end(); ++it) {
cout << (*it);
}
os << npte.getNexthopList();
return os;
}
}//namespace nlsr

3
src/route/name-prefix-table-entry.hpp

@ -97,9 +97,6 @@ private:
NexthopList m_nexthopList;
};
std::ostream&
operator<<(std::ostream& os, NamePrefixTableEntry& npte);
}//namespace nlsr
#endif //NLSR_NAME_PREFIX_TABLE_ENTRY_HPP

11
src/route/name-prefix-table.cpp

@ -164,15 +164,4 @@ NamePrefixTable::writeLog()
}
}
void
NamePrefixTable::print()
{
std::cout << "----------------NPT----------------------" << std::endl;
for (std::list<NamePrefixTableEntry>::iterator it = m_table.begin();
it != m_table.end();
++it) {
cout << (*it) << endl;
}
}
} //namespace nlsr

3
src/route/name-prefix-table.hpp

@ -52,9 +52,6 @@ public:
void
writeLog();
void
print();
private:
void
addEntry(const ndn::Name& name, RoutingTableEntry& rte);

12
src/route/nexthop-list.cpp

@ -105,16 +105,4 @@ NexthopList::writeLog()
}
}
ostream&
operator<<(ostream& os, NexthopList& nhl)
{
std::list<NextHop> nexthopList = nhl.getNextHops();
int i = 1;
for (std::list<NextHop>::iterator it = nexthopList.begin();
it != nexthopList.end() ; it++, i++) {
os << "Nexthop " << i << ": " << (*it) << endl;
}
return os;
}
}//namespace nlsr

3
src/route/nexthop-list.hpp

@ -79,9 +79,6 @@ private:
std::list<NextHop> m_nexthopList;
};
std::ostream&
operator<<(std::ostream& os, NexthopList& nhl);
}//namespace nlsr
#endif //NLSR_NEXTHOP_LIST_HPP

9
src/route/nexthop.hpp

@ -71,15 +71,6 @@ private:
double m_routeCost;
};
inline std::ostream&
operator<<(std::ostream& os, const NextHop& nh)
{
os << "Face: " << nh.getConnectingFaceUri() << " Route Cost: " <<
nh.getRouteCost();
return os;
}
}//namespace nlsr
#endif //NLSR_NEXTHOP_HPP

59
src/route/routing-table-calculator.cpp

@ -28,9 +28,11 @@
#include "lsa.hpp"
#include "nexthop.hpp"
#include "nlsr.hpp"
#include "logger.hpp"
namespace nlsr {
INIT_LOGGER("RoutingTableCalculator");
using namespace std;
void
@ -72,13 +74,15 @@ RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
}
void
RoutingTableCalculator::printAdjMatrix()
RoutingTableCalculator::writeAdjMatrixLog()
{
for (int i = 0; i < numOfRouter; i++) {
string line="";
for (int j = 0; j < numOfRouter; j++) {
printf("%f ", adjMatrix[i][j]);
line += boost::lexical_cast<std::string>(adjMatrix[i][j]);
line += " ";
}
printf("\n");
_LOG_DEBUG(line);
}
}
@ -159,22 +163,18 @@ void
LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
RoutingTable& rt, Nlsr& pnlsr)
{
std::cout << "LinkStateRoutingTableCalculator::calculatePath Called" <<
std::endl;
_LOG_DEBUG("LinkStateRoutingTableCalculator::calculatePath Called");
allocateAdjMatrix();
initMatrix();
makeAdjMatrix(pnlsr, pMap);
std::cout << pMap;
printAdjMatrix();
//printAdjMatrix();
writeAdjMatrixLog();
int sourceRouter = pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix());
//int noLink=getNumOfLinkfromAdjMatrix(sourceRouter);
allocateParent();
allocateDistance();
if (pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1) {
// Single Path
doDijkstraPathCalculation(sourceRouter);
// print all ls path -- debugging purpose
printAllLsPath(sourceRouter);
// update routing table
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
}
@ -186,10 +186,8 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
for (int i = 0 ; i < vNoLink; i++) {
adjustAdMatrix(sourceRouter, links[i], linkCosts[i]);
printAdjMatrix();
writeAdjMatrixLog();
doDijkstraPathCalculation(sourceRouter);
// print all ls path -- debugging purpose
printAllLsPath(sourceRouter);
//update routing table
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
}
@ -243,8 +241,7 @@ void
LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr,
RoutingTable& rt, Map& pMap, int sourceRouter)
{
std::cout <<
"LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called";
_LOG_DEBUG("LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called");
std::cout << std::endl;
int nextHopRouter = 0;
for (int i = 0; i < numOfRouter ; i++) {
@ -255,11 +252,6 @@ LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr,
ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
std::string nextHopFace =
pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFaceUri();
std::cout << "Dest Router: " << pMap.getRouterNameByMappingNo(i) << std::endl;
std::cout << "Next hop Router: " << nextHopRouterName << std::endl;
std::cout << "Next hop Face: " << nextHopFace << std::endl;
std::cout << "Route Cost: " << routeCost << std::endl;
std::cout << std::endl;
// Add next hop to routing table
NextHop nh(nextHopFace, routeCost);
rt.addNextHop(pMap.getRouterNameByMappingNo(i), nh);
@ -282,32 +274,10 @@ LinkStateRoutingTableCalculator::getLsNextHop(int dest, int source)
return nextHop;
}
void
LinkStateRoutingTableCalculator::printAllLsPath(int sourceRouter)
{
std::cout << "LinkStateRoutingTableCalculator::printAllLsPath Called" <<
std::endl;
std::cout << "Source Router: " << sourceRouter << std::endl;
for (int i = 0; i < numOfRouter ; i++) {
if (i != sourceRouter) {
printLsPath(i);
std::cout << std::endl;
}
}
}
void
LinkStateRoutingTableCalculator::printLsPath(int destRouter)
{
if (m_parent[destRouter] != EMPTY_PARENT) {
printLsPath(m_parent[destRouter]);
}
std:: cout << " " << destRouter;
}
void
LinkStateRoutingTableCalculator::sortQueueByDistance(int* Q,
double* dist, int start, int element)
double* dist,
int start, int element)
{
for (int i = start ; i < element ; i++) {
for (int j = i + 1; j < element; j++) {
@ -364,6 +334,7 @@ HypRoutingTableCalculator::calculatePath(Map& pMap,
RoutingTable& rt, Nlsr& pnlsr)
{
makeAdjMatrix(pnlsr, pMap);
//std::cout << pMap;
ndn::Name routerName = pnlsr.getConfParameter().getRouterPrefix();
int sourceRouter = pMap.getMappingNoByRouterName(routerName);
int noLink = getNumOfLinkfromAdjMatrix(sourceRouter);

11
src/route/routing-table-calculator.hpp

@ -52,9 +52,12 @@ protected:
void
makeAdjMatrix(Nlsr& pnlsr, Map pMap);
/*
void
printAdjMatrix();
*/
void
writeAdjMatrixLog();
int
getNumOfLinkfromAdjMatrix(int sRouter);
@ -122,12 +125,6 @@ private:
int
isNotExplored(int* Q, int u, int start, int element);
void
printAllLsPath(int sourceRouter);
void
printLsPath(int destRouter);
void
addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
Map& pMap, int sourceRouter);

14
src/route/routing-table-entry.hpp

@ -62,20 +62,6 @@ private:
NexthopList m_nexthopList;
};
inline std::ostream&
operator<<(std::ostream& os, RoutingTableEntry& rte)
{
os << "Destination: " << rte.getDestination() << std::endl;
os << "Nexthops: " << std::endl;
int32_t i = 1;
std::list<NextHop> nhl = rte.getNexthopList().getNextHops();
for (std::list<NextHop>::iterator it = nhl.begin();
it != nhl.end() ; it++, i++) {
os << " Nexthop " << i << ": " << (*it) << std::endl;
}
return os;
}
} //namespace nlsr
#endif //NLSR_ROUTING_TABLE_ENTRY_HPP

52
src/route/routing-table.cpp

@ -42,11 +42,9 @@ using namespace std;
void
RoutingTable::calculate(Nlsr& pnlsr)
{
//debugging purpose
pnlsr.getNamePrefixTable().print();
pnlsr.getLsdb().printAdjLsdb();
pnlsr.getLsdb().printCorLsdb();
pnlsr.getLsdb().printNameLsdb();
pnlsr.getLsdb().writeCorLsdbLog();
pnlsr.getLsdb().writeNameLsdbLog();
pnlsr.getLsdb().writeAdjLsdbLog();
pnlsr.getNamePrefixTable().writeLog();
if (pnlsr.getIsRoutingTableCalculating() == false) {
//setting routing table calculation
@ -55,7 +53,6 @@ RoutingTable::calculate(Nlsr& pnlsr)
pnlsr.getConfParameter().getRouterPrefix().toUri() + "/" + "adjacency",
std::string("adjacency"))) {
if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
std::cout << "CLearing old routing table ....." << std::endl;
_LOG_DEBUG("CLearing old routing table .....");
clearRoutingTable();
// for dry run options
@ -74,37 +71,25 @@ RoutingTable::calculate(Nlsr& pnlsr)
calculateHypDryRoutingTable(pnlsr);
}
//need to update NPT here
_LOG_DEBUG("Calling Update NPT With new Route");
pnlsr.getNamePrefixTable().updateWithNewRoute();
//debugging purpose
printRoutingTable();
pnlsr.getNamePrefixTable().print();
pnlsr.getFib().print();
writeLog();
pnlsr.getNamePrefixTable().writeLog();
pnlsr.getFib().writeLog();
//debugging purpose end
}
else {
std::cout << "Adjacency building is scheduled, so ";
std::cout << "routing table can not be calculated :(" << std::endl;
_LOG_DEBUG("Adjacency building is scheduled, so"
" routing table can not be calculated :(");
}
}
else {
std::cout << "No Adj LSA of router itself,";
std::cout << " so Routing table can not be calculated :(" << std::endl;
_LOG_DEBUG("No Adj LSA of router itself,"
" so Routing table can not be calculated :(");
clearRoutingTable();
clearDryRoutingTable(); // for dry run options
// need to update NPT here
std::cout << "Calling Update NPT With new Route" << std::endl;
_LOG_DEBUG("Calling Update NPT With new Route");
pnlsr.getNamePrefixTable().updateWithNewRoute();
//debugging purpose
printRoutingTable();
pnlsr.getNamePrefixTable().print();
pnlsr.getFib().print();
writeLog();
pnlsr.getNamePrefixTable().writeLog();
pnlsr.getFib().writeLog();
@ -122,9 +107,10 @@ RoutingTable::calculate(Nlsr& pnlsr)
void
RoutingTable::calculateLsRoutingTable(Nlsr& pnlsr)
{
std::cout << "RoutingTable::calculateLsRoutingTable Called" << std::endl;
_LOG_DEBUG("RoutingTable::calculateLsRoutingTable Called");
Map vMap;
vMap.createFromAdjLsdb(pnlsr);
vMap.writeLog();
int numOfRouter = vMap.getMapSize();
LinkStateRoutingTableCalculator lsrtc(numOfRouter);
lsrtc.calculatePath(vMap, ndn::ref(*this), pnlsr);
@ -135,6 +121,7 @@ RoutingTable::calculateHypRoutingTable(Nlsr& pnlsr)
{
Map vMap;
vMap.createFromAdjLsdb(pnlsr);
vMap.writeLog();
int numOfRouter = vMap.getMapSize();
HypRoutingTableCalculator hrtc(numOfRouter, 0);
hrtc.calculatePath(vMap, ndn::ref(*this), pnlsr);
@ -145,6 +132,7 @@ RoutingTable::calculateHypDryRoutingTable(Nlsr& pnlsr)
{
Map vMap;
vMap.createFromAdjLsdb(pnlsr);
vMap.writeLog();
int numOfRouter = vMap.getMapSize();
HypRoutingTableCalculator hrtc(numOfRouter, 1);
hrtc.calculatePath(vMap, ndn::ref(*this), pnlsr);
@ -207,17 +195,6 @@ RoutingTable::writeLog()
}
}
void
RoutingTable::printRoutingTable()
{
std::cout << "---------------Routing Table------------------" << std::endl;
for (std::list<RoutingTableEntry>::iterator it = m_rTable.begin() ;
it != m_rTable.end(); ++it) {
std::cout << (*it) << std::endl;
}
}
//function related to manipulation of dry routing table
void
RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
@ -236,17 +213,6 @@ RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
}
}
void
RoutingTable::printDryRoutingTable()
{
std::cout << "--------Dry Run's Routing Table--------------" << std::endl;
for (std::list<RoutingTableEntry>::iterator it = m_dryTable.begin() ;
it != m_dryTable.end(); ++it) {
cout << (*it) << endl;
}
}
void
RoutingTable::clearRoutingTable()
{

6
src/route/routing-table.hpp

@ -48,15 +48,9 @@ public:
void
addNextHop(const ndn::Name& destRouter, NextHop& nh);
void
printRoutingTable();
void
addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
void
printDryRoutingTable();
RoutingTableEntry*
findRoutingTableEntry(const ndn::Name& destRouter);

17
src/sequencing-manager.cpp

@ -65,7 +65,7 @@ SequencingManager::writeSeqNoToFile()
void
SequencingManager::initiateSeqNoFromFile()
{
cout << "Seq File Name: " << m_seqFileNameWithPath << endl;
_LOG_DEBUG("Seq File Name: " << m_seqFileNameWithPath);
std::ifstream inputFile(m_seqFileNameWithPath.c_str(), ios::binary);
if (inputFile.good()) {
inputFile >> m_combinedSeqNo;
@ -101,15 +101,14 @@ SequencingManager::getUserHomeDirectory()
return homeDirPath;
}
ostream&
operator<<(ostream& os, const SequencingManager& sm)
void
SequencingManager::writeLog()
{
std::cout << "----SequencingManager----" << std::endl;
std::cout << "Adj LSA seq no: " << sm.getAdjLsaSeq() << endl;
std::cout << "Cor LSA Seq no: " << sm.getCorLsaSeq() << endl;
std::cout << "Name LSA Seq no: " << sm.getNameLsaSeq() << endl;
std::cout << "Combined LSDB Seq no: " << sm.getCombinedSeqNo() << endl;
return os;
_LOG_DEBUG("----SequencingManager----");
_LOG_DEBUG("Adj LSA seq no: " << m_adjLsaSeq);
_LOG_DEBUG("Cor LSA Seq no: " << m_corLsaSeq);
_LOG_DEBUG("Name LSA Seq no: " << m_nameLsaSeq);
_LOG_DEBUG("Combined LSDB Seq no: " << m_combinedSeqNo);
}
}//namespace nlsr

7
src/sequencing-manager.hpp

@ -133,6 +133,9 @@ public:
std::string
getUserHomeDirectory();
void
writeLog();
private:
void
splittSequenceNo(uint64_t seqNo);
@ -148,9 +151,5 @@ private:
std::string m_seqFileNameWithPath;
};
std::ostream&
operator<<(std::ostream& os, const SequencingManager& sm);
}//namespace nlsr
#endif //NLSR_SEQUENCING_MANAGER_HPP

Loading…
Cancel
Save