Do not distribute coordinate LSAs when using link-state routing.
refs: #3661
Change-Id: I6a1467225def5ba04e2179480503cfe01968cede
diff --git a/src/communication/sync-logic-handler.cpp b/src/communication/sync-logic-handler.cpp
index 1434aa4..d99b3e1 100644
--- a/src/communication/sync-logic-handler.cpp
+++ b/src/communication/sync-logic-handler.cpp
@@ -201,8 +201,7 @@
update.getSequencingManager().writeLog();
- try {
- if (isLsaNew(originRouter, NameLsa::TYPE_STRING, update.getNameLsaSeqNo())) {
+ if (isLsaNew(originRouter, NameLsa::TYPE_STRING, update.getNameLsaSeqNo())) {
_LOG_DEBUG("Received sync update with higher Name LSA sequence number than entry in LSDB");
expressInterestForLsa(update, NameLsa::TYPE_STRING, update.getNameLsaSeqNo());
@@ -210,20 +209,29 @@
if (isLsaNew(originRouter, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo())) {
_LOG_DEBUG("Received sync update with higher Adj LSA sequence number than entry in LSDB");
-
- expressInterestForLsa(update, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo());
+ if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
+ if (update.getAdjLsaSeqNo() != 0) {
+ _LOG_ERROR("Tried to fetch an adjacency LSA when hyperbolic routing"
+ << " is enabled.");
+ }
+ }
+ else {
+ expressInterestForLsa(update, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo());
+ }
}
if (isLsaNew(originRouter, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo())) {
_LOG_DEBUG("Received sync update with higher Cor LSA sequence number than entry in LSDB");
-
- expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
+ if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
+ if (update.getCorLsaSeqNo() != 0) {
+ _LOG_ERROR("Tried to fetch a coordinate LSA when link-state"
+ << " is enabled.");
+ }
+ }
+ else {
+ expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
+ }
}
- }
- catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- return;
- }
}
}
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index 72949c7..d6833ed 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -86,7 +86,7 @@
MAX_FACES_PER_PREFIX_MAX = 60
};
-enum {
+enum HyperbolicState {
HYPERBOLIC_STATE_OFF = 0,
HYPERBOLIC_STATE_ON = 1,
HYPERBOLIC_STATE_DRY_RUN = 2,
diff --git a/src/lsdb.cpp b/src/lsdb.cpp
index 8d7f1ec..5b1fda6 100644
--- a/src/lsdb.cpp
+++ b/src/lsdb.cpp
@@ -359,8 +359,15 @@
getLsaExpirationTimePoint(),
m_nlsr.getConfParameter().getCorR(),
m_nlsr.getConfParameter().getCorTheta());
- m_nlsr.getSequencingManager().increaseCorLsaSeq();
+
+ // Sync coordinate LSAs if using HR or HR dry run.
+ if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
+ m_nlsr.getSequencingManager().increaseCorLsaSeq();
+ m_sync.publishRoutingUpdate();
+ }
+
installCoordinateLsa(corLsa);
+
return true;
}
@@ -411,11 +418,12 @@
clsa.writeLog();
addCoordinateLsa(clsa);
+ // Register the LSA's origin router prefix
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
clsa.getOrigRouter());
}
- if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
+ if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
}
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
@@ -479,12 +487,12 @@
_1, key));
if (it != m_corLsdb.end()) {
_LOG_DEBUG("Deleting Coordinate Lsa");
- (*it).writeLog();
- if ((*it).getOrigRouter() !=
- m_nlsr.getConfParameter().getRouterPrefix()) {
- m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
- (*it).getOrigRouter());
+ it->writeLog();
+
+ if (it->getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
+ m_nlsr.getNamePrefixTable().removeEntry(it->getOrigRouter(), it->getOrigRouter());
}
+
m_corLsdb.erase(it);
return true;
}
@@ -533,6 +541,11 @@
{
m_nlsr.incrementAdjBuildCount();
+ if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
+ // Don't build adjacency LSAs in hyperbolic routing
+ return;
+ }
+
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
_LOG_DEBUG("Scheduling Adjacency LSA build in " << m_adjLsaBuildInterval);
@@ -681,9 +694,11 @@
m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
m_nlsr.getAdjacencyList());
- m_nlsr.getSequencingManager().increaseAdjLsaSeq();
-
- m_sync.publishRoutingUpdate();
+ //Sync adjacency LSAs if link-state or dry-run HR is enabled.
+ if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_ON) {
+ m_nlsr.getSequencingManager().increaseAdjLsaSeq();
+ m_sync.publishRoutingUpdate();
+ }
return installAdjLsa(adjLsa);
}
@@ -815,7 +830,10 @@
_LOG_DEBUG("Deleting Coordinate Lsa");
chkCorLsa->writeLog();
chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
- m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
+ if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
+ m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
+ }
+
chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
_LOG_DEBUG("Adding Coordinate Lsa");
chkCorLsa->writeLog();
@@ -824,13 +842,16 @@
chkCorLsa->getKey(),
chkCorLsa->getLsSeqNo(),
m_lsaRefreshTime));
- m_sync.publishRoutingUpdate();
+ // Only sync coordinate LSAs if link-state routing is disabled
+ if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
+ m_sync.publishRoutingUpdate();
+ }
}
else {
_LOG_DEBUG("Other's Cor LSA, so removing form LSDB");
removeCoordinateLsa(lsaKey);
}
- if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
+ if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
}
}
@@ -934,6 +955,10 @@
const ndn::Name& lsaKey,
uint64_t seqNo)
{
+ if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
+ _LOG_ERROR("Received interest for an adjacency LSA when hyperbolic routing is enabled.");
+ }
+
AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
if (adjLsa != 0) {
if (adjLsa->getLsSeqNo() == seqNo) {
@@ -948,6 +973,10 @@
const ndn::Name& lsaKey,
uint64_t seqNo)
{
+ if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
+ _LOG_ERROR("Received Interest for a coordinate LSA when link-state routing is enabled.");
+ }
+
CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
if (corLsa != 0) {
if (corLsa->getLsSeqNo() == seqNo) {
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index a6039e4..6753a13 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -183,7 +183,7 @@
m_nlsrLsdb.setThisRouterPrefix(m_confParam.getRouterPrefix().toUri());
m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
- m_sequencingManager.initiateSeqNoFromFile();
+ m_sequencingManager.initiateSeqNoFromFile(m_confParam.getHyperbolicState());
m_syncLogicHandler.createSyncSocket(m_confParam.getChronosyncPrefix());
@@ -204,7 +204,11 @@
m_routingTable.setRoutingCalcInterval(m_confParam.getRoutingCalcInterval());
m_nlsrLsdb.buildAndInstallOwnNameLsa();
- m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
+
+ // Install coordinate LSAs if using HR or dry-run HR.
+ if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
+ m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
+ }
registerKeyPrefix();
registerLocalhostPrefix();
diff --git a/src/sequencing-manager.cpp b/src/sequencing-manager.cpp
index 7749ae0..2bffc28 100644
--- a/src/sequencing-manager.cpp
+++ b/src/sequencing-manager.cpp
@@ -62,15 +62,34 @@
}
void
-SequencingManager::initiateSeqNoFromFile()
+SequencingManager::initiateSeqNoFromFile(int hypState)
{
_LOG_DEBUG("Seq File Name: " << m_seqFileNameWithPath);
std::ifstream inputFile(m_seqFileNameWithPath.c_str(), ios::binary);
if (inputFile.good()) {
inputFile >> m_combinedSeqNo;
splitSequenceNo(m_combinedSeqNo);
- m_adjLsaSeq += 10;
- m_corLsaSeq += 10;
+
+ // Increment the adjacency LSA seq. no. if link-state or dry HR is enabled
+ if (hypState != HYPERBOLIC_STATE_ON) {
+ if (m_corLsaSeq != 0) {
+ _LOG_WARN("This router was previously configured for hyperbolic"
+ << " routing without clearing the seq. no. file.");
+ m_corLsaSeq = 0;
+ }
+ m_adjLsaSeq += 10;
+ }
+
+ // Similarly, increment the coordinate LSA seq. no only if link-state is disabled.
+ if (hypState != HYPERBOLIC_STATE_OFF) {
+ if (m_adjLsaSeq != 0 &&
+ hypState == HYPERBOLIC_STATE_ON) {
+ _LOG_WARN("This router was previously configured for link-state"
+ << " routing without clearing the seq. no. file.");
+ m_adjLsaSeq = 0;
+ }
+ m_corLsaSeq += 10;
+ }
m_nameLsaSeq += 10;
combineSequenceNo();
inputFile.close();
@@ -111,5 +130,3 @@
}
}//namespace nlsr
-
-
diff --git a/src/sequencing-manager.hpp b/src/sequencing-manager.hpp
index c023b38..32793d7 100644
--- a/src/sequencing-manager.hpp
+++ b/src/sequencing-manager.hpp
@@ -28,7 +28,10 @@
#include <ndn-cxx/face.hpp>
+#include "conf-parameter.hpp"
+
namespace nlsr {
+
class SequencingManager
{
public:
@@ -124,7 +127,7 @@
writeSeqNoToFile() const;
void
- initiateSeqNoFromFile();
+ initiateSeqNoFromFile(int hypState);
void
setSeqFileName(std::string filePath);