Switch to Face::getIoContext() and simplify some code
Change-Id: Iba49171f6e59ead02283e8f975219ab97fcbeb00
This commit is contained in:
1 parent
5849ee7582
commit
fd1e940648
7 files changed
+62
-105
No files matched your search
+26
-52
@@ -1,6 +1,6 @@
|
|||||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-2021, The University of Memphis,
|
* Copyright (c) 2014-2023, The University of Memphis,
|
||||||
* Regents of the University of California,
|
* Regents of the University of California,
|
||||||
* Arizona Board of Regents.
|
* Arizona Board of Regents.
|
||||||
*
|
*
|
||||||
@@ -43,9 +43,9 @@ Adjacent
|
|||||||
AdjacencyList::getAdjacent(const ndn::Name& adjName)
|
AdjacencyList::getAdjacent(const ndn::Name& adjName)
|
||||||
{
|
{
|
||||||
Adjacent adj(adjName);
|
Adjacent adj(adjName);
|
||||||
std::list<Adjacent>::iterator it = find(adjName);
|
auto it = find(adjName);
|
||||||
if (it != m_adjList.end()) {
|
if (it != m_adjList.end()) {
|
||||||
return (*it);
|
return *it;
|
||||||
}
|
}
|
||||||
return adj;
|
return adj;
|
||||||
}
|
}
|
||||||
@@ -60,56 +60,47 @@ AdjacencyList::operator==(const AdjacencyList& adl) const
|
|||||||
|
|
||||||
std::set<Adjacent> ourSet(m_adjList.cbegin(), m_adjList.cend());
|
std::set<Adjacent> ourSet(m_adjList.cbegin(), m_adjList.cend());
|
||||||
std::set<Adjacent> theirSet(theirList.cbegin(), theirList.cend());
|
std::set<Adjacent> theirSet(theirList.cbegin(), theirList.cend());
|
||||||
|
|
||||||
return ourSet == theirSet;
|
return ourSet == theirSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AdjacencyList::isNeighbor(const ndn::Name& adjName) const
|
AdjacencyList::isNeighbor(const ndn::Name& adjName) const
|
||||||
{
|
{
|
||||||
std::list<Adjacent>::const_iterator it = find(adjName);
|
return find(adjName) != m_adjList.end();
|
||||||
if (it == m_adjList.end())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AdjacencyList::incrementTimedOutInterestCount(const ndn::Name& neighbor)
|
AdjacencyList::incrementTimedOutInterestCount(const ndn::Name& neighbor)
|
||||||
{
|
{
|
||||||
std::list<Adjacent>::iterator it = find(neighbor);
|
auto it = find(neighbor);
|
||||||
if (it == m_adjList.end()) {
|
if (it != m_adjList.end()) {
|
||||||
return ;
|
it->setInterestTimedOutNo(it->getInterestTimedOutNo() + 1);
|
||||||
}
|
}
|
||||||
(*it).setInterestTimedOutNo((*it).getInterestTimedOutNo() + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor,
|
AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count)
|
||||||
uint32_t count)
|
|
||||||
{
|
{
|
||||||
std::list<Adjacent>::iterator it = find(neighbor);
|
auto it = find(neighbor);
|
||||||
if (it != m_adjList.end()) {
|
if (it != m_adjList.end()) {
|
||||||
(*it).setInterestTimedOutNo(count);
|
it->setInterestTimedOutNo(count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor) const
|
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor) const
|
||||||
{
|
{
|
||||||
std::list<Adjacent>::const_iterator it = find(neighbor);
|
auto it = find(neighbor);
|
||||||
if (it == m_adjList.end()) {
|
if (it == m_adjList.end()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return (*it).getInterestTimedOutNo();
|
return it->getInterestTimedOutNo();
|
||||||
}
|
}
|
||||||
|
|
||||||
Adjacent::Status
|
Adjacent::Status
|
||||||
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
|
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
|
||||||
{
|
{
|
||||||
std::list<Adjacent>::const_iterator it = find(neighbor);
|
auto it = find(neighbor);
|
||||||
|
|
||||||
if (it == m_adjList.end()) {
|
if (it == m_adjList.end()) {
|
||||||
return Adjacent::STATUS_UNKNOWN;
|
return Adjacent::STATUS_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -121,7 +112,7 @@ AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
|
|||||||
void
|
void
|
||||||
AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status)
|
AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status)
|
||||||
{
|
{
|
||||||
std::list<Adjacent>::iterator it = find(neighbor);
|
auto it = find(neighbor);
|
||||||
if (it != m_adjList.end()) {
|
if (it != m_adjList.end()) {
|
||||||
it->setStatus(status);
|
it->setStatus(status);
|
||||||
}
|
}
|
||||||
@@ -144,8 +135,7 @@ AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
|||||||
{
|
{
|
||||||
uint32_t nTimedOutNeighbors = 0;
|
uint32_t nTimedOutNeighbors = 0;
|
||||||
|
|
||||||
for (const Adjacent& adjacency : m_adjList) {
|
for (const auto& adjacency : m_adjList) {
|
||||||
|
|
||||||
if (adjacency.getStatus() == Adjacent::STATUS_ACTIVE) {
|
if (adjacency.getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -154,12 +144,7 @@ AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nTimedOutNeighbors == m_adjList.size()) {
|
return nTimedOutNeighbors == m_adjList.size();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
@@ -177,54 +162,43 @@ AdjacencyList::getNumOfActiveNeighbor() const
|
|||||||
std::list<Adjacent>::iterator
|
std::list<Adjacent>::iterator
|
||||||
AdjacencyList::find(const ndn::Name& adjName)
|
AdjacencyList::find(const ndn::Name& adjName)
|
||||||
{
|
{
|
||||||
return std::find_if(m_adjList.begin(),
|
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||||
m_adjList.end(),
|
|
||||||
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<Adjacent>::const_iterator
|
std::list<Adjacent>::const_iterator
|
||||||
AdjacencyList::find(const ndn::Name& adjName) const
|
AdjacencyList::find(const ndn::Name& adjName) const
|
||||||
{
|
{
|
||||||
return std::find_if(m_adjList.cbegin(),
|
return std::find_if(m_adjList.cbegin(), m_adjList.cend(),
|
||||||
m_adjList.cend(),
|
|
||||||
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
AdjacencyList::iterator
|
AdjacencyList::iterator
|
||||||
AdjacencyList::findAdjacent(const ndn::Name& adjName)
|
AdjacencyList::findAdjacent(const ndn::Name& adjName)
|
||||||
{
|
{
|
||||||
return std::find_if(m_adjList.begin(),
|
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||||
m_adjList.end(),
|
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||||
std::bind(&Adjacent::compare,
|
|
||||||
_1, std::cref(adjName)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AdjacencyList::iterator
|
AdjacencyList::iterator
|
||||||
AdjacencyList::findAdjacent(uint64_t faceId)
|
AdjacencyList::findAdjacent(uint64_t faceId)
|
||||||
{
|
{
|
||||||
return std::find_if(m_adjList.begin(),
|
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||||
m_adjList.end(),
|
std::bind(&Adjacent::compareFaceId, _1, faceId));
|
||||||
std::bind(&Adjacent::compareFaceId,
|
|
||||||
_1, faceId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AdjacencyList::iterator
|
AdjacencyList::iterator
|
||||||
AdjacencyList::findAdjacent(const ndn::FaceUri& faceUri)
|
AdjacencyList::findAdjacent(const ndn::FaceUri& faceUri)
|
||||||
{
|
{
|
||||||
return std::find_if(m_adjList.begin(),
|
return std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||||
m_adjList.end(),
|
std::bind(&Adjacent::compareFaceUri, _1, faceUri));
|
||||||
std::bind(&Adjacent::compareFaceUri,
|
|
||||||
_1, faceUri));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
AdjacencyList::getFaceId(const ndn::FaceUri& faceUri)
|
AdjacencyList::getFaceId(const ndn::FaceUri& faceUri)
|
||||||
{
|
{
|
||||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
auto it = std::find_if(m_adjList.begin(), m_adjList.end(),
|
||||||
m_adjList.end(),
|
std::bind(&Adjacent::compareFaceUri, _1, faceUri));
|
||||||
std::bind(&Adjacent::compareFaceUri,
|
|
||||||
_1, faceUri));
|
|
||||||
|
|
||||||
return it != m_adjList.end() ? it->getFaceId() : 0;
|
return it != m_adjList.end() ? it->getFaceId() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-12
@@ -1,6 +1,6 @@
|
|||||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-2022, The University of Memphis,
|
* Copyright (c) 2014-2023, The University of Memphis,
|
||||||
* Regents of the University of California
|
* Regents of the University of California
|
||||||
*
|
*
|
||||||
* This file is part of NLSR (Named-data Link State Routing).
|
* This file is part of NLSR (Named-data Link State Routing).
|
||||||
@@ -34,7 +34,7 @@ HelloProtocol::HelloProtocol(ndn::Face& face, ndn::KeyChain& keyChain,
|
|||||||
ConfParameter& confParam, RoutingTable& routingTable,
|
ConfParameter& confParam, RoutingTable& routingTable,
|
||||||
Lsdb& lsdb)
|
Lsdb& lsdb)
|
||||||
: m_face(face)
|
: m_face(face)
|
||||||
, m_scheduler(m_face.getIoService())
|
, m_scheduler(m_face.getIoContext())
|
||||||
, m_keyChain(keyChain)
|
, m_keyChain(keyChain)
|
||||||
, m_signingInfo(confParam.getSigningInfo())
|
, m_signingInfo(confParam.getSigningInfo())
|
||||||
, m_confParam(confParam)
|
, m_confParam(confParam)
|
||||||
@@ -72,8 +72,7 @@ HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
|
|||||||
interest.setCanBePrefix(true);
|
interest.setCanBePrefix(true);
|
||||||
m_face.expressInterest(interest,
|
m_face.expressInterest(interest,
|
||||||
std::bind(&HelloProtocol::onContent, this, _1, _2),
|
std::bind(&HelloProtocol::onContent, this, _1, _2),
|
||||||
[this, seconds] (const ndn::Interest& interest, const ndn::lp::Nack& nack)
|
[this, seconds] (const auto& interest, const auto& nack) {
|
||||||
{
|
|
||||||
NDN_LOG_TRACE("Received Nack with reason: " << nack.getReason());
|
NDN_LOG_TRACE("Received Nack with reason: " << nack.getReason());
|
||||||
NDN_LOG_TRACE("Will treat as timeout in " << 2 * seconds << " seconds");
|
NDN_LOG_TRACE("Will treat as timeout in " << 2 * seconds << " seconds");
|
||||||
m_scheduler.schedule(ndn::time::seconds(2 * seconds),
|
m_scheduler.schedule(ndn::time::seconds(2 * seconds),
|
||||||
@@ -89,7 +88,6 @@ void
|
|||||||
HelloProtocol::sendHelloInterest(const ndn::Name& neighbor)
|
HelloProtocol::sendHelloInterest(const ndn::Name& neighbor)
|
||||||
{
|
{
|
||||||
auto adjacent = m_adjacencyList.findAdjacent(neighbor);
|
auto adjacent = m_adjacencyList.findAdjacent(neighbor);
|
||||||
|
|
||||||
if (adjacent == m_adjacencyList.end()) {
|
if (adjacent == m_adjacencyList.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,9 +117,9 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
|||||||
// increment RCV_HELLO_INTEREST
|
// increment RCV_HELLO_INTEREST
|
||||||
hpIncrementSignal(Statistics::PacketType::RCV_HELLO_INTEREST);
|
hpIncrementSignal(Statistics::PacketType::RCV_HELLO_INTEREST);
|
||||||
|
|
||||||
NLSR_LOG_DEBUG("Interest Received for Name: " << interestName);
|
NLSR_LOG_DEBUG("Interest received for Name: " << interestName);
|
||||||
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
|
if (interestName.get(-2).toUri() != INFO_COMPONENT) {
|
||||||
NLSR_LOG_DEBUG("INFO_COMPONENT not found or interestName: " << interestName
|
NLSR_LOG_DEBUG("INFO_COMPONENT not found or Interest Name " << interestName
|
||||||
<< " does not match expression");
|
<< " does not match expression");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -130,9 +128,9 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
|||||||
neighbor.wireDecode(interestName.get(-1).blockFromValue());
|
neighbor.wireDecode(interestName.get(-1).blockFromValue());
|
||||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
||||||
if (m_adjacencyList.isNeighbor(neighbor)) {
|
if (m_adjacencyList.isNeighbor(neighbor)) {
|
||||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
auto data = std::make_shared<ndn::Data>();
|
||||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||||
data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
|
data->setFreshnessPeriod(10_s);
|
||||||
data->setContent(ndn::make_span(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.data()),
|
data->setContent(ndn::make_span(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.data()),
|
||||||
INFO_COMPONENT.size()));
|
INFO_COMPONENT.size()));
|
||||||
|
|
||||||
@@ -233,8 +231,8 @@ HelloProtocol::onContentValidated(const ndn::Data& data)
|
|||||||
m_adjacencyList.setTimedOutInterestCount(neighbor, 0);
|
m_adjacencyList.setTimedOutInterestCount(neighbor, 0);
|
||||||
Adjacent::Status newStatus = m_adjacencyList.getStatusOfNeighbor(neighbor);
|
Adjacent::Status newStatus = m_adjacencyList.getStatusOfNeighbor(neighbor);
|
||||||
|
|
||||||
NLSR_LOG_DEBUG("Neighbor : " << neighbor);
|
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
||||||
NLSR_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
|
NLSR_LOG_DEBUG("Old Status: " << oldStatus << ", New Status: " << newStatus);
|
||||||
// change in Adjacency list
|
// change in Adjacency list
|
||||||
if ((oldStatus - newStatus) != 0) {
|
if ((oldStatus - newStatus) != 0) {
|
||||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||||
@@ -254,7 +252,7 @@ void
|
|||||||
HelloProtocol::onContentValidationFailed(const ndn::Data& data,
|
HelloProtocol::onContentValidationFailed(const ndn::Data& data,
|
||||||
const ndn::security::ValidationError& ve)
|
const ndn::security::ValidationError& ve)
|
||||||
{
|
{
|
||||||
NLSR_LOG_DEBUG("Validation Error: " << ve);
|
NLSR_LOG_DEBUG("Validation error: " << ve);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nlsr
|
} // namespace nlsr
|
||||||
+13
-21
@@ -33,7 +33,7 @@ INIT_LOGGER(Lsdb);
|
|||||||
|
|
||||||
Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||||
: m_face(face)
|
: m_face(face)
|
||||||
, m_scheduler(face.getIoService())
|
, m_scheduler(face.getIoContext())
|
||||||
, m_confParam(confParam)
|
, m_confParam(confParam)
|
||||||
, m_sync(m_face, keyChain,
|
, m_sync(m_face, keyChain,
|
||||||
[this] (const auto& routerName, const Lsa::Type& lsaType,
|
[this] (const auto& routerName, const Lsa::Type& lsaType,
|
||||||
@@ -203,7 +203,7 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
|||||||
}
|
}
|
||||||
// else the interest is for other router's LSA, serve signed data from LsaSegmentStorage
|
// else the interest is for other router's LSA, serve signed data from LsaSegmentStorage
|
||||||
else if (auto lsaSegment = m_lsaStorage.find(interest); lsaSegment) {
|
else if (auto lsaSegment = m_lsaStorage.find(interest); lsaSegment) {
|
||||||
NLSR_LOG_TRACE("Found data in lsa storage. Sending data for " << interest.getName());
|
NLSR_LOG_TRACE("Found data in LSA storage. Sending data for " << interest.getName());
|
||||||
m_face.put(*lsaSegment);
|
m_face.put(*lsaSegment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,19 +256,16 @@ Lsdb::installLsa(std::shared_ptr<Lsa> lsa)
|
|||||||
|
|
||||||
auto chkLsa = findLsa(lsa->getOriginRouter(), lsa->getType());
|
auto chkLsa = findLsa(lsa->getOriginRouter(), lsa->getType());
|
||||||
if (chkLsa == nullptr) {
|
if (chkLsa == nullptr) {
|
||||||
NLSR_LOG_DEBUG("Adding " << lsa->getType() << " LSA");
|
NLSR_LOG_DEBUG("Adding LSA:\n" << lsa->toString());
|
||||||
NLSR_LOG_DEBUG(lsa->toString());
|
|
||||||
|
|
||||||
m_lsdb.emplace(lsa);
|
m_lsdb.emplace(lsa);
|
||||||
|
|
||||||
onLsdbModified(lsa, LsdbUpdate::INSTALLED, {}, {});
|
onLsdbModified(lsa, LsdbUpdate::INSTALLED, {}, {});
|
||||||
|
|
||||||
lsa->setExpiringEventId(scheduleLsaExpiration(lsa, timeToExpire));
|
lsa->setExpiringEventId(scheduleLsaExpiration(lsa, timeToExpire));
|
||||||
}
|
}
|
||||||
// Else this is a known name LSA, so we are updating it.
|
// Else this is a known name LSA, so we are updating it.
|
||||||
else if (chkLsa->getSeqNo() < lsa->getSeqNo()) {
|
else if (chkLsa->getSeqNo() < lsa->getSeqNo()) {
|
||||||
NLSR_LOG_DEBUG("Updating " << lsa->getType() << " LSA:");
|
NLSR_LOG_DEBUG("Updating LSA:\n" << chkLsa->toString());
|
||||||
NLSR_LOG_DEBUG(chkLsa->toString());
|
|
||||||
chkLsa->setSeqNo(lsa->getSeqNo());
|
chkLsa->setSeqNo(lsa->getSeqNo());
|
||||||
chkLsa->setExpirationTimePoint(lsa->getExpirationTimePoint());
|
chkLsa->setExpirationTimePoint(lsa->getExpirationTimePoint());
|
||||||
|
|
||||||
@@ -278,8 +275,7 @@ Lsdb::installLsa(std::shared_ptr<Lsa> lsa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
chkLsa->setExpiringEventId(scheduleLsaExpiration(chkLsa, timeToExpire));
|
chkLsa->setExpiringEventId(scheduleLsaExpiration(chkLsa, timeToExpire));
|
||||||
NLSR_LOG_DEBUG("Updated " << lsa->getType() << " LSA:");
|
NLSR_LOG_DEBUG("Updated LSA:\n" << chkLsa->toString());
|
||||||
NLSR_LOG_DEBUG(chkLsa->toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,8 +284,7 @@ Lsdb::removeLsa(const LsaContainer::index<Lsdb::byName>::type::iterator& lsaIt)
|
|||||||
{
|
{
|
||||||
if (lsaIt != m_lsdb.end()) {
|
if (lsaIt != m_lsdb.end()) {
|
||||||
auto lsaPtr = *lsaIt;
|
auto lsaPtr = *lsaIt;
|
||||||
NLSR_LOG_DEBUG("Removing " << lsaPtr->getType() << " LSA:");
|
NLSR_LOG_DEBUG("Removing LSA:\n" << lsaPtr->toString());
|
||||||
NLSR_LOG_DEBUG(lsaPtr->toString());
|
|
||||||
m_lsdb.erase(lsaIt);
|
m_lsdb.erase(lsaIt);
|
||||||
onLsdbModified(lsaPtr, LsdbUpdate::REMOVED, {}, {});
|
onLsdbModified(lsaPtr, LsdbUpdate::REMOVED, {}, {});
|
||||||
}
|
}
|
||||||
@@ -385,13 +380,11 @@ Lsdb::expireOrRefreshLsa(std::shared_ptr<Lsa> lsa)
|
|||||||
if (lsaPtr->getSeqNo() == lsa->getSeqNo()) {
|
if (lsaPtr->getSeqNo() == lsa->getSeqNo()) {
|
||||||
if (lsaPtr->getOriginRouter() == m_thisRouterPrefix) {
|
if (lsaPtr->getOriginRouter() == m_thisRouterPrefix) {
|
||||||
NLSR_LOG_DEBUG("Own " << lsaPtr->getType() << " LSA, so refreshing it");
|
NLSR_LOG_DEBUG("Own " << lsaPtr->getType() << " LSA, so refreshing it");
|
||||||
NLSR_LOG_DEBUG("Current LSA:");
|
NLSR_LOG_DEBUG("Current LSA:\n" << lsaPtr->toString());
|
||||||
NLSR_LOG_DEBUG(lsaPtr->toString());
|
|
||||||
lsaPtr->setSeqNo(lsaPtr->getSeqNo() + 1);
|
lsaPtr->setSeqNo(lsaPtr->getSeqNo() + 1);
|
||||||
m_sequencingManager.setLsaSeq(lsaPtr->getSeqNo(), lsaPtr->getType());
|
m_sequencingManager.setLsaSeq(lsaPtr->getSeqNo(), lsaPtr->getType());
|
||||||
lsaPtr->setExpirationTimePoint(getLsaExpirationTimePoint());
|
lsaPtr->setExpirationTimePoint(getLsaExpirationTimePoint());
|
||||||
NLSR_LOG_DEBUG("Updated LSA:");
|
NLSR_LOG_DEBUG("Updated LSA:\n" << lsaPtr->toString());
|
||||||
NLSR_LOG_DEBUG(lsaPtr->toString());
|
|
||||||
// schedule refreshing event again
|
// schedule refreshing event again
|
||||||
lsaPtr->setExpiringEventId(scheduleLsaExpiration(lsaPtr, m_lsaRefreshTime));
|
lsaPtr->setExpiringEventId(scheduleLsaExpiration(lsaPtr, m_lsaRefreshTime));
|
||||||
m_sequencingManager.writeSeqNoToFile();
|
m_sequencingManager.writeSeqNoToFile();
|
||||||
@@ -490,13 +483,12 @@ Lsdb::onFetchLsaError(uint32_t errorCode, const std::string& msg, const ndn::Nam
|
|||||||
// immediately since at the least the LSA Interest lifetime has elapsed.
|
// immediately since at the least the LSA Interest lifetime has elapsed.
|
||||||
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
||||||
// the potential for constant Interest flooding.
|
// the potential for constant Interest flooding.
|
||||||
ndn::time::seconds delay = m_confParam.getLsaInterestLifetime();
|
auto delay = m_confParam.getLsaInterestLifetime();
|
||||||
|
|
||||||
if (errorCode == ndn::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
if (errorCode == ndn::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||||
delay = ndn::time::seconds(0);
|
delay = 0_s;
|
||||||
}
|
}
|
||||||
m_scheduler.schedule(delay, std::bind(&Lsdb::expressInterest, this,
|
m_scheduler.schedule(delay, std::bind(&Lsdb::expressInterest, this, interestName,
|
||||||
interestName, retransmitNo + 1, /*Multicast FaceID*/0, deadline));
|
retransmitNo + 1, /*Multicast FaceID*/0, deadline));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -559,7 +551,7 @@ Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, const ndn::Name& inter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
NLSR_LOG_TRACE("LSA data decoding error :( " << e.what());
|
NLSR_LOG_TRACE("LSA data decoding error: " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -220,11 +220,11 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
|||||||
\param seqNo The sequence number to check.
|
\param seqNo The sequence number to check.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
isLsaNew(const ndn::Name& originRouter, const Lsa::Type& lsaType, uint64_t lsSeqNo) const
|
isLsaNew(const ndn::Name& originRouter, const Lsa::Type& lsaType, uint64_t seqNo) const
|
||||||
{
|
{
|
||||||
// Is the name in the LSDB and the supplied seq no is the highest so far
|
// Is the name in the LSDB and the supplied seq no is the highest so far
|
||||||
auto lsaPtr = findLsa(originRouter, lsaType);
|
auto lsaPtr = findLsa(originRouter, lsaType);
|
||||||
return lsaPtr ? lsaPtr->getSeqNo() < lsSeqNo : true;
|
return lsaPtr ? lsaPtr->getSeqNo() < seqNo : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+8
-15
@@ -36,7 +36,7 @@ INIT_LOGGER(Nlsr);
|
|||||||
|
|
||||||
Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||||
: m_face(face)
|
: m_face(face)
|
||||||
, m_scheduler(face.getIoService())
|
, m_scheduler(face.getIoContext())
|
||||||
, m_confParam(confParam)
|
, m_confParam(confParam)
|
||||||
, m_adjacencyList(confParam.getAdjacencyList())
|
, m_adjacencyList(confParam.getAdjacencyList())
|
||||||
, m_namePrefixList(confParam.getNamePrefixList())
|
, m_namePrefixList(confParam.getNamePrefixList())
|
||||||
@@ -259,7 +259,7 @@ void
|
|||||||
Nlsr::initializeFaces(const FetchDatasetCallback& onFetchSuccess,
|
Nlsr::initializeFaces(const FetchDatasetCallback& onFetchSuccess,
|
||||||
const FetchDatasetTimeoutCallback& onFetchFailure)
|
const FetchDatasetTimeoutCallback& onFetchFailure)
|
||||||
{
|
{
|
||||||
NLSR_LOG_TRACE("Initializing Faces...");
|
NLSR_LOG_TRACE("Initializing faces");
|
||||||
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(onFetchSuccess, onFetchFailure);
|
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(onFetchSuccess, onFetchFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,12 +317,10 @@ Nlsr::onFaceDatasetFetchTimeout(uint32_t code,
|
|||||||
const std::string& msg,
|
const std::string& msg,
|
||||||
uint32_t nRetriesSoFar)
|
uint32_t nRetriesSoFar)
|
||||||
{
|
{
|
||||||
NLSR_LOG_DEBUG("onFaceDatasetFetchTimeout");
|
|
||||||
// If we have exceeded the maximum attempt count, do not try again.
|
// If we have exceeded the maximum attempt count, do not try again.
|
||||||
if (nRetriesSoFar++ < m_confParam.getFaceDatasetFetchTries()) {
|
if (nRetriesSoFar++ < m_confParam.getFaceDatasetFetchTries()) {
|
||||||
NLSR_LOG_DEBUG("Failed to fetch dataset: " << msg << ". Attempting retry #" << nRetriesSoFar);
|
NLSR_LOG_DEBUG("Failed to fetch dataset: " << msg << ". Attempting retry #" << nRetriesSoFar);
|
||||||
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(std::bind(&Nlsr::processFaceDataset,
|
m_faceDatasetController.fetch<ndn::nfd::FaceDataset>(std::bind(&Nlsr::processFaceDataset, this, _1),
|
||||||
this, _1),
|
|
||||||
std::bind(&Nlsr::onFaceDatasetFetchTimeout,
|
std::bind(&Nlsr::onFaceDatasetFetchTimeout,
|
||||||
this, _1, _2, nRetriesSoFar));
|
this, _1, _2, nRetriesSoFar));
|
||||||
}
|
}
|
||||||
@@ -339,17 +337,12 @@ Nlsr::onFaceDatasetFetchTimeout(uint32_t code,
|
|||||||
void
|
void
|
||||||
Nlsr::scheduleDatasetFetch()
|
Nlsr::scheduleDatasetFetch()
|
||||||
{
|
{
|
||||||
NLSR_LOG_DEBUG("Scheduling Dataset Fetch in " << m_confParam.getFaceDatasetFetchInterval());
|
NLSR_LOG_DEBUG("Scheduling dataset fetch in " << m_confParam.getFaceDatasetFetchInterval());
|
||||||
|
|
||||||
m_scheduler.schedule(m_confParam.getFaceDatasetFetchInterval(),
|
m_scheduler.schedule(m_confParam.getFaceDatasetFetchInterval(), [this] {
|
||||||
[this] {
|
initializeFaces(
|
||||||
this->initializeFaces(
|
[this] (const auto& faces) { processFaceDataset(faces); },
|
||||||
[this] (const std::vector<ndn::nfd::FaceStatus>& faces) {
|
[this] (uint32_t code, const std::string& msg) { onFaceDatasetFetchTimeout(code, msg, 0); });
|
||||||
this->processFaceDataset(faces);
|
|
||||||
},
|
|
||||||
[this] (uint32_t code, const std::string& msg) {
|
|
||||||
this->onFaceDatasetFetchTimeout(code, msg, 0);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
|||||||
|
|
||||||
// Iterate over directly connected neighbors
|
// Iterate over directly connected neighbors
|
||||||
std::list<Adjacent> neighbors = adjacencies.getAdjList();
|
std::list<Adjacent> neighbors = adjacencies.getAdjList();
|
||||||
for (std::list<Adjacent>::iterator adj = neighbors.begin(); adj != neighbors.end(); ++adj) {
|
for (auto adj = neighbors.begin(); adj != neighbors.end(); ++adj) {
|
||||||
|
|
||||||
// Don't calculate nexthops using an inactive router
|
// Don't calculate nexthops using an inactive router
|
||||||
if (adj->getStatus() == Adjacent::STATUS_INACTIVE) {
|
if (adj->getStatus() == Adjacent::STATUS_INACTIVE) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
|||||||
const std::string ADJ_NAME_1 = "testname";
|
const std::string ADJ_NAME_1 = "testname";
|
||||||
const std::string ADJ_NAME_2 = "testname2";
|
const std::string ADJ_NAME_2 = "testname2";
|
||||||
|
|
||||||
//adjacent needed to test adjacency list.
|
// adjacent needed to test adjacency list
|
||||||
Adjacent adjacent1(ADJ_NAME_1);
|
Adjacent adjacent1(ADJ_NAME_1);
|
||||||
Adjacent adjacent2(ADJ_NAME_2);
|
Adjacent adjacent2(ADJ_NAME_2);
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ BOOST_AUTO_TEST_CASE(FindAdjacentByFaceUri)
|
|||||||
AdjacencyList adjList;
|
AdjacencyList adjList;
|
||||||
adjList.insert(adj1);
|
adjList.insert(adj1);
|
||||||
|
|
||||||
std::list<Adjacent>::iterator adjIter = adjList.findAdjacent(faceUri);
|
auto adjIter = adjList.findAdjacent(faceUri);
|
||||||
BOOST_CHECK(adjIter != adjList.end());
|
BOOST_CHECK(adjIter != adjList.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user