Compare commits
35
Commits
NLSR-0.2.2
...
NLSR-0.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f590fecfc2 | ||
|
|
6077ea910c | ||
|
|
d1f4f33cfd | ||
|
|
d8c9d8cdab | ||
|
|
feae5574b8 | ||
|
|
4fc69e49a9 | ||
|
|
c6a852234d | ||
|
|
44395237b8 | ||
|
|
c5fa320239 | ||
|
|
41330f4256 | ||
|
|
96bf2f0db8 | ||
|
|
2b057af9e1 | ||
|
|
b71684744f | ||
|
|
b50e51b374 | ||
|
|
3e5120c543 | ||
|
|
ef21d8eab0 | ||
|
|
97e3494256 | ||
|
|
d69f9a3c82 | ||
|
|
63bd0348b3 | ||
|
|
b9d43d06cc | ||
|
|
e2d3fe9d9a | ||
|
|
7b5872ec86 | ||
|
|
fad8e257c0 | ||
|
|
f8b5bcd27e | ||
|
|
800833b7ac | ||
|
|
e8e03ac303 | ||
|
|
5ec9ae4271 | ||
|
|
f7eec4f4c0 | ||
|
|
5c467f0ca8 | ||
|
|
aa3b085384 | ||
|
|
d02c3880d5 | ||
|
|
3ac0728e5a | ||
|
|
c778e814db | ||
|
|
af909fcc13 | ||
|
|
c69da0a350 |
No files matched your search
@@ -3,7 +3,8 @@ set -e
|
||||
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
for i in $( find "$DIR/.jenkins.d" -type f -perm +111 | sort ); do
|
||||
echo "Run: $i"
|
||||
"$i"
|
||||
for file in "$DIR"/.jenkins.d/*; do
|
||||
[[ -f $file && -x $file ]] || continue
|
||||
echo "Run: $file"
|
||||
"$file"
|
||||
done
|
||||
@@ -10,6 +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 log4cxx protobuf
|
||||
brew cleanup
|
||||
fi
|
||||
|
||||
|
||||
+19
-9
@@ -1,15 +1,25 @@
|
||||
sudo: true
|
||||
language: cpp
|
||||
os:
|
||||
- linux
|
||||
compiler:
|
||||
- gcc
|
||||
sudo: required
|
||||
language: generic
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=g++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: osx
|
||||
osx_image: xcode8.2
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="OSX OSX-10.12"
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
on_failure: always
|
||||
env:
|
||||
global:
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-12.04 Ubuntu-12.04-64bit Boost1.48"
|
||||
script:
|
||||
- ./.jenkins
|
||||
@@ -108,6 +108,7 @@ class GccBasicFlags(CompilerFlags):
|
||||
'-Werror',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-error=maybe-uninitialized', # Bug #1615
|
||||
'-Wno-error=deprecated-declarations', # Bug #3795
|
||||
]
|
||||
return flags
|
||||
|
||||
|
||||
+9
-3
@@ -28,6 +28,9 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* Minsheng Zhang <mzhang4@memphis.edu>
|
||||
* Syed Obaid Amin <http://obaidamin.weebly.com/>
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
* Muktadir R Chowdhury <mrchwdhr@memphis.edu>
|
||||
* Nicholas Gordon <nmgordon@memphis.edu>
|
||||
* Laqin Fan <lfan1@memphis.edu>
|
||||
|
||||
* University of California, Los Angeles
|
||||
|
||||
@@ -36,9 +39,12 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* Spyridon Mastorakis <http://cs.ucla.edu/~mastorakis/>
|
||||
* Jiewen Tan <alanwake@ucla.edu>
|
||||
|
||||
* University of Arizona
|
||||
|
||||
* Junxiao Shi <https://www.cs.arizona.edu/people/shijunxiao/>
|
||||
|
||||
|
||||
## Queries about NLSR
|
||||
|
||||
Any general question related to NLSR should be directed to Vince Lehman
|
||||
(vslehman@memphis.edu) and security related question should be directed to
|
||||
Yingdi Yu (yingdi@cs.ucla.edu)
|
||||
Any question related to NLSR should be directed to Ashlesh Gawande (agawande@memphis.edu),
|
||||
Muktadir R Chowdhury (mrchwdhr@memphis.edu), and Nicholas Gordon (nmgordon@memphis.edu).
|
||||
@@ -1,6 +1,69 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
NLSR version 0.3.1 (changes since version 0.3.0)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: January 22, 2016
|
||||
|
||||
**Changes**
|
||||
|
||||
- **breaking change** Sync uses /localhop component in prefix to reduce duplicate NACKs (:issue:`3627`)
|
||||
|
||||
- **breaking change** LSA uses /localhop component in prefix to reduce duplicate NACKs (:issue:`3899`)
|
||||
|
||||
**Code Changes**:
|
||||
|
||||
- Fib and FaceMap use std::map instead of std::list (:issue:`2781`)
|
||||
|
||||
- NamePrefixTableEntries store RoutingTableEntries using a pointer (:issue:`2863`)
|
||||
|
||||
- Namespace closing comments are now consistent with ndn-cxx guidelines (:issue:`3735`)
|
||||
|
||||
- Update copyright date across all files (:issue:`3736`, `3909`, `3923`)
|
||||
|
||||
- Improve formatting of FaceMap and FaceMapEntry (:issue:`3737`)
|
||||
|
||||
- Sort NextHops on NexthopList insertion (:issue:`2721`)
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- HR now recalculates paths after status change of a neighbor (:issue:`3874`)
|
||||
|
||||
- NLSR no longer sets strategies multiple times (:issue:`3743`)
|
||||
|
||||
- NLSR should enable use of ndn-cxx dispatcher (:issue:`3930`)
|
||||
|
||||
- Fix typos in the sample configuration file (:issue:`3113`)
|
||||
|
||||
NLSR version 0.3.0 (changes since version 0.2.2)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: August 1, 2016
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Updated validation checker for LSA rule in the configuration file (:issue:`2965`)
|
||||
|
||||
- Do not advertise Adjacency LSAs when hyperbolic routing is enabled (:issue:`2402`)
|
||||
|
||||
- Do not distribute coordinate LSAs when using link-state routing. (:issue:`3661`)
|
||||
|
||||
- LSAs should be segmented before they are published (:issue:`2965`)
|
||||
|
||||
- Don't use DummyClientFace::sentDatas (:issue:`3383`)
|
||||
|
||||
- Remove disabled security files (:issue:`2960`)
|
||||
|
||||
- Lsa type should be argument for base class LSA constructor (:issue:`2788`)
|
||||
|
||||
- Use ndn-cxx/DummyClientFace (:issue:`2637`)
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- Unit tests cases are installed with `./waf install` (:issue:`3359`)
|
||||
|
||||
|
||||
NLSR version 0.2.2 (changes since version 0.2.1)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ configuration commands follows:
|
||||
log-level INFO ; default value INFO, valid value DEBUG, INFO
|
||||
log-dir /var/log/nlsr/
|
||||
seq-dir /var/lib/nlsr/
|
||||
; log4cxx-conf /path/to/log4cxx-conf
|
||||
}
|
||||
|
||||
; the neighbors section contains the configuration for router's neighbors and hello's behavior
|
||||
@@ -104,6 +105,17 @@ configuration commands follows:
|
||||
|
||||
hello-interval 60 ; interest sending interval in seconds. Default value 60
|
||||
; valid values 30-90
|
||||
|
||||
; adj-lsa-build-interval is the time to wait in seconds after an Adjacency LSA build is scheduled
|
||||
; before actually building the Adjacency LSA
|
||||
|
||||
adj-lsa-build-interval 5 ; default value 5. Valid values 0-5. It is recommended that
|
||||
; adj-lsa-build-interval have a lower value than routing-calc-interval
|
||||
|
||||
; first-hello-interval is the time to wait in seconds before sending the first Hello Interest
|
||||
|
||||
first-hello-interval 10 ; Default value 10. Valid values 0-10
|
||||
|
||||
; neighbor command is used to configure router's neighbor. Each neighbor will need
|
||||
; one block of neighbor command
|
||||
|
||||
|
||||
@@ -408,7 +408,7 @@ EXTRACT_PRIVATE = NO
|
||||
# scope will be included in the documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
EXTRACT_PACKAGE = NO
|
||||
EXTRACT_PACKAGE = YES
|
||||
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file will be
|
||||
# included in the documentation.
|
||||
@@ -2025,7 +2025,7 @@ MSCGEN_PATH =
|
||||
# and usage relations if the target is undocumented or is not a class.
|
||||
# The default value is: YES.
|
||||
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HIDE_UNDOC_RELATIONS = NO
|
||||
|
||||
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
|
||||
# available from the path. This tool is part of Graphviz (see:
|
||||
@@ -2150,7 +2150,7 @@ INCLUDED_BY_GRAPH = YES
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
CALL_GRAPH = NO
|
||||
CALL_GRAPH = YES
|
||||
|
||||
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
|
||||
# dependency graph for every global function or class method.
|
||||
@@ -2161,7 +2161,7 @@ CALL_GRAPH = NO
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
CALLER_GRAPH = NO
|
||||
CALLER_GRAPH = YES
|
||||
|
||||
# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
|
||||
# hierarchy of all classes instead of a textual one.
|
||||
|
||||
@@ -140,7 +140,7 @@ security
|
||||
{
|
||||
rule
|
||||
{
|
||||
id "NSLR Hello Rule"
|
||||
id "NLSR Hello Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
@@ -168,7 +168,7 @@ security
|
||||
|
||||
rule
|
||||
{
|
||||
id "NSLR LSA Rule"
|
||||
id "NLSR LSA Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
@@ -187,7 +187,8 @@ security
|
||||
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><ksk-.*><ID-CERT>$
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><>$
|
||||
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
|
||||
p-expand \\1\\2
|
||||
}
|
||||
}
|
||||
@@ -196,7 +197,7 @@ security
|
||||
|
||||
rule
|
||||
{
|
||||
id "NSLR Hierarchy Exception Rule"
|
||||
id "NLSR Hierarchy Exception Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
@@ -224,7 +225,7 @@ security
|
||||
|
||||
rule
|
||||
{
|
||||
id "NSLR Hierarchical Rule"
|
||||
id "NLSR Hierarchical Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* See COPYING.md for copyright and distribution information.
|
||||
*/
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The 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.
|
||||
|
||||
+20
-21
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,19 +17,16 @@
|
||||
*
|
||||
* 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 <algorithm>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
|
||||
#include "adjacent.hpp"
|
||||
#include "common.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("AdjacencyList");
|
||||
@@ -197,25 +195,26 @@ AdjacencyList::getAdjList()
|
||||
}
|
||||
|
||||
bool
|
||||
AdjacencyList::isAdjLsaBuildable(Nlsr& pnlsr)
|
||||
AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
||||
{
|
||||
uint32_t nbrCount = 0;
|
||||
for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end() ; it++) {
|
||||
uint32_t nTimedOutNeighbors = 0;
|
||||
|
||||
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
nbrCount++;
|
||||
for (const Adjacent& adjacency : m_adjList) {
|
||||
|
||||
if (adjacency.getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if ((*it).getInterestTimedOutNo() >=
|
||||
pnlsr.getConfParameter().getInterestRetryNumber()) {
|
||||
nbrCount++;
|
||||
}
|
||||
else if (adjacency.getInterestTimedOutNo() >= interestRetryNo) {
|
||||
nTimedOutNeighbors++;
|
||||
}
|
||||
}
|
||||
if (nbrCount == m_adjList.size()) {
|
||||
|
||||
if (nTimedOutNeighbors == m_adjList.size()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
@@ -293,4 +292,4 @@ AdjacencyList::writeLog()
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+45
-5
@@ -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-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "adjacent.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
|
||||
class AdjacencyList
|
||||
{
|
||||
@@ -40,9 +39,28 @@ public:
|
||||
AdjacencyList();
|
||||
~AdjacencyList();
|
||||
|
||||
/*! \brief Inserts an adjacency into the list.
|
||||
|
||||
\param adjacent The adjacency that we want to add to this list.
|
||||
|
||||
\retval 0 Indicates success.
|
||||
\retval 1 Indicates failure.
|
||||
|
||||
This function attempts to insert the supplied adjacency into this
|
||||
object, which is an adjacency list.
|
||||
*/
|
||||
int32_t
|
||||
insert(Adjacent& adjacent);
|
||||
|
||||
/*! \brief Sets the status of an adjacency.
|
||||
|
||||
\param adjName The adjacency in this list you want to change the status of.
|
||||
|
||||
\param s The status to change to.
|
||||
|
||||
\return A boolean indicating whether an adjacency was
|
||||
updated. This is false if s is not in the list.
|
||||
*/
|
||||
bool
|
||||
updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s);
|
||||
|
||||
@@ -70,11 +88,33 @@ public:
|
||||
void
|
||||
setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
|
||||
|
||||
/*! \brief Copies the adjacencies in a list to this one.
|
||||
|
||||
\param adl The adjacency list, the entries of which we want to
|
||||
copy into this object.
|
||||
|
||||
Copies the entries contained in one list into this object.
|
||||
*/
|
||||
void
|
||||
addAdjacents(AdjacencyList& adl);
|
||||
|
||||
/*! \brief Determines whether this list can be used to build an adj. LSA.
|
||||
\param interestRetryNo The maximum number of hello-interest
|
||||
retries to contact a neighbor.
|
||||
|
||||
\return Returns a boolean indicating whether this list can be used
|
||||
to build an adj. LSA.
|
||||
|
||||
Determines whether this adjacency list object could be used to
|
||||
build an adjacency LSA. An LSA is buildable when the status of all
|
||||
neighbors is known. A neighbor's status is known when their status
|
||||
is ACTIVE, or INACTIVE and some number of hello interests
|
||||
(specified by nlsr::ConfParameter::getInterestRetryNumber()) have
|
||||
failed. To be explicit, a neighbor's status is unknown if we are
|
||||
still sending hello interests.
|
||||
*/
|
||||
bool
|
||||
isAdjLsaBuildable(Nlsr& pnlsr);
|
||||
isAdjLsaBuildable(const uint32_t interestRetryNo) const;
|
||||
|
||||
int32_t
|
||||
getNumOfActiveNeighbor();
|
||||
@@ -132,5 +172,5 @@ private:
|
||||
std::list<Adjacent> m_adjList;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //NLSR_ADJACENCY_LIST_HPP
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -88,4 +88,4 @@ Adjacent::writeLog()
|
||||
_LOG_DEBUG("Interest Timed out: " << m_interestTimedOutNo);
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
throw Error("Cannot parse update name because expected components are missing");
|
||||
}
|
||||
|
||||
ndn::Name networkName = m_name.getSubName(0, nlsrPosition);
|
||||
ndn::Name networkName = m_name.getSubName(1, nlsrPosition-1);
|
||||
ndn::Name routerName = m_name.getSubName(lsaPosition + 1);
|
||||
|
||||
ndn::Name originRouter = networkName;
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,4 +302,4 @@ SyncLogicHandler::publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqN
|
||||
m_syncSocket->publishData(updateName.toUri(), 0, data.c_str(), data.size(), 1000, seqNo);
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -56,6 +56,11 @@ public:
|
||||
|
||||
SyncLogicHandler(ndn::Face& face, Lsdb& lsdb, ConfParameter& conf, SequencingManager& seqManager);
|
||||
|
||||
/*! \brief Simple wrapper function to handle updates from Sync.
|
||||
|
||||
\param v The information that Sync has acquired.
|
||||
\param socket The socket that Sync is using to synchronize updates.
|
||||
*/
|
||||
void
|
||||
onNsyncUpdate(const std::vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket);
|
||||
|
||||
@@ -104,6 +109,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_SYNC_LOGIC_HANDLER_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -76,5 +76,5 @@ private:
|
||||
Nlsr& m_nlsr;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //CONF_PROCESSOR_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -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,
|
||||
@@ -120,11 +120,13 @@ public:
|
||||
setNetwork(const ndn::Name& networkName)
|
||||
{
|
||||
m_network = networkName;
|
||||
m_chronosyncPrefix = m_network;
|
||||
|
||||
m_chronosyncPrefix.append("localhop");
|
||||
m_chronosyncPrefix.append("NLSR");
|
||||
m_chronosyncPrefix.append("sync");
|
||||
|
||||
m_lsaPrefix = m_network;
|
||||
m_lsaPrefix.append("localhop");
|
||||
m_lsaPrefix.append(m_network);
|
||||
m_lsaPrefix.append("NLSR");
|
||||
m_lsaPrefix.append("LSA");
|
||||
}
|
||||
|
||||
+38
-8
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -20,6 +20,7 @@
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include "nlsr.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "hello-protocol.hpp"
|
||||
@@ -54,6 +55,7 @@ HelloProtocol::sendScheduledInterest(uint32_t seconds)
|
||||
std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList();
|
||||
for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
|
||||
++it) {
|
||||
// If this adjacency has a Face, just proceed as usual.
|
||||
if((*it).getFaceId() != 0) {
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
ndn::Name interestName = (*it).getName() ;
|
||||
@@ -63,6 +65,9 @@ HelloProtocol::sendScheduledInterest(uint32_t seconds)
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
}
|
||||
// If it does not have a Face, we need to give it one. A
|
||||
// successful registration prompts a callback that sends the hello
|
||||
// Interest to the new Face.
|
||||
else {
|
||||
registerPrefixes((*it).getName(), (*it).getConnectingFaceUri(),
|
||||
(*it).getLinkCost(), ndn::time::milliseconds::max());
|
||||
@@ -103,7 +108,9 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
_LOG_DEBUG("Sending out data for name: " << interest.getName());
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor);
|
||||
// If this neighbor was previously inactive, send our own hello interest, too
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_INACTIVE) {
|
||||
// We can only do that if the neighbor currently has a face.
|
||||
if(adjacent->getFaceId() != 0){
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
ndn::Name interestName(neighbor);
|
||||
@@ -113,6 +120,8 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
}
|
||||
// If the originator of the Interest currently lacks a Face, we
|
||||
// need to give it one.
|
||||
else {
|
||||
registerPrefixes(adjacent->getName(), adjacent->getConnectingFaceUri(),
|
||||
adjacent->getLinkCost(), ndn::time::milliseconds::max());
|
||||
@@ -157,6 +166,9 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
}
|
||||
}
|
||||
|
||||
// This is the first function that incoming Hello data will
|
||||
// see. This checks if the data appears to be signed, and passes it
|
||||
// on to validate the content of the data.
|
||||
void
|
||||
HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
{
|
||||
@@ -172,6 +184,11 @@ HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
this, _1, _2));
|
||||
}
|
||||
|
||||
// A validator is called on the incoming data, and if the data
|
||||
// passes the validator's description/definitions, this function is
|
||||
// called. Set the neighbor's status to active and refresh its
|
||||
// LSA. If there was a change in status, we schedule an adjacency
|
||||
// LSA build.
|
||||
void
|
||||
HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
@@ -190,11 +207,18 @@ HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
|
||||
// change in Adjacency list
|
||||
if ((oldStatus - newStatus) != 0) {
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
else {
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simply logs a debug message that the content could not be
|
||||
// validated (and is implicitly being discarded as a result).
|
||||
void
|
||||
HelloProtocol::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg)
|
||||
@@ -202,6 +226,9 @@ HelloProtocol::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>&
|
||||
_LOG_DEBUG("Validation Error: " << msg);
|
||||
}
|
||||
|
||||
|
||||
// Asks the FIB to register the supplied adjacency (in other words,
|
||||
// create a Face for it).
|
||||
void
|
||||
HelloProtocol::registerPrefixes(const ndn::Name& adjName, const std::string& faceUri,
|
||||
double linkCost, const ndn::time::milliseconds& timeout)
|
||||
@@ -211,9 +238,12 @@ HelloProtocol::registerPrefixes(const ndn::Name& adjName, const std::string& fac
|
||||
ndn::bind(&HelloProtocol::onRegistrationSuccess,
|
||||
this, _1, adjName,timeout),
|
||||
ndn::bind(&HelloProtocol::onRegistrationFailure,
|
||||
this, _1, _2, adjName));
|
||||
this, _1, adjName));
|
||||
}
|
||||
|
||||
// After we create a new Face, we need to set it up for use. This
|
||||
// function sets the controlling strategy, registers prefixes in
|
||||
// sync, broadcast, and LSA.
|
||||
void
|
||||
HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const ndn::Name& neighbor,const ndn::time::milliseconds& timeout)
|
||||
@@ -234,8 +264,8 @@ HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandS
|
||||
m_nlsr.getFib().registerPrefix(broadcastKeyPrefix,
|
||||
faceUri, linkCost, timeout,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
m_nlsr.setStrategies();
|
||||
|
||||
// Sends a Hello Interest to determine status before the next scheduled.
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
@@ -247,10 +277,10 @@ HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandS
|
||||
}
|
||||
|
||||
void
|
||||
HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
HelloProtocol::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::Name& name)
|
||||
{
|
||||
_LOG_DEBUG(error << " (code: " << code << ")");
|
||||
_LOG_DEBUG(response.getText() << " (code: " << response.getCode() << ")");
|
||||
/*
|
||||
* If NLSR can not create face for given faceUri then it will treat this
|
||||
* failure as one INFO interest timed out. So that NLSR can move on with
|
||||
@@ -274,4 +304,4 @@ HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+48
-5
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,9 +22,11 @@
|
||||
#ifndef NLSR_HELLO_PROTOCOL_HPP
|
||||
#define NLSR_HELLO_PROTOCOL_HPP
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-parameters.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -40,15 +42,54 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Schedules a hello Interest event.
|
||||
|
||||
\param seconds The number of seconds to wait before calling the event.
|
||||
*/
|
||||
void
|
||||
scheduleInterest(uint32_t seconds);
|
||||
|
||||
/*! \brief Sends a hello Interest packet.
|
||||
|
||||
\param interestNamePrefix The name of the router that has published the
|
||||
update we want. Here that should be: \<router name\>/NLSR/INFO
|
||||
|
||||
\param seconds The lifetime of the Interest we construct, in seconds
|
||||
|
||||
This function attempts to contact neighboring routers to
|
||||
determine their status (which currently is one of: ACTIVE,
|
||||
INACTIVE, or UNKNOWN)
|
||||
*/
|
||||
void
|
||||
expressInterest(const ndn::Name& interestNamePrefix, uint32_t seconds);
|
||||
|
||||
/*! \brief Sends a hello Interest packet that was previously scheduled.
|
||||
|
||||
\param seconds (ignored)
|
||||
|
||||
This function is called as part of a schedule to regularly
|
||||
determine the adjacency status of neighbors. This function checks
|
||||
if the specified neighbor has a Face, and if not creates one. If
|
||||
the neighbor had a Face, it calls \c expressInterest, else it will
|
||||
attempt to create a Face, which will itself attempt to contact the
|
||||
neighbor. Then the function schedules for this function to be invoked again.
|
||||
*/
|
||||
void
|
||||
sendScheduledInterest(uint32_t seconds);
|
||||
|
||||
/*! \brief Processes a hello Interest from a neighbor.
|
||||
|
||||
\param name (ignored)
|
||||
|
||||
\param interest The Interest object that we have received and need to
|
||||
process.
|
||||
|
||||
Processes a hello Interest that this router receives from one of
|
||||
its neighbors. If the neighbor that sent the Interest does not
|
||||
have a Face, NLSR will attempt to register one. Also, if the
|
||||
neighbor that sent the Interest was previously marked as INACTIVE,
|
||||
NLSR will attempt to contact it with its own hello Interest.
|
||||
*/
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
@@ -59,15 +100,17 @@ private:
|
||||
void
|
||||
onContent(const ndn::Interest& interest, const ndn::Data& data);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
private:
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg);
|
||||
|
||||
void
|
||||
onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::Name& name);
|
||||
|
||||
void
|
||||
@@ -85,6 +128,6 @@ private:
|
||||
static const std::string NLSR_COMPONENT;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_HELLO_PROTOCOL_HPP
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
+26
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -53,12 +53,12 @@ NameLsa::getKey() const
|
||||
return key;
|
||||
}
|
||||
|
||||
NameLsa::NameLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
NameLsa::NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl)
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
std::list<ndn::Name>& nl = npl.getNameList();
|
||||
@@ -97,12 +97,16 @@ NameLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != NameLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numName = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numName; i++) {
|
||||
@@ -130,13 +134,12 @@ NameLsa::writeLog()
|
||||
_LOG_DEBUG("name_lsa_end");
|
||||
}
|
||||
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst,
|
||||
uint32_t lsn,
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta)
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_corRad = r;
|
||||
@@ -186,13 +189,17 @@ CoordinateLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != CoordinateLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
m_corRad = boost::lexical_cast<double>(*tok_iter++);
|
||||
m_corTheta = boost::lexical_cast<double>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -210,12 +217,12 @@ CoordinateLsa::writeLog()
|
||||
_LOG_DEBUG(" Hyperbolic Theta: " << m_corTheta);
|
||||
}
|
||||
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl)
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_noLink = nl;
|
||||
@@ -241,7 +248,6 @@ AdjLsa::isEqualContent(AdjLsa& alsa)
|
||||
return m_adl == alsa.getAdl();
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
AdjLsa::getData()
|
||||
{
|
||||
@@ -276,12 +282,16 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != AdjLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numLink = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numLink; i++) {
|
||||
@@ -293,17 +303,20 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
addAdjacent(adjacent);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AdjLsa::addNptEntries(Nlsr& pnlsr)
|
||||
{
|
||||
// Only add NPT entries if this is an adj LSA from another router.
|
||||
if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()) {
|
||||
// Pass the originating router as both the name to register and
|
||||
// where it came from.
|
||||
pnlsr.getNamePrefixTable().addEntry(getOrigRouter(), getOrigRouter());
|
||||
}
|
||||
}
|
||||
|
||||
+61
-20
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -32,24 +32,20 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Lsa
|
||||
{
|
||||
public:
|
||||
Lsa()
|
||||
Lsa(const std::string& lsaType)
|
||||
: m_origRouter()
|
||||
, m_lsType(lsaType)
|
||||
, m_lsSeqNo()
|
||||
, m_expirationTimePoint()
|
||||
, m_expiringEventId()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setLsType(const std::string& lst)
|
||||
{
|
||||
m_lsType = lst;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getLsType() const
|
||||
{
|
||||
@@ -106,7 +102,7 @@ public:
|
||||
|
||||
protected:
|
||||
ndn::Name m_origRouter;
|
||||
std::string m_lsType;
|
||||
const std::string m_lsType;
|
||||
uint32_t m_lsSeqNo;
|
||||
ndn::time::system_clock::TimePoint m_expirationTimePoint;
|
||||
ndn::EventId m_expiringEventId;
|
||||
@@ -116,13 +112,12 @@ class NameLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
NameLsa()
|
||||
: Lsa()
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
, m_npl()
|
||||
{
|
||||
setLsType(NameLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
NameLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl);
|
||||
|
||||
@@ -144,12 +139,30 @@ public:
|
||||
m_npl.remove(name);
|
||||
}
|
||||
|
||||
/*! \brief Gets the key for this LSA.
|
||||
|
||||
Format is: \<router name\>/\<LSA type>\
|
||||
*/
|
||||
const ndn::Name
|
||||
getKey() const;
|
||||
|
||||
/*! \brief Returns the data that this name LSA has.
|
||||
|
||||
Format is: \<original router
|
||||
prefix\>|name|\<seq. no.\>|\<exp. time\>|\<prefix 1\>|\<prefix
|
||||
2\>|...|\<prefix n\>|
|
||||
*/
|
||||
std::string
|
||||
getData();
|
||||
|
||||
/*! \brief Initializes this LSA object with content's data.
|
||||
|
||||
\param content The data (e.g. name prefixes) to initialize this LSA with.
|
||||
|
||||
This function initializes this object to represent the data
|
||||
contained in content. The format for this is the same as for
|
||||
getData(); getData() returns data of this format, in other words.
|
||||
*/
|
||||
bool
|
||||
initializeFromContent(const std::string& content);
|
||||
|
||||
@@ -168,13 +181,12 @@ public:
|
||||
typedef AdjacencyList::const_iterator const_iterator;
|
||||
|
||||
AdjLsa()
|
||||
: Lsa()
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
, m_adl()
|
||||
{
|
||||
setLsType(AdjLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl);
|
||||
|
||||
@@ -193,9 +205,21 @@ public:
|
||||
const ndn::Name
|
||||
getKey() const;
|
||||
|
||||
/*! \brief Returns the data this adjacency LSA has.
|
||||
|
||||
The format is: \<original
|
||||
router\>|adjacency|\<seq. no.\>|\<exp. time\>|\<size\>|\<adjacency prefix
|
||||
1\>|\<face uri 1\>|\<cost 1\>|...|\<adjacency prefix n\>|\<face uri
|
||||
n\>|\<cost n\>|
|
||||
*/
|
||||
std::string
|
||||
getData();
|
||||
|
||||
/*! \brief Initializes this adj. LSA from the supplied content.
|
||||
|
||||
\param content The content that this LSA is to have, formatted
|
||||
according to getData().
|
||||
*/
|
||||
bool
|
||||
initializeFromContent(const std::string& content);
|
||||
|
||||
@@ -208,6 +232,11 @@ public:
|
||||
bool
|
||||
isEqualContent(AdjLsa& alsa);
|
||||
|
||||
/*! \brief Installs this LSA's name prefixes into the NPT.
|
||||
|
||||
\param pnlsr The NLSR top-level whose NPT you want to install the
|
||||
entries into.
|
||||
*/
|
||||
void
|
||||
addNptEntries(Nlsr& pnlsr);
|
||||
|
||||
@@ -242,23 +271,35 @@ class CoordinateLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
CoordinateLsa()
|
||||
: Lsa()
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
, m_corRad(0)
|
||||
, m_corTheta(0)
|
||||
{
|
||||
setLsType(CoordinateLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
CoordinateLsa(const ndn::Name& origR, const std::string lst, uint32_t lsn,
|
||||
CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta);
|
||||
|
||||
const ndn::Name
|
||||
getKey() const;
|
||||
|
||||
/*! \brief Returns the data that this coordinate LSA represents.
|
||||
|
||||
The format is: \<original
|
||||
router\>|coordinate|\<seq. no.\>|\<exp. time\>|\<radians\>|\<theta\>|
|
||||
*/
|
||||
std::string
|
||||
getData();
|
||||
|
||||
/*! \brief Initializes this coordinate LSA with the data in content.
|
||||
|
||||
\param content The string content that is used to build the LSA.
|
||||
|
||||
This function initializes this LSA object to represent the data
|
||||
specified by the parameter. The format that it is expecting is the
|
||||
same as for getData();
|
||||
*/
|
||||
bool
|
||||
initializeFromContent(const std::string& content);
|
||||
|
||||
@@ -303,6 +344,6 @@ public:
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const AdjLsa& adjLsa);
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_LSA_HPP
|
||||
+283
-138
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,24 +19,114 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "lsdb.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "publisher/segment-publisher.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("Lsdb");
|
||||
|
||||
class LsaContentPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
public:
|
||||
LsaContentPublisher(ndn::Face& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
const ndn::time::milliseconds& freshnessPeriod,
|
||||
const std::string& content)
|
||||
: SegmentPublisher(face, keyChain, freshnessPeriod)
|
||||
, m_content(content)
|
||||
{
|
||||
}
|
||||
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) {
|
||||
size_t totalLength = 0;
|
||||
totalLength += outBuffer.prependByteArray(reinterpret_cast<const uint8_t*>(m_content.c_str()),
|
||||
m_content.size());
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_content;
|
||||
};
|
||||
|
||||
const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
|
||||
const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
|
||||
const steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE = steady_clock::TimePoint::min();
|
||||
|
||||
using namespace std;
|
||||
Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
, m_sync(sync)
|
||||
, m_lsaRefreshTime(0)
|
||||
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Failed to fetch LSA: " << lsaName << ", Error code: " << errorCode
|
||||
<< ", Message: " << msg);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
// If the SegmentFetcher failed due to an Interest timeout, it is safe to re-express
|
||||
// immediately since at the least the LSA Interest lifetime has elapsed.
|
||||
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
||||
// the potential for constant Interest flooding.
|
||||
ndn::time::seconds delay = m_nlsr.getConfParameter().getLsaInterestLifetime();
|
||||
|
||||
if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||
delay = ndn::time::seconds(0);
|
||||
}
|
||||
|
||||
m_scheduler.scheduleEvent(delay, std::bind(&Lsdb::expressInterest, this,
|
||||
interestName, retransmitNo + 1, deadline));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, ndn::Name& interestName)
|
||||
{
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(ndn::Name(interestName));
|
||||
data->setContent(bufferPtr);
|
||||
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data->getName());
|
||||
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo > m_highestSeqNo[lsaName]) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo < m_highestSeqNo[lsaName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
onContentValidated(data);
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
|
||||
@@ -44,18 +134,21 @@ Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
|
||||
m_scheduler.cancelEvent(eid);
|
||||
}
|
||||
|
||||
/*! \brief Compares if a name LSA is the same as the one specified by key
|
||||
|
||||
\param nlsa1 A name LSA object
|
||||
\param key A key of an originating router to compare to nlsa1
|
||||
*/
|
||||
static bool
|
||||
nameLsaCompareByKey(const NameLsa& nlsa1, const ndn::Name& key)
|
||||
{
|
||||
return nlsa1.getKey() == key;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::buildAndInstallOwnNameLsa()
|
||||
{
|
||||
NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
NameLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getNamePrefixList());
|
||||
@@ -79,7 +172,9 @@ bool
|
||||
Lsdb::isNameLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
{
|
||||
NameLsa* nameLsaCheck = findNameLsa(key);
|
||||
// Is the name in the LSDB
|
||||
if (nameLsaCheck != 0) {
|
||||
// And the supplied seq no is the highest so far
|
||||
if (nameLsaCheck->getLsSeqNo() < seqNo) {
|
||||
return true;
|
||||
}
|
||||
@@ -103,6 +198,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
{
|
||||
ndn::time::seconds timeToExpire = m_lsaRefreshTime;
|
||||
NameLsa* chkNameLsa = findNameLsa(nlsa.getKey());
|
||||
// Determines if the name LSA is new or not.
|
||||
if (chkNameLsa == 0) {
|
||||
addNameLsa(nlsa);
|
||||
_LOG_DEBUG("New Name LSA");
|
||||
@@ -110,6 +206,8 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
nlsa.writeLog();
|
||||
|
||||
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
// If this name LSA is from another router, add the advertised
|
||||
// prefixes to the NPT.
|
||||
m_nlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
|
||||
nlsa.getOrigRouter());
|
||||
std::list<ndn::Name> nameList = nlsa.getNpl().getNameList();
|
||||
@@ -129,6 +227,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
nlsa.getLsSeqNo(),
|
||||
timeToExpire));
|
||||
}
|
||||
// Else this is a known name LSA, so we are updating it.
|
||||
else {
|
||||
if (chkNameLsa->getLsSeqNo() < nlsa.getLsSeqNo()) {
|
||||
_LOG_DEBUG("Updated Name LSA. Updating LSDB");
|
||||
@@ -138,6 +237,8 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
chkNameLsa->setExpirationTimePoint(nlsa.getExpirationTimePoint());
|
||||
chkNameLsa->getNpl().sort();
|
||||
nlsa.getNpl().sort();
|
||||
// Obtain the set difference of the current and the incoming
|
||||
// name prefix sets, and add those.
|
||||
std::list<ndn::Name> nameToAdd;
|
||||
std::set_difference(nlsa.getNpl().getNameList().begin(),
|
||||
nlsa.getNpl().getNameList().end(),
|
||||
@@ -156,6 +257,7 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
|
||||
chkNameLsa->getNpl().sort();
|
||||
|
||||
// Also remove any names that are no longer being advertised.
|
||||
std::list<ndn::Name> nameToRemove;
|
||||
std::set_difference(chkNameLsa->getNpl().getNameList().begin(),
|
||||
chkNameLsa->getNpl().getNameList().end(),
|
||||
@@ -210,6 +312,8 @@ Lsdb::removeNameLsa(const ndn::Name& key)
|
||||
if (it != m_nameLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Name Lsa");
|
||||
(*it).writeLog();
|
||||
// If the requested name LSA is not ours, we also need to remove
|
||||
// its entries from the NPT.
|
||||
if ((*it).getOrigRouter() !=
|
||||
m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
|
||||
@@ -257,6 +361,10 @@ Lsdb::getNameLsdb()
|
||||
|
||||
// Cor LSA and LSDB related Functions start here
|
||||
|
||||
/*! \brief Compares whether an LSA object is the same as a key.
|
||||
\param clsa The cor. LSA to check the identity of.
|
||||
\param key The key of the publishing router to check against.
|
||||
*/
|
||||
static bool
|
||||
corLsaCompareByKey(const CoordinateLsa& clsa, const ndn::Name& key)
|
||||
{
|
||||
@@ -267,13 +375,19 @@ bool
|
||||
Lsdb::buildAndInstallOwnCoordinateLsa()
|
||||
{
|
||||
CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
CoordinateLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -293,7 +407,9 @@ bool
|
||||
Lsdb::isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
{
|
||||
CoordinateLsa* clsa = findCoordinateLsa(key);
|
||||
// Is the coordinate LSA in the LSDB already
|
||||
if (clsa != 0) {
|
||||
// And the seq no is newer (higher) than the current one
|
||||
if (clsa->getLsSeqNo() < seqNo) {
|
||||
return true;
|
||||
}
|
||||
@@ -304,6 +420,10 @@ Lsdb::isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Schedules a refresh/expire event in the scheduler.
|
||||
// \param key The name of the router that published the LSA.
|
||||
// \param seqNo the seq. no. associated with the LSA to check.
|
||||
// \param expTime How long to wait before triggering the event.
|
||||
ndn::EventId
|
||||
Lsdb::scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
@@ -318,19 +438,22 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
{
|
||||
ndn::time::seconds timeToExpire = m_lsaRefreshTime;
|
||||
CoordinateLsa* chkCorLsa = findCoordinateLsa(clsa.getKey());
|
||||
// Checking whether the LSA is new or not.
|
||||
if (chkCorLsa == 0) {
|
||||
_LOG_DEBUG("New Coordinate LSA. Adding to LSDB");
|
||||
_LOG_DEBUG("Adding Coordinate Lsa");
|
||||
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);
|
||||
}
|
||||
// Set the expiration time for the new LSA.
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
@@ -339,6 +462,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
scheduleCoordinateLsaExpiration(clsa.getKey(),
|
||||
clsa.getLsSeqNo(), timeToExpire);
|
||||
}
|
||||
// We are just updating this LSA.
|
||||
else {
|
||||
if (chkCorLsa->getLsSeqNo() < clsa.getLsSeqNo()) {
|
||||
_LOG_DEBUG("Updated Coordinate LSA. Updating LSDB");
|
||||
@@ -346,6 +470,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
chkCorLsa->writeLog();
|
||||
chkCorLsa->setLsSeqNo(clsa.getLsSeqNo());
|
||||
chkCorLsa->setExpirationTimePoint(clsa.getExpirationTimePoint());
|
||||
// If the new LSA contains new routing information, update the LSDB with it.
|
||||
if (!chkCorLsa->isEqualContent(clsa)) {
|
||||
chkCorLsa->setCorRadius(clsa.getCorRadius());
|
||||
chkCorLsa->setCorTheta(clsa.getCorTheta());
|
||||
@@ -353,6 +478,7 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
}
|
||||
// If this is an LSA from another router, refresh its expiration time.
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
@@ -392,12 +518,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;
|
||||
}
|
||||
@@ -435,6 +561,10 @@ Lsdb::getCoordinateLsdb()
|
||||
|
||||
// Adj LSA and LSDB related function starts here
|
||||
|
||||
/*! \brief Returns whether an adj. LSA object is from some router.
|
||||
\param alsa The adj. LSA object.
|
||||
\param key The router name that you want to compare the LSA with.
|
||||
*/
|
||||
static bool
|
||||
adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
|
||||
{
|
||||
@@ -446,6 +576,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);
|
||||
|
||||
@@ -457,25 +592,43 @@ Lsdb::scheduleAdjLsaBuild()
|
||||
void
|
||||
Lsdb::buildAdjLsa()
|
||||
{
|
||||
_LOG_TRACE("buildAdjLsa called");
|
||||
_LOG_TRACE("Lsdb::buildAdjLsa called");
|
||||
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(false);
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
|
||||
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
|
||||
int adjBuildCount = m_nlsr.getAdjBuildCount();
|
||||
// Only do the adjLsa build if there's one scheduled
|
||||
if (adjBuildCount > 0) {
|
||||
// It only makes sense to do the adjLsa build if we have neighbors
|
||||
if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
|
||||
_LOG_DEBUG("Building and installing Adj LSA");
|
||||
_LOG_DEBUG("Building and installing own Adj LSA");
|
||||
buildAndInstallOwnAdjLsa();
|
||||
}
|
||||
// We have no active neighbors, meaning no one can route through
|
||||
// us. So delete our entry in the LSDB. This prevents this
|
||||
// router from refreshing the LSA, eventually causing other
|
||||
// routers to delete it, too.
|
||||
else {
|
||||
_LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors")
|
||||
// Get this router's key
|
||||
ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
|
||||
key.append(AdjLsa::TYPE_STRING);
|
||||
|
||||
removeAdjLsa(key);
|
||||
// Recompute routing table after removal
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
// In the case that during building the adj LSA, the FIB has to
|
||||
// wait on an Interest response, the number of scheduled adj LSA
|
||||
// builds could change, so we shouldn't just set it to 0.
|
||||
m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
|
||||
}
|
||||
}
|
||||
// We are still waiting to know the adjacency status of some
|
||||
// neighbor, so schedule a build for later (when all that has
|
||||
// hopefully finished)
|
||||
else {
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
|
||||
@@ -485,7 +638,6 @@ Lsdb::buildAdjLsa()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::addAdjLsa(AdjLsa& alsa)
|
||||
{
|
||||
@@ -512,12 +664,13 @@ Lsdb::findAdjLsa(const ndn::Name& key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::isAdjLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
{
|
||||
AdjLsa* adjLsaCheck = findAdjLsa(key);
|
||||
// If it is in the LSDB
|
||||
if (adjLsaCheck != 0) {
|
||||
// And the supplied seq no is newer (higher) than the current one.
|
||||
if (adjLsaCheck->getLsSeqNo() < seqNo) {
|
||||
return true;
|
||||
}
|
||||
@@ -528,7 +681,6 @@ Lsdb::isAdjLsaNew(const ndn::Name& key, uint64_t seqNo)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ndn::EventId
|
||||
Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
@@ -542,11 +694,13 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
|
||||
{
|
||||
ndn::time::seconds timeToExpire = m_lsaRefreshTime;
|
||||
AdjLsa* chkAdjLsa = findAdjLsa(alsa.getKey());
|
||||
// If this adj. LSA is not in the LSDB already
|
||||
if (chkAdjLsa == 0) {
|
||||
_LOG_DEBUG("New Adj LSA. Adding to LSDB");
|
||||
_LOG_DEBUG("Adding Adj Lsa");
|
||||
alsa.writeLog();
|
||||
addAdjLsa(alsa);
|
||||
// Add any new name prefixes to the NPT
|
||||
alsa.addNptEntries(m_nlsr);
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
@@ -564,6 +718,10 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
|
||||
chkAdjLsa->writeLog();
|
||||
chkAdjLsa->setLsSeqNo(alsa.getLsSeqNo());
|
||||
chkAdjLsa->setExpirationTimePoint(alsa.getExpirationTimePoint());
|
||||
// If the new adj LSA has new content, update the contents of
|
||||
// the LSDB entry. Additionally, since we've changed the
|
||||
// contents of the LSDB, we have to schedule a routing
|
||||
// calculation.
|
||||
if (!chkAdjLsa->isEqualContent(alsa)) {
|
||||
chkAdjLsa->getAdl().reset();
|
||||
chkAdjLsa->getAdl().addAdjacents(alsa.getAdl());
|
||||
@@ -589,15 +747,16 @@ bool
|
||||
Lsdb::buildAndInstallOwnAdjLsa()
|
||||
{
|
||||
AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
AdjLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getAdjLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
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);
|
||||
}
|
||||
@@ -643,19 +802,28 @@ Lsdb::setLsaRefreshTime(const seconds& lsaRefreshTime)
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::setThisRouterPrefix(string trp)
|
||||
Lsdb::setThisRouterPrefix(std::string trp)
|
||||
{
|
||||
m_thisRouterPrefix = trp;
|
||||
}
|
||||
|
||||
// This function determines whether a name LSA should be refreshed
|
||||
// or expired. The conditions for getting refreshed are: it is still
|
||||
// in the LSDB, it hasn't been updated by something else already (as
|
||||
// evidenced by its seq. no.), and this is the originating router for
|
||||
// the LSA. Is it let expire in all other cases.
|
||||
// lsaKey is the key of the LSA's publishing router.
|
||||
// seqNo is the seq. no. of the candidate LSA.
|
||||
void
|
||||
Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Lsdb::exprireOrRefreshNameLsa Called");
|
||||
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
|
||||
NameLsa* chkNameLsa = findNameLsa(lsaKey);
|
||||
// If this name LSA exists in the LSDB
|
||||
if (chkNameLsa != 0) {
|
||||
_LOG_DEBUG("LSA Exists with seq no: " << chkNameLsa->getLsSeqNo());
|
||||
// If its seq no is the one we are expecting.
|
||||
if (chkNameLsa->getLsSeqNo() == seqNo) {
|
||||
if (chkNameLsa->getOrigRouter() == m_thisRouterPrefix) {
|
||||
_LOG_DEBUG("Own Name LSA, so refreshing it");
|
||||
@@ -672,6 +840,7 @@ Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
m_lsaRefreshTime));
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
// Since we cannot refresh other router's LSAs, our only choice is to expire.
|
||||
else {
|
||||
_LOG_DEBUG("Other's Name LSA, so removing form LSDB");
|
||||
removeNameLsa(lsaKey);
|
||||
@@ -680,15 +849,25 @@ Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
}
|
||||
}
|
||||
|
||||
// This function determines whether an adj. LSA should be refreshed
|
||||
// or expired. The conditions for getting refreshed are: it is still
|
||||
// in the LSDB, it hasn't been updated by something else already (as
|
||||
// evidenced by its seq. no.), and this is the originating router for
|
||||
// the LSA. Is it let expire in all other cases.
|
||||
// lsaKey is the key of the LSA's publishing router.
|
||||
// seqNo is the seq. no. of the candidate LSA.
|
||||
void
|
||||
Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Lsdb::exprireOrRefreshAdjLsa Called");
|
||||
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
|
||||
AdjLsa* chkAdjLsa = findAdjLsa(lsaKey);
|
||||
// If this is a valid LSA
|
||||
if (chkAdjLsa != 0) {
|
||||
_LOG_DEBUG("LSA Exists with seq no: " << chkAdjLsa->getLsSeqNo());
|
||||
// And if it hasn't been updated for some other reason
|
||||
if (chkAdjLsa->getLsSeqNo() == seqNo) {
|
||||
// If it is our own LSA
|
||||
if (chkAdjLsa->getOrigRouter() == m_thisRouterPrefix) {
|
||||
_LOG_DEBUG("Own Adj LSA, so refreshing it");
|
||||
_LOG_DEBUG("Deleting Adj Lsa");
|
||||
@@ -704,16 +883,25 @@ Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
m_lsaRefreshTime));
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
// An LSA from another router is expiring
|
||||
else {
|
||||
_LOG_DEBUG("Other's Adj LSA, so removing form LSDB");
|
||||
removeAdjLsa(lsaKey);
|
||||
}
|
||||
// schedule Routing table calculaiton
|
||||
// We have changed the contents of the LSDB, so we have to
|
||||
// schedule a routing calculation
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This function determines whether an adj. LSA should be refreshed
|
||||
// or expired. The conditions for getting refreshed are: it is still
|
||||
// in the LSDB, it hasn't been updated by something else already (as
|
||||
// evidenced by its seq. no.), and this is the originating router for
|
||||
// the LSA. It is let expire in all other cases.
|
||||
// lsaKey is the key of the LSA's publishing router.
|
||||
// seqNo is the seq. no. of the candidate LSA.
|
||||
void
|
||||
Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
@@ -721,15 +909,20 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
_LOG_DEBUG("Lsdb::exprireOrRefreshCorLsa Called ");
|
||||
_LOG_DEBUG("LSA Key : " << lsaKey << " Seq No: " << seqNo);
|
||||
CoordinateLsa* chkCorLsa = findCoordinateLsa(lsaKey);
|
||||
// Whether the LSA is in the LSDB or not.
|
||||
if (chkCorLsa != 0) {
|
||||
_LOG_DEBUG("LSA Exists with seq no: " << chkCorLsa->getLsSeqNo());
|
||||
// Whether the LSA has been updated without our knowledge.
|
||||
if (chkCorLsa->getLsSeqNo() == seqNo) {
|
||||
if (chkCorLsa->getOrigRouter() == m_thisRouterPrefix) {
|
||||
_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());
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
}
|
||||
|
||||
chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
|
||||
_LOG_DEBUG("Adding Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
@@ -738,20 +931,23 @@ 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();
|
||||
}
|
||||
}
|
||||
// We can't refresh other router's LSAs, so we remove it.
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline)
|
||||
@@ -759,30 +955,33 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
if (deadline == DEFAULT_LSA_RETRIEVAL_DEADLINE) {
|
||||
deadline = steady_clock::now() + ndn::time::seconds(static_cast<int>(LSA_REFRESH_TIME_MAX));
|
||||
}
|
||||
|
||||
// The first component of the interest is the name.
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
// The seq no is the last
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
// If the LSA is not found in the list currently.
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
// If the new seq no is higher, that means the LSA is valid
|
||||
else if (seqNo > m_highestSeqNo[lsaName]) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
// Otherwise, its an old/invalid LSA
|
||||
else if (seqNo < m_highestSeqNo[lsaName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
interest.setInterestLifetime(m_nlsr.getConfParameter().getLsaInterestLifetime());
|
||||
|
||||
_LOG_DEBUG("Expressing Interest for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
m_nlsr.getNlsrFace().expressInterest(interest,
|
||||
ndn::bind(&Lsdb::onContent,
|
||||
this, _2, deadline, lsaName, seqNo),
|
||||
ndn::bind(&Lsdb::processInterestTimedOut,
|
||||
this, _1, timeoutCount, deadline, lsaName, seqNo));
|
||||
_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
|
||||
m_nlsr.getValidator(),
|
||||
ndn::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
|
||||
ndn::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
|
||||
timeoutCount, deadline, lsaName, seqNo));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -791,11 +990,12 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
const ndn::Name& interestName(interest.getName());
|
||||
_LOG_DEBUG("Interest received for LSA: " << interestName);
|
||||
|
||||
string chkString("LSA");
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
|
||||
// Forms the name of the router that the Interest packet came from.
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
originRouter.append(interestName.getSubName(lsaPosition + 1,
|
||||
interest.getName().size() - lsaPosition - 3));
|
||||
@@ -805,6 +1005,7 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
|
||||
std::string interestedLsType = interestName[-2].toUri();
|
||||
|
||||
// Passes the Interest off to the appropriate subprocessor
|
||||
if (interestedLsType == NameLsa::TYPE_STRING) {
|
||||
processInterestForNameLsa(interest, originRouter.append(interestedLsType), seqNo);
|
||||
}
|
||||
@@ -820,21 +1021,25 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
}
|
||||
}
|
||||
|
||||
// \brief Sends LSA data.
|
||||
// \param interest The Interest that warranted the data.
|
||||
// \param content The data that the Interest was seeking.
|
||||
void
|
||||
Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
|
||||
{
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(m_lsaRefreshTime);
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
|
||||
m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
|
||||
ndn::SignatureSha256WithRsa signature(data->getSignature());
|
||||
ndn::Name signingCertName = signature.getKeyLocator().getName();
|
||||
_LOG_DEBUG("Sending data for LSA(name): " << interest.getName());
|
||||
_LOG_DEBUG("Data signed with: " << signingCertName);
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
|
||||
m_nlsr.getKeyChain(),
|
||||
m_lsaRefreshTime,
|
||||
content);
|
||||
publisher.publish(interest.getName(),
|
||||
ndn::security::signingByCertificate(m_nlsr.getDefaultCertName()));
|
||||
}
|
||||
|
||||
// \brief Finds and sends a requested name LSA.
|
||||
// \param interest The interest that seeks the name LSA.
|
||||
// \param lsaKey The LSA that the Interest is seeking.
|
||||
// \param seqNo A sequence number to ensure that we are sending the
|
||||
// version that was requested.
|
||||
void
|
||||
Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
@@ -849,11 +1054,20 @@ Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
|
||||
}
|
||||
}
|
||||
|
||||
// \brief Finds and sends a requested adj. LSA.
|
||||
// \param interest The interest that seeks the adj. LSA.
|
||||
// \param lsaKey The LSA that the Interest is seeking.
|
||||
// \param seqNo A sequence number to ensure that we are sending the
|
||||
// version that was requested.
|
||||
void
|
||||
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) {
|
||||
@@ -863,11 +1077,20 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
}
|
||||
}
|
||||
|
||||
// \brief Finds and sends a requested cor. LSA.
|
||||
// \param interest The interest that seeks the cor. LSA.
|
||||
// \param lsaKey The LSA that the Interest is seeking.
|
||||
// \param seqNo A sequence number to ensure that we are sending the
|
||||
// version that was requested.
|
||||
void
|
||||
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) {
|
||||
@@ -877,59 +1100,25 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContent(const ndn::Data& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data.getName());
|
||||
if (data.getSignature().hasKeyLocator()) {
|
||||
if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline, lsaName, seqNo));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Retrying validation of LSA(name): " << data->getName());
|
||||
if (data->getSignature().hasKeyLocator()) {
|
||||
if (data->getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data->getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(*data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline, lsaName, seqNo));
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
const ndn::Name& dataName = data->getName();
|
||||
_LOG_DEBUG("Data validation successful for LSA: " << dataName);
|
||||
|
||||
string chkString("LSA");
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
|
||||
// Extracts the prefix of the originating router from the data.
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 4));
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 3));
|
||||
|
||||
uint64_t seqNo = dataName[-2].toNumber();
|
||||
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
uint64_t seqNo = dataName[-1].toNumber();
|
||||
std::string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
|
||||
std::string interestedLsType = dataName[-3].toUri();
|
||||
std::string interestedLsType = dataName[-2].toUri();
|
||||
|
||||
if (interestedLsType == NameLsa::TYPE_STRING) {
|
||||
processContentNameLsa(originRouter.append(interestedLsType), seqNo, dataContent);
|
||||
@@ -946,32 +1135,6 @@ Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Validation Error: " << msg);
|
||||
|
||||
// Delay re-validation by LSA Interest Lifetime. When error callback will have an error
|
||||
// code, re-validation should be done only when some keys from certification chain failed
|
||||
// to be fetched. After that change, delaying will no longer be necessary.
|
||||
|
||||
// Stop retrying if delayed re-validation will be scheduled pass the deadline
|
||||
if (steady_clock::now() + m_nlsr.getConfParameter().getLsaInterestLifetime() < deadline) {
|
||||
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
_LOG_DEBUG("Scheduling revalidation attempt");
|
||||
m_scheduler.scheduleEvent(m_nlsr.getConfParameter().getLsaInterestLifetime(),
|
||||
ndn::bind(&Lsdb::retryContentValidation, this, data,
|
||||
deadline, lsaName, seqNo));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
@@ -1017,24 +1180,6 @@ Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
const ndn::Name& interestName = interest.getName();
|
||||
_LOG_DEBUG("Interest timed out for LSA: " << interestName);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
expressInterest(interestName, retransmitNo + 1, deadline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ndn::time::system_clock::TimePoint
|
||||
Lsdb::getLsaExpirationTimePoint()
|
||||
{
|
||||
|
||||
+140
-47
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <utility>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
|
||||
@@ -41,31 +42,44 @@ class SyncLogicHandler;
|
||||
class Lsdb
|
||||
{
|
||||
public:
|
||||
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
, m_sync(sync)
|
||||
, m_lsaRefreshTime(0)
|
||||
, m_adjLsaBuildInterval(static_cast<uint32_t>(ADJ_LSA_BUILD_INTERVAL_DEFAULT))
|
||||
{
|
||||
}
|
||||
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync);
|
||||
|
||||
bool
|
||||
doesLsaExist(const ndn::Name& key, const std::string& lsType);
|
||||
// function related to Name LSDB
|
||||
|
||||
|
||||
/*! \brief Builds a name LSA for this router and then installs it
|
||||
into the LSDB.
|
||||
*/
|
||||
bool
|
||||
buildAndInstallOwnNameLsa();
|
||||
|
||||
/*! \brief Returns the name LSA with the given key.
|
||||
\param key The name of the router that the desired LSA comes from.
|
||||
*/
|
||||
NameLsa*
|
||||
findNameLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Installs a name LSA into the LSDB
|
||||
\param nlsa The name LSA to install into the LSDB.
|
||||
*/
|
||||
bool
|
||||
installNameLsa(NameLsa& nlsa);
|
||||
|
||||
/*! \brief Remove a name LSA from the LSDB.
|
||||
\param key The name of the router that published the LSA to remove.
|
||||
|
||||
This function will remove a name LSA from the LSDB by finding an
|
||||
LSA whose name matches key. This removal also causes the NPT to
|
||||
remove those name prefixes if no more LSAs advertise them.
|
||||
*/
|
||||
bool
|
||||
removeNameLsa(const ndn::Name& key);
|
||||
|
||||
/*! Returns whether a seq. no. from a certain router signals a new LSA.
|
||||
\param key The name of the originating router.
|
||||
\param seqNo The sequence number to check.
|
||||
*/
|
||||
bool
|
||||
isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
|
||||
|
||||
@@ -75,19 +89,36 @@ public:
|
||||
const std::list<NameLsa>&
|
||||
getNameLsdb();
|
||||
|
||||
//function related to Cor LSDB
|
||||
/*! \brief Builds a cor. LSA for this router and installs it into the LSDB. */
|
||||
bool
|
||||
buildAndInstallOwnCoordinateLsa();
|
||||
|
||||
/*! \brief Finds a cor. LSA in the LSDB.
|
||||
\param key The name of the originating router that published the LSA.
|
||||
*/
|
||||
CoordinateLsa*
|
||||
findCoordinateLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Installs a cor. LSA into the LSDB.
|
||||
\param clsa The cor. LSA to install.
|
||||
*/
|
||||
bool
|
||||
installCoordinateLsa(CoordinateLsa& clsa);
|
||||
|
||||
/*! \brief Removes a cor. LSA from the LSDB.
|
||||
\param key The name of the router that published the LSA to remove.
|
||||
|
||||
Removes the coordinate LSA whose origin router name matches that
|
||||
given by key. Additionally, ask the NPT to remove the prefix,
|
||||
which will occur if no other LSAs point there.
|
||||
*/
|
||||
bool
|
||||
removeCoordinateLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Returns whether a cor. LSA from a router is new or not.
|
||||
\param key The name prefix of the originating router.
|
||||
\param seqNo The sequence number of the candidate LSA.
|
||||
*/
|
||||
bool
|
||||
isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
|
||||
|
||||
@@ -99,21 +130,39 @@ public:
|
||||
|
||||
//function related to Adj LSDB
|
||||
|
||||
/*! \brief Schedules a build of this router's LSA. */
|
||||
void
|
||||
scheduleAdjLsaBuild();
|
||||
|
||||
/*! \brief Wrapper event to build and install an adj. LSA for this router. */
|
||||
bool
|
||||
buildAndInstallOwnAdjLsa();
|
||||
|
||||
/*! \brief Removes an adj. LSA from the LSDB.
|
||||
\param key The name of the publishing router whose LSA to remove.
|
||||
*/
|
||||
bool
|
||||
removeAdjLsa(const ndn::Name& key);
|
||||
|
||||
/*! \brief Returns whether an LSA is new.
|
||||
\param key The name of the publishing router.
|
||||
\param seqNo The seq. no. of the candidate LSA.
|
||||
|
||||
This function determines whether the LSA with the name key and
|
||||
seq. no. seqNo would be new to this LSDB.
|
||||
*/
|
||||
bool
|
||||
isAdjLsaNew(const ndn::Name& key, uint64_t seqNo);
|
||||
|
||||
/*! \brief Installs an adj. LSA into the LSDB.
|
||||
\param alsa The adj. LSA to add to the LSDB.
|
||||
*/
|
||||
bool
|
||||
installAdjLsa(AdjLsa& alsa);
|
||||
|
||||
/*! \brief Finds an adj. LSA in the LSDB.
|
||||
\param key The name of the publishing router whose LSA to find.
|
||||
*/
|
||||
AdjLsa*
|
||||
findAdjLsa(const ndn::Name& key);
|
||||
|
||||
@@ -141,42 +190,88 @@ public:
|
||||
void
|
||||
setThisRouterPrefix(std::string trp);
|
||||
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
/* \brief Add a name LSA to the LSDB if it isn't already there.
|
||||
\param nlsa The candidade name LSA.
|
||||
*/
|
||||
bool
|
||||
addNameLsa(NameLsa& nlsa);
|
||||
|
||||
/*! \brief Returns whether the LSDB contains some LSA.
|
||||
\param key The name of the publishing router whose LSA to check for.
|
||||
*/
|
||||
bool
|
||||
doesNameLsaExist(const ndn::Name& key);
|
||||
|
||||
|
||||
/*! \brief Adds a cor. LSA to the LSDB if it isn't already there.
|
||||
\param clsa The candidate cor. LSA.
|
||||
*/
|
||||
bool
|
||||
addCoordinateLsa(CoordinateLsa& clsa);
|
||||
|
||||
/*! \brief Returns whether a cor. LSA is in the LSDB.
|
||||
\param key The name of the router that published the queried LSA.
|
||||
*/
|
||||
bool
|
||||
doesCoordinateLsaExist(const ndn::Name& key);
|
||||
|
||||
/*! \brief Attempts to construct an adj. LSA.
|
||||
|
||||
This function will attempt to construct an adjacency LSA. An LSA
|
||||
can only be built when the status of all of the router's neighbors
|
||||
is known. That is, when we are not currently trying to contact any
|
||||
neighbor.
|
||||
*/
|
||||
void
|
||||
buildAdjLsa();
|
||||
|
||||
/*! \brief Adds an adj. LSA to the LSDB if it isn't already there.
|
||||
\param alsa The candidate adj. LSA to add to the LSDB.
|
||||
*/
|
||||
bool
|
||||
addAdjLsa(AdjLsa& alsa);
|
||||
|
||||
/*! \brief Returns whether the LSDB contains an LSA.
|
||||
\param key The name of a router whose LSA to check for in the LSDB.
|
||||
*/
|
||||
bool
|
||||
doesAdjLsaExist(const ndn::Name& key);
|
||||
|
||||
/*! \brief Schedules a refresh/expire event in the scheduler.
|
||||
\param key The name of the router that published the LSA.
|
||||
\param seqNo The seq. no. associated with the LSA.
|
||||
\param expTime How many seconds to wait before triggering the event.
|
||||
*/
|
||||
ndn::EventId
|
||||
scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const seconds& expTime);
|
||||
|
||||
/*! \brief Either allow to expire, or refresh a name LSA.
|
||||
\param lsaKey The name of the router that published the LSA.
|
||||
\param seqNo The seq. no. of the LSA to check.
|
||||
*/
|
||||
void
|
||||
exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*! \brief Schedules an expire/refresh event in the LSA.
|
||||
\param key The name of the router whose LSA is in question.
|
||||
\param seqNo The sequence number of the LSA to check.
|
||||
\param expTime The number of seconds to wait before triggering the event.
|
||||
*/
|
||||
ndn::EventId
|
||||
scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const seconds& expTime);
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
|
||||
|
||||
@@ -187,15 +282,9 @@ private:
|
||||
void
|
||||
exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
public:
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
putLsaData(const ndn::Interest& interest, const std::string& content);
|
||||
|
||||
@@ -213,33 +302,9 @@ private:
|
||||
processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
onContent(const ndn::Data& data, const steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName, uint64_t seqNo);
|
||||
|
||||
/**
|
||||
* @brief Retry validation after it fails
|
||||
*
|
||||
* Data packet validation can fail either because the packet does not have
|
||||
* valid signature (fatal) or because some of the certificate chain Data packets
|
||||
* failed to be fetched (non-fatal). Currently, the library does not provide
|
||||
* clear indication (besides plain-text message in error callback) of what is
|
||||
* the reason for failure and we will try to re-validate for as long as it the deadline.
|
||||
*/
|
||||
void
|
||||
retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, const std::string& msg,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
processContentNameLsa(const ndn::Name& lsaKey,
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
@@ -253,15 +318,43 @@ private:
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*!
|
||||
\brief Error callback when SegmentFetcher fails to return an LSA
|
||||
|
||||
In all error cases, a reattempt to fetch the LSA will be made.
|
||||
|
||||
Segment validation can fail either because the packet does not have a
|
||||
valid signature (fatal) or because some of the certificates in the trust chain
|
||||
could not be fetched (non-fatal).
|
||||
|
||||
Currently, the library does not provide clear indication (besides a plain-text message
|
||||
in the error callback) of the reason for the failure nor the segment that failed
|
||||
to be validated, thus we will continue to try to fetch the LSA until the deadline
|
||||
is reached.
|
||||
*/
|
||||
void
|
||||
processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
/*!
|
||||
\brief Success callback when SegmentFetcher returns a valid LSA
|
||||
|
||||
\param interestName The base Interest used to fetch the LSA in the format:
|
||||
/<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
|
||||
*/
|
||||
void
|
||||
afterFetchLsa(const ndn::ConstBufferPtr& data, ndn::Name& interestName);
|
||||
|
||||
private:
|
||||
system_clock::TimePoint
|
||||
getLsaExpirationTimePoint();
|
||||
|
||||
/*! \brief Cancels an event in the event scheduler. */
|
||||
void
|
||||
cancelScheduleLsaExpiringEvent(ndn::EventId eid);
|
||||
|
||||
@@ -292,6 +385,6 @@ private:
|
||||
ndn::time::seconds m_adjLsaBuildInterval;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_LSDB_HPP
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -95,4 +95,4 @@ NamePrefixList::writeLog()
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -37,14 +37,16 @@ public:
|
||||
|
||||
~NamePrefixList();
|
||||
|
||||
/** \brief inserts name into NamePrefixList
|
||||
* \return true if the name is inserted, otherwise false
|
||||
/*! \brief inserts name into NamePrefixList
|
||||
\retval true If the name was successfully inserted.
|
||||
\retval false If the name could not be inserted.
|
||||
*/
|
||||
bool
|
||||
insert(const ndn::Name& name);
|
||||
|
||||
/** \brief removes name from NamePrefixList
|
||||
* \return true if the name is removed, otherwise false
|
||||
/*! \brief removes name from NamePrefixList
|
||||
\retval true If the name is removed
|
||||
\retval false If the name failed to be removed.
|
||||
*/
|
||||
bool
|
||||
remove(const ndn::Name& name);
|
||||
@@ -72,6 +74,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_NAME_PREFIX_LIST_HPP
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+38
-19
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -57,11 +57,10 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
|
||||
, m_fib(m_nlsrFace, scheduler, m_adjacencyList, m_confParam, m_keyChain)
|
||||
, m_namePrefixTable(*this)
|
||||
, m_syncLogicHandler(m_nlsrFace, m_nlsrLsdb, m_confParam, m_sequencingManager)
|
||||
, m_helloProtocol(*this, scheduler)
|
||||
, m_lsdbDatasetHandler(m_nlsrLsdb,
|
||||
m_nlsrFace,
|
||||
m_confParam.getRouterPrefix(),
|
||||
m_keyChain)
|
||||
, m_helloProtocol(*this, scheduler)
|
||||
, m_certificateCache(new ndn::CertificateCacheTtl(ioService))
|
||||
, m_validator(m_nlsrFace, DEFAULT_BROADCAST_PREFIX, m_certificateCache, m_certStore)
|
||||
, m_prefixUpdateProcessor(m_nlsrFace,
|
||||
@@ -72,6 +71,7 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
|
||||
m_keyChain,
|
||||
m_certificateCache,
|
||||
m_certStore)
|
||||
, m_dispatcher(m_nlsrFace, m_keyChain, m_signingInfo)
|
||||
, m_faceMonitor(m_nlsrFace)
|
||||
, m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
|
||||
{
|
||||
@@ -179,11 +179,12 @@ Nlsr::initialize()
|
||||
{
|
||||
_LOG_DEBUG("Initializing Nlsr");
|
||||
m_confParam.buildRouterPrefix();
|
||||
m_lsdbDatasetHandler.setRouterNameCommandPrefix(m_confParam.getRouterPrefix());
|
||||
m_nlsrLsdb.setLsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()));
|
||||
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());
|
||||
|
||||
@@ -197,6 +198,12 @@ Nlsr::initialize()
|
||||
_LOG_DEBUG("Default NLSR identity: " << m_signingInfo.getSignerName());
|
||||
setInfoInterestFilter();
|
||||
setLsaInterestFilter();
|
||||
try {
|
||||
m_dispatcher.addTopPrefix(LOCALHOST_PREFIX, true, m_signingInfo);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
_LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
|
||||
}
|
||||
|
||||
// Set event intervals
|
||||
setFirstHelloInterval(m_confParam.getFirstHelloInterval());
|
||||
@@ -204,7 +211,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();
|
||||
@@ -320,9 +331,9 @@ Nlsr::onDestroyFaceSuccess(const ndn::nfd::ControlParameters& commandSuccessResu
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::onDestroyFaceFailure(int32_t code, const std::string& error)
|
||||
Nlsr::onDestroyFaceFailure(const ndn::nfd::ControlResponse& response)
|
||||
{
|
||||
std::cerr << error << " (code: " << code << ")";
|
||||
std::cerr << response.getText() << " (code: " << response.getCode() << ")";
|
||||
throw Error("Error: Face destruction failed");
|
||||
}
|
||||
|
||||
@@ -334,7 +345,7 @@ Nlsr::destroyFaces()
|
||||
it != adjacents.end(); it++) {
|
||||
m_fib.destroyFace((*it).getConnectingFaceUri(),
|
||||
std::bind(&Nlsr::onDestroyFaceSuccess, this, _1),
|
||||
std::bind(&Nlsr::onDestroyFaceFailure, this, _1, _2));
|
||||
std::bind(&Nlsr::onDestroyFaceFailure, this, _1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,18 +368,21 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
|
||||
adjacent->setFaceId(0);
|
||||
|
||||
// Only trigger an Adjacency LSA build if this node is changing from ACTIVE to INACTIVE
|
||||
// since this rebuild will effectively cancel the previous Adjacency LSA refresh event
|
||||
// and schedule a new one further in the future.
|
||||
// Only trigger an Adjacency LSA build if this node is changing
|
||||
// from ACTIVE to INACTIVE since this rebuild will effectively
|
||||
// cancel the previous Adjacency LSA refresh event and schedule
|
||||
// a new one further in the future.
|
||||
//
|
||||
// Continuously scheduling the refresh in the future will block the router from refreshing
|
||||
// its Adjacency LSA. Since other routers' Name prefixes' expiration times are updated
|
||||
// when this router refreshes its Adjacency LSA, the other routers' prefixes will expire
|
||||
// and be removed from the RIB.
|
||||
// Continuously scheduling the refresh in the future will block
|
||||
// the router from refreshing its Adjacency LSA. Since other
|
||||
// routers' Name prefixes' expiration times are updated when
|
||||
// this router refreshes its Adjacency LSA, the other routers'
|
||||
// prefixes will expire and be removed from the RIB.
|
||||
//
|
||||
// This check is required to fix Bug #2733 for now. This check would be unnecessary
|
||||
// to fix Bug #2733 when Issue #2732 is completed, but the check also helps with
|
||||
// optimization so it can remain even when Issue #2732 is implemented.
|
||||
// This check is required to fix Bug #2733 for now. This check
|
||||
// would be unnecessary to fix Bug #2733 when Issue #2732 is
|
||||
// completed, but the check also helps with optimization so it
|
||||
// can remain even when Issue #2732 is implemented.
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
adjacent->setStatus(Adjacent::STATUS_INACTIVE);
|
||||
|
||||
@@ -376,7 +390,12 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
// has met the HELLO retry threshold
|
||||
adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
|
||||
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
getRoutingTable().scheduleRoutingTableCalculation(*this);
|
||||
}
|
||||
else {
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-6
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,8 +29,9 @@
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/security/certificate-cache-ttl.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
#include <ndn-cxx/management/nfd-face-event-notification.hpp>
|
||||
#include <ndn-cxx/management/nfd-face-monitor.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
|
||||
#include <ndn-cxx/mgmt/dispatcher.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
#include "common.hpp"
|
||||
@@ -226,6 +227,12 @@ public:
|
||||
return m_syncLogicHandler;
|
||||
}
|
||||
|
||||
LsdbDatasetInterestHandler&
|
||||
getLsdbDatasetHandler()
|
||||
{
|
||||
return m_lsdbDatasetHandler;
|
||||
}
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
||||
@@ -282,6 +289,12 @@ public:
|
||||
return m_prefixUpdateProcessor;
|
||||
}
|
||||
|
||||
ndn::mgmt::Dispatcher&
|
||||
getDispatcher()
|
||||
{
|
||||
return m_dispatcher;
|
||||
}
|
||||
|
||||
void
|
||||
createFace(const std::string& faceUri,
|
||||
const CommandSucceedCallback& onSuccess,
|
||||
@@ -334,7 +347,7 @@ private:
|
||||
onDestroyFaceSuccess(const ndn::nfd::ControlParameters& commandSuccessResult);
|
||||
|
||||
void
|
||||
onDestroyFaceFailure(int32_t code, const std::string& error);
|
||||
onDestroyFaceFailure(const ndn::nfd::ControlResponse& response);
|
||||
|
||||
void
|
||||
onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification);
|
||||
@@ -366,9 +379,11 @@ private:
|
||||
Fib m_fib;
|
||||
NamePrefixTable m_namePrefixTable;
|
||||
SyncLogicHandler m_syncLogicHandler;
|
||||
HelloProtocol m_helloProtocol;
|
||||
LsdbDatasetInterestHandler m_lsdbDatasetHandler;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
security::CertificateStore m_certStore;
|
||||
@@ -377,12 +392,13 @@ private:
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
ndn::Name m_defaultCertName;
|
||||
update::PrefixUpdateProcessor m_prefixUpdateProcessor;
|
||||
ndn::mgmt::Dispatcher m_dispatcher;
|
||||
|
||||
ndn::nfd::FaceMonitor m_faceMonitor;
|
||||
|
||||
uint32_t m_firstHelloInterval;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -78,6 +78,7 @@ CoordinateLsaPublisher::CoordinateLsaPublisher(Lsdb& lsdb,
|
||||
{
|
||||
}
|
||||
|
||||
// Returns the list of coordinate LSAs represented by this object.
|
||||
std::list<tlv::CoordinateLsa>
|
||||
CoordinateLsaPublisher::getTlvLsas()
|
||||
{
|
||||
@@ -113,6 +114,8 @@ NameLsaPublisher::NameLsaPublisher(Lsdb& lsdb,
|
||||
{
|
||||
}
|
||||
|
||||
// Returns the list of name LSAs represented by this object.
|
||||
// Note: each name LSA has a list of prefixes as well.
|
||||
std::list<tlv::NameLsa>
|
||||
NameLsaPublisher::getTlvLsas()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -63,10 +63,11 @@ protected:
|
||||
getTlvLsas() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish adjacency lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
/*! \brief Class to publish adjacency lsa dataset
|
||||
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
|
||||
*/
|
||||
class AdjacencyLsaPublisher : public LsaPublisher<tlv::AdjacencyLsa>
|
||||
{
|
||||
public:
|
||||
@@ -74,6 +75,7 @@ public:
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
/*! \brief Returns the adj. LSAs represented by this object. */
|
||||
std::list<tlv::AdjacencyLsa>
|
||||
getTlvLsas();
|
||||
|
||||
@@ -84,10 +86,9 @@ private:
|
||||
const std::list<AdjLsa>& m_adjacencyLsas;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish coordinate lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
/*! \brief Class to publish coordinate lsa dataset
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class CoordinateLsaPublisher : public LsaPublisher<tlv::CoordinateLsa>
|
||||
{
|
||||
public:
|
||||
@@ -95,6 +96,7 @@ public:
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
/*! \brief Returns the cor. LSAs represented by this object. */
|
||||
std::list<tlv::CoordinateLsa>
|
||||
getTlvLsas();
|
||||
|
||||
@@ -105,17 +107,16 @@ private:
|
||||
const std::list<CoordinateLsa>& m_coordinateLsas;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish name lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
/*! \brief Class to publish name lsa dataset
|
||||
\sa https://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class NameLsaPublisher : public LsaPublisher<tlv::NameLsa>
|
||||
{
|
||||
public:
|
||||
NameLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
/*! \brief Returns the name LSAs represented by this object. */
|
||||
std::list<tlv::NameLsa>
|
||||
getTlvLsas();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,13 +19,20 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
/*! \file lsdb-dataset-interest-handler.cpp
|
||||
|
||||
This file details a class that is used by NLSRC and other command-line
|
||||
tools to examine the state of NLSR. This system is not designed to
|
||||
be used by routers to publish data to each other.
|
||||
*/
|
||||
|
||||
#include "lsdb-dataset-interest-handler.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-response.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/util/regex.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -37,10 +44,8 @@ const uint32_t LsdbDatasetInterestHandler::ERROR_CODE_UNSUPPORTED_COMMAND = 501;
|
||||
|
||||
LsdbDatasetInterestHandler::LsdbDatasetInterestHandler(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
const ndn::Name& routerName,
|
||||
ndn::KeyChain& keyChain)
|
||||
: LOCALHOST_COMMAND_PREFIX(ndn::Name(Nlsr::LOCALHOST_PREFIX).append(Lsdb::NAME_COMPONENT))
|
||||
, ROUTER_NAME_COMMAND_PREFIX(ndn::Name(routerName).append(Lsdb::NAME_COMPONENT))
|
||||
, m_face(face)
|
||||
, m_keyChain(keyChain)
|
||||
, m_adjacencyLsaPublisher(lsdb, face, keyChain)
|
||||
@@ -66,10 +71,10 @@ LsdbDatasetInterestHandler::startListeningOnLocalhost()
|
||||
void
|
||||
LsdbDatasetInterestHandler::startListeningOnRouterPrefix()
|
||||
{
|
||||
_LOG_DEBUG("Setting interest filter for: " << ROUTER_NAME_COMMAND_PREFIX);
|
||||
m_face.setInterestFilter(ROUTER_NAME_COMMAND_PREFIX,
|
||||
_LOG_DEBUG("Setting interest filter for: " << m_routerNameCommandPrefix);
|
||||
m_face.setInterestFilter(m_routerNameCommandPrefix,
|
||||
std::bind(&LsdbDatasetInterestHandler::onInterest, this, _2,
|
||||
std::cref(ROUTER_NAME_COMMAND_PREFIX)));
|
||||
std::cref(m_routerNameCommandPrefix)));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -94,7 +99,6 @@ LsdbDatasetInterestHandler::isValidCommandPrefix(const ndn::Interest& interest,
|
||||
{
|
||||
size_t commandSize = interest.getName().size();
|
||||
|
||||
// Does the Interest match the command prefix with one additional component?
|
||||
return (commandSize == commandPrefix.size() + 1 && commandPrefix.isPrefixOf(interest.getName()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish all lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Class to publish all lsa dataset
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbDatasetInterestHandler
|
||||
{
|
||||
@@ -48,7 +48,6 @@ public:
|
||||
|
||||
LsdbDatasetInterestHandler(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
const ndn::Name& routerName,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
void
|
||||
@@ -63,10 +62,16 @@ public:
|
||||
return LOCALHOST_COMMAND_PREFIX;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
ndn::Name&
|
||||
getRouterNameCommandPrefix()
|
||||
{
|
||||
return ROUTER_NAME_COMMAND_PREFIX;
|
||||
return m_routerNameCommandPrefix;
|
||||
}
|
||||
|
||||
void
|
||||
setRouterNameCommandPrefix(const ndn::Name& routerName) {
|
||||
m_routerNameCommandPrefix = routerName;
|
||||
m_routerNameCommandPrefix.append(Lsdb::NAME_COMPONENT);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -84,7 +89,7 @@ private:
|
||||
|
||||
private:
|
||||
const ndn::Name LOCALHOST_COMMAND_PREFIX;
|
||||
const ndn::Name ROUTER_NAME_COMMAND_PREFIX;
|
||||
ndn::Name m_routerNameCommandPrefix;
|
||||
|
||||
ndn::Face& m_face;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -30,9 +30,9 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish lsdb status dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Publishes lsdb status dataset
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbStatusPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, Regents of the University of California,
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -31,8 +31,8 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/** \brief provides a publisher of Status Dataset or other segmented octet stream
|
||||
* \sa http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
/*! \brief provides a publisher of Status Dataset or other segmented octet stream
|
||||
\sa http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
*/
|
||||
template <class FaceBase>
|
||||
class SegmentPublisher : ndn::noncopyable
|
||||
@@ -65,10 +65,11 @@ public:
|
||||
return ndn::time::milliseconds(1000);
|
||||
}
|
||||
|
||||
/** \brief Publish data under provided prefix
|
||||
/*! \brief Publish data under provided prefix
|
||||
*/
|
||||
void
|
||||
publish(const ndn::Name& prefix)
|
||||
publish(const ndn::Name& prefix,
|
||||
const ndn::security::SigningInfo& signingInfo = ndn::security::KeyChain::DEFAULT_SIGNING_INFO)
|
||||
{
|
||||
ndn::EncodingBuffer buffer;
|
||||
generate(buffer);
|
||||
@@ -99,22 +100,22 @@ public:
|
||||
data->setFinalBlockId(segmentName[-1]);
|
||||
}
|
||||
|
||||
publishSegment(data);
|
||||
publishSegment(data, signingInfo);
|
||||
++segmentNo;
|
||||
} while (segmentBegin < end);
|
||||
}
|
||||
|
||||
protected:
|
||||
/** \brief In a derived class, write the octets into outBuffer.
|
||||
/*! \brief In a derived class, write the octets into outBuffer.
|
||||
*/
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) = 0;
|
||||
|
||||
private:
|
||||
void
|
||||
publishSegment(ndn::shared_ptr<ndn::Data>& data)
|
||||
publishSegment(ndn::shared_ptr<ndn::Data>& data, const ndn::security::SigningInfo& signingInfo)
|
||||
{
|
||||
m_keyChain.sign(*data);
|
||||
m_keyChain.sign(*data, signingInfo);
|
||||
m_face.put(*data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -21,7 +21,6 @@
|
||||
*
|
||||
**/
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#include "common.hpp"
|
||||
@@ -36,11 +35,10 @@ 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() << ")");
|
||||
for (const auto& it : m_table) {
|
||||
_LOG_DEBUG("Face Map Entry (FaceUri: " << (it.second).getFaceUri()
|
||||
<< " Face Id: " << (it.second).getFaceId() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NLSR
|
||||
} // namespace nlsr
|
||||
+15
-19
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -17,8 +17,6 @@
|
||||
* 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>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_FACE_MAP_HPP
|
||||
#define NLSR_FACE_MAP_HPP
|
||||
@@ -26,9 +24,12 @@
|
||||
#include <ndn-cxx/common.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class FaceMapEntry {
|
||||
class FaceMapEntry
|
||||
{
|
||||
|
||||
public:
|
||||
FaceMapEntry(const std::string& faceUri, uint32_t faceId)
|
||||
@@ -72,7 +73,8 @@ private:
|
||||
uint32_t m_faceId;
|
||||
};
|
||||
|
||||
class FaceMap {
|
||||
class FaceMap
|
||||
{
|
||||
|
||||
public:
|
||||
FaceMap()
|
||||
@@ -87,15 +89,12 @@ public:
|
||||
update(const std::string& faceUri, uint32_t faceId)
|
||||
{
|
||||
FaceMapEntry fme(faceUri, faceId);
|
||||
std::list<FaceMapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&FaceMapEntry::compare,
|
||||
&fme, _1));
|
||||
std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
|
||||
if (it == m_table.end()) {
|
||||
m_table.push_back(fme);
|
||||
m_table.emplace(faceUri, fme);
|
||||
}
|
||||
else {
|
||||
(*it).setFaceId(fme.getFaceId());
|
||||
(it->second).setFaceId(fme.getFaceId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,12 +102,9 @@ public:
|
||||
getFaceId(const std::string& faceUri)
|
||||
{
|
||||
FaceMapEntry fme(faceUri, 0);
|
||||
std::list<FaceMapEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&FaceMapEntry::compare,
|
||||
&fme, _1));
|
||||
std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
|
||||
if (it != m_table.end()) {
|
||||
return (*it).getFaceId();
|
||||
return (it->second).getFaceId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -117,9 +113,9 @@ public:
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
std::list<FaceMapEntry> m_table;
|
||||
std::map<std::string, FaceMapEntry> m_table;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_FACE_MAP_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -40,4 +40,4 @@ FibEntry::writeLog()
|
||||
m_nexthopList.writeLog();
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -113,6 +113,6 @@ private:
|
||||
NexthopList m_nexthopList;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_FIB_ENTRY_HPP
|
||||
+39
-56
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -16,11 +16,9 @@
|
||||
*
|
||||
* 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 <list>
|
||||
#include <map>
|
||||
|
||||
#include <cmath>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
@@ -41,19 +39,12 @@ const uint64_t Fib::GRACE_PERIOD = 10;
|
||||
using namespace std;
|
||||
using namespace ndn;
|
||||
|
||||
static bool
|
||||
fibEntryNameCompare(const FibEntry& fibEntry, const ndn::Name& name)
|
||||
{
|
||||
return fibEntry.getName() == name;
|
||||
}
|
||||
|
||||
void
|
||||
Fib::cancelScheduledExpiringEvent(EventId eid)
|
||||
{
|
||||
m_scheduler.cancelEvent(eid);
|
||||
}
|
||||
|
||||
|
||||
ndn::EventId
|
||||
Fib::scheduleEntryExpiration(const ndn::Name& name, int32_t feSeqNum,
|
||||
const ndn::time::seconds& expTime)
|
||||
@@ -68,20 +59,18 @@ void
|
||||
Fib::remove(const ndn::Name& name)
|
||||
{
|
||||
_LOG_DEBUG("Fib::remove called");
|
||||
std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&fibEntryNameCompare, _1, name));
|
||||
std::map<ndn::Name, FibEntry>::iterator it = m_table.find(name);
|
||||
if (it != m_table.end()) {
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
(*it).getNexthopList().getNextHops().begin();
|
||||
nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
|
||||
for (std::set<NextHop, NextHopComparator>::iterator nhit =
|
||||
(it->second).getNexthopList().getNextHops().begin();
|
||||
nhit != (it->second).getNexthopList().getNextHops().end(); nhit++) {
|
||||
//remove entry from NDN-FIB
|
||||
if (isPrefixUpdatable(it->getName())) {
|
||||
unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
|
||||
if (isPrefixUpdatable((it->second).getName())) {
|
||||
unregisterPrefix((it->second).getName(), nhit->getConnectingFaceUri());
|
||||
}
|
||||
}
|
||||
_LOG_DEBUG("Cancelling Scheduled event. Name: " << name);
|
||||
cancelScheduledExpiringEvent((*it).getExpiringEventId());
|
||||
cancelScheduledExpiringEvent((it->second).getExpiringEventId());
|
||||
m_table.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -110,8 +99,6 @@ Fib::addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd)
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
entry.getNexthopList().sort();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -156,9 +143,6 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
{
|
||||
_LOG_DEBUG("Fib::update called");
|
||||
|
||||
// Sort all of the next hops so lower cost hops are prioritized
|
||||
allHops.sort();
|
||||
|
||||
// Get the max possible faces which is the minumum of the configuration setting and
|
||||
// the length of the list of all next hops.
|
||||
unsigned int maxFaces = getNumberOfFacesForName(allHops);
|
||||
@@ -173,9 +157,7 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
hopsToAdd.addNextHop(*it);
|
||||
}
|
||||
|
||||
std::list<FibEntry>::iterator entryIt = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&fibEntryNameCompare, _1, name));
|
||||
std::map<ndn::Name, FibEntry>::iterator entryIt = m_table.find(name);
|
||||
|
||||
// New FIB entry
|
||||
if (entryIt == m_table.end()) {
|
||||
@@ -198,13 +180,12 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
// Schedule entry to be refreshed
|
||||
entry.setExpiringEventId(scheduleEntryExpiration(name , entry.getSeqNo(),
|
||||
ndn::time::seconds(m_refreshTime)));
|
||||
m_table.push_back(entry);
|
||||
m_table.emplace(name, entry);
|
||||
}
|
||||
else {
|
||||
// Existing FIB entry
|
||||
_LOG_DEBUG("Existing FIB Entry");
|
||||
|
||||
FibEntry& entry = *entryIt;
|
||||
FibEntry& entry = (entryIt->second);
|
||||
|
||||
// Remove empty FIB entry
|
||||
if (hopsToAdd.getSize() == 0) {
|
||||
@@ -235,15 +216,16 @@ void
|
||||
Fib::clean()
|
||||
{
|
||||
_LOG_DEBUG("Fib::clean called");
|
||||
for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
|
||||
for (std::map<ndn::Name, FibEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end();
|
||||
++it) {
|
||||
_LOG_DEBUG("Cancelling Scheduled event. Name: " << it->getName());
|
||||
cancelScheduledExpiringEvent((*it).getExpiringEventId());
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
(*it).getNexthopList().getNextHops().begin();
|
||||
nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
|
||||
_LOG_DEBUG("Cancelling Scheduled event. Name: " << (it->second).getName());
|
||||
cancelScheduledExpiringEvent((it->second).getExpiringEventId());
|
||||
for (std::set<NextHop, NextHopComparator>::iterator nhit =
|
||||
(it->second).getNexthopList().getNextHops().begin();
|
||||
nhit != (it->second).getNexthopList().getNextHops().end(); nhit++) {
|
||||
//Remove entry from NDN-FIB
|
||||
unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
|
||||
unregisterPrefix((it->second).getName(), nhit->getConnectingFaceUri());
|
||||
}
|
||||
}
|
||||
if (m_table.size() > 0) {
|
||||
@@ -279,7 +261,7 @@ void
|
||||
Fib::removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
|
||||
const ndn::Name& name)
|
||||
{
|
||||
for (std::list<NextHop>::iterator it = nl.getNextHops().begin();
|
||||
for (std::set<NextHop, NextHopComparator>::iterator it = nl.getNextHops().begin();
|
||||
it != nl.getNextHops().end(); ++it) {
|
||||
if (it->getConnectingFaceUri() != doNotRemoveHopFaceUri) {
|
||||
//Remove FIB Entry from NDN-FIB
|
||||
@@ -385,7 +367,7 @@ Fib::registerPrefixInNfd(ndn::nfd::ControlParameters& parameters,
|
||||
"Successful in name registration",
|
||||
faceUri),
|
||||
ndn::bind(&Fib::onRegistrationFailure,
|
||||
this, _1, _2,
|
||||
this, _1,
|
||||
"Failed in name registration",
|
||||
parameters,
|
||||
faceUri, times));
|
||||
@@ -426,7 +408,7 @@ Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
|
||||
ndn::bind(&Fib::onUnregistration, this, _1,
|
||||
"Successful in unregistering name"),
|
||||
ndn::bind(&Fib::onUnregistrationFailure,
|
||||
this, _1, _2,
|
||||
this, _1,
|
||||
"Failed in unregistering name"));
|
||||
}
|
||||
}
|
||||
@@ -442,7 +424,7 @@ Fib::setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t co
|
||||
m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
|
||||
bind(&Fib::onSetStrategySuccess, this, _1,
|
||||
"Successfully set strategy choice"),
|
||||
bind(&Fib::onSetStrategyFailure, this, _1, _2,
|
||||
bind(&Fib::onSetStrategyFailure, this, _1,
|
||||
parameters,
|
||||
count,
|
||||
"Failed to set strategy choice"));
|
||||
@@ -467,13 +449,13 @@ Fib::onUnregistration(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
Fib::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
const std::string& faceUri,
|
||||
uint8_t times)
|
||||
{
|
||||
_LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
|
||||
_LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
|
||||
_LOG_DEBUG("Prefix: " << parameters.getName() << " failed for: " << times);
|
||||
if (times < 3) {
|
||||
_LOG_DEBUG("Trying to register again...");
|
||||
@@ -488,10 +470,10 @@ Fib::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onUnregistrationFailure(uint32_t code, const std::string& error,
|
||||
const std::string& message)
|
||||
Fib::onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message)
|
||||
{
|
||||
_LOG_DEBUG(message << ": " << error << " (code: " << code << ")");
|
||||
_LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -503,10 +485,10 @@ Fib::onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResul
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onSetStrategyFailure(uint32_t code, const std::string& error,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message)
|
||||
Fib::onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message)
|
||||
{
|
||||
_LOG_DEBUG(message << ": " << parameters.getStrategy() << " "
|
||||
<< "for name: " << parameters.getName());
|
||||
@@ -519,10 +501,11 @@ void
|
||||
Fib::writeLog()
|
||||
{
|
||||
_LOG_DEBUG("-------------------FIB-----------------------------");
|
||||
for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
|
||||
for (std::map<ndn::Name, FibEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end();
|
||||
++it) {
|
||||
(*it).writeLog();
|
||||
(it->second).writeLog();
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+14
-15
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -17,16 +18,15 @@
|
||||
* 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>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_FIB_HPP
|
||||
#define NLSR_FIB_HPP
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <ndn-cxx/management/nfd-controller.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/controller.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
#include "face-map.hpp"
|
||||
#include "fib-entry.hpp"
|
||||
@@ -35,8 +35,8 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
typedef ndn::function<void(const ndn::nfd::ControlParameters&)> CommandSucceedCallback;
|
||||
typedef ndn::function<void(uint32_t/*code*/,const std::string&/*reason*/)> CommandFailCallback;
|
||||
typedef ndn::nfd::Controller::CommandSucceedCallback CommandSucceedCallback;
|
||||
typedef ndn::nfd::Controller::CommandFailCallback CommandFailCallback;
|
||||
|
||||
class AdjacencyList;
|
||||
class ConfParameter;
|
||||
@@ -163,30 +163,29 @@ private:
|
||||
const std::string& message);
|
||||
|
||||
void
|
||||
onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
const std::string& faceUri,
|
||||
uint8_t times);
|
||||
|
||||
void
|
||||
onUnregistrationFailure(uint32_t code, const std::string& error,
|
||||
const std::string& message);
|
||||
onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message);
|
||||
|
||||
void
|
||||
onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message);
|
||||
|
||||
void
|
||||
onSetStrategyFailure(uint32_t code, const std::string& error,
|
||||
onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message);
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
std::list<FibEntry> m_table;
|
||||
std::map<ndn::Name, FibEntry> m_table;
|
||||
int32_t m_refreshTime;
|
||||
ndn::nfd::Controller m_controller;
|
||||
util::FaceController m_faceController;
|
||||
@@ -201,5 +200,5 @@ private:
|
||||
static const uint64_t GRACE_PERIOD;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //NLSR_FIB_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
+11
-3
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -112,6 +112,14 @@ Map::createFromAdjLsdb(Nlsr& pnlsr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::createFromCoordinateLsdb(Nlsr& nlsr)
|
||||
{
|
||||
for (CoordinateLsa lsa : nlsr.getLsdb().getCoordinateLsdb()) {
|
||||
addEntry(lsa.getOrigRouter());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::reset()
|
||||
{
|
||||
@@ -129,4 +137,4 @@ Map::writeLog()
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
} // namespace nlsr
|
||||
+10
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -43,13 +43,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Add a map entry to this map.
|
||||
\param rtrName The name of the router.
|
||||
|
||||
Adds a router to this map. Each entry is also given an arbitrary,
|
||||
ascending mappingNo (mapping number).
|
||||
*/
|
||||
void
|
||||
addEntry(const ndn::Name& rtrName);
|
||||
|
||||
void
|
||||
createFromAdjLsdb(Nlsr& pnlsr);
|
||||
|
||||
void
|
||||
createFromCoordinateLsdb(Nlsr& nlsr);
|
||||
|
||||
const ndn::Name
|
||||
getRouterNameByMappingNo(int32_t mn);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,79 +33,80 @@ void
|
||||
NamePrefixTableEntry::generateNhlfromRteList()
|
||||
{
|
||||
m_nexthopList.reset();
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
|
||||
it != m_rteList.end(); ++it)
|
||||
{
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
(*it).getNexthopList().getNextHops().begin();
|
||||
nhit != (*it).getNexthopList().getNextHops().end(); ++nhit)
|
||||
{
|
||||
m_nexthopList.addNextHop((*nhit));
|
||||
for (auto rtpeItr = m_rteList.begin(); rtpeItr != m_rteList.end(); ++rtpeItr) {
|
||||
for (auto nhItr = (*rtpeItr)->getNexthopList().getNextHops().begin();
|
||||
nhItr != (*rtpeItr)->getNexthopList().getNextHops().end();
|
||||
++nhItr) {
|
||||
m_nexthopList.addNextHop((*nhItr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static bool
|
||||
rteCompare(RoutingTableEntry& rte, ndn::Name& destRouter)
|
||||
uint64_t
|
||||
NamePrefixTableEntry::removeRoutingTableEntry(shared_ptr<RoutingTablePoolEntry>
|
||||
rtpePtr)
|
||||
{
|
||||
return rte.getDestination() == destRouter;
|
||||
auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
|
||||
|
||||
if (rtpeItr != m_rteList.end()) {
|
||||
(*rtpeItr)->decrementUseCount();
|
||||
m_rteList.erase(rtpeItr);
|
||||
}
|
||||
else {
|
||||
_LOG_ERROR("Routing entry for: " << rtpePtr->getDestination()
|
||||
<< " not found in NPT entry: " << getNamePrefix());
|
||||
}
|
||||
return (*rtpeItr)->getUseCount();
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::removeRoutingTableEntry(RoutingTableEntry& rte)
|
||||
NamePrefixTableEntry::addRoutingTableEntry(shared_ptr<RoutingTablePoolEntry>
|
||||
rtpePtr)
|
||||
{
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rteList.begin(),
|
||||
m_rteList.end(),
|
||||
bind(&rteCompare, _1, rte.getDestination()));
|
||||
if (it != m_rteList.end())
|
||||
{
|
||||
m_rteList.erase(it);
|
||||
}
|
||||
}
|
||||
auto rtpeItr = std::find(m_rteList.begin(), m_rteList.end(), rtpePtr);
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::addRoutingTableEntry(RoutingTableEntry& rte)
|
||||
{
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rteList.begin(),
|
||||
m_rteList.end(),
|
||||
bind(&rteCompare, _1, rte.getDestination()));
|
||||
if (it == m_rteList.end())
|
||||
{
|
||||
m_rteList.push_back(rte);
|
||||
}
|
||||
else
|
||||
{
|
||||
(*it).getNexthopList().reset(); // reseting existing routing table's next hop
|
||||
for (std::list<NextHop>::iterator nhit =
|
||||
rte.getNexthopList().getNextHops().begin();
|
||||
nhit != rte.getNexthopList().getNextHops().end(); ++nhit) {
|
||||
(*it).getNexthopList().addNextHop((*nhit));
|
||||
}
|
||||
// Ensure that this is a new entry
|
||||
if (rtpeItr == m_rteList.end()) {
|
||||
// Adding a new routing entry to the NPT entry
|
||||
rtpePtr->incrementUseCount();
|
||||
m_rteList.push_back(rtpePtr);
|
||||
}
|
||||
// Note: we don't need to update in the else case because these are
|
||||
// pointers, and they are centrally-located in the NPT and will all
|
||||
// be updated there.
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::writeLog()
|
||||
{
|
||||
_LOG_DEBUG("Name: " << m_namePrefix);
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
|
||||
it != m_rteList.end(); ++it) {
|
||||
_LOG_DEBUG("Destination: " << (*it).getDestination());
|
||||
for (auto it = m_rteList.begin(); it != m_rteList.end(); ++it) {
|
||||
_LOG_DEBUG("Destination: " << (*it)->getDestination());
|
||||
_LOG_DEBUG("Nexthops: ");
|
||||
(*it).getNexthopList().writeLog();
|
||||
(*it)->getNexthopList().writeLog();
|
||||
}
|
||||
m_nexthopList.writeLog();
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const NamePrefixTableEntry& rhs)
|
||||
{
|
||||
return (lhs.getNamePrefix() == rhs.getNamePrefix());
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const ndn::Name& rhs)
|
||||
{
|
||||
return (lhs.getNamePrefix() == rhs);
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTableEntry& entry)
|
||||
{
|
||||
os << "Name: " << entry.getNamePrefix() << "\n";
|
||||
|
||||
for (const RoutingTableEntry& rte : entry.getRteList()) {
|
||||
os << "Destination: " << rte.getDestination() << "\n";
|
||||
for (const shared_ptr<RoutingTablePoolEntry> rtpePtr : entry.getRteList()) {
|
||||
os << "Destination: " << rtpePtr->getDestination() << "\n";
|
||||
}
|
||||
|
||||
return os;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,7 +22,9 @@
|
||||
#ifndef NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
#define NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
|
||||
#include "routing-table-entry.hpp"
|
||||
#include "routing-table-pool-entry.hpp"
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
@@ -48,7 +50,7 @@ public:
|
||||
return m_namePrefix;
|
||||
}
|
||||
|
||||
const std::list<RoutingTableEntry>&
|
||||
const std::list<std::shared_ptr<RoutingTablePoolEntry>>&
|
||||
getRteList() const
|
||||
{
|
||||
return m_rteList;
|
||||
@@ -58,9 +60,8 @@ public:
|
||||
resetRteListNextHop()
|
||||
{
|
||||
if (m_rteList.size() > 0) {
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_rteList.begin();
|
||||
it != m_rteList.end(); ++it) {
|
||||
(*it).getNexthopList().reset();
|
||||
for (auto it = m_rteList.begin(); it != m_rteList.end(); ++it) {
|
||||
(*it)->getNexthopList().reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,24 +78,45 @@ public:
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
/*! \brief Generates a next-hop list from routing table entries. */
|
||||
void
|
||||
generateNhlfromRteList();
|
||||
|
||||
void
|
||||
removeRoutingTableEntry(RoutingTableEntry& rte);
|
||||
/*! \brief Removes a routing entry from this NPT entry.
|
||||
\param rtpePtr The routing entry
|
||||
\return The remaining number of other NPTs using the removed routing entry.
|
||||
*/
|
||||
uint64_t
|
||||
removeRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
|
||||
|
||||
/*! \brief Adds a routing entry to this NPT entry.
|
||||
\param rtpePtr The routing entry.
|
||||
|
||||
Adds a routing table pool entry to this NPT entry's list
|
||||
(reminder: each RTPE has a next-hop list). They are used to
|
||||
calculate this entry's overall next-hop list.
|
||||
*/
|
||||
void
|
||||
addRoutingTableEntry(RoutingTableEntry& rte);
|
||||
addRoutingTableEntry(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
|
||||
|
||||
void
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
ndn::Name m_namePrefix;
|
||||
std::list<RoutingTableEntry> m_rteList;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
std::list<std::shared_ptr<RoutingTablePoolEntry>> m_rteList;
|
||||
NexthopList m_nexthopList;
|
||||
|
||||
};
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const NamePrefixTableEntry& rhs);
|
||||
|
||||
bool
|
||||
operator==(const NamePrefixTableEntry& lhs, const ndn::Name& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTableEntry& entry);
|
||||
|
||||
|
||||
+172
-108
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,110 +33,90 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER("NamePrefixTable");
|
||||
|
||||
static bool
|
||||
bool
|
||||
npteCompare(NamePrefixTableEntry& npte, const ndn::Name& name)
|
||||
{
|
||||
return npte.getNamePrefix() == name;
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::addEntry(const ndn::Name& name, RoutingTableEntry& rte)
|
||||
{
|
||||
NptEntryList::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
if (it == m_table.end()) {
|
||||
_LOG_TRACE("Adding origin: " << rte.getDestination() << " to new name prefix: " << name);
|
||||
|
||||
NamePrefixTableEntry entry(name);
|
||||
|
||||
entry.addRoutingTableEntry(rte);
|
||||
|
||||
entry.generateNhlfromRteList();
|
||||
entry.getNexthopList().sort();
|
||||
|
||||
m_table.push_back(entry);
|
||||
|
||||
if (rte.getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << entry);
|
||||
m_nlsr.getFib().update(name, entry.getNexthopList());
|
||||
}
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE("Adding origin: " << rte.getDestination() << " to existing prefix: " << *it);
|
||||
|
||||
it->addRoutingTableEntry(rte);
|
||||
|
||||
it->generateNhlfromRteList();
|
||||
it->getNexthopList().sort();
|
||||
|
||||
if (it->getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << *it);
|
||||
m_nlsr.getFib().update(name, it->getNexthopList());
|
||||
}
|
||||
else {
|
||||
// The routing table may recalculate and add a routing table entry with no next hops to
|
||||
// replace an existing routing table entry. In this case, the name prefix is no longer
|
||||
// reachable through a next hop and should be removed from the FIB. But, the prefix
|
||||
// should remain in the Name Prefix Table as a future routing table calculation may
|
||||
// add next hops.
|
||||
_LOG_TRACE(*it << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::removeEntry(const ndn::Name& name, RoutingTableEntry& rte)
|
||||
{
|
||||
NptEntryList::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
if (it != m_table.end()) {
|
||||
_LOG_TRACE("Removing origin: " << rte.getDestination() << " from prefix: " << *it);
|
||||
|
||||
it->removeRoutingTableEntry(rte);
|
||||
|
||||
// If the prefix is a router prefix and it does not have any other routing table entries,
|
||||
// the Adjacency/Coordinate LSA associated with that origin router has been removed from
|
||||
// the LSDB and so the router prefix should be removed from the Name Prefix Table.
|
||||
//
|
||||
// If the prefix is an advertised name prefix:
|
||||
// If another router advertises this name prefix, the RteList should have another entry
|
||||
// for that router; the next hops should be recalculated and installed in the FIB.
|
||||
//
|
||||
// If no other router advertises this name prefix, the RteList should be empty and the
|
||||
// prefix can be removed from the Name Prefix Table. Once a new Name LSA advertises this
|
||||
// prefix, a new entry for the prefix will be created.
|
||||
//
|
||||
if (it->getRteListSize() == 0) {
|
||||
_LOG_TRACE(*it << " has no routing table entries; removing from table and FIB");
|
||||
m_table.erase(it);
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE(*it << " has other routing table entries; updating FIB with next hops");
|
||||
it->generateNhlfromRteList();
|
||||
it->getNexthopList().sort();
|
||||
|
||||
m_nlsr.getFib().update(name, it->getNexthopList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
{
|
||||
_LOG_DEBUG("Adding origin: " << destRouter << " to " << name);
|
||||
|
||||
RoutingTableEntry* rteCheck = m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
// Check if the advertised name prefix is in the table already.
|
||||
NptEntryList::iterator nameItr = std::find(m_table.begin(),
|
||||
m_table.end(),
|
||||
name);
|
||||
|
||||
if (rteCheck != nullptr) {
|
||||
addEntry(name, *rteCheck);
|
||||
// Attempt to find a routing table pool entry (RTPE) we can use.
|
||||
RtpEntryMap::iterator rtpeItr = m_rtpool.find(destRouter);
|
||||
|
||||
// These declarations just to make the compiler happy...
|
||||
RoutingTablePoolEntry rtpe;
|
||||
std::shared_ptr<RoutingTablePoolEntry> rtpePtr(nullptr);
|
||||
|
||||
// There isn't currently a routing table entry in the pool for this name
|
||||
if (rtpeItr == m_rtpool.end()) {
|
||||
// See if there is a routing table entry available we could use
|
||||
RoutingTableEntry* routeEntryPtr = m_nlsr.getRoutingTable()
|
||||
.findRoutingTableEntry(destRouter);
|
||||
|
||||
// We have to create a new routing table entry
|
||||
if (routeEntryPtr == nullptr) {
|
||||
rtpe = RoutingTablePoolEntry(destRouter, 0);
|
||||
}
|
||||
// There was already a usable one in the routing table
|
||||
else {
|
||||
rtpe = RoutingTablePoolEntry(*routeEntryPtr, 0);
|
||||
}
|
||||
|
||||
// Add the new pool object to the pool.
|
||||
rtpePtr = addRtpeToPool(rtpe);
|
||||
}
|
||||
// There was one already, so just fetch that one.
|
||||
else {
|
||||
rtpePtr = (*rtpeItr).second;
|
||||
}
|
||||
|
||||
// Either we have to make a new NPT entry or there already was one.
|
||||
if (nameItr == m_table.end()) {
|
||||
_LOG_DEBUG("Adding origin: " << rtpePtr->getDestination()
|
||||
<< " to a new name prefix: " << name);
|
||||
NamePrefixTableEntry npte(name);
|
||||
npte.addRoutingTableEntry(rtpePtr);
|
||||
npte.generateNhlfromRteList();
|
||||
m_table.push_back(npte);
|
||||
|
||||
// If this entry has next hops, we need to inform the FIB
|
||||
if (npte.getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << npte);
|
||||
m_nlsr.getFib().update(name, npte.getNexthopList());
|
||||
}
|
||||
// The routing table may recalculate and add a routing table entry
|
||||
// with no next hops to replace an existing routing table entry. In
|
||||
// this case, the name prefix is no longer reachable through a next
|
||||
// hop and should be removed from the FIB. But, the prefix should
|
||||
// remain in the Name Prefix Table as a future routing table
|
||||
// calculation may add next hops.
|
||||
else {
|
||||
_LOG_TRACE(npte << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
addEntry(name, rte);
|
||||
_LOG_TRACE("Adding origin: " << rtpePtr->getDestination()
|
||||
<< " to existing prefix: " << *nameItr);
|
||||
nameItr->addRoutingTableEntry(rtpePtr);
|
||||
nameItr->generateNhlfromRteList();
|
||||
|
||||
if (nameItr->getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << (*nameItr));
|
||||
m_nlsr.getFib().update(name, nameItr->getNexthopList());
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE((*nameItr) << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,14 +125,64 @@ NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
{
|
||||
_LOG_DEBUG("Removing origin: " << destRouter << " from " << name);
|
||||
|
||||
RoutingTableEntry* rteCheck = m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
// Fetch an iterator to the appropriate pair object in the pool.
|
||||
RtpEntryMap::iterator rtpeItr = m_rtpool.find(destRouter);
|
||||
|
||||
if (rteCheck != nullptr) {
|
||||
removeEntry(name, *rteCheck);
|
||||
// Simple error checking to prevent any unusual behavior in the case
|
||||
// that we try to remove an entry that isn't there.
|
||||
if (rtpeItr == m_rtpool.end()) {
|
||||
_LOG_DEBUG("No entry for origin: " << destRouter
|
||||
<< " found, so it cannot be removed from prefix: "
|
||||
<< name);
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<RoutingTablePoolEntry> rtpePtr = rtpeItr->second;
|
||||
|
||||
// Ensure that the entry exists
|
||||
NptEntryList::iterator nameItr = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
if (nameItr != m_table.end()) {
|
||||
_LOG_TRACE("Removing origin: " << rtpePtr->getDestination()
|
||||
<< " from prefix: " << *nameItr);
|
||||
|
||||
// Rather than iterating through the whole list periodically, just
|
||||
// delete them here if they have no references.
|
||||
if ((*nameItr).removeRoutingTableEntry(rtpePtr) == 0) {
|
||||
deleteRtpeFromPool(rtpePtr);
|
||||
}
|
||||
|
||||
// If the prefix is a router prefix and it does not have any other
|
||||
// routing table entries, the Adjacency/Coordinate LSA associated
|
||||
// with that origin router has been removed from the LSDB and so
|
||||
// the router prefix should be removed from the Name Prefix Table.
|
||||
//
|
||||
// If the prefix is an advertised name prefix: If another router
|
||||
// advertises this name prefix, the RteList should have another
|
||||
// entry for that router; the next hops should be recalculated
|
||||
// and installed in the FIB.
|
||||
//
|
||||
// If no other router advertises this name prefix, the RteList
|
||||
// should be empty and the prefix can be removed from the Name
|
||||
// Prefix Table. Once a new Name LSA advertises this prefix, a
|
||||
// new entry for the prefix will be created.
|
||||
//
|
||||
if ((*nameItr).getRteListSize() == 0) {
|
||||
_LOG_TRACE(*nameItr << " has no routing table entries;"
|
||||
<< " removing from table and FIB");
|
||||
m_table.erase(nameItr);
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
else {
|
||||
_LOG_TRACE(*nameItr << " has other routing table entries;"
|
||||
<< " updating FIB with next hops");
|
||||
(*nameItr).generateNhlfromRteList();
|
||||
m_nlsr.getFib().update(name, (*nameItr).getNexthopList());
|
||||
}
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
removeEntry(name, rte);
|
||||
_LOG_DEBUG("Attempted to remove origin: " << rtpePtr->getDestination()
|
||||
<< " from non-existant prefix: " << name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,26 +191,60 @@ NamePrefixTable::updateWithNewRoute()
|
||||
{
|
||||
_LOG_DEBUG("Updating table with newly calculated routes");
|
||||
|
||||
// Update each name prefix entry in the Name Prefix Table with newly calculated next hops
|
||||
for (const NamePrefixTableEntry& prefixEntry : m_table) {
|
||||
for (const RoutingTableEntry& routingEntry : prefixEntry.getRteList()) {
|
||||
_LOG_TRACE("Updating next hops to origin: " << routingEntry.getDestination()
|
||||
<< " for prefix: " << prefixEntry);
|
||||
|
||||
// Update each name prefix table entry in the NPT with the
|
||||
// newly calculated next hops.
|
||||
for (auto&& npte : m_table) {
|
||||
// For each routing table pool entry in this NPT entry.
|
||||
for (auto&& rtpe : npte.getRteList()) {
|
||||
_LOG_TRACE("Updating next hops to origin: " << rtpe->getDestination()
|
||||
<< " for prefix: " << npte);
|
||||
RoutingTableEntry* rteCheck =
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry(routingEntry.getDestination());
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry(rtpe->getDestination());
|
||||
|
||||
// If there is a routing table entry for this prefix, update the NPT with it.
|
||||
if (rteCheck != nullptr) {
|
||||
addEntry(prefixEntry.getNamePrefix(), *rteCheck);
|
||||
rtpe->setNexthopList(rteCheck->getNexthopList());
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(routingEntry.getDestination());
|
||||
addEntry(prefixEntry.getNamePrefix(), rte);
|
||||
rtpe->getNexthopList().reset();
|
||||
}
|
||||
addEntry(npte.getNamePrefix(), rtpe->getDestination());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inserts the routing table pool entry into the NPT's RTE storage
|
||||
// pool. This cannot fail, so the pool is guaranteed to contain the
|
||||
// item after this occurs.
|
||||
std::shared_ptr<RoutingTablePoolEntry>
|
||||
NamePrefixTable::addRtpeToPool(RoutingTablePoolEntry& rtpe)
|
||||
{
|
||||
RtpEntryMap::iterator poolItr =
|
||||
m_rtpool.insert(std::make_pair(rtpe.getDestination(),
|
||||
std::make_shared<RoutingTablePoolEntry>
|
||||
(rtpe)))
|
||||
.first;
|
||||
//| There's gotta be a more efficient way to do this
|
||||
//std::shared_ptr<RoutingTablePoolEntry> poolPtr = &(poolItr->second);
|
||||
return poolItr->second;
|
||||
}
|
||||
|
||||
// Removes the routing table pool entry from the storage pool. The
|
||||
// postconditions of this function are guaranteed to include that
|
||||
// the storage pool does not contain such an item. Additionally,
|
||||
// this function cannot fail, but nonetheless debug information is
|
||||
// given in the case that this function is called with an entry that
|
||||
// isn't in the pool.
|
||||
void
|
||||
NamePrefixTable::deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr)
|
||||
{
|
||||
if (m_rtpool.erase(rtpePtr->getDestination()) != 1) {
|
||||
_LOG_DEBUG("Attempted to delete non-existant origin: "
|
||||
<< rtpePtr->getDestination()
|
||||
<< " from NPT routing table entry storage pool.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NamePrefixTable::writeLog()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -23,9 +23,12 @@
|
||||
#define NLSR_NAME_PREFIX_TABLE_HPP
|
||||
|
||||
#include "name-prefix-table-entry.hpp"
|
||||
#include "routing-table-entry.hpp"
|
||||
#include "routing-table-pool-entry.hpp"
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
@@ -37,20 +40,78 @@ public:
|
||||
typedef std::list<NamePrefixTableEntry> NptEntryList;
|
||||
typedef NptEntryList::const_iterator const_iterator;
|
||||
|
||||
typedef std::unordered_map<ndn::Name, std::shared_ptr<RoutingTablePoolEntry>>
|
||||
RtpEntryMap;
|
||||
|
||||
NamePrefixTable(Nlsr& nlsr)
|
||||
: m_nlsr(nlsr)
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Adds a destination to the specified name prefix.
|
||||
\param name The name prefix
|
||||
\param destRouter The destination router prefix
|
||||
|
||||
This method adds a router to a name prefix table entry. If the
|
||||
name prefix table entry does not exist, it is created. The method
|
||||
will first look through its local pool of cached entries to find
|
||||
the routing information for destRouter. If it is not found there,
|
||||
it will construct one and fill it with information from an
|
||||
appropriate RoutingTableEntry in the routing table. If there isn't
|
||||
a match, it will instantiate it with no next hops. The FIB will be
|
||||
notified of the change to the NPT entry, too.
|
||||
*/
|
||||
void
|
||||
addEntry(const ndn::Name& name, const ndn::Name& destRouter);
|
||||
|
||||
/*! \brief Removes a destination from a name prefix table entry.
|
||||
\param name The name prefix
|
||||
\param destRouter The destination.
|
||||
|
||||
This method removes a destination from an entry. It will not fail
|
||||
if an invalid name/destination pair are passed. After removal, if
|
||||
the RoutingTablePoolEntry has a use count of 0, it is deleted from
|
||||
the table. Additionally, if the name prefix has no routing table
|
||||
entries associated with it, it is deleted from the NPT. In any
|
||||
case, the FIB is informed of the changes.
|
||||
*/
|
||||
void
|
||||
removeEntry(const ndn::Name& name, const ndn::Name& destRouter);
|
||||
|
||||
/*! \brief Updates all routing information in the NPT.
|
||||
|
||||
Naively iterates over all the NPT entries, then over each of their
|
||||
RoutingTablePoolEntries, passing the name/destination pair back to
|
||||
addEntry after updating the pool entry with new information. This
|
||||
ensures that the FIB is appropriately apprised of any changes to a
|
||||
prefix's preferred next hops.
|
||||
*/
|
||||
void
|
||||
updateWithNewRoute();
|
||||
|
||||
/*! \brief Adds a pool entry to the pool.
|
||||
\param rtpe The entry.
|
||||
|
||||
\return A shared_ptr to the entry, now in the pool.
|
||||
|
||||
Adds a RoutingTablePoolEntry to the NPT's local pool. Shared
|
||||
pointers are used because it eliminates complicated hacks to deal
|
||||
with lifetime issues, and to simplify memory management.
|
||||
*/
|
||||
std::shared_ptr<RoutingTablePoolEntry>
|
||||
addRtpeToPool(RoutingTablePoolEntry& rtpe);
|
||||
|
||||
/*! \brief Removes a pool entry from the pool.
|
||||
\param rtpePtr The shared_ptr to the entry.
|
||||
|
||||
Removes a pool entry from the pool. Comparing these shared_ptrs
|
||||
should not be a problem, because the same pointer is moved around,
|
||||
all sourced from this central location. A more robust solution is
|
||||
certainly possible, though.
|
||||
*/
|
||||
void
|
||||
deleteRtpeFromPool(std::shared_ptr<RoutingTablePoolEntry> rtpePtr);
|
||||
|
||||
void
|
||||
writeLog();
|
||||
|
||||
@@ -60,16 +121,13 @@ public:
|
||||
const_iterator
|
||||
end() const;
|
||||
|
||||
private:
|
||||
void
|
||||
addEntry(const ndn::Name& name, RoutingTableEntry& rte);
|
||||
|
||||
void
|
||||
removeEntry(const ndn::Name& name, RoutingTableEntry& rte);
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
RtpEntryMap m_rtpool;
|
||||
NptEntryList m_table;
|
||||
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
std::list<NamePrefixTableEntry> m_table;
|
||||
|
||||
};
|
||||
|
||||
inline NamePrefixTable::const_iterator
|
||||
@@ -84,6 +142,9 @@ NamePrefixTable::end() const
|
||||
return m_table.end();
|
||||
}
|
||||
|
||||
bool
|
||||
npteCompare(NamePrefixTableEntry& npte, const ndn::Name& name);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTable& table);
|
||||
|
||||
|
||||
+42
-44
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,8 +19,6 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "nexthop-list.hpp"
|
||||
#include "nexthop.hpp"
|
||||
@@ -33,64 +31,70 @@ INIT_LOGGER("NexthopList");
|
||||
using namespace std;
|
||||
|
||||
static bool
|
||||
nexthopCompare(NextHop& nh1, NextHop& nh2)
|
||||
nexthopAddCompare(const NextHop& nh1, const NextHop& nh2)
|
||||
{
|
||||
return nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri();
|
||||
}
|
||||
|
||||
static bool
|
||||
nexthopRemoveCompare(NextHop& nh1, NextHop& nh2)
|
||||
nexthopRemoveCompare(const NextHop& nh1, const NextHop& nh2)
|
||||
{
|
||||
return (nh1.getConnectingFaceUri() == nh2.getConnectingFaceUri() &&
|
||||
nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) ;
|
||||
}
|
||||
|
||||
static bool
|
||||
nextHopSortingComparator(const NextHop& nh1, const NextHop& nh2)
|
||||
bool
|
||||
operator==(const NexthopList& lhs, const NexthopList& rhs)
|
||||
{
|
||||
if (nh1.getRouteCostAsAdjustedInteger() < nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return true;
|
||||
}
|
||||
else if (nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
|
||||
}
|
||||
else {
|
||||
if (lhs.getSize() != rhs.getSize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NexthopList slhs = lhs;
|
||||
NexthopList srhs = rhs;
|
||||
|
||||
for (struct {std::set<NextHop>::iterator lItr;
|
||||
std::set<NextHop>::iterator rItr;} pair = {slhs.begin(), srhs.begin()};
|
||||
(pair.lItr != slhs.end() || pair.rItr != srhs.end());
|
||||
pair.rItr++, pair.lItr++) {
|
||||
if (!((*pair.lItr) == (*pair.rItr))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
Add next hop to the Next Hop list
|
||||
If next hop is new it is added
|
||||
If next hop already exists in next
|
||||
hop list then updates the route
|
||||
cost with new next hop's route cost
|
||||
*/
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NexthopList& nhl)
|
||||
{
|
||||
NexthopList& ucnhl = const_cast<NexthopList&>(nhl);
|
||||
os << "NexthopList(\nNext hops: ";
|
||||
for (auto&& nh : ucnhl.getNextHops()) {
|
||||
os << nh;
|
||||
}
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
void
|
||||
NexthopList::addNextHop(NextHop& nh)
|
||||
NexthopList::addNextHop(const NextHop& nh)
|
||||
{
|
||||
std::list<NextHop>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
std::set<NextHop, NextHopComparator>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
m_nexthopList.end(),
|
||||
ndn::bind(&nexthopCompare, _1, nh));
|
||||
ndn::bind(&nexthopAddCompare, _1, nh));
|
||||
if (it == m_nexthopList.end()) {
|
||||
m_nexthopList.push_back(nh);
|
||||
return;
|
||||
m_nexthopList.insert(nh);
|
||||
}
|
||||
if ((*it).getRouteCost() > nh.getRouteCost()) {
|
||||
(*it).setRouteCost(nh.getRouteCost());
|
||||
else if (it->getRouteCost() > nh.getRouteCost()) {
|
||||
removeNextHop(*it);
|
||||
m_nexthopList.insert(nh);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Remove a next hop only if both next hop face and route cost are same
|
||||
|
||||
*/
|
||||
|
||||
void
|
||||
NexthopList::removeNextHop(NextHop& nh)
|
||||
NexthopList::removeNextHop(const NextHop& nh)
|
||||
{
|
||||
std::list<NextHop>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
std::set<NextHop, NextHopComparator>::iterator it = std::find_if(m_nexthopList.begin(),
|
||||
m_nexthopList.end(),
|
||||
ndn::bind(&nexthopRemoveCompare, _1, nh));
|
||||
if (it != m_nexthopList.end()) {
|
||||
@@ -98,22 +102,16 @@ NexthopList::removeNextHop(NextHop& nh)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NexthopList::sort()
|
||||
{
|
||||
m_nexthopList.sort(nextHopSortingComparator);
|
||||
}
|
||||
|
||||
void
|
||||
NexthopList::writeLog()
|
||||
{
|
||||
int i = 1;
|
||||
sort();
|
||||
for (std::list<NextHop>::iterator it = m_nexthopList.begin();
|
||||
|
||||
for (std::set<NextHop, NextHopComparator>::iterator it = m_nexthopList.begin();
|
||||
it != m_nexthopList.end() ; it++, i++) {
|
||||
_LOG_DEBUG("Nexthop " << i << ": " << (*it).getConnectingFaceUri()
|
||||
<< " Route Cost: " << (*it).getRouteCost());
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
+51
-15
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -16,14 +16,11 @@
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_NEXTHOP_LIST_HPP
|
||||
#define NLSR_NEXTHOP_LIST_HPP
|
||||
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
@@ -34,6 +31,21 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
struct NextHopComparator {
|
||||
bool
|
||||
operator() (const NextHop& nh1, const NextHop& nh2) const {
|
||||
if (nh1.getRouteCostAsAdjustedInteger() < nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return true;
|
||||
}
|
||||
else if (nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) {
|
||||
return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class NexthopList
|
||||
{
|
||||
public:
|
||||
@@ -45,14 +57,23 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
addNextHop(NextHop& nh);
|
||||
/*! \brief Adds a next hop to the list.
|
||||
\param nh The next hop.
|
||||
|
||||
Adds a next hop to this object. If the next hop is new it is
|
||||
added. If the next hop already exists in the list then that next
|
||||
hop's route cost is updated.
|
||||
*/
|
||||
void
|
||||
removeNextHop(NextHop& nh);
|
||||
addNextHop(const NextHop& nh);
|
||||
|
||||
/*! \brief Remove a next hop from the Next Hop list
|
||||
\param nh The NextHop we want to remove.
|
||||
|
||||
The next hop gets removed only if both next hop face and route cost are same.
|
||||
*/
|
||||
void
|
||||
sort();
|
||||
removeNextHop(const NextHop& nh);
|
||||
|
||||
size_t
|
||||
getSize()
|
||||
@@ -60,20 +81,26 @@ public:
|
||||
return m_nexthopList.size();
|
||||
}
|
||||
|
||||
size_t
|
||||
getSize() const
|
||||
{
|
||||
return m_nexthopList.size();
|
||||
}
|
||||
|
||||
void
|
||||
reset()
|
||||
{
|
||||
m_nexthopList.clear();
|
||||
}
|
||||
|
||||
std::list<NextHop>&
|
||||
std::set<NextHop, NextHopComparator>&
|
||||
getNextHops()
|
||||
{
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
typedef std::list<NextHop>::iterator iterator;
|
||||
typedef std::list<NextHop>::const_iterator const_iterator;
|
||||
typedef std::set<NextHop, NextHopComparator>::iterator iterator;
|
||||
typedef std::set<NextHop, NextHopComparator>::const_iterator const_iterator;
|
||||
|
||||
iterator
|
||||
begin()
|
||||
@@ -103,9 +130,18 @@ public:
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
std::list<NextHop> m_nexthopList;
|
||||
std::set<NextHop, NextHopComparator> m_nexthopList;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
bool
|
||||
operator==(NexthopList& lhs, NexthopList& rhs);
|
||||
|
||||
bool
|
||||
operator==(const NexthopList& lhs, const NexthopList& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NexthopList& nhl);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_NEXTHOP_LIST_HPP
|
||||
+11
-3
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -24,6 +24,14 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
bool
|
||||
operator==(const NextHop& lhs, const NextHop& rhs)
|
||||
{
|
||||
return ((lhs.getRouteCostAsAdjustedInteger() == rhs.getRouteCostAsAdjustedInteger())
|
||||
&&
|
||||
(lhs.getConnectingFaceUri() == rhs.getConnectingFaceUri()));
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NextHop& hop)
|
||||
{
|
||||
@@ -34,4 +42,4 @@ operator<<(std::ostream& os, const NextHop& hop)
|
||||
return os;
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
+16
-16
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -16,9 +16,6 @@
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
**/
|
||||
#ifndef NLSR_NEXTHOP_HPP
|
||||
#define NLSR_NEXTHOP_HPP
|
||||
@@ -80,7 +77,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setRouteCost(double rc)
|
||||
setRouteCost(const double rc)
|
||||
{
|
||||
m_routeCost = rc;
|
||||
}
|
||||
@@ -103,22 +100,25 @@ private:
|
||||
bool m_isHyperbolic;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/** \brief Used to adjust floating point route costs to integers
|
||||
* Since NFD uses integer route costs in the FIB, hyperbolic paths with similar route costs
|
||||
* will be rounded to integers and installed with identical nexthop costs.
|
||||
*
|
||||
* e.g. costs 12.34 and 12.35 will be equal in NFD's FIB
|
||||
*
|
||||
* This multiplier is used to differentiate similar route costs in the FIB.
|
||||
*
|
||||
* e.g costs 12.34 and 12.35 will be installed into NFD's FIB as 12340 and 12350
|
||||
/*! \brief Used to adjust floating point route costs to integers
|
||||
Since NFD uses integer route costs in the FIB, hyperbolic paths with similar route costs
|
||||
will be rounded to integers and installed with identical nexthop costs.
|
||||
|
||||
e.g. costs 12.34 and 12.35 will be equal in NFD's FIB
|
||||
|
||||
This multiplier is used to differentiate similar route costs in the FIB.
|
||||
|
||||
e.g costs 12.34 and 12.35 will be installed into NFD's FIB as 12340 and 12350
|
||||
*/
|
||||
static const uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000;
|
||||
};
|
||||
|
||||
bool
|
||||
operator==(const NextHop& lhs, const NextHop& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NextHop& hop);
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_NEXTHOP_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -60,11 +60,14 @@ void
|
||||
RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
|
||||
{
|
||||
std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb();
|
||||
// For each LSA represented in the map
|
||||
for (std::list<AdjLsa>::iterator it = adjLsdb.begin(); it != adjLsdb.end() ; it++) {
|
||||
|
||||
|
||||
int32_t row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
|
||||
|
||||
std::list<Adjacent> adl = (*it).getAdl().getAdjList();
|
||||
// For each adjacency represented in the LSA
|
||||
for (std::list<Adjacent>::iterator itAdl = adl.begin(); itAdl != adl.end() ; itAdl++) {
|
||||
|
||||
int32_t col = pMap.getMappingNoByRouterName((*itAdl).getName());
|
||||
@@ -78,14 +81,17 @@ RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
|
||||
}
|
||||
}
|
||||
|
||||
// Links that do not have the same cost for both directions should have their
|
||||
// costs corrected:
|
||||
// Links that do not have the same cost for both directions should
|
||||
// have their costs corrected:
|
||||
//
|
||||
// If the cost of one side of the link is 0, both sides of the link should have their cost
|
||||
// corrected to 0.
|
||||
// If the cost of one side of the link is 0, both sides of the
|
||||
// link should have their cost corrected to 0.
|
||||
//
|
||||
// Otherwise, both sides of the link should use the larger of the two costs.
|
||||
//
|
||||
// Additionally, this means that we can halve the amount of space
|
||||
// that the matrix uses by only maintaining a triangle.
|
||||
// - But that is not yet implemented.
|
||||
for (size_t row = 0; row < m_nRouters; ++row) {
|
||||
for (size_t col = 0; col < m_nRouters; ++col) {
|
||||
double toCost = adjMatrix[row][col];
|
||||
@@ -173,7 +179,6 @@ RoutingTableCalculator::freeAdjMatrix()
|
||||
delete [] adjMatrix;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RoutingTableCalculator::allocateLinks()
|
||||
{
|
||||
@@ -208,12 +213,12 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
|
||||
makeAdjMatrix(pnlsr, pMap);
|
||||
writeAdjMatrixLog();
|
||||
int sourceRouter = pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix());
|
||||
allocateParent();
|
||||
allocateDistance();
|
||||
allocateParent(); // These two matrices are used in Dijkstra's algorithm.
|
||||
allocateDistance(); //
|
||||
if (pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1) {
|
||||
// Single Path
|
||||
// In the single path case we can simply run Dijkstra's algorithm.
|
||||
doDijkstraPathCalculation(sourceRouter);
|
||||
// update routing table
|
||||
// Inform the routing table of the new next hops.
|
||||
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
|
||||
}
|
||||
else {
|
||||
@@ -221,12 +226,15 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
|
||||
setNoLink(getNumOfLinkfromAdjMatrix(sourceRouter));
|
||||
allocateLinks();
|
||||
allocateLinkCosts();
|
||||
// Gets a sparse listing of adjacencies for path calculation
|
||||
getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
|
||||
for (int i = 0 ; i < vNoLink; i++) {
|
||||
// Simulate that only the current neighbor is accessible
|
||||
adjustAdMatrix(sourceRouter, links[i], linkCosts[i]);
|
||||
writeAdjMatrixLog();
|
||||
// Do Dijkstra's algorithm using the current neighbor as your start.
|
||||
doDijkstraPathCalculation(sourceRouter);
|
||||
//update routing table
|
||||
// Update the routing table with the calculations.
|
||||
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, sourceRouter);
|
||||
}
|
||||
freeLinks();
|
||||
@@ -242,32 +250,44 @@ LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter)
|
||||
{
|
||||
int i;
|
||||
int v, u;
|
||||
int* Q = new int[m_nRouters];
|
||||
int* Q = new int[m_nRouters]; // Each cell represents the router with that mapping no.
|
||||
int head = 0;
|
||||
/* Initiate the Parent */
|
||||
for (i = 0 ; i < static_cast<int>(m_nRouters); i++) {
|
||||
m_parent[i] = EMPTY_PARENT;
|
||||
// Array where the ith element is the distance to the router with mapping no i.
|
||||
m_distance[i] = INF_DISTANCE;
|
||||
Q[i] = i;
|
||||
}
|
||||
if (sourceRouter != NO_MAPPING_NUM) {
|
||||
// Distance to source from source is always 0.
|
||||
m_distance[sourceRouter] = 0;
|
||||
sortQueueByDistance(Q, m_distance, head, m_nRouters);
|
||||
// While we haven't visited every node.
|
||||
while (head < static_cast<int>(m_nRouters)) {
|
||||
u = Q[head];
|
||||
u = Q[head]; // Set u to be the current node pointed to by head.
|
||||
if (m_distance[u] == INF_DISTANCE) {
|
||||
break;
|
||||
break; // This can only happen when there are no accessible nodes.
|
||||
}
|
||||
// Iterate over the adjacent nodes to u.
|
||||
for (v = 0 ; v < static_cast<int>(m_nRouters); v++) {
|
||||
// If the current node is accessible.
|
||||
if (adjMatrix[u][v] > 0) {
|
||||
// And we haven't visited it yet.
|
||||
if (isNotExplored(Q, v, head + 1, m_nRouters)) {
|
||||
// And if the distance to this node + from this node to v
|
||||
// is less than the distance from our source node to v
|
||||
// that we got when we built the adj LSAs
|
||||
if (m_distance[u] + adjMatrix[u][v] < m_distance[v]) {
|
||||
// Set the new distance
|
||||
m_distance[v] = m_distance[u] + adjMatrix[u][v] ;
|
||||
// Set how we get there.
|
||||
m_parent[v] = u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Increment the head position, resort the list by distance from where we are.
|
||||
head++;
|
||||
sortQueueByDistance(Q, m_distance, head, m_nRouters);
|
||||
}
|
||||
@@ -283,14 +303,19 @@ LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, Rou
|
||||
|
||||
int nextHopRouter = 0;
|
||||
|
||||
// For each router we have
|
||||
for (size_t i = 0; i < m_nRouters ; i++) {
|
||||
if (i != sourceRouter) {
|
||||
|
||||
// Obtain the next hop that was determined by the algorithm
|
||||
nextHopRouter = getLsNextHop(i, sourceRouter);
|
||||
|
||||
// If this router is accessible at all
|
||||
if (nextHopRouter != NO_NEXT_HOP) {
|
||||
|
||||
// Fetch its distance
|
||||
double routeCost = m_distance[i];
|
||||
// Fetch its actual name
|
||||
ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
|
||||
std::string nextHopFace =
|
||||
pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFaceUri();
|
||||
@@ -503,4 +528,4 @@ void HyperbolicRoutingCalculator::addNextHop(ndn::Name dest, std::string faceUri
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -46,30 +46,56 @@ public:
|
||||
m_nRouters = nRouters;
|
||||
}
|
||||
protected:
|
||||
/*! \brief Allocate the space needed for the adj. matrix. */
|
||||
void
|
||||
allocateAdjMatrix();
|
||||
|
||||
/*! \brief Zero every cell of the matrix to ensure that the memory is safe. */
|
||||
void
|
||||
initMatrix();
|
||||
|
||||
/*! \brief Constructs an adj. matrix to calculate with.
|
||||
\param pnlsr The NLSR object that contains the LSAs that we need to iterate
|
||||
over.
|
||||
\param pMap The map to populate with the adj. data.
|
||||
*/
|
||||
void
|
||||
makeAdjMatrix(Nlsr& pnlsr, Map pMap);
|
||||
|
||||
void
|
||||
writeAdjMatrixLog();
|
||||
|
||||
/*! \brief Returns how many links a router in the matrix has.
|
||||
\param sRouter The router to count the links of.
|
||||
*/
|
||||
int
|
||||
getNumOfLinkfromAdjMatrix(int sRouter);
|
||||
|
||||
void
|
||||
freeAdjMatrix();
|
||||
|
||||
/*! \brief Adjust a link cost in the adj. matrix
|
||||
\param source The source router whose adjacency to adjust.
|
||||
\param link The adjacency of the source to adjust.
|
||||
\param linkCost The cost to change to.
|
||||
*/
|
||||
void
|
||||
adjustAdMatrix(int source, int link, double linkCost);
|
||||
|
||||
/*! \brief Populates temp. variables with the link costs for some router.
|
||||
\param source The router whose values are to be adjusted.
|
||||
\param links An integer pointer array for the link mappingNos.
|
||||
\param linkCosts A double pointer array that stores the link costs.
|
||||
|
||||
Obtains a sparse list of adjacencies and link costs for some
|
||||
router. Since this is sparse, that means while generating these
|
||||
arrays, if there is no adjacency at i in the matrix, these
|
||||
temporary variables will not contain a 0 at i, but rather will
|
||||
contain the values for the next valid adjacency.
|
||||
*/
|
||||
void
|
||||
getLinksFromAdjMatrix(int* links, double* linkCosts, int source);
|
||||
|
||||
/*! Allocates an array large enough to hold multipath calculation temps. */
|
||||
void
|
||||
allocateLinks();
|
||||
|
||||
@@ -113,12 +139,30 @@ public:
|
||||
calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);
|
||||
|
||||
private:
|
||||
/*! \brief Performs a Dijkstra's calculation over the adjacency matrix.
|
||||
\param sourceRouter The origin router to compute paths from.
|
||||
*/
|
||||
void
|
||||
doDijkstraPathCalculation(int sourceRouter);
|
||||
|
||||
/*! \brief Sort the elements of a list.
|
||||
\param Q The array that contains the elements to sort.
|
||||
\param dist The array that contains the distances.
|
||||
\param start The first element in the list to sort.
|
||||
\param element The last element in the list to sort through.
|
||||
|
||||
Sorts the list based on distance. The distances are indexed by
|
||||
their mappingNo in dist. Currently uses an insertion sort.
|
||||
*/
|
||||
void
|
||||
sortQueueByDistance(int* Q, double* dist, int start, int element);
|
||||
|
||||
/*! \brief Returns whether an element has been visited yet.
|
||||
\param Q The list of elements to look through.
|
||||
\param u The element to check.
|
||||
\param start The start of list to look through.
|
||||
\param element The end of the list to look through.
|
||||
*/
|
||||
int
|
||||
isNotExplored(int* Q, int u, int start, int element);
|
||||
|
||||
@@ -126,6 +170,10 @@ private:
|
||||
addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
|
||||
Map& pMap, uint32_t sourceRouter);
|
||||
|
||||
/*! \brief Determines a destination's next hop.
|
||||
\param dest The router whose next hop we want to determine.
|
||||
\param source The router to determine a next path to.
|
||||
*/
|
||||
int
|
||||
getLsNextHop(int dest, int source);
|
||||
|
||||
@@ -186,6 +234,6 @@ private:
|
||||
static const int32_t ROUTER_NOT_FOUND;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_ROUTING_TABLE_CALCULATOR_HPP
|
||||
@@ -0,0 +1,36 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The 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/>.
|
||||
**/
|
||||
|
||||
#include "routing-table-entry.hpp"
|
||||
#include "nexthop-list.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const RoutingTableEntry& rte)
|
||||
{
|
||||
os << "RoutingTableEntry("
|
||||
<< "Destination: " << rte.getDestination()
|
||||
<< "Next hop list: " << rte.getNexthopList() << ")";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -57,11 +57,28 @@ public:
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
private:
|
||||
const NexthopList&
|
||||
getNexthopList() const
|
||||
{
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
inline bool
|
||||
operator==(RoutingTableEntry& rhs)
|
||||
{
|
||||
return ((*this).getDestination() == rhs.getDestination()
|
||||
&&
|
||||
(*this).getNexthopList() == rhs.getNexthopList());
|
||||
}
|
||||
|
||||
protected:
|
||||
ndn::Name m_destination;
|
||||
NexthopList m_nexthopList;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const RoutingTableEntry& rte);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_ROUTING_TABLE_ENTRY_HPP
|
||||
@@ -0,0 +1,46 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The 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/>.
|
||||
**/
|
||||
|
||||
#include "routing-table-pool-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe)
|
||||
{
|
||||
os << "RoutingTablePoolEntry("
|
||||
<< "Destination router: " << rtpe.getDestination()
|
||||
<< "Next hop list: ";
|
||||
for (auto && nh : rtpe.getNexthopList()) {
|
||||
os << nh;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const RoutingTablePoolEntry& lhs, const RoutingTablePoolEntry& rhs)
|
||||
{
|
||||
return (lhs.getDestination() == rhs.getDestination()
|
||||
&&
|
||||
lhs.getNexthopList() == rhs.getNexthopList());
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -0,0 +1,103 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The 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 Nicholas Gordon <nmgordon@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
#define NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
|
||||
#include <iostream>
|
||||
#include <ndn-cxx/name.hpp>
|
||||
#include "nexthop-list.hpp"
|
||||
#include "routing-table-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class RoutingTablePoolEntry : public RoutingTableEntry
|
||||
{
|
||||
public:
|
||||
RoutingTablePoolEntry()
|
||||
{
|
||||
}
|
||||
|
||||
~RoutingTablePoolEntry()
|
||||
{
|
||||
}
|
||||
|
||||
RoutingTablePoolEntry(const ndn::Name& dest)
|
||||
{
|
||||
m_destination = dest;
|
||||
m_useCount = 1;
|
||||
}
|
||||
|
||||
RoutingTablePoolEntry(RoutingTableEntry& rte, uint64_t useCount)
|
||||
{
|
||||
m_destination = rte.getDestination();
|
||||
m_nexthopList = rte.getNexthopList();
|
||||
m_useCount = useCount;
|
||||
}
|
||||
|
||||
RoutingTablePoolEntry(const ndn::Name& dest, uint64_t useCount)
|
||||
{
|
||||
m_destination = dest;
|
||||
m_useCount = useCount;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getUseCount()
|
||||
{
|
||||
return m_useCount;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
incrementUseCount()
|
||||
{
|
||||
return ++m_useCount;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
decrementUseCount()
|
||||
{
|
||||
if (m_useCount != 0) {
|
||||
return --m_useCount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
setNexthopList(NexthopList nhl)
|
||||
{
|
||||
m_nexthopList = nhl;
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t m_useCount;
|
||||
|
||||
};
|
||||
|
||||
bool
|
||||
operator==(const RoutingTablePoolEntry& lhs, const RoutingTablePoolEntry& rhs);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_ROUTING_TABLE_POOL_ENTRY_HPP
|
||||
+19
-12
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -49,9 +49,20 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
if (pnlsr.getIsRoutingTableCalculating() == false) {
|
||||
//setting routing table calculation
|
||||
pnlsr.setIsRoutingTableCalculating(true);
|
||||
if (pnlsr.getLsdb().doesLsaExist(
|
||||
pnlsr.getConfParameter().getRouterPrefix().toUri() + "/" + "adjacency",
|
||||
std::string("adjacency"))) {
|
||||
|
||||
bool isHrEnabled = pnlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF;
|
||||
|
||||
if ((!isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
|
||||
+ "/" + "adjacency", std::string("adjacency")))
|
||||
||
|
||||
(isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
|
||||
+ "/" + "coordinate", std::string("coordinate")))) {
|
||||
if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
|
||||
_LOG_TRACE("Clearing old routing table");
|
||||
clearRoutingTable();
|
||||
@@ -73,7 +84,7 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
calculateHypDryRoutingTable(pnlsr);
|
||||
}
|
||||
//need to update NPT here
|
||||
// Inform the NPT that updates have been made
|
||||
_LOG_DEBUG("Calling Update NPT With new Route");
|
||||
pnlsr.getNamePrefixTable().updateWithNewRoute();
|
||||
writeLog(pnlsr.getConfParameter().getHyperbolicState());
|
||||
@@ -106,7 +117,6 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RoutingTable::calculateLsRoutingTable(Nlsr& nlsr)
|
||||
{
|
||||
@@ -127,7 +137,7 @@ void
|
||||
RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
|
||||
{
|
||||
Map map;
|
||||
map.createFromAdjLsdb(nlsr);
|
||||
map.createFromCoordinateLsdb(nlsr);
|
||||
map.writeLog();
|
||||
|
||||
size_t nRouters = map.getMapSize();
|
||||
@@ -174,7 +184,6 @@ routingTableEntryCompare(RoutingTableEntry& rte, ndn::Name& destRouter)
|
||||
return rte.getDestination() == destRouter;
|
||||
}
|
||||
|
||||
// function related to manipulation of routing table
|
||||
void
|
||||
RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh)
|
||||
{
|
||||
@@ -226,7 +235,6 @@ RoutingTable::writeLog(int hyperbolicState)
|
||||
}
|
||||
}
|
||||
|
||||
//function related to manipulation of dry routing table
|
||||
void
|
||||
RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
|
||||
{
|
||||
@@ -262,5 +270,4 @@ RoutingTable::clearDryRoutingTable()
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -47,18 +47,34 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Calculates a list of next hops for each router in the network.
|
||||
\param pnlsr The NLSR object that contains the LSAs needed for adj. info.
|
||||
|
||||
Calculates the list of next hops to every other router in the network.
|
||||
*/
|
||||
void
|
||||
calculate(Nlsr& pnlsr);
|
||||
|
||||
/*! \brief Adds a next hop to a routing table entry.
|
||||
\param destRouter The destination router whose RTE we want to modify.
|
||||
\param nh The next hop to add to the RTE.
|
||||
*/
|
||||
void
|
||||
addNextHop(const ndn::Name& destRouter, NextHop& nh);
|
||||
|
||||
/*! \brief Adds a next hop to a routing table entry in a dry run scenario.
|
||||
\param destRouter The destination router whose RTE we want to modify.
|
||||
\param nh The next hop to add to the router.
|
||||
*/
|
||||
void
|
||||
addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
|
||||
|
||||
RoutingTableEntry*
|
||||
findRoutingTableEntry(const ndn::Name& destRouter);
|
||||
|
||||
/*! \brief Schedules a calculation event in the event scheduler.
|
||||
\param pnlsr The NLSR whose scheduling status is needed.
|
||||
*/
|
||||
void
|
||||
scheduleRoutingTableCalculation(Nlsr& pnlsr);
|
||||
|
||||
@@ -81,12 +97,15 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
/*! \brief Calculates a link-state routing table. */
|
||||
void
|
||||
calculateLsRoutingTable(Nlsr& pnlsr);
|
||||
|
||||
/*! \brief Calculates a HR routing table. */
|
||||
void
|
||||
calculateHypRoutingTable(Nlsr& pnlsr);
|
||||
|
||||
/*! \brief Calculates a dry-run HR routing table. */
|
||||
void
|
||||
calculateHypDryRoutingTable(Nlsr& pnlsr);
|
||||
|
||||
@@ -110,6 +129,6 @@ private:
|
||||
ndn::time::seconds m_routingCalcInterval;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
|
||||
#endif //NLSR_ROUTING_TABLE_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -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();
|
||||
@@ -110,6 +129,4 @@ SequencingManager::writeLog() const
|
||||
_LOG_DEBUG("Combined LSDB Seq no: " << m_combinedSeqNo);
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -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);
|
||||
@@ -150,5 +153,5 @@ private:
|
||||
std::string m_seqFileNameWithPath;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
} // namespace nlsr
|
||||
#endif //NLSR_SEQUENCING_MANAGER_HPP
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -34,16 +34,16 @@
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for AdjacencyLsa
|
||||
*
|
||||
* AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH
|
||||
* LsaInfo
|
||||
* Adjacency*
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for AdjacencyLsa
|
||||
|
||||
AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH
|
||||
LsaInfo
|
||||
Adjacency*
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class AdjacencyLsa
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,17 +29,17 @@
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for Adjacency
|
||||
*
|
||||
* Adjacency := ADJACENCY-TYPE TLV-LENGTH
|
||||
* Name
|
||||
* Uri
|
||||
* Cost
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for Adjacency
|
||||
|
||||
Adjacency := ADJACENCY-TYPE TLV-LENGTH
|
||||
Name
|
||||
Uri
|
||||
Cost
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class Adjacency
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -31,17 +31,17 @@
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for CoordinateLsa
|
||||
*
|
||||
* CoordinateLsa := COORDINATE-LSA-TYPE TLV-LENGTH
|
||||
* LsaInfo
|
||||
* HyperbolicRadius
|
||||
* HyperbolicAngle
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for CoordinateLsa
|
||||
|
||||
CoordinateLsa := COORDINATE-LSA-TYPE TLV-LENGTH
|
||||
LsaInfo
|
||||
HyperbolicRadius
|
||||
HyperbolicAngle
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class CoordinateLsa
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -31,17 +31,17 @@
|
||||
#include "lsa.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for LsaInfo
|
||||
*
|
||||
* LsaInfo := LSA-TYPE TLV-LENGTH
|
||||
* OriginRouter
|
||||
* SequenceNumber
|
||||
* ExpirationPeriod?
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for LsaInfo
|
||||
|
||||
LsaInfo := LSA-TYPE TLV-LENGTH
|
||||
OriginRouter
|
||||
SequenceNumber
|
||||
ExpirationPeriod?
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsaInfo
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -35,17 +35,17 @@
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for LsdbStatus
|
||||
*
|
||||
* LsdbStatus := LSDB-STATUS-TYPE TLV-LENGTH
|
||||
* AdjacencyLsa*
|
||||
* CoordinateLsa*
|
||||
* NameLsa*
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for LsdbStatus
|
||||
|
||||
LsdbStatus := LSDB-STATUS-TYPE TLV-LENGTH
|
||||
AdjacencyLsa*
|
||||
CoordinateLsa*
|
||||
NameLsa*
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbStatus
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,16 +33,16 @@
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* @brief Data abstraction for NameLsa
|
||||
*
|
||||
* NameLsa := NAME-LSA-TYPE TLV-LENGTH
|
||||
* LsaInfo
|
||||
* Name+
|
||||
*
|
||||
* @sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
/*!
|
||||
\brief Data abstraction for NameLsa
|
||||
|
||||
NameLsa := NAME-LSA-TYPE TLV-LENGTH
|
||||
LsaInfo
|
||||
Name+
|
||||
|
||||
\sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class NameLsa
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef UPDATE_PREFIX_UPDATE_COMMANDS_HPP
|
||||
#define UPDATE_PREFIX_UPDATE_COMMANDS_HPP
|
||||
|
||||
#include <ndn-cxx/management/nfd-control-command.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-command.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace update {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "prefix-update-commands.hpp"
|
||||
#include "communication/sync-logic-handler.hpp"
|
||||
|
||||
#include <ndn-cxx/management/nfd-control-response.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace update {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/interest.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-command.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-parameters.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-command.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
|
||||
#include <ndn-cxx/security/certificate-cache-ttl.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
|
||||
@@ -43,7 +43,7 @@ class SyncLogicHandler;
|
||||
|
||||
namespace security {
|
||||
class CertificateStore;
|
||||
}
|
||||
} // namespace security
|
||||
|
||||
namespace update {
|
||||
|
||||
@@ -96,13 +96,13 @@ private:
|
||||
uint32_t code,
|
||||
const std::string& text);
|
||||
|
||||
/** \brief adds desired name prefix to the advertised name prefix list
|
||||
/*! \brief adds desired name prefix to the advertised name prefix list
|
||||
*/
|
||||
void
|
||||
advertise(const std::shared_ptr<const ndn::Interest>& request,
|
||||
const ndn::nfd::ControlParameters& parameters);
|
||||
|
||||
/** \brief removes desired name prefix from the advertised name prefix list
|
||||
/*! \brief removes desired name prefix from the advertised name prefix list
|
||||
*/
|
||||
void
|
||||
withdraw(const std::shared_ptr<const ndn::Interest>& request,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -76,7 +76,8 @@ FaceController::onCanonizeFailure(const std::string& reason,
|
||||
const FaceUri& request)
|
||||
{
|
||||
_LOG_WARN("Could not convert " << request << " to canonical form: " << reason);
|
||||
onFailure(CANONIZE_ERROR_CODE, "Could not canonize face-uri: " + request.toString());
|
||||
onFailure(ndn::nfd::ControlResponse(CANONIZE_ERROR_CODE,
|
||||
"Could not canonize face-uri: " + request.toString()));
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,14 +17,13 @@
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_UTIL_FACE_CONTROLLER_HPP
|
||||
#define NLSR_UTIL_FACE_CONTROLLER_HPP
|
||||
|
||||
#include <ndn-cxx/util/face-uri.hpp>
|
||||
#include <ndn-cxx/management/nfd-controller.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/controller.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace util {
|
||||
@@ -31,8 +31,8 @@ namespace util {
|
||||
class FaceController : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
typedef ndn::function<void(const ndn::nfd::ControlParameters&)> CommandSuccessCallback;
|
||||
typedef ndn::function<void(uint32_t,const std::string&)> CommandFailureCallback;
|
||||
typedef ndn::nfd::Controller::CommandSucceedCallback CommandSuccessCallback;
|
||||
typedef ndn::nfd::Controller::CommandFailCallback CommandFailureCallback;
|
||||
|
||||
FaceController(boost::asio::io_service& io, ndn::nfd::Controller& controller)
|
||||
: m_ioService(io)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
@@ -33,12 +33,12 @@
|
||||
namespace nlsr {
|
||||
namespace util {
|
||||
|
||||
/**
|
||||
* @brief search a name component in ndn::Name and return the position of the component
|
||||
* @param name where to search the searchString
|
||||
* @param searchString the string to search in name
|
||||
* @return -1 if searchString not found else return the position
|
||||
* starting from 0
|
||||
/*!
|
||||
\brief search a name component in ndn::Name and return the position of the component
|
||||
\param name where to search the searchString
|
||||
\param searchString the string to search in name
|
||||
\return -1 if searchString not found else return the position
|
||||
starting from 0
|
||||
*/
|
||||
inline static int32_t
|
||||
getNameComponentPosition(const ndn::Name& name, const std::string& searchString)
|
||||
@@ -53,7 +53,7 @@ getNameComponentPosition(const ndn::Name& name, const std::string& searchString)
|
||||
return -1;
|
||||
}
|
||||
|
||||
} //namespace util
|
||||
} // namespace util
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis
|
||||
* Regents of the University of California,
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
"""
|
||||
Copyright (c) 2014 University of Memphis
|
||||
Regents of the University of California,
|
||||
Copyright (c) 2014-2016, The 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis
|
||||
* Regents of the University of California,
|
||||
* Copyright (c) 2014-2017, The 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.
|
||||
|
||||
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user