Compare commits
35
Commits
NLSR-0.4.2
...
NLSR-0.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
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/libPSync*
|
||||
sudo rm -f /usr/local/lib/pkgconfig/PSync*
|
||||
|
||||
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 env "PATH=$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
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
+46
-52
@@ -1,5 +1,5 @@
|
||||
language: cpp
|
||||
dist: trusty
|
||||
dist: xenial
|
||||
sudo: required
|
||||
env:
|
||||
global:
|
||||
@@ -10,78 +10,38 @@ 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
|
||||
|
||||
# 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
|
||||
- os: linux
|
||||
env: COMPILER=clang++-7
|
||||
|
||||
# macOS/clang
|
||||
# https://docs.travis-ci.com/user/osx-ci-environment/#OS-X-Version
|
||||
# https://docs.travis-ci.com/user/reference/osx/#OS-X-Version
|
||||
- os: osx
|
||||
osx_image: xcode7.3
|
||||
env: OSX_VERSION=10.11
|
||||
@@ -89,11 +49,45 @@ matrix:
|
||||
osx_image: xcode8.3
|
||||
env: OSX_VERSION=10.12
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
env: OSX_VERSION=10.12
|
||||
osx_image: xcode9.3
|
||||
env: OSX_VERSION=10.13
|
||||
|
||||
allow_failures:
|
||||
- env: COMPILER=g++-6
|
||||
- env: COMPILER=g++-7
|
||||
- env: COMPILER=g++-8
|
||||
- env: COMPILER=clang++-3.5
|
||||
- env: COMPILER=clang++-3.6
|
||||
- env: COMPILER=clang++-3.7 DISABLE_ASAN=yes
|
||||
- env: COMPILER=clang++-3.8
|
||||
- env: COMPILER=clang++-3.9
|
||||
- env: COMPILER=clang++-4.0
|
||||
- env: COMPILER=clang++-5.0
|
||||
- env: COMPILER=clang++-6.0
|
||||
- env: COMPILER=clang++-7
|
||||
|
||||
fast_finish: true
|
||||
|
||||
install: |
|
||||
case ${COMPILER} in
|
||||
g++-[6789])
|
||||
travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
travis_retry sudo apt-get -qq update
|
||||
travis_retry sudo apt-get -qy install "${COMPILER}"
|
||||
;;
|
||||
clang++-*)
|
||||
CLANG_VERSION=${COMPILER/clang++}
|
||||
if [[ ${CLANG_VERSION} != "-3."* ]]; then
|
||||
wget -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/xenial/ llvm-toolchain-xenial${CLANG_VERSION/-7} main"
|
||||
fi
|
||||
travis_retry sudo apt-get -qq update
|
||||
travis_retry sudo apt-get -qy install "clang${CLANG_VERSION}"
|
||||
;;
|
||||
esac
|
||||
|
||||
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-16.04"; fi
|
||||
- if [[ ${TRAVIS_OS_NAME} == osx ]]; then export NODE_LABELS="OSX OSX-${OSX_VERSION}"; fi
|
||||
- if [[ -n ${COMPILER} ]]; then export CXX=${COMPILER}; fi
|
||||
- ${CXX:-c++} --version
|
||||
|
||||
+6
-2
@@ -54,8 +54,7 @@ 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 = '''
|
||||
@@ -404,6 +403,11 @@ def check_boost(self, *k, **kw):
|
||||
|
||||
var = kw.get('uselib_store', 'BOOST')
|
||||
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
+9
-7
@@ -7,12 +7,13 @@ NLSR is an open source project includes contributions from the members of the
|
||||
## Project co-leads:
|
||||
|
||||
* Ashlesh Gawande <https://www.linkedin.com/in/agawande>
|
||||
* Nicholas Gordon <nmgordon@memphis.edu>
|
||||
* Saurab Dulal <https://dulalsaurab.github.io>
|
||||
|
||||
## Past project leads:
|
||||
|
||||
* A K M Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
* Nicholas Gordon <nmgordon@memphis.edu>
|
||||
|
||||
## Technical advisors:
|
||||
|
||||
@@ -43,15 +44,16 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* Spyridon Mastorakis <http://cs.ucla.edu/~mastorakis/>
|
||||
* Jiewen Tan <https://www.linkedin.com/in/jiewentan>
|
||||
|
||||
* University of Arizona
|
||||
* Universidad Autónoma de San Luis Potosí (UASLP)
|
||||
|
||||
* Pedro David Arjona Villicaña <david.arjona@uaslp.mx>
|
||||
|
||||
* Individual Contributor(s)
|
||||
|
||||
* 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).
|
||||
Any question related to NLSR should be directed to Ashlesh Gawande (agawande@memphis.edu), Saurab Dulal (sdulal@memphis.edu),
|
||||
Muktadir R Chowdhury (mrchwdhr@memphis.edu).
|
||||
+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.0.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
|
||||
+3
-1
@@ -4,7 +4,9 @@ NLSR Versions
|
||||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 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
|
||||
|
||||
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
|
||||
@@ -141,7 +144,7 @@ security
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^[^<NLSR><INFO>]*<NLSR><INFO><><>$
|
||||
regex ^[^<nlsr><INFO>]*<nlsr><INFO><><>$
|
||||
}
|
||||
checker
|
||||
{
|
||||
@@ -152,10 +155,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 +172,7 @@ security
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^[^<NLSR><LSA>]*<NLSR><LSA>
|
||||
regex ^[^<nlsr><LSA>]*<nlsr><LSA>
|
||||
}
|
||||
checker
|
||||
{
|
||||
@@ -180,11 +183,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 +201,7 @@ security
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><NLSR>]*<KEY><><><>$
|
||||
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><nlsr>]*<KEY><><><>$
|
||||
}
|
||||
checker
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-2
@@ -75,8 +75,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&
|
||||
|
||||
+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,16 +23,16 @@
|
||||
#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";
|
||||
|
||||
INIT_LOGGER(SyncLogicHandler);
|
||||
|
||||
template<class T>
|
||||
class NullDeleter
|
||||
{
|
||||
@@ -45,81 +45,75 @@ public:
|
||||
|
||||
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)
|
||||
{
|
||||
createSyncLogic(conf.getSyncPrefix());
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix, const ndn::time::milliseconds& syncInterestLifetime)
|
||||
SyncLogicHandler::createSyncLogic(const ndn::Name& syncPrefix, const ndn::time::milliseconds& syncInterestLifetime)
|
||||
{
|
||||
if (m_syncSocket != nullptr) {
|
||||
NLSR_LOG_WARN("Trying to create Sync socket, but Sync socket already exists");
|
||||
if (m_syncLogic != nullptr) {
|
||||
NLSR_LOG_WARN("Trying to create Sync Logic object, but Sync Logic object already exists");
|
||||
return;
|
||||
}
|
||||
|
||||
m_syncPrefix = syncPrefix;
|
||||
|
||||
// Build LSA sync update prefix
|
||||
buildUpdatePrefix();
|
||||
|
||||
NLSR_LOG_DEBUG("Creating Sync socket. Sync Prefix: " << m_syncPrefix);
|
||||
NLSR_LOG_DEBUG("Creating Sync Logic object. Sync Prefix: " << syncPrefix);
|
||||
|
||||
// The face's lifetime is managed in main.cpp; SyncSocket should not manage the memory
|
||||
// The face's lifetime is managed in main.cpp; Logic 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);
|
||||
m_syncLogic = std::make_shared<SyncProtocolAdapter>(*facePtr,
|
||||
m_confParam.getSyncProtocol(),
|
||||
syncPrefix,
|
||||
m_nameLsaUserPrefix,
|
||||
syncInterestLifetime,
|
||||
std::bind(&SyncLogicHandler::processUpdate, this, _1, _2));
|
||||
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
m_syncSocket->addSyncNode(m_adjLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
m_syncLogic->addUserNode(m_adjLsaUserPrefix);
|
||||
}
|
||||
else if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_syncSocket->addSyncNode(m_coorLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
m_syncLogic->addUserNode(m_coorLsaUserPrefix);
|
||||
}
|
||||
else {
|
||||
m_syncSocket->addSyncNode(m_adjLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
m_syncSocket->addSyncNode(m_coorLsaUserPrefix, chronosync::Socket::DEFAULT_NAME, fixedSession);
|
||||
m_syncLogic->addUserNode(m_adjLsaUserPrefix);
|
||||
m_syncLogic->addUserNode(m_coorLsaUserPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& v)
|
||||
SyncLogicHandler::processUpdate(const ndn::Name& updateName, uint64_t highSeq)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Received ChronoSync update event");
|
||||
NLSR_LOG_DEBUG("Update Name: " << updateName << " Seq no: " << highSeq);
|
||||
|
||||
for (size_t i = 0; i < v.size(); i++){
|
||||
ndn::Name updateName = v[i].session.getPrefix(-1);
|
||||
int32_t nlsrPosition = util::getNameComponentPosition(updateName, nlsr::NLSR_COMPONENT);
|
||||
int32_t lsaPosition = util::getNameComponentPosition(updateName, nlsr::LSA_COMPONENT);
|
||||
|
||||
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);
|
||||
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, 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,21 +123,21 @@ 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);
|
||||
@@ -154,21 +148,21 @@ 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");
|
||||
if (m_syncLogic == nullptr) {
|
||||
NLSR_LOG_FATAL("Cannot publish routing update; SyncLogic does not exist");
|
||||
|
||||
BOOST_THROW_EXCEPTION(SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist"));
|
||||
BOOST_THROW_EXCEPTION(SyncLogicHandler::Error("Cannot publish routing update; SyncLogic 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;
|
||||
@@ -192,16 +186,4 @@ SyncLogicHandler::buildUpdatePrefix()
|
||||
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,34 @@ 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 Create and configure a Logic object to enable Sync for this NLSR.
|
||||
*
|
||||
* 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
|
||||
* \param syncPrefix The sync prefix you want this Sync to use
|
||||
* \param syncInterestLifetime ChronoSync/PSync sends a periodic sync interest every
|
||||
* \p syncInterestLifetime / 2 ms
|
||||
* \sa Nlsr::initialize
|
||||
*/
|
||||
void
|
||||
createSyncSocket(const ndn::Name& syncPrefix,
|
||||
const ndn::time::milliseconds& syncInterestLifetime =
|
||||
ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT));
|
||||
createSyncLogic(const ndn::Name& syncPrefix,
|
||||
const ndn::time::milliseconds& syncInterestLifetime =
|
||||
ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT));
|
||||
|
||||
/*! \brief Callback from Sync protocol
|
||||
*
|
||||
* In a typical situation this only needs to be called once, when NLSR starts.
|
||||
* \param updateName The prefix for which sync reports an update
|
||||
* \param highSeq The latest sequence number of the update
|
||||
*/
|
||||
void
|
||||
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 +114,16 @@ 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;
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
std::shared_ptr<SyncProtocolAdapter> m_syncLogic;
|
||||
private:
|
||||
IsLsaNew m_isLsaNew;
|
||||
const ConfParameter& m_confParam;
|
||||
|
||||
@@ -145,7 +135,6 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
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
|
||||
+94
-43
@@ -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.
|
||||
*
|
||||
@@ -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"
|
||||
@@ -134,6 +133,12 @@ private:
|
||||
bool m_isRequired;
|
||||
};
|
||||
|
||||
ConfFileProcessor::ConfFileProcessor(ConfParameter& confParam)
|
||||
: m_confFileName(confParam.getConfFileName())
|
||||
, m_confParam(confParam)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
ConfFileProcessor::processConfFile()
|
||||
{
|
||||
@@ -220,7 +225,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 +233,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 +241,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,7 +257,7 @@ 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 ";
|
||||
@@ -265,8 +270,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 +282,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 +292,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 +322,26 @@ 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 (boost::filesystem::exists(stateDir)) {
|
||||
if (boost::filesystem::is_directory(stateDir)) {
|
||||
|
||||
// copying nlsr.conf file to a user define directory for possible modification
|
||||
std::string conFileDynamic = (boost::filesystem::path(stateDir) / "nlsr.conf").c_str();
|
||||
m_confParam.setConfFileNameDynamic(conFileDynamic);
|
||||
try {
|
||||
copy_file(m_confFileName, conFileDynamic, boost::filesystem::copy_option::overwrite_if_exists);
|
||||
}
|
||||
catch (const boost::filesystem::filesystem_error& e) {
|
||||
std::cerr << "Error copying conf file to the state directory: " << e.what() << std::endl;
|
||||
}
|
||||
std::string testFileName = (boost::filesystem::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 +349,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 +374,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 +388,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 +402,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 +416,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 +426,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 +440,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,
|
||||
@@ -424,7 +454,7 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
// first-hello-interval
|
||||
ConfigurationVariable<uint32_t> firstHelloInterval("first-hello-interval",
|
||||
std::bind(&ConfParameter::setFirstHelloInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
&m_confParam, _1));
|
||||
firstHelloInterval.setMinAndMaxValue(FIRST_HELLO_INTERVAL_MIN, FIRST_HELLO_INTERVAL_MAX);
|
||||
firstHelloInterval.setOptional(FIRST_HELLO_INTERVAL_DEFAULT);
|
||||
|
||||
@@ -443,7 +473,24 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
|
||||
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();
|
||||
|
||||
if (failedToCanonize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -452,7 +499,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 +522,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 +557,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 +581,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 +593,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);
|
||||
|
||||
@@ -567,7 +614,7 @@ ConfFileProcessor::processConfSectionAdvertising(const ConfigSection& section)
|
||||
std::string prefix = tn->second.data();
|
||||
ndn::Name namePrefix(prefix);
|
||||
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,11 +640,11 @@ 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++) {
|
||||
@@ -618,7 +665,11 @@ ConfFileProcessor::processConfSectionSecurity(const ConfigSection& section)
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nlsr.loadCertToPublish(*idCert);
|
||||
m_confParam.getCertStore().insert(*idCert);
|
||||
m_confParam.getValidator().loadAnchor("Authoritative-Certificate",
|
||||
ndn::security::v2::Certificate(*idCert));
|
||||
m_confParam.getPrefixUpdateValidator().loadAnchor("Authoritative-Certificate",
|
||||
ndn::security::v2::Certificate(*idCert));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -46,11 +46,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.
|
||||
*
|
||||
@@ -125,8 +121,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
|
||||
|
||||
+35
-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).
|
||||
@@ -29,7 +29,31 @@ namespace nlsr {
|
||||
INIT_LOGGER(ConfParameter);
|
||||
|
||||
// To be changed when breaking changes are made to sync
|
||||
const uint64_t ConfParameter::SYNC_VERSION = 4;
|
||||
const uint64_t ConfParameter::SYNC_VERSION = 6;
|
||||
|
||||
ConfParameter::ConfParameter(ndn::Face& face, const std::string& confFileName)
|
||||
: m_confFileName(confFileName)
|
||||
, 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_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(std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
|
||||
, m_prefixUpdateValidator(std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ConfParameter::writeLog()
|
||||
@@ -38,8 +62,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);
|
||||
@@ -54,7 +78,7 @@ ConfParameter::writeLog()
|
||||
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);
|
||||
@@ -67,15 +91,15 @@ 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");
|
||||
}
|
||||
|
||||
|
||||
+93
-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-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -25,10 +25,15 @@
|
||||
#include "common.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "security/certificate-store.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 +44,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,
|
||||
@@ -128,23 +138,12 @@ 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, const std::string& confFileName = "nlsr.conf");
|
||||
|
||||
const std::string&
|
||||
getConfFileName()
|
||||
{
|
||||
return m_confFileName;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -194,11 +193,10 @@ public:
|
||||
return m_routerPrefix;
|
||||
}
|
||||
|
||||
|
||||
const ndn::Name&
|
||||
getChronosyncPrefix() const
|
||||
getSyncPrefix() const
|
||||
{
|
||||
return m_chronosyncPrefix;
|
||||
return m_syncPrefix;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
@@ -213,6 +211,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
|
||||
{
|
||||
@@ -392,15 +404,26 @@ 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,10 +438,43 @@ 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;
|
||||
}
|
||||
|
||||
security::CertificateStore&
|
||||
getCertStore()
|
||||
{
|
||||
return m_certStore;
|
||||
}
|
||||
|
||||
/*! \brief Dump the current state of all attributes to the log.
|
||||
*/
|
||||
void
|
||||
writeLog();
|
||||
|
||||
private:
|
||||
std::string m_confFileName;
|
||||
ndn::Name m_routerName;
|
||||
ndn::Name m_siteName;
|
||||
ndn::Name m_network;
|
||||
@@ -426,7 +482,7 @@ private:
|
||||
ndn::Name m_routerPrefix;
|
||||
ndn::Name m_lsaRouterPrefix;
|
||||
|
||||
ndn::Name m_chronosyncPrefix;
|
||||
ndn::Name m_syncPrefix;
|
||||
ndn::Name m_lsaPrefix;
|
||||
|
||||
uint32_t m_lsaRefreshTime;
|
||||
@@ -440,7 +496,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 +508,22 @@ private:
|
||||
|
||||
uint32_t m_maxFacesPerPrefix;
|
||||
|
||||
std::string m_seqFileDir;
|
||||
std::string m_stateFileDir;
|
||||
|
||||
ndn::time::milliseconds m_syncInterestLifetime;
|
||||
|
||||
int32_t m_syncProtocol;
|
||||
|
||||
std::string m_confFileNameDynamic;
|
||||
|
||||
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;
|
||||
security::CertificateStore m_certStore;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+63
-56
@@ -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,11 +30,19 @@ 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,
|
||||
ndn::security::SigningInfo& signingInfo,
|
||||
ConfParameter& confParam, RoutingTable& routingTable,
|
||||
Lsdb& lsdb)
|
||||
: m_face(face)
|
||||
, m_scheduler(m_face.getIoService())
|
||||
, m_keyChain(keyChain)
|
||||
, m_signingInfo(signingInfo)
|
||||
, m_confParam(confParam)
|
||||
, m_routingTable(routingTable)
|
||||
, m_lsdb(lsdb)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,41 +50,40 @@ 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));
|
||||
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] (const ndn::Interest& interest, const ndn::lp::Nack& nack)
|
||||
{
|
||||
NDN_LOG_TRACE("Received Nack with reason " << nack.getReason());
|
||||
NDN_LOG_TRACE("Treating as timeout");
|
||||
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::sendScheduledInterest()
|
||||
{
|
||||
std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList();
|
||||
for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end();
|
||||
++it) {
|
||||
for (const auto& adjacent : m_confParam.getAdjacencyList().getAdjList()) {
|
||||
// If this adjacency has a Face, just proceed as usual.
|
||||
if((*it).getFaceId() != 0) {
|
||||
if(adjacent.getFaceId() != 0) {
|
||||
// interest name: /<neighbor>/NLSR/INFO/<router>
|
||||
ndn::Name interestName = (*it).getName() ;
|
||||
ndn::Name interestName = adjacent.getName() ;
|
||||
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());
|
||||
NLSR_LOG_DEBUG("Sending scheduled interest: " << interestName);
|
||||
}
|
||||
}
|
||||
scheduleInterest(m_nlsr.getConfParameter().getInfoInterestInterval());
|
||||
scheduleInterest(m_confParam.getInfoInterestInterval());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -85,7 +92,9 @@ HelloProtocol::scheduleInterest(uint32_t seconds)
|
||||
NLSR_LOG_DEBUG("Scheduling HELLO Interests in " << ndn::time::seconds(seconds));
|
||||
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(seconds),
|
||||
std::bind(&HelloProtocol::sendScheduledInterest, this, seconds));
|
||||
[this] {
|
||||
sendScheduledInterest();
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
@@ -108,22 +117,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_confParam.getAdjacencyList().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_confParam.getAdjacencyList().findAdjacent(neighbor);
|
||||
// If this neighbor was previously inactive, send our own hello interest, too
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_INACTIVE) {
|
||||
// We can only do that if the neighbor currently has a face.
|
||||
@@ -132,9 +141,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 +159,30 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
}
|
||||
ndn::Name neighbor = interestName.getPrefix(-3);
|
||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
|
||||
m_confParam.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
|
||||
|
||||
Adjacent::Status status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
Adjacent::Status status = m_confParam.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
|
||||
uint32_t infoIntTimedOutCount =
|
||||
m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor);
|
||||
m_confParam.getAdjacencyList().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_confParam.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_INACTIVE);
|
||||
|
||||
NLSR_LOG_DEBUG("Neighbor: " << neighbor << " status changed to INACTIVE");
|
||||
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
m_lsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,10 +198,10 @@ HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data)
|
||||
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,20 +214,20 @@ 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_confParam.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
m_confParam.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_ACTIVE);
|
||||
m_confParam.getAdjacencyList().setTimedOutInterestCount(neighbor, 0);
|
||||
Adjacent::Status newStatus = m_confParam.getAdjacencyList().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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-10
@@ -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.
|
||||
*
|
||||
@@ -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,15 +34,16 @@
|
||||
#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);
|
||||
HelloProtocol(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
ndn::security::SigningInfo& signingInfo,
|
||||
ConfParameter& confParam, RoutingTable& routingTable, Lsdb& lsdb);
|
||||
|
||||
/*! \brief Schedules a Hello Interest event.
|
||||
*
|
||||
@@ -68,19 +72,17 @@ 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
|
||||
* before and currently has no Face in NFD, this method will call a
|
||||
* different pipeline that creates the Face first, then registers
|
||||
* prefixes.
|
||||
*/
|
||||
void
|
||||
sendScheduledInterest(uint32_t seconds);
|
||||
sendScheduledInterest();
|
||||
|
||||
/*! \brief Processes a Hello Interest from a neighbor.
|
||||
*
|
||||
@@ -172,8 +174,13 @@ private:
|
||||
registerPrefixes(const ndn::Name& adjName, const std::string& faceUri,
|
||||
double linkCost, const ndn::time::milliseconds& timeout);
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
ndn::Face& m_face;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::security::v2::KeyChain& m_keyChain;
|
||||
ndn::security::SigningInfo& m_signingInfo;
|
||||
ConfParameter& m_confParam;
|
||||
RoutingTable& m_routingTable;
|
||||
Lsdb& m_lsdb;
|
||||
|
||||
static const std::string INFO_COMPONENT;
|
||||
static const std::string NLSR_COMPONENT;
|
||||
|
||||
@@ -85,8 +85,8 @@ LsaSegmentStorage::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
|
||||
|
||||
// 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);
|
||||
NLSR_LOG_TRACE("Received LSA segment is new. Storing it in the storage.");
|
||||
NLSR_LOG_TRACE("LSA data segment's name: " << lsaSegmentName);
|
||||
|
||||
// Delete the same LSA with lower sequence number
|
||||
deleteOldLsas(lsaSegmentName);
|
||||
@@ -97,21 +97,8 @@ LsaSegmentStorage::afterFetcherSignalEmitted(const ndn::Data& lsaSegment)
|
||||
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);
|
||||
}
|
||||
|
||||
+3
-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();
|
||||
}
|
||||
@@ -260,26 +260,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
|
||||
{
|
||||
|
||||
+11
-21
@@ -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
|
||||
@@ -33,8 +33,6 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Lsa
|
||||
{
|
||||
public:
|
||||
@@ -54,6 +52,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~Lsa() = default;
|
||||
|
||||
virtual Type
|
||||
getType() const
|
||||
{
|
||||
@@ -155,7 +156,7 @@ protected:
|
||||
ndn::EventId m_expiringEventId;
|
||||
};
|
||||
|
||||
class NameLsa: public Lsa
|
||||
class NameLsa : public Lsa
|
||||
{
|
||||
public:
|
||||
NameLsa()
|
||||
@@ -229,7 +230,7 @@ private:
|
||||
operator<<(std::ostream& os, const NameLsa& lsa);
|
||||
};
|
||||
|
||||
class AdjLsa: public Lsa
|
||||
class AdjLsa : public Lsa
|
||||
{
|
||||
public:
|
||||
typedef AdjacencyList::const_iterator const_iterator;
|
||||
@@ -281,18 +282,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,7 +317,7 @@ private:
|
||||
operator<<(std::ostream& os, const AdjLsa& lsa);
|
||||
};
|
||||
|
||||
class CoordinateLsa: public Lsa
|
||||
class CoordinateLsa : public Lsa
|
||||
{
|
||||
public:
|
||||
CoordinateLsa()
|
||||
@@ -381,7 +371,7 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
isEqualContent(const CoordinateLsa& clsa);
|
||||
isEqualContent(const CoordinateLsa& clsa) const;
|
||||
|
||||
void
|
||||
writeLog() const override;
|
||||
|
||||
+193
-217
@@ -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.
|
||||
*
|
||||
@@ -24,71 +24,61 @@
|
||||
#include "logger.hpp"
|
||||
#include "lsa-segment-storage.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "publisher/segment-publisher.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER(Lsdb);
|
||||
|
||||
class LsaContentPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
public:
|
||||
LsaContentPublisher(ndn::Face& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
const ndn::security::SigningInfo& signingInfo,
|
||||
const ndn::time::milliseconds& freshnessPeriod,
|
||||
const std::string& content)
|
||||
: SegmentPublisher(face, keyChain, signingInfo, freshnessPeriod)
|
||||
, m_content(content)
|
||||
{
|
||||
}
|
||||
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) {
|
||||
size_t totalLength = 0;
|
||||
totalLength += outBuffer.prependByteArray(reinterpret_cast<const uint8_t*>(m_content.c_str()),
|
||||
m_content.size());
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_content;
|
||||
};
|
||||
|
||||
const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
|
||||
const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
|
||||
const ndn::time::steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE =
|
||||
ndn::time::steady_clock::TimePoint::min();
|
||||
|
||||
Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
, m_sync(m_nlsr.getNlsrFace(),
|
||||
Lsdb::Lsdb(ndn::Face& face, ndn::KeyChain& keyChain,
|
||||
ndn::security::SigningInfo& signingInfo, ConfParameter& confParam,
|
||||
NamePrefixTable& namePrefixTable, RoutingTable& routingTable)
|
||||
: m_face(face)
|
||||
, m_scheduler(face.getIoService())
|
||||
, m_signingInfo(signingInfo)
|
||||
, m_confParam(confParam)
|
||||
, m_namePrefixTable(namePrefixTable)
|
||||
, m_routingTable(routingTable)
|
||||
, m_sync(m_face,
|
||||
[this] (const ndn::Name& routerName, const Lsa::Type& lsaType,
|
||||
const uint64_t& sequenceNumber) {
|
||||
return isLsaNew(routerName, lsaType, sequenceNumber);
|
||||
}, m_nlsr.getConfParameter())
|
||||
, m_lsaStorage(scheduler)
|
||||
, m_lsaRefreshTime(0)
|
||||
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
|
||||
, m_sequencingManager()
|
||||
}, m_confParam)
|
||||
, m_lsaStorage(m_scheduler)
|
||||
, m_lsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()))
|
||||
, m_thisRouterPrefix(m_confParam.getRouterPrefix().toUri())
|
||||
, m_adjLsaBuildInterval(m_confParam.getAdjLsaBuildInterval())
|
||||
, m_sequencingManager(m_confParam.getStateFileDir(), m_confParam.getHyperbolicState())
|
||||
, m_onNewLsaConnection(m_sync.onNewLsa->connect(
|
||||
[this] (const ndn::Name& updateName, const uint64_t& sequenceNumber) {
|
||||
[this] (const ndn::Name& updateName, uint64_t sequenceNumber) {
|
||||
ndn::Name lsaInterest{updateName};
|
||||
lsaInterest.appendNumber(sequenceNumber);
|
||||
expressInterest(lsaInterest, 0);
|
||||
}))
|
||||
, m_segmentPublisher(m_face, keyChain)
|
||||
, m_isBuildAdjLsaSheduled(false)
|
||||
, m_adjBuildCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
Lsdb::~Lsdb()
|
||||
{
|
||||
for (const auto& sp : m_fetchers) {
|
||||
sp->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::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,
|
||||
@@ -105,7 +95,7 @@ Lsdb::onFetchLsaError(uint32_t errorCode,
|
||||
// immediately since at the least the LSA Interest lifetime has elapsed.
|
||||
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
||||
// the potential for constant Interest flooding.
|
||||
ndn::time::seconds delay = m_nlsr.getConfParameter().getLsaInterestLifetime();
|
||||
ndn::time::seconds delay = m_confParam.getLsaInterestLifetime();
|
||||
|
||||
if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||
delay = ndn::time::seconds(0);
|
||||
@@ -118,10 +108,10 @@ Lsdb::onFetchLsaError(uint32_t errorCode,
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, ndn::Name& interestName)
|
||||
Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, const ndn::Name& interestName)
|
||||
{
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(ndn::Name(interestName));
|
||||
data->setContent(bufferPtr);
|
||||
data->setContent(ndn::Block(bufferPtr));
|
||||
|
||||
NLSR_LOG_DEBUG("Received data for LSA(name): " << data->getName());
|
||||
|
||||
@@ -162,10 +152,10 @@ nameLsaCompareByKey(const NameLsa& nlsa1, const ndn::Name& key)
|
||||
bool
|
||||
Lsdb::buildAndInstallOwnNameLsa()
|
||||
{
|
||||
NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
NameLsa nameLsa(m_confParam.getRouterPrefix(),
|
||||
m_sequencingManager.getNameLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getNamePrefixList());
|
||||
m_confParam.getNamePrefixList());
|
||||
m_sequencingManager.increaseNameLsaSeq();
|
||||
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
@@ -225,22 +215,20 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
nlsa.writeLog();
|
||||
|
||||
NLSR_LOG_TRACE("nlsa.getOrigRouter(): " << nlsa.getOrigRouter());
|
||||
NLSR_LOG_TRACE("m_nlsr.getConfParameter().getRouterPrefix(): " << m_nlsr.getConfParameter().getRouterPrefix());
|
||||
NLSR_LOG_TRACE("m_confParam.getRouterPrefix(): " << m_confParam.getRouterPrefix());
|
||||
|
||||
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if (nlsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
// If this name LSA is from another router, add the advertised
|
||||
// prefixes to the NPT.
|
||||
m_nlsr.getNamePrefixTable().addEntry(nlsa.getOrigRouter(),
|
||||
m_namePrefixTable.addEntry(nlsa.getOrigRouter(),
|
||||
nlsa.getOrigRouter());
|
||||
std::list<ndn::Name> nameList = nlsa.getNpl().getNames();
|
||||
for (std::list<ndn::Name>::iterator it = nameList.begin(); it != nameList.end();
|
||||
it++) {
|
||||
if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
|
||||
for (const auto& name : nlsa.getNpl().getNames()) {
|
||||
if (name != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.addEntry(name, nlsa.getOrigRouter());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if (nlsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = nlsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
|
||||
@@ -269,12 +257,11 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
std::list<ndn::Name> namesToAdd;
|
||||
std::set_difference(newNames.begin(), newNames.end(), oldNames.begin(), oldNames.end(),
|
||||
std::inserter(namesToAdd, namesToAdd.begin()));
|
||||
for (std::list<ndn::Name>::iterator it = namesToAdd.begin();
|
||||
it != namesToAdd.end(); ++it) {
|
||||
chkNameLsa->addName((*it));
|
||||
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().addEntry((*it), nlsa.getOrigRouter());
|
||||
for (const auto& name : namesToAdd) {
|
||||
chkNameLsa->addName(name);
|
||||
if (nlsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
if (name != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.addEntry(name, nlsa.getOrigRouter());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,18 +272,17 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
std::list<ndn::Name> namesToRemove;
|
||||
std::set_difference(oldNames.begin(), oldNames.end(), newNames.begin(), newNames.end(),
|
||||
std::inserter(namesToRemove, namesToRemove.begin()));
|
||||
for (std::list<ndn::Name>::iterator it = namesToRemove.begin();
|
||||
it != namesToRemove.end(); ++it) {
|
||||
NLSR_LOG_DEBUG("Removing name LSA no longer advertised: " << (*it).toUri());
|
||||
chkNameLsa->removeName((*it));
|
||||
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if ((*it) != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry((*it), nlsa.getOrigRouter());
|
||||
for (const auto& name : namesToRemove) {
|
||||
NLSR_LOG_DEBUG("Removing name LSA no longer advertised: " << name);
|
||||
chkNameLsa->removeName(name);
|
||||
if (nlsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
if (name != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.removeEntry(name, nlsa.getOrigRouter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nlsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if (nlsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = nlsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
|
||||
@@ -337,13 +323,12 @@ Lsdb::removeNameLsa(const ndn::Name& key)
|
||||
(*it).writeLog();
|
||||
// If the requested name LSA is not ours, we also need to remove
|
||||
// its entries from the NPT.
|
||||
if ((*it).getOrigRouter() !=
|
||||
m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
|
||||
(*it).getOrigRouter());
|
||||
if ((*it).getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.removeEntry((*it).getOrigRouter(), (*it).getOrigRouter());
|
||||
|
||||
for (const auto& name : it->getNpl().getNames()) {
|
||||
if (name != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry(name, it->getOrigRouter());
|
||||
if (name != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.removeEntry(name, it->getOrigRouter());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -369,9 +354,8 @@ void
|
||||
Lsdb::writeNameLsdbLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG("---------------Name LSDB-------------------");
|
||||
for (std::list<NameLsa>::iterator it = m_nameLsdb.begin();
|
||||
it != m_nameLsdb.end() ; it++) {
|
||||
(*it).writeLog();
|
||||
for (const auto& nlsa : m_nameLsdb) {
|
||||
nlsa.writeLog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,14 +380,14 @@ corLsaCompareByKey(const CoordinateLsa& clsa, const ndn::Name& key)
|
||||
bool
|
||||
Lsdb::buildAndInstallOwnCoordinateLsa()
|
||||
{
|
||||
CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
CoordinateLsa corLsa(m_confParam.getRouterPrefix(),
|
||||
m_sequencingManager.getCorLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getConfParameter().getCorR(),
|
||||
m_nlsr.getConfParameter().getCorTheta());
|
||||
m_confParam.getCorR(),
|
||||
m_confParam.getCorTheta());
|
||||
|
||||
// Sync coordinate LSAs if using HR or HR dry run.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_sequencingManager.increaseCorLsaSeq();
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
m_sync.publishRoutingUpdate(Lsa::Type::COORDINATE, m_sequencingManager.getCorLsaSeq());
|
||||
@@ -469,15 +453,15 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
addCoordinateLsa(clsa);
|
||||
|
||||
// Register the LSA's origin router prefix
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
|
||||
if (clsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.addEntry(clsa.getOrigRouter(),
|
||||
clsa.getOrigRouter());
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
// Set the expiration time for the new LSA.
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if (clsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
|
||||
@@ -497,12 +481,12 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
if (!chkCorLsa->isEqualContent(clsa)) {
|
||||
chkCorLsa->setCorRadius(clsa.getCorRadius());
|
||||
chkCorLsa->setCorTheta(clsa.getCorTheta());
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
if (m_confParam.getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
}
|
||||
// If this is an LSA from another router, refresh its expiration time.
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if (clsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = clsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
|
||||
@@ -543,8 +527,8 @@ Lsdb::removeCoordinateLsa(const ndn::Name& key)
|
||||
NLSR_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
it->writeLog();
|
||||
|
||||
if (it->getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry(it->getOrigRouter(), it->getOrigRouter());
|
||||
if (it->getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.removeEntry(it->getOrigRouter(), it->getOrigRouter());
|
||||
}
|
||||
|
||||
m_corLsdb.erase(it);
|
||||
@@ -570,9 +554,8 @@ void
|
||||
Lsdb::writeCorLsdbLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG("---------------Cor LSDB-------------------");
|
||||
for (std::list<CoordinateLsa>::iterator it = m_corLsdb.begin();
|
||||
it != m_corLsdb.end() ; it++) {
|
||||
(*it).writeLog();
|
||||
for (const auto& corLsa : m_corLsdb) {
|
||||
corLsa.writeLog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,19 +580,19 @@ adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
|
||||
void
|
||||
Lsdb::scheduleAdjLsaBuild()
|
||||
{
|
||||
m_nlsr.incrementAdjBuildCount();
|
||||
m_adjBuildCount++;
|
||||
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
// Don't build adjacency LSAs in hyperbolic routing
|
||||
NLSR_LOG_DEBUG("Adjacency LSA not built. Currently in hyperbolic routing state.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
if (m_isBuildAdjLsaSheduled == false) {
|
||||
NLSR_LOG_DEBUG("Scheduling Adjacency LSA build in " << m_adjLsaBuildInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_adjLsaBuildInterval, std::bind(&Lsdb::buildAdjLsa, this));
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
m_isBuildAdjLsaSheduled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,15 +601,15 @@ Lsdb::buildAdjLsa()
|
||||
{
|
||||
NLSR_LOG_TRACE("Lsdb::buildAdjLsa called");
|
||||
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(false);
|
||||
m_isBuildAdjLsaSheduled = false;
|
||||
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
if (m_confParam.getAdjacencyList().isAdjLsaBuildable(m_confParam.getInterestRetryNumber())) {
|
||||
|
||||
int adjBuildCount = m_nlsr.getAdjBuildCount();
|
||||
int adjBuildCount = m_adjBuildCount;
|
||||
// Only do the adjLsa build if there's one scheduled
|
||||
if (adjBuildCount > 0) {
|
||||
// It only makes sense to do the adjLsa build if we have neighbors
|
||||
if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
|
||||
if (m_confParam.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
|
||||
NLSR_LOG_DEBUG("Building and installing own Adj LSA");
|
||||
buildAndInstallOwnAdjLsa();
|
||||
}
|
||||
@@ -637,26 +620,26 @@ Lsdb::buildAdjLsa()
|
||||
else {
|
||||
NLSR_LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors");
|
||||
// Get this router's key
|
||||
ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
|
||||
ndn::Name key = m_confParam.getRouterPrefix();
|
||||
key.append(std::to_string(Lsa::Type::ADJACENCY));
|
||||
|
||||
removeAdjLsa(key);
|
||||
// Recompute routing table after removal
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
// In the case that during building the adj LSA, the FIB has to
|
||||
// wait on an Interest response, the number of scheduled adj LSA
|
||||
// builds could change, so we shouldn't just set it to 0.
|
||||
m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
|
||||
m_adjBuildCount = m_adjBuildCount - adjBuildCount;
|
||||
}
|
||||
}
|
||||
// We are still waiting to know the adjacency status of some
|
||||
// neighbor, so schedule a build for later (when all that has
|
||||
// hopefully finished)
|
||||
else {
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
|
||||
m_nlsr.getConfParameter().getInterestResendTime();
|
||||
m_isBuildAdjLsaSheduled = true;
|
||||
int schedulingTime = m_confParam.getInterestRetryNumber() *
|
||||
m_confParam.getInterestResendTime();
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(schedulingTime),
|
||||
std::bind(&Lsdb::buildAdjLsa, this));
|
||||
}
|
||||
@@ -671,6 +654,13 @@ Lsdb::addAdjLsa(AdjLsa& alsa)
|
||||
alsa.getKey()));
|
||||
if (it == m_adjLsdb.end()) {
|
||||
m_adjLsdb.push_back(alsa);
|
||||
// Add any new name prefixes to the NPT
|
||||
// Only add NPT entries if this is an adj LSA from another router.
|
||||
if (alsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
// Pass the originating router as both the name to register and
|
||||
// where it came from.
|
||||
m_namePrefixTable.addEntry(alsa.getOrigRouter(), alsa.getOrigRouter());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -724,10 +714,9 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
|
||||
NLSR_LOG_DEBUG("Adding Adj Lsa");
|
||||
alsa.writeLog();
|
||||
addAdjLsa(alsa);
|
||||
// Add any new name prefixes to the NPT
|
||||
alsa.addNptEntries(m_nlsr);
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
if (alsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = alsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
|
||||
@@ -749,9 +738,9 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
|
||||
if (!chkAdjLsa->isEqualContent(alsa)) {
|
||||
chkAdjLsa->getAdl().reset();
|
||||
chkAdjLsa->getAdl().addAdjacents(alsa.getAdl());
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
if (alsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if (alsa.getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
ndn::time::system_clock::Duration duration = alsa.getExpirationTimePoint() -
|
||||
ndn::time::system_clock::now();
|
||||
timeToExpire = ndn::time::duration_cast<ndn::time::seconds>(duration);
|
||||
@@ -770,14 +759,14 @@ Lsdb::installAdjLsa(AdjLsa& alsa)
|
||||
bool
|
||||
Lsdb::buildAndInstallOwnAdjLsa()
|
||||
{
|
||||
AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
AdjLsa adjLsa(m_confParam.getRouterPrefix(),
|
||||
m_sequencingManager.getAdjLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
|
||||
m_nlsr.getAdjacencyList());
|
||||
m_confParam.getAdjacencyList().getNumOfActiveNeighbor(),
|
||||
m_confParam.getAdjacencyList());
|
||||
|
||||
//Sync adjacency LSAs if link-state or dry-run HR is enabled.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_ON) {
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_ON) {
|
||||
m_sequencingManager.increaseAdjLsaSeq();
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
m_sync.publishRoutingUpdate(Lsa::Type::ADJACENCY, m_sequencingManager.getAdjLsaSeq());
|
||||
@@ -794,8 +783,10 @@ Lsdb::removeAdjLsa(const ndn::Name& key)
|
||||
std::bind(adjLsaCompareByKey, _1, key));
|
||||
if (it != m_adjLsdb.end()) {
|
||||
NLSR_LOG_DEBUG("Deleting Adj Lsa");
|
||||
(*it).writeLog();
|
||||
(*it).removeNptEntries(m_nlsr);
|
||||
it->writeLog();
|
||||
if (it->getOrigRouter() != m_confParam.getRouterPrefix()) {
|
||||
m_namePrefixTable.removeEntry(it->getOrigRouter(), it->getOrigRouter());
|
||||
}
|
||||
m_adjLsdb.erase(it);
|
||||
return true;
|
||||
}
|
||||
@@ -820,18 +811,6 @@ Lsdb::getAdjLsdb() const
|
||||
return m_adjLsdb;
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::setLsaRefreshTime(const ndn::time::seconds& lsaRefreshTime)
|
||||
{
|
||||
m_lsaRefreshTime = lsaRefreshTime;
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::setThisRouterPrefix(std::string trp)
|
||||
{
|
||||
m_thisRouterPrefix = trp;
|
||||
}
|
||||
|
||||
// This function determines whether a name LSA should be refreshed
|
||||
// or expired. The conditions for getting refreshed are: it is still
|
||||
// in the LSDB, it hasn't been updated by something else already (as
|
||||
@@ -917,7 +896,7 @@ Lsdb::expireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
}
|
||||
// We have changed the contents of the LSDB, so we have to
|
||||
// schedule a routing calculation
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -946,7 +925,7 @@ Lsdb::expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
NLSR_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_sequencingManager.setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
}
|
||||
|
||||
@@ -959,7 +938,7 @@ Lsdb::expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
chkCorLsa->getLsSeqNo(),
|
||||
m_lsaRefreshTime));
|
||||
// Only sync coordinate LSAs if link-state routing is disabled
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
m_sync.publishRoutingUpdate(Lsa::Type::COORDINATE, m_sequencingManager.getCorLsaSeq());
|
||||
}
|
||||
@@ -969,8 +948,8 @@ Lsdb::expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
NLSR_LOG_DEBUG("Other's Cor LSA, so removing from LSDB");
|
||||
removeCoordinateLsa(lsaKey);
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_routingTable.scheduleRoutingTableCalculation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1005,18 +984,31 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
}
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
interest.setInterestLifetime(m_nlsr.getConfParameter().getLsaInterestLifetime());
|
||||
ndn::util::SegmentFetcher::Options options;
|
||||
options.interestLifetime = m_confParam.getLsaInterestLifetime();
|
||||
|
||||
NLSR_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
shared_ptr<ndn::util::SegmentFetcher> fetcher =
|
||||
ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
|
||||
m_nlsr.getValidator(),
|
||||
std::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
|
||||
std::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
|
||||
timeoutCount, deadline, lsaName, seqNo));
|
||||
auto fetcher = ndn::util::SegmentFetcher::start(m_face, interest,
|
||||
m_confParam.getValidator(), options);
|
||||
|
||||
auto it = m_fetchers.insert(fetcher).first;
|
||||
|
||||
fetcher->onComplete.connect([this, interestName, it] (ndn::ConstBufferPtr bufferPtr) {
|
||||
afterFetchLsa(bufferPtr, interestName);
|
||||
m_fetchers.erase(it);
|
||||
});
|
||||
|
||||
fetcher->onError.connect([this, interestName, timeoutCount, deadline, lsaName, seqNo, it]
|
||||
(uint32_t errorCode, const std::string& msg) {
|
||||
onFetchLsaError(errorCode, msg, interestName,
|
||||
timeoutCount, deadline, lsaName, seqNo);
|
||||
m_fetchers.erase(it);
|
||||
});
|
||||
|
||||
m_lsaStorage.connectToFetcher(*fetcher);
|
||||
m_nlsr.connectToFetcher(*fetcher);
|
||||
fetcher->afterSegmentValidated.connect([this] (const ndn::Data& data) {
|
||||
afterSegmentValidatedSignal(data);
|
||||
});
|
||||
|
||||
// increment a specific SENT_LSA_INTEREST
|
||||
Lsa::Type lsaType;
|
||||
@@ -1039,77 +1031,66 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
void
|
||||
Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
{
|
||||
ndn::Name interestName(interest.getName());
|
||||
NLSR_LOG_DEBUG("Interest received for LSA: " << interestName);
|
||||
|
||||
if (interestName[-2].isVersion()) {
|
||||
// Interest for particular segment
|
||||
if (m_segmentPublisher.replyFromStore(interestName)) {
|
||||
NLSR_LOG_TRACE("Reply from SegmentPublisher storage");
|
||||
return;
|
||||
}
|
||||
// Remove version and segment
|
||||
interestName = interestName.getSubName(0, interestName.size() - 2);
|
||||
NLSR_LOG_TRACE("Interest w/o segment and version: " << interestName);
|
||||
}
|
||||
|
||||
// increment RCV_LSA_INTEREST
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_LSA_INTEREST);
|
||||
|
||||
const ndn::Name& interestName(interest.getName());
|
||||
NLSR_LOG_DEBUG("Interest received for LSA: " << interestName);
|
||||
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
|
||||
int32_t lsaPosition = util::getNameComponentPosition(interestName, chkString);
|
||||
|
||||
// Forms the name of the router that the Interest packet came from.
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
ndn::Name originRouter = m_confParam.getNetwork();
|
||||
originRouter.append(interestName.getSubName(lsaPosition + 1,
|
||||
interest.getName().size() - lsaPosition - 3));
|
||||
interestName.size() - lsaPosition - 3));
|
||||
|
||||
// if the interest is for this router's LSA
|
||||
if (originRouter == m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
if (originRouter == m_confParam.getRouterPrefix() && lsaPosition >= 0) {
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
std::string lsaType = interestName[-2].toUri();
|
||||
Lsa::Type interestedLsType;
|
||||
std::istringstream(lsaType) >> interestedLsType;
|
||||
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
NLSR_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
|
||||
|
||||
Lsa::Type interestedLsType;
|
||||
std::istringstream(interestName[-2].toUri()) >> interestedLsType;
|
||||
|
||||
if (interestedLsType == Lsa::Type::NAME) {
|
||||
processInterestForNameLsa(interest, originRouter.append(std::to_string(interestedLsType)),
|
||||
seqNo);
|
||||
}
|
||||
else if (interestedLsType == Lsa::Type::ADJACENCY) {
|
||||
processInterestForAdjacencyLsa(interest, originRouter.append(std::to_string(interestedLsType)),
|
||||
seqNo);
|
||||
}
|
||||
else if (interestedLsType == Lsa::Type::COORDINATE) {
|
||||
processInterestForCoordinateLsa(interest, originRouter.append(std::to_string(interestedLsType)),
|
||||
seqNo);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
|
||||
}
|
||||
lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
|
||||
if (interestedLsType == Lsa::Type::NAME) {
|
||||
processInterestForNameLsa(interest, originRouter.append(lsaType), seqNo);
|
||||
}
|
||||
else if (interestedLsType == Lsa::Type::ADJACENCY) {
|
||||
processInterestForAdjacencyLsa(interest, originRouter.append(lsaType), seqNo);
|
||||
}
|
||||
else if (interestedLsType == Lsa::Type::COORDINATE) {
|
||||
processInterestForCoordinateLsa(interest, originRouter.append(lsaType), seqNo);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
|
||||
}
|
||||
lsaIncrementSignal(Statistics::PacketType::SENT_LSA_DATA);
|
||||
}
|
||||
else { // else the interest is for other router's lsa, serve from LsaSegmentStorage
|
||||
const ndn::Data* lsaSegment = m_lsaStorage.getLsaSegment(interest);
|
||||
if (lsaSegment != nullptr) {
|
||||
NLSR_LOG_TRACE("Found data in lsa storage. Sending the data for " << interest.getName());
|
||||
m_nlsr.getNlsrFace().put(*lsaSegment);
|
||||
m_face.put(*lsaSegment);
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_TRACE(interest << " was not found in this lsa storage.");
|
||||
NLSR_LOG_TRACE(interest << " was not found in this lsa storage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// \brief Sends LSA data.
|
||||
// \param interest The Interest that warranted the data.
|
||||
// \param content The data that the Interest was seeking.
|
||||
void
|
||||
Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
|
||||
{
|
||||
LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
|
||||
m_nlsr.getKeyChain(),
|
||||
m_nlsr.getSigningInfo(),
|
||||
m_lsaRefreshTime,
|
||||
content);
|
||||
NLSR_LOG_DEBUG("Sending requested data ( " << content << ") for interest (" << interest
|
||||
<< ") to be published and added to face.");
|
||||
publisher.publish(interest.getName());
|
||||
}
|
||||
|
||||
// \brief Finds and sends a requested name LSA.
|
||||
// \param interest The interest that seeks the name LSA.
|
||||
// \param lsaKey The LSA that the Interest is seeking.
|
||||
@@ -1123,17 +1104,15 @@ Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
|
||||
// increment RCV_NAME_LSA_INTEREST
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_INTEREST);
|
||||
NLSR_LOG_DEBUG("nameLsa interest " << interest << " received");
|
||||
NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
|
||||
NameLsa* nameLsa = findNameLsa(lsaKey);
|
||||
if (nameLsa != nullptr) {
|
||||
NLSR_LOG_TRACE("Verifying SeqNo for NameLsa is same as requested.");
|
||||
if (nameLsa->getLsSeqNo() == seqNo) {
|
||||
// if requested lsa belongs to this router then sign it and serve it
|
||||
std::string content = nameLsa->serialize();
|
||||
putLsaData(interest,content);
|
||||
// else the requested belongs to neighboring routers, so serve the
|
||||
// original data packet corresponding to the lsa
|
||||
m_segmentPublisher.publish(interest.getName(), interest.getName(),
|
||||
ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
|
||||
m_lsaRefreshTime, m_signingInfo);
|
||||
|
||||
// increment SENT_NAME_LSA_DATA
|
||||
lsaIncrementSignal(Statistics::PacketType::SENT_NAME_LSA_DATA);
|
||||
}
|
||||
else {
|
||||
@@ -1155,20 +1134,21 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
NLSR_LOG_ERROR("Received interest for an adjacency LSA when hyperbolic routing is enabled");
|
||||
}
|
||||
|
||||
// increment RCV_ADJ_LSA_INTEREST
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_INTEREST);
|
||||
NLSR_LOG_DEBUG("AdjLsa interest " << interest << " received");
|
||||
AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
|
||||
AdjLsa* adjLsa = findAdjLsa(lsaKey);
|
||||
if (adjLsa != nullptr) {
|
||||
NLSR_LOG_TRACE("Verifying SeqNo for AdjLsa is same as requested.");
|
||||
if (adjLsa->getLsSeqNo() == seqNo) {
|
||||
std::string content = adjLsa->serialize();
|
||||
putLsaData(interest,content);
|
||||
// increment SENT_ADJ_LSA_DATA
|
||||
m_segmentPublisher.publish(interest.getName(), interest.getName(),
|
||||
ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
|
||||
m_lsaRefreshTime, m_signingInfo);
|
||||
|
||||
lsaIncrementSignal(Statistics::PacketType::SENT_ADJ_LSA_DATA);
|
||||
}
|
||||
else {
|
||||
@@ -1190,20 +1170,21 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
NLSR_LOG_ERROR("Received Interest for a coordinate LSA when link-state routing is enabled");
|
||||
}
|
||||
|
||||
// increment RCV_COORD_LSA_INTEREST
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_INTEREST);
|
||||
NLSR_LOG_DEBUG("CoordinateLsa interest " << interest << " received");
|
||||
CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
|
||||
CoordinateLsa* corLsa = findCoordinateLsa(lsaKey);
|
||||
if (corLsa != nullptr) {
|
||||
NLSR_LOG_TRACE("Verifying SeqNo for CoordinateLsa is same as requested.");
|
||||
if (corLsa->getLsSeqNo() == seqNo) {
|
||||
std::string content = corLsa->serialize();
|
||||
putLsaData(interest,content);
|
||||
// increment SENT_COORD_LSA_DATA
|
||||
m_segmentPublisher.publish(interest.getName(), interest.getName(),
|
||||
ndn::encoding::makeStringBlock(ndn::tlv::Content, content),
|
||||
m_lsaRefreshTime, m_signingInfo);
|
||||
|
||||
lsaIncrementSignal(Statistics::PacketType::SENT_COORD_LSA_DATA);
|
||||
}
|
||||
else {
|
||||
@@ -1227,7 +1208,7 @@ Lsdb::onContentValidated(const std::shared_ptr<const ndn::Data>& data)
|
||||
if (lsaPosition >= 0) {
|
||||
|
||||
// Extracts the prefix of the originating router from the data.
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
ndn::Name originRouter = m_confParam.getNetwork();
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 3));
|
||||
|
||||
uint64_t seqNo = dataName[-1].toNumber();
|
||||
@@ -1253,7 +1234,6 @@ Lsdb::onContentValidated(const std::shared_ptr<const ndn::Data>& data)
|
||||
NLSR_LOG_WARN("Received unrecognized LSA Type: " << interestedLsType);
|
||||
}
|
||||
|
||||
// increment RCV_LSA_DATA
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_LSA_DATA);
|
||||
}
|
||||
}
|
||||
@@ -1262,7 +1242,6 @@ void
|
||||
Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
{
|
||||
// increment RCV_NAME_LSA_DATA
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_NAME_LSA_DATA);
|
||||
if (isNameLsaNew(lsaKey, lsSeqNo)) {
|
||||
NameLsa nameLsa;
|
||||
@@ -1279,7 +1258,6 @@ void
|
||||
Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
{
|
||||
// increment RCV_ADJ_LSA_DATA
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_ADJ_LSA_DATA);
|
||||
if (isAdjLsaNew(lsaKey, lsSeqNo)) {
|
||||
AdjLsa adjLsa;
|
||||
@@ -1296,7 +1274,6 @@ void
|
||||
Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
{
|
||||
// increment RCV_COORD_LSA_DATA
|
||||
lsaIncrementSignal(Statistics::PacketType::RCV_COORD_LSA_DATA);
|
||||
if (isCoordinateLsaNew(lsaKey, lsSeqNo)) {
|
||||
CoordinateLsa corLsa;
|
||||
@@ -1314,7 +1291,7 @@ Lsdb::getLsaExpirationTimePoint()
|
||||
{
|
||||
ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
|
||||
expirationTimePoint = expirationTimePoint +
|
||||
ndn::time::seconds(m_nlsr.getConfParameter().getRouterDeadInterval());
|
||||
ndn::time::seconds(m_confParam.getRouterDeadInterval());
|
||||
return expirationTimePoint;
|
||||
}
|
||||
|
||||
@@ -1322,9 +1299,8 @@ void
|
||||
Lsdb::writeAdjLsdbLog()
|
||||
{
|
||||
NLSR_LOG_DEBUG("---------------Adj LSDB-------------------");
|
||||
for (std::list<AdjLsa>::iterator it = m_adjLsdb.begin();
|
||||
it != m_adjLsdb.end() ; it++) {
|
||||
(*it).writeLog();
|
||||
for (const auto& adj : m_adjLsdb) {
|
||||
adj.writeLog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+42
-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.
|
||||
*
|
||||
@@ -29,21 +29,28 @@
|
||||
#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 <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,
|
||||
ndn::security::SigningInfo& signingInfo, ConfParameter& confParam,
|
||||
NamePrefixTable& namePrefixTable, RoutingTable& routingTable);
|
||||
|
||||
~Lsdb();
|
||||
|
||||
SyncLogicHandler&
|
||||
getSyncLogicHandler()
|
||||
@@ -196,28 +203,28 @@ public:
|
||||
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;
|
||||
}
|
||||
|
||||
private:
|
||||
/* \brief Add a name LSA to the LSDB if it isn't already there.
|
||||
\param nlsa The candidade name LSA.
|
||||
@@ -306,9 +313,6 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
void
|
||||
putLsaData(const ndn::Interest& interest, const std::string& content);
|
||||
|
||||
void
|
||||
processInterestForNameLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
@@ -356,7 +360,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,7 +373,7 @@ 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);
|
||||
|
||||
private:
|
||||
ndn::time::system_clock::TimePoint
|
||||
@@ -383,13 +387,22 @@ 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;
|
||||
ndn::Face& m_face;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::security::SigningInfo& m_signingInfo;
|
||||
|
||||
ConfParameter& m_confParam;
|
||||
NamePrefixTable& m_namePrefixTable;
|
||||
RoutingTable& m_routingTable;
|
||||
SyncLogicHandler m_sync;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
LsaSegmentStorage m_lsaStorage;
|
||||
|
||||
private:
|
||||
std::list<NameLsa> m_nameLsdb;
|
||||
std::list<AdjLsa> m_adjLsdb;
|
||||
std::list<CoordinateLsa> m_corLsdb;
|
||||
@@ -411,6 +424,12 @@ private:
|
||||
SequencingManager m_sequencingManager;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+50
-25
@@ -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.
|
||||
*
|
||||
@@ -19,6 +19,7 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "nlsr-runner.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
#include <sstream>
|
||||
|
||||
template<typename E>
|
||||
std::string
|
||||
static std::string
|
||||
getExtendedErrorMessage(const E& exception)
|
||||
{
|
||||
std::ostringstream errorMessage;
|
||||
@@ -46,41 +47,65 @@ 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);
|
||||
|
||||
nlsr::ConfParameter confParam(face, configFileName);
|
||||
nlsr::ConfFileProcessor configProcessor(confParam);
|
||||
|
||||
if (!configProcessor.processConfFile()) {
|
||||
std::cerr << "Error in configuration file processing" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
confParam.buildRouterPrefix();
|
||||
confParam.writeLog();
|
||||
|
||||
nlsr::NlsrRunner runner(face, confParam);
|
||||
|
||||
try {
|
||||
runner.run();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << getExtendedErrorMessage(e) << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
std::cerr << "FATAL: " << getExtendedErrorMessage(e) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
return 0;
|
||||
}
|
||||
+10
-44
@@ -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.
|
||||
*
|
||||
@@ -20,62 +20,28 @@
|
||||
**/
|
||||
|
||||
#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)
|
||||
NlsrRunner::NlsrRunner(ndn::Face& face, ConfParameter& confParam)
|
||||
: m_face(face)
|
||||
, m_confParam(confParam)
|
||||
, m_nlsr(m_face, m_keyChain, m_confParam)
|
||||
{
|
||||
m_nlsr.setConfFileName(configFileName);
|
||||
}
|
||||
|
||||
void
|
||||
NlsrRunner::run()
|
||||
{
|
||||
ConfFileProcessor configProcessor(m_nlsr, m_nlsr.getConfFileName());
|
||||
m_nlsr.initialize();
|
||||
|
||||
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();
|
||||
m_face.processEvents();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
NLSR_LOG_FATAL("ERROR: " << e.what());
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
|
||||
catch (...) {
|
||||
m_nlsr.getFib().clean();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
+8
-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.
|
||||
*
|
||||
@@ -23,13 +23,11 @@
|
||||
#define NLSR_NLSR_RUNNER_HPP
|
||||
|
||||
#include "nlsr.hpp"
|
||||
#include "conf-parameter.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.
|
||||
@@ -40,22 +38,11 @@ namespace nlsr {
|
||||
* 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);
|
||||
NlsrRunner(ndn::Face& face, ConfParameter& confParam);
|
||||
|
||||
/*! \brief Instantiate, configure, and start the NLSR process.
|
||||
*
|
||||
@@ -64,22 +51,17 @@ public:
|
||||
* 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.
|
||||
*
|
||||
* \throws ConfFileError 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::Face& m_face;
|
||||
ndn::KeyChain m_keyChain;
|
||||
ConfParameter& m_confParam;
|
||||
Nlsr m_nlsr;
|
||||
};
|
||||
|
||||
|
||||
+101
-180
@@ -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.
|
||||
*
|
||||
@@ -39,45 +39,42 @@ 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_signingInfo,
|
||||
m_confParam, m_namePrefixTable, m_routingTable)
|
||||
, m_afterSegmentValidatedConnection(m_lsdb.afterSegmentValidatedSignal.connect(
|
||||
std::bind(&Nlsr::afterFetcherSignalEmitted, this, _1)))
|
||||
, m_dispatcher(m_face, m_keyChain)
|
||||
, m_datasetHandler(m_dispatcher, m_lsdb, m_routingTable)
|
||||
, m_helloProtocol(m_face, m_keyChain, m_signingInfo, confParam, m_routingTable, m_lsdb)
|
||||
, m_certStore(m_confParam.getCertStore())
|
||||
, m_controller(m_face, m_keyChain)
|
||||
, m_faceDatasetController(m_face, m_keyChain)
|
||||
, m_prefixUpdateProcessor(m_dispatcher,
|
||||
m_nlsrFace,
|
||||
m_confParam.getPrefixUpdateValidator(),
|
||||
m_namePrefixList,
|
||||
m_nlsrLsdb)
|
||||
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_lsdb)
|
||||
, m_statsCollector(m_lsdb, m_helloProtocol)
|
||||
, m_faceMonitor(m_face)
|
||||
{
|
||||
m_faceMonitor.onNotification.connect(std::bind(&Nlsr::onFaceEventNotification, this, _1));
|
||||
m_faceMonitor.start();
|
||||
|
||||
setStrategies();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -97,18 +94,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_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -118,20 +113,18 @@ 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_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Nlsr::addDispatcherTopPrefix(const ndn::Name& topPrefix)
|
||||
{
|
||||
try {
|
||||
// false since we want to have control over the registration process
|
||||
m_dispatcher.addTopPrefix(topPrefix, false, m_signingInfo);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@@ -145,44 +138,7 @@ 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();
|
||||
}
|
||||
m_fib.setStrategy(m_confParam.getSyncPrefix(), strategy, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -197,15 +153,6 @@ Nlsr::loadCertToPublish(const ndn::security::v2::Certificate& 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)
|
||||
{
|
||||
@@ -227,15 +174,13 @@ Nlsr::publishCertFromCache(const ndn::Name& 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);
|
||||
ndn::Name certName = ndn::security::v2::extractKeyNameFromCertName(cert->getName());
|
||||
NLSR_LOG_TRACE("Setting interest filter for: " << certName);
|
||||
m_face.setInterestFilter(ndn::InterestFilter(certName).allowLoopback(false),
|
||||
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());
|
||||
@@ -250,34 +195,22 @@ 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());
|
||||
|
||||
// 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(m_confParam.getRouterPrefix());
|
||||
addDispatcherTopPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"));
|
||||
addDispatcherTopPrefix(LOCALHOST_PREFIX);
|
||||
|
||||
initializeFaces(std::bind(&Nlsr::processFaceDataset, this, _1),
|
||||
@@ -285,22 +218,18 @@ Nlsr::initialize()
|
||||
|
||||
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();
|
||||
registerRouterPrefix();
|
||||
|
||||
m_helloProtocol.scheduleInterest(m_firstHelloInterval);
|
||||
m_helloProtocol.scheduleInterest(m_confParam.getFirstHelloInterval());
|
||||
|
||||
// Need to set direct neighbors' costs to 0 for hyperbolic routing
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
@@ -319,7 +248,7 @@ Nlsr::initializeKey()
|
||||
NLSR_LOG_DEBUG("Initializing Key ...");
|
||||
|
||||
ndn::Name nlsrInstanceName = m_confParam.getRouterPrefix();
|
||||
nlsrInstanceName.append("NLSR");
|
||||
nlsrInstanceName.append("nlsr");
|
||||
|
||||
try {
|
||||
m_keyChain.deleteIdentity(m_keyChain.getPib().getIdentity(nlsrInstanceName));
|
||||
@@ -368,71 +297,69 @@ Nlsr::initializeKey()
|
||||
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");
|
||||
ndn::Name nlsrKeyPrefix = m_confParam.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);
|
||||
m_face.setInterestFilter(ndn::InterestFilter(nlsrKeyPrefix).allowLoopback(false),
|
||||
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();
|
||||
ndn::Name routerKeyPrefix = m_confParam.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);
|
||||
m_face.setInterestFilter(ndn::InterestFilter(routerKeyPrefix).allowLoopback(false),
|
||||
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());
|
||||
ndn::Name operatorKeyPrefix = m_confParam.getNetwork();
|
||||
operatorKeyPrefix.append(m_confParam.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);
|
||||
m_face.setInterestFilter(ndn::InterestFilter(operatorKeyPrefix).allowLoopback(false),
|
||||
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());
|
||||
ndn::Name siteKeyPrefix = m_confParam.getNetwork();
|
||||
siteKeyPrefix.append(m_confParam.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);
|
||||
m_face.setInterestFilter(ndn::InterestFilter(siteKeyPrefix).allowLoopback(false),
|
||||
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::registerRouterPrefix()
|
||||
{
|
||||
m_face.registerPrefix(ndn::Name(m_confParam.getRouterPrefix()).append("nlsr"),
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -448,7 +375,7 @@ Nlsr::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
return; // cert is not found
|
||||
}
|
||||
|
||||
m_nlsrFace.put(*cert);
|
||||
m_face.put(*cert);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -496,10 +423,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -528,10 +455,10 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
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;
|
||||
@@ -596,7 +523,7 @@ Nlsr::registerAdjacencyPrefixes(const Adjacent& adj,
|
||||
m_fib.registerPrefix(adjName, faceUri, linkCost,
|
||||
timeout, ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
|
||||
m_fib.registerPrefix(m_confParam.getChronosyncPrefix(),
|
||||
m_fib.registerPrefix(m_confParam.getSyncPrefix(),
|
||||
faceUri, linkCost, timeout,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
|
||||
@@ -675,10 +602,4 @@ Nlsr::onFaceIdIndicationFailure(const ndn::nfd::ControlResponse& cr)
|
||||
NLSR_LOG_DEBUG(os.str());
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::startEventLoop()
|
||||
{
|
||||
m_nlsrFace.processEvents();
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
+30
-262
@@ -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.
|
||||
*
|
||||
@@ -80,7 +80,7 @@ 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
|
||||
registrationFailed(const ndn::Name& name);
|
||||
@@ -102,147 +102,12 @@ 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;
|
||||
}
|
||||
|
||||
Fib&
|
||||
getFib()
|
||||
{
|
||||
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();
|
||||
|
||||
@@ -298,9 +163,6 @@ public:
|
||||
void
|
||||
loadCertToPublish(const ndn::security::v2::Certificate& certificate);
|
||||
|
||||
void
|
||||
connectToFetcher(ndn::util::SegmentFetcher& fetcher);
|
||||
|
||||
/*! \brief Callback when SegmentFetcher retrieves a segment.
|
||||
*/
|
||||
void
|
||||
@@ -316,19 +178,6 @@ public:
|
||||
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
|
||||
@@ -346,77 +195,9 @@ public:
|
||||
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&
|
||||
@@ -436,6 +217,11 @@ private:
|
||||
void
|
||||
registerLocalhostPrefix();
|
||||
|
||||
/*! \brief Registers the <router-prefix>/nlsr so that NLSR can respond to status requests from remote routers.
|
||||
*/
|
||||
void
|
||||
registerRouterPrefix();
|
||||
|
||||
/*! \brief Attempts to satisfy an Interest for a certificate, and send it back.
|
||||
*/
|
||||
void
|
||||
@@ -451,23 +237,6 @@ private:
|
||||
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 +260,48 @@ 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;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
HelloProtocol m_helloProtocol;
|
||||
Fib m_fib;
|
||||
RoutingTable m_routingTable;
|
||||
NamePrefixTable m_namePrefixTable;
|
||||
Lsdb m_lsdb;
|
||||
|
||||
ndn::security::ValidatorConfig m_validator;
|
||||
private:
|
||||
ndn::util::signal::ScopedConnection m_afterSegmentValidatedConnection;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::mgmt::Dispatcher m_dispatcher;
|
||||
DatasetInterestHandler m_datasetHandler;
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
private:
|
||||
/*! \brief Where NLSR stores certificates it claims to be
|
||||
* authoritative for. Usually the router certificate.
|
||||
*/
|
||||
security::CertificateStore m_certStore;
|
||||
security::CertificateStore& m_certStore;
|
||||
|
||||
ndn::nfd::Controller m_controller;
|
||||
ndn::nfd::Controller m_faceDatasetController;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
ndn::Name m_defaultCertName;
|
||||
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())
|
||||
{
|
||||
|
||||
@@ -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,10 +112,8 @@ 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;
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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).
|
||||
@@ -21,10 +21,10 @@
|
||||
#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
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
writeLog();
|
||||
writeLog() const;
|
||||
|
||||
typedef NexthopList::const_iterator const_iterator;
|
||||
|
||||
|
||||
+65
-68
@@ -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).
|
||||
@@ -35,20 +35,26 @@ INIT_LOGGER(route.Fib);
|
||||
|
||||
const uint64_t Fib::GRACE_PERIOD = 10;
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
// 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 +62,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 +84,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,7 +96,7 @@ 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;
|
||||
for (NexthopList::iterator it = allHops.cbegin(); it != allHops.cend() && nFaces < maxFaces;
|
||||
++it, ++nFaces) {
|
||||
hopsToAdd.addNextHop(*it);
|
||||
}
|
||||
@@ -126,9 +134,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 +150,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 +164,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,12 +191,9 @@ 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
|
||||
@@ -215,14 +216,13 @@ 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,
|
||||
"Successful in name registration",
|
||||
faceUri),
|
||||
std::bind(&Fib::onRegistrationFailure, this, _1,
|
||||
"Failed in name registration",
|
||||
faceParameters,
|
||||
faceUri, times));
|
||||
}
|
||||
else {
|
||||
NLSR_LOG_WARN("Error: No Face Id for face uri: " << faceUri);
|
||||
@@ -234,7 +234,7 @@ Fib::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResu
|
||||
const std::string& message, const ndn::FaceUri& faceUri)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << commandSuccessResult.getName() <<
|
||||
" Face Uri: " << faceUri << " faceId: " << commandSuccessResult.getFaceId());
|
||||
" Face Uri: " << faceUri << " faceId: " << commandSuccessResult.getFaceId());
|
||||
|
||||
AdjacencyList::iterator adjacent = m_adjacencyList.findAdjacent(faceUri);
|
||||
if (adjacent != m_adjacencyList.end()) {
|
||||
@@ -292,7 +292,7 @@ Fib::onUnregistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessRe
|
||||
const std::string& message)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Unregister successful Prefix: " << commandSuccessResult.getName() <<
|
||||
" Face Id: " << commandSuccessResult.getFaceId());
|
||||
" Face Id: " << commandSuccessResult.getFaceId());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -323,8 +323,8 @@ void
|
||||
Fib::onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
|
||||
const std::string& message)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << commandSuccessResult.getStrategy() << " "
|
||||
<< "for name: " << commandSuccessResult.getName());
|
||||
NLSR_LOG_DEBUG(message << ": " << commandSuccessResult.getStrategy() <<
|
||||
" for name: " << commandSuccessResult.getName());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -333,19 +333,19 @@ Fib::onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
|
||||
uint32_t count,
|
||||
const std::string& message)
|
||||
{
|
||||
NLSR_LOG_DEBUG(message << ": " << parameters.getStrategy() << " "
|
||||
<< "for name: " << parameters.getName());
|
||||
NLSR_LOG_DEBUG(message << ": " << 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,
|
||||
@@ -355,14 +355,13 @@ Fib::scheduleEntryRefresh(FibEntry& entry, const afterRefreshCallback& refreshCa
|
||||
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());
|
||||
NLSR_LOG_DEBUG("Canceling refresh for " << entry.getName() << " Seq Num: " << entry.getSeqNo());
|
||||
|
||||
m_scheduler.cancelEvent(entry.getRefreshEventId());
|
||||
entry.getRefreshEventId().reset();
|
||||
@@ -381,7 +380,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 +397,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-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-2018, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -17,8 +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_ROUTE_FIB_HPP
|
||||
#define NLSR_ROUTE_FIB_HPP
|
||||
@@ -54,15 +53,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 +64,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 +78,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 +141,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 +150,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.
|
||||
*
|
||||
|
||||
+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,7 +22,6 @@
|
||||
#include "routing-table-calculator.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "map.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "nexthop.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "logger.hpp"
|
||||
@@ -57,21 +56,17 @@ RoutingTableCalculator::initMatrix()
|
||||
}
|
||||
|
||||
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))
|
||||
@@ -119,7 +114,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 +128,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);
|
||||
@@ -224,24 +219,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 +253,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();
|
||||
@@ -318,8 +314,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");
|
||||
|
||||
@@ -341,7 +338,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 +422,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,12 +465,12 @@ 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);
|
||||
*destRouterName);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -485,8 +482,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 +611,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,7 +36,6 @@ namespace nlsr {
|
||||
|
||||
class Map;
|
||||
class RoutingTable;
|
||||
class Nlsr;
|
||||
|
||||
class RoutingTableCalculator
|
||||
{
|
||||
@@ -56,12 +57,11 @@ protected:
|
||||
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);
|
||||
|
||||
void
|
||||
writeAdjMatrixLog(const Map& map) const;
|
||||
@@ -137,7 +137,8 @@ public:
|
||||
}
|
||||
|
||||
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.
|
||||
@@ -168,7 +169,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.
|
||||
@@ -215,11 +216,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);
|
||||
|
||||
+67
-81
@@ -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"
|
||||
@@ -34,39 +35,44 @@ 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_fib(fib)
|
||||
, m_lsdb(lsdb)
|
||||
, m_namePrefixTable(namePrefixTable)
|
||||
, m_NO_NEXT_HOP{-12345}
|
||||
, m_routingCalcInterval{static_cast<uint32_t>(ROUTING_CALC_INTERVAL_DEFAULT)}
|
||||
, 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 +81,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 +113,60 @@ 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 != true) {
|
||||
NLSR_LOG_DEBUG("Scheduling routing table calculation in " << m_routingCalcInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_routingCalcInterval,
|
||||
std::bind(&RoutingTable::calculate, this, std::ref(pnlsr)));
|
||||
std::bind(&RoutingTable::calculate, this));
|
||||
|
||||
pnlsr.setIsRouteCalculationScheduled(true);
|
||||
m_isRouteCalculationScheduled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,23 +206,21 @@ RoutingTable::findRoutingTableEntry(const ndn::Name& destRouter)
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
-14
@@ -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,10 +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);
|
||||
scheduleRoutingTableCalculation();
|
||||
|
||||
int
|
||||
getNoNextHop()
|
||||
@@ -114,15 +114,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 +127,7 @@ private:
|
||||
clearDryRoutingTable();
|
||||
|
||||
void
|
||||
writeLog(int hyperbolicState);
|
||||
writeLog();
|
||||
|
||||
public:
|
||||
std::unique_ptr<AfterRoutingChange> afterRoutingChange;
|
||||
@@ -141,12 +137,20 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
|
||||
private:
|
||||
ndn::Scheduler& m_scheduler;
|
||||
Fib& m_fib;
|
||||
Lsdb& m_lsdb;
|
||||
NamePrefixTable& m_namePrefixTable;
|
||||
|
||||
const int m_NO_NEXT_HOP;
|
||||
|
||||
std::list<RoutingTableEntry> m_dryTable;
|
||||
|
||||
ndn::time::seconds m_routingCalcInterval;
|
||||
|
||||
bool m_isRoutingTableCalculating;
|
||||
bool m_isRouteCalculationScheduled;
|
||||
|
||||
ConfParameter& m_confParam;
|
||||
};
|
||||
|
||||
} // 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.
|
||||
*
|
||||
@@ -34,6 +34,16 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER(SequencingManager);
|
||||
|
||||
SequencingManager::SequencingManager(std::string filePath, int hypState)
|
||||
: m_nameLsaSeq(0)
|
||||
, m_adjLsaSeq(0)
|
||||
, m_corLsaSeq(0)
|
||||
, m_hyperbolicState(hypState)
|
||||
{
|
||||
setSeqFileDirectory(filePath);
|
||||
initiateSeqNoFromFile();
|
||||
}
|
||||
|
||||
void
|
||||
SequencingManager::writeSeqNoToFile() const
|
||||
{
|
||||
@@ -48,7 +58,7 @@ 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());
|
||||
@@ -87,7 +97,7 @@ SequencingManager::initiateSeqNoFromFile(int hypState)
|
||||
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.");
|
||||
@@ -97,7 +107,7 @@ SequencingManager::initiateSeqNoFromFile(int hypState)
|
||||
}
|
||||
|
||||
// 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.");
|
||||
@@ -110,7 +120,7 @@ SequencingManager::initiateSeqNoFromFile(int hypState)
|
||||
}
|
||||
|
||||
void
|
||||
SequencingManager::setSeqFileDirectory(std::string filePath)
|
||||
SequencingManager::setSeqFileDirectory(const std::string& filePath)
|
||||
{
|
||||
m_seqFileNameWithPath = filePath;
|
||||
|
||||
|
||||
+14
-14
@@ -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(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,7 +107,7 @@ public:
|
||||
\param filePath The directory where sequence file will be stored
|
||||
*/
|
||||
void
|
||||
setSeqFileDirectory(std::string filePath);
|
||||
setSeqFileDirectory(const std::string& filePath);
|
||||
|
||||
void
|
||||
writeLog() const;
|
||||
@@ -120,6 +117,9 @@ private:
|
||||
uint64_t m_adjLsaSeq;
|
||||
uint64_t m_corLsaSeq;
|
||||
std::string m_seqFileNameWithPath;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
int m_hyperbolicState;
|
||||
};
|
||||
|
||||
} // 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,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 "coordinate-lsa.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
@@ -50,21 +50,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 += prependDouble(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 += prependDouble(block, ndn::tlv::nlsr::HyperbolicRadius, m_hyperbolicRadius);
|
||||
|
||||
totalLength += m_lsaInfo.wireEncode(block);
|
||||
|
||||
@@ -74,11 +65,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
|
||||
@@ -127,17 +114,8 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
|
||||
}
|
||||
|
||||
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::tlv::nlsr::readDouble(*val);
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
std::cout << "Missing required HyperbolicRadius field" << std::endl;
|
||||
@@ -146,17 +124,7 @@ CoordinateLsa::wireDecode(const ndn::Block& wire)
|
||||
|
||||
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::tlv::nlsr::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);
|
||||
|
||||
|
||||
+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 "name-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<NameLsa>));
|
||||
BOOST_CONCEPT_ASSERT((ndn::WireDecodable<NameLsa>));
|
||||
@@ -62,11 +62,7 @@ NameLsa::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
template size_t
|
||||
NameLsa::wireEncode<ndn::encoding::EncoderTag>(ndn::EncodingImpl<ndn::encoding::EncoderTag>& block) const;
|
||||
|
||||
template size_t
|
||||
NameLsa::wireEncode<ndn::encoding::EstimatorTag>(ndn::EncodingImpl<ndn::encoding::EstimatorTag>& block) const;
|
||||
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(NameLsa);
|
||||
|
||||
const ndn::Block&
|
||||
NameLsa::wireEncode() const
|
||||
@@ -95,10 +91,8 @@ NameLsa::wireDecode(const ndn::Block& wire)
|
||||
m_wire = wire;
|
||||
|
||||
if (m_wire.type() != ndn::tlv::nlsr::NameLsa) {
|
||||
std::stringstream error;
|
||||
error << "Expected NameLsa Block, but Block is of a different type: #"
|
||||
<< m_wire.type();
|
||||
throw Error(error.str());
|
||||
BOOST_THROW_EXCEPTION(Error("Expected NameLsa Block, but Block is of a different type: #" +
|
||||
ndn::to_string(m_wire.type())));
|
||||
}
|
||||
|
||||
m_wire.parse();
|
||||
@@ -110,7 +104,7 @@ NameLsa::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 @@ NameLsa::wireDecode(const ndn::Block& wire)
|
||||
m_hasNames = true;
|
||||
}
|
||||
else {
|
||||
std::stringstream error;
|
||||
error << "Expected Name Block, but Block is of a different type: #"
|
||||
<< m_wire.type();
|
||||
throw Error(error.str());
|
||||
BOOST_THROW_EXCEPTION(Error("Expected Name 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_NAME_LSA_HPP
|
||||
#define NLSR_TLV_NAME_LSA_HPP
|
||||
@@ -152,6 +152,8 @@ private:
|
||||
mutable ndn::Block m_wire;
|
||||
};
|
||||
|
||||
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(NameLsa);
|
||||
|
||||
inline NameLsa::iterator
|
||||
NameLsa::begin() const
|
||||
{
|
||||
|
||||
+3
-9
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "nexthop.hpp"
|
||||
#include "tlv-nlsr.hpp"
|
||||
#include "coordinate-lsa.hpp"
|
||||
|
||||
#include <ndn-cxx/util/concepts.hpp>
|
||||
#include <ndn-cxx/encoding/block-helpers.hpp>
|
||||
@@ -49,8 +50,7 @@ NextHop::wireEncode(ndn::EncodingImpl<TAG>& block) const
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
const uint8_t* doubleBytes = reinterpret_cast<const uint8_t*>(&m_cost);
|
||||
totalLength += block.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes, 8);
|
||||
totalLength += prependDouble(block, ndn::tlv::nlsr::Double, m_cost);
|
||||
|
||||
totalLength += block.prependByteArrayBlock(
|
||||
ndn::tlv::nlsr::Uri, reinterpret_cast<const uint8_t*>(m_uri.c_str()), m_uri.size());
|
||||
@@ -108,13 +108,7 @@ NextHop::wireDecode(const ndn::Block& wire)
|
||||
BOOST_THROW_EXCEPTION(Error("Missing required Uri field"));
|
||||
}
|
||||
|
||||
if (val != val->elements_end() && val->type() == ndn::tlv::nlsr::Double) {
|
||||
m_cost = *reinterpret_cast<const double*>(val->value());
|
||||
++val;
|
||||
}
|
||||
else {
|
||||
BOOST_THROW_EXCEPTION(Error("HyperbolicCost: Missing required Double field"));
|
||||
}
|
||||
m_cost = ndn::tlv::nlsr::readDouble(*val);
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#define NLSR_TLV_NLSR_HPP
|
||||
|
||||
#include <ndn-cxx/encoding/tlv.hpp>
|
||||
#include <ndn-cxx/encoding/block-helpers.hpp>
|
||||
|
||||
namespace ndn {
|
||||
namespace tlv {
|
||||
@@ -54,6 +55,45 @@ enum {
|
||||
RouteTableEntry = 145
|
||||
};
|
||||
|
||||
/*! \brief Read a double from a TLV element
|
||||
* \param block the TLV element
|
||||
* \throw ndn::tlv::Error block does not contain a double
|
||||
* \sa prependDouble
|
||||
*/
|
||||
inline double
|
||||
readDouble(const ndn::Block& block)
|
||||
{
|
||||
block.parse();
|
||||
auto it = block.elements_begin();
|
||||
|
||||
double doubleFromBlock = 0.0;
|
||||
if (it == it->elements_end() || it->type() != ndn::tlv::nlsr::Double ||
|
||||
it->value_size() != sizeof(doubleFromBlock)) {
|
||||
BOOST_THROW_EXCEPTION(ndn::tlv::Error("Block does not contain a double"));
|
||||
}
|
||||
memcpy(&doubleFromBlock, it->value(), sizeof(doubleFromBlock));
|
||||
return doubleFromBlock;
|
||||
}
|
||||
|
||||
/*! \brief Prepend a TLV element containing a double.
|
||||
* \param encoder an EncodingBuffer or EncodingEstimator
|
||||
* \param type TLV-TYPE number
|
||||
* \param value double value
|
||||
*/
|
||||
template<ndn::encoding::Tag TAG>
|
||||
inline size_t
|
||||
prependDouble(ndn::EncodingImpl<TAG>& encoder, uint32_t type, double value)
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
const uint8_t* doubleBytes = reinterpret_cast<const uint8_t*>(&value);
|
||||
totalLength = encoder.prependByteArrayBlock(ndn::tlv::nlsr::Double, doubleBytes, 8);
|
||||
totalLength += encoder.prependVarNumber(totalLength);
|
||||
totalLength += encoder.prependVarNumber(type);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
} // namespace tlv
|
||||
} // namespace ndn
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -61,12 +61,35 @@ CommandManagerBase::advertiseAndInsertPrefix(const ndn::Name& prefix,
|
||||
|
||||
// Only build a Name LSA if the added name is new
|
||||
if (m_namePrefixList.insert(castParams.getName())) {
|
||||
NLSR_LOG_INFO("Advertising/Inserting name: " << castParams.getName() << "\n");
|
||||
NLSR_LOG_INFO("Advertising name: " << castParams.getName() << "\n");
|
||||
m_lsdb.buildAndInstallOwnNameLsa();
|
||||
if (castParams.hasFlags() && castParams.getFlags() == PREFIX_FLAG) {
|
||||
NLSR_LOG_INFO("Saving name to the configuration file ");
|
||||
if (afterAdvertise(castParams.getName()) == true) {
|
||||
return done(ndn::nfd::ControlResponse(205, "OK").setBody(parameters.wireEncode()));
|
||||
}
|
||||
else {
|
||||
return done(ndn::nfd::ControlResponse(406, "Failed to open configuration file.")
|
||||
.setBody(parameters.wireEncode()));
|
||||
}
|
||||
}
|
||||
return done(ndn::nfd::ControlResponse(200, "OK").setBody(parameters.wireEncode()));
|
||||
}
|
||||
|
||||
return done(ndn::nfd::ControlResponse(204, "Prefix is already advetised/inserted.").setBody(parameters.wireEncode()));
|
||||
else {
|
||||
if (castParams.hasFlags() && castParams.getFlags() == PREFIX_FLAG) {
|
||||
// Save an already advertised prefix
|
||||
NLSR_LOG_INFO("Saving an already advertised name: " << castParams.getName() << "\n");
|
||||
if (afterAdvertise(castParams.getName()) == true) {
|
||||
return done(ndn::nfd::ControlResponse(205, "OK").setBody(parameters.wireEncode()));
|
||||
}
|
||||
else {
|
||||
return done(ndn::nfd::ControlResponse(406, "Prefix is already Saved/Failed to open configuration file.")
|
||||
.setBody(parameters.wireEncode()));
|
||||
}
|
||||
}
|
||||
return done(ndn::nfd::ControlResponse(204, "Prefix is already advertised/inserted.")
|
||||
.setBody(parameters.wireEncode()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -82,10 +105,32 @@ CommandManagerBase::withdrawAndRemovePrefix(const ndn::Name& prefix,
|
||||
if (m_namePrefixList.remove(castParams.getName())) {
|
||||
NLSR_LOG_INFO("Withdrawing/Removing name: " << castParams.getName() << "\n");
|
||||
m_lsdb.buildAndInstallOwnNameLsa();
|
||||
if (castParams.hasFlags() && castParams.getFlags() == PREFIX_FLAG) {
|
||||
if (afterWithdraw(castParams.getName()) == true) {
|
||||
return done(ndn::nfd::ControlResponse(205, "OK").setBody(parameters.wireEncode()));
|
||||
}
|
||||
else {
|
||||
return done(ndn::nfd::ControlResponse(406, "Failed to open configuration file.")
|
||||
.setBody(parameters.wireEncode()));
|
||||
}
|
||||
}
|
||||
return done(ndn::nfd::ControlResponse(200, "OK").setBody(parameters.wireEncode()));
|
||||
}
|
||||
|
||||
return done(ndn::nfd::ControlResponse(204, "Prefix is already withdrawn/removed.").setBody(parameters.wireEncode()));
|
||||
else {
|
||||
if (castParams.hasFlags() && castParams.getFlags() == PREFIX_FLAG) {
|
||||
// Delete an already withdrawn prefix
|
||||
NLSR_LOG_INFO("Deleting an already withdrawn name: " << castParams.getName() << "\n");
|
||||
if (afterWithdraw(castParams.getName()) == true) {
|
||||
return done(ndn::nfd::ControlResponse(205, "OK").setBody(parameters.wireEncode()));
|
||||
}
|
||||
else {
|
||||
return done(ndn::nfd::ControlResponse(406, "Prefix is already deleted/Failed to open configuration file.")
|
||||
.setBody(parameters.wireEncode()));
|
||||
}
|
||||
}
|
||||
return done(ndn::nfd::ControlResponse(204, "Prefix is already withdrawn/removed.")
|
||||
.setBody(parameters.wireEncode()));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace update
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -44,6 +44,8 @@ class Lsdb;
|
||||
|
||||
namespace update {
|
||||
|
||||
enum { PREFIX_FLAG = 1 };
|
||||
|
||||
class ManagerBase : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
@@ -107,6 +109,8 @@ public:
|
||||
Lsdb& lsdb,
|
||||
const std::string& module);
|
||||
|
||||
virtual ~CommandManagerBase() {}
|
||||
|
||||
/*! \brief add desired name prefix to the advertised name prefix list
|
||||
* or insert a prefix into the FIB if parameters is valid.
|
||||
*/
|
||||
@@ -125,6 +129,18 @@ public:
|
||||
const ndn::mgmt::ControlParameters& parameters,
|
||||
const ndn::mgmt::CommandContinuation& done);
|
||||
|
||||
/*! \brief save an advertised prefix to the nlsr configuration file
|
||||
* returns bool from the overridden function while nullopt here
|
||||
*/
|
||||
virtual ndn::optional<bool>
|
||||
afterAdvertise(const ndn::Name& prefix) { return ndn::nullopt; }
|
||||
|
||||
/*! \brief save an advertised prefix to the nlsr configuration file
|
||||
* returns bool from the overridden function while nullopt here
|
||||
*/
|
||||
virtual ndn::optional<bool>
|
||||
afterWithdraw(const ndn::Name& prefix) { return ndn::nullopt; }
|
||||
|
||||
protected:
|
||||
NamePrefixList& m_namePrefixList;
|
||||
Lsdb& m_lsdb;
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -29,6 +29,9 @@ WithdrawPrefixCommand::WithdrawPrefixCommand()
|
||||
{
|
||||
m_requestValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
|
||||
m_responseValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
|
||||
|
||||
m_requestValidator.optional(ndn::nfd::CONTROL_PARAMETER_FLAGS);
|
||||
m_responseValidator.optional(ndn::nfd::CONTROL_PARAMETER_FLAGS);
|
||||
}
|
||||
|
||||
AdvertisePrefixCommand::AdvertisePrefixCommand()
|
||||
@@ -36,6 +39,10 @@ AdvertisePrefixCommand::AdvertisePrefixCommand()
|
||||
{
|
||||
m_requestValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
|
||||
m_responseValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
|
||||
|
||||
m_requestValidator.optional(ndn::nfd::CONTROL_PARAMETER_FLAGS);
|
||||
m_responseValidator.optional(ndn::nfd::CONTROL_PARAMETER_FLAGS);
|
||||
|
||||
}
|
||||
|
||||
} // namespace update
|
||||
|
||||
@@ -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,8 +23,9 @@
|
||||
#include "lsdb.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/tag.hpp>
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace nlsr {
|
||||
namespace update {
|
||||
@@ -50,12 +51,12 @@ getSignerFromTag(const ndn::Interest& interest)
|
||||
}
|
||||
|
||||
PrefixUpdateProcessor::PrefixUpdateProcessor(ndn::mgmt::Dispatcher& dispatcher,
|
||||
ndn::Face& face,
|
||||
ndn::security::ValidatorConfig& validator,
|
||||
NamePrefixList& namePrefixList,
|
||||
Lsdb& lsdb)
|
||||
Lsdb& lsdb, const std::string& configFileName)
|
||||
: CommandManagerBase(dispatcher, namePrefixList, lsdb, "prefix-update")
|
||||
|
||||
, m_validator(ndn::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
|
||||
, m_validator(validator)
|
||||
, m_confFileNameDynamic(configFileName)
|
||||
{
|
||||
NLSR_LOG_DEBUG("Setting dispatcher to capture Interests for: "
|
||||
<< ndn::Name(Nlsr::LOCALHOST_PREFIX).append("prefix-update"));
|
||||
@@ -103,5 +104,90 @@ PrefixUpdateProcessor::loadValidator(boost::property_tree::ptree section,
|
||||
m_validator.load(section, filename);
|
||||
}
|
||||
|
||||
bool
|
||||
PrefixUpdateProcessor::checkForPrefixInFile(const std::string prefix)
|
||||
{
|
||||
std::string line;
|
||||
std::fstream fp(m_confFileNameDynamic);
|
||||
if (!fp.good() || !fp.is_open()) {
|
||||
NLSR_LOG_ERROR("Failed to open configuration file for parsing");
|
||||
return true;
|
||||
}
|
||||
while (!fp.eof()) {
|
||||
getline(fp, line);
|
||||
if (line == prefix) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
fp.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PrefixUpdateProcessor::addOrDeletePrefix(const ndn::Name& prefix, bool addPrefix)
|
||||
{
|
||||
std::string value = " prefix " + prefix.toUri();;
|
||||
std::string fileString;
|
||||
std::string line;
|
||||
std::string trimedLine;
|
||||
std::fstream input(m_confFileNameDynamic, input.in);
|
||||
if (!input.good() || !input.is_open()) {
|
||||
NLSR_LOG_ERROR("Failed to open configuration file for parsing");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addPrefix) {
|
||||
//check if prefix already exist in the nlsr configuration file
|
||||
if (checkForPrefixInFile(value)) {
|
||||
NLSR_LOG_ERROR("Prefix already exists in the configuration file");
|
||||
return false;
|
||||
}
|
||||
while (!input.eof()) {
|
||||
getline(input, line);
|
||||
if (!line.empty()) {
|
||||
fileString.append(line + "\n");
|
||||
if (line == "advertising") {
|
||||
getline(input, line);
|
||||
fileString.append(line + "\n" + value + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!checkForPrefixInFile(value)) {
|
||||
NLSR_LOG_ERROR("Prefix doesn't exists in the configuration file");
|
||||
return false;
|
||||
}
|
||||
boost::trim(value);
|
||||
while (!input.eof()) {
|
||||
getline(input, line);
|
||||
if (!line.empty()) {
|
||||
std::string trimLine = line;
|
||||
boost::trim(trimLine);
|
||||
if (trimLine != value) {
|
||||
fileString.append(line + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input.close();
|
||||
std::ofstream output(m_confFileNameDynamic);
|
||||
output << fileString;
|
||||
output.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
ndn::optional<bool>
|
||||
PrefixUpdateProcessor::afterAdvertise(const ndn::Name& prefix)
|
||||
{
|
||||
return addOrDeletePrefix(prefix, true);
|
||||
}
|
||||
|
||||
ndn::optional<bool>
|
||||
PrefixUpdateProcessor::afterWithdraw(const ndn::Name& prefix)
|
||||
{
|
||||
return addOrDeletePrefix(prefix, false);
|
||||
}
|
||||
|
||||
} // namespace update
|
||||
} // 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-2019, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -24,15 +24,11 @@
|
||||
|
||||
#include "manager-base.hpp"
|
||||
#include "prefix-update-commands.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/util/io.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/security/v2/certificate-storage.hpp>
|
||||
#include <ndn-cxx/util/io.hpp>
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <memory>
|
||||
#include <boost/property_tree/info_parser.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
@@ -48,9 +44,9 @@ class PrefixUpdateProcessor : public CommandManagerBase
|
||||
{
|
||||
public:
|
||||
PrefixUpdateProcessor(ndn::mgmt::Dispatcher& dispatcher,
|
||||
ndn::Face& face,
|
||||
ndn::security::ValidatorConfig& validator,
|
||||
NamePrefixList& namePrefixList,
|
||||
Lsdb& lsdb);
|
||||
Lsdb& lsdb, const std::string& configFileName);
|
||||
|
||||
/*! \brief Load the validator's configuration from a section of a
|
||||
* configuration file.
|
||||
@@ -66,6 +62,22 @@ public:
|
||||
void
|
||||
loadValidator(ConfigSection section, const std::string& filename);
|
||||
|
||||
/*! \brief Add or delete an advertise or withdrawn prefix to the nlsr
|
||||
* configuration file
|
||||
*/
|
||||
bool
|
||||
addOrDeletePrefix(const ndn::Name& prefix, bool addPrefix);
|
||||
|
||||
ndn::optional<bool>
|
||||
afterAdvertise(const ndn::Name& prefix);
|
||||
|
||||
ndn::optional<bool>
|
||||
afterWithdraw(const ndn::Name& prefix);
|
||||
|
||||
/*! \brief Check if a prefix exists in the nlsr configuration file */
|
||||
bool
|
||||
checkForPrefixInFile(const std::string prefix);
|
||||
|
||||
ndn::security::ValidatorConfig&
|
||||
getValidator()
|
||||
{
|
||||
@@ -83,7 +95,8 @@ private:
|
||||
makeAuthorization();
|
||||
|
||||
private:
|
||||
ndn::security::ValidatorConfig m_validator;
|
||||
ndn::security::ValidatorConfig& m_validator;
|
||||
const std::string& m_confFileNameDynamic;
|
||||
};
|
||||
|
||||
} // namespace update
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Copyright (c) 2014-2019, 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/>.
|
||||
#
|
||||
# Author: Eric Newberry <enewberry@email.arizona.edu>
|
||||
# Author: Davide Pesavento <davidepesa@gmail.com>
|
||||
|
||||
[Unit]
|
||||
Description=NDN Link State Routing Daemon
|
||||
Documentation=man:nlsr(1)
|
||||
BindsTo=nfd.service
|
||||
After=nfd.service
|
||||
|
||||
[Service]
|
||||
Environment=HOME=%S/ndn/nlsr
|
||||
ExecStart=@BINDIR@/nlsr -f @SYSCONFDIR@/ndn/nlsr.conf
|
||||
Restart=on-failure
|
||||
RestartPreventExitStatus=2
|
||||
User=nlsr
|
||||
|
||||
LockPersonality=yes
|
||||
MemoryDenyWriteExecute=yes
|
||||
NoNewPrivileges=yes
|
||||
PrivateDevices=yes
|
||||
PrivateTmp=yes
|
||||
PrivateUsers=yes
|
||||
ProtectControlGroups=yes
|
||||
ProtectHome=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
ProtectSystem=strict
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
# "nlsr" is the state-dir, "ndn/nlsr" is the HOME
|
||||
StateDirectory=nlsr ndn/nlsr
|
||||
SystemCallArchitectures=native
|
||||
SystemCallErrorNumber=EPERM
|
||||
SystemCallFilter=~@clock @cpu-emulation @debug @module @mount @obsolete @privileged @raw-io @reboot @setuid @swap
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=nfd.service
|
||||
+84
-107
@@ -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.
|
||||
*
|
||||
@@ -20,7 +20,7 @@
|
||||
**/
|
||||
|
||||
#include "communication/sync-logic-handler.hpp"
|
||||
#include "test-common.hpp"
|
||||
#include "../test-common.hpp"
|
||||
#include "common.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "lsa.hpp"
|
||||
@@ -32,91 +32,85 @@ namespace test {
|
||||
|
||||
using std::shared_ptr;
|
||||
|
||||
template<int32_t Protocol>
|
||||
class SyncLogicFixture : public UnitTestTimeFixture
|
||||
{
|
||||
public:
|
||||
SyncLogicFixture()
|
||||
: face(m_ioService, m_keyChain)
|
||||
, nlsr(m_ioService, m_scheduler, face, m_keyChain)
|
||||
, conf(face)
|
||||
, confProcessor(conf, Protocol)
|
||||
, testIsLsaNew([] (const ndn::Name& name, const Lsa::Type& lsaType,
|
||||
const uint64_t sequenceNumber) {
|
||||
return true;
|
||||
})
|
||||
, CONFIG_NETWORK("/ndn")
|
||||
, CONFIG_SITE("/site")
|
||||
, CONFIG_ROUTER_NAME("/%C1.Router/this-router")
|
||||
, OTHER_ROUTER_NAME("/%C1.Router/other-router/")
|
||||
, sync(face, testIsLsaNew, conf)
|
||||
, updateNamePrefix(this->conf.getLsaPrefix().toUri() +
|
||||
this->conf.getSiteName().toUri() +
|
||||
"/%C1.Router/other-router/")
|
||||
{
|
||||
nlsr.getConfParameter().setNetwork(CONFIG_NETWORK);
|
||||
nlsr.getConfParameter().setSiteName(CONFIG_SITE);
|
||||
nlsr.getConfParameter().setRouterName(CONFIG_ROUTER_NAME);
|
||||
nlsr.getConfParameter().buildRouterPrefix();
|
||||
|
||||
conf.setNetwork(CONFIG_NETWORK);
|
||||
conf.setSiteName(CONFIG_SITE);
|
||||
conf.setRouterName(CONFIG_ROUTER_NAME);
|
||||
conf.buildRouterPrefix();
|
||||
|
||||
addIdentity(conf.getRouterPrefix());
|
||||
}
|
||||
|
||||
void
|
||||
receiveUpdate(std::string prefix, uint64_t seqNo, SyncLogicHandler& p_sync)
|
||||
receiveUpdate(const std::string& prefix, uint64_t seqNo)
|
||||
{
|
||||
chronosync::MissingDataInfo info = {ndn::Name(prefix).appendNumber(1), 0, seqNo};
|
||||
|
||||
std::vector<chronosync::MissingDataInfo> updates;
|
||||
updates.push_back(info);
|
||||
|
||||
this->advanceClocks(ndn::time::milliseconds(1), 10);
|
||||
face.sentInterests.clear();
|
||||
|
||||
p_sync.onChronoSyncUpdate(updates);
|
||||
if (Protocol == SYNC_PROTOCOL_CHRONOSYNC) {
|
||||
std::vector<chronosync::MissingDataInfo> updates;
|
||||
updates.push_back({ndn::Name(prefix).appendNumber(1), 0, seqNo});
|
||||
sync.m_syncLogic->onChronoSyncUpdate(updates);
|
||||
}
|
||||
else {
|
||||
std::vector<psync::MissingDataInfo> updates;
|
||||
updates.push_back({ndn::Name(prefix), 0, seqNo});
|
||||
sync.m_syncLogic->onPSyncUpdate(updates);
|
||||
}
|
||||
|
||||
this->advanceClocks(ndn::time::milliseconds(1), 10);
|
||||
}
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
Nlsr nlsr;
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
SyncLogicHandler::IsLsaNew testIsLsaNew;
|
||||
SyncLogicHandler sync;
|
||||
|
||||
const std::string CONFIG_NETWORK;
|
||||
const std::string CONFIG_SITE;
|
||||
const std::string CONFIG_ROUTER_NAME;
|
||||
const std::string OTHER_ROUTER_NAME;
|
||||
const std::string updateNamePrefix;
|
||||
const std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY,
|
||||
Lsa::Type::COORDINATE};
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
|
||||
using mpl_::int_;
|
||||
using Protocols = boost::mpl::vector<int_<SYNC_PROTOCOL_CHRONOSYNC>,
|
||||
int_<SYNC_PROTOCOL_PSYNC>>;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestSyncLogicHandler)
|
||||
|
||||
/* Tests that when SyncLogicHandler receives an LSA of either Name or
|
||||
Adjacency type that appears to be newer, it will emit to its signal
|
||||
with those LSA details.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherLS, T, Protocols, SyncLogicFixture<T::value>)
|
||||
{
|
||||
SyncLogicHandler sync{face, testIsLsaNew, conf};
|
||||
sync.createSyncSocket(conf.getChronosyncPrefix());
|
||||
|
||||
std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY};
|
||||
|
||||
uint64_t syncSeqNo = 1;
|
||||
|
||||
for (const Lsa::Type& lsaType : lsaTypes) {
|
||||
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
|
||||
+ OTHER_ROUTER_NAME + std::to_string(lsaType);
|
||||
std::string updateName = this->updateNamePrefix + std::to_string(lsaType);
|
||||
|
||||
// Actual testing done here -- signal function callback
|
||||
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
|
||||
[&, this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
|
||||
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
|
||||
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
|
||||
});
|
||||
|
||||
receiveUpdate(updateName, syncSeqNo, sync);
|
||||
this->receiveUpdate(updateName, syncSeqNo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,27 +118,23 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
|
||||
either Coordinate or Name type that appears to be newer, it will
|
||||
emit to its signal with those LSA details.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherHR, T, Protocols, SyncLogicFixture<T::value>)
|
||||
{
|
||||
conf.setHyperbolicState(HYPERBOLIC_STATE_ON);
|
||||
|
||||
SyncLogicHandler sync{face, testIsLsaNew, conf};
|
||||
sync.createSyncSocket(conf.getChronosyncPrefix());
|
||||
this->conf.setHyperbolicState(HYPERBOLIC_STATE_ON);
|
||||
|
||||
uint64_t syncSeqNo = 1;
|
||||
std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::COORDINATE};
|
||||
|
||||
for (const Lsa::Type& lsaType : lsaTypes) {
|
||||
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
|
||||
+ OTHER_ROUTER_NAME + std::to_string(lsaType);
|
||||
std::string updateName = this->updateNamePrefix + std::to_string(lsaType);
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
|
||||
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
|
||||
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
|
||||
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
|
||||
});
|
||||
|
||||
receiveUpdate(updateName, syncSeqNo, sync);
|
||||
this->receiveUpdate(updateName, syncSeqNo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,26 +142,22 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
|
||||
any type that appears to be newer, it will emit to its signal with
|
||||
those LSA details.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdateForOtherHRDry, T, Protocols, SyncLogicFixture<T::value>)
|
||||
{
|
||||
conf.setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
|
||||
this->conf.setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
|
||||
|
||||
SyncLogicHandler sync{face, testIsLsaNew, conf};
|
||||
sync.createSyncSocket(conf.getChronosyncPrefix());
|
||||
uint64_t syncSeqNo = 1;
|
||||
|
||||
for (const Lsa::Type& lsaType : lsaTypes) {
|
||||
uint64_t syncSeqNo = 1;
|
||||
for (const Lsa::Type& lsaType : this->lsaTypes) {
|
||||
std::string updateName = this->updateNamePrefix + std::to_string(lsaType);
|
||||
|
||||
std::string updateName = conf.getLsaPrefix().toUri() + CONFIG_SITE
|
||||
+ OTHER_ROUTER_NAME + std::to_string(lsaType);
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
|
||||
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
|
||||
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
|
||||
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
|
||||
});
|
||||
|
||||
receiveUpdate(updateName, syncSeqNo, sync);
|
||||
this->receiveUpdate(updateName, syncSeqNo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,25 +165,24 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
|
||||
details matching this router's details, it will *not* emit to its
|
||||
signal those LSA details.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(NoUpdateForSelf, T, Protocols, SyncLogicFixture<T::value>)
|
||||
{
|
||||
const uint64_t sequenceNumber = 1;
|
||||
|
||||
SyncLogicHandler sync{face, testIsLsaNew, conf};
|
||||
sync.createSyncSocket(conf.getChronosyncPrefix());
|
||||
|
||||
for (const Lsa::Type& lsaType : lsaTypes) {
|
||||
for (const Lsa::Type& lsaType : this->lsaTypes) {
|
||||
// To ensure that we get correctly-separated components, create
|
||||
// and modify a Name to hand off.
|
||||
ndn::Name updateName = ndn::Name{conf.getLsaPrefix()};
|
||||
updateName.append(CONFIG_SITE).append(CONFIG_ROUTER_NAME).append(std::to_string(lsaType));
|
||||
ndn::Name updateName = ndn::Name{this->conf.getLsaPrefix()};
|
||||
updateName.append(this->conf.getSiteName())
|
||||
.append(this->conf.getRouterName())
|
||||
.append(std::to_string(lsaType));
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
|
||||
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
|
||||
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
BOOST_FAIL("Updates for self should not be emitted!");
|
||||
});
|
||||
|
||||
receiveUpdate(updateName.toUri(), sequenceNumber, sync);
|
||||
this->receiveUpdate(updateName.toUri(), sequenceNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,23 +190,20 @@ BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
|
||||
details that do not match the expected format, it will *not* emit
|
||||
to its signal those LSA details.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(MalformedUpdate)
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(MalformedUpdate, T, Protocols, SyncLogicFixture<T::value>)
|
||||
{
|
||||
const uint64_t sequenceNumber = 1;
|
||||
|
||||
SyncLogicHandler sync{face, testIsLsaNew, conf};
|
||||
sync.createSyncSocket(conf.getChronosyncPrefix());
|
||||
for (const Lsa::Type& lsaType : this->lsaTypes) {
|
||||
ndn::Name updateName{this->conf.getSiteName()};
|
||||
updateName.append(this->conf.getRouterName()).append(std::to_string(lsaType));
|
||||
|
||||
for (const Lsa::Type& lsaType : lsaTypes) {
|
||||
ndn::Name updateName{CONFIG_SITE};
|
||||
updateName.append(CONFIG_ROUTER_NAME).append(std::to_string(lsaType));
|
||||
|
||||
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
|
||||
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
|
||||
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
BOOST_FAIL("Malformed updates should not be emitted!");
|
||||
});
|
||||
|
||||
receiveUpdate(updateName.toUri(), sequenceNumber, sync);
|
||||
this->receiveUpdate(updateName.toUri(), sequenceNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,69 +211,64 @@ BOOST_AUTO_TEST_CASE(MalformedUpdate)
|
||||
details that do not appear to be new, it will *not* emit to its
|
||||
signal those LSA details.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(LsaNotNew)
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(LsaNotNew, T, Protocols, SyncLogicFixture<T::value>)
|
||||
{
|
||||
auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const Lsa::Type& lsaType,
|
||||
const uint64_t& sequenceNumber) {
|
||||
const uint64_t& sequenceNumber) {
|
||||
return false;
|
||||
};
|
||||
|
||||
const uint64_t sequenceNumber = 1;
|
||||
SyncLogicHandler sync{face, testLsaAlwaysFalse, conf};
|
||||
sync.createSyncSocket(conf.getChronosyncPrefix());
|
||||
SyncLogicHandler sync{this->face, testLsaAlwaysFalse, this->conf};
|
||||
ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
|
||||
[& ,this] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
[&] (const ndn::Name& routerName, const uint64_t& sequenceNumber) {
|
||||
BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!");
|
||||
});
|
||||
|
||||
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
|
||||
CONFIG_SITE + "/%C1.Router/other-router/" +
|
||||
std::to_string(Lsa::Type::NAME);
|
||||
std::string updateName = this->updateNamePrefix + std::to_string(Lsa::Type::NAME);
|
||||
|
||||
receiveUpdate(updateName, sequenceNumber, sync);
|
||||
this->receiveUpdate(updateName, sequenceNumber);
|
||||
}
|
||||
|
||||
/* Tests that SyncLogicHandler successfully concatenates configured
|
||||
variables together to form the necessary prefixes to advertise
|
||||
through ChronoSync.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(UpdatePrefix)
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdatePrefix, T, Protocols, SyncLogicFixture<T::value>)
|
||||
{
|
||||
ndn::Name expectedPrefix = this->conf.getLsaPrefix();
|
||||
expectedPrefix.append(this->conf.getSiteName());
|
||||
expectedPrefix.append(this->conf.getRouterName());
|
||||
|
||||
SyncLogicHandler sync{face, testIsLsaNew, conf};
|
||||
this->sync.buildUpdatePrefix();
|
||||
|
||||
ndn::Name expectedPrefix = nlsr.getConfParameter().getLsaPrefix();
|
||||
expectedPrefix.append(CONFIG_SITE);
|
||||
expectedPrefix.append(CONFIG_ROUTER_NAME);
|
||||
|
||||
sync.buildUpdatePrefix();
|
||||
|
||||
BOOST_CHECK_EQUAL(sync.m_nameLsaUserPrefix,
|
||||
BOOST_CHECK_EQUAL(this->sync.m_nameLsaUserPrefix,
|
||||
ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::NAME)));
|
||||
BOOST_CHECK_EQUAL(sync.m_adjLsaUserPrefix,
|
||||
BOOST_CHECK_EQUAL(this->sync.m_adjLsaUserPrefix,
|
||||
ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::ADJACENCY)));
|
||||
BOOST_CHECK_EQUAL(sync.m_coorLsaUserPrefix,
|
||||
BOOST_CHECK_EQUAL(this->sync.m_coorLsaUserPrefix,
|
||||
ndn::Name(expectedPrefix).append(std::to_string(Lsa::Type::COORDINATE)));
|
||||
}
|
||||
|
||||
/* Tests that SyncLogicHandler's socket will be created when
|
||||
Nlsr::initialize is called, preventing use of sync before the
|
||||
Nlsr is initialized, preventing use of sync before the
|
||||
socket is created.
|
||||
|
||||
NB: This test is as much an Nlsr class test as a
|
||||
SyncLogicHandler class test, but it rides the line and ends up here.
|
||||
*/
|
||||
BOOST_AUTO_TEST_CASE(CreateSyncSocketOnInitialization) // Bug #2649
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(createSyncLogicOnInitialization, T, Protocols,
|
||||
SyncLogicFixture<T::value>) // Bug #2649
|
||||
{
|
||||
nlsr.initialize();
|
||||
Nlsr nlsr(this->face, this->m_keyChain, this->conf);
|
||||
|
||||
// Make sure an adjacency LSA has not been built yet
|
||||
ndn::Name key = ndn::Name(nlsr.getConfParameter().getRouterPrefix()).append(std::to_string(Lsa::Type::ADJACENCY));
|
||||
AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key);
|
||||
ndn::Name key = ndn::Name(this->conf.getRouterPrefix()).append(std::to_string(Lsa::Type::ADJACENCY));
|
||||
AdjLsa* lsa = nlsr.m_lsdb.findAdjLsa(key);
|
||||
BOOST_REQUIRE(lsa == nullptr);
|
||||
|
||||
// Publish a routing update before an Adjacency LSA is built
|
||||
BOOST_CHECK_NO_THROW(nlsr.getLsdb().getSyncLogicHandler()
|
||||
BOOST_CHECK_NO_THROW(nlsr.m_lsdb.getSyncLogicHandler()
|
||||
.publishRoutingUpdate(Lsa::Type::ADJACENCY, 0));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2019, 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 "communication/sync-protocol-adapter.hpp"
|
||||
#include "../test-common.hpp"
|
||||
#include "../boost-test.hpp"
|
||||
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using namespace ndn;
|
||||
|
||||
class SyncProtocolAdapterFixture : public UnitTestTimeFixture
|
||||
{
|
||||
public:
|
||||
SyncProtocolAdapterFixture()
|
||||
: syncPrefix("/localhop/ndn/nlsr/sync/")
|
||||
, nameLsaUserPrefix("/localhop/ndn/nlsr/LSA/NAME")
|
||||
, syncInterestLifetime(time::seconds(60))
|
||||
{
|
||||
syncPrefix.appendVersion(4);
|
||||
}
|
||||
|
||||
template <int32_t T>
|
||||
void
|
||||
addNodes()
|
||||
{
|
||||
for (int i = 0; i < 2; i++) {
|
||||
faces[i] = std::make_shared<ndn::util::DummyClientFace>(m_ioService,
|
||||
util::DummyClientFace::Options{true, true});
|
||||
userPrefixes[i] = Name(nameLsaUserPrefix).appendNumber(i);
|
||||
nodes[i] = std::make_shared<SyncProtocolAdapter>(*faces[i], T, syncPrefix,
|
||||
userPrefixes[i],
|
||||
syncInterestLifetime,
|
||||
[i, this] (const ndn::Name& updateName,
|
||||
uint64_t highSeq) {
|
||||
prefixToSeq[i].emplace(updateName, highSeq);
|
||||
});
|
||||
}
|
||||
|
||||
faces[0]->linkTo(*faces[1]);
|
||||
advanceClocks(ndn::time::milliseconds(10), 10);
|
||||
}
|
||||
|
||||
public:
|
||||
Name syncPrefix, nameLsaUserPrefix;
|
||||
Name userPrefixes[2];
|
||||
time::milliseconds syncInterestLifetime;
|
||||
std::shared_ptr<ndn::util::DummyClientFace> faces[2];
|
||||
std::shared_ptr<SyncProtocolAdapter> nodes[2];
|
||||
std::map<ndn::Name, uint64_t> prefixToSeq[2];
|
||||
};
|
||||
|
||||
using boost::mpl::int_;
|
||||
using Protocols = boost::mpl::vector<int_<SYNC_PROTOCOL_CHRONOSYNC>, int_<SYNC_PROTOCOL_PSYNC>>;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestSyncProtocolAdapter, SyncProtocolAdapterFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(Sync, SyncProtocol, Protocols)
|
||||
{
|
||||
addNodes<SyncProtocol::value>();
|
||||
|
||||
nodes[0]->publishUpdate(userPrefixes[0], 10);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
|
||||
auto it = prefixToSeq[1].find(userPrefixes[0]);
|
||||
BOOST_CHECK(it != prefixToSeq[1].end());
|
||||
BOOST_CHECK_EQUAL(it->first, userPrefixes[0]);
|
||||
BOOST_CHECK_EQUAL(it->second, 10);
|
||||
|
||||
nodes[1]->publishUpdate(userPrefixes[1], 100);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
|
||||
it = prefixToSeq[0].find(userPrefixes[1]);
|
||||
BOOST_CHECK(it != prefixToSeq[0].end());
|
||||
BOOST_CHECK_EQUAL(it->first, userPrefixes[1]);
|
||||
BOOST_CHECK_EQUAL(it->second, 100);
|
||||
|
||||
Name adjLsaUserPrefix("/localhop/ndn/nlsr/LSA/ADJACENCY");
|
||||
nodes[0]->addUserNode(adjLsaUserPrefix);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
nodes[0]->publishUpdate(adjLsaUserPrefix, 10);
|
||||
advanceClocks(ndn::time::milliseconds(1000), 100);
|
||||
|
||||
it = prefixToSeq[1].find(adjLsaUserPrefix);
|
||||
BOOST_CHECK(it != prefixToSeq[1].end());
|
||||
BOOST_CHECK_EQUAL(it->first, adjLsaUserPrefix);
|
||||
BOOST_CHECK_EQUAL(it->second, 10);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace test
|
||||
} // 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.
|
||||
*
|
||||
@@ -46,19 +46,35 @@ class PublisherFixture : public BaseFixture
|
||||
public:
|
||||
PublisherFixture()
|
||||
: face(m_ioService, m_keyChain, {true, true})
|
||||
, nlsr(m_ioService, m_scheduler, face, m_keyChain)
|
||||
, lsdb(nlsr.getLsdb())
|
||||
, rt1(nlsr.getRoutingTable())
|
||||
, conf(face)
|
||||
, confProcessor(conf)
|
||||
, nlsr(face, m_keyChain, conf)
|
||||
, lsdb(nlsr.m_lsdb)
|
||||
, rt1(nlsr.m_routingTable)
|
||||
{
|
||||
nlsr.getConfParameter().setNetwork("/ndn");
|
||||
nlsr.getConfParameter().setRouterName("/This/Router");
|
||||
|
||||
routerId = addIdentity("/ndn/This/Router");
|
||||
routerId = addIdentity(conf.getRouterPrefix());
|
||||
|
||||
nlsr.initialize();
|
||||
face.processEvents(ndn::time::milliseconds(100));
|
||||
}
|
||||
|
||||
void
|
||||
checkPrefixRegistered(const Name& prefix)
|
||||
{
|
||||
bool registerCommandEmitted = false;
|
||||
for (const auto& interest : face.sentInterests) {
|
||||
if (interest.getName().size() > 4 && interest.getName().get(3) == name::Component("register")) {
|
||||
name::Component test = interest.getName().get(4);
|
||||
ndn::nfd::ControlParameters params(test.blockFromValue());
|
||||
if (params.getName() == prefix) {
|
||||
registerCommandEmitted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_CHECK(registerCommandEmitted);
|
||||
}
|
||||
|
||||
void
|
||||
addAdjacency(AdjLsa& lsa, const std::string& name, const std::string& faceUri, double cost)
|
||||
{
|
||||
@@ -161,7 +177,8 @@ public:
|
||||
|
||||
public:
|
||||
ndn::util::DummyClientFace face;
|
||||
|
||||
ConfParameter conf;
|
||||
DummyConfFileProcessor confProcessor;
|
||||
Nlsr nlsr;
|
||||
Lsdb& lsdb;
|
||||
|
||||
|
||||
@@ -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,11 +33,11 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
void
|
||||
static void
|
||||
processDatasetInterest(ndn::util::DummyClientFace& face,
|
||||
std::function<bool(const ndn::Block&)> isSameType)
|
||||
{
|
||||
face.processEvents(ndn::time::milliseconds(30));
|
||||
face.processEvents(30_ms);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
|
||||
|
||||
@@ -57,6 +57,8 @@ BOOST_FIXTURE_TEST_SUITE(PublisherTestLsdbDatasetInterestHandler, PublisherFixtu
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Localhost)
|
||||
{
|
||||
checkPrefixRegistered(Nlsr::LOCALHOST_PREFIX);
|
||||
|
||||
// Install adjacency LSA
|
||||
AdjLsa adjLsa;
|
||||
adjLsa.setOrigRouter("/RouterA");
|
||||
@@ -84,31 +86,37 @@ BOOST_AUTO_TEST_CASE(Localhost)
|
||||
rt1.addNextHop(DEST_ROUTER, nh);
|
||||
|
||||
// Request adjacency LSAs
|
||||
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("adjacencies")));
|
||||
face.receive(ndn::Interest("/localhost/nlsr/lsdb/adjacencies").setCanBePrefix(true));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
|
||||
|
||||
// Request coordinate LSAs
|
||||
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("coordinates")));
|
||||
face.receive(ndn::Interest("/localhost/nlsr/lsdb/coordinates").setCanBePrefix(true));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
|
||||
|
||||
// Request Name LSAs
|
||||
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("names")));
|
||||
face.receive(ndn::Interest("/localhost/nlsr/lsdb/names").setCanBePrefix(true));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
|
||||
|
||||
// Request Routing Table
|
||||
face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/routing-table")));
|
||||
face.receive(ndn::Interest("/localhost/nlsr/routing-table").setCanBePrefix(true));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) {
|
||||
return block.type() == ndn::tlv::nlsr::RoutingTable; });
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Routername)
|
||||
{
|
||||
//Install adjacencies LSA
|
||||
ndn::Name regRouterPrefix(conf.getRouterPrefix());
|
||||
regRouterPrefix.append("nlsr");
|
||||
// Should already be added to dispatcher
|
||||
BOOST_CHECK_THROW(nlsr.m_dispatcher.addTopPrefix(regRouterPrefix), std::out_of_range);
|
||||
|
||||
checkPrefixRegistered(regRouterPrefix);
|
||||
|
||||
// Install adjacencies LSA
|
||||
AdjLsa adjLsa;
|
||||
adjLsa.setOrigRouter("/RouterA");
|
||||
addAdjacency(adjLsa, "/RouterA/adjacency1", "udp://face-1", 10);
|
||||
@@ -116,11 +124,11 @@ BOOST_AUTO_TEST_CASE(Routername)
|
||||
|
||||
std::vector<double> angles = {20.00, 30.00};
|
||||
|
||||
//Install coordinate LSA
|
||||
// Install coordinate LSA
|
||||
CoordinateLsa coordinateLsa = createCoordinateLsa("/RouterA", 10.0, angles);
|
||||
lsdb.installCoordinateLsa(coordinateLsa);
|
||||
|
||||
//Install routing table
|
||||
// Install routing table
|
||||
RoutingTableEntry rte1("desrouter1");
|
||||
const ndn::Name& DEST_ROUTER = rte1.getDestination();
|
||||
|
||||
@@ -128,23 +136,26 @@ BOOST_AUTO_TEST_CASE(Routername)
|
||||
|
||||
rt1.addNextHop(DEST_ROUTER, nh);
|
||||
|
||||
ndn::Name routerName(conf.getRouterPrefix());
|
||||
routerName.append("nlsr");
|
||||
|
||||
// Request adjacency LSAs
|
||||
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("adjacencies")));
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("lsdb").append("adjacencies")).setCanBePrefix(true));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
|
||||
|
||||
// Request coordinate LSAs
|
||||
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("coordinates")));
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("lsdb").append("coordinates")).setCanBePrefix(true));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
|
||||
|
||||
// Request Name LSAs
|
||||
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("names")));
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("lsdb").append("names")).setCanBePrefix(true));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
|
||||
|
||||
// Request Routing Table
|
||||
face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/routing-table")));
|
||||
face.receive(ndn::Interest(ndn::Name(routerName).append("routing-table")));
|
||||
processDatasetInterest(face,
|
||||
[] (const ndn::Block& block) {
|
||||
return block.type() == ndn::tlv::nlsr::RoutingTable; });
|
||||
|
||||
@@ -1,173 +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/>.
|
||||
*/
|
||||
|
||||
#include "publisher/segment-publisher.hpp"
|
||||
|
||||
#include "../boost-test.hpp"
|
||||
#include "../test-common.hpp"
|
||||
|
||||
#include <ndn-cxx/encoding/tlv.hpp>
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace tests {
|
||||
|
||||
using namespace nlsr::test;
|
||||
|
||||
template<int64_t N=10000>
|
||||
class TestSegmentPublisher : public SegmentPublisher<ndn::util::DummyClientFace>
|
||||
{
|
||||
public:
|
||||
TestSegmentPublisher(ndn::util::DummyClientFace& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
ndn::security::SigningInfo& signingInfo,
|
||||
const ndn::time::milliseconds freshnessPeriod)
|
||||
: SegmentPublisher(face, keyChain, signingInfo, freshnessPeriod)
|
||||
, m_totalPayloadLength(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual
|
||||
~TestSegmentPublisher()
|
||||
{
|
||||
}
|
||||
|
||||
uint16_t
|
||||
getLimit() const
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
size_t
|
||||
getTotalPayloadLength() const
|
||||
{
|
||||
return m_totalPayloadLength;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer)
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
for (int64_t i = 0; i < N; i++) {
|
||||
totalLength += prependNonNegativeIntegerBlock(outBuffer, ndn::tlv::Content, i);
|
||||
}
|
||||
|
||||
m_totalPayloadLength += totalLength;
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
protected:
|
||||
size_t m_totalPayloadLength;
|
||||
};
|
||||
|
||||
template<int64_t N>
|
||||
class SegmentPublisherFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
SegmentPublisherFixture()
|
||||
: m_face(std::make_shared<ndn::util::DummyClientFace>(m_ioService, m_keyChain))
|
||||
, m_expectedFreshnessPeriod(ndn::time::milliseconds(111))
|
||||
, m_publisher(*m_face, m_keyChain, m_signingInfo, m_expectedFreshnessPeriod)
|
||||
, m_publishingPrefix("/localhost/nfd/SegmentPublisherFixture")
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
validate(const ndn::Data& data)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(data.getFreshnessPeriod(), m_expectedFreshnessPeriod);
|
||||
|
||||
ndn::Block payload = data.getContent();
|
||||
|
||||
m_buffer.appendByteArray(payload.value(), payload.value_size());
|
||||
|
||||
// uint64_t segmentNo = data.getName()[-1].toSegment();
|
||||
if (data.getFinalBlockId() != data.getName()[-1]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// wrap data in a single Content TLV for easy parsing
|
||||
m_buffer.prependVarNumber(m_buffer.size());
|
||||
m_buffer.prependVarNumber(ndn::tlv::Content);
|
||||
|
||||
BOOST_TEST_CHECKPOINT("creating parser");
|
||||
ndn::Block parser(m_buffer.buf(), m_buffer.size());
|
||||
BOOST_TEST_CHECKPOINT("parsing aggregated response");
|
||||
parser.parse();
|
||||
|
||||
BOOST_REQUIRE_EQUAL(parser.elements_size(), m_publisher.getLimit());
|
||||
|
||||
uint64_t expectedNo = m_publisher.getLimit() - 1;
|
||||
for (ndn::Block::element_const_iterator i = parser.elements_begin();
|
||||
i != parser.elements_end();
|
||||
++i)
|
||||
{
|
||||
uint64_t number = readNonNegativeInteger(*i);
|
||||
BOOST_REQUIRE_EQUAL(number, expectedNo);
|
||||
--expectedNo;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ndn::util::DummyClientFace> m_face;
|
||||
const ndn::time::milliseconds m_expectedFreshnessPeriod;
|
||||
TestSegmentPublisher<N> m_publisher;
|
||||
ndn::EncodingBuffer m_buffer;
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
const ndn::Name m_publishingPrefix;
|
||||
};
|
||||
|
||||
using boost::mpl::int_;
|
||||
typedef boost::mpl::vector<int_<10000>, int_<100>, int_<10>, int_<0> > DatasetSizes;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(PublisherTestSegmentPublisher)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Generate, T, DatasetSizes, SegmentPublisherFixture<T::value>)
|
||||
{
|
||||
this->m_publisher.publish(this->m_publishingPrefix);
|
||||
this->m_face->processEvents();
|
||||
|
||||
size_t nSegments = this->m_publisher.getTotalPayloadLength() /
|
||||
this->m_publisher.getMaxSegmentSize();
|
||||
if (this->m_publisher.getTotalPayloadLength() % this->m_publisher.getMaxSegmentSize() != 0 ||
|
||||
nSegments == 0)
|
||||
++nSegments;
|
||||
|
||||
BOOST_CHECK_EQUAL(this->m_face->sentData.size(), nSegments);
|
||||
for (const ndn::Data& data : this->m_face->sentData) {
|
||||
this->validate(data);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace tests
|
||||
} // 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-2019, The University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
@@ -20,9 +20,11 @@
|
||||
* \author Ashlesh Gawande <agawande@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
|
||||
#include "route/fib-entry.hpp"
|
||||
#include "route/nexthop-list.hpp"
|
||||
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user