src: Replace std::cout with log message
Change-Id: Idf49992711b4bb4a45d8f9665963feebf3b0a887
diff --git a/src/adjacency-list.cpp b/src/adjacency-list.cpp
index c028942..a905a7d 100644
--- a/src/adjacency-list.cpp
+++ b/src/adjacency-list.cpp
@@ -243,14 +243,4 @@
}
}
-// 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
diff --git a/src/adjacency-list.hpp b/src/adjacency-list.hpp
index d9105b4..85bec25 100644
--- a/src/adjacency-list.hpp
+++ b/src/adjacency-list.hpp
@@ -99,9 +99,6 @@
}
void
- print();
-
- void
writeLog();
private:
diff --git a/src/adjacent.cpp b/src/adjacent.cpp
index c4f131b..ddee24f 100644
--- a/src/adjacent.cpp
+++ b/src/adjacent.cpp
@@ -90,15 +90,4 @@
_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
diff --git a/src/adjacent.hpp b/src/adjacent.hpp
index 6d076b5..90a0460 100644
--- a/src/adjacent.hpp
+++ b/src/adjacent.hpp
@@ -125,9 +125,6 @@
uint32_t m_interestTimedOutNo;
};
-std::ostream&
-operator<<(std::ostream& os, const Adjacent& adj);
-
} // namespace nlsr
#endif //NLSR_ADJACENT_HPP
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 65039bf..dea3782 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -37,8 +37,6 @@
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 @@
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 @@
SyncLogicHandler::nsyncRemoveCallBack(const string& prefix, Nlsr& pnlsr)
{
_LOG_DEBUG("nsyncRemoveCallBack called ....");
- std::cout << "nsyncRemoveCallBack called ...." << std::endl;
}
void
@@ -94,11 +88,10 @@
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 @@
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 @@
}
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 @@
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");
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index a45199b..20a6a68 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -405,7 +405,6 @@
}
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;
}
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index 25df9ee..a08377c 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -338,28 +338,6 @@
};
-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
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index 91b68a9..506954c 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -35,7 +35,6 @@
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 @@
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 @@
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 @@
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 @@
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);
diff --git a/src/lsa.cpp b/src/lsa.cpp
index 9c3bf44..2e933ce 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -124,28 +124,9 @@
{
_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 @@
_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 @@
_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
diff --git a/src/lsa.hpp b/src/lsa.hpp
index ed0d870..2137069 100644
--- a/src/lsa.hpp
+++ b/src/lsa.hpp
@@ -162,9 +162,6 @@
};
-std::ostream&
-operator<<(std::ostream& os, NameLsa& nLsa);
-
class AdjLsa: public Lsa
{
public:
@@ -223,9 +220,6 @@
AdjacencyList m_adl;
};
-std::ostream&
-operator<<(std::ostream& os, AdjLsa& aLsa);
-
class CoordinateLsa: public Lsa
{
public:
@@ -286,10 +280,6 @@
};
-std::ostream&
-operator<<(std::ostream& os, const CoordinateLsa& cLsa);
-
-
}//namespace nlsr
#endif //NLSR_LSA_HPP
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index bb1150e..16e7d1a 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -103,10 +103,10 @@
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 @@
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 @@
chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(nlsa.getKey(),
nlsa.getLsSeqNo(),
timeToExpire));
- _LOG_DEBUG("Updated Name LSA");
+ _LOG_DEBUG("Adding Name Lsa");
chkNameLsa->writeLog();
}
}
@@ -203,7 +203,7 @@
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 @@
}
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 @@
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 @@
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 @@
chkCorLsa->setExpiringEventId(scheduleCoordinateLsaExpiration(clsa.getKey(),
clsa.getLsSeqNo(),
timeToExpire));
- _LOG_DEBUG("Updated Coordinate LSA");
+ _LOG_DEBUG("Adding Coordinate Lsa");
chkCorLsa->writeLog();
}
}
@@ -381,7 +380,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(alsa.getKey(),
alsa.getLsSeqNo(),
timeToExpire));
- _LOG_DEBUG("Updated Adj LSA");
+ _LOG_DEBUG("Adding Adj Lsa");
chkAdjLsa->writeLog();
}
}
@@ -585,7 +581,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
return;
}
else {
- cout << "Unrecognized LSA Type :(" << endl;
+ _LOG_DEBUG("Unrecognized LSA Type :(");
}
}
}
@@ -878,7 +863,6 @@
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 @@
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 @@
return;
}
else {
- cout << "Unrecognized LSA Type :(" << endl;
+ _LOG_DEBUG("Unrecognized LSA Type :(");
}
}
}
@@ -917,7 +898,7 @@
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 @@
installNameLsa(nameLsa);
}
else {
- std::cout << "LSA data decoding error :(" << std::endl;
+ _LOG_DEBUG("LSA data decoding error :(");
}
}
}
@@ -945,7 +926,7 @@
installAdjLsa(adjLsa);
}
else {
- std::cout << "LSA data decoding error :(" << std::endl;
+ _LOG_DEBUG("LSA data decoding error :(");
}
}
}
@@ -960,7 +941,7 @@
installCoordinateLsa(corLsa);
}
else {
- std::cout << "LSA data decoding error :(" << std::endl;
+ _LOG_DEBUG("LSA data decoding error :(");
}
}
}
@@ -989,12 +970,12 @@
}
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();
}
}
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 79d6e2c..7c6ceb1 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -62,9 +62,8 @@
bool
isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
- //debugging
void
- printNameLsdb();
+ writeNameLsdbLog();
//function related to Cor LSDB
bool
@@ -82,9 +81,8 @@
bool
isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
- //debugging
void
- printCorLsdb();
+ writeCorLsdbLog();
//function related to Adj LSDB
void
@@ -108,9 +106,8 @@
getAdjLsdb();
void
- printAdjLsdb();
+ writeAdjLsdbLog();
- //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
void
setLsaRefreshTime(int lrt);
diff --git a/src/name-prefix-list.cpp b/src/name-prefix-list.cpp
index 8238732..0be579f 100644
--- a/src/name-prefix-list.cpp
+++ b/src/name-prefix-list.cpp
@@ -93,15 +93,4 @@
}
}
-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
diff --git a/src/name-prefix-list.hpp b/src/name-prefix-list.hpp
index 8d8b1c1..9f50d2e 100644
--- a/src/name-prefix-list.hpp
+++ b/src/name-prefix-list.hpp
@@ -62,9 +62,6 @@
void
writeLog();
- void
- print();
-
private:
std::list<ndn::Name> m_nameList;
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 02a366b..9084d7c 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -104,11 +104,6 @@
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();
diff --git a/src/route/face-map.cpp b/src/route/face-map.cpp
new file mode 100644
index 0000000..7251fc5
--- /dev/null
+++ b/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
diff --git a/src/route/face-map.hpp b/src/route/face-map.hpp
index 2225446..4bc2b68 100644
--- a/src/route/face-map.hpp
+++ b/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 @@
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 @@
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;
diff --git a/src/route/fib-entry.cpp b/src/route/fib-entry.cpp
index aacb0a3..a7eb68f 100644
--- a/src/route/fib-entry.cpp
+++ b/src/route/fib-entry.cpp
@@ -64,13 +64,4 @@
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
diff --git a/src/route/fib-entry.hpp b/src/route/fib-entry.hpp
index 5465ec9..7f39fdd 100644
--- a/src/route/fib-entry.hpp
+++ b/src/route/fib-entry.hpp
@@ -116,9 +116,6 @@
NexthopList m_nexthopList;
};
-std::ostream&
-operator<<(std::ostream& os, FibEntry fe);
-
} //namespace nlsr
#endif //NLSR_FIB_ENTRY_HPP
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 1460dbb..8b5d668 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -56,8 +56,6 @@
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 @@
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 @@
}
}
}
- 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 @@
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 @@
}
}
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 @@
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 @@
_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 @@
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 @@
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 @@
}
}
-void
-Fib::print()
-{
- cout << "-------------------FIB-----------------------------" << endl;
- for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
- ++it) {
- cout << (*it);
- }
-}
-
} //namespace nlsr
diff --git a/src/route/fib.hpp b/src/route/fib.hpp
index b44c86d..9ffd44c 100644
--- a/src/route/fib.hpp
+++ b/src/route/fib.hpp
@@ -66,9 +66,6 @@
m_refreshTime = fert;
}
- void
- print();
-
private:
void
removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
diff --git a/src/route/map-entry.hpp b/src/route/map-entry.hpp
index f2ba05d..f3779e9 100644
--- a/src/route/map-entry.hpp
+++ b/src/route/map-entry.hpp
@@ -64,14 +64,6 @@
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
diff --git a/src/route/map.cpp b/src/route/map.cpp
index 65d004f..a34f415 100644
--- a/src/route/map.cpp
+++ b/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 @@
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
diff --git a/src/route/map.hpp b/src/route/map.hpp
index 09cdeee..8f7d0f4 100644
--- a/src/route/map.hpp
+++ b/src/route/map.hpp
@@ -71,6 +71,8 @@
return m_table.size();
}
+ void
+ writeLog();
private:
bool
@@ -80,8 +82,5 @@
std::list<MapEntry> m_table;
};
-std::ostream&
-operator<<(std::ostream& os, Map& map);
-
} // namespace nlsr
#endif //NLSR_MAP_HPP
diff --git a/src/route/name-prefix-table-entry.cpp b/src/route/name-prefix-table-entry.cpp
index 80008ff..1d20319 100644
--- a/src/route/name-prefix-table-entry.cpp
+++ b/src/route/name-prefix-table-entry.cpp
@@ -103,18 +103,4 @@
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
diff --git a/src/route/name-prefix-table-entry.hpp b/src/route/name-prefix-table-entry.hpp
index ee8df2b..9b25f5e 100644
--- a/src/route/name-prefix-table-entry.hpp
+++ b/src/route/name-prefix-table-entry.hpp
@@ -97,9 +97,6 @@
NexthopList m_nexthopList;
};
-std::ostream&
-operator<<(std::ostream& os, NamePrefixTableEntry& npte);
-
}//namespace nlsr
#endif //NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
diff --git a/src/route/name-prefix-table.cpp b/src/route/name-prefix-table.cpp
index 582c01d..d9c63e4 100644
--- a/src/route/name-prefix-table.cpp
+++ b/src/route/name-prefix-table.cpp
@@ -164,15 +164,4 @@
}
}
-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
diff --git a/src/route/name-prefix-table.hpp b/src/route/name-prefix-table.hpp
index 2596174..fb36ffb 100644
--- a/src/route/name-prefix-table.hpp
+++ b/src/route/name-prefix-table.hpp
@@ -52,9 +52,6 @@
void
writeLog();
- void
- print();
-
private:
void
addEntry(const ndn::Name& name, RoutingTableEntry& rte);
diff --git a/src/route/nexthop-list.cpp b/src/route/nexthop-list.cpp
index 07b7d1f..6159563 100644
--- a/src/route/nexthop-list.cpp
+++ b/src/route/nexthop-list.cpp
@@ -105,16 +105,4 @@
}
}
-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
diff --git a/src/route/nexthop-list.hpp b/src/route/nexthop-list.hpp
index e358166..c34400d 100644
--- a/src/route/nexthop-list.hpp
+++ b/src/route/nexthop-list.hpp
@@ -79,9 +79,6 @@
std::list<NextHop> m_nexthopList;
};
-std::ostream&
-operator<<(std::ostream& os, NexthopList& nhl);
-
}//namespace nlsr
#endif //NLSR_NEXTHOP_LIST_HPP
diff --git a/src/route/nexthop.hpp b/src/route/nexthop.hpp
index 097230f..ecd84fa 100644
--- a/src/route/nexthop.hpp
+++ b/src/route/nexthop.hpp
@@ -71,15 +71,6 @@
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
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 63147a5..1c39d51 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/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 @@
}
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 @@
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 @@
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 @@
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 @@
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);
@@ -283,31 +275,9 @@
}
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 @@
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);
diff --git a/src/route/routing-table-calculator.hpp b/src/route/routing-table-calculator.hpp
index e03b21e..3f1b53f 100644
--- a/src/route/routing-table-calculator.hpp
+++ b/src/route/routing-table-calculator.hpp
@@ -52,9 +52,12 @@
void
makeAdjMatrix(Nlsr& pnlsr, Map pMap);
-
+/*
void
printAdjMatrix();
+*/
+ void
+ writeAdjMatrixLog();
int
getNumOfLinkfromAdjMatrix(int sRouter);
@@ -123,12 +126,6 @@
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);
diff --git a/src/route/routing-table-entry.hpp b/src/route/routing-table-entry.hpp
index d0636e8..aa351ac 100644
--- a/src/route/routing-table-entry.hpp
+++ b/src/route/routing-table-entry.hpp
@@ -62,20 +62,6 @@
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
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 6d632f4..613371f 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -42,11 +42,9 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
}
}
-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)
@@ -237,17 +214,6 @@
}
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()
{
if (m_rTable.size() > 0) {
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index ecf26c9..952a07e 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -49,14 +49,8 @@
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);
diff --git a/src/sequencing-manager.cpp b/src/sequencing-manager.cpp
index 72e0c47..b5bd89c 100644
--- a/src/sequencing-manager.cpp
+++ b/src/sequencing-manager.cpp
@@ -65,7 +65,7 @@
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 @@
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
diff --git a/src/sequencing-manager.hpp b/src/sequencing-manager.hpp
index 48a1f96..50795b2 100644
--- a/src/sequencing-manager.hpp
+++ b/src/sequencing-manager.hpp
@@ -133,6 +133,9 @@
std::string
getUserHomeDirectory();
+ void
+ writeLog();
+
private:
void
splittSequenceNo(uint64_t seqNo);
@@ -148,9 +151,5 @@
std::string m_seqFileNameWithPath;
};
-
-std::ostream&
-operator<<(std::ostream& os, const SequencingManager& sm);
-
}//namespace nlsr
#endif //NLSR_SEQUENCING_MANAGER_HPP