Do not distribute coordinate LSAs when using link-state routing.

refs: #3661

Change-Id: I6a1467225def5ba04e2179480503cfe01968cede
This commit is contained in:
Nick Gordon committed 2016-07-28 12:28:41 -05:00
1 parent aa3b085384
commit 5c467f0ca8
8 files changed
+174 -43

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ if has OSX $NODE_LABELS && ! has OSX-10.8-c++11-64bit $NODE_LABELS; then
brew update
brew upgrade
brew install boost pkg-config sqlite cryptopp log4cxx protobuf openssl
brew link --force openssl
brew link --force openssl log4cxx protobuf
brew cleanup
fi
+19 -11
View File
@@ -201,8 +201,7 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
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 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
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;
}
}
}
+1 -1
View File
@@ -86,7 +86,7 @@ enum {
MAX_FACES_PER_PREFIX_MAX = 60
};
enum {
enum HyperbolicState {
HYPERBOLIC_STATE_OFF = 0,
HYPERBOLIC_STATE_ON = 1,
HYPERBOLIC_STATE_DRY_RUN = 2,
+42 -13
View File
@@ -359,8 +359,15 @@ Lsdb::buildAndInstallOwnCoordinateLsa()
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 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
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 @@ Lsdb::removeCoordinateLsa(const ndn::Name& key)
_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 @@ Lsdb::scheduleAdjLsaBuild()
{
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 @@ Lsdb::buildAndInstallOwnAdjLsa()
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 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
_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 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
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 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
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 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
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) {
+6 -2
View File
@@ -183,7 +183,7 @@ Nlsr::initialize()
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 @@ Nlsr::initialize()
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();
+22 -5
View File
@@ -62,15 +62,34 @@ SequencingManager::writeSeqNoToFile() const
}
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 @@ SequencingManager::writeLog() const
}
}//namespace nlsr
+4 -1
View File
@@ -28,7 +28,10 @@
#include <ndn-cxx/face.hpp>
#include "conf-parameter.hpp"
namespace nlsr {
class SequencingManager
{
public:
@@ -124,7 +127,7 @@ public:
writeSeqNoToFile() const;
void
initiateSeqNoFromFile();
initiateSeqNoFromFile(int hypState);
void
setSeqFileName(std::string filePath);
+79 -9
View File
@@ -49,7 +49,7 @@ public:
}
void
receiveUpdate(std::string prefix, uint64_t seqNo)
receiveUpdate(std::string prefix, uint64_t seqNo, SyncLogicHandler& p_sync)
{
Sync::MissingDataInfo info = {prefix, 0, seqNo};
@@ -59,7 +59,7 @@ public:
face->processEvents(ndn::time::milliseconds(1));
face->sentInterests.clear();
sync.onNsyncUpdate(updates, NULL);
p_sync.onNsyncUpdate(updates, NULL);
face->processEvents(ndn::time::milliseconds(1));
}
@@ -76,17 +76,86 @@ public:
BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
BOOST_AUTO_TEST_CASE(UpdateForOther)
BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
{
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
CONFIG_SITE + "/%C1.Router/other-router/";
receiveUpdate(updateName, 1);
uint64_t syncSeqNo = 1;
receiveUpdate(updateName, syncSeqNo, sync);
std::vector<ndn::Interest>& interests = face->sentInterests;
std::vector<ndn::Interest>::iterator it = interests.begin();
BOOST_REQUIRE_EQUAL(interests.size(), 2);
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
++it;
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
}
BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
{
Nlsr nlsr_hr(g_ioService, g_scheduler, ndn::ref(*face));
SyncLogicHandler& sync_hr(nlsr_hr.getSyncLogicHandler());
nlsr_hr.getConfParameter().setNetwork(CONFIG_NETWORK);
nlsr_hr.getConfParameter().setSiteName(CONFIG_SITE);
nlsr_hr.getConfParameter().setRouterName(CONFIG_ROUTER_NAME);
nlsr_hr.getConfParameter().buildRouterPrefix();
nlsr_hr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
nlsr_hr.initialize();
std::string updateName = nlsr_hr.getConfParameter().getLsaPrefix().toUri() +
CONFIG_SITE + "/%C1.Router/other-router/";
uint64_t syncSeqNo = 0;
syncSeqNo = syncSeqNo | (static_cast<uint64_t>(1) << 20);
receiveUpdate(updateName, syncSeqNo, sync_hr);
std::vector<ndn::Interest>& interests = face->sentInterests;
std::vector<ndn::Interest>::iterator it = interests.begin();
BOOST_REQUIRE_EQUAL(interests.size(), 2);
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
++it;
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
}
BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
{
Nlsr nlsr_hrdry(g_ioService, g_scheduler, ndn::ref(*face));
SyncLogicHandler& sync_hrdry(nlsr_hrdry.getSyncLogicHandler());
nlsr_hrdry.getConfParameter().setNetwork(CONFIG_NETWORK);
nlsr_hrdry.getConfParameter().setSiteName(CONFIG_SITE);
nlsr_hrdry.getConfParameter().setRouterName(CONFIG_ROUTER_NAME);
nlsr_hrdry.getConfParameter().buildRouterPrefix();
nlsr_hrdry.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
nlsr_hrdry.initialize();
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
CONFIG_SITE + "/%C1.Router/other-router/";
uint64_t syncSeqNo = 1;
syncSeqNo = syncSeqNo | (static_cast<uint64_t>(1) << 20);
receiveUpdate(updateName, syncSeqNo, sync_hrdry);
std::vector<ndn::Interest>& interests = face->sentInterests;
std::vector<ndn::Interest>::iterator it = interests.begin();
BOOST_REQUIRE_EQUAL(interests.size(), 3);
std::vector<ndn::Interest>::iterator it = interests.begin();
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
++it;
@@ -94,6 +163,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOther)
++it;
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
}
BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
@@ -101,7 +171,7 @@ BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
CONFIG_SITE + CONFIG_ROUTER_NAME;
receiveUpdate(updateName, 1);
receiveUpdate(updateName, 1, sync);
std::vector<ndn::Interest>& interests = face->sentInterests;
BOOST_CHECK_EQUAL(interests.size(), 0);
@@ -143,21 +213,21 @@ BOOST_AUTO_TEST_CASE(SequenceNumber)
// Lower NameLSA sequence number
uint64_t lowerSeqNo = static_cast<uint64_t>(998) << 40;
receiveUpdate(updateName, lowerSeqNo);
receiveUpdate(updateName, lowerSeqNo, sync);
std::vector<ndn::Interest>& interests = face->sentInterests;
BOOST_REQUIRE_EQUAL(interests.size(), 0);
// Same NameLSA sequence number
uint64_t sameSeqNo = static_cast<uint64_t>(999) << 40;
receiveUpdate(updateName, sameSeqNo);
receiveUpdate(updateName, sameSeqNo, sync);
interests = face->sentInterests;
BOOST_REQUIRE_EQUAL(interests.size(), 0);
// Higher NameLSA sequence number
uint64_t higherSeqNo = static_cast<uint64_t>(1000) << 40;
receiveUpdate(updateName, higherSeqNo);
receiveUpdate(updateName, higherSeqNo, sync);
interests = face->sentInterests;
BOOST_REQUIRE_EQUAL(interests.size(), 1);