Compare commits
58
Commits
NLSR-0.4.2
...
NLSR-0.5.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1158c55878 | ||
|
|
427e012304 | ||
|
|
4a5334cba7 | ||
|
|
55d1b5c2c0 | ||
|
|
cb065f1773 | ||
|
|
328fc11217 | ||
|
|
6b388fc36d | ||
|
|
f75bfdaa34 | ||
|
|
842b1cf1f0 | ||
|
|
d21d83d892 | ||
|
|
4187857a9a | ||
|
|
d0816a3ced | ||
|
|
c64bed22a8 | ||
|
|
9ea3639be2 | ||
|
|
cf22053914 | ||
|
|
348321368d | ||
|
|
08bce9c325 | ||
|
|
0b1b7d9ff4 | ||
|
|
15052408e9 | ||
|
|
dec85d2da4 | ||
|
|
af7a2113e4 | ||
|
|
0b0eddd60c | ||
|
|
9ecbdc95c5 | ||
|
|
b2fea6d79f | ||
|
|
d3b60a8b24 | ||
|
|
0da3eab4da | ||
|
|
82a34c2cd8 | ||
|
|
85998a1dc9 | ||
|
|
7e3f6d75c8 | ||
|
|
e3c741da9a | ||
|
|
5859ed3dfb | ||
|
|
e556991595 | ||
|
|
72b2b25cd2 | ||
|
|
7c13ba5448 | ||
|
|
008c9b18a5 | ||
|
|
7526cee087 | ||
|
|
939b6f8652 | ||
|
|
e5002b3fc4 | ||
|
|
32ec3fd51e | ||
|
|
2fa23ea104 | ||
|
|
744e481642 | ||
|
|
8433cfeace | ||
|
|
2e6c8bb896 | ||
|
|
3494f7366a | ||
|
|
05cb728c63 | ||
|
|
057005460e | ||
|
|
e8d8bd5276 | ||
|
|
481010723b | ||
|
|
a08dc3f1f1 | ||
|
|
301220346e | ||
|
|
8df15986ef | ||
|
|
f3c79a6f87 | ||
|
|
cba0ae2f56 | ||
|
|
f1a8ee66de | ||
|
|
d65786a0ea | ||
|
|
e6ba9158e0 | ||
|
|
aa41b04807 | ||
|
|
67758b1fba |
No files matched your search
+32
-7
@@ -1,7 +1,32 @@
|
||||
.DS*
|
||||
.waf-1*
|
||||
.waf3-*
|
||||
.lock*
|
||||
**/*.pyc
|
||||
build/
|
||||
VERSION
|
||||
# Emacs
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
.\#*
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/
|
||||
|
||||
# KDevelop
|
||||
*.kdev*
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
._*
|
||||
|
||||
# Waf build system
|
||||
/build/
|
||||
.waf-*-*/
|
||||
.waf3-*-*/
|
||||
.lock-waf*
|
||||
|
||||
# Compiled python code
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# Other
|
||||
/VERSION
|
||||
@@ -7,7 +7,7 @@ source "$JDIR"/util.sh
|
||||
set -x
|
||||
|
||||
if has OSX $NODE_LABELS; then
|
||||
FORMULAE=(boost pkg-config openssl)
|
||||
FORMULAE=(boost openssl pkg-config)
|
||||
brew update
|
||||
if [[ -n $TRAVIS ]]; then
|
||||
# travis images come with a large number of brew packages
|
||||
@@ -28,7 +28,6 @@ if has Ubuntu $NODE_LABELS; then
|
||||
libsqlite3-dev libssl-dev
|
||||
|
||||
if [[ $JOB_NAME == *"code-coverage" ]]; then
|
||||
sudo apt-get -qy install lcov libgd-perl python-setuptools
|
||||
sudo easy_install --upgrade gcovr
|
||||
sudo apt-get -qy install gcovr lcov libgd-perl
|
||||
fi
|
||||
fi
|
||||
@@ -37,14 +37,14 @@ fi
|
||||
|
||||
sudo rm -f /usr/local/bin/ndnsec*
|
||||
sudo rm -fr /usr/local/include/ndn-cxx
|
||||
sudo rm -f /usr/local/lib/libndn-cxx*
|
||||
sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx.pc
|
||||
sudo rm -f /usr/local/lib{,64}/libndn-cxx*
|
||||
sudo rm -f /usr/local/lib{,64}/pkgconfig/libndn-cxx.pc
|
||||
|
||||
pushd ndn-cxx >/dev/null
|
||||
|
||||
./waf configure --color=yes --enable-shared --disable-static --without-osx-keychain
|
||||
./waf build --color=yes -j${WAF_JOBS:-1}
|
||||
sudo env "PATH=$PATH" ./waf install --color=yes
|
||||
sudo_preserve_env PATH -- ./waf install --color=yes
|
||||
|
||||
popd >/dev/null
|
||||
popd >/dev/null
|
||||
|
||||
@@ -9,13 +9,11 @@ set -x
|
||||
pushd "${CACHE_DIR:-/tmp}" >/dev/null
|
||||
|
||||
INSTALLED_VERSION=
|
||||
if has OSX $NODE_LABELS; then
|
||||
BOOST=$(brew ls --versions boost)
|
||||
OLD_BOOST=$(cat boost_chrono.txt || :)
|
||||
if [[ $OLD_BOOST != $BOOST ]]; then
|
||||
echo "$BOOST" > boost_chrono.txt
|
||||
INSTALLED_VERSION=NONE
|
||||
fi
|
||||
NDN_CXX=$(ndnsec version)
|
||||
OLD_NDN_CXX=$(cat ndn_cxx_chrono.txt || :)
|
||||
if [[ $OLD_NDN_CXX != $NDN_CXX ]]; then
|
||||
echo "$NDN_CXX" > ndn_cxx_chrono.txt
|
||||
INSTALLED_VERSION=NONE
|
||||
fi
|
||||
|
||||
if [[ -z $INSTALLED_VERSION ]]; then
|
||||
@@ -36,8 +34,8 @@ else
|
||||
fi
|
||||
|
||||
sudo rm -fr /usr/local/include/ChronoSync
|
||||
sudo rm -f /usr/local/lib/libChronoSync*
|
||||
sudo rm -f /usr/local/lib/pkgconfig/ChronoSync*
|
||||
sudo rm -f /usr/local/lib{,64}/libChronoSync*
|
||||
sudo rm -f /usr/local/lib{,64}/pkgconfig/ChronoSync.pc
|
||||
|
||||
pushd ChronoSync >/dev/null
|
||||
|
||||
@@ -47,7 +45,7 @@ fi
|
||||
|
||||
./waf configure --color=yes
|
||||
./waf build --color=yes -j${WAF_JOBS:-1}
|
||||
sudo env "PATH=$PATH" ./waf install --color=yes
|
||||
sudo_preserve_env PATH -- ./waf install --color=yes
|
||||
|
||||
popd >/dev/null
|
||||
popd >/dev/null
|
||||
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
source "$JDIR"/util.sh
|
||||
|
||||
set -x
|
||||
|
||||
pushd "${CACHE_DIR:-/tmp}" >/dev/null
|
||||
|
||||
INSTALLED_VERSION=
|
||||
NDN_CXX=$(ndnsec version)
|
||||
OLD_NDN_CXX=$(cat ndn_cxx_psync.txt || :)
|
||||
if [[ $OLD_NDN_CXX != $NDN_CXX ]]; then
|
||||
echo "$NDN_CXX" > ndn_cxx_psync.txt
|
||||
INSTALLED_VERSION=NONE
|
||||
fi
|
||||
|
||||
if [[ -z $INSTALLED_VERSION ]]; then
|
||||
INSTALLED_VERSION=$(git -C PSync rev-parse HEAD 2>/dev/null || echo NONE)
|
||||
fi
|
||||
|
||||
sudo rm -Rf PSync-latest
|
||||
|
||||
git clone --depth 1 git://github.com/named-data/PSync PSync-latest
|
||||
|
||||
LATEST_VERSION=$(git -C PSync-latest rev-parse HEAD 2>/dev/null || echo UNKNOWN)
|
||||
|
||||
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
|
||||
sudo rm -Rf PSync
|
||||
mv PSync-latest PSync
|
||||
else
|
||||
sudo rm -Rf PSync-latest
|
||||
fi
|
||||
|
||||
sudo rm -fr /usr/local/include/PSync
|
||||
sudo rm -f /usr/local/lib{,64}/libPSync*
|
||||
sudo rm -f /usr/local/lib{,64}/pkgconfig/PSync.pc
|
||||
|
||||
pushd PSync >/dev/null
|
||||
|
||||
if has FreeBSD10 $NODE_LABELS; then
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
|
||||
fi
|
||||
|
||||
./waf configure --color=yes
|
||||
./waf build --color=yes -j${WAF_JOBS:-1}
|
||||
sudo_preserve_env PATH -- ./waf install --color=yes
|
||||
|
||||
popd >/dev/null
|
||||
popd >/dev/null
|
||||
|
||||
if has Linux $NODE_LABELS; then
|
||||
sudo ldconfig
|
||||
elif has FreeBSD10 $NODE_LABELS; then
|
||||
sudo ldconfig -m
|
||||
fi
|
||||
@@ -17,7 +17,7 @@ elif [[ -z $DISABLE_ASAN ]]; then
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
sudo env "PATH=$PATH" ./waf --color=yes distclean
|
||||
sudo_preserve_env PATH -- ./waf --color=yes distclean
|
||||
|
||||
if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
|
||||
# Configure/build in optimized mode with tests
|
||||
@@ -25,14 +25,14 @@ if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
|
||||
./waf --color=yes build -j${WAF_JOBS:-1}
|
||||
|
||||
# Cleanup
|
||||
sudo env "PATH=$PATH" ./waf --color=yes distclean
|
||||
sudo_preserve_env PATH -- ./waf --color=yes distclean
|
||||
|
||||
# Configure/build in optimized mode without tests
|
||||
./waf --color=yes configure
|
||||
./waf --color=yes build -j${WAF_JOBS:-1}
|
||||
|
||||
# Cleanup
|
||||
sudo env "PATH=$PATH" ./waf --color=yes distclean
|
||||
sudo_preserve_env PATH -- ./waf --color=yes distclean
|
||||
fi
|
||||
|
||||
# Configure/build in debug mode with tests
|
||||
@@ -42,4 +42,4 @@ fi
|
||||
# (tests will be run against debug version)
|
||||
|
||||
# Install
|
||||
sudo env "PATH=$PATH" ./waf --color=yes install
|
||||
sudo_preserve_env PATH -- ./waf --color=yes install
|
||||
+19
-1
@@ -1,12 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
source "$JDIR"/util.sh
|
||||
|
||||
set -x
|
||||
|
||||
# Prepare environment
|
||||
rm -Rf ~/.ndn
|
||||
|
||||
BOOST_VERSION=$(python -c "import sys; sys.path.append('build/c4che'); import _cache; print(_cache.BOOST_VERSION_NUMBER);")
|
||||
|
||||
ut_log_args() {
|
||||
echo --log_level=test_suite
|
||||
if (( BOOST_VERSION >= 106200 )); then
|
||||
echo --logger=HRF,test_suite,stdout:XML,all,build/xunit-${1:-report}.xml
|
||||
else
|
||||
if [[ -n $XUNIT ]]; then
|
||||
echo --log_level=all $( (( BOOST_VERSION >= 106000 )) && echo -- ) \
|
||||
--log_format2=XML --log_sink2=build/xunit-${1:-report}.xml
|
||||
else
|
||||
echo --log_level=test_suite
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ASAN_OPTIONS="color=always"
|
||||
@@ -19,5 +34,8 @@ ASAN_OPTIONS+=":strict_string_checks=true"
|
||||
ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
|
||||
export ASAN_OPTIONS
|
||||
|
||||
export BOOST_TEST_BUILD_INFO=1
|
||||
export BOOST_TEST_COLOR_OUTPUT=1
|
||||
|
||||
# Run unit tests
|
||||
./build/unit-tests-nlsr $(ut_log_args)
|
||||
@@ -13,13 +13,13 @@ Environment Variables Used in Build Scripts
|
||||
|
||||
* `[OS_TYPE]`: `Linux`
|
||||
* `[DISTRO_TYPE]`: `Ubuntu`
|
||||
* `[DISTRO_VERSION]`: `Ubuntu-14.04`, `Ubuntu-16.04`
|
||||
* `[DISTRO_VERSION]`: `Ubuntu-16.04`, `Ubuntu-18.04`
|
||||
|
||||
Possible values for OS X / macOS:
|
||||
|
||||
* `[OS_TYPE]`: `OSX`
|
||||
* `[DISTRO_TYPE]`: `OSX` (can be absent)
|
||||
* `[DISTRO_VERSION]`: `OSX-10.10`, `OSX-10.11`, `OSX-10.12`
|
||||
* `[DISTRO_VERSION]`: `OSX-10.11`, `OSX-10.12`, `OSX-10.13`
|
||||
|
||||
- `JOB_NAME`: optional variable to define type of the job. Depending on the defined job type,
|
||||
the build scripts can perform different tasks.
|
||||
@@ -27,7 +27,7 @@ Environment Variables Used in Build Scripts
|
||||
Possible values:
|
||||
|
||||
* empty: default build process
|
||||
* `code-coverage` (Linux OS is assumed): debug build with tests and code coverage analysis
|
||||
* `code-coverage` (Ubuntu Linux is assumed): debug build with tests and code coverage analysis
|
||||
* `limited-build`: only a single debug build with tests
|
||||
|
||||
- `CACHE_DIR`: the variable defines a path to folder containing cached files from previous builds,
|
||||
|
||||
@@ -16,3 +16,22 @@ has() {
|
||||
set ${saved_xtrace}
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
sudo_preserve_env() {
|
||||
local saved_xtrace
|
||||
[[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x
|
||||
set +x
|
||||
|
||||
local vars=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
local arg=$1
|
||||
shift
|
||||
case ${arg} in
|
||||
--) break ;;
|
||||
*) vars+=("${arg}=${!arg}") ;;
|
||||
esac
|
||||
done
|
||||
|
||||
set ${saved_xtrace}
|
||||
sudo env "${vars[@]}" "$@"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
A K M Mahmudul Hoque <akmhoque@gmail.com>
|
||||
<agawande@memphis.edu> <ashu2493@gmail.com>
|
||||
Nick Gordon <nmgordon@memphis.edu>
|
||||
Laqin Fan <lfan1@memphis.edu>
|
||||
Syed Obaid Amin <soamin@memphis.edu>
|
||||
Syed Obaid Amin <soamin@memphis.edu> <obaidasyed@gmail.com>
|
||||
Syed Obaid Amin <soamin@memphis.edu> <obaid@Obaids-MacBook.local>
|
||||
Syed Obaid Amin <soamin@memphis.edu> <obaid@obaids-macbook.memphis.edu>
|
||||
Syed Obaid Amin <soamin@memphis.edu> <soamin@mira.cs.memphis.edu>
|
||||
Syed Obaid Amin <soamin@memphis.edu> <soamin@wd222yx4.memphis.edu>
|
||||
Muktadir R Chowdhury <mrchwdhr@memphis.edu>
|
||||
Muktadir R Chowdhury <mrchwdhr@memphis.edu> <muktadir.rahman.c@gmail.com>
|
||||
<aa@cs.fiu.edu> <alexander.afanasyev@ucla.edu>
|
||||
<davidepesa@gmail.com> <davide.pesavento@lip6.fr>
|
||||
<enewberry@email.arizona.edu> <enewberry@cs.arizona.edu>
|
||||
Md Ashiqur Rahman <marahman@email.arizona.edu>
|
||||
+61
-66
@@ -1,100 +1,95 @@
|
||||
language: cpp
|
||||
dist: trusty
|
||||
sudo: required
|
||||
dist: bionic
|
||||
env:
|
||||
global:
|
||||
- JOB_NAME=limited-build
|
||||
- WAF_JOBS=2
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# Linux/gcc
|
||||
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test/+packages
|
||||
- os: linux
|
||||
env: COMPILER=g++-4.8
|
||||
- os: linux
|
||||
env: COMPILER=g++-4.9
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-4.9
|
||||
- os: linux
|
||||
env: COMPILER=g++-5
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-5
|
||||
- os: linux
|
||||
env: COMPILER=g++-6
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-6
|
||||
- os: linux
|
||||
env: COMPILER=g++-7
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: g++-7
|
||||
- os: linux
|
||||
env: COMPILER=g++-8
|
||||
- os: linux
|
||||
env: COMPILER=g++-9
|
||||
|
||||
# Linux/clang
|
||||
# https://apt.llvm.org/
|
||||
- os: linux
|
||||
env: COMPILER=clang++-3.5
|
||||
addons:
|
||||
apt:
|
||||
packages: clang-3.5
|
||||
- os: linux
|
||||
env: COMPILER=clang++-3.6
|
||||
addons:
|
||||
apt:
|
||||
packages: clang-3.6
|
||||
- os: linux
|
||||
env: COMPILER=clang++-3.7 DISABLE_ASAN=yes
|
||||
addons:
|
||||
apt:
|
||||
sources: ["llvm-toolchain-precise-3.7", "ubuntu-toolchain-r-test"]
|
||||
packages: clang-3.7
|
||||
- os: linux
|
||||
env: COMPILER=clang++-3.8
|
||||
addons:
|
||||
apt:
|
||||
sources: ["llvm-toolchain-precise-3.8", "ubuntu-toolchain-r-test"]
|
||||
packages: clang-3.8
|
||||
- os: linux
|
||||
env: COMPILER=clang++-3.9 DISABLE_ASAN=yes
|
||||
addons:
|
||||
apt:
|
||||
sources: ["llvm-toolchain-trusty-3.9", "ubuntu-toolchain-r-test"]
|
||||
packages: clang-3.9
|
||||
env: COMPILER=clang++-3.9
|
||||
- os: linux
|
||||
env: COMPILER=clang++-4.0
|
||||
addons:
|
||||
apt:
|
||||
sources: ["llvm-toolchain-trusty-4.0", "ubuntu-toolchain-r-test"]
|
||||
packages: clang-4.0
|
||||
- os: linux
|
||||
env: COMPILER=clang++-5.0
|
||||
addons:
|
||||
apt:
|
||||
sources: ["llvm-toolchain-trusty-5.0", "ubuntu-toolchain-r-test"]
|
||||
packages: clang-5.0
|
||||
- os: linux
|
||||
env: COMPILER=clang++-6.0
|
||||
# disable AddressSanitizer with clang 7 and 8
|
||||
# due to https://bugs.llvm.org/show_bug.cgi?id=40808
|
||||
- os: linux
|
||||
env: COMPILER=clang++-7 DISABLE_ASAN=yes
|
||||
- os: linux
|
||||
env: COMPILER=clang++-8 DISABLE_ASAN=yes
|
||||
- os: linux
|
||||
env: COMPILER=clang++-9
|
||||
- os: linux
|
||||
env: COMPILER=clang++-10
|
||||
|
||||
# macOS/clang
|
||||
# https://docs.travis-ci.com/user/osx-ci-environment/#OS-X-Version
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
env: OSX_VERSION=10.11
|
||||
- os: osx
|
||||
osx_image: xcode8.3
|
||||
env: OSX_VERSION=10.12
|
||||
# https://docs.travis-ci.com/user/reference/osx/#macos-version
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
env: OSX_VERSION=10.12
|
||||
- os: osx
|
||||
osx_image: xcode9.4
|
||||
env: OSX_VERSION=10.13
|
||||
- os: osx
|
||||
osx_image: xcode10.1
|
||||
env: OSX_VERSION=10.13
|
||||
- os: osx
|
||||
osx_image: xcode10.3
|
||||
env: OSX_VERSION=10.14
|
||||
- os: osx
|
||||
osx_image: xcode11
|
||||
env: OSX_VERSION=10.14
|
||||
|
||||
allow_failures:
|
||||
- env: COMPILER=clang++-10
|
||||
|
||||
fast_finish: true
|
||||
|
||||
before_install: |
|
||||
case ${COMPILER} in
|
||||
g++-[567]|clang++-[3456].*)
|
||||
;;
|
||||
g++-*)
|
||||
travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
travis_retry sudo apt-get -qq update
|
||||
;;
|
||||
clang++-*)
|
||||
LLVM_REPO=${COMPILER/clang++/llvm-toolchain-${TRAVIS_DIST}}
|
||||
travis_retry wget -nv -O - "https://apt.llvm.org/llvm-snapshot.gpg.key" | sudo apt-key add -
|
||||
travis_retry sudo add-apt-repository -y "deb http://apt.llvm.org/${TRAVIS_DIST}/ ${LLVM_REPO%-10} main"
|
||||
travis_retry sudo apt-get -qq update
|
||||
;;
|
||||
esac
|
||||
|
||||
install:
|
||||
- if [[ -n ${COMPILER} ]]; then travis_retry sudo apt-get -qy install "${COMPILER/clang++/clang}"; fi
|
||||
|
||||
before_script:
|
||||
- if [[ ${TRAVIS_OS_NAME} == linux ]]; then export NODE_LABELS="Linux Ubuntu Ubuntu-14.04"; fi
|
||||
- if [[ ${TRAVIS_OS_NAME} == linux ]]; then export NODE_LABELS="Linux Ubuntu Ubuntu-18.04"; fi
|
||||
- if [[ ${TRAVIS_OS_NAME} == osx ]]; then export NODE_LABELS="OSX OSX-${OSX_VERSION}"; fi
|
||||
- if [[ ${OSX_VERSION} == 10.12 ]]; then brew update; fi
|
||||
# workaround for https://github.com/Homebrew/homebrew-core/issues/26358
|
||||
- if [[ ${OSX_VERSION} == 10.12 ]]; then brew outdated python || brew upgrade python; fi
|
||||
# workaround for https://github.com/travis-ci/travis-ci/issues/6688
|
||||
- if [[ ${OSX_VERSION} == 10.12 ]]; then /usr/bin/yes | pip2 uninstall numpy || true; fi
|
||||
- if [[ -n ${COMPILER} ]]; then export CXX=${COMPILER}; fi
|
||||
- ${CXX:-c++} --version
|
||||
- python --version
|
||||
|
||||
+53
-38
@@ -54,9 +54,9 @@ from waflib import Utils, Logs, Errors
|
||||
from waflib.Configure import conf
|
||||
from waflib.TaskGen import feature, after_method
|
||||
|
||||
BOOST_LIBS = ['/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu',
|
||||
'/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
|
||||
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
|
||||
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include']
|
||||
|
||||
BOOST_VERSION_FILE = 'boost/version.hpp'
|
||||
BOOST_VERSION_CODE = '''
|
||||
#include <iostream>
|
||||
@@ -91,13 +91,18 @@ int main() { boost::thread t; }
|
||||
|
||||
BOOST_LOG_CODE = '''
|
||||
#include <boost/log/trivial.hpp>
|
||||
int main() { BOOST_LOG_TRIVIAL(info) << "boost_log is working"; }
|
||||
'''
|
||||
|
||||
BOOST_LOG_SETUP_CODE = '''
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/log/utility/setup/console.hpp>
|
||||
#include <boost/log/utility/setup/common_attributes.hpp>
|
||||
int main() {
|
||||
using namespace boost::log;
|
||||
add_common_attributes();
|
||||
add_console_log(std::clog, keywords::format = "%Message%");
|
||||
BOOST_LOG_TRIVIAL(debug) << "log is working" << std::endl;
|
||||
BOOST_LOG_TRIVIAL(info) << "boost_log_setup is working";
|
||||
}
|
||||
'''
|
||||
|
||||
@@ -146,7 +151,7 @@ def options(opt):
|
||||
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
|
||||
help='''select libraries with tags (gd for debug, static is automatically added),
|
||||
see doc Boost, Getting Started, chapter 6.1''')
|
||||
opt.add_option('--boost-linkage_autodetect', action="store_true", dest='boost_linkage_autodetect',
|
||||
opt.add_option('--boost-linkage_autodetect', action='store_true', dest='boost_linkage_autodetect',
|
||||
help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
|
||||
opt.add_option('--boost-toolset', type='string',
|
||||
default='', dest='boost_toolset',
|
||||
@@ -176,7 +181,7 @@ def boost_get_version(self, d):
|
||||
try:
|
||||
txt = node.read()
|
||||
except EnvironmentError:
|
||||
Logs.error("Could not read the file %r" % node.abspath())
|
||||
Logs.error('Could not read the file %r' % node.abspath())
|
||||
else:
|
||||
re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.+)"', re.M)
|
||||
m1 = re_but1.search(txt)
|
||||
@@ -184,7 +189,7 @@ def boost_get_version(self, d):
|
||||
m2 = re_but2.search(txt)
|
||||
if m1 and m2:
|
||||
return (m1.group(1), m2.group(1))
|
||||
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(":")
|
||||
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(':')
|
||||
|
||||
@conf
|
||||
def boost_get_includes(self, *k, **kw):
|
||||
@@ -195,10 +200,10 @@ def boost_get_includes(self, *k, **kw):
|
||||
if self.__boost_get_version_file(d):
|
||||
return d
|
||||
if includes:
|
||||
self.end_msg('headers not found in %s' % includes)
|
||||
self.end_msg('headers not found in %s' % includes, 'YELLOW')
|
||||
self.fatal('The configuration failed')
|
||||
else:
|
||||
self.end_msg('headers not found, please provide a --boost-includes argument (see help)')
|
||||
self.end_msg('headers not found, please provide a --boost-includes argument (see help)', 'YELLOW')
|
||||
self.fatal('The configuration failed')
|
||||
|
||||
|
||||
@@ -241,10 +246,10 @@ def __boost_get_libs_path(self, *k, **kw):
|
||||
break
|
||||
if not path:
|
||||
if libs:
|
||||
self.end_msg('libs not found in %s' % libs)
|
||||
self.end_msg('libs not found in %s' % libs, 'YELLOW')
|
||||
self.fatal('The configuration failed')
|
||||
else:
|
||||
self.end_msg('libs not found, please provide a --boost-libs argument (see help)')
|
||||
self.end_msg('libs not found, please provide a --boost-libs argument (see help)', 'YELLOW')
|
||||
self.fatal('The configuration failed')
|
||||
|
||||
self.to_log('Found the boost path in %r with the libraries:' % path)
|
||||
@@ -314,7 +319,7 @@ def boost_get_libs(self, *k, **kw):
|
||||
libs.append(format_lib_name(file.name))
|
||||
break
|
||||
else:
|
||||
self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
|
||||
self.end_msg('lib %s not found in %s' % (lib, path.abspath()), 'YELLOW')
|
||||
self.fatal('The configuration failed')
|
||||
return libs
|
||||
|
||||
@@ -355,7 +360,7 @@ def _check_pthread_flag(self, *k, **kw):
|
||||
# ... -mt is also the pthreads flag for HP/aCC
|
||||
# -lpthread: GNU Linux, etc.
|
||||
# --thread-safe: KAI C++
|
||||
if Utils.unversioned_sys_platform() == "sunos":
|
||||
if Utils.unversioned_sys_platform() == 'sunos':
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
||||
@@ -363,23 +368,22 @@ def _check_pthread_flag(self, *k, **kw):
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
boost_pthread_flags = ["-pthreads", "-lpthread", "-mt", "-pthread"]
|
||||
boost_pthread_flags = ['-pthreads', '-lpthread', '-mt', '-pthread']
|
||||
else:
|
||||
boost_pthread_flags = ["", "-lpthreads", "-Kthread", "-kthread", "-llthread", "-pthread",
|
||||
"-pthreads", "-mthreads", "-lpthread", "--thread-safe", "-mt"]
|
||||
boost_pthread_flags = ['', '-lpthreads', '-Kthread', '-kthread', '-llthread', '-pthread',
|
||||
'-pthreads', '-mthreads', '-lpthread', '--thread-safe', '-mt']
|
||||
|
||||
for boost_pthread_flag in boost_pthread_flags:
|
||||
try:
|
||||
self.env.stash()
|
||||
self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
|
||||
self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
|
||||
self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False)
|
||||
|
||||
self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False, quiet=True)
|
||||
self.end_msg(boost_pthread_flag)
|
||||
return
|
||||
except self.errors.ConfigurationError:
|
||||
self.env.revert()
|
||||
self.end_msg('None')
|
||||
self.end_msg('none')
|
||||
|
||||
@conf
|
||||
def check_boost(self, *k, **kw):
|
||||
@@ -404,16 +408,24 @@ def check_boost(self, *k, **kw):
|
||||
|
||||
var = kw.get('uselib_store', 'BOOST')
|
||||
|
||||
self.start_msg('Checking boost includes')
|
||||
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
|
||||
versions = self.boost_get_version(inc)
|
||||
self.env.BOOST_VERSION = versions[0]
|
||||
self.env.BOOST_VERSION_NUMBER = int(versions[1])
|
||||
self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
|
||||
int(versions[1]) / 100 % 1000,
|
||||
int(versions[1]) % 100))
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
|
||||
if not self.env.DONE_FIND_BOOST_COMMON:
|
||||
self.find_program('dpkg-architecture', var='DPKG_ARCHITECTURE', mandatory=False)
|
||||
if self.env.DPKG_ARCHITECTURE:
|
||||
deb_host_multiarch = self.cmd_and_log([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
|
||||
BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())
|
||||
|
||||
self.start_msg('Checking boost includes')
|
||||
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
|
||||
versions = self.boost_get_version(inc)
|
||||
self.env.BOOST_VERSION = versions[0]
|
||||
self.env.BOOST_VERSION_NUMBER = int(versions[1])
|
||||
self.end_msg('%d.%d.%d' % (int(versions[1]) / 100000,
|
||||
int(versions[1]) / 100 % 1000,
|
||||
int(versions[1]) % 100))
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
|
||||
|
||||
self.env.DONE_FIND_BOOST_COMMON = True
|
||||
|
||||
if not params['lib'] and not params['stlib']:
|
||||
return
|
||||
@@ -425,7 +437,7 @@ def check_boost(self, *k, **kw):
|
||||
self.env['STLIBPATH_%s' % var] = [path]
|
||||
self.env['LIB_%s' % var] = libs
|
||||
self.env['STLIB_%s' % var] = stlibs
|
||||
self.end_msg('ok')
|
||||
self.end_msg(' '.join(libs + stlibs))
|
||||
if Logs.verbose:
|
||||
Logs.pprint('CYAN', ' path : %s' % path)
|
||||
Logs.pprint('CYAN', ' shared libs : %s' % libs)
|
||||
@@ -446,15 +458,18 @@ def check_boost(self, *k, **kw):
|
||||
self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
|
||||
if has_lib('thread'):
|
||||
self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
|
||||
if has_lib('log'):
|
||||
if has_lib('log') or has_lib('log_setup'):
|
||||
if not has_lib('thread'):
|
||||
self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
|
||||
if has_shlib('log'):
|
||||
if has_shlib('log') or has_shlib('log_setup'):
|
||||
self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
|
||||
self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
|
||||
if has_lib('log_setup'):
|
||||
self.check_cxx(fragment=BOOST_LOG_SETUP_CODE, use=var, execute=False)
|
||||
else:
|
||||
self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
|
||||
|
||||
if params.get('linkage_autodetect', False):
|
||||
self.start_msg("Attempting to detect boost linkage flags")
|
||||
self.start_msg('Attempting to detect boost linkage flags')
|
||||
toolset = self.boost_get_toolset(kw.get('toolset', ''))
|
||||
if toolset in ('vc',):
|
||||
# disable auto-linking feature, causing error LNK1181
|
||||
@@ -476,10 +491,10 @@ def check_boost(self, *k, **kw):
|
||||
# we attempt to play with some known-to-work CXXFLAGS combinations
|
||||
for cxxflags in (['/MD', '/EHsc'], []):
|
||||
self.env.stash()
|
||||
self.env["CXXFLAGS_%s" % var] += cxxflags
|
||||
self.env['CXXFLAGS_%s' % var] += cxxflags
|
||||
try:
|
||||
try_link()
|
||||
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
|
||||
self.end_msg('ok: winning cxxflags combination: %s' % (self.env['CXXFLAGS_%s' % var]))
|
||||
exc = None
|
||||
break
|
||||
except Errors.ConfigurationError as e:
|
||||
@@ -487,17 +502,17 @@ def check_boost(self, *k, **kw):
|
||||
exc = e
|
||||
|
||||
if exc is not None:
|
||||
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=exc)
|
||||
self.end_msg('Could not auto-detect boost linking flags combination, you may report it to boost.py author', ex=exc)
|
||||
self.fatal('The configuration failed')
|
||||
else:
|
||||
self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
|
||||
self.end_msg('Boost linkage flags auto-detection not implemented (needed ?) for this toolchain')
|
||||
self.fatal('The configuration failed')
|
||||
else:
|
||||
self.start_msg('Checking for boost linkage')
|
||||
try:
|
||||
try_link()
|
||||
except Errors.ConfigurationError as e:
|
||||
self.end_msg("Could not link against boost libraries using supplied options")
|
||||
self.end_msg('Could not link against boost libraries using supplied options', 'YELLOW')
|
||||
self.fatal('The configuration failed')
|
||||
self.end_msg('ok')
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
from waflib import TaskGen, Logs
|
||||
from waflib import TaskGen
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage',
|
||||
help='''Set compiler flags for gcc to enable code coverage information''')
|
||||
opt.add_option('--with-coverage', action='store_true', default=False,
|
||||
help='Add compiler flags to enable code coverage information')
|
||||
|
||||
def configure(conf):
|
||||
if conf.options.with_coverage:
|
||||
if not conf.options.debug:
|
||||
conf.fatal("Code coverage flags require debug mode compilation (add --debug)")
|
||||
conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
|
||||
conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
|
||||
linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
|
||||
|
||||
|
||||
@@ -1,64 +1,67 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
from waflib import Logs, Configure, Utils
|
||||
from waflib import Configure, Logs, Utils
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
|
||||
help='''Compile in debugging mode with minimal optimizations (-O0 or -Og)''')
|
||||
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
|
||||
help='Compile in debugging mode with minimal optimizations (-O0 or -Og)')
|
||||
|
||||
def configure(conf):
|
||||
conf.start_msg('Checking C++ compiler version')
|
||||
|
||||
cxx = conf.env['CXX_NAME'] # CXX_NAME is the generic name of the compiler
|
||||
ccver = tuple(int(i) for i in conf.env['CC_VERSION'])
|
||||
cxx = conf.env.CXX_NAME # generic name of the compiler
|
||||
ccver = tuple(int(i) for i in conf.env.CC_VERSION)
|
||||
ccverstr = '.'.join(conf.env.CC_VERSION)
|
||||
errmsg = ''
|
||||
warnmsg = ''
|
||||
if cxx == 'gcc':
|
||||
if ccver < (4, 8, 2):
|
||||
if ccver < (5, 3, 0):
|
||||
errmsg = ('The version of gcc you are using is too old.\n'
|
||||
'The minimum supported gcc version is 4.8.2.')
|
||||
flags = GccFlags()
|
||||
'The minimum supported gcc version is 5.3.0.')
|
||||
conf.flags = GccFlags()
|
||||
elif cxx == 'clang':
|
||||
if ccver < (3, 4, 0):
|
||||
if ccver < (3, 6, 0):
|
||||
errmsg = ('The version of clang you are using is too old.\n'
|
||||
'The minimum supported clang version is 3.4.0.')
|
||||
flags = ClangFlags()
|
||||
'The minimum supported clang version is 3.6.0.')
|
||||
conf.flags = ClangFlags()
|
||||
else:
|
||||
warnmsg = 'Note: %s compiler is unsupported' % cxx
|
||||
flags = CompilerFlags()
|
||||
conf.flags = CompilerFlags()
|
||||
|
||||
if errmsg:
|
||||
conf.end_msg('.'.join(conf.env['CC_VERSION']), color='RED')
|
||||
conf.end_msg(ccverstr, color='RED')
|
||||
conf.fatal(errmsg)
|
||||
elif warnmsg:
|
||||
conf.end_msg('.'.join(conf.env['CC_VERSION']), color='YELLOW')
|
||||
conf.end_msg(ccverstr, color='YELLOW')
|
||||
Logs.warn(warnmsg)
|
||||
else:
|
||||
conf.end_msg('.'.join(conf.env['CC_VERSION']))
|
||||
conf.end_msg(ccverstr)
|
||||
|
||||
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
|
||||
conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
|
||||
|
||||
# General flags are always applied (e.g., selecting C++11 mode)
|
||||
generalFlags = flags.getGeneralFlags(conf)
|
||||
# General flags are always applied (e.g., selecting C++ language standard)
|
||||
generalFlags = conf.flags.getGeneralFlags(conf)
|
||||
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
|
||||
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
|
||||
conf.env.DEFINES += generalFlags['DEFINES']
|
||||
|
||||
@Configure.conf
|
||||
def check_compiler_flags(conf):
|
||||
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
|
||||
# corresponding environment variables are not set.
|
||||
# DEFINES are always applied.
|
||||
if conf.options.debug:
|
||||
extraFlags = flags.getDebugFlags(conf)
|
||||
if areCustomCxxflagsPresent:
|
||||
extraFlags = conf.flags.getDebugFlags(conf)
|
||||
if conf.areCustomCxxflagsPresent:
|
||||
missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
|
||||
if len(missingFlags) > 0:
|
||||
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
|
||||
% " ".join(conf.env.CXXFLAGS))
|
||||
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
|
||||
if missingFlags:
|
||||
Logs.warn('Selected debug mode, but CXXFLAGS is set to a custom value "%s"'
|
||||
% ' '.join(conf.env.CXXFLAGS))
|
||||
Logs.warn('Default flags "%s" will not be used' % ' '.join(missingFlags))
|
||||
else:
|
||||
extraFlags = flags.getOptimizedFlags(conf)
|
||||
extraFlags = conf.flags.getOptimizedFlags(conf)
|
||||
|
||||
if not areCustomCxxflagsPresent:
|
||||
if not conf.areCustomCxxflagsPresent:
|
||||
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
|
||||
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
|
||||
|
||||
@@ -75,9 +78,10 @@ def add_supported_cxxflags(self, cxxflags):
|
||||
self.start_msg('Checking supported CXXFLAGS')
|
||||
|
||||
supportedFlags = []
|
||||
for flag in cxxflags:
|
||||
if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
|
||||
supportedFlags += [flag]
|
||||
for flags in cxxflags:
|
||||
flags = Utils.to_list(flags)
|
||||
if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False):
|
||||
supportedFlags += flags
|
||||
|
||||
self.end_msg(' '.join(supportedFlags))
|
||||
self.env.prepend_value('CXXFLAGS', supportedFlags)
|
||||
@@ -93,15 +97,19 @@ def add_supported_linkflags(self, linkflags):
|
||||
self.start_msg('Checking supported LINKFLAGS')
|
||||
|
||||
supportedFlags = []
|
||||
for flag in linkflags:
|
||||
if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
|
||||
supportedFlags += [flag]
|
||||
for flags in linkflags:
|
||||
flags = Utils.to_list(flags)
|
||||
if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False):
|
||||
supportedFlags += flags
|
||||
|
||||
self.end_msg(' '.join(supportedFlags))
|
||||
self.env.prepend_value('LINKFLAGS', supportedFlags)
|
||||
|
||||
|
||||
class CompilerFlags(object):
|
||||
def getCompilerVersion(self, conf):
|
||||
return tuple(int(i) for i in conf.env.CC_VERSION)
|
||||
|
||||
def getGeneralFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
|
||||
@@ -120,7 +128,11 @@ class GccBasicFlags(CompilerFlags):
|
||||
"""
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-std=c++11']
|
||||
flags['CXXFLAGS'] += ['-std=c++14']
|
||||
if Utils.unversioned_sys_platform() == 'linux':
|
||||
flags['LINKFLAGS'] += ['-fuse-ld=gold']
|
||||
elif Utils.unversioned_sys_platform() == 'freebsd':
|
||||
flags['LINKFLAGS'] += ['-fuse-ld=lld']
|
||||
return flags
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
@@ -132,11 +144,12 @@ class GccBasicFlags(CompilerFlags):
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Werror',
|
||||
'-Wnon-virtual-dtor',
|
||||
'-Wno-error=deprecated-declarations', # Bug #3795
|
||||
'-Wno-error=maybe-uninitialized', # Bug #1615
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
|
||||
flags['LINKFLAGS'] += ['-Wl,-O1']
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
@@ -146,57 +159,58 @@ class GccBasicFlags(CompilerFlags):
|
||||
'-pedantic',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wnon-virtual-dtor',
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
flags['LINKFLAGS'] += ['-fuse-ld=gold', '-Wl,-O1']
|
||||
flags['LINKFLAGS'] += ['-Wl,-O1']
|
||||
return flags
|
||||
|
||||
class GccFlags(GccBasicFlags):
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(GccFlags, self).getDebugFlags(conf)
|
||||
version = tuple(int(i) for i in conf.env['CC_VERSION'])
|
||||
if version < (5, 1, 0):
|
||||
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
|
||||
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
|
||||
flags['CXXFLAGS'] += ['-fdiagnostics-color']
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(GccFlags, self).getOptimizedFlags(conf)
|
||||
version = tuple(int(i) for i in conf.env['CC_VERSION'])
|
||||
if version < (5, 1, 0):
|
||||
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
|
||||
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
|
||||
flags['CXXFLAGS'] += ['-fdiagnostics-color']
|
||||
return flags
|
||||
|
||||
class ClangFlags(GccBasicFlags):
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getGeneralFlags(conf)
|
||||
if Utils.unversioned_sys_platform() == 'darwin':
|
||||
flags['CXXFLAGS'] += ['-stdlib=libc++']
|
||||
flags['LINKFLAGS'] += ['-stdlib=libc++']
|
||||
if Utils.unversioned_sys_platform() == 'darwin' and self.getCompilerVersion(conf) >= (9, 0, 0):
|
||||
# Bug #4296
|
||||
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
|
||||
['-isystem', '/opt/local/include']] # for MacPorts
|
||||
if Utils.unversioned_sys_platform() == 'freebsd':
|
||||
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']] # Bug #4790
|
||||
return flags
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wno-error=deprecated-register',
|
||||
'-Wno-error=ignored-qualifiers',
|
||||
'-Wno-error=infinite-recursion', # Bug #3358
|
||||
'-Wno-error=keyword-macro', # Bug #3235
|
||||
'-Wno-error=unneeded-internal-declaration', # Bug #1588
|
||||
'-Wno-keyword-macro',
|
||||
'-Wno-nested-anon-types',
|
||||
'-Wno-sign-compare',
|
||||
'-Wextra-semi',
|
||||
'-Wundefined-func-template',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
]
|
||||
version = self.getCompilerVersion(conf)
|
||||
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
|
||||
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
|
||||
if version < (6, 0, 0):
|
||||
flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wno-keyword-macro',
|
||||
'-Wno-nested-anon-types',
|
||||
'-Wno-sign-compare',
|
||||
'-Wextra-semi',
|
||||
'-Wundefined-func-template',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
]
|
||||
version = self.getCompilerVersion(conf)
|
||||
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
|
||||
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
|
||||
if version < (6, 0, 0):
|
||||
flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
|
||||
return flags
|
||||
@@ -44,28 +44,28 @@ def apply_sphinx(self):
|
||||
task.inputs.append(conf)
|
||||
|
||||
confdir = conf.parent.abspath()
|
||||
buildername = getattr(self, "builder", "html")
|
||||
srcdir = getattr(self, "srcdir", confdir)
|
||||
outdir = self.path.find_or_declare(getattr(self, "outdir", buildername)).get_bld()
|
||||
doctreedir = getattr(self, "doctreedir", os.path.join(outdir.abspath(), ".doctrees"))
|
||||
buildername = getattr(self, 'builder', 'html')
|
||||
srcdir = getattr(self, 'srcdir', confdir)
|
||||
outdir = self.path.find_or_declare(getattr(self, 'outdir', buildername)).get_bld()
|
||||
doctreedir = getattr(self, 'doctreedir', os.path.join(outdir.abspath(), '.doctrees'))
|
||||
|
||||
task.env['BUILDERNAME'] = buildername
|
||||
task.env['SRCDIR'] = srcdir
|
||||
task.env['DOCTREEDIR'] = doctreedir
|
||||
task.env['OUTDIR'] = outdir.abspath()
|
||||
task.env['VERSION'] = "version=%s" % self.VERSION
|
||||
task.env['RELEASE'] = "release=%s" % self.VERSION
|
||||
task.env['VERSION'] = 'version=%s' % self.version
|
||||
task.env['RELEASE'] = 'release=%s' % getattr(self, 'release', self.version)
|
||||
|
||||
import imp
|
||||
confData = imp.load_source('sphinx_conf', conf.abspath())
|
||||
|
||||
if buildername == "man":
|
||||
if buildername == 'man':
|
||||
for i in confData.man_pages:
|
||||
target = outdir.find_or_declare('%s.%d' % (i[1], i[4]))
|
||||
task.outputs.append(target)
|
||||
|
||||
if self.install_path:
|
||||
self.bld.install_files("%s/man%d/" % (self.install_path, i[4]), target)
|
||||
self.bld.install_files('%s/man%d/' % (self.install_path, i[4]), target)
|
||||
else:
|
||||
task.outputs.append(outdir)
|
||||
|
||||
|
||||
+34
-53
@@ -1,57 +1,38 @@
|
||||
NLSR Authors
|
||||
============
|
||||
# NLSR Authors
|
||||
|
||||
NLSR is an open source project includes contributions from the members of the
|
||||
[NDN project team](http://named-data.net/project/participants/).
|
||||
The following lists maintainers, primary developers, and all much-appreciated contributors to NLSR in alphabetic order.
|
||||
The specific contributions of individual authors can be obtained from the git history of the [official NLSR repository](https://github.com/named-data/NLSR).
|
||||
If you would like to become a contributor to the official repository, please follow the recommendations in https://github.com/named-data/.github/blob/master/CONTRIBUTING.md.
|
||||
|
||||
## Project co-leads:
|
||||
* Alexander Afanasyev <https://users.cs.fiu.edu/~afanasyev>
|
||||
* Adam Alyyan <https://github.com/a64adam>
|
||||
* Syed Obaid Amin <http://obaidamin.weebly.com/>
|
||||
* Pedro David Arjona Villicaña <https://github.com/david-arjona>
|
||||
* Muktadir R. Chowdhury <https://github.com/alvyC>
|
||||
* Damian Coomes <https://github.com/dmcoomes>
|
||||
* ***(Maintainer)*** Saurab Dulal <https://dulalsaurab.github.io>
|
||||
* Laqin Fan <https://github.com/laqinfan>
|
||||
* Simon Fayer <https://github.com/sfayer>
|
||||
* ***(Former Maintainer)*** Ashlesh Gawande <https://www.linkedin.com/in/agawande>
|
||||
* ***(Former Maintainer)*** Nicholas Gordon <https://github.com/gorgonical>
|
||||
* ***(Former Maintainer)*** A. K. M. Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
|
||||
* ***(Former Maintainer)*** Vince Lehman <http://vslehman.com>
|
||||
* Tianxing Ma <https://github.com/matianxing1992>
|
||||
* Spyridon Mastorakis <https://sites.google.com/site/spyridonmastorakis>
|
||||
* Eric Newberry <https://ericnewberry.com>
|
||||
* João Pereira <http://website.jpereira.co.uk>
|
||||
* Davide Pesavento <https://github.com/Pesa>
|
||||
* Md Ashiqur Rahman <https://ashiqrahman.com>
|
||||
* Junxiao Shi <https://cs.arizona.edu/~shijunxiao>
|
||||
* Salvatore Signorello <https://wwwen.uni.lu/snt/people/salvatore_signorello>
|
||||
* Jiewen Tan <https://www.linkedin.com/in/jiewentan>
|
||||
* Alejandro Gil Torres <https://github.com/gltorres>
|
||||
* Ryan Wickman <http://rwickman.github.io>
|
||||
* Yingdi Yu <https://irl.cs.ucla.edu/~yingdi>
|
||||
* Minsheng Zhang <https://www.linkedin.com/in/minsheng-zhang-032023a1>
|
||||
|
||||
* Ashlesh Gawande <https://www.linkedin.com/in/agawande>
|
||||
* Nicholas Gordon <nmgordon@memphis.edu>
|
||||
## Technical Advisors
|
||||
|
||||
## Past project leads:
|
||||
|
||||
* A K M Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
|
||||
## Technical advisors:
|
||||
|
||||
* Lan Wang <http://www.cs.memphis.edu/~lanwang/>
|
||||
* Beichuan Zhang <http://www.cs.arizona.edu/~bzhang/>
|
||||
* Lixia Zhang <http://www.cs.ucla.edu/~lixia/>
|
||||
|
||||
|
||||
## All project authors, contributors and their affiliations:
|
||||
|
||||
* The University of Memphis
|
||||
|
||||
* A K M Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
|
||||
* Ashlesh Gawande <https://www.linkedin.com/in/agawande>
|
||||
* Minsheng Zhang <https://www.linkedin.com/in/minsheng-zhang-032023a1>
|
||||
* 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>
|
||||
* Damian Coomes <dmcoomes@memphis.edu>
|
||||
* Saurab Dulal <sdulal@memphis.edu>
|
||||
|
||||
* University of California, Los Angeles
|
||||
|
||||
* Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/web/index.html>
|
||||
* Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
|
||||
* Spyridon Mastorakis <http://cs.ucla.edu/~mastorakis/>
|
||||
* Jiewen Tan <https://www.linkedin.com/in/jiewentan>
|
||||
|
||||
* University of Arizona
|
||||
|
||||
* Junxiao Shi <https://www.linkedin.com/in/shijunxiao>
|
||||
|
||||
* University Pierre & Marie Curie, Sorbonne University
|
||||
|
||||
* Davide Pesavento <https://www.linkedin.com/in/davidepesavento>
|
||||
|
||||
## Queries about NLSR
|
||||
|
||||
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).
|
||||
* Lan Wang <http://www.cs.memphis.edu/~lanwang>
|
||||
* Beichuan Zhang <https://cs.arizona.edu/~bzhang>
|
||||
* Lixia Zhang <https://web.cs.ucla.edu/~lixia>
|
||||
+367
-368
File diff suppressed because it is too large.
Load diff
@@ -71,8 +71,18 @@ value are enabled.
|
||||
FATAL fatal (will be logged unconditionally)
|
||||
|
||||
To obtain logs for NLSR, set the NDN_LOG environment variable with the correct prefix and
|
||||
log-level settings. For example, running the command `export NDN_LOG=nlsr.*=TRACE && nlsr`
|
||||
will display all log messages in NLSR with a DEBUG level or below. If the user is presented
|
||||
with an error message `User does not have read and write permission on the directory` it can
|
||||
be circumvented by running the application with sudo: `sudo env NDN_LOG=nlsr.*=DEBUG nlsr`.
|
||||
log-level settings. For example, running the following command will display all log
|
||||
messages in NLSR with a DEBUG level or below.
|
||||
|
||||
::
|
||||
|
||||
NDN_LOG='nlsr.*=DEBUG' nlsr
|
||||
|
||||
If the user is presented with an error message `User does not have read and write
|
||||
permission on the directory` it can be circumvented by running the application with sudo:
|
||||
|
||||
::
|
||||
|
||||
sudo env NDN_LOG='nlsr.*=DEBUG' nlsr
|
||||
|
||||
Use `man ndn-log` for more detailed instructions.
|
||||
+15
-3
@@ -7,17 +7,29 @@ NLSR Installation Instructions
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
- `NFD <http://named-data.net/doc/NFD/current/>`_ and its requirements:
|
||||
- `NFD <https://named-data.net/doc/NFD/>`_ and its requirements:
|
||||
|
||||
Refer to `Getting started with NFD <http://named-data.net/doc/NFD/current/INSTALL.html>`_
|
||||
Refer to `Getting started with NFD <https://named-data.net/doc/NFD/current/INSTALL.html>`_
|
||||
for detailed installation and running instruction.
|
||||
|
||||
- ChronoSync library
|
||||
- ChronoSync library:
|
||||
|
||||
Download the ChronoSync library and build it according to the instructions at the following
|
||||
address:
|
||||
|
||||
::
|
||||
|
||||
https://github.com/named-data/ChronoSync#build
|
||||
|
||||
- PSync library:
|
||||
|
||||
Download the PSync library and build it according to the instructions at the following
|
||||
address:
|
||||
|
||||
::
|
||||
|
||||
https://github.com/named-data/PSync#build
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
|
||||
+14
-2
@@ -35,6 +35,9 @@ The number represents the connecting face id. For example,
|
||||
We will walk through setting up the faces and creating the configuration file for
|
||||
``/ndn/edu/memphis/%C1.Router/router1``.
|
||||
|
||||
It is recommended to configure security as described at :doc:`SECURITY-CONFIG`, before
|
||||
starting router configuration.
|
||||
|
||||
Step 1. Ensuring nfd is running
|
||||
-------------------------------
|
||||
|
||||
@@ -48,6 +51,15 @@ If you see ``error while connecting to the forwarder (No such file or directory)
|
||||
``nfd`` is not running. Follow the instructions in `Getting started with NFD
|
||||
<http://named-data.net/doc/NFD/current/INSTALL.html>`_ to run nfd.
|
||||
|
||||
Since v0.4.0, NLSR no longer creates Faces for the neighbors that are
|
||||
specified in ``nlsr.conf``. Instead, it relies on the pre-existence of
|
||||
the Faces in NFD. NLSR will obtain this information from NFD, and
|
||||
configure its neighbors using this information.
|
||||
|
||||
To create faces it is now necessary to use the ``nfdc`` command. Its documentation can
|
||||
be found `here
|
||||
<https://named-data.net/doc/NFD/current/manpages/nfdc.html>`_
|
||||
|
||||
Step 2. Determining FaceUri
|
||||
---------------------------
|
||||
|
||||
@@ -83,7 +95,7 @@ configuration commands follows:
|
||||
; InterestLifetime (in seconds) for LSA fetching
|
||||
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
|
||||
|
||||
seq-dir /var/lib/nlsr/
|
||||
state-dir /var/lib/nlsr/ ; state directory to store all dynamic changes to NLSR
|
||||
}
|
||||
|
||||
; the neighbors section contains the configuration for router's neighbors and hello's behavior
|
||||
@@ -197,7 +209,7 @@ To avoid this, the directory can be set in a user-owned directory. For example:
|
||||
{
|
||||
...
|
||||
|
||||
seq-dir /home/username/nlsr/log ; path for sequence directory (Absolute path)
|
||||
state-dir /home/username/nlsr/log ; path for sequence directory and other dynamic changes (Absolute path)
|
||||
|
||||
}
|
||||
...
|
||||
|
||||
@@ -35,12 +35,15 @@ router /\<network\>/\<site\>/%C1.Router/\<router-name\> /ndn/edu/ucla/%C
|
||||
NLSR /\<network\>/\<site\>/%C1.Router/\<router-name\>/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR/KEY/5/%00/%01
|
||||
======== ===================================================== ================================= ===============================================
|
||||
|
||||
Users should create keys according to the naming and signing hierarchies above.
|
||||
Users should create keys according to the naming and signing hierarchies above. The
|
||||
``%C1.Operator`` and ``%C1.Router`` labels are NDN keywords that should not be modified
|
||||
by the user.
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
Detailed information about key setup is given in NLSR Developer's Guide.
|
||||
Detailed information about key setup is given in NLSR Developer's Guide and the
|
||||
:doc:`beginners-guide`.
|
||||
|
||||
Certificate Publishing
|
||||
----------------------
|
||||
|
||||
@@ -0,0 +1,888 @@
|
||||
==========================================================
|
||||
A beginners guide to installing and testing NLSR on Fedora
|
||||
==========================================================
|
||||
|
||||
:Authors: David Arjona-Villicaña, Octavio Renteria-Vidales, Ashlesh Gawande
|
||||
:Date: November, 2018
|
||||
:Abstract: This is an easy to follow guide on how to install and test the NLSR routing protocol for NDN using two Fedora 28 machines. The commands and the paths used in this guide have been tested only in Fedora, although a similar procedure should be used for other linux systems. Specifically, the testing section (§ `5 <#test>`__) is platform independent. Therefore users who have NLSR already installed may skip to this section. Since neither NDN, NLSR nor Fedora are static software developments, it is expected that some commands and features in this guide will change over time. However, this guide is as accurate as it could be at the time it was published.
|
||||
|
||||
.. role:: raw-latex(raw)
|
||||
:format: latex
|
||||
|
||||
|
||||
.. _intro:
|
||||
|
||||
1. Introduction
|
||||
===============
|
||||
|
||||
The following instructions are based on the information provided at the
|
||||
Named Data Networking project web page [NDNmain]_.
|
||||
Before installing NLSR it is necessary to install different libraries
|
||||
and programs: ndn-cxx, NFD, ChronoSync, and PSync. This document describes the
|
||||
necessary steps to correctly install these programs (§ `2 <#ndncxx>`__,
|
||||
`3 <#nfd>`__ and `4 <#nlsr>`__) and a brief guide on how to configure
|
||||
and test NLSR using a simple two-node network (§ `5 <#test>`__).
|
||||
|
||||
Many of the commands in this guide need to be executed as *root*.
|
||||
Starting from Fedora 28, there is no need to set a root user
|
||||
[Kolman2018]_. However it is possible to define it,
|
||||
using the following command:
|
||||
|
||||
::
|
||||
|
||||
$ sudo -i
|
||||
|
||||
And then using the *passwd* command to set up a password. After setting
|
||||
up the root user, it is possible to become root by employing the
|
||||
following command and providing the root password when prompted:
|
||||
|
||||
::
|
||||
|
||||
$ su -
|
||||
|
||||
Fedora employs the *dnf* command to install and verify installed
|
||||
packages. The following commands may become useful during the
|
||||
installation process and should be executed as root:
|
||||
|
||||
- To verify that all installed packages are up to date
|
||||
|
||||
::
|
||||
|
||||
$ dnf update
|
||||
|
||||
- To verify if a package is already installed in the system
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed <package-name>
|
||||
|
||||
- To search for information about a package or family of packages (not
|
||||
necessarily installed in the system).
|
||||
|
||||
::
|
||||
|
||||
$ dnf info <package-name>
|
||||
|
||||
- To install a package in the system.
|
||||
|
||||
::
|
||||
|
||||
$ dnf install <package-name>
|
||||
|
||||
It is also a good installation practice to download and install all the
|
||||
NDN programs in a common directory. Therefore, it is recommended to
|
||||
create a directory at the home directory where all the following
|
||||
programs may get installed. The name of this directory is not important.
|
||||
However, the following are provided as suggestions: project, NDNproject,
|
||||
NDNprograms. Each of the programs in the following sections should be
|
||||
downloaded to their own directory using the *git* command, and then
|
||||
compiled in this directory.
|
||||
|
||||
.. _ndncxx:
|
||||
|
||||
2. Installing ndn-cxx
|
||||
=====================
|
||||
|
||||
2.1 Before installing ndn-cxx
|
||||
-----------------------------
|
||||
|
||||
An updated list of the packages and programs that need to be installed
|
||||
before installing ndn-cxx, is provided at [NDN-cxx]_.
|
||||
This list is also reproduced bellow with the commands to verify that all
|
||||
the packages have been installed in the system. The following commands
|
||||
should be run as root:
|
||||
|
||||
#. gcc and gcc-c++
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed gcc
|
||||
$ dnf list --installed gcc-c++
|
||||
|
||||
#. Python version 2.6 or later
|
||||
|
||||
::
|
||||
|
||||
$ python -V
|
||||
|
||||
#. libsqlite3
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed sqlite
|
||||
$ dnf list --installed sqlite-devel
|
||||
|
||||
#. openssl version 1.0.1 or later
|
||||
|
||||
::
|
||||
|
||||
$ openssl version
|
||||
$ dnf list --installed openssl-devel
|
||||
|
||||
#. pkgconf that replaces pkg-config
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed pkgconf*
|
||||
|
||||
#. boost libraries version 1.54 or later
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed boost
|
||||
$ dnf list --installed boost-devel
|
||||
|
||||
#. doxygen
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed doxygen
|
||||
|
||||
#. graphviz
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed graphviz
|
||||
|
||||
#. python2-sphinx that replaces python-sphinx
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed python2-sphinx
|
||||
|
||||
#. After verifying that the python-sphinx package has been installed, it
|
||||
is necessary to run the following two commands:
|
||||
|
||||
::
|
||||
|
||||
$ pip-3 install sphinxcontrib-doxylink
|
||||
$ pip install sphinxcontrib-googleanalytics
|
||||
|
||||
Note: When the two previous commands are run before correctly
|
||||
installing python-sphinx, the following error message is produced
|
||||
when trying to install this latter package: “Error unpacking rpm
|
||||
package python2-urllib3-1.22-3.fc27.noarch”. To fix this problem, it
|
||||
is necessary to run the following commands before installing
|
||||
python-sphinx again:
|
||||
|
||||
::
|
||||
|
||||
$ dnf remove python2-sphinx
|
||||
$ pip uninstall sphinxcontrib-googleanalytics
|
||||
$ pip-3 uninstall sphinxcontrib-doxylink
|
||||
$ pip uninstall urllib3
|
||||
|
||||
#. dpkg-architecture
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed dpkg
|
||||
$ dnf list --installed dpkg-dev
|
||||
|
||||
#. git and valgrind, which is used when installing NFD (§
|
||||
`3 <#nfd>`__).
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed valgrind
|
||||
$ dnf list --installed valgrind-devel
|
||||
$ dnf list --installed git
|
||||
|
||||
2.2 Downloading and installing ndn-cxx
|
||||
--------------------------------------
|
||||
|
||||
The *git* command allows to download the ndn-cxx library in its own
|
||||
folder, also called *ndn-cxx*. Therefore it is recommended to execute
|
||||
this command at the directory created at § `1 <#intro>`__:
|
||||
|
||||
::
|
||||
|
||||
$ git clone --depth 1 https://github.com/named-data/ndn-cxx.git
|
||||
|
||||
Move to the ndn-cxx directory:
|
||||
|
||||
::
|
||||
|
||||
$ cd ndn-cxx
|
||||
|
||||
Use the following command to verify that everything is ready to compile.
|
||||
If an error message displays, it is necessary to fix it before
|
||||
continuing:
|
||||
|
||||
::
|
||||
|
||||
$ ./waf configure --with-examples
|
||||
|
||||
Compile the ndn-cxx library and install the compiled files at the
|
||||
system’s directories:
|
||||
|
||||
::
|
||||
|
||||
$ ./waf
|
||||
$ sudo ./waf install
|
||||
|
||||
2.3 Configuring ndn-cxx
|
||||
-----------------------
|
||||
|
||||
The commands in this subsection need to be run as root. First, it is
|
||||
necessary to create file *local.conf*, which contains a line with the
|
||||
location for the ndn-cxx library:
|
||||
|
||||
::
|
||||
|
||||
$ echo /usr/local/lib64 >> /etc/ld.so.conf.d/local.conf
|
||||
|
||||
The following command configures the libraries:
|
||||
|
||||
::
|
||||
|
||||
$ ldconfig -v | grep ndn
|
||||
|
||||
This command should display a line similar to the following:
|
||||
|
||||
::
|
||||
|
||||
libndn-cxx.so.0.6.1 -> libndn-cxx.so.0.6.1
|
||||
|
||||
Configure the NDN path:
|
||||
|
||||
::
|
||||
|
||||
$ echo export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig >>
|
||||
/etc/profile.d/ndn.sh
|
||||
|
||||
After this command has been executed, it is necessary to apply the
|
||||
changes by either logging out and back in, and then running the
|
||||
following command:
|
||||
|
||||
::
|
||||
|
||||
$ printenv | grep PKG
|
||||
|
||||
Or by executing the following command:
|
||||
|
||||
::
|
||||
|
||||
$ ./etc/profile.d/ndn.sh
|
||||
|
||||
For more information and examples about how to compile and configure
|
||||
this library, users should read the ndn-cxx guide at
|
||||
[NDN-cxx]_.
|
||||
|
||||
.. _nfd:
|
||||
|
||||
3. Installing NFD
|
||||
=================
|
||||
|
||||
3.1 Before installing NFD
|
||||
-------------------------
|
||||
|
||||
An updated list of the packages and programs that need to be installed
|
||||
before NFD is provided at [NDNNFD]_. Before installing
|
||||
NFD it is necessary to verify that the following packages are installed:
|
||||
|
||||
#. libpcap libraries
|
||||
|
||||
::
|
||||
|
||||
$ dnf list --installed libpcap
|
||||
$ dnf list --installed libpcap-devel
|
||||
|
||||
3.2 Downloading and installing NFD
|
||||
----------------------------------
|
||||
|
||||
This library is downloaded and installed in a folder called *NFD*, which
|
||||
should be created at the directory defined at § `1 <#intro>`__. The
|
||||
following commands need to be run as a regular user:
|
||||
|
||||
::
|
||||
|
||||
$ git clone --depth 1 https://github.com/named-data/NFD.git
|
||||
$ cd NFD
|
||||
$ ./waf configure
|
||||
|
||||
If the previous command prints an error message saying that waf cannot
|
||||
find WebSocket, it is necessary to follow the instructions provided by
|
||||
this same output, which tells the user to execute either of the
|
||||
following two set of commands:
|
||||
|
||||
::
|
||||
|
||||
$ git submodule init && git submodule update
|
||||
|
||||
Or:
|
||||
|
||||
::
|
||||
|
||||
$ mkdir websocketpp
|
||||
$ curl -L https://github.com/zaphoyd/websocketpp/archive/0.7.0.tar.gz
|
||||
> websocket.tar.gz
|
||||
$ tar zxf websocket.tar.gz -C websocketpp/ --strip 1
|
||||
|
||||
After executing either of these instructions, complete the configuration
|
||||
by running *./waf configure* again. Then complete the installation by
|
||||
means of the following commands:
|
||||
|
||||
::
|
||||
|
||||
$ ./waf
|
||||
$ sudo ./waf install
|
||||
|
||||
3.3 Configuring NFD
|
||||
-------------------
|
||||
|
||||
Create a configuration file by running the following command as root:
|
||||
|
||||
::
|
||||
|
||||
$ cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf
|
||||
|
||||
After the configuration file has been created, NFD’s behavior may be
|
||||
changed by modifying this file. Once the configuration file has been
|
||||
created, it is recommended to start NFD by using the following command:
|
||||
|
||||
::
|
||||
|
||||
$ nfd-start
|
||||
|
||||
This command does not properly allow to employ the command window to
|
||||
enter new commands; however it displays the NFD logs. Therefore, it is
|
||||
recommended to open a new command window. This second window may be used
|
||||
to verify NDF’s status and then stop NFD by using the following
|
||||
commands:
|
||||
|
||||
::
|
||||
|
||||
$ nfd-status
|
||||
$ nfd-stop
|
||||
|
||||
.. _nlsr:
|
||||
|
||||
4. Installing NLSR
|
||||
==================
|
||||
|
||||
4.1 Installing ChronoSync
|
||||
-------------------------
|
||||
|
||||
Before installing NLSR, it is necessary to first download and install
|
||||
ChronoSync, which is a synchronization library which allows NLSR routers
|
||||
to synchronize Link State Advertisements (LSAs). More information about
|
||||
ChronoSync may be found at [Chronosync]_. This library may be
|
||||
installed by running the following commands as a regular user and at the
|
||||
directory defined at § `1 <#intro>`__:
|
||||
|
||||
::
|
||||
|
||||
$ git clone --depth 1 https://github.com/named-data/ChronoSync.git
|
||||
$ cd ChronoSync
|
||||
$ ./waf configure
|
||||
$ ./waf
|
||||
$ sudo ./waf install
|
||||
|
||||
The following command needs to be used again to configure the libraries:
|
||||
|
||||
::
|
||||
|
||||
$ sudo ldconfig -v | grep -i chronosync
|
||||
|
||||
This command should display a line similar to the following:
|
||||
|
||||
::
|
||||
|
||||
libChronoSync.so.0.5.0 -> libChronoSync.so.0.5.0
|
||||
|
||||
4.2 Installing PSync
|
||||
-------------------------
|
||||
|
||||
Before installing NLSR, it is also necessary to download and install
|
||||
PSync. PSync is a synchronization library which allows NLSR to synchronize LSAs
|
||||
similar to ChronoSync. More information about PSync may be found at [PSync]_.
|
||||
This library may be installed by running the following commands as a regular
|
||||
user and at the directory defined at § `1 <#intro>`__:
|
||||
|
||||
::
|
||||
|
||||
$ git clone --depth 1 https://github.com/named-data/PSync.git
|
||||
$ cd PSync
|
||||
$ ./waf configure
|
||||
$ ./waf
|
||||
$ sudo ./waf install
|
||||
|
||||
The following command needs to be used again to configure the libraries:
|
||||
|
||||
::
|
||||
|
||||
$ sudo ldconfig -v | grep -i psync
|
||||
|
||||
This command should display a line similar to the following:
|
||||
|
||||
::
|
||||
|
||||
libPSync.so.0.1.0 -> libPSync.so.0.1.0
|
||||
|
||||
4.3 Downloading and installing NLSR
|
||||
-----------------------------------
|
||||
|
||||
NLSR is downloaded and installed in a folder called *NLSR* which should
|
||||
be created at the directory defined at § `1 <#intro>`__. The following
|
||||
commands need to be run as a regular user:
|
||||
|
||||
::
|
||||
|
||||
$ git clone --depth 1 https://github.com/named-data/NLSR.git
|
||||
$ cd NLSR
|
||||
$ ./waf configure
|
||||
$ ./waf
|
||||
$ sudo ./waf install
|
||||
|
||||
4.4 Configuring NLSR
|
||||
--------------------
|
||||
|
||||
Create and configure the following directory by running the following
|
||||
commands as root:
|
||||
|
||||
::
|
||||
|
||||
$ mkdir /var/lib/nlsr
|
||||
$ chmod 777 /var/lib/nlsr
|
||||
|
||||
.. _test:
|
||||
|
||||
5. Configuring and Testing NLSR
|
||||
===============================
|
||||
|
||||
To test NLSR, the first step is to configure the keys and certificates
|
||||
that implement a secure communication between the routers. Then it is
|
||||
necessary to verify that the computers in the test network are
|
||||
connected, that NFD is running and the faces between the computers are
|
||||
configured. Finally, the NLSR configuration file has to be edited before
|
||||
running NLSR. The following subsections are provided as a guide to
|
||||
define and configure a simple computer network between two computers:
|
||||
router1 and router2.
|
||||
|
||||
.. _security:
|
||||
|
||||
5.1 Setting up the security
|
||||
---------------------------
|
||||
|
||||
Configuring security in an NDN network requires to generate, exchange
|
||||
and install, keys and certificates between the root, site, operator and
|
||||
router computers that form the network
|
||||
[NLSRsecconf]_, [NLSRdevguide]_, although in practice, it
|
||||
is possible to keep more than one of these entities in a single machine.
|
||||
The following example and *Figure 1* show how to configure security
|
||||
for a single router, called Router X. In this example, the root, site,
|
||||
operator and Router X are in different computers:
|
||||
|
||||
.. figure:: security_comp.png
|
||||
:alt: Security configuration example for Router X.
|
||||
:width: 19cm
|
||||
:align: center
|
||||
|
||||
Fig. 1. Security configuration example for Router X.
|
||||
|
||||
|
||||
#. At the root server, generate the root key:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-key-gen /ndn/ > root.key
|
||||
|
||||
#. Generate the certificate for the root key at the root server:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-dump -i /ndn/ > root.cert
|
||||
|
||||
#. Install the root certificate at the root server:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-install -f root.cert
|
||||
|
||||
#. At the site server, generate the site key:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-key-gen /ndn/edu/uaslp > site.key
|
||||
|
||||
#. Copy the site key to the root server and generate the certificate for
|
||||
the site server:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-gen -s /ndn/ site.key > site.cert
|
||||
|
||||
#. Copy the site certificate to the site server and install it:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-install -f site.cert
|
||||
|
||||
#. At the operator server, generate the operator key:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-key-gen /ndn/edu/uaslp/%C1.Operator/op > op.key
|
||||
|
||||
#. Copy the operator key to the site server and generate the certificate
|
||||
for the operator server:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-gen -s /ndn/edu/uaslp op.key > op.cert
|
||||
|
||||
#. Copy the operator certificate to the operator server and install it:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-install -f op.cert
|
||||
|
||||
#. At the router, generate the router key:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-key-gen /ndn/edu/uaslp/%C1.Router/routerX > routerX.key
|
||||
|
||||
#. Copy the router key to the operator server and generate the
|
||||
certificate for the router:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-gen -s /ndn/edu/uaslp/%C1.Operator/op routerX.key >
|
||||
routerX.cert
|
||||
|
||||
#. Copy the router certificate to the router and install it:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-cert-install -f routerX.cert
|
||||
|
||||
In the previous steps, the *%C1.Router* and *%C1.Operator* labels are
|
||||
NDN keywords and should not be changed. These labels will be also used
|
||||
by the configuration file (§ `5.4 <#configfile>`__)
|
||||
|
||||
The following command may be used to verify that the certificates have
|
||||
been installed in a computer:
|
||||
|
||||
::
|
||||
|
||||
$ ndnsec-list
|
||||
|
||||
This guide recommends that one machine functions as the root, site,
|
||||
operator and router1, while a different computer only functions as
|
||||
router2. *Figure 2* shows this
|
||||
configuration. For router1, the twelve steps described before need to be
|
||||
executed except for exchanging files between computers. For the router2,
|
||||
only steps 10 to 12 are needed to generate this router’s certificate.
|
||||
|
||||
Additionally, the following command may be used to print a list and a
|
||||
brief description of all the *ndnsec* commands:
|
||||
|
||||
::
|
||||
|
||||
$ man ndnsec
|
||||
|
||||
|
||||
.. figure:: netwk1.png
|
||||
:alt: Example network.
|
||||
:width: 19cm
|
||||
:align: center
|
||||
|
||||
Fig. 2. Example network.
|
||||
|
||||
|
||||
5.2 Configuring the network
|
||||
---------------------------
|
||||
|
||||
The first step is to configure the physical network. If two computers
|
||||
are going to get connected using a single Ethernet cable, it is
|
||||
necessary to verify that this cable is a crossover. The other option is
|
||||
to employ a switch between two computers that are then connected using
|
||||
two regular Ethernet cables.
|
||||
|
||||
After the physical network has been assembled, it is necessary to
|
||||
configure the network addresses and cards for all the computers in the
|
||||
network. It is important to remember that computers that are connected
|
||||
to each other should use the same subnetwork address. It is possible to
|
||||
verify the network configuration in a Linux computer by means of the *ip
|
||||
addr* command
|
||||
|
||||
Once the physical network and network cards have been configured, it is
|
||||
necessary to verify that the computers can communicate with each other.
|
||||
The simplest way to do this is by using the *ping* command:
|
||||
|
||||
::
|
||||
|
||||
$ ping <remote-ip-address>
|
||||
|
||||
5.3 Starting and configuring NFD
|
||||
--------------------------------
|
||||
|
||||
To start and configure NFD it is necessary to open two terminal windows.
|
||||
The first one will be used to start NFD by means of the *nfd-start*
|
||||
command. This terminal will also display the logs that NFD generates. By
|
||||
default, NFD only generates informational logs (INFO). However, it is
|
||||
possible to obtain different levels of verbosity for these logs. These
|
||||
levels can be set before NFD starts by editing the
|
||||
*/usr/local/etc/ndn/nfd.conf* file. Open this file using a regular text
|
||||
editor, read the information provided about logging and then modify the
|
||||
*default-level* variable at the *log* section according to the
|
||||
instructions provided in the file. Additional information about NFD
|
||||
configuration may be found at [NDNNFDusage]_.
|
||||
|
||||
The second terminal will be used to monitor the NFD status:
|
||||
|
||||
::
|
||||
|
||||
$ nfd-status
|
||||
|
||||
Employ the following command to configure each face that a computer uses
|
||||
to connect to a neighboring computer:
|
||||
|
||||
::
|
||||
|
||||
$ nfdc face create udp4://<remote-ip-address>
|
||||
|
||||
The face id may be displayed by running either *nfd-status* or:
|
||||
|
||||
::
|
||||
|
||||
$ nfdc face list
|
||||
|
||||
The status of the face may be verified by using the following command:
|
||||
|
||||
::
|
||||
|
||||
$ nfdc face show id <face-id>
|
||||
|
||||
After finishing NLSR testing, it is necessary to destroy the face before
|
||||
stopping NFD. This operation is described at § `5.6 <#turn_off>`__. For
|
||||
the two computer network provided as an example (*Figure 2*), it is necessary that both
|
||||
machines run NFD and that each one configures a face that connects to
|
||||
the other machine.
|
||||
|
||||
.. _configfile:
|
||||
|
||||
5.4 Setting up the configuration file
|
||||
-------------------------------------
|
||||
|
||||
Instructions on how to use the configuration file are already provided
|
||||
at the NLSR’s Router Configuration page [NLSRrtrconf]_.
|
||||
Read the information in this page to understand NLSR router
|
||||
configuration. The following text describes the instructions that have
|
||||
been modified at the default nlsr.conf file for router1:
|
||||
|
||||
::
|
||||
|
||||
; AT general SECTION:
|
||||
{
|
||||
network /ndn/ ; name of the network
|
||||
site /edu/uaslp ; name of the site
|
||||
router /%C1.Router/router1 ; name of the router: router1
|
||||
}
|
||||
|
||||
;AT neighbors SECTION:
|
||||
neighbors
|
||||
{
|
||||
neighbor
|
||||
{
|
||||
name /ndn/edu/uaslp/%C1.Router/router2 ; Neighbor router: router2
|
||||
face-uri udp://140.220.80.124 ; face to the neighbor
|
||||
link-cost 30 ; cost of the link
|
||||
}
|
||||
}
|
||||
|
||||
; AT advertising SECTION:
|
||||
advertising
|
||||
{
|
||||
prefix /ndn/edu/uaslp/office/bldg1 ; Advertising destinations
|
||||
prefix /ndn/edu/uaslp/office/bldg2 ; for router1
|
||||
}
|
||||
|
||||
; AT security SECTION:
|
||||
security
|
||||
{
|
||||
validator
|
||||
{
|
||||
...
|
||||
trust-anchor
|
||||
{
|
||||
type file
|
||||
file-name "root.cert" ; root certificate file
|
||||
}
|
||||
}
|
||||
|
||||
prefix-update-validator
|
||||
{
|
||||
...
|
||||
trust-anchor
|
||||
{
|
||||
type file
|
||||
file-name "site.cert" ; site certificate file
|
||||
}
|
||||
}
|
||||
|
||||
cert-to-publish "root.cert" ; root certificate file
|
||||
|
||||
cert-to-publish "site.cert" ; site certificate file
|
||||
|
||||
cert-to-publish "op.cert" ; operator certificate file
|
||||
|
||||
cert-to-publish "router1.cert" ; router1 certificate file
|
||||
}
|
||||
|
||||
The following text shows the modified instructions for router2:
|
||||
|
||||
::
|
||||
|
||||
; AT general SECTION:
|
||||
{
|
||||
network /ndn/ ; name of the network
|
||||
site /edu/uaslp ; name of the site
|
||||
router /%C1.Router/router2 ; name of the router: router2
|
||||
}
|
||||
|
||||
;AT neighbors SECTION:
|
||||
neighbors
|
||||
{
|
||||
neighbor
|
||||
{
|
||||
name /ndn/edu/uaslp/%C1.Router/router1 ; Neighbor router: router1
|
||||
face-uri udp://140.220.80.121 ; face to the neighbor
|
||||
link-cost 30 ; cost of the link
|
||||
}
|
||||
}
|
||||
|
||||
; AT advertising SECTION:
|
||||
advertising
|
||||
{
|
||||
prefix /ndn/edu/uaslp/labs/networks ; Advertising destinations
|
||||
prefix /ndn/edu/uaslp/labs/hardware ; for router2
|
||||
}
|
||||
|
||||
; AT security SECTION:
|
||||
security
|
||||
{
|
||||
validator
|
||||
{
|
||||
...
|
||||
trust-anchor
|
||||
{
|
||||
type file
|
||||
file-name "root.cert" ; root certificate file
|
||||
} ; this file needs to be copied to
|
||||
} ; router2
|
||||
|
||||
prefix-update-validator
|
||||
{
|
||||
...
|
||||
trust-anchor
|
||||
{
|
||||
type file
|
||||
file-name "site.cert" ; site certificate file
|
||||
} ; this file needs to be copied to
|
||||
} ; router2
|
||||
|
||||
...
|
||||
cert-to-publish "router2.cert" ; router2 certificate file
|
||||
}
|
||||
|
||||
Notice that files *root.cert* and *site.cert*, which were generated at
|
||||
router1, need to be copied to router2. Also notice that the *%C1.Router*
|
||||
and *%C1.Operator* keywords employed at § `5.1 <#security>`__ are also
|
||||
referenced by these configuration files.
|
||||
|
||||
.. _starting_nlsr:
|
||||
|
||||
5.5 Starting NLSR
|
||||
-----------------
|
||||
|
||||
It is recommended to open a third command terminal and run NLSR in this
|
||||
window. After the NLSR configuration file has been edited and saved as
|
||||
*nlsr.conf*, it is possible to start NLSR by running either of the
|
||||
following two commands:
|
||||
|
||||
::
|
||||
|
||||
$ nlsr
|
||||
$ nlsr -f <configuration-file>
|
||||
|
||||
However, to verify what is NLSR doing, it becomes necessary to employ
|
||||
NLSR’s logging facility [NLSRstarting]_. A brief
|
||||
description on how to use NDN’s logging facility may be displayed by
|
||||
entering the *man ndn-log* command. This guide recommends using one of
|
||||
the following two instructions to start NLSR:
|
||||
|
||||
::
|
||||
|
||||
$ export NDN_LOG=nlsr.*=TRACE && nlsr
|
||||
$ export NDN_LOG=nlsr.*=TRACE && nlsr -f <configuration-file>
|
||||
|
||||
The second terminal window may be used to run *nfd-status* again and it
|
||||
should be possible to verify that the status has changed, specially at
|
||||
the FIB and RIB sections of the generated report.
|
||||
|
||||
.. _turn_off:
|
||||
|
||||
5.6 Turning everything off
|
||||
--------------------------
|
||||
|
||||
In order to stop NLSR and NFD, the following sequence of events is
|
||||
recommended:
|
||||
|
||||
#. Stop NLSR by pressing the Ctrl+C keys at the third terminal window.
|
||||
|
||||
#. Destroy the face to the remote computers using either of the
|
||||
following two commands at the second terminal window:
|
||||
|
||||
::
|
||||
|
||||
$ nfdc face destroy <face-id>
|
||||
$ nfdc face destroy udp4://<remote-ip-address>
|
||||
|
||||
#. Stop NFD by entering the following command at the second terminal
|
||||
window:
|
||||
|
||||
::
|
||||
|
||||
$ nfd-stop
|
||||
|
||||
#. The crossover Ethernet cable may be unplugged and the computers’
|
||||
network configuration restored to its original settings.
|
||||
|
||||
5.7 Where to go from here
|
||||
-------------------------
|
||||
|
||||
Users interested in building and configuring larger networks may want to
|
||||
take a look at the NDN Ansible repository
|
||||
[NDNAnsible]_. This repository uses Ansible, which is a
|
||||
configuration management tool, to manage the official NDN testbed
|
||||
deployment [NDNTestbed]_.
|
||||
|
||||
|
||||
.. [NDNmain] *Named Data Networking*, http://named-data.net/, March 2018.
|
||||
|
||||
.. [Kolman2018] M. Kolman. *Anaconda improvements in Fedora 28*, Fedora Magazine, June 2018.
|
||||
|
||||
.. [NDN-cxx] *Getting started with ndn-cxx*, http://named-data.net/doc/ndn-cxx/current/INSTALL.html, April 2018.
|
||||
|
||||
.. [NDNNFD] *Getting started with NFD*, http://named-data.net/doc/NFD/current/INSTALL.html, April 2018.
|
||||
|
||||
.. [NDNNFDusage] *NFD usage*, http://named-data.net/doc/NFD/current/manpages/nfd.html, May 2018.
|
||||
|
||||
.. [Chronosync] Z. Zhu and A. Afanasyev. *Let’s ChronoSync: Decentralized dataset state synchronization in Named Data Networking*, in IEEE ICNP, October 2013.
|
||||
|
||||
.. [PSync] M. Zhang, V. Lehman, and L. Wang. *Scalable Name-based Data Synchronization for Named Data Networking*, in IEEE INFOCOM, May 2017.
|
||||
|
||||
.. [NLSRsecconf] *NLSR Security Configuration*, http://named-data.net/doc/NLSR/current/SECURITY-CONFIG.html June 2018.
|
||||
|
||||
.. [NLSRdevguide] V. Lehman, M. Chowdhury, N. Gordon, A. Gawande. *NLSR Developer’s Guide*, University of Memphis, November 2017.
|
||||
|
||||
.. [NLSRrtrconf] *NLSR Router Configuration*, http://named-data.net/doc/NLSR/current/ROUTER-CONFIG.html, April 2018.
|
||||
|
||||
.. [NLSRstarting] *Getting Started with NLSR*, http://named-data.net/doc/NLSR/current/GETTING-STARTED.html, May 2018.
|
||||
|
||||
.. [NDNAnsible] *NDN Ansible repository*, https://github.com/WU-ARL/NDN_Ansible, October 2018.
|
||||
|
||||
.. [NDNTestbed] *NDN Testbed*, https://named-data.net/ndn-testbed/, October 2018.
|
||||
+3
-2
@@ -44,8 +44,9 @@ def addExtensionIfExists(extension):
|
||||
sys.stderr.write("To install, use \n"
|
||||
" sudo pip install %s\n" % extension.replace('.', '-'))
|
||||
|
||||
if os.getenv('GOOGLE_ANALYTICS', None):
|
||||
addExtensionIfExists('sphinxcontrib.googleanalytics')
|
||||
# sphinxcontrib.googleanalytics is currently not working with the latest version of sphinx
|
||||
# if os.getenv('GOOGLE_ANALYTICS', None):
|
||||
# addExtensionIfExists('sphinxcontrib.googleanalytics')
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
+4
-2
@@ -31,19 +31,21 @@ NLSR Documentation
|
||||
|
||||
GETTING-STARTED
|
||||
INSTALL
|
||||
ROUTER-CONFIG
|
||||
SECURITY-CONFIG
|
||||
ROUTER-CONFIG
|
||||
RELEASE-NOTES
|
||||
releases
|
||||
manpages
|
||||
beginners-guide
|
||||
|
||||
- :doc:`GETTING-STARTED`
|
||||
- :doc:`INSTALL`
|
||||
- :doc:`ROUTER-CONFIG`
|
||||
- :doc:`SECURITY-CONFIG`
|
||||
- :doc:`ROUTER-CONFIG`
|
||||
- :doc:`RELEASE-NOTES`
|
||||
- :doc:`releases`
|
||||
- :doc:`manpages`
|
||||
- :doc:`beginners-guide`
|
||||
|
||||
Downloading
|
||||
-----------
|
||||
|
||||
@@ -43,6 +43,11 @@ Options
|
||||
``name``
|
||||
The Name prefix to be advertised
|
||||
|
||||
``advertise <name> save``
|
||||
|
||||
``save``
|
||||
Advertise a prefix and also save it to the nlsr.conf file residing in the state-dir for the next start of NLSR that operator may copy and use for the next start of NLSR
|
||||
|
||||
``withdraw``
|
||||
Remove a Name prefix advertised through NLSR
|
||||
|
||||
@@ -51,6 +56,11 @@ Options
|
||||
``name``
|
||||
The Name prefix to be withdrawn
|
||||
|
||||
``withdraw <name> delete``
|
||||
|
||||
``delete``
|
||||
Withdraw a prefix and also delete it from the nlsr.conf file residing in the state-dir
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div id="logo">
|
||||
<a href="http://named-data.net" title="A Future Internet Architecture"><img src="http://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
|
||||
<a href="https://named-data.net" title="A Future Internet Architecture"><img src="https://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
|
||||
</div><!--logo end-->
|
||||
</div>
|
||||
|
||||
@@ -38,12 +38,14 @@
|
||||
<h3>{{ _('Table Of Contents') }}</h3>
|
||||
{{ toctree(includehidden=True) }}
|
||||
|
||||
<h3>{{ _('Additional documenation') }}</h3>
|
||||
<h3>{{ _('Developer documentation') }}</h3>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference external" href="http://redmine.named-data.net/projects/nlsr/wiki">NLSR Wiki</a></li>
|
||||
<li class="toctree-l1"><a class="reference external" href="https://redmine.named-data.net/projects/nlsr/wiki">NLSR Wiki</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="doxygen/annotated.html">API documentation (doxygen)</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="code-style.html">ndn-cxx Code Style and Coding Guidelines</a></li>
|
||||
</ul>
|
||||
{%- endblock %}
|
||||
|
||||
{%- block sidebarsearch %}
|
||||
<h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3>
|
||||
<form class="search" action="{{ pathto('search') }}" method="get">
|
||||
@@ -74,22 +76,11 @@
|
||||
<div class="row">
|
||||
<div class="twelve columns">
|
||||
|
||||
<div id="copyright">This research is partially supported by NSF (Award <a href="http://www.nsf.gov/awardsearch/showAward?AWD_ID=1040868" target="_blank>">CNS-1040868</a>)<br/><br/><a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US" target="_blank">Creative Commons Attribution 3.0 Unported License</a> except where noted.</div>
|
||||
<div id="copyright">This research is partially supported by NSF (Award <a href="https://www.nsf.gov/awardsearch/showAward?AWD_ID=1040868" target="_blank>">CNS-1040868</a>)<br/><br/><a rel="license" href="https://creativecommons.org/licenses/by/3.0/deed.en_US" target="_blank">Creative Commons Attribution 3.0 Unported License</a> except where noted.</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div><!--footer info end-->
|
||||
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-22320603-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block relbar1 %}{% endblock %}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<!-- start footer part -->
|
||||
<!--BEGIN GENERATE_TREEVIEW-->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
$navpath
|
||||
<li class="footer">$generatedby
|
||||
<a href="https://www.doxygen.org/index.html">
|
||||
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--END GENERATE_TREEVIEW-->
|
||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||
<hr class="footer"/>
|
||||
<address class="footer"><small>
|
||||
$generatedby  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/>
|
||||
</a> $doxygenversion
|
||||
</small></address>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '@GOOGLE_ANALYTICS@', 'auto');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -4,7 +4,7 @@
|
||||
<ul>
|
||||
$navpath
|
||||
<li class="footer">$generatedby
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<a href="https://www.doxygen.org/index.html">
|
||||
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -18,5 +18,7 @@ $generatedby  <a href="http://www.doxygen.org/index.html">
|
||||
</small></address>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="https://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
@@ -26,13 +26,13 @@ $mathjax
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div id="logo">
|
||||
<a href="http://named-data.net" title="A Future Internet Architecture"><img src="http://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
|
||||
<a href="https://named-data.net" title="A Future Internet Architecture"><img src="https://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
|
||||
</div><!--logo end-->
|
||||
</div>
|
||||
|
||||
<!--top menu-->
|
||||
<div class="nine columns" id="menu_container" >
|
||||
<h1><a href="http://named-data.net/doc/NLSR/$projectnumber/">$projectname $projectnumber documentation</a></h1>
|
||||
<h1><a href="https://named-data.net/doc/NLSR/$projectnumber/">$projectname $projectnumber documentation</a></h1>
|
||||
</div>
|
||||
</div>
|
||||
</div><!--header container end-->
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -1 +1 @@
|
||||
release-notes/release-notes-0.4.2.rst
|
||||
release-notes/release-notes-0.5.2.rst
|
||||
@@ -4,7 +4,7 @@ NLSR version 0.1.0 (initial release)
|
||||
Release date: August 25, 2014
|
||||
|
||||
The main design goal of NLSR is to provide a routing protocol to populate `NFD's
|
||||
<http://named-data.net/doc/NFD/current/>`_ RIB. NLSR calculates the routing table using
|
||||
<https://named-data.net/doc/NFD/>`_ RIB. NLSR calculates the routing table using
|
||||
link-state or hyperbolic routing and produces multiple faces for each reachable name
|
||||
prefix in a single authoritative domain.
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
NLSR version 0.4.3
|
||||
++++++++++++++++++
|
||||
|
||||
**Changes**:
|
||||
|
||||
- **breaking change** Change NLSR to nlsr for various prefixes (:issue:`4543`)
|
||||
|
||||
**Bug Fixes**:
|
||||
|
||||
- Fix dry-run mode not working (:issue:`4394`)
|
||||
- Fix convergence w/o content store (:issue:`4430`)
|
||||
- Register router prefix to fix remote requests (:issue:`4543`)
|
||||
- Fix build with clang-5.0 (:issue:`4547`)
|
||||
- Avoid misaligned memory access (:issue:`4609`)
|
||||
@@ -0,0 +1,35 @@
|
||||
NLSR version 0.5.0
|
||||
++++++++++++++++++
|
||||
|
||||
**New Features**
|
||||
|
||||
- Set CanBePrefix to false on Hello Interest (:issue:`4581`)
|
||||
- Optionally write prefixes to a copy of config file via nlsrc advertise (:issue:`4303`)
|
||||
- Use SegmentPublisher utility from PSync to publish LSA data (:issue:`4760`)
|
||||
- Add PSync as a dependency and switch it as default in conf file. (:issue:`4082`)
|
||||
|
||||
**Changes**
|
||||
|
||||
- Decouple classes from Nlsr object for easier unit testing (:issue:`1952`)
|
||||
- Set sequence number file in SequencingManager constructor. (:issue:`4288`)
|
||||
- Read conf file in test prefix update processor instead of static string (:issue:`3960`)
|
||||
- Canonize FaceUri in conf file processor (:issue:`4817`)
|
||||
- Remove redundant function "calculateHypDryRoutingTable" (:issue:`4811`)
|
||||
- In dry run mode, print HR and LS routing table in nlsrc separately (:issue:`4452`)
|
||||
- Fix ASan memory leaks in unit tests (:issue:`4682`)
|
||||
- Systemd service files dependency corrections for Ubuntu 18.04 (:issue:`4594`)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Fix processing of interest w/ segments for segmented LSA data (:issue:`4784`)
|
||||
- Fib: don't refresh neighbor router's FIB entry (:issue:`4799`)
|
||||
- Disable Interest filter loopback where ever not needed (:issue:`4768`)
|
||||
- Avoid crash when ndn-cxx is compiled with tests by setting canBePrefix (:issue:`4691`)
|
||||
- Make sure NLSR is not using any deprecated API (:issue:`4679`)
|
||||
- Fix crash in equals operator of adjacency-list (:issue:`4705`)
|
||||
- Fix error handling and normalize exit codes
|
||||
|
||||
**Miscellaneous**
|
||||
|
||||
- Improving documentation for NLSR
|
||||
- A beginners' guide to installing and testing on Fedora
|
||||
@@ -0,0 +1,15 @@
|
||||
NLSR version 0.5.1
|
||||
++++++++++++++++++
|
||||
|
||||
**Changes**
|
||||
|
||||
- Set best-route strategy for certificate prefixes (:issue:`4881`)
|
||||
- Use ndn-cxx InMemoryStorage for LsaSegmentStorage (:issue:`4788`)
|
||||
- Switch from ndn::EventId to ndn::scheduler::EventId (:issue:`4883`)
|
||||
- Add FreshnessPeriod where MustBeFresh is used (:issue:`4913`)
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
- Fix canonization by resetting io service after each neighbor (:issue:`4872`)
|
||||
- Disable network interest in while fetching NLSR certificate (:issue:`4879`)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
NLSR version 0.5.2
|
||||
++++++++++++++++++
|
||||
|
||||
**Breaking Changes**
|
||||
|
||||
The following breaking changes makes this release incompatible with the previous version.
|
||||
- Use latest PSync version 0.2.0, sync data compression enabled in full sync by default (:issue:`5061`, :issue:`4917`)
|
||||
- Use the double encoding/decoding functions for hyperbolic coordinates (:issue:`4615`)
|
||||
|
||||
**New Features**
|
||||
|
||||
- Handle zero cost links in Link State Routing (:issue:`4978`)
|
||||
|
||||
**Improvements and Bug Fixes**:
|
||||
|
||||
- Remove support for old combined seq no file (:issue:`4143`)
|
||||
- Sync common test infrastructure with ndn-cxx
|
||||
- Refactor Certificate Storage class (:issue:`5075`)
|
||||
- Avoid crashing NLSR if identity cannot be created
|
||||
- Change init order to register sync routes after hello data has been verified (:issue:`5009`)
|
||||
- Fix empty file creation if conf file is same as dynamic (:issue:`5071`)
|
||||
- On face event notification, only proceed if face id was zero or updated (:issue:`4394`)
|
||||
@@ -5,6 +5,10 @@ NLSR Versions
|
||||
:hidden:
|
||||
:maxdepth: 1
|
||||
|
||||
release-notes/release-notes-0.5.2
|
||||
release-notes/release-notes-0.5.1
|
||||
release-notes/release-notes-0.5.0
|
||||
release-notes/release-notes-0.4.3
|
||||
release-notes/release-notes-0.4.2
|
||||
release-notes/release-notes-0.4.1
|
||||
release-notes/release-notes-0.4.0
|
||||
@@ -16,6 +20,37 @@ NLSR Versions
|
||||
release-notes/release-notes-0.2.0
|
||||
release-notes/release-notes-0.1.0
|
||||
|
||||
|
||||
* **NLSR version 0.5.2**
|
||||
(:doc:`Release Notes <release-notes/release-notes-0.5.2>`, `Documentation <https://named-data.net/doc/NLSR/0.5.2/>`__)
|
||||
|
||||
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.5.2>`__,
|
||||
`src (tarball) <https://named-data.net/downloads/nlsr-0.5.2.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.5.2.tar.bz2.sha256>`__)
|
||||
|
||||
* **NLSR version 0.5.1**
|
||||
(:doc:`Release Notes <release-notes/release-notes-0.5.1>`, `Documentation <https://named-data.net/doc/NLSR/0.5.1/>`__)
|
||||
|
||||
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.5.1>`__,
|
||||
`src (tarball) <https://named-data.net/downloads/nlsr-0.5.1.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.5.1.tar.bz2.sha256>`__)
|
||||
|
||||
* **NLSR version 0.5.0**
|
||||
(:doc:`Release Notes <release-notes/release-notes-0.5.0>`, `Documentation <https://named-data.net/doc/NLSR/0.5.0/>`__)
|
||||
|
||||
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.5.0>`__,
|
||||
`src (tarball) <https://named-data.net/downloads/nlsr-0.5.0.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.5.0.tar.bz2.sha256>`__)
|
||||
|
||||
* **NLSR version 0.4.3**
|
||||
(:doc:`Release Notes <release-notes/release-notes-0.4.3>`, `Documentation <https://named-data.net/doc/NLSR/0.4.3/>`__)
|
||||
|
||||
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.4.3>`__,
|
||||
`src (tarball) <https://named-data.net/downloads/nlsr-0.4.3.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.4.3.tar.bz2.sha256>`__)
|
||||
|
||||
* **NLSR version 0.4.2**
|
||||
(:doc:`Release Notes <release-notes/release-notes-0.4.2>`, `Documentation <https://named-data.net/doc/NLSR/0.4.2/>`__)
|
||||
|
||||
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.4.2>`__,
|
||||
`src (tarball) <https://named-data.net/downloads/nlsr-0.4.2.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.4.2.tar.bz2.sha256>`__)
|
||||
|
||||
* **NLSR version 0.4.1**
|
||||
(:doc:`Release Notes <release-notes/release-notes-0.4.1>`, `Documentation <https://named-data.net/doc/NLSR/0.4.1/>`__)
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@@ -19,10 +19,13 @@ general
|
||||
; InterestLifetime (in seconds) for LSA fetching
|
||||
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
|
||||
|
||||
; sync interest lifetime of ChronoSync in milliseconds
|
||||
; select sync protocol: chronosync or psync
|
||||
sync-protocol psync
|
||||
|
||||
; sync interest lifetime of ChronoSync/PSync in milliseconds
|
||||
sync-interest-lifetime 60000 ; default value 60000. Valid values 1000-120,000
|
||||
|
||||
seq-dir /var/lib/nlsr ; path for sequence directory (Absolute path)
|
||||
state-dir /var/lib/nlsr ; path for intermediate state files including sequence directory (Absolute path)
|
||||
}
|
||||
|
||||
; the neighbor's section contains the configuration for router's neighbors and hellos behavior
|
||||
@@ -35,7 +38,7 @@ neighbors
|
||||
hello-retries 3 ; interest retries number in integer. Default value 3
|
||||
; valid values 1-10
|
||||
|
||||
hello-timeout 1 ; interest time out value in integer. Default value 1
|
||||
hello-timeout 1 ; interest time out value in seconds. Default value 1
|
||||
; Valid values 1-15
|
||||
|
||||
hello-interval 60 ; interest sending interval in seconds. Default value 60
|
||||
@@ -44,12 +47,7 @@ neighbors
|
||||
; 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
|
||||
adj-lsa-build-interval 10 ; default value 10. Valid values 5-30.
|
||||
|
||||
face-dataset-fetch-tries 3 ; default is 3. Valid values 1-10. The FaceDataset is
|
||||
; gotten from NFD, and is needed to configure NLSR
|
||||
@@ -141,7 +139,7 @@ security
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^[^<NLSR><INFO>]*<NLSR><INFO><><>$
|
||||
regex ^[^<nlsr><INFO>]*<nlsr><INFO><><>$
|
||||
}
|
||||
checker
|
||||
{
|
||||
@@ -152,10 +150,10 @@ security
|
||||
type name
|
||||
hyper-relation
|
||||
{
|
||||
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><>$
|
||||
k-regex ^([^<KEY><nlsr>]*)<nlsr><KEY><>$
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
p-regex ^([^<NLSR><INFO>]*)<NLSR><INFO><><>$
|
||||
p-regex ^([^<nlsr><INFO>]*)<nlsr><INFO><><>$
|
||||
p-expand \\1
|
||||
}
|
||||
}
|
||||
@@ -169,7 +167,7 @@ security
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^[^<NLSR><LSA>]*<NLSR><LSA>
|
||||
regex ^[^<nlsr><LSA>]*<nlsr><LSA>
|
||||
}
|
||||
checker
|
||||
{
|
||||
@@ -180,11 +178,11 @@ security
|
||||
type name
|
||||
hyper-relation
|
||||
{
|
||||
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><>$
|
||||
k-regex ^([^<KEY><nlsr>]*)<nlsr><KEY><>$
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
|
||||
p-regex ^<localhop>([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
|
||||
p-regex ^<localhop>([^<nlsr><LSA>]*)<nlsr><LSA>(<>*)<><><><>$
|
||||
p-expand \\1\\2
|
||||
}
|
||||
}
|
||||
@@ -198,7 +196,7 @@ security
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><NLSR>]*<KEY><><><>$
|
||||
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><nlsr>]*<KEY><><><>$
|
||||
}
|
||||
checker
|
||||
{
|
||||
|
||||
+17
-26
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -73,14 +73,15 @@ AdjacencyList::getAdjacent(const ndn::Name& adjName)
|
||||
bool
|
||||
AdjacencyList::operator==(const AdjacencyList& adl) const
|
||||
{
|
||||
if (m_adjList.size() != adl.getAdjList().size()) {
|
||||
auto theirList = adl.getAdjList();
|
||||
if (m_adjList.size() != theirList.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::set<Adjacent> ourList(m_adjList.cbegin(), m_adjList.cend());
|
||||
std::set<Adjacent> theirList(adl.getAdjList().cbegin(), adl.getAdjList().cend());
|
||||
std::set<Adjacent> ourSet(m_adjList.cbegin(), m_adjList.cend());
|
||||
std::set<Adjacent> theirSet(theirList.cbegin(), theirList.cend());
|
||||
|
||||
return ourList == theirList;
|
||||
return ourSet == theirSet;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -185,9 +186,8 @@ int32_t
|
||||
AdjacencyList::getNumOfActiveNeighbor() const
|
||||
{
|
||||
int32_t actNbrCount = 0;
|
||||
for (std::list<Adjacent>::const_iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
|
||||
|
||||
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
for (const auto& adjacent: m_adjList) {
|
||||
if (adjacent.getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
actNbrCount++;
|
||||
}
|
||||
}
|
||||
@@ -197,24 +197,19 @@ AdjacencyList::getNumOfActiveNeighbor() const
|
||||
std::list<Adjacent>::iterator
|
||||
AdjacencyList::find(const ndn::Name& adjName)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
std::bind(&Adjacent::compare,
|
||||
_1, std::cref(adjName)));
|
||||
return it;
|
||||
return std::find_if(m_adjList.begin(),
|
||||
m_adjList.end(),
|
||||
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||
}
|
||||
|
||||
std::list<Adjacent>::const_iterator
|
||||
AdjacencyList::find(const ndn::Name& adjName) const
|
||||
{
|
||||
std::list<Adjacent>::const_iterator it = std::find_if(m_adjList.cbegin(),
|
||||
m_adjList.cend(),
|
||||
std::bind(&Adjacent::compare,
|
||||
_1, std::cref(adjName)));
|
||||
return it;
|
||||
return std::find_if(m_adjList.cbegin(),
|
||||
m_adjList.cend(),
|
||||
std::bind(&Adjacent::compare, _1, std::cref(adjName)));
|
||||
}
|
||||
|
||||
|
||||
AdjacencyList::iterator
|
||||
AdjacencyList::findAdjacent(const ndn::Name& adjName)
|
||||
{
|
||||
@@ -249,20 +244,16 @@ AdjacencyList::getFaceId(const ndn::FaceUri& faceUri)
|
||||
m_adjList.end(),
|
||||
std::bind(&Adjacent::compareFaceUri,
|
||||
_1, faceUri));
|
||||
if (it != m_adjList.end()) {
|
||||
return it->getFaceId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
return it != m_adjList.end() ? it->getFaceId() : 0;
|
||||
}
|
||||
|
||||
void
|
||||
AdjacencyList::writeLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG("-------Adjacency List--------");
|
||||
for (std::list<Adjacent>::iterator it = m_adjList.begin();
|
||||
it != m_adjList.end(); it++) {
|
||||
(*it).writeLog();
|
||||
for (const auto& adjacent : m_adjList) {
|
||||
NLSR_LOG_DEBUG(adjacent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-12
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -30,7 +30,8 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(Adjacent);
|
||||
|
||||
const float Adjacent::DEFAULT_LINK_COST = 10.0;
|
||||
const double Adjacent::DEFAULT_LINK_COST = 10.0;
|
||||
const double Adjacent::NON_ADJACENT_COST = -12345;
|
||||
|
||||
Adjacent::Adjacent()
|
||||
: m_name()
|
||||
@@ -52,17 +53,31 @@ Adjacent::Adjacent(const ndn::Name& an)
|
||||
{
|
||||
}
|
||||
|
||||
Adjacent::Adjacent(const ndn::Name& an, const ndn::FaceUri& faceUri, double lc,
|
||||
Adjacent::Adjacent(const ndn::Name& an, const ndn::FaceUri& faceUri, double lc,
|
||||
Status s, uint32_t iton, uint64_t faceId)
|
||||
: m_name(an)
|
||||
, m_faceUri(faceUri)
|
||||
, m_linkCost(lc)
|
||||
, m_status(s)
|
||||
, m_interestTimedOutNo(iton)
|
||||
, m_faceId(faceId)
|
||||
{
|
||||
this->setLinkCost(lc);
|
||||
}
|
||||
|
||||
void
|
||||
Adjacent::setLinkCost(double lc)
|
||||
{
|
||||
// NON_ADJACENT_COST is a negative value and is used for nodes that aren't direct neighbors.
|
||||
// But for direct/active neighbors, the cost cannot be negative.
|
||||
if (lc < 0 && lc != NON_ADJACENT_COST)
|
||||
{
|
||||
NLSR_LOG_ERROR(" Neighbor's link-cost cannot be negative");
|
||||
BOOST_THROW_EXCEPTION(ndn::tlv::Error("Neighbor's link-cost cannot be negative"));
|
||||
}
|
||||
|
||||
m_linkCost = lc;
|
||||
}
|
||||
|
||||
bool
|
||||
Adjacent::operator==(const Adjacent& adjacent) const
|
||||
{
|
||||
@@ -75,8 +90,9 @@ Adjacent::operator==(const Adjacent& adjacent) const
|
||||
bool
|
||||
Adjacent::operator<(const Adjacent& adjacent) const
|
||||
{
|
||||
return (m_name < adjacent.getName()) ||
|
||||
(m_linkCost < adjacent.getLinkCost());
|
||||
auto linkCost = adjacent.getLinkCost();
|
||||
return std::tie(m_name, m_linkCost) <
|
||||
std::tie(adjacent.getName(), linkCost);
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
@@ -88,10 +104,4 @@ operator<<(std::ostream& os, const Adjacent& adjacent)
|
||||
return os;
|
||||
}
|
||||
|
||||
void
|
||||
Adjacent::writeLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG(*this);
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
+6
-12
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -77,18 +77,14 @@ public:
|
||||
m_faceUri = faceUri;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
double
|
||||
getLinkCost() const
|
||||
{
|
||||
uint64_t linkCost = static_cast<uint64_t>(ceil(m_linkCost));
|
||||
return linkCost;
|
||||
return ceil(m_linkCost);
|
||||
}
|
||||
|
||||
void
|
||||
setLinkCost(double lc)
|
||||
{
|
||||
m_linkCost = lc;
|
||||
}
|
||||
setLinkCost(double lc);
|
||||
|
||||
Status
|
||||
getStatus() const
|
||||
@@ -157,11 +153,9 @@ public:
|
||||
return m_faceUri == faceUri;
|
||||
}
|
||||
|
||||
void
|
||||
writeLog();
|
||||
|
||||
public:
|
||||
static const float DEFAULT_LINK_COST;
|
||||
static const double DEFAULT_LINK_COST;
|
||||
static const double NON_ADJACENT_COST;
|
||||
|
||||
private:
|
||||
/*! m_name The NLSR-configured router name of the neighbor */
|
||||
|
||||
+1
-2
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -27,7 +27,6 @@
|
||||
#ifndef NLSR_COMMON_HPP
|
||||
#define NLSR_COMMON_HPP
|
||||
|
||||
#include <ndn-cxx/common.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -23,103 +23,67 @@
|
||||
#include "common.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(SyncLogicHandler);
|
||||
|
||||
const std::string NLSR_COMPONENT = "NLSR";
|
||||
const std::string NLSR_COMPONENT = "nlsr";
|
||||
const std::string LSA_COMPONENT = "LSA";
|
||||
|
||||
template<class T>
|
||||
class NullDeleter
|
||||
{
|
||||
public:
|
||||
void
|
||||
operator()(T*)
|
||||
{
|
||||
}
|
||||
};
|
||||
INIT_LOGGER(SyncLogicHandler);
|
||||
|
||||
SyncLogicHandler::SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew,
|
||||
const ConfParameter& conf)
|
||||
: onNewLsa(ndn::make_unique<OnNewLsa>())
|
||||
: onNewLsa(std::make_unique<OnNewLsa>())
|
||||
, m_syncFace(face)
|
||||
, m_isLsaNew(isLsaNew)
|
||||
, m_confParam(conf)
|
||||
, m_nameLsaUserPrefix(ndn::Name(m_confParam.getSyncUserPrefix()).append(std::to_string(Lsa::Type::NAME)))
|
||||
, m_syncLogic(m_syncFace, m_confParam.getSyncProtocol(), m_confParam.getSyncPrefix(),
|
||||
m_nameLsaUserPrefix, m_confParam.getSyncInterestLifetime(),
|
||||
std::bind(&SyncLogicHandler::processUpdate, this, _1, _2))
|
||||
{
|
||||
m_adjLsaUserPrefix = ndn::Name(m_confParam.getSyncUserPrefix())
|
||||
.append(std::to_string(Lsa::Type::ADJACENCY));
|
||||
m_coorLsaUserPrefix = ndn::Name(m_confParam.getSyncUserPrefix())
|
||||
.append(std::to_string(Lsa::Type::COORDINATE));
|
||||
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF ||
|
||||
m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
m_syncLogic.addUserNode(m_adjLsaUserPrefix);
|
||||
}
|
||||
else if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON ||
|
||||
m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
m_syncLogic.addUserNode(m_coorLsaUserPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix, const ndn::time::milliseconds& syncInterestLifetime)
|
||||
SyncLogicHandler::processUpdate(const ndn::Name& updateName, uint64_t highSeq)
|
||||
{
|
||||
if (m_syncSocket != nullptr) {
|
||||
NLSR_LOG_WARN("Trying to create Sync socket, but Sync socket already exists");
|
||||
NLSR_LOG_DEBUG("Update Name: " << updateName << " Seq no: " << highSeq);
|
||||
|
||||
int32_t nlsrPosition = util::getNameComponentPosition(updateName, nlsr::NLSR_COMPONENT);
|
||||
int32_t lsaPosition = util::getNameComponentPosition(updateName, nlsr::LSA_COMPONENT);
|
||||
|
||||
if (nlsrPosition < 0 || lsaPosition < 0) {
|
||||
NLSR_LOG_WARN("Received malformed sync update");
|
||||
return;
|
||||
}
|
||||
|
||||
m_syncPrefix = syncPrefix;
|
||||
ndn::Name networkName = updateName.getSubName(1, nlsrPosition-1);
|
||||
ndn::Name routerName = updateName.getSubName(lsaPosition + 1).getPrefix(-1);
|
||||
|
||||
// Build LSA sync update prefix
|
||||
buildUpdatePrefix();
|
||||
ndn::Name originRouter = networkName;
|
||||
originRouter.append(routerName);
|
||||
|
||||
NLSR_LOG_DEBUG("Creating Sync socket. Sync Prefix: " << m_syncPrefix);
|
||||
|
||||
// The face's lifetime is managed in main.cpp; SyncSocket should not manage the memory
|
||||
// of the object
|
||||
std::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
|
||||
|
||||
const auto fixedSession = ndn::name::Component::fromNumber(0);
|
||||
m_syncSocket = std::make_shared<chronosync::Socket>(m_syncPrefix, m_nameLsaUserPrefix, *facePtr,
|
||||
std::bind(&SyncLogicHandler::onChronoSyncUpdate, this, _1),
|
||||
chronosync::Socket::DEFAULT_NAME, chronosync::Socket::DEFAULT_VALIDATOR,
|
||||
syncInterestLifetime, fixedSession);
|
||||
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
m_syncSocket->addSyncNode(m_adjLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
}
|
||||
else if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_syncSocket->addSyncNode(m_coorLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
}
|
||||
else {
|
||||
m_syncSocket->addSyncNode(m_adjLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
m_syncSocket->addSyncNode(m_coorLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& v)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Received ChronoSync update event");
|
||||
|
||||
for (size_t i = 0; i < v.size(); i++){
|
||||
ndn::Name updateName = v[i].session.getPrefix(-1);
|
||||
|
||||
NLSR_LOG_DEBUG("Update Name: " << updateName << " Seq no: " << v[i].high);
|
||||
|
||||
int32_t nlsrPosition = util::getNameComponentPosition(updateName, nlsr::NLSR_COMPONENT);
|
||||
int32_t lsaPosition = util::getNameComponentPosition(updateName, nlsr::LSA_COMPONENT);
|
||||
|
||||
if (nlsrPosition < 0 || lsaPosition < 0) {
|
||||
NLSR_LOG_WARN("Received malformed sync update");
|
||||
return;
|
||||
}
|
||||
|
||||
ndn::Name networkName = updateName.getSubName(1, nlsrPosition-1);
|
||||
ndn::Name routerName = updateName.getSubName(lsaPosition + 1).getPrefix(-1);
|
||||
|
||||
ndn::Name originRouter = networkName;
|
||||
originRouter.append(routerName);
|
||||
|
||||
processUpdateFromSync(originRouter, updateName, v[i].high);
|
||||
}
|
||||
processUpdateFromSync(originRouter, updateName, highSeq);
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::processUpdateFromSync(const ndn::Name& originRouter,
|
||||
const ndn::Name& updateName, const uint64_t& seqNo)
|
||||
const ndn::Name& updateName, uint64_t seqNo)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Origin Router of update: " << originRouter);
|
||||
|
||||
@@ -129,24 +93,24 @@ SyncLogicHandler::processUpdateFromSync(const ndn::Name& originRouter,
|
||||
Lsa::Type lsaType;
|
||||
std::istringstream(updateName.get(updateName.size()-1).toUri()) >> lsaType;
|
||||
|
||||
NLSR_LOG_DEBUG("Received sync update with higher " << lsaType
|
||||
<< " sequence number than entry in LSDB");
|
||||
NLSR_LOG_DEBUG("Received sync update with higher " << lsaType <<
|
||||
" sequence number than entry in LSDB");
|
||||
|
||||
if (m_isLsaNew(originRouter, lsaType, seqNo)) {
|
||||
if (lsaType == Lsa::Type::ADJACENCY && seqNo != 0 &&
|
||||
m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
NLSR_LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing"
|
||||
<< " is enabled. Not going to fetch.");
|
||||
NLSR_LOG_ERROR("Got an update for adjacency LSA when hyperbolic routing " <<
|
||||
"is enabled. Not going to fetch.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lsaType == Lsa::Type::COORDINATE && seqNo != 0 &&
|
||||
m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
NLSR_LOG_ERROR("Got an update for coordinate LSA when link-state"
|
||||
<< " is enabled. Not going to fetch.");
|
||||
NLSR_LOG_ERROR("Got an update for coordinate LSA when link-state " <<
|
||||
"is enabled. Not going to fetch.");
|
||||
return;
|
||||
}
|
||||
(*onNewLsa)(updateName, seqNo);
|
||||
(*onNewLsa)(updateName, seqNo, originRouter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,54 +118,19 @@ SyncLogicHandler::processUpdateFromSync(const ndn::Name& originRouter,
|
||||
void
|
||||
SyncLogicHandler::publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo)
|
||||
{
|
||||
if (m_syncSocket == nullptr) {
|
||||
NLSR_LOG_FATAL("Cannot publish routing update; SyncSocket does not exist");
|
||||
|
||||
BOOST_THROW_EXCEPTION(SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist"));
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Lsa::Type::ADJACENCY:
|
||||
publishSyncUpdate(m_adjLsaUserPrefix, seqNo);
|
||||
m_syncLogic.publishUpdate(m_adjLsaUserPrefix, seqNo);
|
||||
break;
|
||||
case Lsa::Type::COORDINATE:
|
||||
publishSyncUpdate(m_coorLsaUserPrefix, seqNo);
|
||||
m_syncLogic.publishUpdate(m_coorLsaUserPrefix, seqNo);
|
||||
break;
|
||||
case Lsa::Type::NAME:
|
||||
publishSyncUpdate(m_nameLsaUserPrefix, seqNo);
|
||||
m_syncLogic.publishUpdate(m_nameLsaUserPrefix, seqNo);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::buildUpdatePrefix()
|
||||
{
|
||||
ndn::Name updatePrefix = m_confParam.getLsaPrefix();
|
||||
updatePrefix.append(m_confParam.getSiteName());
|
||||
updatePrefix.append(m_confParam.getRouterName());
|
||||
|
||||
m_nameLsaUserPrefix = updatePrefix;
|
||||
m_nameLsaUserPrefix.append(std::to_string(Lsa::Type::NAME));
|
||||
|
||||
m_adjLsaUserPrefix = updatePrefix;
|
||||
m_adjLsaUserPrefix.append(std::to_string(Lsa::Type::ADJACENCY));
|
||||
|
||||
m_coorLsaUserPrefix = updatePrefix;
|
||||
m_coorLsaUserPrefix.append(std::to_string(Lsa::Type::COORDINATE));
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Publishing Sync Update. Prefix: " << updatePrefix << " Seq No: " << seqNo);
|
||||
|
||||
ndn::Name updateName(updatePrefix);
|
||||
std::string data("NoData");
|
||||
|
||||
m_syncSocket->publishData(reinterpret_cast<const uint8_t*>(data.c_str()), data.size(),
|
||||
ndn::time::milliseconds(1000), seqNo, updateName);
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -26,10 +26,10 @@
|
||||
#include "test-access-control.hpp"
|
||||
#include "signals.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "sync-protocol-adapter.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/util/signal.hpp>
|
||||
#include <ChronoSync/socket.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
class InterestManager;
|
||||
@@ -64,17 +64,6 @@ public:
|
||||
|
||||
SyncLogicHandler(ndn::Face& face, const IsLsaNew& isLsaNew, const ConfParameter& conf);
|
||||
|
||||
/*! \brief Hook function to call whenever sync detects new data.
|
||||
*
|
||||
* This function packages the sync information into discrete updates
|
||||
* and passes those off to another function, processUpdateFromSync.
|
||||
* \sa processUpdateFromSync
|
||||
*
|
||||
* \param v A container with the new information sync has received
|
||||
*/
|
||||
void
|
||||
onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& v);
|
||||
|
||||
/*! \brief Instruct ChronoSync to publish an update.
|
||||
*
|
||||
* This function instructs sync to push an update into the network,
|
||||
@@ -87,25 +76,16 @@ public:
|
||||
void
|
||||
publishRoutingUpdate(const Lsa::Type& type, const uint64_t& seqNo);
|
||||
|
||||
/*! \brief Create and configure a socket to enable ChronoSync for this NLSR.
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*! \brief Callback from Sync protocol
|
||||
*
|
||||
* In a typical situation this only needs to be called once, when NLSR starts.
|
||||
* \param syncPrefix The sync prefix you want this ChronoSync to use
|
||||
* \param syncInterestLifetime ChronoSync sends a periodic sync interest every \p syncInterestLifetime / 2 ms
|
||||
* \sa Nlsr::initialize
|
||||
* \param updateName The prefix for which sync reports an update
|
||||
* \param highSeq The latest sequence number of the update
|
||||
*/
|
||||
void
|
||||
createSyncSocket(const ndn::Name& syncPrefix,
|
||||
const ndn::time::milliseconds& syncInterestLifetime =
|
||||
ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT));
|
||||
processUpdate(const ndn::Name& updateName, uint64_t highSeq);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*! \brief Simple function to glue Name components together
|
||||
*/
|
||||
void
|
||||
buildUpdatePrefix();
|
||||
|
||||
private:
|
||||
/*! \brief Determine which kind of LSA was updated and fetch it.
|
||||
*
|
||||
* Checks that the received update is not from us, which can happen,
|
||||
@@ -116,24 +96,13 @@ private:
|
||||
*/
|
||||
void
|
||||
processUpdateFromSync(const ndn::Name& originRouter,
|
||||
const ndn::Name& updateName, const uint64_t& seqNo);
|
||||
|
||||
/*! \brief Instruct ChronoSync, via the sync socket, to publish an update.
|
||||
*
|
||||
* Each ChronoSync instance maintains its own PIT for sync
|
||||
* updates. This function creates a data that satisfies that update,
|
||||
* so that the interested routers will know new data is available.
|
||||
*/
|
||||
void
|
||||
publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
|
||||
const ndn::Name& updateName, uint64_t seqNo);
|
||||
|
||||
public:
|
||||
std::unique_ptr<OnNewLsa> onNewLsa;
|
||||
|
||||
private:
|
||||
ndn::Face& m_syncFace;
|
||||
std::shared_ptr<chronosync::Socket> m_syncSocket;
|
||||
ndn::Name m_syncPrefix;
|
||||
IsLsaNew m_isLsaNew;
|
||||
const ConfParameter& m_confParam;
|
||||
|
||||
@@ -142,10 +111,11 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::Name m_adjLsaUserPrefix;
|
||||
ndn::Name m_coorLsaUserPrefix;
|
||||
|
||||
SyncProtocolAdapter m_syncLogic;
|
||||
|
||||
private:
|
||||
static const std::string NLSR_COMPONENT;
|
||||
static const std::string LSA_COMPONENT;
|
||||
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, 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.
|
||||
*
|
||||
* 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 "sync-protocol-adapter.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
INIT_LOGGER(SyncProtocolAdapter);
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
const auto FIXED_SESSION = ndn::name::Component::fromNumber(0);
|
||||
|
||||
SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face,
|
||||
int32_t syncProtocol,
|
||||
const ndn::Name& syncPrefix,
|
||||
const ndn::Name& userPrefix,
|
||||
ndn::time::milliseconds syncInterestLifetime,
|
||||
const SyncUpdateCallback& syncUpdateCallback)
|
||||
: m_syncProtocol(syncProtocol)
|
||||
, m_syncUpdateCallback(syncUpdateCallback)
|
||||
{
|
||||
if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) {
|
||||
NDN_LOG_DEBUG("Using ChronoSync");
|
||||
m_chronoSyncLogic = std::make_shared<chronosync::Logic>(face,
|
||||
syncPrefix,
|
||||
userPrefix,
|
||||
std::bind(&SyncProtocolAdapter::onChronoSyncUpdate, this, _1),
|
||||
chronosync::Logic::DEFAULT_NAME,
|
||||
chronosync::Logic::DEFAULT_VALIDATOR,
|
||||
chronosync::Logic::DEFAULT_RESET_TIMER,
|
||||
chronosync::Logic::DEFAULT_CANCEL_RESET_TIMER,
|
||||
chronosync::Logic::DEFAULT_RESET_INTEREST_LIFETIME,
|
||||
syncInterestLifetime,
|
||||
chronosync::Logic::DEFAULT_SYNC_REPLY_FRESHNESS,
|
||||
chronosync::Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME,
|
||||
FIXED_SESSION);
|
||||
}
|
||||
else {
|
||||
NDN_LOG_DEBUG("Using PSync");
|
||||
m_psyncLogic = std::make_shared<psync::FullProducer>(80,
|
||||
face,
|
||||
syncPrefix,
|
||||
userPrefix,
|
||||
std::bind(&SyncProtocolAdapter::onPSyncUpdate, this, _1),
|
||||
syncInterestLifetime);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncProtocolAdapter::addUserNode(const ndn::Name& userPrefix)
|
||||
{
|
||||
if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) {
|
||||
m_chronoSyncLogic->addUserNode(userPrefix, chronosync::Logic::DEFAULT_NAME, FIXED_SESSION);
|
||||
}
|
||||
else {
|
||||
m_psyncLogic->addUserNode(userPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncProtocolAdapter::publishUpdate(const ndn::Name& userPrefix, uint64_t seq)
|
||||
{
|
||||
if (m_syncProtocol == SYNC_PROTOCOL_CHRONOSYNC) {
|
||||
m_chronoSyncLogic->updateSeqNo(seq, userPrefix);
|
||||
}
|
||||
else {
|
||||
m_psyncLogic->publishName(userPrefix, seq);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncProtocolAdapter::onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& updates)
|
||||
{
|
||||
NLSR_LOG_TRACE("Received ChronoSync update event");
|
||||
|
||||
for (const auto& update : updates) {
|
||||
// Remove FIXED_SESSION
|
||||
m_syncUpdateCallback(update.session.getPrefix(-1), update.high);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncProtocolAdapter::onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates)
|
||||
{
|
||||
NLSR_LOG_TRACE("Received PSync update event");
|
||||
|
||||
for (const auto& update : updates) {
|
||||
m_syncUpdateCallback(update.prefix, update.highSeq);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -0,0 +1,96 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, 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.
|
||||
*
|
||||
* 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/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_SYNC_PROTOCOL_ADAPTER_HPP
|
||||
#define NLSR_SYNC_PROTOCOL_ADAPTER_HPP
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ChronoSync/logic.hpp>
|
||||
#include <PSync/full-producer.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
typedef std::function<void(const ndn::Name& updateName,
|
||||
uint64_t seqNo)> SyncUpdateCallback;
|
||||
|
||||
class SyncProtocolAdapter
|
||||
{
|
||||
public:
|
||||
SyncProtocolAdapter(ndn::Face& facePtr,
|
||||
int32_t syncProtocol,
|
||||
const ndn::Name& syncPrefix,
|
||||
const ndn::Name& userPrefix,
|
||||
ndn::time::milliseconds syncInterestLifetime,
|
||||
const SyncUpdateCallback& syncUpdateCallback);
|
||||
|
||||
/*! \brief Add user node to ChronoSync or PSync
|
||||
*
|
||||
* \param userPrefix the Name under which the application will publishData
|
||||
*/
|
||||
void
|
||||
addUserNode(const ndn::Name& userPrefix);
|
||||
|
||||
/*! \brief Publish update to ChronoSync or PSync
|
||||
*
|
||||
* NLSR forces sequences number on the sync protocol
|
||||
* as it manages is its own sequence number by storing it in a file.
|
||||
*
|
||||
* \param userPrefix the Name to be updated
|
||||
* \param seq the sequence of userPrefix
|
||||
*/
|
||||
void
|
||||
publishUpdate(const ndn::Name& userPrefix, uint64_t seq);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*! \brief Hook function to call whenever ChronoSync detects new data.
|
||||
*
|
||||
* This function packages the sync information into discrete updates
|
||||
* and passes those off to another function, m_syncUpdateCallback.
|
||||
* \sa m_syncUpdateCallback
|
||||
*
|
||||
* \param v A container with the new information sync has received
|
||||
*/
|
||||
void
|
||||
onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& updates);
|
||||
|
||||
/*! \brief Hook function to call whenever PSync detects new data.
|
||||
*
|
||||
* This function packages the sync information into discrete updates
|
||||
* and passes those off to another function, m_syncUpdateCallback.
|
||||
* \sa m_syncUpdateCallback
|
||||
*
|
||||
* \param v A container with the new information sync has received
|
||||
*/
|
||||
void
|
||||
onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates);
|
||||
|
||||
private:
|
||||
int32_t m_syncProtocol;
|
||||
SyncUpdateCallback m_syncUpdateCallback;
|
||||
std::shared_ptr<chronosync::Logic> m_chronoSyncLogic;
|
||||
std::shared_ptr<psync::FullProducer> m_psyncLogic;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_SYNC_PROTOCOL_ADAPTER_HPP
|
||||
+122
-77
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
**/
|
||||
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "adjacent.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
#include "update/prefix-update-processor.hpp"
|
||||
@@ -40,7 +39,6 @@ class ConfigurationVariable
|
||||
{
|
||||
public:
|
||||
typedef std::function<void(T)> ConfParameterCallback;
|
||||
typedef boost::property_tree::ptree ConfigSection;
|
||||
|
||||
ConfigurationVariable(const std::string& key, const ConfParameterCallback& setter)
|
||||
: m_key(key)
|
||||
@@ -134,6 +132,12 @@ private:
|
||||
bool m_isRequired;
|
||||
};
|
||||
|
||||
ConfFileProcessor::ConfFileProcessor(ConfParameter& confParam)
|
||||
: m_confFileName(confParam.getConfFileName())
|
||||
, m_confParam(confParam)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ConfFileProcessor::processConfFile()
|
||||
{
|
||||
@@ -148,6 +152,12 @@ ConfFileProcessor::processConfFile()
|
||||
}
|
||||
ret = load(inputFile);
|
||||
inputFile.close();
|
||||
|
||||
if (ret) {
|
||||
m_confParam.buildRouterAndSyncUserPrefix();
|
||||
m_confParam.writeLog();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -155,7 +165,6 @@ bool
|
||||
ConfFileProcessor::load(std::istream& input)
|
||||
{
|
||||
ConfigSection pt;
|
||||
bool ret = true;
|
||||
try {
|
||||
boost::property_tree::read_info(input, pt);
|
||||
}
|
||||
@@ -166,14 +175,12 @@ ConfFileProcessor::load(std::istream& input)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ConfigSection::const_iterator tn = pt.begin();
|
||||
tn != pt.end(); ++tn) {
|
||||
ret = processSection(tn->first, tn->second);
|
||||
if (ret == false) {
|
||||
break;
|
||||
for (const auto& tn : pt) {
|
||||
if (!processSection(tn.first, tn.second)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -220,7 +227,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
std::string router = section.get<std::string>("router");
|
||||
ndn::Name networkName(network);
|
||||
if (!networkName.empty()) {
|
||||
m_nlsr.getConfParameter().setNetwork(networkName);
|
||||
m_confParam.setNetwork(networkName);
|
||||
}
|
||||
else {
|
||||
std::cerr << " Network can not be null or empty or in bad URI format :(!" << std::endl;
|
||||
@@ -228,7 +235,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
ndn::Name siteName(site);
|
||||
if (!siteName.empty()) {
|
||||
m_nlsr.getConfParameter().setSiteName(siteName);
|
||||
m_confParam.setSiteName(siteName);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Site can not be null or empty or in bad URI format:( !" << std::endl;
|
||||
@@ -236,7 +243,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
ndn::Name routerName(router);
|
||||
if (!routerName.empty()) {
|
||||
m_nlsr.getConfParameter().setRouterName(routerName);
|
||||
m_confParam.setRouterName(routerName);
|
||||
}
|
||||
else {
|
||||
std::cerr << " Router name can not be null or empty or in bad URI format:( !" << std::endl;
|
||||
@@ -252,11 +259,11 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
uint32_t lsaRefreshTime = section.get<uint32_t>("lsa-refresh-time", LSA_REFRESH_TIME_DEFAULT);
|
||||
|
||||
if (lsaRefreshTime >= LSA_REFRESH_TIME_MIN && lsaRefreshTime <= LSA_REFRESH_TIME_MAX) {
|
||||
m_nlsr.getConfParameter().setLsaRefreshTime(lsaRefreshTime);
|
||||
m_confParam.setLsaRefreshTime(lsaRefreshTime);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for lsa-refresh-time ";
|
||||
std::cerr << "Allowed value: " << LSA_REFRESH_TIME_MIN << "-";;
|
||||
std::cerr << "Allowed value: " << LSA_REFRESH_TIME_MIN << "-";
|
||||
std::cerr << LSA_REFRESH_TIME_MAX << std::endl;
|
||||
|
||||
return false;
|
||||
@@ -265,8 +272,8 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
// router-dead-interval
|
||||
uint32_t routerDeadInterval = section.get<uint32_t>("router-dead-interval", (2*lsaRefreshTime));
|
||||
|
||||
if (routerDeadInterval > m_nlsr.getConfParameter().getLsaRefreshTime()) {
|
||||
m_nlsr.getConfParameter().setRouterDeadInterval(routerDeadInterval);
|
||||
if (routerDeadInterval > m_confParam.getLsaRefreshTime()) {
|
||||
m_confParam.setRouterDeadInterval(routerDeadInterval);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Value of router-dead-interval must be larger than lsa-refresh-time" << std::endl;
|
||||
@@ -277,7 +284,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
int lifetime = section.get<int>("lsa-interest-lifetime", LSA_INTEREST_LIFETIME_DEFAULT);
|
||||
|
||||
if (lifetime >= LSA_INTEREST_LIFETIME_MIN && lifetime <= LSA_INTEREST_LIFETIME_MAX) {
|
||||
m_nlsr.getConfParameter().setLsaInterestLifetime(ndn::time::seconds(lifetime));
|
||||
m_confParam.setLsaInterestLifetime(ndn::time::seconds(lifetime));
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for lsa-interest-timeout. "
|
||||
@@ -287,10 +294,26 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t syncInterestLifetime = section.get<uint32_t>("sync-interest-lifetime", SYNC_INTEREST_LIFETIME_DEFAULT);
|
||||
// sync-protocol
|
||||
std::string syncProtocol = section.get<std::string>("sync-protocol", "chronosync");
|
||||
if (syncProtocol == "chronosync") {
|
||||
m_confParam.setSyncProtocol(SYNC_PROTOCOL_CHRONOSYNC);
|
||||
}
|
||||
else if (syncProtocol == "psync") {
|
||||
m_confParam.setSyncProtocol(SYNC_PROTOCOL_PSYNC);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Sync protocol " << syncProtocol << " is not supported!"
|
||||
<< "Use chronosync or psync" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// sync-interest-lifetime
|
||||
uint32_t syncInterestLifetime = section.get<uint32_t>("sync-interest-lifetime",
|
||||
SYNC_INTEREST_LIFETIME_DEFAULT);
|
||||
if (syncInterestLifetime >= SYNC_INTEREST_LIFETIME_MIN &&
|
||||
syncInterestLifetime <= SYNC_INTEREST_LIFETIME_MAX) {
|
||||
m_nlsr.getConfParameter().setSyncInterestLifetime(syncInterestLifetime);
|
||||
m_confParam.setSyncInterestLifetime(syncInterestLifetime);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for sync-interest-lifetime. "
|
||||
@@ -301,17 +324,38 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
|
||||
try {
|
||||
std::string seqDir = section.get<std::string>("seq-dir");
|
||||
if (boost::filesystem::exists(seqDir)) {
|
||||
if (boost::filesystem::is_directory(seqDir)) {
|
||||
std::string testFileName=seqDir+"/test.seq";
|
||||
std::ofstream testOutFile;
|
||||
testOutFile.open(testFileName.c_str());
|
||||
if (testOutFile.is_open() && testOutFile.good()) {
|
||||
m_nlsr.getConfParameter().setSeqFileDir(seqDir);
|
||||
std::string stateDir = section.get<std::string>("state-dir");
|
||||
if (bf::exists(stateDir)) {
|
||||
if (bf::is_directory(stateDir)) {
|
||||
|
||||
// copying nlsr.conf file to a user define directory for possible modification
|
||||
std::string conFileDynamic = (bf::path(stateDir) / "nlsr.conf").c_str();
|
||||
|
||||
if (m_confFileName == conFileDynamic) {
|
||||
std::cerr << "Please use nlsr.conf stored at another location "
|
||||
<< "or change the state-dir in the configuration." << std::endl;
|
||||
std::cerr << "The file at " << conFileDynamic <<
|
||||
" is used as dynamic file for saving NLSR runtime changes." << std::endl;
|
||||
std::cerr << "The dynamic file can be used for next run "
|
||||
<< "after copying to another location." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_confParam.setConfFileNameDynamic(conFileDynamic);
|
||||
try {
|
||||
bf::copy_file(m_confFileName, conFileDynamic, bf::copy_option::overwrite_if_exists);
|
||||
}
|
||||
catch (const bf::filesystem_error& e) {
|
||||
std::cerr << "Error copying conf file to the state directory: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
std::string testFileName = (bf::path(stateDir) / "test.seq").c_str();
|
||||
std::ofstream testOutFile(testFileName);
|
||||
if (testOutFile) {
|
||||
m_confParam.setStateFileDir(stateDir);
|
||||
}
|
||||
else {
|
||||
std::cerr << "User does not have read and write permission on the directory";
|
||||
std::cerr << "User does not have read and write permission on the state directory";
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -319,17 +363,17 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
remove(testFileName.c_str());
|
||||
}
|
||||
else {
|
||||
std::cerr << "Provided path is not a directory" << std::endl;
|
||||
std::cerr << "Provided: " << stateDir << "is not a directory" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "Provided sequence directory <" << seqDir << "> does not exist" << std::endl;
|
||||
std::cerr << "Provided state directory <" << stateDir << "> does not exist" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << "You must configure sequence directory" << std::endl;
|
||||
std::cerr << "You must configure state directory" << std::endl;
|
||||
std::cerr << ex.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
@@ -344,7 +388,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
int retrials = section.get<int>("hello-retries", HELLO_RETRIES_DEFAULT);
|
||||
|
||||
if (retrials >= HELLO_RETRIES_MIN && retrials <= HELLO_RETRIES_MAX) {
|
||||
m_nlsr.getConfParameter().setInterestRetryNumber(retrials);
|
||||
m_confParam.setInterestRetryNumber(retrials);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-retries." << std::endl;
|
||||
@@ -358,7 +402,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
uint32_t timeOut = section.get<uint32_t>("hello-timeout", HELLO_TIMEOUT_DEFAULT);
|
||||
|
||||
if (timeOut >= HELLO_TIMEOUT_MIN && timeOut <= HELLO_TIMEOUT_MAX) {
|
||||
m_nlsr.getConfParameter().setInterestResendTime(timeOut);
|
||||
m_confParam.setInterestResendTime(timeOut);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-timeout. ";
|
||||
@@ -372,7 +416,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
uint32_t interval = section.get<uint32_t>("hello-interval", HELLO_INTERVAL_DEFAULT);
|
||||
|
||||
if (interval >= HELLO_INTERVAL_MIN && interval <= HELLO_INTERVAL_MAX) {
|
||||
m_nlsr.getConfParameter().setInfoInterestInterval(interval);
|
||||
m_confParam.setInfoInterestInterval(interval);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-interval. ";
|
||||
@@ -386,7 +430,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
// adj-lsa-build-interval
|
||||
ConfigurationVariable<uint32_t> adjLsaBuildInterval("adj-lsa-build-interval",
|
||||
std::bind(&ConfParameter::setAdjLsaBuildInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
&m_confParam, _1));
|
||||
adjLsaBuildInterval.setMinAndMaxValue(ADJ_LSA_BUILD_INTERVAL_MIN, ADJ_LSA_BUILD_INTERVAL_MAX);
|
||||
adjLsaBuildInterval.setOptional(ADJ_LSA_BUILD_INTERVAL_DEFAULT);
|
||||
|
||||
@@ -396,7 +440,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
// Set the retry count for fetching the FaceStatus dataset
|
||||
ConfigurationVariable<uint32_t> faceDatasetFetchTries("face-dataset-fetch-tries",
|
||||
std::bind(&ConfParameter::setFaceDatasetFetchTries,
|
||||
&m_nlsr.getConfParameter(),
|
||||
&m_confParam,
|
||||
_1));
|
||||
|
||||
faceDatasetFetchTries.setMinAndMaxValue(FACE_DATASET_FETCH_TRIES_MIN,
|
||||
@@ -410,7 +454,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
// Set the interval between FaceStatus dataset fetch attempts.
|
||||
ConfigurationVariable<uint32_t> faceDatasetFetchInterval("face-dataset-fetch-interval",
|
||||
bind(&ConfParameter::setFaceDatasetFetchInterval,
|
||||
&m_nlsr.getConfParameter(),
|
||||
&m_confParam,
|
||||
_1));
|
||||
|
||||
faceDatasetFetchInterval.setMinAndMaxValue(FACE_DATASET_FETCH_INTERVAL_MIN,
|
||||
@@ -421,29 +465,34 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
return false;
|
||||
}
|
||||
|
||||
// first-hello-interval
|
||||
ConfigurationVariable<uint32_t> firstHelloInterval("first-hello-interval",
|
||||
std::bind(&ConfParameter::setFirstHelloInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
firstHelloInterval.setMinAndMaxValue(FIRST_HELLO_INTERVAL_MIN, FIRST_HELLO_INTERVAL_MAX);
|
||||
firstHelloInterval.setOptional(FIRST_HELLO_INTERVAL_DEFAULT);
|
||||
|
||||
if (!firstHelloInterval.parseFromConfigSection(section)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ConfigSection::const_iterator tn =
|
||||
section.begin(); tn != section.end(); ++tn) {
|
||||
|
||||
if (tn->first == "neighbor") {
|
||||
for (const auto& tn : section) {
|
||||
if (tn.first == "neighbor") {
|
||||
try {
|
||||
ConfigSection CommandAttriTree = tn->second;
|
||||
ConfigSection CommandAttriTree = tn.second;
|
||||
std::string name = CommandAttriTree.get<std::string>("name");
|
||||
std::string uriString = CommandAttriTree.get<std::string>("face-uri");
|
||||
|
||||
ndn::FaceUri faceUri;
|
||||
if (! faceUri.parse(uriString)) {
|
||||
std::cerr << "parsing failed!" << std::endl;
|
||||
std::cerr << "Parsing failed!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool failedToCanonize = false;
|
||||
faceUri.canonize([&faceUri] (ndn::FaceUri canonicalUri) {
|
||||
faceUri = canonicalUri;
|
||||
},
|
||||
[&faceUri, &failedToCanonize] (const std::string& reason) {
|
||||
failedToCanonize = true;
|
||||
std::cerr << "Could not canonize URI: " << faceUri
|
||||
<< "because: " << reason << std::endl;
|
||||
},
|
||||
m_io,
|
||||
TIME_ALLOWED_FOR_CANONIZATION);
|
||||
m_io.run();
|
||||
m_io.reset();
|
||||
|
||||
if (failedToCanonize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -452,7 +501,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
ndn::Name neighborName(name);
|
||||
if (!neighborName.empty()) {
|
||||
Adjacent adj(name, faceUri, linkCost, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
m_nlsr.getAdjacencyList().insert(adj);
|
||||
m_confParam.getAdjacencyList().insert(adj);
|
||||
}
|
||||
else {
|
||||
std::cerr << " Wrong command format ! [name /nbr/name/ \n face-uri /uri\n]";
|
||||
@@ -475,13 +524,13 @@ ConfFileProcessor::processConfSectionHyperbolic(const ConfigSection& section)
|
||||
std::string state = section.get<std::string>("state", "off");
|
||||
|
||||
if (boost::iequals(state, "off")) {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_OFF);
|
||||
m_confParam.setHyperbolicState(HYPERBOLIC_STATE_OFF);
|
||||
}
|
||||
else if (boost::iequals(state, "on")) {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
|
||||
m_confParam.setHyperbolicState(HYPERBOLIC_STATE_ON);
|
||||
}
|
||||
else if (state == "dry-run") {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
|
||||
m_confParam.setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong format for hyperbolic state." << std::endl;
|
||||
@@ -510,10 +559,10 @@ ConfFileProcessor::processConfSectionHyperbolic(const ConfigSection& section)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_nlsr.getConfParameter().setCorR(radius)) {
|
||||
if (!m_confParam.setCorR(radius)) {
|
||||
return false;
|
||||
}
|
||||
m_nlsr.getConfParameter().setCorTheta(angles);
|
||||
m_confParam.setCorTheta(angles);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
@@ -534,7 +583,7 @@ ConfFileProcessor::processConfSectionFib(const ConfigSection& section)
|
||||
if (maxFacesPerPrefix >= MAX_FACES_PER_PREFIX_MIN &&
|
||||
maxFacesPerPrefix <= MAX_FACES_PER_PREFIX_MAX)
|
||||
{
|
||||
m_nlsr.getConfParameter().setMaxFacesPerPrefix(maxFacesPerPrefix);
|
||||
m_confParam.setMaxFacesPerPrefix(maxFacesPerPrefix);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for max-faces-per-prefix. ";
|
||||
@@ -546,7 +595,7 @@ ConfFileProcessor::processConfSectionFib(const ConfigSection& section)
|
||||
// routing-calc-interval
|
||||
ConfigurationVariable<uint32_t> routingCalcInterval("routing-calc-interval",
|
||||
std::bind(&ConfParameter::setRoutingCalcInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
&m_confParam, _1));
|
||||
routingCalcInterval.setMinAndMaxValue(ROUTING_CALC_INTERVAL_MIN, ROUTING_CALC_INTERVAL_MAX);
|
||||
routingCalcInterval.setOptional(ROUTING_CALC_INTERVAL_DEFAULT);
|
||||
|
||||
@@ -560,14 +609,12 @@ ConfFileProcessor::processConfSectionFib(const ConfigSection& section)
|
||||
bool
|
||||
ConfFileProcessor::processConfSectionAdvertising(const ConfigSection& section)
|
||||
{
|
||||
for (ConfigSection::const_iterator tn =
|
||||
section.begin(); tn != section.end(); ++tn) {
|
||||
if (tn->first == "prefix") {
|
||||
for (const auto& tn : section) {
|
||||
if (tn.first == "prefix") {
|
||||
try {
|
||||
std::string prefix = tn->second.data();
|
||||
ndn::Name namePrefix(prefix);
|
||||
ndn::Name namePrefix(tn.second.data());
|
||||
if (!namePrefix.empty()) {
|
||||
m_nlsr.getNamePrefixList().insert(namePrefix);
|
||||
m_confParam.getNamePrefixList().insert(namePrefix);
|
||||
}
|
||||
else {
|
||||
std::cerr << " Wrong command format ! [prefix /name/prefix] or bad URI" << std::endl;
|
||||
@@ -593,15 +640,14 @@ ConfFileProcessor::processConfSectionSecurity(const ConfigSection& section)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nlsr.loadValidator(it->second, m_confFileName);
|
||||
m_confParam.getValidator().load(it->second, m_confFileName);
|
||||
|
||||
it++;
|
||||
if (it != section.end() && it->first == "prefix-update-validator") {
|
||||
m_nlsr.getPrefixUpdateProcessor().loadValidator(it->second, m_confFileName);
|
||||
m_confParam.getPrefixUpdateValidator().load(it->second, m_confFileName);
|
||||
|
||||
it++;
|
||||
for (; it != section.end(); it++) {
|
||||
using namespace boost::filesystem;
|
||||
|
||||
if (it->first != "cert-to-publish") {
|
||||
std::cerr << "Error: Expect cert-to-publish!" << std::endl;
|
||||
@@ -609,16 +655,15 @@ ConfFileProcessor::processConfSectionSecurity(const ConfigSection& section)
|
||||
}
|
||||
|
||||
std::string file = it->second.data();
|
||||
path certfilePath = absolute(file, path(m_confFileName).parent_path());
|
||||
std::shared_ptr<ndn::security::v2::Certificate> idCert =
|
||||
ndn::io::load<ndn::security::v2::Certificate>(certfilePath.string());
|
||||
bf::path certfilePath = absolute(file, bf::path(m_confFileName).parent_path());
|
||||
auto idCert = ndn::io::load<ndn::security::v2::Certificate>(certfilePath.string());
|
||||
|
||||
if (idCert == nullptr) {
|
||||
std::cerr << "Error: Cannot load cert-to-publish: " << file << "!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nlsr.loadCertToPublish(*idCert);
|
||||
m_confParam.addCertPath(certfilePath.string());
|
||||
m_confParam.loadCertToValidator(*idCert);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -22,7 +22,7 @@
|
||||
#define NLSR_CONF_FILE_PROCESSOR_HPP
|
||||
|
||||
#include "common.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/property_tree/info_parser.hpp>
|
||||
@@ -30,6 +30,9 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
namespace bf = boost::filesystem;
|
||||
using ConfigSection = boost::property_tree::ptree;
|
||||
|
||||
/*! \brief A class containing methods to parse an NLSR configuration file
|
||||
*
|
||||
* This class contains methods to parse an NLSR configuration file and
|
||||
@@ -46,11 +49,7 @@ namespace nlsr {
|
||||
class ConfFileProcessor
|
||||
{
|
||||
public:
|
||||
ConfFileProcessor(Nlsr& nlsr, const std::string& cfile)
|
||||
: m_confFileName(cfile)
|
||||
, m_nlsr(nlsr)
|
||||
{
|
||||
}
|
||||
ConfFileProcessor(ConfParameter& confParam);
|
||||
|
||||
/*! \brief Load and parse the configuration file, then populate NLSR.
|
||||
*
|
||||
@@ -63,8 +62,6 @@ public:
|
||||
processConfFile();
|
||||
|
||||
private:
|
||||
typedef boost::property_tree::ptree ConfigSection;
|
||||
|
||||
/*! \brief Parse the configuration file into a tree and process the nodes.
|
||||
*
|
||||
* Reads the configuration file as a property tree, and then iterates
|
||||
@@ -125,8 +122,10 @@ private:
|
||||
private:
|
||||
/*! m_confFileName The full path of the configuration file to parse. */
|
||||
std::string m_confFileName;
|
||||
/*! m_nlsr The NLSR object to configure upon successful parsing. */
|
||||
Nlsr& m_nlsr;
|
||||
/*! m_confParam The ConfFileProcessor object to configure as parsing is done. */
|
||||
ConfParameter& m_confParam;
|
||||
/*! m_io For canonization of faceUri. */
|
||||
boost::asio::io_service m_io;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+127
-20
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -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>
|
||||
*
|
||||
**/
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
@@ -28,8 +25,43 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(ConfParameter);
|
||||
|
||||
using namespace ndn::time_literals;
|
||||
|
||||
// To be changed when breaking changes are made to sync
|
||||
const uint64_t ConfParameter::SYNC_VERSION = 4;
|
||||
const uint64_t ConfParameter::SYNC_VERSION = 8;
|
||||
|
||||
static std::unique_ptr<ndn::security::v2::CertificateFetcherDirectFetch>
|
||||
makeCertificateFetcher(ndn::Face& face)
|
||||
{
|
||||
auto fetcher = std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face);
|
||||
fetcher->setSendDirectInterestOnly(true);
|
||||
return fetcher;
|
||||
}
|
||||
|
||||
ConfParameter::ConfParameter(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
const std::string& confFileName)
|
||||
: m_confFileName(confFileName)
|
||||
, m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
|
||||
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
|
||||
, m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
|
||||
, m_faceDatasetFetchInterval(ndn::time::seconds(static_cast<int>(FACE_DATASET_FETCH_INTERVAL_DEFAULT)))
|
||||
, m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
|
||||
, m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
|
||||
, m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
|
||||
, m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
|
||||
, m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
|
||||
, m_hyperbolicState(HYPERBOLIC_STATE_OFF)
|
||||
, m_corR(0)
|
||||
, m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
|
||||
, m_syncInterestLifetime(ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
|
||||
, m_syncProtocol(SYNC_PROTOCOL_CHRONOSYNC)
|
||||
, m_adjl()
|
||||
, m_npl()
|
||||
, m_validator(makeCertificateFetcher(face))
|
||||
, m_prefixUpdateValidator(std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
|
||||
, m_keyChain(keyChain)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ConfParameter::writeLog()
|
||||
@@ -38,8 +70,8 @@ ConfParameter::writeLog()
|
||||
NLSR_LOG_INFO("Site Name: " << m_siteName);
|
||||
NLSR_LOG_INFO("Network: " << m_network);
|
||||
NLSR_LOG_INFO("Router Prefix: " << m_routerPrefix);
|
||||
NLSR_LOG_INFO("ChronoSync sync Prefix: " << m_chronosyncPrefix);
|
||||
NLSR_LOG_INFO("ChronoSync LSA prefix: " << m_lsaPrefix);
|
||||
NLSR_LOG_INFO("Sync Prefix: " << m_syncPrefix);
|
||||
NLSR_LOG_INFO("Sync LSA prefix: " << m_lsaPrefix);
|
||||
NLSR_LOG_INFO("Hello Interest retry number: " << m_interestRetryNumber);
|
||||
NLSR_LOG_INFO("Hello Interest resend second: " << m_interestResendTime);
|
||||
NLSR_LOG_INFO("Info Interest interval: " << m_infoInterestInterval);
|
||||
@@ -48,17 +80,18 @@ ConfParameter::writeLog()
|
||||
NLSR_LOG_INFO("LSA Interest lifetime: " << getLsaInterestLifetime());
|
||||
NLSR_LOG_INFO("Router dead interval: " << getRouterDeadInterval());
|
||||
NLSR_LOG_INFO("Max Faces Per Prefix: " << m_maxFacesPerPrefix);
|
||||
NLSR_LOG_INFO("Hyperbolic Routing: " << m_hyperbolicState);
|
||||
NLSR_LOG_INFO("Hyp R: " << m_corR);
|
||||
int i=0;
|
||||
for (auto const& value: m_corTheta) {
|
||||
NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
|
||||
if (m_hyperbolicState == HYPERBOLIC_STATE_ON || m_hyperbolicState == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
NLSR_LOG_INFO("Hyperbolic Routing: " << m_hyperbolicState);
|
||||
NLSR_LOG_INFO("Hyp R: " << m_corR);
|
||||
int i=0;
|
||||
for (auto const& value: m_corTheta) {
|
||||
NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
|
||||
}
|
||||
}
|
||||
NLSR_LOG_INFO("Seq Directory: " << m_seqFileDir);
|
||||
NLSR_LOG_INFO("State Directory: " << m_stateFileDir);
|
||||
|
||||
// Event Intervals
|
||||
NLSR_LOG_INFO("Adjacency LSA build interval: " << m_adjLsaBuildInterval);
|
||||
NLSR_LOG_INFO("First Hello Interest interval: " << m_firstHelloInterval);
|
||||
NLSR_LOG_INFO("Routing calculation interval: " << m_routingCalcInterval);
|
||||
}
|
||||
|
||||
@@ -67,16 +100,90 @@ ConfParameter::setNetwork(const ndn::Name& networkName)
|
||||
{
|
||||
m_network = networkName;
|
||||
|
||||
m_chronosyncPrefix.append("localhop");
|
||||
m_chronosyncPrefix.append(m_network);
|
||||
m_chronosyncPrefix.append("NLSR");
|
||||
m_chronosyncPrefix.append("sync");
|
||||
m_chronosyncPrefix.appendVersion(SYNC_VERSION);
|
||||
m_syncPrefix.append("localhop");
|
||||
m_syncPrefix.append(m_network);
|
||||
m_syncPrefix.append("nlsr");
|
||||
m_syncPrefix.append("sync");
|
||||
m_syncPrefix.appendVersion(SYNC_VERSION);
|
||||
|
||||
m_lsaPrefix.append("localhop");
|
||||
m_lsaPrefix.append(m_network);
|
||||
m_lsaPrefix.append("NLSR");
|
||||
m_lsaPrefix.append("nlsr");
|
||||
m_lsaPrefix.append("LSA");
|
||||
}
|
||||
|
||||
void
|
||||
ConfParameter::loadCertToValidator(const ndn::security::v2::Certificate& cert)
|
||||
{
|
||||
NLSR_LOG_TRACE("Loading Certificate Name: " << cert.getName());
|
||||
m_validator.loadAnchor("Authoritative-Certificate", ndn::security::v2::Certificate(cert));
|
||||
m_prefixUpdateValidator.loadAnchor("Authoritative-Certificate", ndn::security::v2::Certificate(cert));
|
||||
}
|
||||
|
||||
shared_ptr<ndn::security::v2::Certificate>
|
||||
ConfParameter::initializeKey()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Initializing Key ...");
|
||||
|
||||
ndn::Name nlsrInstanceName(m_routerPrefix);
|
||||
nlsrInstanceName.append("nlsr");
|
||||
|
||||
try {
|
||||
m_keyChain.deleteIdentity(m_keyChain.getPib().getIdentity(nlsrInstanceName));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_WARN(e.what());
|
||||
}
|
||||
|
||||
ndn::security::Identity nlsrInstanceIdentity;
|
||||
try {
|
||||
nlsrInstanceIdentity = m_keyChain.createIdentity(nlsrInstanceName);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_ERROR(e.what());
|
||||
NLSR_LOG_ERROR("Unable to create identity, NLSR will run without security!");
|
||||
NLSR_LOG_ERROR("Can be ignored if running in non-production environments.");
|
||||
return nullptr;
|
||||
}
|
||||
auto certificate = std::make_shared<ndn::security::v2::Certificate>();
|
||||
auto nlsrInstanceKey = nlsrInstanceIdentity.getDefaultKey();
|
||||
ndn::Name certificateName = nlsrInstanceKey.getName();
|
||||
certificateName.append("NA");
|
||||
certificateName.appendVersion();
|
||||
|
||||
certificate->setName(certificateName);
|
||||
|
||||
// set metainfo
|
||||
certificate->setContentType(ndn::tlv::ContentType_Key);
|
||||
certificate->setFreshnessPeriod(365_days);
|
||||
|
||||
// set content
|
||||
certificate->setContent(nlsrInstanceKey.getPublicKey().data(),
|
||||
nlsrInstanceKey.getPublicKey().size());
|
||||
|
||||
// set signature-info
|
||||
ndn::SignatureInfo signatureInfo;
|
||||
signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(ndn::time::system_clock::TimePoint(),
|
||||
ndn::time::system_clock::now()
|
||||
+ 365_days));
|
||||
|
||||
try {
|
||||
m_keyChain.sign(*certificate,
|
||||
ndn::security::SigningInfo(m_keyChain.getPib().getIdentity(m_routerPrefix))
|
||||
.setSignatureInfo(signatureInfo));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_ERROR("Router's " << e.what() << ", NLSR is running without security. " <<
|
||||
"If security is enabled in the configuration, NLSR will not converge.");
|
||||
|
||||
}
|
||||
|
||||
m_signingInfo = ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID,
|
||||
nlsrInstanceName);
|
||||
|
||||
loadCertToValidator(*certificate);
|
||||
|
||||
return certificate;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
+135
-52
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -25,10 +25,13 @@
|
||||
#include "common.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/security/validator-config.hpp>
|
||||
#include <ndn-cxx/security/v2/certificate-fetcher-direct-fetch.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -39,6 +42,11 @@ enum {
|
||||
LSA_REFRESH_TIME_MAX = 7200
|
||||
};
|
||||
|
||||
enum {
|
||||
SYNC_PROTOCOL_CHRONOSYNC = 0,
|
||||
SYNC_PROTOCOL_PSYNC = 1
|
||||
};
|
||||
|
||||
enum {
|
||||
LSA_INTEREST_LIFETIME_MIN = 1,
|
||||
LSA_INTEREST_LIFETIME_DEFAULT = 4,
|
||||
@@ -46,15 +54,9 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
ADJ_LSA_BUILD_INTERVAL_MIN = 0,
|
||||
ADJ_LSA_BUILD_INTERVAL_DEFAULT = 5,
|
||||
ADJ_LSA_BUILD_INTERVAL_MAX = 5
|
||||
};
|
||||
|
||||
enum {
|
||||
FIRST_HELLO_INTERVAL_MIN = 0,
|
||||
FIRST_HELLO_INTERVAL_DEFAULT = 10,
|
||||
FIRST_HELLO_INTERVAL_MAX = 10
|
||||
ADJ_LSA_BUILD_INTERVAL_MIN = 5,
|
||||
ADJ_LSA_BUILD_INTERVAL_DEFAULT = 10,
|
||||
ADJ_LSA_BUILD_INTERVAL_MAX = 30
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -84,7 +86,7 @@ enum {
|
||||
|
||||
enum {
|
||||
HELLO_TIMEOUT_MIN = 1,
|
||||
HELLO_TIMEOUT_DEFAULT = 3,
|
||||
HELLO_TIMEOUT_DEFAULT = 1,
|
||||
HELLO_TIMEOUT_MAX = 15
|
||||
};
|
||||
|
||||
@@ -128,23 +130,13 @@ class ConfParameter
|
||||
{
|
||||
|
||||
public:
|
||||
ConfParameter()
|
||||
: m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
|
||||
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
|
||||
, m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
|
||||
, m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
|
||||
, m_faceDatasetFetchInterval(ndn::time::seconds(static_cast<int>(FACE_DATASET_FETCH_INTERVAL_DEFAULT)))
|
||||
, m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
|
||||
, m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
|
||||
, m_logLevel("INFO")
|
||||
, m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
|
||||
, m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
|
||||
, m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
|
||||
, m_hyperbolicState(HYPERBOLIC_STATE_OFF)
|
||||
, m_corR(0)
|
||||
, m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
|
||||
, m_syncInterestLifetime(ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
|
||||
ConfParameter(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
const std::string& confFileName = "nlsr.conf");
|
||||
|
||||
const std::string&
|
||||
getConfFileName()
|
||||
{
|
||||
return m_confFileName;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -181,11 +173,15 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
buildRouterPrefix()
|
||||
buildRouterAndSyncUserPrefix()
|
||||
{
|
||||
m_routerPrefix = m_network;
|
||||
m_routerPrefix.append(m_siteName);
|
||||
m_routerPrefix.append(m_routerName);
|
||||
|
||||
m_syncUserPrefix = m_lsaPrefix;
|
||||
m_syncUserPrefix.append(m_siteName);
|
||||
m_syncUserPrefix.append(m_routerName);
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
@@ -194,11 +190,16 @@ public:
|
||||
return m_routerPrefix;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
getSyncUserPrefix() const
|
||||
{
|
||||
return m_syncUserPrefix;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
getChronosyncPrefix() const
|
||||
getSyncPrefix() const
|
||||
{
|
||||
return m_chronosyncPrefix;
|
||||
return m_syncPrefix;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
@@ -213,6 +214,20 @@ public:
|
||||
m_lsaRefreshTime = lrt;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getSyncProtocol() const
|
||||
{
|
||||
return m_syncProtocol;
|
||||
}
|
||||
|
||||
void
|
||||
setSyncProtocol(int32_t syncProtocol)
|
||||
{
|
||||
if (syncProtocol == SYNC_PROTOCOL_CHRONOSYNC || syncProtocol == SYNC_PROTOCOL_PSYNC) {
|
||||
m_syncProtocol = syncProtocol;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getLsaRefreshTime() const
|
||||
{
|
||||
@@ -243,18 +258,6 @@ public:
|
||||
return m_adjLsaBuildInterval;
|
||||
}
|
||||
|
||||
void
|
||||
setFirstHelloInterval(uint32_t interval)
|
||||
{
|
||||
m_firstHelloInterval = interval;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getFirstHelloInterval() const
|
||||
{
|
||||
return m_firstHelloInterval;
|
||||
}
|
||||
|
||||
void
|
||||
setRoutingCalcInterval(uint32_t interval)
|
||||
{
|
||||
@@ -392,15 +395,27 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setSeqFileDir(const std::string& ssfd)
|
||||
setStateFileDir(const std::string& ssfd)
|
||||
{
|
||||
m_seqFileDir = ssfd;
|
||||
m_stateFileDir = ssfd;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getSeqFileDir() const
|
||||
getStateFileDir() const
|
||||
{
|
||||
return m_seqFileDir;
|
||||
return m_stateFileDir;
|
||||
}
|
||||
|
||||
void
|
||||
setConfFileNameDynamic(const std::string& confFileDynamic)
|
||||
{
|
||||
m_confFileNameDynamic = confFileDynamic;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getConfFileNameDynamic() const
|
||||
{
|
||||
return m_confFileNameDynamic;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -415,24 +430,82 @@ public:
|
||||
return m_syncInterestLifetime;
|
||||
}
|
||||
|
||||
AdjacencyList&
|
||||
getAdjacencyList()
|
||||
{
|
||||
return m_adjl;
|
||||
}
|
||||
|
||||
NamePrefixList&
|
||||
getNamePrefixList()
|
||||
{
|
||||
return m_npl;
|
||||
}
|
||||
|
||||
ndn::security::ValidatorConfig&
|
||||
getValidator()
|
||||
{
|
||||
return m_validator;
|
||||
}
|
||||
|
||||
ndn::security::ValidatorConfig&
|
||||
getPrefixUpdateValidator()
|
||||
{
|
||||
return m_prefixUpdateValidator;
|
||||
}
|
||||
|
||||
const ndn::security::SigningInfo&
|
||||
getSigningInfo() const
|
||||
{
|
||||
return m_signingInfo;
|
||||
}
|
||||
|
||||
void
|
||||
addCertPath(const std::string& certPath)
|
||||
{
|
||||
m_certs.insert(certPath);
|
||||
}
|
||||
|
||||
const std::unordered_set<std::string>&
|
||||
getIdCerts() const
|
||||
{
|
||||
return m_certs;
|
||||
}
|
||||
|
||||
const ndn::KeyChain&
|
||||
getKeyChain() const
|
||||
{
|
||||
return m_keyChain;
|
||||
}
|
||||
|
||||
shared_ptr<ndn::security::v2::Certificate>
|
||||
initializeKey();
|
||||
|
||||
void
|
||||
loadCertToValidator(const ndn::security::v2::Certificate& cert);
|
||||
|
||||
/*! \brief Dump the current state of all attributes to the log.
|
||||
*/
|
||||
void
|
||||
writeLog();
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
std::string m_confFileName;
|
||||
std::string m_confFileNameDynamic;
|
||||
private:
|
||||
ndn::Name m_routerName;
|
||||
ndn::Name m_siteName;
|
||||
ndn::Name m_network;
|
||||
|
||||
ndn::Name m_routerPrefix;
|
||||
ndn::Name m_lsaRouterPrefix;
|
||||
ndn::Name m_syncUserPrefix;
|
||||
|
||||
ndn::Name m_chronosyncPrefix;
|
||||
ndn::Name m_syncPrefix;
|
||||
ndn::Name m_lsaPrefix;
|
||||
|
||||
uint32_t m_lsaRefreshTime;
|
||||
|
||||
uint32_t m_adjLsaBuildInterval;
|
||||
uint32_t m_firstHelloInterval;
|
||||
uint32_t m_routingCalcInterval;
|
||||
|
||||
uint32_t m_faceDatasetFetchTries;
|
||||
@@ -440,7 +513,6 @@ private:
|
||||
|
||||
ndn::time::seconds m_lsaInterestLifetime;
|
||||
uint32_t m_routerDeadInterval;
|
||||
std::string m_logLevel;
|
||||
|
||||
uint32_t m_interestRetryNumber;
|
||||
uint32_t m_interestResendTime;
|
||||
@@ -453,11 +525,22 @@ private:
|
||||
|
||||
uint32_t m_maxFacesPerPrefix;
|
||||
|
||||
std::string m_seqFileDir;
|
||||
std::string m_stateFileDir;
|
||||
|
||||
ndn::time::milliseconds m_syncInterestLifetime;
|
||||
|
||||
int32_t m_syncProtocol;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
static const uint64_t SYNC_VERSION;
|
||||
|
||||
AdjacencyList m_adjl;
|
||||
NamePrefixList m_npl;
|
||||
ndn::security::ValidatorConfig m_validator;
|
||||
ndn::security::ValidatorConfig m_prefixUpdateValidator;
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
std::unordered_set<std::string> m_certs;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+78
-76
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -17,7 +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/>.
|
||||
**/
|
||||
#include "hello-protocol.hpp"
|
||||
|
||||
#include "hello-protocol.hpp"
|
||||
#include "nlsr.hpp"
|
||||
@@ -30,62 +29,67 @@ namespace nlsr {
|
||||
INIT_LOGGER(HelloProtocol);
|
||||
|
||||
const std::string HelloProtocol::INFO_COMPONENT = "INFO";
|
||||
const std::string HelloProtocol::NLSR_COMPONENT = "NLSR";
|
||||
const std::string HelloProtocol::NLSR_COMPONENT = "nlsr";
|
||||
|
||||
HelloProtocol::HelloProtocol(Nlsr& nlsr, ndn::Scheduler& scheduler)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
HelloProtocol::HelloProtocol(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
ConfParameter& confParam, RoutingTable& routingTable,
|
||||
Lsdb& lsdb)
|
||||
: m_face(face)
|
||||
, m_scheduler(m_face.getIoService())
|
||||
, m_keyChain(keyChain)
|
||||
, m_signingInfo(confParam.getSigningInfo())
|
||||
, m_confParam(confParam)
|
||||
, m_routingTable(routingTable)
|
||||
, m_lsdb(lsdb)
|
||||
, m_adjacencyList(m_confParam.getAdjacencyList())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Expressing Interest :" << interestName);
|
||||
ndn::Interest i(interestName);
|
||||
i.setInterestLifetime(ndn::time::seconds(seconds));
|
||||
i.setMustBeFresh(true);
|
||||
m_nlsr.getNlsrFace().expressInterest(i,
|
||||
std::bind(&HelloProtocol::onContent,
|
||||
this,
|
||||
_1, _2),
|
||||
std::bind(&HelloProtocol::processInterestTimedOut, // Nack
|
||||
this, _1),
|
||||
std::bind(&HelloProtocol::processInterestTimedOut,
|
||||
this, _1));
|
||||
NLSR_LOG_DEBUG("Expressing Interest: " << interestName);
|
||||
ndn::Interest interest(interestName);
|
||||
interest.setInterestLifetime(ndn::time::seconds(seconds));
|
||||
interest.setMustBeFresh(true);
|
||||
interest.setCanBePrefix(true);
|
||||
m_face.expressInterest(interest,
|
||||
std::bind(&HelloProtocol::onContent, this, _1, _2),
|
||||
[this, seconds] (const ndn::Interest& interest, const ndn::lp::Nack& nack)
|
||||
{
|
||||
NDN_LOG_TRACE("Received Nack with reason: " << nack.getReason());
|
||||
NDN_LOG_TRACE("Will treat as timeout in " << 2 * seconds << " seconds");
|
||||
m_scheduler.schedule(ndn::time::seconds(2 * seconds),
|
||||
[this, interest] { processInterestTimedOut(interest); });
|
||||
},
|
||||
std::bind(&HelloProtocol::processInterestTimedOut, this, _1));
|
||||
|
||||
// increment SENT_HELLO_INTEREST
|
||||
hpIncrementSignal(Statistics::PacketType::SENT_HELLO_INTEREST);
|
||||
}
|
||||
|
||||
void
|
||||
HelloProtocol::sendScheduledInterest(uint32_t seconds)
|
||||
HelloProtocol::sendHelloInterest(const ndn::Name& neighbor)
|
||||
{
|
||||
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() ;
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
NLSR_LOG_DEBUG("Sending scheduled interest: " << interestName);
|
||||
}
|
||||
auto adjacent = m_adjacencyList.findAdjacent(neighbor);
|
||||
|
||||
if (adjacent == m_adjacencyList.end()) {
|
||||
return;
|
||||
}
|
||||
scheduleInterest(m_nlsr.getConfParameter().getInfoInterestInterval());
|
||||
}
|
||||
|
||||
void
|
||||
HelloProtocol::scheduleInterest(uint32_t seconds)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Scheduling HELLO Interests in " << ndn::time::seconds(seconds));
|
||||
// If this adjacency has a Face, just proceed as usual.
|
||||
if(adjacent->getFaceId() != 0) {
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName = adjacent->getName() ;
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
interestName.append(m_confParam.getRouterPrefix().wireEncode());
|
||||
expressInterest(interestName, m_confParam.getInterestResendTime());
|
||||
NLSR_LOG_DEBUG("Sending HELLO interest: " << interestName);
|
||||
}
|
||||
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(seconds),
|
||||
std::bind(&HelloProtocol::sendScheduledInterest, this, seconds));
|
||||
m_scheduler.schedule(ndn::time::seconds(m_confParam.getInfoInterestInterval()),
|
||||
[this, neighbor] { sendHelloInterest(neighbor); });
|
||||
}
|
||||
|
||||
void
|
||||
@@ -108,22 +112,22 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
ndn::Name neighbor;
|
||||
neighbor.wireDecode(interestName.get(-1).blockFromValue());
|
||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) {
|
||||
if (m_adjacencyList.isNeighbor(neighbor)) {
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()),
|
||||
INFO_COMPONENT.size());
|
||||
INFO_COMPONENT.size());
|
||||
|
||||
m_nlsr.getKeyChain().sign(*data, m_nlsr.getSigningInfo());
|
||||
m_keyChain.sign(*data, m_signingInfo);
|
||||
|
||||
NLSR_LOG_DEBUG("Sending out data for name: " << interest.getName());
|
||||
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
m_face.put(*data);
|
||||
// increment SENT_HELLO_DATA
|
||||
hpIncrementSignal(Statistics::PacketType::SENT_HELLO_DATA);
|
||||
|
||||
auto adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor);
|
||||
auto adjacent = m_adjacencyList.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.
|
||||
@@ -132,9 +136,8 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
interestName.append(m_confParam.getRouterPrefix().wireEncode());
|
||||
expressInterest(interestName, m_confParam.getInterestResendTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,31 +154,29 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
}
|
||||
ndn::Name neighbor = interestName.getPrefix(-3);
|
||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
|
||||
m_adjacencyList.incrementTimedOutInterestCount(neighbor);
|
||||
|
||||
Adjacent::Status status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
Adjacent::Status status = m_adjacencyList.getStatusOfNeighbor(neighbor);
|
||||
|
||||
uint32_t infoIntTimedOutCount =
|
||||
m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor);
|
||||
uint32_t infoIntTimedOutCount = m_adjacencyList.getTimedOutInterestCount(neighbor);
|
||||
NLSR_LOG_DEBUG("Status: " << status);
|
||||
NLSR_LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount);
|
||||
if (infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber()) {
|
||||
if (infoIntTimedOutCount <= m_confParam.getInterestRetryNumber()) {
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName(neighbor);
|
||||
interestName.append(NLSR_COMPONENT);
|
||||
interestName.append(INFO_COMPONENT);
|
||||
interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode());
|
||||
interestName.append(m_confParam.getRouterPrefix().wireEncode());
|
||||
NLSR_LOG_DEBUG("Resending interest: " << interestName);
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
expressInterest(interestName, m_confParam.getInterestResendTime());
|
||||
}
|
||||
else if ((status == Adjacent::STATUS_ACTIVE) &&
|
||||
(infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_INACTIVE);
|
||||
(infoIntTimedOutCount == m_confParam.getInterestRetryNumber())) {
|
||||
m_adjacencyList.setStatusOfNeighbor(neighbor, Adjacent::STATUS_INACTIVE);
|
||||
|
||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor << " status changed to INACTIVE");
|
||||
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
m_lsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,15 +187,14 @@ void
|
||||
HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Received data for INFO(name): " << data.getName());
|
||||
if (data.getSignature().hasKeyLocator()) {
|
||||
if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
NLSR_LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
|
||||
}
|
||||
if (data.getSignature().hasKeyLocator() &&
|
||||
data.getSignature().getKeyLocator().getType() == ndn::tlv::Name) {
|
||||
NLSR_LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
|
||||
}
|
||||
m_nlsr.getValidator().validate(data,
|
||||
std::bind(&HelloProtocol::onContentValidated, this, _1),
|
||||
std::bind(&HelloProtocol::onContentValidationFailed,
|
||||
this, _1, _2));
|
||||
m_confParam.getValidator().validate(data,
|
||||
std::bind(&HelloProtocol::onContentValidated, this, _1),
|
||||
std::bind(&HelloProtocol::onContentValidationFailed,
|
||||
this, _1, _2));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -207,22 +207,24 @@ HelloProtocol::onContentValidated(const ndn::Data& data)
|
||||
if (dataName.get(-3).toUri() == INFO_COMPONENT) {
|
||||
ndn::Name neighbor = dataName.getPrefix(-4);
|
||||
|
||||
Adjacent::Status oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_ACTIVE);
|
||||
m_nlsr.getAdjacencyList().setTimedOutInterestCount(neighbor, 0);
|
||||
Adjacent::Status newStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
Adjacent::Status oldStatus = m_adjacencyList.getStatusOfNeighbor(neighbor);
|
||||
m_adjacencyList.setStatusOfNeighbor(neighbor, Adjacent::STATUS_ACTIVE);
|
||||
m_adjacencyList.setTimedOutInterestCount(neighbor, 0);
|
||||
Adjacent::Status newStatus = m_adjacencyList.getStatusOfNeighbor(neighbor);
|
||||
|
||||
NLSR_LOG_DEBUG("Neighbor : " << neighbor);
|
||||
NLSR_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
|
||||
// change in Adjacency list
|
||||
if ((oldStatus - newStatus) != 0) {
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
else {
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
m_lsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
|
||||
onHelloDataValidated(neighbor);
|
||||
}
|
||||
// increment RCV_HELLO_DATA
|
||||
hpIncrementSignal(Statistics::PacketType::RCV_HELLO_DATA);
|
||||
|
||||
+22
-32
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
#include "statistics.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "route/routing-table.hpp"
|
||||
|
||||
#include <ndn-cxx/util/signal.hpp>
|
||||
#include <ndn-cxx/face.hpp>
|
||||
@@ -31,27 +34,15 @@
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
#include <ndn-cxx/security/v2/validation-error.hpp>
|
||||
#include <ndn-cxx/security/validator-config.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class HelloProtocol
|
||||
{
|
||||
public:
|
||||
HelloProtocol(Nlsr& nlsr, ndn::Scheduler& scheduler);
|
||||
|
||||
/*! \brief Schedules a Hello Interest event.
|
||||
*
|
||||
* This function serves as the Hello Interest loop, and must be
|
||||
* explicitly called to start the Hello cycle. This is done at
|
||||
* NLSR's initialization.
|
||||
*
|
||||
* \sa Nlsr::initialize
|
||||
* \param seconds The number of seconds to wait before calling the event.
|
||||
*/
|
||||
void
|
||||
scheduleInterest(uint32_t seconds);
|
||||
HelloProtocol(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam,
|
||||
RoutingTable& routingTable, Lsdb& lsdb);
|
||||
|
||||
/*! \brief Sends a Hello Interest packet.
|
||||
*
|
||||
@@ -68,19 +59,15 @@ public:
|
||||
expressInterest(const ndn::Name& interestNamePrefix, uint32_t seconds);
|
||||
|
||||
/*! \brief Sends Hello Interests to all neighbors
|
||||
*
|
||||
* \param seconds (ignored)
|
||||
*
|
||||
* This function is called as part of a schedule to regularly
|
||||
* determine the adjacency status of neighbors. This function
|
||||
* creates and sends a Hello Interest to each neighbor in
|
||||
* Nlsr::m_adjacencyList. If the neighbor has not been contacted
|
||||
* before and curerntly has no Face in NFD, this method will call a
|
||||
* different pipeline that creates the Face first, then registers
|
||||
* prefixes.
|
||||
* creates and sends a Hello Interest to the given adjacent.
|
||||
*
|
||||
* \param neighbor the name of the neighbor
|
||||
*/
|
||||
void
|
||||
sendScheduledInterest(uint32_t seconds);
|
||||
sendHelloInterest(const ndn::Name& neighbor);
|
||||
|
||||
/*! \brief Processes a Hello Interest from a neighbor.
|
||||
*
|
||||
@@ -165,15 +152,18 @@ private:
|
||||
onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const ndn::Name& neighbor, const ndn::time::milliseconds& timeout);
|
||||
|
||||
/*! \brief Create a Face for an adjacency
|
||||
* \sa HelloProtocol::onRegistrationSuccess
|
||||
*/
|
||||
void
|
||||
registerPrefixes(const ndn::Name& adjName, const std::string& faceUri,
|
||||
double linkCost, const ndn::time::milliseconds& timeout);
|
||||
public:
|
||||
ndn::util::Signal<HelloProtocol, const ndn::Name&> onHelloDataValidated;
|
||||
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
ndn::Face& m_face;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::security::v2::KeyChain& m_keyChain;
|
||||
const ndn::security::SigningInfo& m_signingInfo;
|
||||
ConfParameter& m_confParam;
|
||||
RoutingTable& m_routingTable;
|
||||
Lsdb& m_lsdb;
|
||||
AdjacencyList& m_adjacencyList;
|
||||
|
||||
static const std::string INFO_COMPONENT;
|
||||
static const std::string NLSR_COMPONENT;
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, 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.
|
||||
*
|
||||
* 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 "lsa-segment-storage.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(LsaSegmentStorage);
|
||||
|
||||
LsaSegmentStorage::LsaSegmentStorage(ndn::Scheduler& scheduler)
|
||||
: m_scheduler(scheduler)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LsaSegmentStorage::connectToFetcher(ndn::util::SegmentFetcher& fetcher)
|
||||
{
|
||||
fetcher.afterSegmentValidated.connect(std::bind(&LsaSegmentStorage::afterFetcherSignalEmitted,
|
||||
this, _1));
|
||||
}
|
||||
|
||||
const ndn::Data*
|
||||
LsaSegmentStorage::getLsaSegment(const ndn::Interest& interest)
|
||||
{
|
||||
ndn::Name lsaSegmentsKey = interest.getName();
|
||||
|
||||
// If this is the first interest then it does not contain the segment number,
|
||||
// so need to append zero segment component at the end to match with the data
|
||||
if (lsaSegmentsKey.size() > 0) {
|
||||
if (!lsaSegmentsKey.get(-1).isSegment()) {
|
||||
lsaSegmentsKey.appendSegment(0);
|
||||
}
|
||||
|
||||
auto it = m_lsaSegments.find(lsaSegmentsKey);
|
||||
if (it == m_lsaSegments.end()) {
|
||||
NLSR_LOG_TRACE("Data for interest: " << interest.getName() << " cannot be found in the lsa storage");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE("Data for interest: " << interest.getName() << " is in the storage.");
|
||||
return &(it->second);
|
||||
}
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_ERROR("Received interest has empty name.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LsaSegmentStorage::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
|
||||
{
|
||||
NLSR_LOG_TRACE("Received a LSA segment: " << lsaSegment.getName());
|
||||
|
||||
// lsaSegmentName is /<router-prefix>/<LS type>/<sequence no.>/<version no.>/<segment no.>
|
||||
auto lsaSegmentName = lsaSegment.getName();
|
||||
|
||||
if (lsaSegmentName.size() > 0) {
|
||||
// lsaSegmentsKey is /<router-prefix>/<LS type>/<sequence no.>/<segment no.>
|
||||
ndn::Name lsaSegmentsKey(lsaSegmentName.getPrefix(lsaSegmentName.size() - 2));
|
||||
lsaSegmentsKey.append(lsaSegmentName.get(-1));
|
||||
|
||||
// No need to store same LSA multiple time
|
||||
if (m_lsaSegments.find(lsaSegmentsKey) == m_lsaSegments.end()) {
|
||||
NLSR_LOG_TRACE("Received LSA segment is new. Storing it in the storage.\n"
|
||||
<< " LSA data name: " << lsaSegmentName);
|
||||
|
||||
// Delete the same LSA with lower sequence number
|
||||
deleteOldLsas(lsaSegmentName);
|
||||
|
||||
m_lsaSegments[lsaSegmentsKey] = lsaSegment;
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE("The received segment is already in the storage.");
|
||||
}
|
||||
|
||||
std::string content(reinterpret_cast<const char*>(lsaSegment.getContent().value()),
|
||||
lsaSegment.getContent().value_size());
|
||||
|
||||
ndn::time::seconds expirationTime(LSA_REFRESH_TIME_DEFAULT);
|
||||
|
||||
std::vector<std::string> options;
|
||||
boost::split(options, content, boost::is_any_of("|"));
|
||||
|
||||
try {
|
||||
expirationTime = ndn::time::duration_cast<ndn::time::seconds>
|
||||
(ndn::time::system_clock::now() - ndn::time::fromIsoString(options.at(3)));
|
||||
} catch (const std::exception& e) {
|
||||
NLSR_LOG_ERROR("Cannot extract expiration time from LSA content: " << e.what());
|
||||
}
|
||||
|
||||
// schedule the segment deletion
|
||||
scheduleLsaSegmentDeletion(lsaSegmentsKey, expirationTime);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_ERROR("The received LSA segment has empty name.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LsaSegmentStorage::deleteOldLsas(const ndn::Name& newLsaName)
|
||||
{
|
||||
auto newLsaKey = newLsaName.getPrefix(newLsaName.size() - 3);
|
||||
auto newSeqNo = newLsaName.get(-3).toNumber();
|
||||
|
||||
std::vector<decltype(m_lsaSegments)::key_type> lsaToDelete;
|
||||
|
||||
for (const auto& segment : m_lsaSegments) {
|
||||
ndn::Name segmentKey = segment.first;
|
||||
auto oldSeqNo = segmentKey.get(-2).toNumber();
|
||||
auto existingLsaKey = segmentKey.getPrefix(segmentKey.size() - 2);
|
||||
|
||||
if (newLsaKey == existingLsaKey) {
|
||||
if (newSeqNo > oldSeqNo) { // in the key the second last component is the sequence number
|
||||
NLSR_LOG_TRACE("Outdated LSA: " << segmentKey << " with seq no: " <<
|
||||
oldSeqNo << " is deleted.");
|
||||
lsaToDelete.push_back(segmentKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& segmentKey : lsaToDelete) {
|
||||
m_lsaSegments.erase(segmentKey);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LsaSegmentStorage::scheduleLsaSegmentDeletion(const ndn::Name& lsaSegmentsKey,
|
||||
ndn::time::seconds expirationTime)
|
||||
{
|
||||
NLSR_LOG_TRACE("Scheduling LSA segment deletion for "
|
||||
<< lsaSegmentsKey << " in: " << expirationTime);
|
||||
m_scheduler.scheduleEvent(expirationTime,
|
||||
[lsaSegmentsKey, this] {
|
||||
m_lsaSegments.erase(lsaSegmentsKey);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,85 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, 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.
|
||||
*
|
||||
* 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/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_LSA_SEGMENT_STORAGE_HPP
|
||||
#define NLSR_LSA_SEGMENT_STORAGE_HPP
|
||||
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
#include <ndn-cxx/util/signal.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class LsaSegmentStorage
|
||||
{
|
||||
public:
|
||||
LsaSegmentStorage(ndn::Scheduler& scheduler);
|
||||
|
||||
/*! \brief Get connected to the signal emitted by SegmentFetcher
|
||||
* \param fetcher The SegmentFetcher to whose signal LsaSegmentStorage will subscribe to.
|
||||
*/
|
||||
void
|
||||
connectToFetcher(ndn::util::SegmentFetcher& fetcher);
|
||||
|
||||
/*! \brief Returns an LSA segment for an interest from LsaSegmentStorage
|
||||
* \param interest Interest corresponding to the returned LSA segment.
|
||||
*/
|
||||
const ndn::Data*
|
||||
getLsaSegment(const ndn::Interest& interest);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*! \brief Callback when SegmentFetcher retrieves a segment.
|
||||
*/
|
||||
void
|
||||
afterFetcherSignalEmitted(const ndn::Data& lsaSegment);
|
||||
|
||||
private:
|
||||
/*! \brief Given an LSA name check whether Data for the same name exists in the
|
||||
* LsaSegmentStorage. If the matched LSA data are of a lower sequence number,
|
||||
* then remove them from LsaSegmentStorage.
|
||||
* \param newLsaName Name of the LSA that will be matched against
|
||||
*/
|
||||
void
|
||||
deleteOldLsas(const ndn::Name& newLsaName);
|
||||
|
||||
/*! \brief Schedules the deletion of a LSA data given the segmentKey
|
||||
*/
|
||||
void
|
||||
scheduleLsaSegmentDeletion(const ndn::Name& segmentKey, ndn::time::seconds expirationTime);
|
||||
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
// Key: /<router-prefix>/<LS type>/<sequence no.>/<segment no.>
|
||||
// Value: corresponding LSA data packet
|
||||
// Data name: /<router-prefix>/<LS type>/<sequence no.>/<version no.>/<segment no.>
|
||||
std::unordered_map<ndn::Name, ndn::Data> m_lsaSegments;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_LSA_SEGMENT_STORAGE_HPP
|
||||
+8
-23
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -138,7 +138,7 @@ CoordinateLsa::CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
}
|
||||
|
||||
bool
|
||||
CoordinateLsa::isEqualContent(const CoordinateLsa& clsa)
|
||||
CoordinateLsa::isEqualContent(const CoordinateLsa& clsa) const
|
||||
{
|
||||
if (clsa.getCorTheta().size() != m_angles.size()) {
|
||||
return false;
|
||||
@@ -213,7 +213,7 @@ AdjLsa::AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
}
|
||||
|
||||
bool
|
||||
AdjLsa::isEqualContent(AdjLsa& alsa)
|
||||
AdjLsa::isEqualContent(const AdjLsa& alsa) const
|
||||
{
|
||||
return m_adl == alsa.getAdl();
|
||||
}
|
||||
@@ -248,11 +248,16 @@ AdjLsa::deserialize(const std::string& content) noexcept
|
||||
ndn::Name adjName(*tok_iter++);
|
||||
std::string connectingFaceUri(*tok_iter++);
|
||||
double linkCost = boost::lexical_cast<double>(*tok_iter++);
|
||||
|
||||
Adjacent adjacent(adjName, ndn::FaceUri(connectingFaceUri), linkCost,
|
||||
Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
addAdjacent(adjacent);
|
||||
}
|
||||
}
|
||||
// Ignore neighbors with negative cost received from the Adjacent LSA data.
|
||||
catch (const ndn::tlv::Error& e) {
|
||||
NLSR_LOG_ERROR(e.what());
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_ERROR("Could not deserialize from content: " << e.what());
|
||||
return false;
|
||||
@@ -260,26 +265,6 @@ AdjLsa::deserialize(const std::string& content) noexcept
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AdjLsa::removeNptEntries(Nlsr& pnlsr)
|
||||
{
|
||||
if (getOrigRouter() != pnlsr.getConfParameter().getRouterPrefix()) {
|
||||
pnlsr.getNamePrefixTable().removeEntry(getOrigRouter(), getOrigRouter());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AdjLsa::writeLog() const
|
||||
{
|
||||
|
||||
+23
-49
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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_LSA_HPP
|
||||
#define NLSR_LSA_HPP
|
||||
@@ -26,15 +26,12 @@
|
||||
#include "adjacent.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
#include <boost/tokenizer.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Lsa
|
||||
{
|
||||
public:
|
||||
@@ -46,13 +43,8 @@ public:
|
||||
MOCK
|
||||
};
|
||||
|
||||
Lsa()
|
||||
: m_origRouter()
|
||||
, m_lsSeqNo()
|
||||
, m_expirationTimePoint()
|
||||
, m_expiringEventId()
|
||||
{
|
||||
}
|
||||
virtual
|
||||
~Lsa() = default;
|
||||
|
||||
virtual Type
|
||||
getType() const
|
||||
@@ -97,12 +89,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setExpiringEventId(const ndn::EventId leei)
|
||||
setExpiringEventId(ndn::scheduler::EventId eid)
|
||||
{
|
||||
m_expiringEventId = leei;
|
||||
m_expiringEventId = std::move(eid);
|
||||
}
|
||||
|
||||
ndn::EventId
|
||||
ndn::scheduler::EventId
|
||||
getExpiringEventId() const
|
||||
{
|
||||
return m_expiringEventId;
|
||||
@@ -150,17 +142,15 @@ protected:
|
||||
|
||||
protected:
|
||||
ndn::Name m_origRouter;
|
||||
uint32_t m_lsSeqNo;
|
||||
uint32_t m_lsSeqNo = 0;
|
||||
ndn::time::system_clock::TimePoint m_expirationTimePoint;
|
||||
ndn::EventId m_expiringEventId;
|
||||
ndn::scheduler::EventId m_expiringEventId;
|
||||
};
|
||||
|
||||
class NameLsa: public Lsa
|
||||
class NameLsa : public Lsa
|
||||
{
|
||||
public:
|
||||
NameLsa()
|
||||
{
|
||||
}
|
||||
NameLsa() = default;
|
||||
|
||||
NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
@@ -229,14 +219,12 @@ private:
|
||||
operator<<(std::ostream& os, const NameLsa& lsa);
|
||||
};
|
||||
|
||||
class AdjLsa: public Lsa
|
||||
class AdjLsa : public Lsa
|
||||
{
|
||||
public:
|
||||
typedef AdjacencyList::const_iterator const_iterator;
|
||||
|
||||
AdjLsa()
|
||||
{
|
||||
}
|
||||
AdjLsa() = default;
|
||||
|
||||
AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
@@ -281,18 +269,7 @@ 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);
|
||||
|
||||
void
|
||||
removeNptEntries(Nlsr& pnlsr);
|
||||
isEqualContent(const AdjLsa& alsa) const;
|
||||
|
||||
void
|
||||
writeLog() const override;
|
||||
@@ -327,13 +304,10 @@ private:
|
||||
operator<<(std::ostream& os, const AdjLsa& lsa);
|
||||
};
|
||||
|
||||
class CoordinateLsa: public Lsa
|
||||
class CoordinateLsa : public Lsa
|
||||
{
|
||||
public:
|
||||
CoordinateLsa()
|
||||
: m_corRad(0)
|
||||
{
|
||||
}
|
||||
CoordinateLsa() = default;
|
||||
|
||||
CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
@@ -359,13 +333,13 @@ public:
|
||||
double
|
||||
getCorRadius() const
|
||||
{
|
||||
return m_corRad;
|
||||
return m_corRad;
|
||||
}
|
||||
|
||||
void
|
||||
setCorRadius(double cr)
|
||||
{
|
||||
m_corRad = cr;
|
||||
m_corRad = cr;
|
||||
}
|
||||
|
||||
const std::vector<double>
|
||||
@@ -381,7 +355,7 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
isEqualContent(const CoordinateLsa& clsa);
|
||||
isEqualContent(const CoordinateLsa& clsa) const;
|
||||
|
||||
void
|
||||
writeLog() const override;
|
||||
@@ -395,7 +369,7 @@ public:
|
||||
serialize() const override;
|
||||
|
||||
private:
|
||||
double m_corRad;
|
||||
double m_corRad = 0.0;
|
||||
std::vector<double> m_angles;
|
||||
|
||||
friend std::ostream&
|
||||
@@ -420,8 +394,8 @@ operator>>(std::istream& is, Lsa::Type& type);
|
||||
} // namespace nlsr
|
||||
|
||||
namespace std {
|
||||
std::string
|
||||
to_string(const nlsr::Lsa::Type& type);
|
||||
std::string
|
||||
to_string(const nlsr::Lsa::Type& type);
|
||||
} // namespace std
|
||||
|
||||
#endif // NLSR_LSA_HPP
|
||||
+293
-337
File diff suppressed because it is too large.
Load diff
+64
-55
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -24,32 +24,32 @@
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "lsa-segment-storage.hpp"
|
||||
#include "sequencing-manager.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "communication/sync-logic-handler.hpp"
|
||||
#include "statistics.hpp"
|
||||
#include "route/name-prefix-table.hpp"
|
||||
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/util/signal.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
#include <ndn-cxx/ims/in-memory-storage-persistent.hpp>
|
||||
|
||||
#include <PSync/segment-publisher.hpp>
|
||||
|
||||
#include <utility>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Lsdb
|
||||
{
|
||||
public:
|
||||
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler);
|
||||
Lsdb(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam,
|
||||
NamePrefixTable& namePrefixTable, RoutingTable& routingTable);
|
||||
|
||||
SyncLogicHandler&
|
||||
getSyncLogicHandler()
|
||||
{
|
||||
return m_sync;
|
||||
}
|
||||
~Lsdb();
|
||||
|
||||
bool
|
||||
isLsaNew(const ndn::Name& routerName, const Lsa::Type& lsaType, const uint64_t& sequenceNumber);
|
||||
@@ -184,40 +184,33 @@ public:
|
||||
m_adjLsaBuildInterval = ndn::time::seconds(interval);
|
||||
}
|
||||
|
||||
const ndn::time::seconds&
|
||||
getAdjLsaBuildInterval() const
|
||||
{
|
||||
return m_adjLsaBuildInterval;
|
||||
}
|
||||
|
||||
SequencingManager&
|
||||
getSequencingManager()
|
||||
{
|
||||
return m_sequencingManager;
|
||||
}
|
||||
|
||||
LsaSegmentStorage&
|
||||
getLsaStorage()
|
||||
{
|
||||
return m_lsaStorage;
|
||||
}
|
||||
|
||||
void
|
||||
writeAdjLsdbLog();
|
||||
|
||||
void
|
||||
setLsaRefreshTime(const ndn::time::seconds& lsaRefreshTime);
|
||||
|
||||
void
|
||||
setThisRouterPrefix(std::string trp);
|
||||
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
ndn::time::steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
/* \brief Process interest which can be either:
|
||||
* 1) Discovery interest from segment fetcher:
|
||||
* /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>
|
||||
* 2) Interest containing segment number:
|
||||
* /localhop/<network>/nlsr/LSA/<site>/<router>/<lsaType>/<seqNo>/<version>/<segmentNo>
|
||||
*/
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
bool
|
||||
getIsBuildAdjLsaSheduled()
|
||||
{
|
||||
return m_isBuildAdjLsaSheduled;
|
||||
}
|
||||
|
||||
SyncLogicHandler&
|
||||
getSync() {
|
||||
return m_sync;
|
||||
}
|
||||
|
||||
private:
|
||||
/* \brief Add a name LSA to the LSDB if it isn't already there.
|
||||
\param nlsa The candidade name LSA.
|
||||
@@ -270,7 +263,7 @@ private:
|
||||
\param seqNo The seq. no. associated with the LSA.
|
||||
\param expTime How many seconds to wait before triggering the event.
|
||||
*/
|
||||
ndn::EventId
|
||||
ndn::scheduler::EventId
|
||||
scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime);
|
||||
|
||||
@@ -287,27 +280,21 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
\param seqNo The sequence number of the LSA to check.
|
||||
\param expTime The number of seconds to wait before triggering the event.
|
||||
*/
|
||||
ndn::EventId
|
||||
ndn::scheduler::EventId
|
||||
scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime);
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
expireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
|
||||
|
||||
ndn::EventId
|
||||
ndn::scheduler::EventId
|
||||
scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime);
|
||||
|
||||
void
|
||||
expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
putLsaData(const ndn::Interest& interest, const std::string& content);
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
processInterestForNameLsa(const ndn::Interest& interest,
|
||||
@@ -323,6 +310,7 @@ private:
|
||||
processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
onContentValidated(const std::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
@@ -356,7 +344,7 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
const ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
@@ -369,27 +357,36 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
|
||||
*/
|
||||
void
|
||||
afterFetchLsa(const ndn::ConstBufferPtr& data, ndn::Name& interestName);
|
||||
afterFetchLsa(const ndn::ConstBufferPtr& data, const ndn::Name& interestName);
|
||||
|
||||
void
|
||||
emitSegmentValidatedSignal(const ndn::Data& data)
|
||||
{
|
||||
afterSegmentValidatedSignal(data);
|
||||
}
|
||||
|
||||
private:
|
||||
ndn::time::system_clock::TimePoint
|
||||
getLsaExpirationTimePoint();
|
||||
|
||||
/*! \brief Cancels an event in the event scheduler. */
|
||||
void
|
||||
cancelScheduleLsaExpiringEvent(ndn::EventId eid);
|
||||
|
||||
public:
|
||||
static const ndn::Name::Component NAME_COMPONENT;
|
||||
|
||||
ndn::util::signal::Signal<Lsdb, Statistics::PacketType> lsaIncrementSignal;
|
||||
ndn::util::signal::Signal<Lsdb, const ndn::Data&> afterSegmentValidatedSignal;
|
||||
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
SyncLogicHandler m_sync;
|
||||
LsaSegmentStorage m_lsaStorage;
|
||||
ndn::Face& m_face;
|
||||
ndn::Scheduler m_scheduler;
|
||||
|
||||
ConfParameter& m_confParam;
|
||||
NamePrefixTable& m_namePrefixTable;
|
||||
RoutingTable& m_routingTable;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
SyncLogicHandler m_sync;
|
||||
|
||||
private:
|
||||
std::list<NameLsa> m_nameLsdb;
|
||||
std::list<AdjLsa> m_adjLsdb;
|
||||
std::list<CoordinateLsa> m_corLsdb;
|
||||
@@ -406,11 +403,23 @@ private:
|
||||
static const ndn::time::seconds GRACE_PERIOD;
|
||||
static const ndn::time::steady_clock::TimePoint DEFAULT_LSA_RETRIEVAL_DEADLINE;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::time::seconds m_adjLsaBuildInterval;
|
||||
|
||||
SequencingManager m_sequencingManager;
|
||||
|
||||
private:
|
||||
ndn::util::signal::ScopedConnection m_onNewLsaConnection;
|
||||
|
||||
std::set<std::shared_ptr<ndn::util::SegmentFetcher>> m_fetchers;
|
||||
psync::SegmentPublisher m_segmentPublisher;
|
||||
|
||||
bool m_isBuildAdjLsaSheduled;
|
||||
int64_t m_adjBuildCount;
|
||||
ndn::scheduler::ScopedEventId m_scheduledAdjLsaBuild;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::InMemoryStoragePersistent m_lsaStorage;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+61
-27
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,14 +19,16 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include "nlsr-runner.hpp"
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "security/certificate-store.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
#include <sstream>
|
||||
|
||||
template<typename E>
|
||||
std::string
|
||||
static std::string
|
||||
getExtendedErrorMessage(const E& exception)
|
||||
{
|
||||
std::ostringstream errorMessage;
|
||||
@@ -46,41 +48,73 @@ getExtendedErrorMessage(const E& exception)
|
||||
return errorMessage.str();
|
||||
}
|
||||
|
||||
int
|
||||
main(int32_t argc, char** argv)
|
||||
static void
|
||||
printUsage(std::ostream& os, const std::string& programName)
|
||||
{
|
||||
using namespace nlsr;
|
||||
os << "Usage: " << programName << " [OPTIONS...]\n"
|
||||
<< "\n"
|
||||
<< "Options:\n"
|
||||
<< " -f <FILE> Path to configuration file\n"
|
||||
<< " -h Display this help message\n"
|
||||
<< " -V Display version information\n"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
std::string programName(argv[0]);
|
||||
std::string configFileName("nlsr.conf");
|
||||
|
||||
std::string configFileName = "nlsr.conf";
|
||||
|
||||
int32_t opt;
|
||||
while ((opt = getopt(argc, argv, "df:hV")) != -1) {
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "hf:V")) != -1) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
configFileName = optarg;
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << NLSR_VERSION_BUILD_STRING << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
NlsrRunner::printUsage(programName);
|
||||
return EXIT_FAILURE;
|
||||
case 'h':
|
||||
printUsage(std::cout, programName);
|
||||
return 0;
|
||||
case 'f':
|
||||
configFileName = optarg;
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << NLSR_VERSION_BUILD_STRING << std::endl;
|
||||
return 0;
|
||||
default:
|
||||
printUsage(std::cerr, programName);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
NlsrRunner runner(configFileName);
|
||||
boost::asio::io_service ioService;
|
||||
ndn::Face face(ioService);
|
||||
ndn::KeyChain keyChain;
|
||||
|
||||
nlsr::ConfParameter confParam(face, keyChain, configFileName);
|
||||
nlsr::ConfFileProcessor configProcessor(confParam);
|
||||
|
||||
if (!configProcessor.processConfFile()) {
|
||||
std::cerr << "Error in configuration file processing" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
// Since confParam is already populated, key is initialized here before
|
||||
// and independent of the NLSR class
|
||||
auto certificate = confParam.initializeKey();
|
||||
|
||||
nlsr::Nlsr nlsr(face, keyChain, confParam);
|
||||
|
||||
nlsr::security::CertificateStore certStore(face, confParam, nlsr.getLsdb());
|
||||
|
||||
if (certificate) {
|
||||
certStore.insert(*certificate);
|
||||
}
|
||||
|
||||
try {
|
||||
runner.run();
|
||||
face.processEvents();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << getExtendedErrorMessage(e) << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
nlsr.getFib().clean();
|
||||
std::cerr << "FATAL: " << getExtendedErrorMessage(e) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, 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.
|
||||
*
|
||||
* 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 "nlsr-runner.hpp"
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(NlsrRunner);
|
||||
|
||||
NlsrRunner::NlsrRunner(std::string& configFileName)
|
||||
: m_scheduler(m_ioService)
|
||||
, m_face(m_ioService)
|
||||
, m_nlsr(m_ioService, m_scheduler, m_face, m_keyChain)
|
||||
{
|
||||
m_nlsr.setConfFileName(configFileName);
|
||||
}
|
||||
|
||||
void
|
||||
NlsrRunner::run()
|
||||
{
|
||||
ConfFileProcessor configProcessor(m_nlsr, m_nlsr.getConfFileName());
|
||||
|
||||
if (!configProcessor.processConfFile()) {
|
||||
BOOST_THROW_EXCEPTION(Error("Error in configuration file processing! Exiting from NLSR"));
|
||||
}
|
||||
|
||||
/** Because URI canonization needs to occur before initialization,
|
||||
we have to pass initialize as the finally() in neighbor
|
||||
canonization.
|
||||
*/
|
||||
m_nlsr.canonizeNeighborUris(m_nlsr.getAdjacencyList().getAdjList().begin(),
|
||||
[this] (std::list<Adjacent>::iterator iterator) {
|
||||
m_nlsr.canonizeContinuation(iterator, [this] {
|
||||
m_nlsr.initialize();
|
||||
});
|
||||
},
|
||||
[this] {
|
||||
m_nlsr.initialize();
|
||||
});
|
||||
try {
|
||||
m_nlsr.startEventLoop();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_FATAL("ERROR: " << e.what());
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
|
||||
m_nlsr.getFib().clean();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NlsrRunner::printUsage(const std::string& programName)
|
||||
{
|
||||
std::cout << "Usage: " << programName << " [OPTIONS...]" << std::endl;
|
||||
std::cout << " NDN routing...." << std::endl;
|
||||
std::cout << " -f <FILE> Specify configuration file name" << std::endl;
|
||||
std::cout << " -V Display version information" << std::endl;
|
||||
std::cout << " -h Display this help message" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, 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.
|
||||
*
|
||||
* 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/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_NLSR_RUNNER_HPP
|
||||
#define NLSR_NLSR_RUNNER_HPP
|
||||
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
// boost needs to be included after ndn-cxx, otherwise there will be conflict with _1, _2, ...
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/*! \brief A wrapper class to instantiate and configure an NLSR object.
|
||||
*
|
||||
* As its name suggests, this class is responsible for running
|
||||
* NLSR. It creates an nlsr::ConfFileProcessor to read a configuration
|
||||
* file and uses that to configure and then start an NLSR process.
|
||||
* This class only exists to provide this functionality, and there is
|
||||
* no special reliance of NLSR on this class.
|
||||
*/
|
||||
|
||||
class NlsrRunner
|
||||
{
|
||||
public:
|
||||
class Error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
Error(const std::string& what)
|
||||
: std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
explicit
|
||||
NlsrRunner(std::string& configFileName);
|
||||
|
||||
/*! \brief Instantiate, configure, and start the NLSR process.
|
||||
*
|
||||
* Each NlsrRunner is uniquely paired to the Face it's instantiated
|
||||
* with. This is *not* a factory-type class, but a one-to-one
|
||||
* relationship. If one wants to create multiple NLSR classes,
|
||||
* multiple NLSR runners need to be created, too.
|
||||
*
|
||||
* \throws Error If the configuration file cannot be processed. NLSR
|
||||
* is not started.
|
||||
*
|
||||
* \sa Nlsr::canonizeNeighborUris
|
||||
*/
|
||||
void
|
||||
run();
|
||||
|
||||
static void
|
||||
printUsage(const std::string& programName);
|
||||
|
||||
private:
|
||||
boost::asio::io_service m_ioService;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::Face m_face;
|
||||
ndn::KeyChain m_keyChain;
|
||||
Nlsr m_nlsr;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_NLSR_RUNNER_HPP
|
||||
+150
-363
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -39,51 +39,123 @@ INIT_LOGGER(Nlsr);
|
||||
|
||||
const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
|
||||
|
||||
Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face, ndn::KeyChain& keyChain)
|
||||
: m_nlsrFace(face)
|
||||
, m_scheduler(scheduler)
|
||||
Nlsr::Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam)
|
||||
: m_face(face)
|
||||
, m_scheduler(face.getIoService())
|
||||
, m_keyChain(keyChain)
|
||||
, m_confParam()
|
||||
, m_adjacencyList()
|
||||
, m_namePrefixList()
|
||||
, m_configFileName("nlsr.conf")
|
||||
, m_nlsrLsdb(*this, scheduler)
|
||||
, m_adjBuildCount(0)
|
||||
, m_isBuildAdjLsaSheduled(false)
|
||||
, m_isRouteCalculationScheduled(false)
|
||||
, m_isRoutingTableCalculating(false)
|
||||
, m_routingTable(scheduler)
|
||||
, m_fib(m_nlsrFace, scheduler, m_adjacencyList, m_confParam, m_keyChain)
|
||||
, m_namePrefixTable(*this, m_routingTable.afterRoutingChange)
|
||||
, m_dispatcher(m_nlsrFace, m_keyChain)
|
||||
, m_datasetHandler(m_nlsrLsdb,
|
||||
m_routingTable,
|
||||
m_dispatcher,
|
||||
m_nlsrFace,
|
||||
m_keyChain)
|
||||
, m_helloProtocol(*this, scheduler)
|
||||
, m_validator(ndn::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(m_nlsrFace))
|
||||
, m_controller(m_nlsrFace, m_keyChain)
|
||||
, m_faceDatasetController(m_nlsrFace, m_keyChain)
|
||||
, m_confParam(confParam)
|
||||
, m_adjacencyList(confParam.getAdjacencyList())
|
||||
, m_namePrefixList(confParam.getNamePrefixList())
|
||||
, m_validator(m_confParam.getValidator())
|
||||
, m_fib(m_face, m_scheduler, m_adjacencyList, m_confParam, m_keyChain)
|
||||
, m_routingTable(m_scheduler, m_fib, m_lsdb, m_namePrefixTable, m_confParam)
|
||||
, m_namePrefixTable(m_fib, m_routingTable, m_routingTable.afterRoutingChange)
|
||||
, m_lsdb(m_face, m_keyChain, m_confParam, m_namePrefixTable, m_routingTable)
|
||||
, m_helloProtocol(m_face, m_keyChain, confParam, m_routingTable, m_lsdb)
|
||||
, m_onNewLsaConnection(m_lsdb.getSync().onNewLsa->connect(
|
||||
[this] (const ndn::Name& updateName, uint64_t sequenceNumber,
|
||||
const ndn::Name& originRouter) {
|
||||
registerStrategyForCerts(originRouter);
|
||||
}))
|
||||
, m_onPrefixRegistrationSuccess(m_fib.onPrefixRegistrationSuccess.connect(
|
||||
[this] (const ndn::Name& name) {
|
||||
m_helloProtocol.sendHelloInterest(name);
|
||||
}))
|
||||
, m_onHelloDataValidated(m_helloProtocol.onHelloDataValidated.connect(
|
||||
[this] (const ndn::Name& neighbor) {
|
||||
auto it = m_adjacencyList.findAdjacent(neighbor);
|
||||
if (it != m_adjacencyList.end()) {
|
||||
m_fib.registerPrefix(m_confParam.getSyncPrefix(), it->getFaceUri(), it->getLinkCost(),
|
||||
ndn::time::milliseconds::max(), ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
}
|
||||
}))
|
||||
, m_dispatcher(m_face, m_keyChain)
|
||||
, m_datasetHandler(m_dispatcher, m_lsdb, m_routingTable)
|
||||
, m_controller(m_face, m_keyChain)
|
||||
, m_faceDatasetController(m_face, m_keyChain)
|
||||
, m_prefixUpdateProcessor(m_dispatcher,
|
||||
m_nlsrFace,
|
||||
m_namePrefixList,
|
||||
m_nlsrLsdb)
|
||||
m_confParam.getPrefixUpdateValidator(),
|
||||
m_namePrefixList,
|
||||
m_lsdb,
|
||||
m_confParam.getConfFileNameDynamic())
|
||||
, m_nfdRibCommandProcessor(m_dispatcher,
|
||||
m_namePrefixList,
|
||||
m_nlsrLsdb)
|
||||
, m_statsCollector(m_nlsrLsdb, m_helloProtocol)
|
||||
, m_faceMonitor(m_nlsrFace)
|
||||
, m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
|
||||
m_namePrefixList,
|
||||
m_lsdb)
|
||||
, m_statsCollector(m_lsdb, m_helloProtocol)
|
||||
, m_faceMonitor(m_face)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Initializing Nlsr");
|
||||
|
||||
m_faceMonitor.onNotification.connect(std::bind(&Nlsr::onFaceEventNotification, this, _1));
|
||||
m_faceMonitor.start();
|
||||
|
||||
// Do key initialization and registrations first, then initialize faces
|
||||
// which will create routes to neighbor
|
||||
|
||||
setStrategies();
|
||||
|
||||
NLSR_LOG_DEBUG("Default NLSR identity: " << m_confParam.getSigningInfo().getSignerName());
|
||||
|
||||
// Can be moved to HelloProtocol and Lsdb ctor if initializeKey is set
|
||||
// earlier in the Nlsr constructor so as to set m_signingInfo
|
||||
setInfoInterestFilter();
|
||||
setLsaInterestFilter();
|
||||
|
||||
// Add top-level prefixes: router and localhost prefix
|
||||
addDispatcherTopPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"));
|
||||
addDispatcherTopPrefix(LOCALHOST_PREFIX);
|
||||
|
||||
enableIncomingFaceIdIndication();
|
||||
|
||||
registerLocalhostPrefix();
|
||||
registerRouterPrefix();
|
||||
|
||||
initializeFaces(std::bind(&Nlsr::processFaceDataset, this, _1),
|
||||
std::bind(&Nlsr::onFaceDatasetFetchTimeout, this, _1, _2, 0));
|
||||
|
||||
// Could be moved into ctor, but unit tests need to be modified
|
||||
initialize();
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registerStrategyForCerts(const ndn::Name& originRouter)
|
||||
{
|
||||
for (const ndn::Name& router : m_strategySetOnRouters) {
|
||||
if (router == originRouter) {
|
||||
// Have already set strategy for this router's certs once
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_strategySetOnRouters.push_back(originRouter);
|
||||
|
||||
ndn::Name routerKey(originRouter);
|
||||
routerKey.append("KEY");
|
||||
ndn::Name instanceKey(originRouter);
|
||||
instanceKey.append("nlsr").append("KEY");
|
||||
|
||||
m_fib.setStrategy(routerKey, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
m_fib.setStrategy(instanceKey, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
|
||||
ndn::Name siteKey;
|
||||
for (size_t i = 0; i < originRouter.size(); ++i) {
|
||||
if (originRouter[i].toUri() == "%C1.Router") {
|
||||
break;
|
||||
}
|
||||
siteKey.append(originRouter[i]);
|
||||
}
|
||||
ndn::Name opPrefix(siteKey);
|
||||
siteKey.append("KEY");
|
||||
m_fib.setStrategy(siteKey, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
|
||||
opPrefix.append(std::string("%C1.Operator"));
|
||||
m_fib.setStrategy(opPrefix, Fib::BEST_ROUTE_V2_STRATEGY, 0);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registrationFailed(const ndn::Name& name)
|
||||
{
|
||||
NLSR_LOG_ERROR("ERROR: Failed to register prefix in local hub's daemon");
|
||||
NLSR_LOG_ERROR("ERROR: Failed to register prefix " << name << " in local hub's daemon");
|
||||
BOOST_THROW_EXCEPTION(Error("Error: Prefix registration failed"));
|
||||
}
|
||||
|
||||
@@ -97,18 +169,16 @@ void
|
||||
Nlsr::setInfoInterestFilter()
|
||||
{
|
||||
ndn::Name name(m_confParam.getRouterPrefix());
|
||||
name.append("NLSR");
|
||||
name.append("nlsr");
|
||||
name.append("INFO");
|
||||
|
||||
NLSR_LOG_DEBUG("Setting interest filter for Hello interest: " << name);
|
||||
|
||||
getNlsrFace().setInterestFilter(name,
|
||||
std::bind(&HelloProtocol::processInterest,
|
||||
&m_helloProtocol, _1, _2),
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
m_face.setInterestFilter(ndn::InterestFilter(name).allowLoopback(false),
|
||||
std::bind(&HelloProtocol::processInterest, &m_helloProtocol, _1, _2),
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_confParam.getSigningInfo(), ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -118,21 +188,19 @@ Nlsr::setLsaInterestFilter()
|
||||
|
||||
NLSR_LOG_DEBUG("Setting interest filter for LsaPrefix: " << name);
|
||||
|
||||
getNlsrFace().setInterestFilter(name,
|
||||
std::bind(&Lsdb::processInterest,
|
||||
&m_nlsrLsdb, _1, _2),
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
m_face.setInterestFilter(ndn::InterestFilter(name).allowLoopback(false),
|
||||
std::bind(&Lsdb::processInterest, &m_lsdb, _1, _2),
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_confParam.getSigningInfo(), ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Nlsr::addDispatcherTopPrefix(const ndn::Name& topPrefix)
|
||||
{
|
||||
try {
|
||||
m_dispatcher.addTopPrefix(topPrefix, false, m_signingInfo);
|
||||
// false since we want to have control over the registration process
|
||||
m_dispatcher.addTopPrefix(topPrefix, false, m_confParam.getSigningInfo());
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_ERROR("Error setting top-level prefix in dispatcher: " << e.what() << "\n");
|
||||
@@ -142,319 +210,46 @@ Nlsr::addDispatcherTopPrefix(const ndn::Name& topPrefix)
|
||||
void
|
||||
Nlsr::setStrategies()
|
||||
{
|
||||
const std::string strategy("ndn:/localhost/nfd/strategy/multicast");
|
||||
|
||||
m_fib.setStrategy(m_confParam.getLsaPrefix(), strategy, 0);
|
||||
m_fib.setStrategy(m_confParam.getChronosyncPrefix(), strategy, 0);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::canonizeContinuation(std::list<Adjacent>::iterator iterator,
|
||||
std::function<void(void)> finally)
|
||||
{
|
||||
canonizeNeighborUris(iterator, [this, finally] (std::list<Adjacent>::iterator iterator) {
|
||||
canonizeContinuation(iterator, finally);
|
||||
},
|
||||
finally);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::canonizeNeighborUris(std::list<Adjacent>::iterator currentNeighbor,
|
||||
std::function<void(std::list<Adjacent>::iterator)> then,
|
||||
std::function<void(void)> finally)
|
||||
{
|
||||
if (currentNeighbor != m_adjacencyList.getAdjList().end()) {
|
||||
ndn::FaceUri uri(currentNeighbor->getFaceUri());
|
||||
uri.canonize([this, then, currentNeighbor] (ndn::FaceUri canonicalUri) {
|
||||
NLSR_LOG_DEBUG("Canonized URI: " << currentNeighbor->getFaceUri()
|
||||
<< " to: " << canonicalUri);
|
||||
currentNeighbor->setFaceUri(canonicalUri);
|
||||
then(std::next(currentNeighbor));
|
||||
},
|
||||
[this, then, currentNeighbor] (const std::string& reason) {
|
||||
NLSR_LOG_ERROR("Could not canonize URI: " << currentNeighbor->getFaceUri()
|
||||
<< " because: " << reason);
|
||||
then(std::next(currentNeighbor));
|
||||
},
|
||||
m_nlsrFace.getIoService(),
|
||||
TIME_ALLOWED_FOR_CANONIZATION);
|
||||
}
|
||||
// We have finished canonizing all neighbors, so call finally()
|
||||
else {
|
||||
finally();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::loadCertToPublish(const ndn::security::v2::Certificate& certificate)
|
||||
{
|
||||
NLSR_LOG_TRACE("Loading cert to publish.");
|
||||
m_certStore.insert(certificate);
|
||||
m_validator.loadAnchor("Authoritative-Certificate",
|
||||
ndn::security::v2::Certificate(certificate));
|
||||
m_prefixUpdateProcessor.getValidator().
|
||||
loadAnchor("Authoritative-Certificate",
|
||||
ndn::security::v2::Certificate(certificate));
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::connectToFetcher(ndn::util::SegmentFetcher& fetcher)
|
||||
{
|
||||
NLSR_LOG_TRACE("NLSR: Connect to SegmentFetcher.");
|
||||
|
||||
fetcher.afterSegmentValidated.connect(std::bind(&Nlsr::afterFetcherSignalEmitted,
|
||||
this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
|
||||
{
|
||||
NLSR_LOG_TRACE("SegmentFetcher fetched a data segment. Start inserting cert to own cert store.");
|
||||
ndn::Name keyName = lsaSegment.getSignature().getKeyLocator().getName();
|
||||
if (getCertificate(keyName) == nullptr) {
|
||||
publishCertFromCache(keyName);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE("Certificate is already in the store: " << keyName);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::publishCertFromCache(const ndn::Name& keyName)
|
||||
{
|
||||
const ndn::security::v2::Certificate* cert = m_validator.getUnverifiedCertCache()
|
||||
.find(keyName);
|
||||
if (cert != nullptr) {
|
||||
m_certStore.insert(*cert);
|
||||
NLSR_LOG_TRACE(*cert);
|
||||
NLSR_LOG_TRACE("Setting interest filter for: "
|
||||
<< ndn::security::v2::extractKeyNameFromCertName(cert->getName()));
|
||||
m_nlsrFace.setInterestFilter(ndn::security::v2::extractKeyNameFromCertName(cert->getName()),
|
||||
std::bind(&Nlsr::onKeyInterest,
|
||||
this, _1, _2),
|
||||
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
|
||||
if (!cert->getKeyName().equals(cert->getSignature().getKeyLocator().getName())) {
|
||||
publishCertFromCache(cert->getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE("Cert for " << keyName << " was not found in the Validator's cache. ");
|
||||
}
|
||||
m_fib.setStrategy(m_confParam.getLsaPrefix(), Fib::MULTICAST_STRATEGY, 0);
|
||||
m_fib.setStrategy(m_confParam.getSyncPrefix(), Fib::MULTICAST_STRATEGY, 0);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::initialize()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Initializing Nlsr");
|
||||
m_confParam.buildRouterPrefix();
|
||||
m_datasetHandler.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_nlsrLsdb.getSequencingManager().setSeqFileDirectory(m_confParam.getSeqFileDir());
|
||||
m_nlsrLsdb.getSequencingManager().initiateSeqNoFromFile(m_confParam.getHyperbolicState());
|
||||
|
||||
m_nlsrLsdb.getSyncLogicHandler().createSyncSocket(m_confParam.getChronosyncPrefix(),
|
||||
m_confParam.getSyncInterestLifetime());
|
||||
|
||||
// Logging start
|
||||
m_confParam.writeLog();
|
||||
m_adjacencyList.writeLog();
|
||||
NLSR_LOG_DEBUG(m_namePrefixList);
|
||||
// Logging end
|
||||
|
||||
initializeKey();
|
||||
setStrategies();
|
||||
|
||||
NLSR_LOG_DEBUG("Default NLSR identity: " << m_signingInfo.getSignerName());
|
||||
|
||||
setInfoInterestFilter();
|
||||
setLsaInterestFilter();
|
||||
|
||||
// add top-level prefixes: router and localhost prefix
|
||||
addDispatcherTopPrefix(m_confParam.getRouterPrefix());
|
||||
addDispatcherTopPrefix(LOCALHOST_PREFIX);
|
||||
|
||||
initializeFaces(std::bind(&Nlsr::processFaceDataset, this, _1),
|
||||
std::bind(&Nlsr::onFaceDatasetFetchTimeout, this, _1, _2, 0));
|
||||
|
||||
enableIncomingFaceIdIndication();
|
||||
|
||||
// Set event intervals
|
||||
setFirstHelloInterval(m_confParam.getFirstHelloInterval());
|
||||
m_nlsrLsdb.setAdjLsaBuildInterval(m_confParam.getAdjLsaBuildInterval());
|
||||
m_routingTable.setRoutingCalcInterval(m_confParam.getRoutingCalcInterval());
|
||||
|
||||
m_nlsrLsdb.buildAndInstallOwnNameLsa();
|
||||
m_lsdb.buildAndInstallOwnNameLsa();
|
||||
|
||||
// Install coordinate LSAs if using HR or dry-run HR.
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
|
||||
m_lsdb.buildAndInstallOwnCoordinateLsa();
|
||||
}
|
||||
|
||||
registerKeyPrefix();
|
||||
registerLocalhostPrefix();
|
||||
|
||||
m_helloProtocol.scheduleInterest(m_firstHelloInterval);
|
||||
|
||||
// Need to set direct neighbors' costs to 0 for hyperbolic routing
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
|
||||
std::list<Adjacent>& neighbors = m_adjacencyList.getAdjList();
|
||||
|
||||
for (std::list<Adjacent>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) {
|
||||
it->setLinkCost(0);
|
||||
for (auto&& neighbor : m_adjacencyList.getAdjList()) {
|
||||
neighbor.setLinkCost(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::initializeKey()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Initializing Key ...");
|
||||
|
||||
ndn::Name nlsrInstanceName = m_confParam.getRouterPrefix();
|
||||
nlsrInstanceName.append("NLSR");
|
||||
|
||||
try {
|
||||
m_keyChain.deleteIdentity(m_keyChain.getPib().getIdentity(nlsrInstanceName));
|
||||
} catch (const std::exception& e) {
|
||||
NLSR_LOG_WARN(e.what());
|
||||
}
|
||||
|
||||
auto nlsrInstanceIdentity = m_keyChain.createIdentity(nlsrInstanceName);
|
||||
auto nlsrInstanceKey = nlsrInstanceIdentity.getDefaultKey();
|
||||
|
||||
ndn::security::v2::Certificate certificate;
|
||||
|
||||
ndn::Name certificateName = nlsrInstanceKey.getName();
|
||||
certificateName.append("NA");
|
||||
certificateName.appendVersion();
|
||||
certificate.setName(certificateName);
|
||||
|
||||
// set metainfo
|
||||
certificate.setContentType(ndn::tlv::ContentType_Key);
|
||||
certificate.setFreshnessPeriod(ndn::time::days(365));
|
||||
|
||||
// set content
|
||||
certificate.setContent(nlsrInstanceKey.getPublicKey().data(), nlsrInstanceKey.getPublicKey().size());
|
||||
|
||||
// set signature-info
|
||||
ndn::SignatureInfo signatureInfo;
|
||||
signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(ndn::time::system_clock::TimePoint(),
|
||||
ndn::time::system_clock::now()
|
||||
+ ndn::time::days(365)));
|
||||
try {
|
||||
m_keyChain.sign(certificate,
|
||||
ndn::security::SigningInfo(m_keyChain.getPib().getIdentity(m_confParam.getRouterPrefix()))
|
||||
.setSignatureInfo(signatureInfo));
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_WARN("ERROR: Router's " << e.what()
|
||||
<< "NLSR is running without security."
|
||||
<< " If security is enabled NLSR will not converge.");
|
||||
|
||||
std::cerr << "Router's " << e.what() << ". NLSR is running without security "
|
||||
<< "(Only for testing, should not be used in production.)"
|
||||
<< " If security is enabled NLSR will not converge." << std::endl;
|
||||
}
|
||||
|
||||
m_signingInfo = ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID,
|
||||
nlsrInstanceName);
|
||||
|
||||
loadCertToPublish(certificate);
|
||||
|
||||
m_defaultCertName = certificate.getName();
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registerKeyPrefix()
|
||||
{
|
||||
// Start listening for the interest of this router's NLSR certificate
|
||||
ndn::Name nlsrKeyPrefix = getConfParameter().getRouterPrefix();
|
||||
nlsrKeyPrefix.append("NLSR");
|
||||
nlsrKeyPrefix.append("KEY");
|
||||
|
||||
m_nlsrFace.setInterestFilter(nlsrKeyPrefix,
|
||||
std::bind(&Nlsr::onKeyInterest,
|
||||
this, _1, _2),
|
||||
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
|
||||
// Start listening for the interest of this router's certificate
|
||||
ndn::Name routerKeyPrefix = getConfParameter().getRouterPrefix();
|
||||
routerKeyPrefix.append("KEY");
|
||||
|
||||
m_nlsrFace.setInterestFilter(routerKeyPrefix,
|
||||
std::bind(&Nlsr::onKeyInterest,
|
||||
this, _1, _2),
|
||||
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
|
||||
// Start listening for the interest of this router's operator's certificate
|
||||
ndn::Name operatorKeyPrefix = getConfParameter().getNetwork();
|
||||
operatorKeyPrefix.append(getConfParameter().getSiteName());
|
||||
operatorKeyPrefix.append(std::string("%C1.Operator"));
|
||||
|
||||
m_nlsrFace.setInterestFilter(operatorKeyPrefix,
|
||||
std::bind(&Nlsr::onKeyInterest,
|
||||
this, _1, _2),
|
||||
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
|
||||
// Start listening for the interest of this router's site's certificate
|
||||
ndn::Name siteKeyPrefix = getConfParameter().getNetwork();
|
||||
siteKeyPrefix.append(getConfParameter().getSiteName());
|
||||
siteKeyPrefix.append("KEY");
|
||||
|
||||
m_nlsrFace.setInterestFilter(siteKeyPrefix,
|
||||
std::bind(&Nlsr::onKeyInterest,
|
||||
this, _1, _2),
|
||||
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registerLocalhostPrefix()
|
||||
{
|
||||
m_nlsrFace.registerPrefix(LOCALHOST_PREFIX,
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1));
|
||||
m_face.registerPrefix(LOCALHOST_PREFIX,
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
Nlsr::registerRouterPrefix()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Got interest for certificate. Interest: " << interest.getName());
|
||||
|
||||
const ndn::Name& interestName = interest.getName();
|
||||
const ndn::security::v2::Certificate* cert = getCertificate(interestName);
|
||||
|
||||
if (cert == nullptr) {
|
||||
NLSR_LOG_DEBUG("Certificate is not found for: " << interest);
|
||||
return; // cert is not found
|
||||
}
|
||||
|
||||
m_nlsrFace.put(*cert);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::onKeyPrefixRegSuccess(const ndn::Name& name)
|
||||
{
|
||||
NLSR_LOG_DEBUG("KEY prefix: " << name << " registration is successful.");
|
||||
m_face.registerPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"),
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -496,10 +291,10 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
|
||||
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
getRoutingTable().scheduleRoutingTableCalculation(*this);
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
else {
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
m_lsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -516,22 +311,24 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
return;
|
||||
}
|
||||
auto adjacent = m_adjacencyList.findAdjacent(faceUri);
|
||||
uint64_t faceId = faceEventNotification.getFaceId();
|
||||
|
||||
// If we have a neighbor by that FaceUri and it has no FaceId, we
|
||||
// have a match.
|
||||
if (adjacent != m_adjacencyList.end()) {
|
||||
// If we have a neighbor by that FaceUri and it has no FaceId or
|
||||
// the FaceId is different from ours, we have a match.
|
||||
if (adjacent != m_adjacencyList.end() &&
|
||||
(adjacent->getFaceId() == 0 || adjacent->getFaceId() != faceId))
|
||||
{
|
||||
NLSR_LOG_DEBUG("Face creation event matches neighbor: " << adjacent->getName()
|
||||
<< ". New Face ID: " << faceEventNotification.getFaceId()
|
||||
<< ". Registering prefixes.");
|
||||
adjacent->setFaceId(faceEventNotification.getFaceId());
|
||||
<< ". New Face ID: " << faceId << ". Registering prefixes.");
|
||||
adjacent->setFaceId(faceId);
|
||||
|
||||
registerAdjacencyPrefixes(*adjacent, ndn::time::milliseconds::max());
|
||||
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
getRoutingTable().scheduleRoutingTableCalculation(*this);
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
else {
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
m_lsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -557,11 +354,11 @@ Nlsr::processFaceDataset(const std::vector<ndn::nfd::FaceStatus>& faces)
|
||||
NLSR_LOG_DEBUG("Processing face dataset");
|
||||
|
||||
// Iterate over each neighbor listed in nlsr.conf
|
||||
for (auto& adjacent : m_adjacencyList.getAdjList()) {
|
||||
for (auto&& adjacent : m_adjacencyList.getAdjList()) {
|
||||
|
||||
const std::string faceUriString = adjacent.getFaceUri().toString();
|
||||
const std::string& faceUriString = adjacent.getFaceUri().toString();
|
||||
// Check the list of FaceStatus objects we got for a match
|
||||
for (const ndn::nfd::FaceStatus& faceStatus : faces) {
|
||||
for (const auto& faceStatus : faces) {
|
||||
// Set the adjacency FaceID if we find a URI match and it was
|
||||
// previously unset. Change the boolean to true.
|
||||
if (adjacent.getFaceId() == 0 && faceUriString == faceStatus.getRemoteUri()) {
|
||||
@@ -596,10 +393,6 @@ Nlsr::registerAdjacencyPrefixes(const Adjacent& adj,
|
||||
m_fib.registerPrefix(adjName, faceUri, linkCost,
|
||||
timeout, ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
|
||||
m_fib.registerPrefix(m_confParam.getChronosyncPrefix(),
|
||||
faceUri, linkCost, timeout,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
|
||||
m_fib.registerPrefix(m_confParam.getLsaPrefix(),
|
||||
faceUri, linkCost, timeout,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
@@ -634,7 +427,7 @@ Nlsr::scheduleDatasetFetch()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Scheduling Dataset Fetch in " << m_confParam.getFaceDatasetFetchInterval());
|
||||
|
||||
m_scheduler.scheduleEvent(m_confParam.getFaceDatasetFetchInterval(),
|
||||
m_scheduler.schedule(m_confParam.getFaceDatasetFetchInterval(),
|
||||
[this] {
|
||||
this->initializeFaces(
|
||||
[this] (const std::vector<ndn::nfd::FaceStatus>& faces) {
|
||||
@@ -675,10 +468,4 @@ Nlsr::onFaceIdIndicationFailure(const ndn::nfd::ControlResponse& cr)
|
||||
NLSR_LOG_DEBUG(os.str());
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::startEventLoop()
|
||||
{
|
||||
m_nlsrFace.processEvents();
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
+32
-317
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "route/fib.hpp"
|
||||
#include "route/name-prefix-table.hpp"
|
||||
#include "route/routing-table.hpp"
|
||||
#include "security/certificate-store.hpp"
|
||||
#include "update/prefix-update-processor.hpp"
|
||||
#include "update/nfd-rib-command-processor.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
@@ -80,7 +79,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face, ndn::KeyChain& keyChain);
|
||||
Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam);
|
||||
|
||||
void
|
||||
registerStrategyForCerts(const ndn::Name& originRouter);
|
||||
|
||||
void
|
||||
registrationFailed(const ndn::Name& name);
|
||||
@@ -102,79 +104,10 @@ public:
|
||||
void
|
||||
addDispatcherTopPrefix(const ndn::Name& topPrefix);
|
||||
|
||||
void
|
||||
startEventLoop();
|
||||
|
||||
std::string
|
||||
getConfFileName() const
|
||||
{
|
||||
return m_configFileName;
|
||||
}
|
||||
|
||||
void
|
||||
setConfFileName(const std::string& fileName)
|
||||
{
|
||||
m_configFileName = fileName;
|
||||
}
|
||||
|
||||
ConfParameter&
|
||||
getConfParameter()
|
||||
{
|
||||
return m_confParam;
|
||||
}
|
||||
|
||||
const ConfParameter&
|
||||
getConfParameter() const
|
||||
{
|
||||
return m_confParam;
|
||||
}
|
||||
|
||||
AdjacencyList&
|
||||
getAdjacencyList()
|
||||
{
|
||||
return m_adjacencyList;
|
||||
}
|
||||
|
||||
const AdjacencyList&
|
||||
getAdjacencyList() const
|
||||
{
|
||||
return m_adjacencyList;
|
||||
}
|
||||
|
||||
NamePrefixList&
|
||||
getNamePrefixList()
|
||||
{
|
||||
return m_namePrefixList;
|
||||
}
|
||||
|
||||
const NamePrefixList&
|
||||
getNamePrefixList() const
|
||||
{
|
||||
return m_namePrefixList;
|
||||
}
|
||||
|
||||
ndn::Face&
|
||||
getNlsrFace()
|
||||
{
|
||||
return m_nlsrFace;
|
||||
}
|
||||
|
||||
Lsdb&
|
||||
getLsdb()
|
||||
{
|
||||
return m_nlsrLsdb;
|
||||
}
|
||||
|
||||
RoutingTable&
|
||||
getRoutingTable()
|
||||
{
|
||||
return m_routingTable;
|
||||
}
|
||||
|
||||
NamePrefixTable&
|
||||
getNamePrefixTable()
|
||||
{
|
||||
return m_namePrefixTable;
|
||||
return m_lsdb;
|
||||
}
|
||||
|
||||
Fib&
|
||||
@@ -183,66 +116,6 @@ public:
|
||||
return m_fib;
|
||||
}
|
||||
|
||||
long int
|
||||
getAdjBuildCount()
|
||||
{
|
||||
return m_adjBuildCount;
|
||||
}
|
||||
|
||||
void
|
||||
incrementAdjBuildCount()
|
||||
{
|
||||
m_adjBuildCount++;
|
||||
}
|
||||
|
||||
void
|
||||
setAdjBuildCount(int64_t abc)
|
||||
{
|
||||
m_adjBuildCount = abc;
|
||||
}
|
||||
|
||||
bool
|
||||
getIsBuildAdjLsaSheduled()
|
||||
{
|
||||
return m_isBuildAdjLsaSheduled;
|
||||
}
|
||||
|
||||
void
|
||||
setIsBuildAdjLsaSheduled(bool iabls)
|
||||
{
|
||||
m_isBuildAdjLsaSheduled = iabls;
|
||||
}
|
||||
|
||||
bool
|
||||
getIsRoutingTableCalculating()
|
||||
{
|
||||
return m_isRoutingTableCalculating;
|
||||
}
|
||||
|
||||
void
|
||||
setIsRoutingTableCalculating(bool irtc)
|
||||
{
|
||||
m_isRoutingTableCalculating = irtc;
|
||||
}
|
||||
|
||||
bool
|
||||
getIsRouteCalculationScheduled()
|
||||
{
|
||||
return m_isRouteCalculationScheduled;
|
||||
}
|
||||
|
||||
void
|
||||
setIsRouteCalculationScheduled(bool ircs)
|
||||
{
|
||||
m_isRouteCalculationScheduled = ircs;
|
||||
}
|
||||
|
||||
DatasetInterestHandler&
|
||||
getDatasetHandler()
|
||||
{
|
||||
return m_datasetHandler;
|
||||
}
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
||||
@@ -291,183 +164,25 @@ public:
|
||||
registerAdjacencyPrefixes(const Adjacent& adj,
|
||||
const ndn::time::milliseconds& timeout);
|
||||
|
||||
/*! \brief Add a certificate NLSR claims to be authoritative for to the certificate store.
|
||||
*
|
||||
* \sa CertificateStore
|
||||
*/
|
||||
void
|
||||
loadCertToPublish(const ndn::security::v2::Certificate& certificate);
|
||||
|
||||
void
|
||||
connectToFetcher(ndn::util::SegmentFetcher& fetcher);
|
||||
|
||||
/*! \brief Callback when SegmentFetcher retrieves a segment.
|
||||
*/
|
||||
void
|
||||
afterFetcherSignalEmitted(const ndn::Data& lsaSegment);
|
||||
|
||||
/*! \brief Retrieves the chain of certificates from Validator's cache and
|
||||
* store them in Nlsr's own CertificateStore.
|
||||
* \param keyName Name of the first key in the certificate chain.
|
||||
*/
|
||||
void
|
||||
publishCertFromCache(const ndn::Name& keyName);
|
||||
|
||||
void
|
||||
initializeKey();
|
||||
|
||||
void
|
||||
loadValidator(boost::property_tree::ptree section,
|
||||
const std::string& filename)
|
||||
{
|
||||
m_validator.load(section, filename);
|
||||
}
|
||||
|
||||
ndn::security::ValidatorConfig&
|
||||
getValidator()
|
||||
{
|
||||
return m_validator;
|
||||
}
|
||||
|
||||
/*! \brief Find a certificate
|
||||
*
|
||||
* Find a certificate that NLSR has. First it checks against the
|
||||
* certificates this NLSR claims to be authoritative for, usually
|
||||
* something like this specific router's certificate, and then
|
||||
* checks the cache of certficates it has already fetched. If none
|
||||
* can be found, it will return an empty pointer.
|
||||
*/
|
||||
const ndn::security::v2::Certificate*
|
||||
getCertificate(const ndn::Name& certificateKeyName)
|
||||
{
|
||||
const ndn::security::v2::Certificate* cert =
|
||||
m_certStore.find(certificateKeyName);
|
||||
|
||||
return cert;
|
||||
}
|
||||
|
||||
ndn::security::v2::KeyChain&
|
||||
getKeyChain()
|
||||
{
|
||||
return m_keyChain;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
getDefaultCertName()
|
||||
{
|
||||
return m_defaultCertName;
|
||||
}
|
||||
|
||||
const ndn::security::SigningInfo&
|
||||
getSigningInfo()
|
||||
{
|
||||
return m_signingInfo;
|
||||
}
|
||||
|
||||
update::PrefixUpdateProcessor&
|
||||
getPrefixUpdateProcessor()
|
||||
{
|
||||
return m_prefixUpdateProcessor;
|
||||
}
|
||||
|
||||
update::NfdRibCommandProcessor&
|
||||
getNfdRibCommandProcessor()
|
||||
{
|
||||
return m_nfdRibCommandProcessor;
|
||||
}
|
||||
|
||||
ndn::mgmt::Dispatcher&
|
||||
getDispatcher()
|
||||
{
|
||||
return m_dispatcher;
|
||||
}
|
||||
|
||||
void
|
||||
setStrategies();
|
||||
|
||||
uint32_t
|
||||
getFirstHelloInterval() const
|
||||
{
|
||||
return m_firstHelloInterval;
|
||||
}
|
||||
|
||||
/*! \brief Canonize the URI for this and all proceeding neighbors in a list.
|
||||
*
|
||||
* This function canonizes the URI of the Adjacent object pointed to
|
||||
* by currentNeighbor. It then executes the then callback, providing
|
||||
* the next iterator in the list to the callback. A standard
|
||||
* invocation would be to pass the begin() iterator of NLSR's
|
||||
* adjacency list, and to provide Nlsr::canonizeContinuation as the
|
||||
* callback. Because every URI must be canonical before we begin
|
||||
* operations, the canonize function provides a finally() function
|
||||
* to resume whatever needs to occur.
|
||||
*
|
||||
* \sa Nlsr::canonizeContinuation
|
||||
* \sa Nlsr::initialize
|
||||
* \sa NlsrRunner::run
|
||||
*/
|
||||
void
|
||||
canonizeNeighborUris(std::list<Adjacent>::iterator currentNeighbor,
|
||||
std::function<void(std::list<Adjacent>::iterator)> then,
|
||||
std::function<void(void)> finally);
|
||||
|
||||
StatsCollector&
|
||||
getStatsCollector()
|
||||
{
|
||||
return m_statsCollector;
|
||||
}
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
security::CertificateStore&
|
||||
getCertificateStore()
|
||||
{
|
||||
return m_certStore;
|
||||
}
|
||||
|
||||
private:
|
||||
/*! \brief Registers the prefix that NLSR will use for key/certificate interests.
|
||||
*/
|
||||
void
|
||||
registerKeyPrefix();
|
||||
|
||||
/*! \brief Registers the prefix that NLSR will consider to be the machine-local, secure prefix.
|
||||
*/
|
||||
void
|
||||
registerLocalhostPrefix();
|
||||
|
||||
/*! \brief Attempts to satisfy an Interest for a certificate, and send it back.
|
||||
/*! \brief Registers the <router-prefix>/nlsr so that NLSR can respond to status requests from remote routers.
|
||||
*/
|
||||
void
|
||||
onKeyInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
/*! \brief Do nothing.
|
||||
*/
|
||||
void
|
||||
onKeyPrefixRegSuccess(const ndn::Name& name);
|
||||
registerRouterPrefix();
|
||||
|
||||
/*! \brief Do nothing.
|
||||
*/
|
||||
void
|
||||
onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification);
|
||||
|
||||
void
|
||||
setFirstHelloInterval(uint32_t interval)
|
||||
{
|
||||
m_firstHelloInterval = interval;
|
||||
}
|
||||
|
||||
/*! \brief Continues canonizing neighbor URIs.
|
||||
*
|
||||
* For testability reasons, we want what each instance of
|
||||
* canonization does after completion to be controllable. The best
|
||||
* way to do this is to control that by simply passing a
|
||||
* continuation function.
|
||||
*/
|
||||
void
|
||||
canonizeContinuation(std::list<Adjacent>::iterator iterator,
|
||||
std::function<void(void)> finally);
|
||||
|
||||
void
|
||||
scheduleDatasetFetch();
|
||||
|
||||
@@ -491,49 +206,49 @@ public:
|
||||
static const ndn::Name LOCALHOST_PREFIX;
|
||||
|
||||
private:
|
||||
ndn::Face& m_nlsrFace;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
ndn::Face& m_face;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::security::v2::KeyChain& m_keyChain;
|
||||
ConfParameter m_confParam;
|
||||
AdjacencyList m_adjacencyList;
|
||||
NamePrefixList m_namePrefixList;
|
||||
std::string m_configFileName;
|
||||
Lsdb m_nlsrLsdb;
|
||||
int64_t m_adjBuildCount;
|
||||
bool m_isBuildAdjLsaSheduled;
|
||||
bool m_isRouteCalculationScheduled;
|
||||
bool m_isRoutingTableCalculating;
|
||||
RoutingTable m_routingTable;
|
||||
Fib m_fib;
|
||||
NamePrefixTable m_namePrefixTable;
|
||||
|
||||
ndn::mgmt::Dispatcher m_dispatcher;
|
||||
|
||||
DatasetInterestHandler m_datasetHandler;
|
||||
ConfParameter& m_confParam;
|
||||
AdjacencyList& m_adjacencyList;
|
||||
NamePrefixList& m_namePrefixList;
|
||||
bool m_isDaemonProcess;
|
||||
ndn::security::ValidatorConfig& m_validator;
|
||||
std::vector<ndn::Name> m_strategySetOnRouters;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
Fib m_fib;
|
||||
RoutingTable m_routingTable;
|
||||
NamePrefixTable m_namePrefixTable;
|
||||
Lsdb m_lsdb;
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
ndn::security::ValidatorConfig m_validator;
|
||||
private:
|
||||
ndn::util::signal::ScopedConnection m_onNewLsaConnection;
|
||||
ndn::util::signal::ScopedConnection m_onPrefixRegistrationSuccess;
|
||||
ndn::util::signal::ScopedConnection m_onHelloDataValidated;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::mgmt::Dispatcher m_dispatcher;
|
||||
DatasetInterestHandler m_datasetHandler;
|
||||
|
||||
private:
|
||||
/*! \brief Where NLSR stores certificates it claims to be
|
||||
* authoritative for. Usually the router certificate.
|
||||
*/
|
||||
security::CertificateStore m_certStore;
|
||||
|
||||
ndn::nfd::Controller m_controller;
|
||||
ndn::nfd::Controller m_faceDatasetController;
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
ndn::Name m_defaultCertName;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
update::PrefixUpdateProcessor m_prefixUpdateProcessor;
|
||||
update::NfdRibCommandProcessor m_nfdRibCommandProcessor;
|
||||
|
||||
StatsCollector m_statsCollector;
|
||||
|
||||
private:
|
||||
ndn::nfd::FaceMonitor m_faceMonitor;
|
||||
|
||||
uint32_t m_firstHelloInterval;
|
||||
|
||||
friend class NlsrRunner;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -36,13 +36,11 @@ const ndn::PartialName COORDINATES_DATASET = ndn::PartialName("lsdb/coordinates"
|
||||
const ndn::PartialName NAMES_DATASET = ndn::PartialName("lsdb/names");
|
||||
const ndn::PartialName RT_DATASET = ndn::PartialName("routing-table");
|
||||
|
||||
DatasetInterestHandler::DatasetInterestHandler(const Lsdb& lsdb,
|
||||
const RoutingTable& rt,
|
||||
ndn::mgmt::Dispatcher& dispatcher,
|
||||
const ndn::Face& face,
|
||||
const ndn::KeyChain& keyChain)
|
||||
: m_lsdb(lsdb)
|
||||
, m_dispatcher(dispatcher)
|
||||
DatasetInterestHandler::DatasetInterestHandler(ndn::mgmt::Dispatcher& dispatcher,
|
||||
const Lsdb& lsdb,
|
||||
const RoutingTable& rt)
|
||||
: m_dispatcher(dispatcher)
|
||||
, m_lsdb(lsdb)
|
||||
, m_routingTableEntries(rt.getRoutingTableEntry())
|
||||
, m_dryRoutingTableEntries(rt.getDryRoutingTableEntry())
|
||||
{
|
||||
@@ -187,82 +185,4 @@ DatasetInterestHandler::publishRtStatus(const ndn::Name& topPrefix, const ndn::I
|
||||
context.end();
|
||||
}
|
||||
|
||||
template<> std::list<tlv::AdjacencyLsa>
|
||||
getTlvLsas<tlv::AdjacencyLsa>(const Lsdb& lsdb)
|
||||
{
|
||||
std::list<tlv::AdjacencyLsa> lsas;
|
||||
|
||||
auto lsaRange = std::make_pair<std::list<AdjLsa>::const_iterator,
|
||||
std::list<AdjLsa>::const_iterator>(
|
||||
lsdb.getAdjLsdb().cbegin(), lsdb.getAdjLsdb().cend());
|
||||
for (auto lsa = lsaRange.first; lsa != lsaRange.second; lsa++) {
|
||||
tlv::AdjacencyLsa tlvLsa;
|
||||
|
||||
std::shared_ptr<tlv::LsaInfo> tlvLsaInfo = tlv::makeLsaInfo(*lsa);
|
||||
tlvLsa.setLsaInfo(*tlvLsaInfo);
|
||||
|
||||
for (const Adjacent& adj : lsa->getAdl().getAdjList()) {
|
||||
tlv::Adjacency tlvAdj;
|
||||
tlvAdj.setName(adj.getName());
|
||||
tlvAdj.setUri(adj.getFaceUri().toString());
|
||||
tlvAdj.setCost(adj.getLinkCost());
|
||||
tlvLsa.addAdjacency(tlvAdj);
|
||||
}
|
||||
lsas.push_back(tlvLsa);
|
||||
}
|
||||
|
||||
return lsas;
|
||||
|
||||
}
|
||||
|
||||
template<> std::list<tlv::CoordinateLsa>
|
||||
getTlvLsas<tlv::CoordinateLsa>(const Lsdb& lsdb)
|
||||
{
|
||||
std::list<tlv::CoordinateLsa> lsas;
|
||||
|
||||
auto lsaRange = std::make_pair<std::list<CoordinateLsa>::const_iterator,
|
||||
std::list<CoordinateLsa>::const_iterator>(
|
||||
lsdb.getCoordinateLsdb().cbegin(), lsdb.getCoordinateLsdb().cend());
|
||||
|
||||
for (auto lsa = lsaRange.first; lsa != lsaRange.second; lsa++) {
|
||||
tlv::CoordinateLsa tlvLsa;
|
||||
|
||||
std::shared_ptr<tlv::LsaInfo> tlvLsaInfo = tlv::makeLsaInfo(*lsa);
|
||||
tlvLsa.setLsaInfo(*tlvLsaInfo);
|
||||
|
||||
tlvLsa.setHyperbolicRadius(lsa->getCorRadius());
|
||||
tlvLsa.setHyperbolicAngle(lsa->getCorTheta());
|
||||
|
||||
lsas.push_back(tlvLsa);
|
||||
}
|
||||
|
||||
return lsas;
|
||||
|
||||
}
|
||||
|
||||
template<> std::list<tlv::NameLsa>
|
||||
getTlvLsas<tlv::NameLsa>(const Lsdb& lsdb)
|
||||
{
|
||||
std::list<tlv::NameLsa> lsas;
|
||||
|
||||
auto lsaRange = std::make_pair<std::list<NameLsa>::const_iterator,
|
||||
std::list<NameLsa>::const_iterator>(
|
||||
lsdb.getNameLsdb().cbegin(), lsdb.getNameLsdb().cend());
|
||||
for (auto lsa = lsaRange.first; lsa != lsaRange.second; lsa++) {
|
||||
tlv::NameLsa tlvLsa;
|
||||
|
||||
std::shared_ptr<tlv::LsaInfo> tlvLsaInfo = tlv::makeLsaInfo(*lsa);
|
||||
tlvLsa.setLsaInfo(*tlvLsaInfo);
|
||||
|
||||
for (const ndn::Name& name : lsa->getNpl().getNames()) {
|
||||
tlvLsa.addName(name);
|
||||
}
|
||||
|
||||
lsas.push_back(tlvLsa);
|
||||
}
|
||||
|
||||
return lsas;
|
||||
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -72,23 +72,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
DatasetInterestHandler(const Lsdb& lsdb,
|
||||
const RoutingTable& rt,
|
||||
ndn::mgmt::Dispatcher& dispatcher,
|
||||
const ndn::Face& face,
|
||||
const ndn::KeyChain& keyChain);
|
||||
|
||||
ndn::Name&
|
||||
getRouterNameCommandPrefix()
|
||||
{
|
||||
return m_routerNamePrefix;
|
||||
}
|
||||
|
||||
void
|
||||
setRouterNameCommandPrefix(const ndn::Name& routerName) {
|
||||
m_routerNamePrefix = routerName;
|
||||
m_routerNamePrefix.append(Lsdb::NAME_COMPONENT);
|
||||
}
|
||||
DatasetInterestHandler(ndn::mgmt::Dispatcher& dispatcher,
|
||||
const Lsdb& lsdb,
|
||||
const RoutingTable& rt);
|
||||
|
||||
private:
|
||||
/*! \brief set dispatcher for localhost or remote router
|
||||
@@ -126,27 +112,13 @@ private:
|
||||
ndn::mgmt::StatusDatasetContext& context);
|
||||
|
||||
private:
|
||||
const Lsdb& m_lsdb;
|
||||
ndn::Name m_routerNamePrefix;
|
||||
|
||||
ndn::mgmt::Dispatcher& m_dispatcher;
|
||||
const Lsdb& m_lsdb;
|
||||
|
||||
const std::list<RoutingTableEntry>& m_routingTableEntries;
|
||||
const std::list<RoutingTableEntry>& m_dryRoutingTableEntries;
|
||||
};
|
||||
|
||||
template<typename T> std::list<T>
|
||||
getTlvLsas(const Lsdb& lsdb);
|
||||
|
||||
template<> std::list<tlv::AdjacencyLsa>
|
||||
getTlvLsas<tlv::AdjacencyLsa>(const Lsdb& lsdb);
|
||||
|
||||
template<> std::list<tlv::CoordinateLsa>
|
||||
getTlvLsas<tlv::CoordinateLsa>(const Lsdb& lsdb);
|
||||
|
||||
template<> std::list<tlv::NameLsa>
|
||||
getTlvLsas<tlv::NameLsa>(const Lsdb& lsdb);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_PUBLISHER_DATASET_INTEREST_HANDLER_HPP
|
||||
@@ -1,141 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
* Washington University in St. Louis,
|
||||
* Beijing Institute of Technology,
|
||||
* The University of Memphis.
|
||||
*
|
||||
* This file is part of NFD (Named Data Networking Forwarding Daemon).
|
||||
* See AUTHORS.md for complete list of NFD authors and contributors.
|
||||
*
|
||||
* NFD 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.
|
||||
*
|
||||
* NFD 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
|
||||
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
|
||||
#define NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
|
||||
|
||||
#include <ndn-cxx/encoding/encoding-buffer.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/*! \brief provides a publisher of Status Dataset or other segmented octet stream
|
||||
\sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
*/
|
||||
template <class FaceBase>
|
||||
class SegmentPublisher : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
SegmentPublisher(FaceBase& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
const ndn::security::SigningInfo& signingInfo,
|
||||
const ndn::time::milliseconds& freshnessPeriod = getDefaultFreshness())
|
||||
: m_face(face)
|
||||
, m_keyChain(keyChain)
|
||||
, m_signingInfo(signingInfo)
|
||||
, m_freshnessPeriod(freshnessPeriod)
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~SegmentPublisher()
|
||||
{
|
||||
}
|
||||
|
||||
/*! \brief Define the max segment size as half the max NDN packet size.
|
||||
*/
|
||||
static size_t
|
||||
getMaxSegmentSize()
|
||||
{
|
||||
static const size_t MAX_SEGMENT_SIZE = ndn::MAX_NDN_PACKET_SIZE >> 1;
|
||||
return MAX_SEGMENT_SIZE;
|
||||
}
|
||||
|
||||
static constexpr ndn::time::milliseconds
|
||||
getDefaultFreshness()
|
||||
{
|
||||
return ndn::time::milliseconds(1000);
|
||||
}
|
||||
|
||||
/*! \brief Publish data under the provided prefix
|
||||
*
|
||||
* Processes whatever is provided from SegmentPublisher::generate,
|
||||
* by breaking it into segments of MAX_SEGMENT_SIZE and sending each
|
||||
* one individually. The last segment is distinguished by having the
|
||||
* final block ID set to a timestamp.
|
||||
*/
|
||||
void
|
||||
publish(const ndn::Name& prefix)
|
||||
{
|
||||
ndn::EncodingBuffer buffer;
|
||||
generate(buffer);
|
||||
|
||||
const uint8_t* rawBuffer = buffer.buf();
|
||||
const uint8_t* segmentBegin = rawBuffer;
|
||||
const uint8_t* end = rawBuffer + buffer.size();
|
||||
|
||||
ndn::Name segmentPrefix(prefix);
|
||||
segmentPrefix.appendVersion();
|
||||
|
||||
uint64_t segmentNo = 0;
|
||||
do {
|
||||
const uint8_t* segmentEnd = segmentBegin + getMaxSegmentSize();
|
||||
if (segmentEnd > end) {
|
||||
segmentEnd = end;
|
||||
}
|
||||
|
||||
ndn::Name segmentName(segmentPrefix);
|
||||
segmentName.appendSegment(segmentNo);
|
||||
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(segmentName);
|
||||
data->setContent(segmentBegin, segmentEnd - segmentBegin);
|
||||
data->setFreshnessPeriod(m_freshnessPeriod);
|
||||
|
||||
segmentBegin = segmentEnd;
|
||||
if (segmentBegin >= end) {
|
||||
data->setFinalBlockId(segmentName[-1]);
|
||||
}
|
||||
|
||||
publishSegment(data);
|
||||
++segmentNo;
|
||||
} while (segmentBegin < end);
|
||||
}
|
||||
|
||||
protected:
|
||||
/*! \brief In a derived class, write the octets into outBuffer.
|
||||
*/
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) = 0;
|
||||
|
||||
private:
|
||||
/*! \brief Helper function to sign and put data on a Face.
|
||||
*/
|
||||
void
|
||||
publishSegment(std::shared_ptr<ndn::Data>& data)
|
||||
{
|
||||
m_keyChain.sign(*data, m_signingInfo);
|
||||
m_face.put(*data);
|
||||
}
|
||||
|
||||
private:
|
||||
FaceBase& m_face;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
const ndn::security::SigningInfo& m_signingInfo;
|
||||
const ndn::time::milliseconds m_freshnessPeriod;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
|
||||
@@ -1,44 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, 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 A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include "face-map.hpp"
|
||||
#include "common.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(route.FaceMap);
|
||||
|
||||
void
|
||||
FaceMap::writeLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG("------- Face Map-----------");
|
||||
for (const auto& it : m_table) {
|
||||
NLSR_LOG_DEBUG("Face Map Entry (FaceUri: " << (it.second).getFaceUri()
|
||||
<< " Face Id: " << (it.second).getFaceId() << ")");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,121 +0,0 @@
|
||||
/* -*- 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/>.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_FACE_MAP_HPP
|
||||
#define NLSR_FACE_MAP_HPP
|
||||
|
||||
#include "common.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class FaceMapEntry
|
||||
{
|
||||
|
||||
public:
|
||||
FaceMapEntry(const std::string& faceUri, uint32_t faceId)
|
||||
: m_faceUri(faceUri)
|
||||
, m_faceId(faceId)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
setFaceUri(const std::string& faceUri)
|
||||
{
|
||||
m_faceUri = faceUri;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getFaceUri() const
|
||||
{
|
||||
return m_faceUri;
|
||||
}
|
||||
|
||||
void
|
||||
setFaceId(uint32_t faceId)
|
||||
{
|
||||
m_faceId = faceId;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getFaceId() const
|
||||
{
|
||||
return m_faceId;
|
||||
}
|
||||
|
||||
bool
|
||||
compare(const FaceMapEntry& fme)
|
||||
{
|
||||
return m_faceUri == fme.getFaceUri();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_faceUri;
|
||||
uint32_t m_faceId;
|
||||
};
|
||||
|
||||
class FaceMap
|
||||
{
|
||||
|
||||
public:
|
||||
FaceMap()
|
||||
{
|
||||
}
|
||||
|
||||
~FaceMap()
|
||||
{
|
||||
}
|
||||
|
||||
inline void
|
||||
update(const std::string& faceUri, uint32_t faceId)
|
||||
{
|
||||
FaceMapEntry fme(faceUri, faceId);
|
||||
std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
|
||||
if (it == m_table.end()) {
|
||||
m_table.emplace(faceUri, fme);
|
||||
}
|
||||
else {
|
||||
(it->second).setFaceId(fme.getFaceId());
|
||||
}
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
getFaceId(const std::string& faceUri)
|
||||
{
|
||||
FaceMapEntry fme(faceUri, 0);
|
||||
std::map<std::string, FaceMapEntry>::iterator it = m_table.find(faceUri);
|
||||
if (it != m_table.end()) {
|
||||
return (it->second).getFaceId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
std::map<std::string, FaceMapEntry> m_table;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_FACE_MAP_HPP
|
||||
@@ -26,7 +26,7 @@ namespace nlsr {
|
||||
INIT_LOGGER(route.FibEntry);
|
||||
|
||||
void
|
||||
FibEntry::writeLog()
|
||||
FibEntry::writeLog() const
|
||||
{
|
||||
NLSR_LOG_DEBUG("Name Prefix: " << m_name);
|
||||
NLSR_LOG_DEBUG("Seq No: " << m_seqNo);
|
||||
|
||||
+12
-19
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -21,27 +21,20 @@
|
||||
#ifndef NLSR_FIB_ENTRY_HPP
|
||||
#define NLSR_FIB_ENTRY_HPP
|
||||
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
#include "nexthop-list.hpp"
|
||||
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class FibEntry
|
||||
{
|
||||
public:
|
||||
FibEntry()
|
||||
: m_name()
|
||||
, m_seqNo(1)
|
||||
, m_nexthopList()
|
||||
{
|
||||
}
|
||||
FibEntry() = default;
|
||||
|
||||
FibEntry(const ndn::Name& name)
|
||||
: m_seqNo(1)
|
||||
, m_nexthopList()
|
||||
: m_name(name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
@@ -57,12 +50,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setRefreshEventId(ndn::EventId id)
|
||||
setRefreshEventId(ndn::scheduler::EventId id)
|
||||
{
|
||||
m_refreshEventId = id;
|
||||
m_refreshEventId = std::move(id);
|
||||
}
|
||||
|
||||
ndn::EventId
|
||||
ndn::scheduler::EventId
|
||||
getRefreshEventId() const
|
||||
{
|
||||
return m_refreshEventId;
|
||||
@@ -81,7 +74,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
writeLog();
|
||||
writeLog() const;
|
||||
|
||||
typedef NexthopList::const_iterator const_iterator;
|
||||
|
||||
@@ -93,8 +86,8 @@ public:
|
||||
|
||||
private:
|
||||
ndn::Name m_name;
|
||||
ndn::EventId m_refreshEventId;
|
||||
int32_t m_seqNo;
|
||||
ndn::scheduler::EventId m_refreshEventId;
|
||||
int32_t m_seqNo = 1;
|
||||
NexthopList m_nexthopList;
|
||||
};
|
||||
|
||||
|
||||
+101
-125
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -34,21 +34,29 @@ namespace nlsr {
|
||||
INIT_LOGGER(route.Fib);
|
||||
|
||||
const uint64_t Fib::GRACE_PERIOD = 10;
|
||||
const std::string Fib::MULTICAST_STRATEGY("ndn:/localhost/nfd/strategy/multicast");
|
||||
const std::string Fib::BEST_ROUTE_V2_STRATEGY("ndn:/localhost/nfd/strategy/best-route");
|
||||
|
||||
Fib::Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList,
|
||||
ConfParameter& conf, ndn::security::v2::KeyChain& keyChain)
|
||||
: m_scheduler(scheduler)
|
||||
, m_refreshTime(2 * conf.getLsaRefreshTime())
|
||||
, m_controller(face, keyChain)
|
||||
, m_adjacencyList(adjacencyList)
|
||||
, m_confParameter(conf)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Fib::remove(const ndn::Name& name)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Fib::remove called");
|
||||
std::map<ndn::Name, FibEntry>::iterator it = m_table.find(name);
|
||||
if (it != m_table.end()) {
|
||||
for (std::set<NextHop, NextHopComparator>::iterator nhit =
|
||||
(it->second).getNexthopList().getNextHops().begin();
|
||||
nhit != (it->second).getNexthopList().getNextHops().end(); nhit++) {
|
||||
//remove entry from NDN-FIB
|
||||
// Only unregister the prefix if it ISN'T a neighbor.
|
||||
if (isPrefixUpdatable((it->second).getName())) {
|
||||
unregisterPrefix((it->second).getName(), nhit->getConnectingFaceUri());
|
||||
}
|
||||
auto it = m_table.find(name);
|
||||
|
||||
// Only unregister the prefix if it ISN'T a neighbor.
|
||||
if (it != m_table.end() && isNotNeighbor((it->second).getName())) {
|
||||
for (const auto& nexthop : (it->second).getNexthopList().getNextHops()) {
|
||||
unregisterPrefix((it->second).getName(), nexthop.getConnectingFaceUri());
|
||||
}
|
||||
cancelEntryRefresh(it->second);
|
||||
m_table.erase(it);
|
||||
@@ -56,19 +64,21 @@ Fib::remove(const ndn::Name& name)
|
||||
}
|
||||
|
||||
void
|
||||
Fib::addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd)
|
||||
Fib::addNextHopsToFibEntryAndNfd(FibEntry& entry, const NexthopList& hopsToAdd)
|
||||
{
|
||||
const ndn::Name& name = entry.getName();
|
||||
|
||||
for (NexthopList::iterator it = hopsToAdd.begin(); it != hopsToAdd.end(); ++it)
|
||||
bool shouldRegister = isNotNeighbor(name);
|
||||
|
||||
for (const auto& hop : hopsToAdd.getNextHops())
|
||||
{
|
||||
// Add nexthop to FIB entry
|
||||
entry.getNexthopList().addNextHop(*it);
|
||||
entry.getNexthopList().addNextHop(hop);
|
||||
|
||||
if (isPrefixUpdatable(name)) {
|
||||
if (shouldRegister) {
|
||||
// Add nexthop to NDN-FIB
|
||||
registerPrefix(name, ndn::FaceUri(it->getConnectingFaceUri()),
|
||||
it->getRouteCostAsAdjustedInteger(),
|
||||
registerPrefix(name, ndn::FaceUri(hop.getConnectingFaceUri()),
|
||||
hop.getRouteCostAsAdjustedInteger(),
|
||||
ndn::time::seconds(m_refreshTime + GRACE_PERIOD),
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
}
|
||||
@@ -76,11 +86,11 @@ Fib::addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd)
|
||||
}
|
||||
|
||||
void
|
||||
Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
Fib::update(const ndn::Name& name, const NexthopList& allHops)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Fib::update called");
|
||||
|
||||
// Get the max possible faces which is the minumum of the configuration setting and
|
||||
// Get the max possible faces which is the minimum of the configuration setting and
|
||||
// the length of the list of all next hops.
|
||||
unsigned int maxFaces = getNumberOfFacesForName(allHops);
|
||||
|
||||
@@ -88,12 +98,11 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
unsigned int nFaces = 0;
|
||||
|
||||
// Create a list of next hops to be installed with length == maxFaces
|
||||
for (NexthopList::iterator it = allHops.begin(); it != allHops.end() && nFaces < maxFaces;
|
||||
++it, ++nFaces) {
|
||||
for (auto it = allHops.cbegin(); it != allHops.cend() && nFaces < maxFaces; ++it, ++nFaces) {
|
||||
hopsToAdd.addNextHop(*it);
|
||||
}
|
||||
|
||||
std::map<ndn::Name, FibEntry>::iterator entryIt = m_table.find(name);
|
||||
auto entryIt = m_table.find(name);
|
||||
|
||||
// New FIB entry that has nextHops
|
||||
if (entryIt == m_table.end() && hopsToAdd.size() != 0) {
|
||||
@@ -126,9 +135,9 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
hopsToAdd.begin(), hopsToAdd.end(),
|
||||
std::inserter(hopsToRemove, hopsToRemove.end()), NextHopComparator());
|
||||
|
||||
bool isUpdatable = isPrefixUpdatable(entry.getName());
|
||||
bool isUpdatable = isNotNeighbor(entry.getName());
|
||||
// Remove the uninstalled next hops from NFD and FIB entry
|
||||
for (const auto& hop: hopsToRemove){
|
||||
for (const auto& hop : hopsToRemove){
|
||||
if (isUpdatable) {
|
||||
unregisterPrefix(entry.getName(), hop.getConnectingFaceUri());
|
||||
}
|
||||
@@ -142,7 +151,9 @@ Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
entryIt = m_table.find(name);
|
||||
|
||||
}
|
||||
if (entryIt != m_table.end() && !entryIt->second.getRefreshEventId()) {
|
||||
if (entryIt != m_table.end() &&
|
||||
!entryIt->second.getRefreshEventId() &&
|
||||
isNotNeighbor(entryIt->second.getName())) {
|
||||
scheduleEntryRefresh(entryIt->second,
|
||||
[this] (FibEntry& entry) {
|
||||
scheduleLoop(entry);
|
||||
@@ -154,25 +165,19 @@ void
|
||||
Fib::clean()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Fib::clean called");
|
||||
for (std::map<ndn::Name, FibEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end();
|
||||
++it) {
|
||||
NLSR_LOG_DEBUG("Cancelling Scheduled event. Name: " << it->second.getName());
|
||||
cancelEntryRefresh(it->second);
|
||||
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->second).getName(), nhit->getConnectingFaceUri());
|
||||
// can't use const ref here as getNexthopList can't be marked const
|
||||
for (auto&& it : m_table) {
|
||||
NLSR_LOG_DEBUG("Canceling Scheduled event. Name: " << it.second.getName());
|
||||
cancelEntryRefresh(it.second);
|
||||
|
||||
for (const auto& hop : it.second.getNexthopList().getNextHops()) {
|
||||
unregisterPrefix(it.second.getName(), hop.getConnectingFaceUri());
|
||||
}
|
||||
}
|
||||
if (m_table.size() > 0) {
|
||||
m_table.clear();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
Fib::getNumberOfFacesForName(NexthopList& nextHopList)
|
||||
Fib::getNumberOfFacesForName(const NexthopList& nextHopList)
|
||||
{
|
||||
uint32_t nNextHops = static_cast<uint32_t>(nextHopList.getNextHops().size());
|
||||
uint32_t nMaxFaces = m_confParameter.getMaxFacesPerPrefix();
|
||||
@@ -187,23 +192,19 @@ Fib::getNumberOfFacesForName(NexthopList& nextHopList)
|
||||
}
|
||||
|
||||
bool
|
||||
Fib::isPrefixUpdatable(const ndn::Name& name) {
|
||||
if (!m_adjacencyList.isNeighbor(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
Fib::isNotNeighbor(const ndn::Name& name)
|
||||
{
|
||||
return !m_adjacencyList.isNeighbor(name);
|
||||
}
|
||||
|
||||
void
|
||||
Fib::registerPrefix(const ndn::Name& namePrefix, const ndn::FaceUri& faceUri,
|
||||
uint64_t faceCost,
|
||||
const ndn::time::milliseconds& timeout,
|
||||
uint64_t faceCost, const ndn::time::milliseconds& timeout,
|
||||
uint64_t flags, uint8_t times)
|
||||
{
|
||||
uint64_t faceId = m_adjacencyList.getFaceId(ndn::FaceUri(faceUri));
|
||||
uint64_t faceId = m_adjacencyList.getFaceId(faceUri);
|
||||
|
||||
if (faceId != 0) {
|
||||
if (faceId > 0) {
|
||||
ndn::nfd::ControlParameters faceParameters;
|
||||
faceParameters
|
||||
.setName(namePrefix)
|
||||
@@ -215,14 +216,9 @@ Fib::registerPrefix(const ndn::Name& namePrefix, const ndn::FaceUri& faceUri,
|
||||
|
||||
NLSR_LOG_DEBUG("Registering prefix: " << faceParameters.getName() << " faceUri: " << faceUri);
|
||||
m_controller.start<ndn::nfd::RibRegisterCommand>(faceParameters,
|
||||
std::bind(&Fib::onRegistrationSuccess, this, _1,
|
||||
"Successful in name registration",
|
||||
faceUri),
|
||||
std::bind(&Fib::onRegistrationFailure,
|
||||
this, _1,
|
||||
"Failed in name registration",
|
||||
faceParameters,
|
||||
faceUri, times));
|
||||
std::bind(&Fib::onRegistrationSuccess, this, _1, faceUri),
|
||||
std::bind(&Fib::onRegistrationFailure, this, _1,
|
||||
faceParameters, faceUri, times));
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_WARN("Error: No Face Id for face uri: " << faceUri);
|
||||
@@ -230,31 +226,28 @@ Fib::registerPrefix(const ndn::Name& namePrefix, const ndn::FaceUri& faceUri,
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message, const ndn::FaceUri& faceUri)
|
||||
Fib::onRegistrationSuccess(const ndn::nfd::ControlParameters& param,
|
||||
const ndn::FaceUri& faceUri)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << commandSuccessResult.getName() <<
|
||||
" Face Uri: " << faceUri << " faceId: " << commandSuccessResult.getFaceId());
|
||||
NLSR_LOG_DEBUG("Successful in name registration: " << param.getName() <<
|
||||
" Face Uri: " << faceUri << " faceId: " << param.getFaceId());
|
||||
|
||||
AdjacencyList::iterator adjacent = m_adjacencyList.findAdjacent(faceUri);
|
||||
auto adjacent = m_adjacencyList.findAdjacent(faceUri);
|
||||
if (adjacent != m_adjacencyList.end()) {
|
||||
adjacent->setFaceId(commandSuccessResult.getFaceId());
|
||||
adjacent->setFaceId(param.getFaceId());
|
||||
}
|
||||
|
||||
// Update the fast-access FaceMap with the new Face ID, too
|
||||
m_faceMap.update(faceUri.toString(), commandSuccessResult.getFaceId());
|
||||
m_faceMap.writeLog();
|
||||
onPrefixRegistrationSuccess(param.getName());
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
const ndn::FaceUri& faceUri,
|
||||
uint8_t times)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
|
||||
NLSR_LOG_DEBUG("Prefix: " << parameters.getName() << " failed for: " << times);
|
||||
NLSR_LOG_DEBUG("Failed in name registration: " << response.getText() <<
|
||||
" (code: " << response.getCode() << ")");
|
||||
NLSR_LOG_DEBUG("Prefix: " << parameters.getName() << " failed for: " << +times);
|
||||
if (times < 3) {
|
||||
NLSR_LOG_DEBUG("Trying to register again...");
|
||||
registerPrefix(parameters.getName(), faceUri,
|
||||
@@ -270,7 +263,12 @@ Fib::onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
void
|
||||
Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
|
||||
{
|
||||
uint32_t faceId = m_faceMap.getFaceId(faceUri);
|
||||
uint64_t faceId = 0;
|
||||
auto adjacent = m_adjacencyList.findAdjacent(ndn::FaceUri(faceUri));
|
||||
if (adjacent != m_adjacencyList.end()) {
|
||||
faceId = adjacent->getFaceId();
|
||||
}
|
||||
|
||||
NLSR_LOG_DEBUG("Unregister prefix: " << namePrefix << " Face Uri: " << faceUri);
|
||||
if (faceId > 0) {
|
||||
ndn::nfd::ControlParameters controlParameters;
|
||||
@@ -278,30 +276,19 @@ Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
|
||||
.setName(namePrefix)
|
||||
.setFaceId(faceId)
|
||||
.setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
|
||||
|
||||
m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
|
||||
std::bind(&Fib::onUnregistrationSuccess, this, _1,
|
||||
"Successful in unregistering name"),
|
||||
std::bind(&Fib::onUnregistrationFailure,
|
||||
this, _1,
|
||||
"Failed in unregistering name"));
|
||||
[] (const ndn::nfd::ControlParameters& commandSuccessResult) {
|
||||
NLSR_LOG_DEBUG("Unregister successful Prefix: " << commandSuccessResult.getName() <<
|
||||
" Face Id: " << commandSuccessResult.getFaceId());
|
||||
},
|
||||
[] (const ndn::nfd::ControlResponse& response) {
|
||||
NLSR_LOG_DEBUG("Failed in unregistering name" << ": " << response.getText() <<
|
||||
" (code: " << response.getCode() << ")");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onUnregistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Unregister successful Prefix: " << commandSuccessResult.getName() <<
|
||||
" Face Id: " << commandSuccessResult.getFaceId());
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << response.getText() << " (code: " << response.getCode() << ")");
|
||||
}
|
||||
|
||||
void
|
||||
Fib::setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t count)
|
||||
{
|
||||
@@ -311,68 +298,59 @@ Fib::setStrategy(const ndn::Name& name, const std::string& strategy, uint32_t co
|
||||
.setStrategy(strategy);
|
||||
|
||||
m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
|
||||
std::bind(&Fib::onSetStrategySuccess, this, _1,
|
||||
"Successfully set strategy choice"),
|
||||
std::bind(&Fib::onSetStrategySuccess, this, _1),
|
||||
std::bind(&Fib::onSetStrategyFailure, this, _1,
|
||||
parameters,
|
||||
count,
|
||||
"Failed to set strategy choice"));
|
||||
parameters, count));
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message)
|
||||
Fib::onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << commandSuccessResult.getStrategy() << " "
|
||||
<< "for name: " << commandSuccessResult.getName());
|
||||
NLSR_LOG_DEBUG("Successfully set strategy choice: " << commandSuccessResult.getStrategy() <<
|
||||
" for name: " << commandSuccessResult.getName());
|
||||
}
|
||||
|
||||
void
|
||||
Fib::onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message)
|
||||
uint32_t count)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << parameters.getStrategy() << " "
|
||||
<< "for name: " << parameters.getName());
|
||||
NLSR_LOG_DEBUG("Failed to set strategy choice: " << parameters.getStrategy() <<
|
||||
" for name: " << parameters.getName());
|
||||
if (count < 3) {
|
||||
setStrategy(parameters.getName(), parameters.getStrategy().toUri(),count+1);
|
||||
setStrategy(parameters.getName(), parameters.getStrategy().toUri(), count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Fib::scheduleEntryRefresh(FibEntry& entry, const afterRefreshCallback& refreshCallback)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Scheduling refresh for " << entry.getName()
|
||||
<< " Seq Num: " << entry.getSeqNo()
|
||||
<< " in " << m_refreshTime << " seconds");
|
||||
NLSR_LOG_DEBUG("Scheduling refresh for " << entry.getName() <<
|
||||
" Seq Num: " << entry.getSeqNo() <<
|
||||
" in " << m_refreshTime << " seconds");
|
||||
|
||||
entry.setRefreshEventId(m_scheduler.scheduleEvent(ndn::time::seconds(m_refreshTime),
|
||||
std::bind(&Fib::refreshEntry, this,
|
||||
entry.getName(), refreshCallback)));
|
||||
entry.setRefreshEventId(m_scheduler.schedule(ndn::time::seconds(m_refreshTime),
|
||||
std::bind(&Fib::refreshEntry, this,
|
||||
entry.getName(), refreshCallback)));
|
||||
}
|
||||
|
||||
void
|
||||
Fib::scheduleLoop(FibEntry& entry)
|
||||
{
|
||||
scheduleEntryRefresh(entry,
|
||||
std::bind(&Fib::scheduleLoop, this, _1));
|
||||
scheduleEntryRefresh(entry, std::bind(&Fib::scheduleLoop, this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
Fib::cancelEntryRefresh(const FibEntry& entry)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Cancelling refresh for " << entry.getName() << " Seq Num: " << entry.getSeqNo());
|
||||
|
||||
m_scheduler.cancelEvent(entry.getRefreshEventId());
|
||||
entry.getRefreshEventId().reset();
|
||||
NLSR_LOG_DEBUG("Canceling refresh for " << entry.getName() << " Seq Num: " << entry.getSeqNo());
|
||||
entry.getRefreshEventId().cancel();
|
||||
}
|
||||
|
||||
void
|
||||
Fib::refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb)
|
||||
{
|
||||
std::map<ndn::Name, FibEntry>::iterator it = m_table.find(name);
|
||||
|
||||
auto it = m_table.find(name);
|
||||
if (it == m_table.end()) {
|
||||
return;
|
||||
}
|
||||
@@ -381,7 +359,7 @@ Fib::refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb)
|
||||
NLSR_LOG_DEBUG("Refreshing " << entry.getName() << " Seq Num: " << entry.getSeqNo());
|
||||
|
||||
// Increment sequence number
|
||||
entry.setSeqNo(entry.getSeqNo() + 1);
|
||||
entry.setSeqNo(entry.getSeqNo() + 1);
|
||||
|
||||
for (const NextHop& hop : entry) {
|
||||
registerPrefix(entry.getName(),
|
||||
@@ -398,10 +376,8 @@ void
|
||||
Fib::writeLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG("-------------------FIB-----------------------------");
|
||||
for (std::map<ndn::Name, FibEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end();
|
||||
++it) {
|
||||
(it->second).writeLog();
|
||||
for (const auto& entry : m_table) {
|
||||
entry.second.writeLog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+20
-40
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,13 +17,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/>.
|
||||
*
|
||||
**/
|
||||
*/
|
||||
|
||||
#ifndef NLSR_ROUTE_FIB_HPP
|
||||
#define NLSR_ROUTE_FIB_HPP
|
||||
|
||||
#include "face-map.hpp"
|
||||
#include "fib-entry.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
@@ -54,15 +52,8 @@ class FibEntry;
|
||||
class Fib
|
||||
{
|
||||
public:
|
||||
Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList, ConfParameter& conf,
|
||||
ndn::security::v2::KeyChain& keyChain)
|
||||
: m_scheduler(scheduler)
|
||||
, m_refreshTime(0)
|
||||
, m_controller(face, keyChain)
|
||||
, m_adjacencyList(adjacencyList)
|
||||
, m_confParameter(conf)
|
||||
{
|
||||
}
|
||||
Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList,
|
||||
ConfParameter& conf, ndn::security::v2::KeyChain& keyChain);
|
||||
|
||||
/*! \brief Completely remove a name prefix from the FIB.
|
||||
*
|
||||
@@ -72,7 +63,7 @@ public:
|
||||
*
|
||||
* \sa nlsr::NamePrefixTable::removeEntry
|
||||
*/
|
||||
VIRTUAL_WITH_TESTS void
|
||||
void
|
||||
remove(const ndn::Name& name);
|
||||
|
||||
/*! \brief Set the nexthop list of a name.
|
||||
@@ -86,8 +77,8 @@ public:
|
||||
* \param name The name prefix that the next-hops apply to
|
||||
* \param allHops A complete list of next-hops to associate with name.
|
||||
*/
|
||||
VIRTUAL_WITH_TESTS void
|
||||
update(const ndn::Name& name, NexthopList& allHops);
|
||||
void
|
||||
update(const ndn::Name& name, const NexthopList& allHops);
|
||||
|
||||
/*! \brief Remove all entries from the FIB.
|
||||
*
|
||||
@@ -149,7 +140,7 @@ private:
|
||||
* \return Whether the name is NOT associated with a direct neighbor
|
||||
*/
|
||||
bool
|
||||
isPrefixUpdatable(const ndn::Name& name);
|
||||
isNotNeighbor(const ndn::Name& name);
|
||||
|
||||
/*! \brief Does one half of the updating of a FibEntry with new next-hops.
|
||||
*
|
||||
@@ -158,10 +149,10 @@ private:
|
||||
* \sa Fib::removeOldNextHopsFromFibEntryAndNfd
|
||||
*/
|
||||
void
|
||||
addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd);
|
||||
addNextHopsToFibEntryAndNfd(FibEntry& entry, const NexthopList& hopsToAdd);
|
||||
|
||||
unsigned int
|
||||
getNumberOfFacesForName(NexthopList& nextHopList);
|
||||
getNumberOfFacesForName(const NexthopList& nextHopList);
|
||||
|
||||
/*! \brief Unregisters a prefix from NFD's RIB.
|
||||
*
|
||||
@@ -172,43 +163,28 @@ private:
|
||||
/*! \brief Log registration success, and update the Face ID associated with a URI.
|
||||
*/
|
||||
void
|
||||
onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message, const ndn::FaceUri& faceUri);
|
||||
onRegistrationSuccess(const ndn::nfd::ControlParameters& param,
|
||||
const ndn::FaceUri& faceUri);
|
||||
|
||||
/*! \brief Retry a prefix (next-hop) registration up to three (3) times.
|
||||
*/
|
||||
void
|
||||
onRegistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
const ndn::FaceUri& faceUri,
|
||||
uint8_t times);
|
||||
|
||||
/*! \brief Log a successful unregistration.
|
||||
*/
|
||||
void
|
||||
onUnregistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message);
|
||||
|
||||
/*! \brief Log an unregistration failure. Does not retry.
|
||||
*/
|
||||
void
|
||||
onUnregistrationFailure(const ndn::nfd::ControlResponse& response,
|
||||
const std::string& message);
|
||||
|
||||
/*! \brief Log a successful strategy setting.
|
||||
*/
|
||||
void
|
||||
onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message);
|
||||
onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult);
|
||||
|
||||
/*! \brief Retry a strategy setting up to three (3) times.
|
||||
*/
|
||||
void
|
||||
onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
const ndn::nfd::ControlParameters& parameters,
|
||||
uint32_t count,
|
||||
const std::string& message);
|
||||
uint32_t count);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/*! \brief Schedule a refresh event for an entry.
|
||||
@@ -247,13 +223,17 @@ private:
|
||||
void
|
||||
refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb);
|
||||
|
||||
public:
|
||||
static const std::string MULTICAST_STRATEGY;
|
||||
static const std::string BEST_ROUTE_V2_STRATEGY;
|
||||
ndn::util::Signal<Fib, const ndn::Name&> onPrefixRegistrationSuccess;
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
int32_t m_refreshTime;
|
||||
ndn::nfd::Controller m_controller;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
FaceMap m_faceMap;
|
||||
std::map<ndn::Name, FibEntry> m_table;
|
||||
|
||||
private:
|
||||
|
||||
+1
-3
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -54,8 +54,6 @@ namespace detail {
|
||||
|
||||
} // namespace detail
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Map
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -75,8 +75,8 @@ public:
|
||||
return m_rteList.size();
|
||||
}
|
||||
|
||||
NexthopList&
|
||||
getNexthopList()
|
||||
const NexthopList&
|
||||
getNexthopList() const
|
||||
{
|
||||
return m_nexthopList;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,9 +33,10 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(route.NamePrefixTable);
|
||||
|
||||
NamePrefixTable::NamePrefixTable(Nlsr& nlsr,
|
||||
NamePrefixTable::NamePrefixTable(Fib& fib, RoutingTable& routingTable,
|
||||
std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal)
|
||||
: m_nlsr(nlsr)
|
||||
: m_fib(fib)
|
||||
, m_routingTable(routingTable)
|
||||
{
|
||||
m_afterRoutingChangeConnection = afterRoutingChangeSignal->connect(
|
||||
[this] (const std::list<RoutingTableEntry>& entries) {
|
||||
@@ -70,8 +71,7 @@ NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
// 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);
|
||||
RoutingTableEntry* routeEntryPtr = m_routingTable.findRoutingTableEntry(destRouter);
|
||||
|
||||
// We have to create a new routing table entry
|
||||
if (routeEntryPtr == nullptr) {
|
||||
@@ -101,8 +101,8 @@ NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
m_table.push_back(npte);
|
||||
// If this entry has next hops, we need to inform the FIB
|
||||
if (npte->getNexthopList().size() > 0) {
|
||||
NLSR_LOG_TRACE("Updating FIB with next hops for " << npte);
|
||||
m_nlsr.getFib().update(name, npte->getNexthopList());
|
||||
NLSR_LOG_TRACE("Updating FIB with next hops for " << npte->getNamePrefix());
|
||||
m_fib.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
|
||||
@@ -111,24 +111,24 @@ NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
// remain in the Name Prefix Table as a future routing table
|
||||
// calculation may add next hops.
|
||||
else {
|
||||
NLSR_LOG_TRACE(*npte << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
NLSR_LOG_TRACE(npte->getNamePrefix() << " has no next hops; removing from FIB");
|
||||
m_fib.remove(name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
npte = *nameItr;
|
||||
NLSR_LOG_TRACE("Adding origin: " << rtpePtr->getDestination()
|
||||
<< " to existing prefix: " << *nameItr);
|
||||
NLSR_LOG_TRACE("Adding origin: " << rtpePtr->getDestination() <<
|
||||
" to existing prefix: " << **nameItr);
|
||||
(*nameItr)->addRoutingTableEntry(rtpePtr);
|
||||
(*nameItr)->generateNhlfromRteList();
|
||||
|
||||
if ((*nameItr)->getNexthopList().size() > 0) {
|
||||
NLSR_LOG_TRACE("Updating FIB with next hops for " << (*nameItr));
|
||||
m_nlsr.getFib().update(name, (*nameItr)->getNexthopList());
|
||||
NLSR_LOG_TRACE("Updating FIB with next hops for " << (**nameItr));
|
||||
m_fib.update(name, (*nameItr)->getNexthopList());
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE((*nameItr) << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
NLSR_LOG_TRACE(npte->getNamePrefix() << " has no next hops; removing from FIB");
|
||||
m_fib.remove(name);
|
||||
}
|
||||
}
|
||||
// Add the reference to this NPT to the RTPE.
|
||||
@@ -189,13 +189,13 @@ NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
NLSR_LOG_TRACE(**nameItr << " has no routing table entries;"
|
||||
<< " removing from table and FIB");
|
||||
m_table.erase(nameItr);
|
||||
m_nlsr.getFib().remove(name);
|
||||
m_fib.remove(name);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE(**nameItr << " has other routing table entries;"
|
||||
<< " updating FIB with next hops");
|
||||
(*nameItr)->generateNhlfromRteList();
|
||||
m_nlsr.getFib().update(name, (*nameItr)->getNexthopList());
|
||||
m_fib.update(name, (*nameItr)->getNexthopList());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -26,12 +26,12 @@
|
||||
#include "routing-table-pool-entry.hpp"
|
||||
#include "signals.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "route/fib.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
|
||||
class NamePrefixTable
|
||||
{
|
||||
@@ -41,7 +41,8 @@ public:
|
||||
using NptEntryList = std::list<std::shared_ptr<NamePrefixTableEntry>>;
|
||||
using const_iterator = NptEntryList::const_iterator;
|
||||
|
||||
NamePrefixTable(Nlsr& nlsr, std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal);
|
||||
NamePrefixTable(Fib& fib, RoutingTable& routingTable,
|
||||
std::unique_ptr<AfterRoutingChange>& afterRoutingChangeSignal);
|
||||
|
||||
~NamePrefixTable();
|
||||
|
||||
@@ -124,7 +125,8 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
NptEntryList m_table;
|
||||
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
Fib& m_fib;
|
||||
RoutingTable& m_routingTable;
|
||||
ndn::util::signal::Connection m_afterRoutingChangeConnection;
|
||||
};
|
||||
|
||||
|
||||
@@ -107,14 +107,13 @@ NexthopList::removeNextHop(const NextHop& nh)
|
||||
}
|
||||
|
||||
void
|
||||
NexthopList::writeLog()
|
||||
NexthopList::writeLog() const
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
for (std::set<NextHop, NextHopComparator>::iterator it = m_nexthopList.begin();
|
||||
it != m_nexthopList.end() ; it++, i++) {
|
||||
NLSR_LOG_DEBUG("Nexthop " << i << ": " << (*it).getConnectingFaceUri()
|
||||
<< " Route Cost: " << (*it).getRouteCost());
|
||||
for (const auto& nexthop : m_nexthopList) {
|
||||
NLSR_LOG_DEBUG("Nexthop " << i++ << ": " << nexthop.getConnectingFaceUri() <<
|
||||
" Route Cost: " << nexthop.getRouteCost());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
writeLog();
|
||||
writeLog() const;
|
||||
|
||||
private:
|
||||
std::set<NextHop, NextHopComparator> m_nexthopList;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,10 +22,10 @@
|
||||
#include "routing-table-calculator.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "map.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "nexthop.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "adjacent.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
@@ -36,6 +36,11 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(route.RoutingTableCalculator);
|
||||
|
||||
const int LinkStateRoutingTableCalculator::EMPTY_PARENT = -12345;
|
||||
const double LinkStateRoutingTableCalculator::INF_DISTANCE = 2147483647;
|
||||
const int LinkStateRoutingTableCalculator::NO_MAPPING_NUM = -1;
|
||||
const int LinkStateRoutingTableCalculator::NO_NEXT_HOP = -12345;
|
||||
|
||||
void
|
||||
RoutingTableCalculator::allocateAdjMatrix()
|
||||
{
|
||||
@@ -51,27 +56,23 @@ RoutingTableCalculator::initMatrix()
|
||||
{
|
||||
for (size_t i = 0; i < m_nRouters; i++) {
|
||||
for (size_t j = 0; j < m_nRouters; j++) {
|
||||
adjMatrix[i][j] = 0;
|
||||
adjMatrix[i][j] = Adjacent::NON_ADJACENT_COST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map& pMap)
|
||||
RoutingTableCalculator::makeAdjMatrix(const std::list<AdjLsa>& adjLsaList, 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++) {
|
||||
for (const auto& adjLsa : adjLsaList) {
|
||||
ndn::optional<int32_t> row = pMap.getMappingNoByRouterName(adjLsa.getOrigRouter());
|
||||
|
||||
|
||||
ndn::optional<int32_t> row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
|
||||
|
||||
std::list<Adjacent> adl = (*it).getAdl().getAdjList();
|
||||
std::list<Adjacent> adl = adjLsa.getAdl().getAdjList();
|
||||
// For each adjacency represented in the LSA
|
||||
for (std::list<Adjacent>::iterator itAdl = adl.begin(); itAdl != adl.end() ; itAdl++) {
|
||||
|
||||
ndn::optional<int32_t> col = pMap.getMappingNoByRouterName((*itAdl).getName());
|
||||
double cost = (*itAdl).getLinkCost();
|
||||
for (const auto& adjacent : adl) {
|
||||
ndn::optional<int32_t> col = pMap.getMappingNoByRouterName(adjacent.getName());
|
||||
double cost = adjacent.getLinkCost();
|
||||
|
||||
if (row && col && *row < static_cast<int32_t>(m_nRouters)
|
||||
&& *col < static_cast<int32_t>(m_nRouters))
|
||||
@@ -84,8 +85,8 @@ RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map& pMap)
|
||||
// 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 NON_ADJACENT_COST (i.e. broken) or negative,
|
||||
// both direction of the link should have their cost corrected to NON_ADJACENT_COST.
|
||||
//
|
||||
// Otherwise, both sides of the link should use the larger of the two costs.
|
||||
//
|
||||
@@ -98,10 +99,10 @@ RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map& pMap)
|
||||
double fromCost = adjMatrix[col][row];
|
||||
|
||||
if (fromCost != toCost) {
|
||||
double correctedCost = 0.0;
|
||||
double correctedCost = Adjacent::NON_ADJACENT_COST;
|
||||
|
||||
if (toCost != 0 && fromCost != 0) {
|
||||
// If both sides of the link are up, use the larger cost
|
||||
if (toCost >= 0 && fromCost >= 0) {
|
||||
// If both sides of the link are up, use the larger cost else break the link
|
||||
correctedCost = std::max(toCost, fromCost);
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map& pMap)
|
||||
void
|
||||
RoutingTableCalculator::writeAdjMatrixLog(const Map& map) const
|
||||
{
|
||||
if (!getNdnCxxLogger().isLevelEnabled(ndn::util::LogLevel::DEBUG)) {
|
||||
if (!ndn_cxx_getLogger().isLevelEnabled(ndn::util::LogLevel::DEBUG)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ RoutingTableCalculator::writeAdjMatrixLog(const Map& map) const
|
||||
routerIndex += " ";
|
||||
lengthOfDash += "--";
|
||||
NLSR_LOG_DEBUG("Router:" + map.getRouterNameByMappingNo(i)->toUri() +
|
||||
"Index:" + boost::lexical_cast<std::string>(i));
|
||||
" Index:" + boost::lexical_cast<std::string>(i));
|
||||
}
|
||||
NLSR_LOG_DEBUG(" |" + routerIndex);
|
||||
NLSR_LOG_DEBUG(lengthOfDash);
|
||||
@@ -141,8 +142,13 @@ RoutingTableCalculator::writeAdjMatrixLog(const Map& map) const
|
||||
for (size_t i = 0; i < m_nRouters; i++) {
|
||||
std::string line;
|
||||
for (size_t j = 0; j < m_nRouters; j++) {
|
||||
line += boost::lexical_cast<std::string>(adjMatrix[i][j]);
|
||||
line += " ";
|
||||
if (adjMatrix[i][j] == LinkStateRoutingTableCalculator::NO_NEXT_HOP) {
|
||||
line += "0 ";
|
||||
}
|
||||
else {
|
||||
line += boost::lexical_cast<std::string>(adjMatrix[i][j]);
|
||||
line += " ";
|
||||
}
|
||||
}
|
||||
line = boost::lexical_cast<std::string>(i) + "|" + line;
|
||||
NLSR_LOG_DEBUG(line);
|
||||
@@ -157,7 +163,8 @@ RoutingTableCalculator::adjustAdMatrix(int source, int link, double linkCost)
|
||||
adjMatrix[source][i] = linkCost;
|
||||
}
|
||||
else {
|
||||
adjMatrix[source][i] = 0;
|
||||
// if "i" is not a link to the source, set it's cost to a non adjacent value.
|
||||
adjMatrix[source][i] = Adjacent::NON_ADJACENT_COST;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,7 +175,7 @@ RoutingTableCalculator::getNumOfLinkfromAdjMatrix(int sRouter)
|
||||
int noLink = 0;
|
||||
|
||||
for (size_t i = 0; i < m_nRouters; i++) {
|
||||
if (adjMatrix[sRouter][i] > 0) {
|
||||
if (adjMatrix[sRouter][i] >= 0 && i != static_cast<size_t>(sRouter)) { // make sure "i" is not self
|
||||
noLink++;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +189,7 @@ RoutingTableCalculator::getLinksFromAdjMatrix(int* links,
|
||||
int j = 0;
|
||||
|
||||
for (size_t i = 0; i < m_nRouters; i++) {
|
||||
if (adjMatrix[source][i] > 0) {
|
||||
if (adjMatrix[source][i] >= 0 && i != static_cast<size_t>(source)) {// make sure "i" is not self
|
||||
links[j] = i;
|
||||
linkCosts[j] = adjMatrix[source][i];
|
||||
j++;
|
||||
@@ -224,24 +231,25 @@ RoutingTableCalculator::freeLinksCosts()
|
||||
}
|
||||
|
||||
void
|
||||
LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
|
||||
RoutingTable& rt, Nlsr& pnlsr)
|
||||
LinkStateRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt,
|
||||
ConfParameter& confParam,
|
||||
const std::list<AdjLsa>& adjLsaList)
|
||||
{
|
||||
NLSR_LOG_DEBUG("LinkStateRoutingTableCalculator::calculatePath Called");
|
||||
allocateAdjMatrix();
|
||||
initMatrix();
|
||||
makeAdjMatrix(pnlsr, pMap);
|
||||
makeAdjMatrix(adjLsaList, pMap);
|
||||
writeAdjMatrixLog(pMap);
|
||||
ndn::optional<int32_t> sourceRouter =
|
||||
pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix());
|
||||
pMap.getMappingNoByRouterName(confParam.getRouterPrefix());
|
||||
allocateParent(); // These two matrices are used in Dijkstra's algorithm.
|
||||
allocateDistance(); //
|
||||
// We only bother to do the calculation if we have a router by that name.
|
||||
if (sourceRouter && pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1) {
|
||||
if (sourceRouter && confParam.getMaxFacesPerPrefix() == 1) {
|
||||
// In the single path case we can simply run Dijkstra's algorithm.
|
||||
doDijkstraPathCalculation(*sourceRouter);
|
||||
// Inform the routing table of the new next hops.
|
||||
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, *sourceRouter);
|
||||
addAllLsNextHopsToRoutingTable(confParam.getAdjacencyList(), rt, pMap, *sourceRouter);
|
||||
}
|
||||
else {
|
||||
// Multi Path
|
||||
@@ -257,7 +265,7 @@ LinkStateRoutingTableCalculator::calculatePath(Map& pMap,
|
||||
// Do Dijkstra's algorithm using the current neighbor as your start.
|
||||
doDijkstraPathCalculation(*sourceRouter);
|
||||
// Update the routing table with the calculations.
|
||||
addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, *sourceRouter);
|
||||
addAllLsNextHopsToRoutingTable(confParam.getAdjacencyList(), rt, pMap, *sourceRouter);
|
||||
}
|
||||
freeLinks();
|
||||
freeLinksCosts();
|
||||
@@ -294,7 +302,7 @@ LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter)
|
||||
// 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) {
|
||||
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
|
||||
@@ -318,8 +326,9 @@ LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter)
|
||||
}
|
||||
|
||||
void
|
||||
LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
|
||||
Map& pMap, uint32_t sourceRouter)
|
||||
LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(AdjacencyList& adjacencies,
|
||||
RoutingTable& rt, Map& pMap,
|
||||
uint32_t sourceRouter)
|
||||
{
|
||||
NLSR_LOG_DEBUG("LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called");
|
||||
|
||||
@@ -331,7 +340,6 @@ LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, Rou
|
||||
|
||||
// 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) {
|
||||
|
||||
@@ -341,7 +349,7 @@ LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, Rou
|
||||
ndn::optional<ndn::Name> nextHopRouterName= pMap.getRouterNameByMappingNo(nextHopRouter);
|
||||
if (nextHopRouterName) {
|
||||
std::string nextHopFace =
|
||||
pnlsr.getAdjacencyList().getAdjacent(*nextHopRouterName).getFaceUri().toString();
|
||||
adjacencies.getAdjacent(*nextHopRouterName).getFaceUri().toString();
|
||||
// Add next hop to routing table
|
||||
NextHop nh(nextHopFace, routeCost);
|
||||
rt.addNextHop(*(pMap.getRouterNameByMappingNo(i)), nh);
|
||||
@@ -425,8 +433,8 @@ const double HyperbolicRoutingCalculator::UNKNOWN_DISTANCE = -1.0;
|
||||
const double HyperbolicRoutingCalculator::UNKNOWN_RADIUS = -1.0;
|
||||
|
||||
void
|
||||
HyperbolicRoutingCalculator::calculatePaths(Map& map, RoutingTable& rt,
|
||||
Lsdb& lsdb, AdjacencyList& adjacencies)
|
||||
HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
|
||||
Lsdb& lsdb, AdjacencyList& adjacencies)
|
||||
{
|
||||
NLSR_LOG_TRACE("Calculating hyperbolic paths");
|
||||
|
||||
@@ -468,15 +476,14 @@ HyperbolicRoutingCalculator::calculatePaths(Map& map, RoutingTable& rt,
|
||||
|
||||
ndn::optional<ndn::Name> destRouterName = map.getRouterNameByMappingNo(dest);
|
||||
if (destRouterName) {
|
||||
double distance = getHyperbolicDistance(map, lsdb, srcRouterName, *destRouterName);
|
||||
double distance = getHyperbolicDistance(lsdb, srcRouterName, *destRouterName);
|
||||
|
||||
// Could not compute distance
|
||||
if (distance == UNKNOWN_DISTANCE) {
|
||||
NLSR_LOG_WARN("Could not calculate hyperbolic distance from " << srcRouterName << " to " <<
|
||||
*destRouterName);
|
||||
NLSR_LOG_WARN("Could not calculate hyperbolic distance from " << srcRouterName
|
||||
<< " to " << *destRouterName);
|
||||
continue;
|
||||
}
|
||||
|
||||
addNextHop(*destRouterName, srcFaceUri, distance, rt);
|
||||
}
|
||||
}
|
||||
@@ -485,8 +492,7 @@ HyperbolicRoutingCalculator::calculatePaths(Map& map, RoutingTable& rt,
|
||||
}
|
||||
|
||||
double
|
||||
HyperbolicRoutingCalculator::getHyperbolicDistance(Map& map, Lsdb& lsdb,
|
||||
ndn::Name src, ndn::Name dest)
|
||||
HyperbolicRoutingCalculator::getHyperbolicDistance(Lsdb& lsdb, ndn::Name src, ndn::Name dest)
|
||||
{
|
||||
NLSR_LOG_TRACE("Calculating hyperbolic distance from " << src << " to " << dest);
|
||||
|
||||
@@ -615,6 +621,7 @@ HyperbolicRoutingCalculator::calculateHyperbolicDistance(double rI, double rJ,
|
||||
|
||||
if (deltaTheta <= 0.0 || rI <= 0.0 || rJ <= 0.0) {
|
||||
NLSR_LOG_ERROR("Delta theta or rI or rJ is <= 0");
|
||||
NLSR_LOG_ERROR("Please make sure that no two nodes have the exact same HR coordinates");
|
||||
return UNKNOWN_DISTANCE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -23,6 +23,8 @@
|
||||
#define NLSR_ROUTING_TABLE_CALCULATOR_HPP
|
||||
|
||||
#include "common.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
@@ -34,35 +36,35 @@ namespace nlsr {
|
||||
|
||||
class Map;
|
||||
class RoutingTable;
|
||||
class Nlsr;
|
||||
|
||||
class RoutingTableCalculator
|
||||
{
|
||||
public:
|
||||
RoutingTableCalculator()
|
||||
{
|
||||
}
|
||||
RoutingTableCalculator(size_t nRouters)
|
||||
{
|
||||
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. */
|
||||
/*! \brief set NON_ADJACENT_COST i.e. -12345 to every cell of the matrix to
|
||||
ensure that the memory is safe. This is also to incorporate zero cost links */
|
||||
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 adjLsaList The Adjacency Lsa list.
|
||||
\param pMap The map to populate with the adj. data.
|
||||
*/
|
||||
void
|
||||
makeAdjMatrix(Nlsr& pnlsr, Map& pMap);
|
||||
makeAdjMatrix(const std::list<AdjLsa>& adjLsaList, Map& pMap);
|
||||
|
||||
/*! \brief Writes a formated adjacent matrix to DEBUG log
|
||||
\param map The map containing adjacent matrix data
|
||||
*/
|
||||
void
|
||||
writeAdjMatrixLog(const Map& map) const;
|
||||
|
||||
@@ -90,8 +92,8 @@ protected:
|
||||
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.
|
||||
temporary variables will not contain a NON_ADJACENT_COST (-12345) at i,
|
||||
but rather will contain the values for the next valid adjacency.
|
||||
*/
|
||||
void
|
||||
getLinksFromAdjMatrix(int* links, double* linkCosts, int source);
|
||||
@@ -122,6 +124,7 @@ protected:
|
||||
int vNoLink;
|
||||
int* links;
|
||||
double* linkCosts;
|
||||
|
||||
};
|
||||
|
||||
class LinkStateRoutingTableCalculator: public RoutingTableCalculator
|
||||
@@ -129,15 +132,12 @@ class LinkStateRoutingTableCalculator: public RoutingTableCalculator
|
||||
public:
|
||||
LinkStateRoutingTableCalculator(size_t nRouters)
|
||||
: RoutingTableCalculator(nRouters)
|
||||
, EMPTY_PARENT(-12345)
|
||||
, INF_DISTANCE(2147483647)
|
||||
, NO_MAPPING_NUM(-1)
|
||||
, NO_NEXT_HOP(-12345)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);
|
||||
calculatePath(Map& pMap, RoutingTable& rt, ConfParameter& confParam,
|
||||
const std::list<AdjLsa>& adjLsaList);
|
||||
|
||||
private:
|
||||
/*! \brief Performs a Dijkstra's calculation over the adjacency matrix.
|
||||
@@ -154,6 +154,9 @@ private:
|
||||
|
||||
Sorts the list based on distance. The distances are indexed by
|
||||
their mappingNo in dist. Currently uses an insertion sort.
|
||||
|
||||
The cost between two nodes can be zero or greater than zero.
|
||||
|
||||
*/
|
||||
void
|
||||
sortQueueByDistance(int* Q, double* dist, int start, int element);
|
||||
@@ -168,7 +171,7 @@ private:
|
||||
isNotExplored(int* Q, int u, int start, int element);
|
||||
|
||||
void
|
||||
addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
|
||||
addAllLsNextHopsToRoutingTable(AdjacencyList& adjacencies, RoutingTable& rt,
|
||||
Map& pMap, uint32_t sourceRouter);
|
||||
|
||||
/*! \brief Determines a destination's next hop.
|
||||
@@ -194,10 +197,11 @@ private:
|
||||
int* m_parent;
|
||||
double* m_distance;
|
||||
|
||||
const int EMPTY_PARENT;
|
||||
const double INF_DISTANCE;
|
||||
const int NO_MAPPING_NUM;
|
||||
const int NO_NEXT_HOP;
|
||||
static const int EMPTY_PARENT;
|
||||
static const double INF_DISTANCE;
|
||||
static const int NO_MAPPING_NUM;
|
||||
public:
|
||||
static const int NO_NEXT_HOP;
|
||||
|
||||
};
|
||||
|
||||
@@ -215,11 +219,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
calculatePaths(Map& map, RoutingTable& rt, Lsdb& lsdb, AdjacencyList& adjacencies);
|
||||
calculatePath(Map& map, RoutingTable& rt, Lsdb& lsdb, AdjacencyList& adjacencies);
|
||||
|
||||
private:
|
||||
double
|
||||
getHyperbolicDistance(Map& map, Lsdb& lsdb, ndn::Name src, ndn::Name dest);
|
||||
getHyperbolicDistance(Lsdb& lsdb, ndn::Name src, ndn::Name dest);
|
||||
|
||||
void
|
||||
addNextHop(ndn::Name destinationRouter, std::string faceUri, double cost, RoutingTable& rt);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -66,9 +66,8 @@ public:
|
||||
inline bool
|
||||
operator==(RoutingTableEntry& rhs)
|
||||
{
|
||||
return ((*this).getDestination() == rhs.getDestination()
|
||||
&&
|
||||
(*this).getNexthopList() == rhs.getNexthopList());
|
||||
return ((*this).getDestination() == rhs.getDestination() &&
|
||||
(*this).getNexthopList() == rhs.getNexthopList());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -43,8 +43,7 @@ operator<<(std::ostream& os, RoutingTablePoolEntry& rtpe)
|
||||
bool
|
||||
operator==(const RoutingTablePoolEntry& lhs, const RoutingTablePoolEntry& rhs)
|
||||
{
|
||||
return (lhs.getDestination() == rhs.getDestination()
|
||||
&&
|
||||
return (lhs.getDestination() == rhs.getDestination() &&
|
||||
lhs.getNexthopList() == rhs.getNexthopList());
|
||||
}
|
||||
|
||||
|
||||
+75
-98
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -17,6 +17,7 @@
|
||||
* 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.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "map.hpp"
|
||||
@@ -26,7 +27,6 @@
|
||||
#include "name-prefix-table.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
@@ -34,39 +34,43 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(route.RoutingTable);
|
||||
|
||||
RoutingTable::RoutingTable(ndn::Scheduler& scheduler)
|
||||
: afterRoutingChange{ndn::make_unique<AfterRoutingChange>()}
|
||||
RoutingTable::RoutingTable(ndn::Scheduler& scheduler, Fib& fib, Lsdb& lsdb,
|
||||
NamePrefixTable& namePrefixTable, ConfParameter& confParam)
|
||||
: afterRoutingChange{std::make_unique<AfterRoutingChange>()}
|
||||
, m_scheduler(scheduler)
|
||||
, m_NO_NEXT_HOP{-12345}
|
||||
, m_routingCalcInterval{static_cast<uint32_t>(ROUTING_CALC_INTERVAL_DEFAULT)}
|
||||
, m_fib(fib)
|
||||
, m_lsdb(lsdb)
|
||||
, m_namePrefixTable(namePrefixTable)
|
||||
, m_routingCalcInterval{confParam.getRoutingCalcInterval()}
|
||||
, m_isRoutingTableCalculating(false)
|
||||
, m_isRouteCalculationScheduled(false)
|
||||
, m_confParam(confParam)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::calculate(Nlsr& pnlsr)
|
||||
RoutingTable::calculate()
|
||||
{
|
||||
pnlsr.getLsdb().writeCorLsdbLog();
|
||||
pnlsr.getLsdb().writeNameLsdbLog();
|
||||
pnlsr.getLsdb().writeAdjLsdbLog();
|
||||
pnlsr.getNamePrefixTable().writeLog();
|
||||
if (pnlsr.getIsRoutingTableCalculating() == false) {
|
||||
//setting routing table calculation
|
||||
pnlsr.setIsRoutingTableCalculating(true);
|
||||
m_lsdb.writeCorLsdbLog();
|
||||
m_lsdb.writeNameLsdbLog();
|
||||
m_lsdb.writeAdjLsdbLog();
|
||||
m_namePrefixTable.writeLog();
|
||||
if (m_isRoutingTableCalculating == false) {
|
||||
// setting routing table calculation
|
||||
m_isRoutingTableCalculating = true;
|
||||
|
||||
bool isHrEnabled = pnlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF;
|
||||
bool isHrEnabled = m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF;
|
||||
|
||||
if ((!isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(ndn::Name{pnlsr.getConfParameter().getRouterPrefix()}
|
||||
if ((!isHrEnabled &&
|
||||
m_lsdb
|
||||
.doesLsaExist(ndn::Name{m_confParam.getRouterPrefix()}
|
||||
.append(std::to_string(Lsa::Type::ADJACENCY)), Lsa::Type::ADJACENCY))
|
||||
||
|
||||
(isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(ndn::Name{pnlsr.getConfParameter().getRouterPrefix()}
|
||||
(isHrEnabled &&
|
||||
m_lsdb
|
||||
.doesLsaExist(ndn::Name{m_confParam.getRouterPrefix()}
|
||||
.append(std::to_string(Lsa::Type::COORDINATE)), Lsa::Type::COORDINATE))) {
|
||||
if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
|
||||
if (m_lsdb.getIsBuildAdjLsaSheduled() != 1) {
|
||||
NLSR_LOG_TRACE("Clearing old routing table");
|
||||
clearRoutingTable();
|
||||
// for dry run options
|
||||
@@ -75,24 +79,24 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
NLSR_LOG_DEBUG("Calculating routing table");
|
||||
|
||||
// calculate Link State routing
|
||||
if ((pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF)
|
||||
|| (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN)) {
|
||||
calculateLsRoutingTable(pnlsr);
|
||||
if ((m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF)
|
||||
|| (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN)) {
|
||||
calculateLsRoutingTable();
|
||||
}
|
||||
//calculate hyperbolic routing
|
||||
if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
calculateHypRoutingTable(pnlsr);
|
||||
// calculate hyperbolic routing
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
calculateHypRoutingTable(false);
|
||||
}
|
||||
//calculate dry hyperbolic routing
|
||||
if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
calculateHypDryRoutingTable(pnlsr);
|
||||
// calculate dry hyperbolic routing
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
calculateHypRoutingTable(true);
|
||||
}
|
||||
// Inform the NPT that updates have been made
|
||||
NLSR_LOG_DEBUG("Calling Update NPT With new Route");
|
||||
(*afterRoutingChange)(m_rTable);
|
||||
writeLog(pnlsr.getConfParameter().getHyperbolicState());
|
||||
pnlsr.getNamePrefixTable().writeLog();
|
||||
pnlsr.getFib().writeLog();
|
||||
writeLog();
|
||||
m_namePrefixTable.writeLog();
|
||||
m_fib.writeLog();
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_DEBUG("Adjacency building is scheduled, so"
|
||||
@@ -107,78 +111,57 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
// need to update NPT here
|
||||
NLSR_LOG_DEBUG("Calling Update NPT With new Route");
|
||||
(*afterRoutingChange)(m_rTable);
|
||||
writeLog(pnlsr.getConfParameter().getHyperbolicState());
|
||||
pnlsr.getNamePrefixTable().writeLog();
|
||||
pnlsr.getFib().writeLog();
|
||||
//debugging purpose end
|
||||
writeLog();
|
||||
m_namePrefixTable.writeLog();
|
||||
m_fib.writeLog();
|
||||
// debugging purpose end
|
||||
}
|
||||
pnlsr.setIsRouteCalculationScheduled(false); //clear scheduled flag
|
||||
pnlsr.setIsRoutingTableCalculating(false); //unsetting routing table calculation
|
||||
m_isRouteCalculationScheduled = false; // clear scheduled flag
|
||||
m_isRoutingTableCalculating = false; // unsetting routing table calculation
|
||||
}
|
||||
else {
|
||||
scheduleRoutingTableCalculation(pnlsr);
|
||||
scheduleRoutingTableCalculation();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::calculateLsRoutingTable(Nlsr& nlsr)
|
||||
RoutingTable::calculateLsRoutingTable()
|
||||
{
|
||||
NLSR_LOG_DEBUG("RoutingTable::calculateLsRoutingTable Called");
|
||||
|
||||
Map map;
|
||||
map.createFromAdjLsdb(nlsr.getLsdb().getAdjLsdb().begin(), nlsr.getLsdb().getAdjLsdb().end());
|
||||
map.createFromAdjLsdb(m_lsdb.getAdjLsdb().begin(), m_lsdb.getAdjLsdb().end());
|
||||
map.writeLog();
|
||||
|
||||
size_t nRouters = map.getMapSize();
|
||||
|
||||
LinkStateRoutingTableCalculator calculator(nRouters);
|
||||
|
||||
calculator.calculatePath(map, std::ref(*this), nlsr);
|
||||
calculator.calculatePath(map, *this, m_confParam, m_lsdb.getAdjLsdb());
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
|
||||
RoutingTable::calculateHypRoutingTable(bool isDryRun)
|
||||
{
|
||||
Map map;
|
||||
map.createFromCoordinateLsdb(nlsr.getLsdb().getCoordinateLsdb().begin(),
|
||||
nlsr.getLsdb().getCoordinateLsdb().end());
|
||||
map.createFromCoordinateLsdb(m_lsdb.getCoordinateLsdb().begin(),
|
||||
m_lsdb.getCoordinateLsdb().end());
|
||||
map.writeLog();
|
||||
|
||||
size_t nRouters = map.getMapSize();
|
||||
|
||||
HyperbolicRoutingCalculator calculator(nRouters, false,
|
||||
nlsr.getConfParameter().getRouterPrefix());
|
||||
HyperbolicRoutingCalculator calculator(nRouters, isDryRun, m_confParam.getRouterPrefix());
|
||||
|
||||
calculator.calculatePaths(map, std::ref(*this),
|
||||
nlsr.getLsdb(), nlsr.getAdjacencyList());
|
||||
calculator.calculatePath(map, *this, m_lsdb, m_confParam.getAdjacencyList());
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::calculateHypDryRoutingTable(Nlsr& nlsr)
|
||||
RoutingTable::scheduleRoutingTableCalculation()
|
||||
{
|
||||
Map map;
|
||||
map.createFromAdjLsdb(nlsr.getLsdb().getAdjLsdb().begin(), nlsr.getLsdb().getAdjLsdb().end());
|
||||
map.writeLog();
|
||||
|
||||
size_t nRouters = map.getMapSize();
|
||||
|
||||
HyperbolicRoutingCalculator calculator(nRouters, true,
|
||||
nlsr.getConfParameter().getRouterPrefix());
|
||||
|
||||
calculator.calculatePaths(map, std::ref(*this),
|
||||
nlsr.getLsdb(), nlsr.getAdjacencyList());
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
|
||||
{
|
||||
if (pnlsr.getIsRouteCalculationScheduled() != true) {
|
||||
if (!m_isRouteCalculationScheduled) {
|
||||
NLSR_LOG_DEBUG("Scheduling routing table calculation in " << m_routingCalcInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_routingCalcInterval,
|
||||
std::bind(&RoutingTable::calculate, this, std::ref(pnlsr)));
|
||||
|
||||
pnlsr.setIsRouteCalculationScheduled(true);
|
||||
m_scheduler.schedule(m_routingCalcInterval, [this] { calculate(); });
|
||||
m_isRouteCalculationScheduled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +177,7 @@ RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh)
|
||||
NLSR_LOG_DEBUG("Adding " << nh << " for destination: " << destRouter);
|
||||
|
||||
RoutingTableEntry* rteChk = findRoutingTableEntry(destRouter);
|
||||
if (rteChk == 0) {
|
||||
if (rteChk == nullptr) {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
rte.getNexthopList().addNextHop(nh);
|
||||
m_rTable.push_back(rte);
|
||||
@@ -207,34 +190,30 @@ RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh)
|
||||
RoutingTableEntry*
|
||||
RoutingTable::findRoutingTableEntry(const ndn::Name& destRouter)
|
||||
{
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
|
||||
m_rTable.end(),
|
||||
std::bind(&routingTableEntryCompare,
|
||||
_1, destRouter));
|
||||
auto it = std::find_if(m_rTable.begin(), m_rTable.end(),
|
||||
std::bind(&routingTableEntryCompare, _1, destRouter));
|
||||
if (it != m_rTable.end()) {
|
||||
return &(*it);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::writeLog(int hyperbolicState)
|
||||
RoutingTable::writeLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG("---------------Routing Table------------------");
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_rTable.begin() ;
|
||||
it != m_rTable.end(); ++it) {
|
||||
NLSR_LOG_DEBUG("Destination: " << (*it).getDestination());
|
||||
for (const auto& rte : m_rTable) {
|
||||
NLSR_LOG_DEBUG("Destination: " << rte.getDestination());
|
||||
NLSR_LOG_DEBUG("Nexthops: ");
|
||||
(*it).getNexthopList().writeLog();
|
||||
rte.getNexthopList().writeLog();
|
||||
}
|
||||
|
||||
if (hyperbolicState == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
NLSR_LOG_DEBUG("--------Hyperbolic Routing Table(Dry)---------");
|
||||
for (std::list<RoutingTableEntry>::iterator it = m_dryTable.begin() ;
|
||||
it != m_dryTable.end(); ++it) {
|
||||
NLSR_LOG_DEBUG("Destination: " << (*it).getDestination());
|
||||
for (const auto& rte : m_dryTable) {
|
||||
NLSR_LOG_DEBUG("Destination: " << rte.getDestination());
|
||||
NLSR_LOG_DEBUG("Nexthops: ");
|
||||
(*it).getNexthopList().writeLog();
|
||||
rte.getNexthopList().writeLog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,17 +223,15 @@ RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Adding " << nh << " to dry table for destination: " << destRouter);
|
||||
|
||||
std::list<RoutingTableEntry>::iterator it = std::find_if(m_dryTable.begin(),
|
||||
m_dryTable.end(),
|
||||
std::bind(&routingTableEntryCompare,
|
||||
_1, destRouter));
|
||||
auto it = std::find_if(m_dryTable.begin(), m_dryTable.end(),
|
||||
std::bind(&routingTableEntryCompare, _1, destRouter));
|
||||
if (it == m_dryTable.end()) {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
rte.getNexthopList().addNextHop(nh);
|
||||
m_dryTable.push_back(rte);
|
||||
}
|
||||
else {
|
||||
(*it).getNexthopList().addNextHop(nh);
|
||||
it->getNexthopList().addNextHop(nh);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-22
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "conf-parameter.hpp"
|
||||
#include "routing-table-entry.hpp"
|
||||
#include "signals.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "route/fib.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
@@ -34,22 +36,21 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
class NextHop;
|
||||
|
||||
class RoutingTable : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
RoutingTable(ndn::Scheduler& scheduler);
|
||||
RoutingTable(ndn::Scheduler& scheduler, Fib& fib, Lsdb& lsdb,
|
||||
NamePrefixTable& namePrefixTable, ConfParameter& confParam);
|
||||
|
||||
/*! \brief Calculates a list of next hops for each router in the network.
|
||||
* \param nlsr 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& nlsr);
|
||||
calculate();
|
||||
|
||||
/*! \brief Adds a next hop to a routing table entry.
|
||||
* \param destRouter The destination router whose RTE we want to modify.
|
||||
@@ -70,16 +71,9 @@ public:
|
||||
|
||||
/*! \brief Schedules a calculation event in the event scheduler only
|
||||
* if one isn't already scheduled.
|
||||
* \param pnlsr The NLSR whose scheduling status is needed.
|
||||
*/
|
||||
void
|
||||
scheduleRoutingTableCalculation(Nlsr& pnlsr);
|
||||
|
||||
int
|
||||
getNoNextHop()
|
||||
{
|
||||
return m_NO_NEXT_HOP;
|
||||
}
|
||||
scheduleRoutingTableCalculation();
|
||||
|
||||
void
|
||||
setRoutingCalcInterval(uint32_t interval)
|
||||
@@ -114,15 +108,11 @@ public:
|
||||
private:
|
||||
/*! \brief Calculates a link-state routing table. */
|
||||
void
|
||||
calculateLsRoutingTable(Nlsr& pnlsr);
|
||||
calculateLsRoutingTable();
|
||||
|
||||
/*! \brief Calculates a HR routing table. */
|
||||
void
|
||||
calculateHypRoutingTable(Nlsr& pnlsr);
|
||||
|
||||
/*! \brief Calculates a dry-run HR routing table. */
|
||||
void
|
||||
calculateHypDryRoutingTable(Nlsr& pnlsr);
|
||||
calculateHypRoutingTable(bool isDryRun);
|
||||
|
||||
void
|
||||
clearRoutingTable();
|
||||
@@ -131,7 +121,7 @@ private:
|
||||
clearDryRoutingTable();
|
||||
|
||||
void
|
||||
writeLog(int hyperbolicState);
|
||||
writeLog();
|
||||
|
||||
public:
|
||||
std::unique_ptr<AfterRoutingChange> afterRoutingChange;
|
||||
@@ -141,12 +131,18 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
const int m_NO_NEXT_HOP;
|
||||
Fib& m_fib;
|
||||
Lsdb& m_lsdb;
|
||||
NamePrefixTable& m_namePrefixTable;
|
||||
|
||||
std::list<RoutingTableEntry> m_dryTable;
|
||||
|
||||
ndn::time::seconds m_routingCalcInterval;
|
||||
|
||||
bool m_isRoutingTableCalculating;
|
||||
bool m_isRouteCalculationScheduled;
|
||||
|
||||
ConfParameter& m_confParam;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2020, 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.
|
||||
*
|
||||
* 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 "certificate-store.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <ndn-cxx/util/io.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace security {
|
||||
|
||||
INIT_LOGGER(CertificateStore);
|
||||
|
||||
CertificateStore::CertificateStore(ndn::Face& face, ConfParameter& confParam, Lsdb& lsdb)
|
||||
: m_face(face)
|
||||
, m_confParam(confParam)
|
||||
, m_lsdb(lsdb)
|
||||
, m_validator(m_confParam.getValidator())
|
||||
, m_afterSegmentValidatedConnection(m_lsdb.afterSegmentValidatedSignal.connect(
|
||||
std::bind(&CertificateStore::afterFetcherSignalEmitted,
|
||||
this, _1)))
|
||||
{
|
||||
for (const auto& x: confParam.getIdCerts()) {
|
||||
auto idCert = ndn::io::load<ndn::security::v2::Certificate>(x);
|
||||
insert(*idCert);
|
||||
}
|
||||
|
||||
registerKeyPrefixes();
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::insert(const ndn::security::v2::Certificate& certificate)
|
||||
{
|
||||
m_certificates[certificate.getKeyName()] = certificate;
|
||||
NLSR_LOG_TRACE("Certificate inserted successfully");
|
||||
}
|
||||
|
||||
const ndn::security::v2::Certificate*
|
||||
CertificateStore::find(const ndn::Name& keyName) const
|
||||
{
|
||||
auto it = m_certificates.find(keyName);
|
||||
return it != m_certificates.end() ? &it->second : nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::clear()
|
||||
{
|
||||
m_certificates.clear();
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::setInterestFilter(const ndn::Name& prefix, bool loopback)
|
||||
{
|
||||
m_face.setInterestFilter(ndn::InterestFilter(prefix).allowLoopback(loopback),
|
||||
std::bind(&CertificateStore::onKeyInterest, this, _1, _2),
|
||||
std::bind(&CertificateStore::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&CertificateStore::registrationFailed, this, _1),
|
||||
m_confParam.getSigningInfo(), ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::registerKeyPrefixes()
|
||||
{
|
||||
std::vector<ndn::Name> prefixes;
|
||||
|
||||
// Router's NLSR certificate
|
||||
ndn::Name nlsrKeyPrefix = m_confParam.getRouterPrefix();
|
||||
nlsrKeyPrefix.append("nlsr");
|
||||
nlsrKeyPrefix.append("KEY");
|
||||
prefixes.push_back(nlsrKeyPrefix);
|
||||
|
||||
// Router's certificate
|
||||
ndn::Name routerKeyPrefix = m_confParam.getRouterPrefix();
|
||||
routerKeyPrefix.append("KEY");
|
||||
prefixes.push_back(routerKeyPrefix);
|
||||
|
||||
// Router's operator's certificate
|
||||
ndn::Name operatorKeyPrefix = m_confParam.getNetwork();
|
||||
operatorKeyPrefix.append(m_confParam.getSiteName());
|
||||
operatorKeyPrefix.append(std::string("%C1.Operator"));
|
||||
prefixes.push_back(operatorKeyPrefix);
|
||||
|
||||
// Router's site's certificate
|
||||
ndn::Name siteKeyPrefix = m_confParam.getNetwork();
|
||||
siteKeyPrefix.append(m_confParam.getSiteName());
|
||||
siteKeyPrefix.append("KEY");
|
||||
prefixes.push_back(siteKeyPrefix);
|
||||
|
||||
// Start listening for interest of this router's NLSR certificate,
|
||||
// router's certificate and site's certificate
|
||||
for (const auto& i : prefixes) {
|
||||
setInterestFilter(i);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Got interest for certificate. Interest: " << interest.getName());
|
||||
|
||||
const auto* cert = find(interest.getName());
|
||||
|
||||
if (!cert) {
|
||||
NLSR_LOG_TRACE("Certificate is not found for: " << interest);
|
||||
return;
|
||||
}
|
||||
m_face.put(*cert);
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::onKeyPrefixRegSuccess(const ndn::Name& name)
|
||||
{
|
||||
NLSR_LOG_DEBUG("KEY prefix: " << name << " registration is successful.");
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::registrationFailed(const ndn::Name& name)
|
||||
{
|
||||
NLSR_LOG_ERROR("ERROR: Failed to register prefix " << name);
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("Prefix registration failed"));
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::publishCertFromCache(const ndn::Name& keyName)
|
||||
{
|
||||
const auto* cert = m_validator.getUnverifiedCertCache().find(keyName);
|
||||
|
||||
if (cert) {
|
||||
insert(*cert);
|
||||
NLSR_LOG_TRACE(*cert);
|
||||
ndn::Name certName = ndn::security::v2::extractKeyNameFromCertName(cert->getName());
|
||||
NLSR_LOG_TRACE("Setting interest filter for: " << certName);
|
||||
|
||||
setInterestFilter(certName);
|
||||
|
||||
if (cert->getKeyName() != cert->getSignature().getKeyLocator().getName()) {
|
||||
publishCertFromCache(cert->getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Happens for root cert
|
||||
NLSR_LOG_TRACE("Cert for " << keyName << " was not found in the Validator's cache. ");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CertificateStore::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
|
||||
{
|
||||
const auto keyName = lsaSegment.getSignature().getKeyLocator().getName();
|
||||
if (!find(keyName)) {
|
||||
NLSR_LOG_TRACE("Publishing certificate for: " << keyName);
|
||||
publishCertFromCache(keyName);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE("Certificate is already in the store: " << keyName);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace security
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2020, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,13 +22,17 @@
|
||||
#ifndef NLSR_CERTIFICATE_STORE_HPP
|
||||
#define NLSR_CERTIFICATE_STORE_HPP
|
||||
|
||||
#include "../common.hpp"
|
||||
#include "../test-access-control.hpp"
|
||||
#include "common.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "lsdb.hpp"
|
||||
|
||||
#include <ndn-cxx/interest.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/controller.hpp>
|
||||
#include <ndn-cxx/security/v2/certificate.hpp>
|
||||
#include <ndn-cxx/security/validator-config.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
class ConfParameter;
|
||||
namespace security {
|
||||
|
||||
/*! \brief Store certificates for names
|
||||
@@ -40,35 +44,61 @@ namespace security {
|
||||
*/
|
||||
class CertificateStore
|
||||
{
|
||||
|
||||
public:
|
||||
CertificateStore(ndn::Face& face, ConfParameter& confParam, Lsdb& lsdb);
|
||||
|
||||
void
|
||||
insert(const ndn::security::v2::Certificate& certificate)
|
||||
{
|
||||
m_certificates[certificate.getKeyName()] = certificate;
|
||||
}
|
||||
insert(const ndn::security::v2::Certificate& certificate);
|
||||
|
||||
/*! \brief Find a certificate
|
||||
*
|
||||
* Find a certificate that NLSR has. First it checks against the
|
||||
* certificates this NLSR claims to be authoritative for, usually
|
||||
* something like this specific router's certificate, and then
|
||||
* checks the cache of certificates it has already fetched. If none
|
||||
* can be found, it will return an null pointer.
|
||||
*/
|
||||
const ndn::security::v2::Certificate*
|
||||
find(const ndn::Name keyName)
|
||||
{
|
||||
CertMap::iterator it = m_certificates.find(keyName);
|
||||
find(const ndn::Name& keyName) const;
|
||||
|
||||
if (it != m_certificates.end()) {
|
||||
return &it->second;
|
||||
}
|
||||
/*! \brief Retrieves the chain of certificates from Validator's cache and
|
||||
* store them in Nlsr's own CertificateStore.
|
||||
* \param keyName Name of the first key in the certificate chain.
|
||||
*/
|
||||
void
|
||||
publishCertFromCache(const ndn::Name& keyName);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
void
|
||||
afterFetcherSignalEmitted(const ndn::Data& lsaSegment);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
clear()
|
||||
{
|
||||
m_certificates.clear();
|
||||
}
|
||||
clear();
|
||||
|
||||
void
|
||||
setInterestFilter(const ndn::Name& prefix, const bool loopback = false);
|
||||
|
||||
void
|
||||
registerKeyPrefixes();
|
||||
|
||||
void
|
||||
onKeyInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
void
|
||||
onKeyPrefixRegSuccess(const ndn::Name& name);
|
||||
|
||||
void
|
||||
registrationFailed(const ndn::Name& name);
|
||||
|
||||
private:
|
||||
typedef std::map<ndn::Name, ndn::security::v2::Certificate> CertMap;
|
||||
CertMap m_certificates;
|
||||
ndn::Face& m_face;
|
||||
ConfParameter& m_confParam;
|
||||
Lsdb& m_lsdb;
|
||||
ndn::security::ValidatorConfig& m_validator;
|
||||
ndn::util::signal::ScopedConnection m_afterSegmentValidatedConnection;
|
||||
};
|
||||
|
||||
} // namespace security
|
||||
|
||||
+30
-38
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -34,6 +34,13 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(SequencingManager);
|
||||
|
||||
SequencingManager::SequencingManager(const std::string& filePath, int hypState)
|
||||
: m_hyperbolicState(hypState)
|
||||
{
|
||||
setSeqFileDirectory(filePath);
|
||||
initiateSeqNoFromFile();
|
||||
}
|
||||
|
||||
void
|
||||
SequencingManager::writeSeqNoToFile() const
|
||||
{
|
||||
@@ -48,59 +55,39 @@ SequencingManager::writeSeqNoToFile() const
|
||||
}
|
||||
|
||||
void
|
||||
SequencingManager::initiateSeqNoFromFile(int hypState)
|
||||
SequencingManager::initiateSeqNoFromFile()
|
||||
{
|
||||
NLSR_LOG_DEBUG("Seq File Name: " << m_seqFileNameWithPath);
|
||||
std::ifstream inputFile(m_seqFileNameWithPath.c_str());
|
||||
|
||||
std::string seqType;
|
||||
// Good checks that file is not (bad or eof or fail)
|
||||
if (inputFile.good()) {
|
||||
std::string lsaOrCombinedSeqNo;
|
||||
uint64_t seqNo = 0;
|
||||
|
||||
// If file has a combined seq number, lsaOrCombinedSeqNo would hold it
|
||||
// and seqNo will be zero everytime
|
||||
inputFile >> lsaOrCombinedSeqNo >> seqNo;
|
||||
m_nameLsaSeq = seqNo;
|
||||
|
||||
inputFile >> lsaOrCombinedSeqNo >> seqNo;
|
||||
m_adjLsaSeq = seqNo;
|
||||
|
||||
inputFile >> lsaOrCombinedSeqNo >> seqNo;;
|
||||
m_corLsaSeq = seqNo;
|
||||
|
||||
// File was in old format and had a combined sequence number
|
||||
// if all of the seqNo should are still zero and
|
||||
// lsaOrCombinedSeqNo != CorLsaSeq
|
||||
if (m_nameLsaSeq == 0 && m_adjLsaSeq == 0 && m_corLsaSeq == 0 &&
|
||||
lsaOrCombinedSeqNo != "CorLsaSeq") {
|
||||
NLSR_LOG_DEBUG("Old file had combined sequence number: " << lsaOrCombinedSeqNo);
|
||||
std::istringstream iss(lsaOrCombinedSeqNo);
|
||||
iss >> seqNo;
|
||||
m_adjLsaSeq = (seqNo & 0xFFFFF);
|
||||
m_corLsaSeq = ((seqNo >> 20) & 0xFFFFF);
|
||||
m_nameLsaSeq = ((seqNo >> 40) & 0xFFFFFF);
|
||||
}
|
||||
inputFile >> seqType >> m_nameLsaSeq;
|
||||
inputFile >> seqType >> m_adjLsaSeq;
|
||||
inputFile >> seqType >> m_corLsaSeq;
|
||||
|
||||
inputFile.close();
|
||||
|
||||
// Increment by 10 in case last run of NLSR was not able to write to file
|
||||
// before crashing
|
||||
m_nameLsaSeq += 10;
|
||||
|
||||
// Increment the adjacency LSA seq. no. if link-state or dry HR is enabled
|
||||
if (hypState != HYPERBOLIC_STATE_ON) {
|
||||
if (m_hyperbolicState != HYPERBOLIC_STATE_ON) {
|
||||
if (m_corLsaSeq != 0) {
|
||||
NLSR_LOG_WARN("This router was previously configured for hyperbolic"
|
||||
<< " routing without clearing the seq. no. file.");
|
||||
NLSR_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_hyperbolicState != HYPERBOLIC_STATE_OFF) {
|
||||
if (m_adjLsaSeq != 0) {
|
||||
NLSR_LOG_WARN("This router was previously configured for link-state"
|
||||
<< " routing without clearing the seq. no. file.");
|
||||
NLSR_LOG_WARN("This router was previously configured for link-state " <<
|
||||
"routing without clearing the seq. no. file.");
|
||||
m_adjLsaSeq = 0;
|
||||
}
|
||||
m_corLsaSeq += 10;
|
||||
@@ -110,7 +97,7 @@ SequencingManager::initiateSeqNoFromFile(int hypState)
|
||||
}
|
||||
|
||||
void
|
||||
SequencingManager::setSeqFileDirectory(std::string filePath)
|
||||
SequencingManager::setSeqFileDirectory(const std::string& filePath)
|
||||
{
|
||||
m_seqFileNameWithPath = filePath;
|
||||
|
||||
@@ -127,9 +114,14 @@ SequencingManager::setSeqFileDirectory(std::string filePath)
|
||||
void
|
||||
SequencingManager::writeLog() const
|
||||
{
|
||||
NLSR_LOG_DEBUG("----SequencingManager----");
|
||||
NLSR_LOG_DEBUG("Adj LSA seq no: " << m_adjLsaSeq);
|
||||
NLSR_LOG_DEBUG("Cor LSA Seq no: " << m_corLsaSeq);
|
||||
if (m_hyperbolicState == HYPERBOLIC_STATE_OFF ||
|
||||
m_hyperbolicState == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
NLSR_LOG_DEBUG("Adj LSA seq no: " << m_adjLsaSeq);
|
||||
}
|
||||
if (m_hyperbolicState == HYPERBOLIC_STATE_ON ||
|
||||
m_hyperbolicState == HYPERBOLIC_STATE_DRY_RUN) {
|
||||
NLSR_LOG_DEBUG("Cor LSA Seq no: " << m_corLsaSeq);
|
||||
}
|
||||
NLSR_LOG_DEBUG("Name LSA Seq no: " << m_nameLsaSeq);
|
||||
}
|
||||
|
||||
|
||||
+17
-17
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,26 +22,21 @@
|
||||
#ifndef NLSR_SEQUENCING_MANAGER_HPP
|
||||
#define NLSR_SEQUENCING_MANAGER_HPP
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "conf-parameter.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class SequencingManager
|
||||
{
|
||||
public:
|
||||
SequencingManager()
|
||||
: m_nameLsaSeq(0)
|
||||
, m_adjLsaSeq(0)
|
||||
, m_corLsaSeq(0)
|
||||
, m_seqFileNameWithPath()
|
||||
{
|
||||
}
|
||||
SequencingManager(const std::string& filePath, int hypState);
|
||||
|
||||
uint64_t
|
||||
getNameLsaSeq() const
|
||||
@@ -100,9 +95,11 @@ public:
|
||||
void
|
||||
writeSeqNoToFile() const;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
initiateSeqNoFromFile(int hypState);
|
||||
initiateSeqNoFromFile();
|
||||
|
||||
private:
|
||||
/*! \brief Set the sequence file directory
|
||||
|
||||
If the string is empty, home directory is set as sequence file directory
|
||||
@@ -110,16 +107,19 @@ public:
|
||||
\param filePath The directory where sequence file will be stored
|
||||
*/
|
||||
void
|
||||
setSeqFileDirectory(std::string filePath);
|
||||
setSeqFileDirectory(const std::string& filePath);
|
||||
|
||||
void
|
||||
writeLog() const;
|
||||
|
||||
private:
|
||||
uint64_t m_nameLsaSeq;
|
||||
uint64_t m_adjLsaSeq;
|
||||
uint64_t m_corLsaSeq;
|
||||
uint64_t m_nameLsaSeq = 0;
|
||||
uint64_t m_adjLsaSeq = 0;
|
||||
uint64_t m_corLsaSeq = 0;
|
||||
std::string m_seqFileNameWithPath;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
int m_hyperbolicState;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -33,7 +33,7 @@ class RoutingTableEntry;
|
||||
class SyncLogicHandler;
|
||||
|
||||
using AfterRoutingChange = ndn::util::Signal<RoutingTable, const std::list<RoutingTableEntry>&>;
|
||||
using OnNewLsa = ndn::util::Signal<SyncLogicHandler, const ndn::Name&, const uint64_t&>;
|
||||
using OnNewLsa = ndn::util::Signal<SyncLogicHandler, const ndn::Name&, const uint64_t&, const ndn::Name&>;
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
|
||||
+10
-18
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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 "adjacency-lsa.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <ndn-cxx/encoding/block-helpers.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<AdjacencyLsa>));
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<AdjacencyLsa>));
|
||||
@@ -62,11 +62,7 @@ AdjacencyLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
template size_t
|
||||
AdjacencyLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& encoder) const;
|
||||
|
||||
template size_t
|
||||
AdjacencyLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& encoder) const;
|
||||
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa);
|
||||
|
||||
const ndn::Block&
|
||||
AdjacencyLsa::wireEncode() const
|
||||
@@ -95,10 +91,8 @@ AdjacencyLsa::wireDecode(const ndn::Block& wire)
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::AdjacencyLsa) {
|
||||
std::stringstream error;
|
||||
error << "Expected AdjacencyLsa Block, but Block is of a different type: #"
|
||||
<< m_wire.type();
|
||||
throw Error(error.str());
|
||||
BOOST_THROW_EXCEPTION(Error("Expected AdjacencyLsa Block, but Block is of a different type: #" +
|
||||
ndn::to_string(m_wire.type())));
|
||||
}
|
||||
|
||||
m_wire.parse();
|
||||
@@ -110,7 +104,7 @@ AdjacencyLsa::wireDecode(const ndn::Block& wire)
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required LsaInfo field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required LsaInfo field"));
|
||||
}
|
||||
|
||||
for (; val != m_wire.elements_end(); ++val) {
|
||||
@@ -119,10 +113,8 @@ AdjacencyLsa::wireDecode(const ndn::Block& wire)
|
||||
m_hasAdjacencies = true;
|
||||
}
|
||||
else {
|
||||
std::stringstream error;
|
||||
error << "Expected Adjacency Block, but Block is of a different type: #"
|
||||
<< m_wire.type();
|
||||
throw Error(error.str());
|
||||
BOOST_THROW_EXCEPTION(Error("Expected Adjacency Block, but Block is of a different type: #" +
|
||||
ndn::to_string(m_wire.type())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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_TLV_ADJACENCY_LSA_HPP
|
||||
#define NLSR_TLV_ADJACENCY_LSA_HPP
|
||||
@@ -153,6 +153,8 @@ private:
|
||||
mutable ndn::Block m_wire;
|
||||
};
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdjacencyLsa);
|
||||
|
||||
inline AdjacencyLsa::iterator
|
||||
AdjacencyLsa::begin() const
|
||||
{
|
||||
|
||||
+10
-16
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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 "adjacency.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <ndn-cxx/encoding/block-helpers.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
namespace tlv {
|
||||
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireEncodable<Adjacency>));
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<Adjacency>));
|
||||
@@ -62,11 +62,7 @@ Adjacency::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
template size_t
|
||||
Adjacency::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
Adjacency::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Adjacency);
|
||||
|
||||
const ndn::Block&
|
||||
Adjacency::wireEncode() const
|
||||
@@ -96,10 +92,8 @@ Adjacency::wireDecode(const ndn::Block& wire)
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::Adjacency) {
|
||||
std::stringstream error;
|
||||
error << "Expected Adjacency Block, but Block is of a different type: #"
|
||||
<< m_wire.type();
|
||||
throw Error(error.str());
|
||||
BOOST_THROW_EXCEPTION(Error("Expected Adjacency Block, but Block is of a different type: #" +
|
||||
ndn::to_string(m_wire.type())));
|
||||
}
|
||||
|
||||
m_wire.parse();
|
||||
@@ -111,7 +105,7 @@ Adjacency::wireDecode(const ndn::Block& wire)
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required Name field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required Name field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Uri) {
|
||||
@@ -119,7 +113,7 @@ Adjacency::wireDecode(const ndn::Block& wire)
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required Uri field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required Uri field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::Cost) {
|
||||
@@ -127,7 +121,7 @@ Adjacency::wireDecode(const ndn::Block& wire)
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
throw Error("Missing required Cost field");
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required Cost field"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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_TLV_ADJACENCY_HPP
|
||||
#define NLSR_TLV_ADJACENCY_HPP
|
||||
@@ -137,6 +137,8 @@ private:
|
||||
mutable ndn::Block m_wire;
|
||||
};
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Adjacency);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const Adjacency& adjacency);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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 "coordinate-lsa.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
@@ -25,8 +25,6 @@
|
||||
#include <ndn-cxx/util/concepts.hpp>
|
||||
#include <ndn-cxx/encoding/block-helpers.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tlv {
|
||||
|
||||
@@ -50,21 +48,12 @@ size_t
|
||||
CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
size_t doubleLength = 10;
|
||||
|
||||
const uint8_t* doubleBytes1;
|
||||
for (auto it = m_hyperbolicAngle.rbegin(); it != m_hyperbolicAngle.rend(); ++it) {
|
||||
doubleBytes1 = reinterpret_cast<const uint8_t*>(&*it);
|
||||
|
||||
totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes1, 8);
|
||||
totalLength += block.prependVarNumber(doubleLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicAngle);
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::HyperbolicAngle, *it);
|
||||
}
|
||||
|
||||
const uint8_t* doubleBytes2 = reinterpret_cast<const uint8_t*>(&m_hyperbolicRadius);
|
||||
totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes2, 8);
|
||||
totalLength += block.prependVarNumber(doubleLength);
|
||||
totalLength += block.prependVarNumber(ndn::tlv::nlsr::HyperbolicRadius);
|
||||
totalLength += ndn::encoding::prependDoubleBlock(block, ndn::tlv::nlsr::HyperbolicRadius, m_hyperbolicRadius);
|
||||
|
||||
totalLength += m_lsaInfo.wireEncode(block);
|
||||
|
||||
@@ -74,11 +63,7 @@ CoordinateLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
template size_t
|
||||
CoordinateLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
CoordinateLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(CoordinateLsa);
|
||||
|
||||
const ndn::Block&
|
||||
CoordinateLsa::wireEncode() const
|
||||
@@ -122,41 +107,20 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
std::cout << "Missing required LsaInfo field" << std::endl;
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required LsaInfo field"));
|
||||
}
|
||||
|
||||
if (val != m_wire.elements_end() && val->type() == ndn::tlv::nlsr::HyperbolicRadius) {
|
||||
val->parse();
|
||||
ndn::Block::element_const_iterator it = val->elements_begin();
|
||||
if (it != val->elements_end() && it->type() == ndn::tlv::nlsr::Double) {
|
||||
m_hyperbolicRadius = *reinterpret_cast<const double*>(it->value());
|
||||
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
std::cout << "HyperbolicRadius: Missing required Double field" << std::endl;
|
||||
BOOST_THROW_EXCEPTION(Error("HyperbolicRadius: Missing required Double field"));
|
||||
}
|
||||
m_hyperbolicRadius = ndn::encoding::readDouble(*val);
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
std::cout << "Missing required HyperbolicRadius field" << std::endl;
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required HyperbolicRadius field"));
|
||||
}
|
||||
|
||||
for (; val != m_wire.elements_end(); ++val) {
|
||||
if (val->type() == ndn::tlv::nlsr::HyperbolicAngle) {
|
||||
val->parse();
|
||||
|
||||
for (auto it = val->elements_begin(); it != val->elements_end(); ++it) {
|
||||
if (it->type() == ndn::tlv::nlsr::Double) {
|
||||
m_hyperbolicAngle.push_back(*reinterpret_cast<const double*>(it->value()));
|
||||
}
|
||||
else {
|
||||
std::cout << "HyperbolicAngle: Missing required Double field" << std::endl;
|
||||
BOOST_THROW_EXCEPTION(Error("HyperbolicAngle: Missing required Double field"));
|
||||
}
|
||||
}
|
||||
m_hyperbolicAngle.push_back(ndn::encoding::readDouble(*val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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_TLV_COORDINATE_LSA_HPP
|
||||
#define NLSR_TLV_COORDINATE_LSA_HPP
|
||||
@@ -141,6 +141,8 @@ private:
|
||||
mutable ndn::Block m_wire;
|
||||
};
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(CoordinateLsa);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const CoordinateLsa& coordinateLsa);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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 "lsa-info.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
@@ -72,11 +72,7 @@ LsaInfo::wireEncode(ndn::EncodingImpl<TAG>& encoder) const
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
template size_t
|
||||
LsaInfo::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
LsaInfo::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(LsaInfo);
|
||||
|
||||
const ndn::Block&
|
||||
LsaInfo::wireEncode() const
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, The University of Memphis,
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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_TLV_LSA_INFO_HPP
|
||||
#define NLSR_TLV_LSA_INFO_HPP
|
||||
@@ -154,6 +154,8 @@ private:
|
||||
mutable ndn::Block m_wire;
|
||||
};
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(LsaInfo);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const LsaInfo& lsaInfo);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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 "lsdb-status.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
@@ -123,13 +123,7 @@ LsdbStatus::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(LsdbStatus);
|
||||
|
||||
template size_t
|
||||
LsdbStatus::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
LsdbStatus::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(LsdbStatus);
|
||||
|
||||
const ndn::Block&
|
||||
LsdbStatus::wireEncode() const
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* 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_TLV_LSDB_STATUS_HPP
|
||||
#define NLSR_TLV_LSDB_STATUS_HPP
|
||||
@@ -165,6 +165,8 @@ private:
|
||||
mutable ndn::Block m_wire;
|
||||
};
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(LsdbStatus);
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const LsdbStatus& lsdbStatus);
|
||||
|
||||
|
||||
Loaded 100 of 165 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user