Compare commits
89
Commits
NLSR-0.1.0
...
NLSR-0.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
800833b7ac | ||
|
|
e8e03ac303 | ||
|
|
5ec9ae4271 | ||
|
|
f7eec4f4c0 | ||
|
|
5c467f0ca8 | ||
|
|
aa3b085384 | ||
|
|
d02c3880d5 | ||
|
|
3ac0728e5a | ||
|
|
c778e814db | ||
|
|
af909fcc13 | ||
|
|
c69da0a350 | ||
|
|
0ff5d45ba8 | ||
|
|
5d9c0573c0 | ||
|
|
4c7caadb72 | ||
|
|
f9f3910dd2 | ||
|
|
53c0e3e9ee | ||
|
|
c57c64b633 | ||
|
|
97473d47fd | ||
|
|
5363c7946b | ||
|
|
f4772d4f21 | ||
|
|
46ccaae829 | ||
|
|
c69c9af931 | ||
|
|
d33e5bc475 | ||
|
|
dce3f18229 | ||
|
|
cae33b69f2 | ||
|
|
18df0602d3 | ||
|
|
41b173ed54 | ||
|
|
9630fbf4e0 | ||
|
|
a6f3e645f5 | ||
|
|
de5560cd3d | ||
|
|
9551edf4d8 | ||
|
|
52493c7c19 | ||
|
|
59dfac3569 | ||
|
|
c2acdcbbb6 | ||
|
|
c439d66728 | ||
|
|
d6bb3fa306 | ||
|
|
297f4163c2 | ||
|
|
9d09780605 | ||
|
|
199e9cf8d9 | ||
|
|
24ed83aa5e | ||
|
|
cec3885c43 | ||
|
|
fb2adee968 | ||
|
|
a0497d8f5c | ||
|
|
02e32996c7 | ||
|
|
50df6b7981 | ||
|
|
7a56d1c7c1 | ||
|
|
75b0ea543f | ||
|
|
c035206443 | ||
|
|
c00650f1ad | ||
|
|
6151e957cf | ||
|
|
9dce0c9445 | ||
|
|
7ccf694ae1 | ||
|
|
f814205d5c | ||
|
|
c2e51f6b6b | ||
|
|
d5a13cdaea | ||
|
|
49b1c0c23f | ||
|
|
5a45495e3e | ||
|
|
c11cc20948 | ||
|
|
0bcf9a361d | ||
|
|
f09e2633a0 | ||
|
|
b45eed2d28 | ||
|
|
a2228c6e1f | ||
|
|
93d9ec37ea | ||
|
|
fc7d5b6fc5 | ||
|
|
2fe12879bd | ||
|
|
bfa2760c57 | ||
|
|
b669f9c02d | ||
|
|
c292d18cd9 | ||
|
|
ee29a03a66 | ||
|
|
b7079a11a3 | ||
|
|
0a7da61b45 | ||
|
|
7c8882ffac | ||
|
|
1cf1e10389 | ||
|
|
7b616582ed | ||
|
|
27f1add26d | ||
|
|
92e5ffba6e | ||
|
|
5bf83175c3 | ||
|
|
20fe4a9cb0 | ||
|
|
942eb7b67d | ||
|
|
f1aa52389a | ||
|
|
0913112f4a | ||
|
|
e875d1f0e6 | ||
|
|
9a7090334d | ||
|
|
904c2413b2 | ||
|
|
9f51efdbcb | ||
|
|
7c60329b07 | ||
|
|
c0b97af1cc | ||
|
|
cb76aded0a | ||
|
|
f99b87fe07 |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
.DS*
|
||||
.waf-1*
|
||||
.waf3-*
|
||||
.lock*
|
||||
**/*.pyc
|
||||
build/
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
|
||||
for i in `find "$DIR/.jenkins.d" -type f -perm +111 | sort`; do
|
||||
for i in $( find "$DIR/.jenkins.d" -type f -perm +111 | sort ); do
|
||||
echo "Run: $i"
|
||||
$i
|
||||
"$i"
|
||||
done
|
||||
@@ -1,7 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
|
||||
sudo apt-get -y install liblog4cxx10-dev protobuf-compiler libprotobuf-dev pkg-config || true
|
||||
sudo brew update || true
|
||||
brew install log4cxx protobuf pkg-config || true
|
||||
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
source "$JDIR"/util.sh
|
||||
|
||||
if has OSX $NODE_LABELS && ! has OSX-10.8-c++11-64bit $NODE_LABELS; then
|
||||
# OSX 10.8 requires special handling of dependencies
|
||||
set -x
|
||||
brew update
|
||||
brew upgrade
|
||||
brew install boost pkg-config sqlite cryptopp log4cxx protobuf openssl
|
||||
brew link --force openssl log4cxx protobuf
|
||||
brew cleanup
|
||||
fi
|
||||
|
||||
if has Ubuntu $NODE_LABELS; then
|
||||
BOOST_PKG=libboost-all-dev
|
||||
if has Ubuntu-12.04 $NODE_LABELS; then
|
||||
BOOST_PKG=libboost1.48-all-dev
|
||||
fi
|
||||
|
||||
set -x
|
||||
sudo apt-get update -qq -y
|
||||
sudo apt-get -qq -y install build-essential pkg-config $BOOST_PKG \
|
||||
libcrypto++-dev libsqlite3-dev \
|
||||
liblog4cxx10-dev protobuf-compiler libprotobuf-dev libssl-dev
|
||||
fi
|
||||
+30
-26
@@ -1,38 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
|
||||
cd /tmp
|
||||
BUILD="no"
|
||||
if [ ! -d ndn-cxx ]; then
|
||||
git clone --depth 1 git://github.com/named-data/ndn-cxx
|
||||
cd ndn-cxx
|
||||
BUILD="yes"
|
||||
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
source "$JDIR"/util.sh
|
||||
|
||||
pushd /tmp >/dev/null
|
||||
|
||||
INSTALLED_VERSION=$((cd ndn-cxx && git rev-parse HEAD) 2>/dev/null || echo NONE)
|
||||
|
||||
sudo rm -Rf ndn-cxx-latest
|
||||
|
||||
git clone --depth 1 git://github.com/named-data/ndn-cxx ndn-cxx-latest
|
||||
|
||||
LATEST_VERSION=$((cd ndn-cxx-latest && git rev-parse HEAD) 2>/dev/null || echo UNKNOWN)
|
||||
|
||||
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
|
||||
sudo rm -Rf ndn-cxx
|
||||
mv ndn-cxx-latest ndn-cxx
|
||||
else
|
||||
cd ndn-cxx
|
||||
INSTALLED_VERSION=`git rev-parse HEAD || echo NONE`
|
||||
sudo rm -Rf latest-version
|
||||
git clone --depth 1 git://github.com/named-data/ndn-cxx latest-version
|
||||
cd latest-version
|
||||
LATEST_VERSION=`git rev-parse HEAD || echo UNKNOWN`
|
||||
cd ..
|
||||
rm -Rf latest-version
|
||||
if [ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]; then
|
||||
cd ..
|
||||
sudo rm -Rf ndn-cxx
|
||||
git clone --depth 1 git://github.com/named-data/ndn-cxx
|
||||
cd ndn-cxx
|
||||
BUILD="yes"
|
||||
fi
|
||||
sudo rm -Rf ndn-cxx-latest
|
||||
fi
|
||||
|
||||
sudo rm -Rf /usr/local/include/ndn-cxx
|
||||
sudo rm -f /usr/local/lib/libndn-cxx*
|
||||
sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
|
||||
|
||||
if [ "$BUILD" = "yes" ]; then
|
||||
./waf distclean --color=yes
|
||||
fi
|
||||
pushd ndn-cxx >/dev/null
|
||||
|
||||
./waf configure --color=yes --without-osx-keychain
|
||||
./waf configure -j1 --color=yes --enable-shared --disable-static --without-osx-keychain
|
||||
./waf -j1 --color=yes
|
||||
sudo ./waf install --color=yes
|
||||
sudo ./waf install -j1 --color=yes
|
||||
|
||||
popd >/dev/null
|
||||
popd >/dev/null
|
||||
|
||||
if has Linux $NODE_LABELS; then
|
||||
sudo ldconfig
|
||||
elif has FreeBSD $NODE_LABELS; then
|
||||
sudo ldconfig -a
|
||||
fi
|
||||
+25
-4
@@ -1,16 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
|
||||
git submodule init
|
||||
git submodule sync
|
||||
git submodule update
|
||||
|
||||
# actual build
|
||||
./waf distclean --color=yes
|
||||
COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
|
||||
|
||||
COVERAGE=`python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''"`
|
||||
# Cleanup
|
||||
sudo ./waf -j1 --color=yes distclean
|
||||
|
||||
CXXFLAGS="-Wall -Wno-long-long -O2 -g -Werror" ./waf configure --color=yes --with-tests $COVERAGE
|
||||
# Configure/build in debug mode
|
||||
./waf -j1 --color=yes configure --with-tests --debug
|
||||
./waf -j1 --color=yes build
|
||||
|
||||
# Cleanup
|
||||
sudo ./waf -j1 --color=yes distclean
|
||||
|
||||
# Configure/build in optimized mode without tests
|
||||
./waf -j1 --color=yes configure
|
||||
./waf -j1 --color=yes build
|
||||
|
||||
# Cleanup
|
||||
sudo ./waf -j1 --color=yes distclean
|
||||
|
||||
# Configure/build in optimized mode with tests
|
||||
./waf -j1 --color=yes configure --with-tests $COVERAGE
|
||||
./waf -j1 --color=yes build
|
||||
|
||||
# (tests will be run against optimized version)
|
||||
|
||||
./waf configure --color=yes --with-tests $COVERAGE
|
||||
|
||||
./waf -j1 --color=yes
|
||||
sudo ./waf install --color=yes
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
|
||||
rm -Rf ~/.ndn
|
||||
|
||||
./build/unit-tests-nlsr -l test_suite
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
has() {
|
||||
local p=$1
|
||||
shift
|
||||
local x
|
||||
for x in "$@"; do
|
||||
[[ "${x}" == "${p}" ]] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
sudo: required
|
||||
language: generic
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=g++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: osx
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="OSX OSX-10.9"
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
on_failure: always
|
||||
script:
|
||||
- ./.jenkins
|
||||
@@ -1,63 +1,191 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
#
|
||||
# Copyright (c) 2014 University of Memphis,
|
||||
# Regents of the University of California
|
||||
#
|
||||
# GPL 3.0 license, see the COPYING.md file for more information
|
||||
|
||||
from waflib import Logs, Configure
|
||||
from waflib import Logs, Configure, Utils
|
||||
|
||||
def options(opt):
|
||||
opt.add_option('--with-c++11', action='store_true', default=False, dest='use_cxx11',
|
||||
help='''Enable C++11 mode (experimental, may not work)''')
|
||||
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
|
||||
help='''Compile in debugging mode without all optimizations (-O0)''')
|
||||
help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
|
||||
|
||||
def configure(conf):
|
||||
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
|
||||
defaultFlags = []
|
||||
|
||||
if conf.options.use_cxx11:
|
||||
defaultFlags += ['-std=c++0x', '-std=c++11']
|
||||
cxx = conf.env['CXX_NAME'] # CXX_NAME represents generic name of the compiler
|
||||
if cxx == 'gcc':
|
||||
flags = GccFlags()
|
||||
elif cxx == 'clang':
|
||||
flags = ClangFlags()
|
||||
else:
|
||||
defaultFlags += ['-std=c++03']
|
||||
flags = CompilerFlags()
|
||||
Logs.warn('The code has not yet been tested with %s compiler' % cxx)
|
||||
|
||||
# defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long']
|
||||
defaultFlags += ['-Wall', '-Wno-long-long']
|
||||
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
|
||||
|
||||
# General flags are always applied (e.g., selecting C++11 mode)
|
||||
generalFlags = flags.getGeneralFlags(conf)
|
||||
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
|
||||
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
|
||||
conf.env.DEFINES += generalFlags['DEFINES']
|
||||
|
||||
# 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:
|
||||
conf.define('_DEBUG', 1)
|
||||
defaultFlags += ['-O0',
|
||||
'-Og', # gcc >= 4.8
|
||||
'-g3',
|
||||
'-fcolor-diagnostics', # clang
|
||||
'-fdiagnostics-color', # gcc >= 4.9
|
||||
'-Werror'
|
||||
]
|
||||
extraFlags = flags.getDebugFlags(conf)
|
||||
if areCustomCxxflagsPresent:
|
||||
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
|
||||
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))
|
||||
else:
|
||||
conf.add_supported_cxxflags(defaultFlags)
|
||||
else:
|
||||
defaultFlags += ['-O2', '-g']
|
||||
if not areCustomCxxflagsPresent:
|
||||
conf.add_supported_cxxflags(defaultFlags)
|
||||
extraFlags = flags.getOptimizedFlags(conf)
|
||||
|
||||
if not areCustomCxxflagsPresent:
|
||||
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
|
||||
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
|
||||
|
||||
conf.env.DEFINES += extraFlags['DEFINES']
|
||||
|
||||
@Configure.conf
|
||||
def add_supported_cxxflags(self, cxxflags):
|
||||
"""
|
||||
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
|
||||
"""
|
||||
self.start_msg('Checking allowed flags for c++ compiler')
|
||||
if len(cxxflags) == 0:
|
||||
return
|
||||
|
||||
self.start_msg('Checking supported CXXFLAGS')
|
||||
|
||||
supportedFlags = []
|
||||
for flag in cxxflags:
|
||||
if self.check_cxx(cxxflags=[flag], mandatory=False):
|
||||
if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
|
||||
supportedFlags += [flag]
|
||||
|
||||
self.end_msg(' '.join(supportedFlags))
|
||||
self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
|
||||
|
||||
@Configure.conf
|
||||
def add_supported_linkflags(self, linkflags):
|
||||
"""
|
||||
Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
|
||||
"""
|
||||
if len(linkflags) == 0:
|
||||
return
|
||||
|
||||
self.start_msg('Checking supported LINKFLAGS')
|
||||
|
||||
supportedFlags = []
|
||||
for flag in linkflags:
|
||||
if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
|
||||
supportedFlags += [flag]
|
||||
|
||||
self.end_msg(' '.join(supportedFlags))
|
||||
self.env.LINKFLAGS = supportedFlags + self.env.LINKFLAGS
|
||||
|
||||
|
||||
class CompilerFlags(object):
|
||||
def getGeneralFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
|
||||
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
|
||||
|
||||
class GccBasicFlags(CompilerFlags):
|
||||
"""
|
||||
This class defines basic flags that work for both gcc and clang compilers
|
||||
"""
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-O0',
|
||||
'-g3',
|
||||
'-pedantic',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Werror',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wno-error=maybe-uninitialized', # Bug #1615
|
||||
]
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(GccBasicFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-O2',
|
||||
'-g',
|
||||
'-pedantic',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wno-unused-parameter',
|
||||
]
|
||||
return flags
|
||||
|
||||
class GccFlags(GccBasicFlags):
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(GccFlags, self).getGeneralFlags(conf)
|
||||
version = tuple(int(i) for i in conf.env['CC_VERSION'])
|
||||
if version < (4, 6, 0):
|
||||
conf.fatal('The version of gcc you are using (%s) is too old.\n' %
|
||||
'.'.join(conf.env['CC_VERSION']) +
|
||||
'The minimum supported gcc version is 4.6.0.')
|
||||
elif version < (4, 7, 0):
|
||||
flags['CXXFLAGS'] += ['-std=c++0x']
|
||||
else:
|
||||
flags['CXXFLAGS'] += ['-std=c++11']
|
||||
if version < (4, 8, 0):
|
||||
flags['DEFINES'] += ['_GLIBCXX_USE_NANOSLEEP'] # Bug #2499
|
||||
return flags
|
||||
|
||||
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'] += ['-Og', # gcc >= 4.8
|
||||
'-fdiagnostics-color', # gcc >= 4.9
|
||||
]
|
||||
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
|
||||
return flags
|
||||
|
||||
class ClangFlags(GccBasicFlags):
|
||||
def getGeneralFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getGeneralFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-std=c++11']
|
||||
if Utils.unversioned_sys_platform() == 'darwin':
|
||||
flags['CXXFLAGS'] += ['-stdlib=libc++']
|
||||
flags['LINKFLAGS'] += ['-stdlib=libc++']
|
||||
return flags
|
||||
|
||||
def getDebugFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getDebugFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
'-Wno-error=unneeded-internal-declaration', # Bug #1588
|
||||
'-Wno-error=deprecated-register',
|
||||
'-Wno-error=keyword-macro', # Bug #3235
|
||||
'-Wno-nested-anon-types',
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-keyword-macro',
|
||||
'-Wno-error=ignored-qualifiers',
|
||||
'-Wno-error=infinite-recursion',
|
||||
]
|
||||
return flags
|
||||
|
||||
def getOptimizedFlags(self, conf):
|
||||
flags = super(ClangFlags, self).getOptimizedFlags(conf)
|
||||
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
|
||||
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
|
||||
'-Wno-nested-anon-types',
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-keyword-macro',
|
||||
]
|
||||
return flags
|
||||
@@ -30,10 +30,11 @@ def check_openssl(self,*k,**kw):
|
||||
libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
|
||||
msg='Checking for OpenSSL library',
|
||||
define_name='HAVE_%s' % var,
|
||||
global_define=True,
|
||||
uselib_store=var,
|
||||
mandatory=mandatory,
|
||||
cxxflags="-I%s/include" % root,
|
||||
linkflags="-L%s/lib" % root)
|
||||
includes="%s/include" % root,
|
||||
libpath="%s/lib" % root)
|
||||
else:
|
||||
libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
|
||||
msg='Checking for OpenSSL library',
|
||||
|
||||
+18
-7
@@ -6,6 +6,10 @@ NLSR is an open source project includes contributions from the members of the
|
||||
|
||||
## Project lead:
|
||||
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
|
||||
## Past project leads:
|
||||
|
||||
* A K M Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
|
||||
|
||||
## Technical advisors:
|
||||
@@ -20,19 +24,26 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* The University of Memphis
|
||||
|
||||
* A K M Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
|
||||
* Ashlesh Gawande
|
||||
* Minsheng Zhang
|
||||
* Syed Obaid Amin <http://obaidamin.weebly.com/>
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
* Ashlesh Gawande <agawande@memphis.edu>
|
||||
* Minsheng Zhang <mzhang4@memphis.edu>
|
||||
* Syed Obaid Amin <http://obaidamin.weebly.com/>
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
* Muktadir R Chowdhury <mrchwdhr@memphis.edu>
|
||||
* Nicholas Gordon <nmgordon@memphis.edu>
|
||||
|
||||
* University of California, Los Angeles
|
||||
|
||||
* Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/web/index.html>
|
||||
* Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
|
||||
* Spyridon Mastorakis <http://cs.ucla.edu/~mastorakis/>
|
||||
* Jiewen Tan <alanwake@ucla.edu>
|
||||
|
||||
* University of Arizona
|
||||
|
||||
* Junxiao Shi <https://www.cs.arizona.edu/people/shijunxiao/>
|
||||
|
||||
|
||||
## Queries about NLSR
|
||||
|
||||
Any general question related to NLSR should be directed to A K M Mahmudul Hoque
|
||||
(ahoque1@memphis.edu) and security related question should be directed to Yingdi
|
||||
Yu (yingdi@cs.ucla.edu)
|
||||
Any question related to NLSR should be directed to Ashlesh Gawande (agawande@memphis.edu),
|
||||
Muktadir R Chowdhury (mrchwdhr@memphis.edu), and Nicholas Gordon (nmgordon@memphis.edu).
|
||||
+45
@@ -1,3 +1,48 @@
|
||||
NLSR LICENSE
|
||||
============
|
||||
|
||||
NLSR is released under the GPL with the additional exemption that
|
||||
compiling, linking, and/or using OpenSSL is allowed.
|
||||
|
||||
NLSR relies on third-party software and libraries, licensed under the following
|
||||
licenses:
|
||||
|
||||
- Boost libraries are licensed under the conditions of
|
||||
[Boost Software License 1.0](http://www.boost.org/users/license.html)
|
||||
|
||||
- CryptoPP library is licensed under the conditions of
|
||||
[Boost Software License 1.0](http://www.boost.org/users/license.html)
|
||||
|
||||
- log4cxx is licensed under the conditions of
|
||||
[Apache License, Version 2.0](https://logging.apache.org/log4cxx/license.html)
|
||||
|
||||
- ndn-cxx is licensed under the conditions of
|
||||
[LGPL 3.0](https://github.com/named-data/ndn-cxx/blob/master/COPYING.md)
|
||||
|
||||
- protobuf is licensed under the conditions of
|
||||
[BSD license](https://github.com/google/protobuf/blob/master/LICENSE)
|
||||
|
||||
- SQLite is in [public domain](http://www.sqlite.org/copyright.html)
|
||||
|
||||
- waf build system is licensed under the conditions of
|
||||
[BSD license](https://github.com/named-data/ndn-cxx/blob/master/waf)
|
||||
|
||||
NLSR also relies on third-party libraries with non-GPL compatible licenses.
|
||||
These libraries fall into the category of "System Libraries" under GPL
|
||||
license definitions and are used in accordance with the GPL license exception
|
||||
for "System Libraries":
|
||||
|
||||
- OpenSSL is licensed under an
|
||||
[Apache-style licence](http://www.openssl.org/source/license.html)
|
||||
|
||||
- (OS X platform only) OS X Security Framework is licensed under
|
||||
[Apple Public Source License](http://www.opensource.apple.com/license/apsl/)
|
||||
|
||||
The GPL license is provided below in this file.
|
||||
For more information, see http://www.gnu.org/licenses/
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
==========================
|
||||
Version 3, 29 June 2007
|
||||
|
||||
+11
-9
@@ -1,12 +1,15 @@
|
||||
Requirements
|
||||
---------------------
|
||||
------------
|
||||
|
||||
Include the following header into all `.hpp` and `.cpp` files:
|
||||
Contributions to NLSR must be licensed under GPL 3.0 or compatible license. If you are
|
||||
choosing GPL 3.0, please use the following license boilerplate in all `.hpp` and `.cpp`
|
||||
files:
|
||||
|
||||
Include the following header in all `.hpp` and `.cpp` files:
|
||||
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 The University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) [Year(s)], [Copyright Holder(s)].
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -21,13 +24,12 @@ Include the following header into all `.hpp` and `.cpp` files:
|
||||
*
|
||||
* 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/>.
|
||||
////// [optional part] //////
|
||||
*
|
||||
* \author Author's Name <email@domain>
|
||||
* \author Other Author's Name <another.email@domain>
|
||||
////// [end of optional part] //////
|
||||
**/
|
||||
|
||||
If you are affiliated with an NSF-supported NDN project institution,
|
||||
please use the [NDN Team License Boilerplate]
|
||||
(http://redmine.named-data.net/projects/nlsr/wiki/NDN_Team_License_Boilerplate_(NLSR)).
|
||||
|
||||
Recommendations
|
||||
---------------
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
NLSR - Named Data Link State Routing Protocol
|
||||
=============================================
|
||||
|
||||
For complete documentation and more extensive information,
|
||||
please visit the [NLSR homepage](http://named-data.net/doc/NLSR/current/).
|
||||
|
||||
## Overview
|
||||
|
||||
NLSR is a routing protocol in NDN that populates NDN's Routing Information Base. NLSR
|
||||
@@ -28,9 +31,9 @@ Source releases
|
||||
The source code and source-code installation instructions are always available at
|
||||
the following links:
|
||||
|
||||
- [Installation](https://github.com/named-data/NLSR/blob/master/docs/INSTALL.md)
|
||||
- [Getting Started with NLSR](https://github.com/named-data/NLSR/blob/master/docs/GETTING-STARTED.md)
|
||||
- [Github NLSR repository](https://github.com/named-data/NLSR)
|
||||
- [Installation](http://named-data.net/doc/NLSR/current/INSTALL.html)
|
||||
- [Getting Started with NLSR](http://named-data.net/doc/NLSR/current/GETTING-STARTED.html)
|
||||
- [GitHub NLSR repository](https://github.com/named-data/NLSR)
|
||||
|
||||
Additional information
|
||||
----------------------
|
||||
|
||||
+16
-2
@@ -40,6 +40,20 @@ for detailed installation and running instruction.
|
||||
|
||||
sudo port install protobuf-cpp
|
||||
|
||||
- openssl
|
||||
|
||||
On Ubuntu Linux:
|
||||
|
||||
::
|
||||
|
||||
sudo apt-get install libssl-dev
|
||||
|
||||
On OS X with MacPorts:
|
||||
|
||||
::
|
||||
|
||||
sudo port install openssl
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
@@ -54,11 +68,11 @@ Execute the following commands to build NLSR:
|
||||
Refer to ``./waf –help`` for more options that can be used during the configure stage and
|
||||
how to properly configure NLSR.
|
||||
|
||||
If your pkgconfig path is not set properly you can do following before running ``./waf
|
||||
If your pkgconfig path is not set properly you can do the following before running ``./waf
|
||||
configure``
|
||||
|
||||
::
|
||||
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
|
||||
or
|
||||
export PKG_CONFIG_PATH=/path/to/pkgconfig/in/your/machine
|
||||
export PKG_CONFIG_PATH=/path/to/pkgconfig/on/your/machine
|
||||
+159
-17
@@ -1,6 +1,157 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
NLSR version 0.3.0 (changes since version 0.2.2)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: August 1, 2016
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Do not advertise Adjacency LSAs when hyperbolic routing is enabled (:issue:`2402`)
|
||||
|
||||
- Do not distribute coordinate LSAs when using link-state routing. (:issue:`3661`)
|
||||
|
||||
- LSAs should be segmented before they are published (:issue:`2965`)
|
||||
|
||||
- Don't use DummyClientFace::sentDatas (:issue:`3383`)
|
||||
|
||||
- Remove disabled security files (:issue:`2960`)
|
||||
|
||||
- Lsa type should be argument for base class LSA constructor (:issue:`2788`)
|
||||
|
||||
- Use ndn-cxx/DummyClientFace (:issue:`2637`)
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- Unit tests cases are installed with `./waf install` (:issue:`3359`)
|
||||
|
||||
|
||||
NLSR version 0.2.2 (changes since version 0.2.1)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: January 5, 2016
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Adapt code to changes in NFD/ndn-cxx version 0.4.0 release
|
||||
|
||||
NLSR version 0.2.1 (changes since version 0.2.0)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: June 30, 2015
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Using a configuration file without ``prefix-update-validator`` disables runtime advertise/withdraw instead of exiting (:issue:`2814`)
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- Prevent incomplete removal of NPT entry (:issue:`2785`)
|
||||
|
||||
- Correct bidirectional links with differing costs (:issue:`2801`)
|
||||
|
||||
- Fix non-incrementing Adjacency number in AdjLsa::writeLog (:issue:`2594`)
|
||||
|
||||
- Remove FaceDestroyEvent test's reliance on nlsrSeqNo.txt (:issue:`2881`)
|
||||
|
||||
- Test ACTIVE/INACTIVE Adjacencies in LSA construction (:issue:`2735`)
|
||||
|
||||
NLSR version 0.2.0 (changes since version 0.1.0)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: April 30, 2015
|
||||
|
||||
**Build**:
|
||||
|
||||
- The code now requires C++11. The minimum supported gcc version is 4.6, as earlier versions do not have proper support for C++11 features. (:issue:`1930`)
|
||||
|
||||
- Require OpenSSL (:issue:`2375`)
|
||||
|
||||
**New features**:
|
||||
|
||||
- Add nlsrc command-line tool (:issue:`1834`)
|
||||
|
||||
- Advertise/Withdraw name prefixes at runtime (:issue:`1834`)
|
||||
|
||||
- Assign zero cost to hyperbolic direct neighbors (:issue:`1975`)
|
||||
|
||||
- Only hyperbolic costs are adjusted before registering (:issue:`1974`)
|
||||
|
||||
- Add ability to specify different logging levels (:issue:`1935`)
|
||||
|
||||
- Add LSDB dataset publishers (:issue:`2280`)
|
||||
|
||||
- Add LSDB dataset tlv abstractions (:issue:`2280`)
|
||||
|
||||
- Allow zero cost neighbors for hyperbolic routing table calculation (:issue:`1982`)
|
||||
|
||||
- Faces are now created with canonical Face URI (:issue:`1911`)
|
||||
|
||||
- Add configurable router event intervals (:issue:`2071`)
|
||||
|
||||
- Add router-dead-interval configuration setting (:issue:`1878`)
|
||||
|
||||
- Add log formatting specified by log4cxx configuration file (:issue:`1950`)
|
||||
|
||||
- Face URIs in configuration file are checked for validity on load (:issue:`2070`)
|
||||
|
||||
- Configuration variables with default values are now optional (:issue:`1949`)
|
||||
|
||||
- Recalculate routing table after face destroy event (:issue:`2635`)
|
||||
|
||||
- Add Travis-CI build script
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Change adjacency status from uint32_t to enum (:issue:`1946`)
|
||||
|
||||
- Remove scheduler from NLSR class (:issue:`1981`)
|
||||
|
||||
- Change hyperbolic cost adjustment factor from 100 to 1000 (:issue:`1974`)
|
||||
|
||||
- Remove use of outdated namespace ``ndn::Tlv`` (:issue:`2079`)
|
||||
|
||||
- Remove use of deprecated ``ndn::nfd::Controller(Face&)`` constructor (:issue:`2133`)
|
||||
|
||||
- Routing update publishing is abstracted to SyncLogicHandler (:issue:`2289`)
|
||||
|
||||
- Make ConfParameter variable types consistent with min and max values (:issue:`2084`)
|
||||
|
||||
- Replace LSA string literals with constants (:issue:`2310`)
|
||||
|
||||
- Subscribe to FaceMonitor notifications using connect (:issue:`2350`)
|
||||
|
||||
- Log exceptions thrown in event loop
|
||||
|
||||
- Change ``ndn::ptr_lib::shared_ptr`` to ``std::shared_ptr`` (:issue:`2110`)
|
||||
|
||||
- Avoid deprecated ``ndn::Name::set`` method (:issue:`2505`)
|
||||
|
||||
- Update waf to version 1.8.8-dev
|
||||
|
||||
- Add sorting tiebreaker to NexthopList (:issue:`2715`)
|
||||
|
||||
- Update Jenkins-CI build scripts
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- Fix python3 build error (:issue:`1956`)
|
||||
|
||||
- Fix typos in nlsr.conf security section (:issue:`1985`)
|
||||
|
||||
- Stop SyncLogicHandler from fetching a router’s own LSAs (:issue:`2005`)
|
||||
|
||||
- Fix Name LSA comparison which could cause incorrect advertised names to be removed (:issue:`2029`)
|
||||
|
||||
- Fix issue where more faces than max-faces-per-prefix could be applied to a prefix (:issue:`2018`)
|
||||
|
||||
- Stop LSDB from retrieving and out of date LSA when a new one is detected (:issue:`1987`)
|
||||
|
||||
- Correct mistakes in documentation
|
||||
|
||||
- Correct bitmask used to copy Name LSA sequence number (:issue:`2323`)
|
||||
|
||||
NLSR version 0.1.0 (initial release)
|
||||
++++++++++++++++++++++++++++++++++++
|
||||
|
||||
@@ -13,30 +164,21 @@ prefix in a single authoritative domain.
|
||||
|
||||
**Included features**:
|
||||
|
||||
- Produce a list of ranked forwarding options for each name prefix to facilitate NDN's adaptive forwarding strategies
|
||||
|
||||
- Name Prefix advertisement
|
||||
|
||||
+ Advertise availability of content through the configured router
|
||||
- Advertise availability of content through the configured router
|
||||
|
||||
- Use `ChronoSync <https://github.com/named-data/ChronoSync>`_ to synchronize routers' LSA sequence numbers and Interest/Data to retrieve LSAs
|
||||
|
||||
- Limit faces per prefix
|
||||
- Produce a list of ranked forwarding options for each name prefix to facilitate NDN's adaptive forwarding strategies
|
||||
|
||||
+ Configure maximum number of faces per prefix in NFD's RIB
|
||||
- Configure maximum number of faces per prefix in NFD’s RIB
|
||||
|
||||
- Automatic NFD tunnel configuration and maintenance to neighbors
|
||||
- Set up NFD tunnels to neighbors automatically and maintain the tunnels to neighbors
|
||||
|
||||
- Routing protocol
|
||||
- Provide two routing protocols:
|
||||
|
||||
+ Link State routing
|
||||
+ Hyperbolic routing
|
||||
|
||||
+ Calculates route cost based on a node's polar coordinates
|
||||
+ Link State routing: calculate route cost based on link costs
|
||||
+ Hyperbolic routing: calculate route cost based on hyperbolic coordinates
|
||||
|
||||
- Use a hierarchical trust model for routing within a single administrative domain
|
||||
|
||||
- NFD Routing Information Base (RIB) consistency
|
||||
|
||||
+ Provides shortest path next hops for efficient forwarding
|
||||
+ Keeps NFD's RIB updated on node failure and recovery
|
||||
- Keep NFD’s RIB updated on failure and recovery
|
||||
+17
-6
@@ -51,12 +51,11 @@ If you see ``ERROR: error while connecting to the forwarder (No such file or dir
|
||||
Step 2. Determining FaceUri
|
||||
---------------------------
|
||||
|
||||
Assume that ``/ndn/edu/arizona/%C1.Router/router3`` has hostname ``router3.arizona.edu``,
|
||||
``/ndn/edu/colostate/%C1.Router/router2`` has IP address ``79.123.10.145``, and that all
|
||||
routers in the network have agreed to sync data with name prefix ``/ndn/nlsr/sync``.
|
||||
Assume that ``/ndn/edu/arizona/%C1.Router/router3`` has hostname ``router3.arizona.edu`` and
|
||||
``/ndn/edu/colostate/%C1.Router/router2`` has IP address ``79.123.10.145``.
|
||||
``/ndn/edu/memphis/%C1.Router/router1`` will consider FaceUri
|
||||
``udp4://router3.arizona.edu`` for router ``/ndn/edu/arizona/%C1.Router/router3`` and face
|
||||
uri ``udp4://79.123.10.145`` for router ``/ndn/edu/colostate/%C1.Router/router2``.
|
||||
``udp4://router3.arizona.edu`` for router ``/ndn/edu/arizona/%C1.Router/router3`` and
|
||||
FaceUri ``udp4://79.123.10.145`` for router ``/ndn/edu/colostate/%C1.Router/router2``.
|
||||
|
||||
Step 3: Creating configuration file
|
||||
-----------------------------------
|
||||
@@ -88,6 +87,7 @@ configuration commands follows:
|
||||
log-level INFO ; default value INFO, valid value DEBUG, INFO
|
||||
log-dir /var/log/nlsr/
|
||||
seq-dir /var/lib/nlsr/
|
||||
; log4cxx-conf /path/to/log4cxx-conf
|
||||
}
|
||||
|
||||
; the neighbors section contains the configuration for router's neighbors and hello's behavior
|
||||
@@ -105,6 +105,17 @@ configuration commands follows:
|
||||
|
||||
hello-interval 60 ; interest sending interval in seconds. Default value 60
|
||||
; valid values 30-90
|
||||
|
||||
; adj-lsa-build-interval is the time to wait in seconds after an Adjacency LSA build is scheduled
|
||||
; before actually building the Adjacency LSA
|
||||
|
||||
adj-lsa-build-interval 5 ; default value 5. Valid values 0-5. It is recommended that
|
||||
; adj-lsa-build-interval have a lower value than routing-calc-interval
|
||||
|
||||
; first-hello-interval is the time to wait in seconds before sending the first Hello Interest
|
||||
|
||||
first-hello-interval 10 ; Default value 10. Valid values 0-10
|
||||
|
||||
; neighbor command is used to configure router's neighbor. Each neighbor will need
|
||||
; one block of neighbor command
|
||||
|
||||
@@ -137,7 +148,7 @@ configuration commands follows:
|
||||
; the switch is used to set hyperbolic routing calculation in NLSR
|
||||
|
||||
state off ; default value 'off', set value 'on' to enable hyperbolic routing table
|
||||
; calculation which turns link state routing 'off'. set value to 'dry-run"
|
||||
; calculation which turns link state routing 'off'. set value to 'dry-run'
|
||||
; to test hyperbolic routing and compare with link state routing.
|
||||
|
||||
|
||||
|
||||
+6
-2
@@ -18,7 +18,7 @@ import os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
@@ -30,6 +30,7 @@ import os
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.todo',
|
||||
'redmine_issue',
|
||||
]
|
||||
|
||||
def addExtensionIfExists(extension):
|
||||
@@ -59,7 +60,7 @@ master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'NLSR - Named Data Link State Routing Protocol'
|
||||
copyright = u'2014, Named Data Networking Project'
|
||||
copyright = u'2014-2015, Named Data Networking Project'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
@@ -239,6 +240,7 @@ latex_documents = [
|
||||
man_pages = [
|
||||
('manpages/nlsr', 'nlsr', u'Named Data Link State Routing Protocol Daemon', None, 1),
|
||||
('manpages/nlsr.conf', 'nlsr.conf', u'Named Data Link State Routing Protocol Daemon config file', None, 5),
|
||||
('manpages/nlsrc', 'nlsrc', u'Command-line utility to interact with and collect statistics from NLSR', None, 1),
|
||||
]
|
||||
|
||||
|
||||
@@ -248,3 +250,5 @@ man_pages = [
|
||||
if os.getenv('GOOGLE_ANALYTICS', None):
|
||||
googleanalytics_id = os.environ['GOOGLE_ANALYTICS']
|
||||
googleanalytics_enabled = True
|
||||
|
||||
redmine_project_url = "http://redmine.named-data.net/"
|
||||
+12
-13
@@ -1782,18 +1782,6 @@ GENERATE_XML = NO
|
||||
|
||||
XML_OUTPUT = xml
|
||||
|
||||
# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_SCHEMA =
|
||||
|
||||
# The XML_DTD tag can be used to specify a XML DTD, which can be used by a
|
||||
# validating XML parser to check the syntax of the XML files.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_DTD =
|
||||
|
||||
# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program
|
||||
# listings (including syntax highlighting and cross-referencing information) to
|
||||
# the XML output. Note that enabling this will significantly increase the size
|
||||
@@ -1928,7 +1916,18 @@ INCLUDE_FILE_PATTERNS =
|
||||
# recursively expanded use the := operator instead of the = operator.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
PREDEFINED =
|
||||
PREDEFINED = DOXYGEN=1 \
|
||||
INIT_LOGGER(x)= \
|
||||
BOOST_STATIC_ASSERT(x)= \
|
||||
BOOST_CONCEPT_ASSERT(x)= \
|
||||
BOOST_CONCEPT_REQUIRES(x)= \
|
||||
DECL_OVERRIDE=override \
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE=private \
|
||||
PUBLIC_WITH_TESTS_ELSE_PROTECTED=protected \
|
||||
PROTECTED_WITH_TESTS_ELSE_PRIVATE=private \
|
||||
VIRTUAL_WITH_TESTS \
|
||||
DECL_CLASS_FINAL=final \
|
||||
DECL_FINAL=final
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
# tag can be used to specify a list of macro names that should be expanded. The
|
||||
|
||||
+4
-4
@@ -19,7 +19,7 @@ The main design goal of NLSR is to provide a routing protocol to populate NDN's
|
||||
calculates the routing table using link-state or hyperbolic routing and produces multiple
|
||||
faces for each reachable name prefix in a single authoritative domain. NLSR will continue
|
||||
to evolve over time to include neighbor discovery and to become a full fledged
|
||||
inter-domain routing protocol for NDN. The project design is presented in full detail in
|
||||
inter-domain routing protocol for NDN. The protocol design is presented in full detail in
|
||||
the `NLSR Paper`_.
|
||||
|
||||
NLSR Documentation
|
||||
@@ -30,14 +30,14 @@ NLSR Documentation
|
||||
:maxdepth: 3
|
||||
|
||||
RELEASE-NOTES
|
||||
INSTALL
|
||||
GETTING-STARTED
|
||||
INSTALL
|
||||
ROUTER-CONFIG
|
||||
SECURITY-CONFIG
|
||||
manpages
|
||||
|
||||
- :doc:`INSTALL`
|
||||
- :doc:`GETTING-STARTED`
|
||||
- :doc:`INSTALL`
|
||||
- :doc:`ROUTER-CONFIG`
|
||||
- :doc:`SECURITY-CONFIG`
|
||||
- :doc:`RELEASE-NOTES`
|
||||
@@ -58,4 +58,4 @@ Additional information
|
||||
|
||||
|
||||
.. _NLSR Wiki: http://redmine.named-data.net/projects/nlsr
|
||||
.. _NLSR Paper: http://conferences.sigcomm.org/sigcomm/2013/papers/icn/p15.pdf
|
||||
.. _NLSR Paper: http://www.cs.memphis.edu/~lanwang/paper/nlsr-final.pdf
|
||||
@@ -6,4 +6,5 @@ Manpages
|
||||
.. toctree::
|
||||
manpages/nlsr
|
||||
manpages/nlsr.conf
|
||||
manpages/nlsrc
|
||||
:maxdepth: 1
|
||||
@@ -0,0 +1,55 @@
|
||||
nlsrc
|
||||
=====
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
::
|
||||
|
||||
nlsrc [-h] [-V] COMMAND [<Command Options>]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
``nlsrc`` is a tool to retrieve link-state database (LSDB) status information from NLSR and
|
||||
announce/withdraw Name prefixes advertised by NLSR.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
``-h``
|
||||
Print usage information
|
||||
|
||||
``-V``
|
||||
Show NLSRC version information
|
||||
|
||||
``COMMAND``
|
||||
|
||||
``status``
|
||||
Retrieve LSDB status information
|
||||
|
||||
``advertise``
|
||||
Add a Name prefix to be advertised by NLSR
|
||||
|
||||
``advertise <name>``
|
||||
|
||||
``name``
|
||||
The Name prefix to be advertised
|
||||
|
||||
``withdraw``
|
||||
Remove a Name prefix advertised through NLSR
|
||||
|
||||
``withdraw <name>``
|
||||
|
||||
``name``
|
||||
The Name prefix to be withdrawn
|
||||
|
||||
Exit Status
|
||||
-----------
|
||||
|
||||
nlsrc exits with one of the following values:
|
||||
::
|
||||
|
||||
0 nlsrc exited successfully
|
||||
>0 An error occurred
|
||||
@@ -0,0 +1,70 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
# Based on http://doughellmann.com/2010/05/09/defining-custom-roles-in-sphinx.html
|
||||
|
||||
"""Integration of Sphinx with Redmine.
|
||||
"""
|
||||
|
||||
from docutils import nodes, utils
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
|
||||
def redmine_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||
"""Link to a Redmine issue.
|
||||
|
||||
Returns 2 part tuple containing list of nodes to insert into the
|
||||
document and a list of system messages. Both are allowed to be
|
||||
empty.
|
||||
|
||||
:param name: The role name used in the document.
|
||||
:param rawtext: The entire markup snippet, with role.
|
||||
:param text: The text marked with the role.
|
||||
:param lineno: The line number where rawtext appears in the input.
|
||||
:param inliner: The inliner instance that called us.
|
||||
:param options: Directive options for customization.
|
||||
:param content: The directive content for customization.
|
||||
"""
|
||||
try:
|
||||
issue_num = int(text)
|
||||
if issue_num <= 0:
|
||||
raise ValueError
|
||||
except ValueError:
|
||||
msg = inliner.reporter.error(
|
||||
'Redmine issue number must be a number greater than or equal to 1; '
|
||||
'"%s" is invalid.' % text, line=lineno)
|
||||
prb = inliner.problematic(rawtext, rawtext, msg)
|
||||
return [prb], [msg]
|
||||
app = inliner.document.settings.env.app
|
||||
node = make_link_node(rawtext, app, 'issues', str(issue_num), options)
|
||||
return [node], []
|
||||
|
||||
def make_link_node(rawtext, app, type, slug, options):
|
||||
"""Create a link to a Redmine resource.
|
||||
|
||||
:param rawtext: Text being replaced with link node.
|
||||
:param app: Sphinx application context
|
||||
:param type: Link type (issue, changeset, etc.)
|
||||
:param slug: ID of the thing to link to
|
||||
:param options: Options dictionary passed to role func.
|
||||
"""
|
||||
#
|
||||
try:
|
||||
base = app.config.redmine_project_url
|
||||
if not base:
|
||||
raise AttributeError
|
||||
except AttributeError, err:
|
||||
raise ValueError('redmine_project_url configuration value is not set (%s)' % str(err))
|
||||
#
|
||||
slash = '/' if base[-1] != '/' else ''
|
||||
ref = base + slash + type + '/' + slug + '/'
|
||||
set_classes(options)
|
||||
node = nodes.reference(rawtext, 'Issue #' + utils.unescape(slug), refuri=ref,
|
||||
**options)
|
||||
return node
|
||||
|
||||
def setup(app):
|
||||
"""Install the plugin.
|
||||
|
||||
:param app: Sphinx application context.
|
||||
"""
|
||||
app.add_role('issue', redmine_role)
|
||||
app.add_config_value('redmine_project_url', None, 'env')
|
||||
return
|
||||
@@ -0,0 +1,11 @@
|
||||
log4j.rootLogger=DEBUG, Rolling
|
||||
|
||||
log4j.appender.Rolling=org.apache.log4j.rolling.RollingFileAppender
|
||||
log4j.appender.Rolling.File=/tmp/testnlsrproperties.log
|
||||
log4j.appender.Rolling.MaxSize=1MB
|
||||
log4j.appender.Rolling.MaxBackupIndex=10
|
||||
|
||||
log4j.appender.Rolling.layout=PatternLayout
|
||||
log4j.appender.Rolling.layout.ContextPrinting=enabled
|
||||
log4j.appender.Rolling.layout.DateFormat=ISO8601
|
||||
log4j.appender.Rolling.layout.ConversionPattern=%date{yyyyMMddHHmmssSSS} %p: [%c] %m%n
|
||||
@@ -11,14 +11,32 @@ general
|
||||
; lsa-refresh-time is the time in seconds, after which router will refresh its LSAs
|
||||
lsa-refresh-time 1800 ; default value 1800. Valid values 240-7200
|
||||
|
||||
; router-dead-interval is the time in seconds after which an inactive router's
|
||||
; LSAs are removed
|
||||
;router-dead-interval 3600 ; default value: 2*lsa-refresh-time. Value must be larger
|
||||
; than lsa-refresh-time
|
||||
|
||||
; InterestLifetime (in seconds) for LSA fetching
|
||||
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
|
||||
|
||||
; log-level is to set the levels of log for NLSR
|
||||
; log-level is used to set the logging level for NLSR.
|
||||
; All debugging levels listed above the selected value are enabled.
|
||||
;
|
||||
; Valid values:
|
||||
;
|
||||
; NONE ; no messages
|
||||
; ERROR ; error messages
|
||||
; WARN ; warning messages
|
||||
; INFO ; informational messages (default)
|
||||
; DEBUG ; debugging messages
|
||||
; TRACE ; trace messages (most verbose)
|
||||
; ALL ; all messages
|
||||
|
||||
log-level INFO ; default value INFO, valid value DEBUG, INFO
|
||||
log-dir /var/log/nlsr/ ; path for log directory (Absolute path)
|
||||
seq-dir /var/lib/nlsr/ ; path for sequence directory (Absolute path)
|
||||
log-level INFO
|
||||
|
||||
log-dir /var/log/nlsr/ ; path for log directory (Absolute path)
|
||||
seq-dir /var/lib/nlsr/ ; path for sequence directory (Absolute path)
|
||||
;log4cxx-conf /path/to/log4cxx-conf ; path for log4cxx configuration file (Absolute path)
|
||||
}
|
||||
|
||||
; the neighbors section contains the configuration for router's neighbors and hello's behavior
|
||||
@@ -37,6 +55,16 @@ neighbors
|
||||
hello-interval 60 ; interest sending interval in seconds. Default value 60
|
||||
; valid values 30-90
|
||||
|
||||
; adj-lsa-build-interval is the time to wait in seconds after an Adjacency LSA build is scheduled
|
||||
; before actually building the Adjacency LSA
|
||||
|
||||
adj-lsa-build-interval 5 ; default value 5. Valid values 0-5. It is recommended that
|
||||
; adj-lsa-build-interval have a lower value than routing-calc-interval
|
||||
|
||||
; first-hello-interval is the time to wait in seconds before sending the first Hello Interest
|
||||
|
||||
first-hello-interval 10 ; Default value 10. Valid values 0-10
|
||||
|
||||
; neighbor command is used to configure router's neighbor. Each neighbor will need
|
||||
; one block of neighbor command
|
||||
|
||||
@@ -68,7 +96,7 @@ hyperbolic
|
||||
; the switch is used to set hyperbolic routing calculation in NLSR
|
||||
|
||||
state off ; default value 'off', set value 'on' to enable hyperbolic routing table
|
||||
; calculation which turns link state routing 'off'. set value to 'dry-run"
|
||||
; calculation which turns link state routing 'off'. set value to 'dry-run'
|
||||
; to test hyperbolic routing and compare with link state routing.
|
||||
|
||||
|
||||
@@ -86,6 +114,12 @@ fib
|
||||
|
||||
max-faces-per-prefix 3 ; default value 0. Valid value 0-60. By default (value 0) NLSR adds
|
||||
; all available faces for each reachable name prefixes in NDN FIB
|
||||
|
||||
; routing-calc-interval is the time to wait in seconds after a routing table calculation is
|
||||
; scheduled before actually performing the routing table calculation
|
||||
|
||||
routing-calc-interval 15 ; default value 15. Valid values 0-15. It is recommended that
|
||||
; routing-calc-interval have a higher value than adj-lsa-build-interval
|
||||
}
|
||||
|
||||
; the advertising section contains the configuration settings of the name prefixes
|
||||
@@ -153,7 +187,8 @@ security
|
||||
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><ksk-.*><ID-CERT>$
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><>$
|
||||
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
|
||||
p-expand \\1\\2
|
||||
}
|
||||
}
|
||||
@@ -178,7 +213,7 @@ security
|
||||
type name
|
||||
hyper-relation
|
||||
{
|
||||
k-regex ^([^<KEY><%C1.Operator>]*)<%C1.Operator>[^<KEY>]*<KEY><ksk-.*><ID-CERT>$
|
||||
k-regex ^([^<KEY><%C1.Operator>]*)<%C1.Operator>[^<KEY>]*<KEY><ksk-.*><ID-CERT>$
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
p-regex ^([^<KEY><%C1.Router>]*)<%C1.Router>[^<KEY>]*<KEY><ksk-.*><ID-CERT><>$
|
||||
@@ -210,12 +245,63 @@ security
|
||||
file-name "root.cert"
|
||||
}
|
||||
}
|
||||
; cert-to-publish "root.cert" ; optional, a file containing the root certificate. only the router
|
||||
; that is designated to publish root cert needs to specify this
|
||||
; cert-to-publish "site.cert" ; optional, a file containing the root certificate. only the router
|
||||
; that is designated to publish site cert need to specify this
|
||||
; cert-to-publish "operator.cert" ; optional, a file containing the root certificate. only the
|
||||
; router that is designated to publish operator cert need to
|
||||
; specify this
|
||||
|
||||
prefix-update-validator
|
||||
{
|
||||
rule
|
||||
{
|
||||
id "NLSR ControlCommand Rule"
|
||||
for interest
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^<localhost><nlsr><prefix-update>[<advertise><withdraw>]<>$
|
||||
}
|
||||
checker
|
||||
{
|
||||
type customized
|
||||
sig-type rsa-sha256
|
||||
key-locator
|
||||
{
|
||||
type name
|
||||
regex ^([^<KEY><%C1.Operator>]*)<%C1.Operator>[^<KEY>]*<KEY><ksk-.*><ID-CERT>$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rule
|
||||
{
|
||||
id "NLSR Hierarchy Rule"
|
||||
for data
|
||||
filter
|
||||
{
|
||||
type name
|
||||
regex ^[^<KEY>]*<KEY><ksk-.*><ID-CERT><>$
|
||||
}
|
||||
checker
|
||||
{
|
||||
type hierarchical
|
||||
sig-type rsa-sha256
|
||||
}
|
||||
}
|
||||
|
||||
trust-anchor
|
||||
{
|
||||
type file
|
||||
file-name "site.cert"
|
||||
}
|
||||
}
|
||||
; cert-to-publish "root.cert" ; optional, a file containing the root certificate
|
||||
; Only the router that is designated to publish the root cert
|
||||
; needs to specify this
|
||||
|
||||
; cert-to-publish "site.cert" ; optional, a file containing the site certificate
|
||||
; Only the router that is designated to publish the site cert
|
||||
; needs to specify this
|
||||
|
||||
; cert-to-publish "operator.cert" ; optional, a file containing the operator certificate
|
||||
; Only the router that is designated to publish the operator
|
||||
; cert needs to specify this
|
||||
|
||||
cert-to-publish "router.cert" ; required, a file containing the router certificate.
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NSYNC_SYNC_COMMON_HPP
|
||||
#define NSYNC_SYNC_COMMON_HPP
|
||||
|
||||
#include <boost/exception/all.hpp>
|
||||
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace Sync {
|
||||
|
||||
using std::bind;
|
||||
using std::function;
|
||||
|
||||
using std::make_shared;
|
||||
using std::shared_ptr;
|
||||
using std::weak_ptr;
|
||||
|
||||
using std::dynamic_pointer_cast;
|
||||
using std::static_pointer_cast;
|
||||
|
||||
using std::tuple;
|
||||
using std::make_tuple;
|
||||
using std::tie;
|
||||
|
||||
} // namespace Sync
|
||||
|
||||
#endif // NSYNC_SYNC_COMMON_HPP
|
||||
@@ -17,12 +17,12 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-diff-leaf.h"
|
||||
#include <boost/throw_exception.hpp>
|
||||
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info;
|
||||
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info;
|
||||
|
||||
using namespace Sync::Error;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_DIFF_LEAF_H
|
||||
@@ -40,7 +40,7 @@ enum Operation
|
||||
|
||||
/**
|
||||
* @ingroup sync
|
||||
* @brief Annotated SYNC leaf
|
||||
* @brief Annotated SYNC leaf
|
||||
*/
|
||||
class DiffLeaf : public Leaf
|
||||
{
|
||||
@@ -73,8 +73,8 @@ private:
|
||||
Operation m_op;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<DiffLeaf> DiffLeafPtr;
|
||||
typedef boost::shared_ptr<const DiffLeaf> DiffLeafConstPtr;
|
||||
typedef shared_ptr<DiffLeaf> DiffLeafPtr;
|
||||
typedef shared_ptr<const DiffLeaf> DiffLeafConstPtr;
|
||||
|
||||
std::ostream &
|
||||
operator << (std::ostream &os, Operation op);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_DIFF_STATE_CONTAINER_H
|
||||
@@ -40,7 +40,7 @@ namespace mi = boost::multi_index;
|
||||
|
||||
namespace Sync {
|
||||
|
||||
/// @cond include_hidden
|
||||
/// @cond include_hidden
|
||||
struct sequenced { };
|
||||
struct timed { };
|
||||
/// @endcond
|
||||
@@ -59,7 +59,7 @@ struct DiffStateContainer : public mi::multi_index_container<
|
||||
DigestPtrHash,
|
||||
DigestPtrEqual
|
||||
>
|
||||
,
|
||||
,
|
||||
// sequenced index to access older/newer element (like in list)
|
||||
mi::sequenced<mi::tag<sequenced> >
|
||||
>
|
||||
|
||||
@@ -17,18 +17,15 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-diff-state.h"
|
||||
#include "sync-diff-leaf.h"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
namespace Sync {
|
||||
|
||||
DiffState::DiffState ()
|
||||
@@ -43,7 +40,7 @@ DiffStatePtr
|
||||
DiffState::diff () const
|
||||
{
|
||||
DiffStatePtr ret = make_shared<DiffState> ();
|
||||
|
||||
|
||||
DiffStatePtr state = m_next;
|
||||
while (state != 0)
|
||||
{
|
||||
@@ -71,17 +68,17 @@ DiffState::operator += (const DiffState &state)
|
||||
BOOST_ASSERT (false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// from State
|
||||
boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
DiffState::update (NameInfoConstPtr info, const SeqNo &seq)
|
||||
{
|
||||
m_leaves.erase (info);
|
||||
|
||||
DiffLeafPtr leaf = make_shared<DiffLeaf> (info, cref (seq));
|
||||
DiffLeafPtr leaf = make_shared<DiffLeaf> (info, seq);
|
||||
m_leaves.insert (leaf);
|
||||
|
||||
return make_tuple (true, false, SeqNo ());
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_DIFF_STATE_H
|
||||
@@ -29,8 +29,8 @@
|
||||
namespace Sync {
|
||||
|
||||
class DiffState;
|
||||
typedef boost::shared_ptr<DiffState> DiffStatePtr;
|
||||
typedef boost::shared_ptr<DiffState> DiffStateConstPtr;
|
||||
typedef shared_ptr<DiffState> DiffStatePtr;
|
||||
typedef shared_ptr<DiffState> DiffStateConstPtr;
|
||||
|
||||
/**
|
||||
* @ingroup ccnx
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
*/
|
||||
DigestConstPtr
|
||||
getDigest () const { return m_digest; }
|
||||
|
||||
|
||||
/**
|
||||
* @brief Accumulate differences from `this' state to the most current state
|
||||
* @returns Accumulated differences from `this' state to the most current state
|
||||
@@ -84,14 +84,14 @@ public:
|
||||
*/
|
||||
DiffState&
|
||||
operator += (const DiffState &state);
|
||||
|
||||
|
||||
// from State
|
||||
virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
virtual tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
update (NameInfoConstPtr info, const SeqNo &seq);
|
||||
|
||||
virtual bool
|
||||
remove (NameInfoConstPtr info);
|
||||
|
||||
|
||||
private:
|
||||
DiffStatePtr m_next;
|
||||
DigestConstPtr m_digest;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-digest.h"
|
||||
|
||||
+4
-4
@@ -23,8 +23,8 @@
|
||||
#ifndef SYNC_DIGEST_H
|
||||
#define SYNC_DIGEST_H
|
||||
|
||||
#include <boost/exception/all.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "sync-common.h"
|
||||
|
||||
#include <vector>
|
||||
#include "openssl.h"
|
||||
|
||||
@@ -142,8 +142,8 @@ namespace Error {
|
||||
struct DigestCalculationError : virtual boost::exception, virtual std::exception { };
|
||||
}
|
||||
|
||||
typedef boost::shared_ptr<Digest> DigestPtr;
|
||||
typedef boost::shared_ptr<const Digest> DigestConstPtr;
|
||||
typedef shared_ptr<Digest> DigestPtr;
|
||||
typedef shared_ptr<const Digest> DigestConstPtr;
|
||||
|
||||
Digest &
|
||||
Digest::operator << (const std::string &str)
|
||||
|
||||
+3
-3
@@ -17,18 +17,18 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_EVENT_H
|
||||
#define SYNC_EVENT_H
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include "sync-common.h"
|
||||
|
||||
namespace Sync
|
||||
{
|
||||
|
||||
typedef boost::function< void ( ) > Event;
|
||||
typedef function< void ( ) > Event;
|
||||
|
||||
} // Sync
|
||||
|
||||
|
||||
@@ -17,13 +17,10 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-full-leaf.h"
|
||||
#include <boost/ref.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
namespace Sync {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_FULL_LEAF_H
|
||||
@@ -29,7 +29,7 @@ namespace Sync {
|
||||
|
||||
/**
|
||||
* @ingroup sync
|
||||
* @brief SYNC leaf for the full state (with support of Digest calculation)
|
||||
* @brief SYNC leaf for the full state (with support of Digest calculation)
|
||||
*/
|
||||
class FullLeaf : public Leaf
|
||||
{
|
||||
@@ -49,12 +49,12 @@ public:
|
||||
* (including updates of child classes)
|
||||
*/
|
||||
const Digest &
|
||||
getDigest () const { return m_digest; }
|
||||
getDigest () const { return m_digest; }
|
||||
|
||||
// from Leaf
|
||||
virtual void
|
||||
setSeq (const SeqNo &seq);
|
||||
|
||||
|
||||
private:
|
||||
void
|
||||
updateDigest ();
|
||||
@@ -63,8 +63,8 @@ private:
|
||||
Digest m_digest;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<FullLeaf> FullLeafPtr;
|
||||
typedef boost::shared_ptr<const FullLeaf> FullLeafConstPtr;
|
||||
typedef shared_ptr<FullLeaf> FullLeafPtr;
|
||||
typedef shared_ptr<const FullLeaf> FullLeafConstPtr;
|
||||
|
||||
} // Sync
|
||||
|
||||
|
||||
@@ -17,22 +17,15 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-full-state.h"
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include "sync-full-leaf.h"
|
||||
|
||||
using namespace boost;
|
||||
namespace ll = boost::lambda;
|
||||
|
||||
namespace Sync {
|
||||
|
||||
|
||||
@@ -59,7 +52,7 @@ FullState::getDigest ()
|
||||
m_digest = make_shared<Digest> ();
|
||||
if (m_leaves.get<ordered> ().size () > 0)
|
||||
{
|
||||
BOOST_FOREACH (LeafConstPtr leaf, m_leaves.get<ordered> ())
|
||||
for (LeafConstPtr leaf : m_leaves.get<ordered> ())
|
||||
{
|
||||
FullLeafConstPtr fullLeaf = dynamic_pointer_cast<const FullLeaf> (leaf);
|
||||
BOOST_ASSERT (fullLeaf != 0);
|
||||
@@ -78,7 +71,7 @@ FullState::getDigest ()
|
||||
}
|
||||
|
||||
// from State
|
||||
boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
FullState::update (NameInfoConstPtr info, const SeqNo &seq)
|
||||
{
|
||||
m_lastUpdated = ndn::time::system_clock::now();
|
||||
@@ -89,7 +82,7 @@ FullState::update (NameInfoConstPtr info, const SeqNo &seq)
|
||||
LeafContainer::iterator item = m_leaves.find (info);
|
||||
if (item == m_leaves.end ())
|
||||
{
|
||||
m_leaves.insert (make_shared<FullLeaf> (info, cref (seq)));
|
||||
m_leaves.insert (make_shared<FullLeaf> (info, seq));
|
||||
return make_tuple (true, false, SeqNo ());
|
||||
}
|
||||
else
|
||||
@@ -100,8 +93,7 @@ FullState::update (NameInfoConstPtr info, const SeqNo &seq)
|
||||
}
|
||||
|
||||
SeqNo old = (*item)->getSeq ();
|
||||
m_leaves.modify (item,
|
||||
ll::bind (&Leaf::setSeq, *ll::_1, seq));
|
||||
m_leaves.modify (item, [&seq](LeafPtr data){ data->setSeq(seq); });
|
||||
return make_tuple (false, true, old);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_FULL_STATE_H
|
||||
@@ -29,8 +29,8 @@
|
||||
namespace Sync {
|
||||
|
||||
class FullState;
|
||||
typedef boost::shared_ptr<FullState> FullStatePtr;
|
||||
typedef boost::shared_ptr<FullState> FullStateConstPtr;
|
||||
typedef shared_ptr<FullState> FullStatePtr;
|
||||
typedef shared_ptr<FullState> FullStateConstPtr;
|
||||
|
||||
|
||||
/**
|
||||
@@ -61,14 +61,14 @@ public:
|
||||
*/
|
||||
DigestConstPtr
|
||||
getDigest ();
|
||||
|
||||
|
||||
// from State
|
||||
virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
virtual tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
update (NameInfoConstPtr info, const SeqNo &seq);
|
||||
|
||||
virtual bool
|
||||
remove (NameInfoConstPtr info);
|
||||
|
||||
|
||||
private:
|
||||
ndn::time::system_clock::TimePoint m_lastUpdated; ///< @brief Time when state was updated last time
|
||||
DigestPtr m_digest;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_INTEREST_CONTAINER_H
|
||||
@@ -51,14 +51,14 @@ struct Interest
|
||||
, m_unknown (unknown)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DigestConstPtr m_digest;
|
||||
std::string m_name;
|
||||
ndn::time::system_clock::TimePoint m_time;
|
||||
bool m_unknown;
|
||||
};
|
||||
|
||||
/// @cond include_hidden
|
||||
/// @cond include_hidden
|
||||
struct named { };
|
||||
struct hashed;
|
||||
struct timed;
|
||||
@@ -76,7 +76,7 @@ struct InterestContainer : public mi::multi_index_container<
|
||||
BOOST_MULTI_INDEX_MEMBER(Interest, std::string, m_name)
|
||||
>
|
||||
,
|
||||
|
||||
|
||||
mi::hashed_non_unique<
|
||||
mi::tag<hashed>,
|
||||
BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
|
||||
@@ -84,7 +84,7 @@ struct InterestContainer : public mi::multi_index_container<
|
||||
DigestPtrEqual
|
||||
>
|
||||
,
|
||||
|
||||
|
||||
mi::ordered_non_unique<
|
||||
mi::tag<timed>,
|
||||
BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::system_clock::TimePoint, m_time)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_INTEREST_TABLE_H
|
||||
@@ -36,7 +36,7 @@ namespace Sync {
|
||||
/**
|
||||
* \ingroup sync
|
||||
* @brief A table to keep unanswered Sync Interest
|
||||
* all access operation to the table should grab the
|
||||
* all access operation to the table should grab the
|
||||
* mutex first
|
||||
*/
|
||||
class SyncInterestTable
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
*/
|
||||
bool
|
||||
remove (const std::string &name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief pop a non-expired Interest from PIT
|
||||
*/
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-leaf.h"
|
||||
|
||||
+5
-5
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_LEAF_H
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
*/
|
||||
Leaf (NameInfoConstPtr info, const SeqNo &seq);
|
||||
virtual ~Leaf ();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get name of the leaf
|
||||
*/
|
||||
@@ -63,14 +63,14 @@ public:
|
||||
*/
|
||||
virtual void
|
||||
setSeq (const SeqNo &seq);
|
||||
|
||||
|
||||
private:
|
||||
NameInfoConstPtr m_info;
|
||||
SeqNo m_seq;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<Leaf> LeafPtr;
|
||||
typedef boost::shared_ptr<const Leaf> LeafConstPtr;
|
||||
typedef shared_ptr<Leaf> LeafPtr;
|
||||
typedef shared_ptr<const Leaf> LeafConstPtr;
|
||||
|
||||
inline std::ostream &
|
||||
operator << (std::ostream &os, const Leaf &leaf)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-logging.h"
|
||||
@@ -43,7 +43,7 @@ INIT_LOGGERS ()
|
||||
static bool configured = false;
|
||||
|
||||
if (configured) return;
|
||||
|
||||
|
||||
if (access ("log4cxx.properties", R_OK)==0)
|
||||
PropertyConfigurator::configureAndWatch ("log4cxx.properties");
|
||||
else
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_LOG_H
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <log4cxx/logger.h>
|
||||
|
||||
#define INIT_LOGGER(name) \
|
||||
static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name);
|
||||
static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name)
|
||||
|
||||
#define _LOG_DEBUG(x) \
|
||||
LOG4CXX_DEBUG(staticModuleLogger, x);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_LOGIC_EVENT_CONTAINER_H
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "sync-event.h"
|
||||
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
|
||||
#include <boost/multi_index_container.hpp>
|
||||
@@ -49,7 +48,7 @@ struct LogicEvent
|
||||
, event (_event)
|
||||
, lbl (_label)
|
||||
{ }
|
||||
|
||||
|
||||
boost::system_time time;
|
||||
Event event;
|
||||
uint32_t lbl;
|
||||
|
||||
+21
-12
@@ -29,10 +29,19 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace ndn;
|
||||
|
||||
using ndn::Data;
|
||||
using ndn::EventId;
|
||||
using ndn::KeyChain;
|
||||
using ndn::Face;
|
||||
using ndn::Name;
|
||||
using ndn::OnDataValidated;
|
||||
using ndn::OnDataValidationFailed;
|
||||
using ndn::Validator;
|
||||
|
||||
INIT_LOGGER ("SyncLogic");
|
||||
|
||||
@@ -138,7 +147,7 @@ SyncLogic::~SyncLogic ()
|
||||
* Normal name: .../<hash>
|
||||
* Recovery name: .../recovery/<hash>
|
||||
*/
|
||||
boost::tuple<DigestConstPtr, std::string>
|
||||
tuple<DigestConstPtr, std::string>
|
||||
SyncLogic::convertNameToDigestAndType (const Name &name)
|
||||
{
|
||||
BOOST_ASSERT (m_syncPrefix.isPrefixOf(name));
|
||||
@@ -157,11 +166,11 @@ SyncLogic::convertNameToDigestAndType (const Name &name)
|
||||
|
||||
_LOG_DEBUG_ID (hash << ", " << interestType);
|
||||
|
||||
DigestPtr digest = boost::make_shared<Digest> ();
|
||||
DigestPtr digest = make_shared<Digest> ();
|
||||
istringstream is (hash);
|
||||
is >> *digest;
|
||||
|
||||
return make_tuple (digest, interestType);
|
||||
return make_tuple(digest, interestType);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -332,7 +341,7 @@ void
|
||||
SyncLogic::processSyncData (const Name &name, DigestConstPtr digest,
|
||||
const char *wireData, size_t len)
|
||||
{
|
||||
DiffStatePtr diffLog = boost::make_shared<DiffState> ();
|
||||
DiffStatePtr diffLog = make_shared<DiffState> ();
|
||||
bool ownInterestSatisfied = false;
|
||||
|
||||
try
|
||||
@@ -354,7 +363,7 @@ SyncLogic::processSyncData (const Name &name, DigestConstPtr digest,
|
||||
vector<MissingDataInfo> v;
|
||||
BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
|
||||
{
|
||||
DiffLeafConstPtr diffLeaf = boost::dynamic_pointer_cast<const DiffLeaf> (leaf);
|
||||
DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
|
||||
BOOST_ASSERT (diffLeaf != 0);
|
||||
|
||||
NameInfoConstPtr info = diffLeaf->getInfo();
|
||||
@@ -366,7 +375,7 @@ SyncLogic::processSyncData (const Name &name, DigestConstPtr digest,
|
||||
bool updated = false;
|
||||
SeqNo oldSeq;
|
||||
{
|
||||
boost::tie (inserted, updated, oldSeq) = m_state->update (info, seq);
|
||||
tie (inserted, updated, oldSeq) = m_state->update (info, seq);
|
||||
}
|
||||
|
||||
if (inserted || updated)
|
||||
@@ -484,7 +493,7 @@ SyncLogic::processSyncRecoveryInterest (const Name &name, DigestConstPtr digest)
|
||||
void
|
||||
SyncLogic::satisfyPendingSyncInterests (DiffStateConstPtr diffLog)
|
||||
{
|
||||
DiffStatePtr fullStateLog = boost::make_shared<DiffState> ();
|
||||
DiffStatePtr fullStateLog = make_shared<DiffState> ();
|
||||
{
|
||||
BOOST_FOREACH (LeafConstPtr leaf, m_state->getLeaves ()/*.get<timed> ()*/)
|
||||
{
|
||||
@@ -549,7 +558,7 @@ SyncLogic::addLocalNames (const Name &prefix, uint64_t session, uint64_t seq)
|
||||
|
||||
_LOG_DEBUG_ID ("addLocalNames (): new state " << *m_state->getDigest ());
|
||||
|
||||
diff = boost::make_shared<DiffState>();
|
||||
diff = make_shared<DiffState>();
|
||||
diff->update(info, seqN);
|
||||
insertToDiffLog (diff);
|
||||
}
|
||||
@@ -578,7 +587,7 @@ SyncLogic::remove(const Name &prefix)
|
||||
}
|
||||
m_state->update (forwarderInfo, seqNo);
|
||||
|
||||
diff = boost::make_shared<DiffState>();
|
||||
diff = make_shared<DiffState>();
|
||||
diff->remove(info);
|
||||
diff->update(forwarderInfo, seqNo);
|
||||
|
||||
@@ -714,7 +723,7 @@ SyncLogic::getNumberOfBranches () const
|
||||
void
|
||||
SyncLogic::printState () const
|
||||
{
|
||||
BOOST_FOREACH (const boost::shared_ptr<Sync::Leaf> leaf, m_state->getLeaves ())
|
||||
BOOST_FOREACH (const shared_ptr<Sync::Leaf> leaf, m_state->getLeaves ())
|
||||
{
|
||||
std::cout << *leaf << std::endl;
|
||||
}
|
||||
@@ -725,7 +734,7 @@ SyncLogic::getBranchPrefixes() const
|
||||
{
|
||||
std::map<std::string, bool> m;
|
||||
|
||||
BOOST_FOREACH (const boost::shared_ptr<Sync::Leaf> leaf, m_state->getLeaves ())
|
||||
BOOST_FOREACH (const shared_ptr<Sync::Leaf> leaf, m_state->getLeaves ())
|
||||
{
|
||||
std::string prefix = leaf->getInfo()->toString();
|
||||
// do not return forwarder prefix
|
||||
|
||||
+7
-7
@@ -63,9 +63,9 @@ struct MissingDataInfo {
|
||||
class SyncLogic
|
||||
{
|
||||
public:
|
||||
typedef boost::function< void (const std::vector<MissingDataInfo> & ) > LogicUpdateCallback;
|
||||
typedef boost::function< void (const std::string &/*prefix*/ ) > LogicRemoveCallback;
|
||||
typedef boost::function< void (const std::string &)> LogicPerBranchCallback;
|
||||
typedef function< void (const std::vector<MissingDataInfo> & ) > LogicUpdateCallback;
|
||||
typedef function< void (const std::string &/*prefix*/ ) > LogicRemoveCallback;
|
||||
typedef function< void (const std::string &)> LogicPerBranchCallback;
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
@@ -156,7 +156,7 @@ private:
|
||||
void
|
||||
satisfyPendingSyncInterests (DiffStateConstPtr diff);
|
||||
|
||||
boost::tuple<DigestConstPtr, std::string>
|
||||
tuple<DigestConstPtr, std::string>
|
||||
convertNameToDigestAndType (const ndn::Name &name);
|
||||
|
||||
void
|
||||
@@ -189,9 +189,9 @@ private:
|
||||
LogicRemoveCallback m_onRemove;
|
||||
LogicPerBranchCallback m_onUpdateBranch;
|
||||
bool m_perBranch;
|
||||
ndn::ptr_lib::shared_ptr<ndn::Validator> m_validator;
|
||||
ndn::ptr_lib::shared_ptr<ndn::KeyChain> m_keyChain;
|
||||
ndn::ptr_lib::shared_ptr<ndn::Face> m_face;
|
||||
std::shared_ptr<ndn::Validator> m_validator;
|
||||
std::shared_ptr<ndn::KeyChain> m_keyChain;
|
||||
std::shared_ptr<ndn::Face> m_face;
|
||||
const ndn::RegisteredPrefixId* m_syncRegisteredPrefixId;
|
||||
|
||||
ndn::Scheduler m_scheduler;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-name-info.h"
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_NAME_INFO_H
|
||||
#define SYNC_NAME_INFO_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include "sync-common.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "sync-digest.h"
|
||||
@@ -38,8 +38,8 @@ namespace Sync {
|
||||
class NameInfo
|
||||
{
|
||||
private:
|
||||
typedef boost::weak_ptr<const NameInfo> const_weak_ptr;
|
||||
|
||||
typedef weak_ptr<const NameInfo> const_weak_ptr;
|
||||
|
||||
public:
|
||||
virtual ~NameInfo () { };
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
*/
|
||||
virtual std::string
|
||||
toString () const = 0;
|
||||
|
||||
|
||||
protected:
|
||||
// actual stuff
|
||||
size_t m_id; ///< @brief Identifies NameInfo throughout the library (for hash container, doesn't need to be strictly unique)
|
||||
@@ -87,8 +87,8 @@ protected:
|
||||
static NameMap m_names;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<NameInfo> NameInfoPtr;
|
||||
typedef boost::shared_ptr<const NameInfo> NameInfoConstPtr;
|
||||
typedef shared_ptr<NameInfo> NameInfoPtr;
|
||||
typedef shared_ptr<const NameInfo> NameInfoConstPtr;
|
||||
|
||||
inline std::ostream &
|
||||
operator << (std::ostream &os, const NameInfo &info)
|
||||
|
||||
@@ -17,13 +17,10 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-seq-no.h"
|
||||
#include <boost/make_shared.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
namespace Sync {
|
||||
|
||||
|
||||
+5
-5
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Yingdi Yu <yingdi@cs.ucla.edu>
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
, m_seq (0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Copy constructor
|
||||
* @param seq sequence number object to copy from
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
{
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get session id
|
||||
*/
|
||||
@@ -164,10 +164,10 @@ public:
|
||||
void
|
||||
setSeq(uint64_t seq)
|
||||
{ m_seq = seq; }
|
||||
|
||||
|
||||
private:
|
||||
bool m_valid;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Session ID (e.g., after crash, application will choose new session ID.
|
||||
*
|
||||
|
||||
+10
-1
@@ -20,10 +20,19 @@
|
||||
|
||||
#include "sync-socket.h"
|
||||
#include "sync-logging.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace ndn;
|
||||
|
||||
using ndn::Data;
|
||||
using ndn::Face;
|
||||
using ndn::KeyChain;
|
||||
using ndn::Name;
|
||||
using ndn::OnDataValidated;
|
||||
using ndn::OnDataValidationFailed;
|
||||
using ndn::Validator;
|
||||
|
||||
INIT_LOGGER ("SyncSocket");
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#ifndef _SYNC_SOCKET_H
|
||||
#define _SYNC_SOCKET_H
|
||||
|
||||
#include "sync-common.h"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/security/validator.hpp>
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_STATE_LEAF_CONTAINER
|
||||
@@ -66,7 +66,7 @@ struct NameInfoCompare : public std::unary_function<NameInfo, std::size_t>
|
||||
}
|
||||
};
|
||||
|
||||
/// @cond include_hidden
|
||||
/// @cond include_hidden
|
||||
struct hashed { };
|
||||
struct ordered { };
|
||||
/// @endcond
|
||||
@@ -85,7 +85,7 @@ struct LeafContainer : public mi::multi_index_container<
|
||||
NameInfoHash,
|
||||
NameInfoEqual
|
||||
>,
|
||||
|
||||
|
||||
mi::ordered_unique<
|
||||
mi::tag<ordered>,
|
||||
mi::const_mem_fun<Leaf, NameInfoConstPtr, &Leaf::getInfo>,
|
||||
|
||||
+8
-11
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-state.h"
|
||||
@@ -26,16 +26,13 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
// using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
typedef error_info<struct tag_errmsg, std::string> info_str;
|
||||
typedef boost::error_info<struct tag_errmsg, std::string> info_str;
|
||||
|
||||
using namespace Sync::Error;
|
||||
using boost::lexical_cast;
|
||||
|
||||
namespace Sync {
|
||||
|
||||
@@ -44,7 +41,7 @@ std::ostream &
|
||||
operator << (std::ostream &os, const State &state)
|
||||
{
|
||||
os << "<state>"; DEBUG_ENDL;
|
||||
|
||||
|
||||
BOOST_FOREACH (shared_ptr<const Leaf> leaf, state.getLeaves ().get<ordered> ())
|
||||
{
|
||||
shared_ptr<const DiffLeaf> diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
|
||||
@@ -106,7 +103,7 @@ operator >> (std::istream &in, State &state)
|
||||
|
||||
if (doc.RootElement() == 0)
|
||||
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("Empty XML"));
|
||||
|
||||
|
||||
for (TiXmlElement *iterator = doc.RootElement()->FirstChildElement ("item");
|
||||
iterator != 0;
|
||||
iterator = iterator->NextSiblingElement("item"))
|
||||
@@ -114,15 +111,15 @@ operator >> (std::istream &in, State &state)
|
||||
TiXmlElement *name = iterator->FirstChildElement ("name");
|
||||
if (name == 0 || name->GetText() == 0)
|
||||
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("<name> element is missing"));
|
||||
|
||||
|
||||
NameInfoConstPtr info = StdNameInfo::FindOrCreate (name->GetText());
|
||||
|
||||
|
||||
if (iterator->Attribute("action") == 0 || strcmp(iterator->Attribute("action"), "update") == 0)
|
||||
{
|
||||
TiXmlElement *seq = iterator->FirstChildElement ("seq");
|
||||
if (seq == 0)
|
||||
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("<seq> element is missing"));
|
||||
|
||||
|
||||
TiXmlElement *session = seq->FirstChildElement ("session");
|
||||
TiXmlElement *seqno = seq->FirstChildElement ("seqno");
|
||||
|
||||
|
||||
+9
-10
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_STATE_H
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "sync-state-leaf-container.h"
|
||||
#include <boost/exception/all.hpp>
|
||||
#include "boost/tuple/tuple.hpp"
|
||||
#include "sync-state.pb.h"
|
||||
|
||||
/**
|
||||
@@ -38,16 +37,16 @@ namespace Sync {
|
||||
/**
|
||||
* \ingroup sync
|
||||
* @brief this prefix will be used for the dummy node which increases its sequence number whenever
|
||||
* a remove operation happens; this is to prevent the reversion of root digest when we prune
|
||||
* a remove operation happens; this is to prevent the reversion of root digest when we prune
|
||||
* a branch, i.e. help the root digest to be forward only
|
||||
* No corresponding data msg would be published and no attempt would be made to retrieve the
|
||||
* No corresponding data msg would be published and no attempt would be made to retrieve the
|
||||
* data msg
|
||||
*/
|
||||
const std::string forwarderPrefix = "/d0n0t18ak/t0ps8cr8t";
|
||||
|
||||
class State;
|
||||
typedef boost::shared_ptr<State> StatePtr;
|
||||
typedef boost::shared_ptr<State> StateConstPtr;
|
||||
typedef shared_ptr<State> StatePtr;
|
||||
typedef shared_ptr<State> StateConstPtr;
|
||||
|
||||
/**
|
||||
* \ingroup sync
|
||||
@@ -57,14 +56,14 @@ class State
|
||||
{
|
||||
public:
|
||||
virtual ~State () { };
|
||||
|
||||
|
||||
/**
|
||||
* @brief Add or update leaf to the state tree
|
||||
*
|
||||
* @param info name of the leaf
|
||||
* @param seq sequence number of the leaf
|
||||
*/
|
||||
virtual boost::tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
virtual tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
|
||||
update (NameInfoConstPtr info, const SeqNo &seq) = 0;
|
||||
|
||||
/**
|
||||
@@ -78,9 +77,9 @@ public:
|
||||
* @brief Get state leaves
|
||||
*/
|
||||
const LeafContainer &
|
||||
getLeaves () const
|
||||
getLeaves () const
|
||||
{ return m_leaves; }
|
||||
|
||||
|
||||
protected:
|
||||
LeafContainer m_leaves;
|
||||
};
|
||||
|
||||
@@ -17,14 +17,11 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#include "sync-std-name-info.h"
|
||||
|
||||
// using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
namespace Sync {
|
||||
|
||||
|
||||
@@ -32,9 +29,9 @@ NameInfoConstPtr
|
||||
StdNameInfo::FindOrCreate (const std::string &key)
|
||||
{
|
||||
// std::cout << "FindOrCreate: " << m_names.size () << "\n";
|
||||
|
||||
|
||||
NameInfoConstPtr ret;
|
||||
|
||||
|
||||
NameMap::iterator item = m_names.find (key);
|
||||
if (item != m_names.end ())
|
||||
{
|
||||
@@ -47,7 +44,7 @@ StdNameInfo::FindOrCreate (const std::string &key)
|
||||
weak_ptr<const NameInfo> value (ret);
|
||||
std::pair<NameMap::iterator,bool> inserted =
|
||||
m_names.insert (make_pair (key, value));
|
||||
|
||||
|
||||
BOOST_ASSERT (inserted.second); // previous call has to insert value
|
||||
item = inserted.first;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*
|
||||
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
|
||||
* Chaoyi Bian <bcy@pku.edu.cn>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
|
||||
*/
|
||||
|
||||
#ifndef SYNC_STD_NAME_INFO_H
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
* @brief Destructor which will clean up m_names structure
|
||||
*/
|
||||
virtual ~StdNameInfo ();
|
||||
|
||||
|
||||
// from NameInfo
|
||||
virtual bool
|
||||
operator == (const NameInfo &info) const;
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
toString () const;
|
||||
|
||||
private:
|
||||
// implementing a singleton pattern.
|
||||
// implementing a singleton pattern.
|
||||
/**
|
||||
* @brief Disabled default constructor. NameInfo object should be created through FindOrCreate static call.
|
||||
*/
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
StdNameInfo () {}
|
||||
StdNameInfo& operator = (const StdNameInfo &info) { (void)info; return *this; }
|
||||
StdNameInfo (const std::string &name);
|
||||
|
||||
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
+41
-34
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,17 +17,16 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include <algorithm>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
|
||||
#include "adjacent.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "common.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("AdjacencyList");
|
||||
@@ -61,15 +61,18 @@ AdjacencyList::addAdjacents(AdjacencyList& adl)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, int32_t s)
|
||||
bool
|
||||
AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = find(adjName);
|
||||
|
||||
if (it == m_adjList.end()) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
it->setStatus(s);
|
||||
return true;
|
||||
}
|
||||
(*it).setStatus(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Adjacent
|
||||
@@ -163,22 +166,25 @@ AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
|
||||
return (*it).getInterestTimedOutNo();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Adjacent::Status
|
||||
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = find(neighbor);
|
||||
|
||||
if (it == m_adjList.end()) {
|
||||
return -1;
|
||||
return Adjacent::STATUS_UNKNOWN;
|
||||
}
|
||||
else {
|
||||
return it->getStatus();
|
||||
}
|
||||
return (*it).getStatus();
|
||||
}
|
||||
|
||||
void
|
||||
AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, int32_t status)
|
||||
AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status)
|
||||
{
|
||||
std::list<Adjacent>::iterator it = find(neighbor);
|
||||
if (it != m_adjList.end()) {
|
||||
(*it).setStatus(status);
|
||||
it->setStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,34 +195,35 @@ AdjacencyList::getAdjList()
|
||||
}
|
||||
|
||||
bool
|
||||
AdjacencyList::isAdjLsaBuildable(Nlsr& pnlsr)
|
||||
AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
||||
{
|
||||
uint32_t nbrCount = 0;
|
||||
for (std::list<Adjacent>::iterator it = m_adjList.begin();
|
||||
it != m_adjList.end() ; it++) {
|
||||
if (((*it).getStatus() == 1)) {
|
||||
nbrCount++;
|
||||
uint32_t nTimedOutNeighbors = 0;
|
||||
|
||||
for (const Adjacent& adjacency : m_adjList) {
|
||||
|
||||
if (adjacency.getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if ((*it).getInterestTimedOutNo() >=
|
||||
pnlsr.getConfParameter().getInterestRetryNumber()) {
|
||||
nbrCount++;
|
||||
}
|
||||
else if (adjacency.getInterestTimedOutNo() >= interestRetryNo) {
|
||||
nTimedOutNeighbors++;
|
||||
}
|
||||
}
|
||||
if (nbrCount == m_adjList.size()) {
|
||||
|
||||
if (nTimedOutNeighbors == m_adjList.size()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
AdjacencyList::getNumOfActiveNeighbor()
|
||||
{
|
||||
int32_t actNbrCount = 0;
|
||||
for (std::list<Adjacent>::iterator it = m_adjList.begin();
|
||||
it != m_adjList.end(); it++) {
|
||||
if (((*it).getStatus() == 1)) {
|
||||
for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
|
||||
|
||||
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
actNbrCount++;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-13
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,10 +17,8 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_ADJACENCY_LIST_HPP
|
||||
#define NLSR_ADJACENCY_LIST_HPP
|
||||
|
||||
@@ -30,20 +29,21 @@
|
||||
#include "adjacent.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
|
||||
class AdjacencyList
|
||||
{
|
||||
|
||||
public:
|
||||
typedef std::list<Adjacent>::const_iterator const_iterator;
|
||||
typedef std::list<Adjacent>::iterator iterator;
|
||||
|
||||
AdjacencyList();
|
||||
~AdjacencyList();
|
||||
|
||||
int32_t
|
||||
insert(Adjacent& adjacent);
|
||||
|
||||
int32_t
|
||||
updateAdjacentStatus(const ndn::Name& adjName, int32_t s);
|
||||
bool
|
||||
updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s);
|
||||
|
||||
int32_t
|
||||
updateAdjacentLinkCost(const ndn::Name& adjName, double lc);
|
||||
@@ -60,11 +60,11 @@ public:
|
||||
int32_t
|
||||
getTimedOutInterestCount(const ndn::Name& neighbor);
|
||||
|
||||
uint32_t
|
||||
Adjacent::Status
|
||||
getStatusOfNeighbor(const ndn::Name& neighbor);
|
||||
|
||||
void
|
||||
setStatusOfNeighbor(const ndn::Name& neighbor, int32_t status);
|
||||
setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status);
|
||||
|
||||
void
|
||||
setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
addAdjacents(AdjacencyList& adl);
|
||||
|
||||
bool
|
||||
isAdjLsaBuildable(Nlsr& pnlsr);
|
||||
isAdjLsaBuildable(const uint32_t interestRetryNo) const;
|
||||
|
||||
int32_t
|
||||
getNumOfActiveNeighbor();
|
||||
@@ -110,8 +110,21 @@ public:
|
||||
void
|
||||
writeLog();
|
||||
|
||||
public:
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return m_adjList.begin();
|
||||
}
|
||||
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return m_adjList.end();
|
||||
}
|
||||
|
||||
private:
|
||||
std::list<Adjacent>::iterator
|
||||
iterator
|
||||
find(const ndn::Name& adjName);
|
||||
|
||||
private:
|
||||
|
||||
+3
-3
@@ -41,7 +41,7 @@ Adjacent::Adjacent()
|
||||
: m_name()
|
||||
, m_connectingFaceUri()
|
||||
, m_linkCost(DEFAULT_LINK_COST)
|
||||
, m_status(ADJACENT_STATUS_INACTIVE)
|
||||
, m_status(STATUS_INACTIVE)
|
||||
, m_interestTimedOutNo(0)
|
||||
, m_faceId(0)
|
||||
{
|
||||
@@ -51,14 +51,14 @@ Adjacent::Adjacent(const ndn::Name& an)
|
||||
: m_name(an)
|
||||
, m_connectingFaceUri()
|
||||
, m_linkCost(DEFAULT_LINK_COST)
|
||||
, m_status(ADJACENT_STATUS_INACTIVE)
|
||||
, m_status(STATUS_INACTIVE)
|
||||
, m_interestTimedOutNo(0)
|
||||
, m_faceId(0)
|
||||
{
|
||||
}
|
||||
|
||||
Adjacent::Adjacent(const ndn::Name& an, const std::string& cfu, double lc,
|
||||
uint32_t s, uint32_t iton, uint64_t faceId)
|
||||
Status s, uint32_t iton, uint64_t faceId)
|
||||
: m_name(an)
|
||||
, m_connectingFaceUri(cfu)
|
||||
, m_linkCost(lc)
|
||||
|
||||
+11
-9
@@ -30,21 +30,23 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
enum {
|
||||
ADJACENT_STATUS_INACTIVE = 0,
|
||||
ADJACENT_STATUS_ACTIVE = 1
|
||||
};
|
||||
|
||||
class Adjacent
|
||||
{
|
||||
|
||||
public:
|
||||
enum Status
|
||||
{
|
||||
STATUS_UNKNOWN = -1,
|
||||
STATUS_INACTIVE = 0,
|
||||
STATUS_ACTIVE = 1
|
||||
};
|
||||
|
||||
Adjacent();
|
||||
|
||||
Adjacent(const ndn::Name& an);
|
||||
|
||||
Adjacent(const ndn::Name& an, const std::string& cfu, double lc,
|
||||
uint32_t s, uint32_t iton, uint64_t faceId);
|
||||
Status s, uint32_t iton, uint64_t faceId);
|
||||
|
||||
const ndn::Name&
|
||||
getName() const
|
||||
@@ -83,14 +85,14 @@ public:
|
||||
m_linkCost = lc;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Status
|
||||
getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
void
|
||||
setStatus(uint32_t s)
|
||||
setStatus(Status s)
|
||||
{
|
||||
m_status = s;
|
||||
}
|
||||
@@ -150,7 +152,7 @@ private:
|
||||
ndn::Name m_name;
|
||||
std::string m_connectingFaceUri;
|
||||
double m_linkCost;
|
||||
uint32_t m_status;
|
||||
Status m_status;
|
||||
uint32_t m_interestTimedOutNo;
|
||||
uint64_t m_faceId;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_COMMON_HPP
|
||||
#define NLSR_COMMON_HPP
|
||||
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
using std::bind;
|
||||
using std::make_shared;
|
||||
using std::shared_ptr;
|
||||
using std::function;
|
||||
|
||||
}
|
||||
|
||||
#endif // NLSR_COMMON_HPP
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,15 +17,17 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include "sync-logic-handler.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
#include "lsa.hpp"
|
||||
|
||||
#include "common.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "sequencing-manager.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
@@ -33,115 +36,270 @@ INIT_LOGGER("SyncLogicHandler");
|
||||
using namespace ndn;
|
||||
using namespace std;
|
||||
|
||||
void
|
||||
SyncLogicHandler::createSyncSocket(Nlsr& pnlsr)
|
||||
class SyncUpdate
|
||||
{
|
||||
_LOG_DEBUG("Creating Sync socket. Sync Prefix: " << m_syncPrefix);
|
||||
m_syncSocket = ndn::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator,
|
||||
m_syncFace,
|
||||
ndn::bind(&SyncLogicHandler::nsyncUpdateCallBack,
|
||||
this, _1, _2, ndn::ref(pnlsr)),
|
||||
ndn::bind(&SyncLogicHandler::nsyncRemoveCallBack,
|
||||
this, _1, ndn::ref(pnlsr)));
|
||||
}
|
||||
public:
|
||||
class Error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
Error(const std::string& what)
|
||||
: std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
SyncLogicHandler::nsyncUpdateCallBack(const vector<Sync::MissingDataInfo>& v,
|
||||
Sync::SyncSocket* socket, Nlsr& pnlsr)
|
||||
{
|
||||
_LOG_DEBUG("nsyncUpdateCallBack called ....");
|
||||
int32_t n = v.size();
|
||||
for (int32_t i = 0; i < n; i++){
|
||||
_LOG_DEBUG("Update Name: " << v[i].prefix << " Seq: " << v[i].high.getSeq());
|
||||
processUpdateFromSync(v[i].prefix, v[i].high.getSeq(), pnlsr);
|
||||
public:
|
||||
SyncUpdate(const ndn::Name& name, uint64_t seqNo)
|
||||
: m_name(name)
|
||||
, m_seqManager(seqNo)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::nsyncRemoveCallBack(const string& prefix, Nlsr& pnlsr)
|
||||
const ndn::Name&
|
||||
getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const ndn::Name
|
||||
getOriginRouter() const
|
||||
{
|
||||
int32_t nlsrPosition = util::getNameComponentPosition(m_name, NLSR_COMPONENT);
|
||||
int32_t lsaPosition = util::getNameComponentPosition(m_name, LSA_COMPONENT);
|
||||
|
||||
if (nlsrPosition < 0 || lsaPosition < 0) {
|
||||
throw Error("Cannot parse update name because expected components are missing");
|
||||
}
|
||||
|
||||
ndn::Name networkName = m_name.getSubName(0, nlsrPosition);
|
||||
ndn::Name routerName = m_name.getSubName(lsaPosition + 1);
|
||||
|
||||
ndn::Name originRouter = networkName;
|
||||
originRouter.append(routerName);
|
||||
|
||||
return originRouter;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getNameLsaSeqNo() const
|
||||
{
|
||||
return m_seqManager.getNameLsaSeq();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getAdjLsaSeqNo() const
|
||||
{
|
||||
return m_seqManager.getAdjLsaSeq();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getCorLsaSeqNo() const
|
||||
{
|
||||
return m_seqManager.getCorLsaSeq();
|
||||
}
|
||||
|
||||
const SequencingManager&
|
||||
getSequencingManager() const
|
||||
{
|
||||
return m_seqManager;
|
||||
}
|
||||
|
||||
private:
|
||||
const ndn::Name m_name;
|
||||
SequencingManager m_seqManager;
|
||||
|
||||
static const std::string NLSR_COMPONENT;
|
||||
static const std::string LSA_COMPONENT;
|
||||
};
|
||||
|
||||
const std::string SyncUpdate::NLSR_COMPONENT = "NLSR";
|
||||
const std::string SyncUpdate::LSA_COMPONENT = "LSA";
|
||||
|
||||
template<class T>
|
||||
class NullDeleter
|
||||
{
|
||||
_LOG_DEBUG("nsyncRemoveCallBack called ....");
|
||||
}
|
||||
public:
|
||||
void
|
||||
operator()(T*)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
SyncLogicHandler::removeRouterFromSyncing(const ndn::Name& routerPrefix)
|
||||
SyncLogicHandler::SyncLogicHandler(ndn::Face& face,
|
||||
Lsdb& lsdb, ConfParameter& conf,
|
||||
SequencingManager& seqManager)
|
||||
: m_validator(new ndn::ValidatorNull())
|
||||
, m_syncFace(face)
|
||||
, m_lsdb(lsdb)
|
||||
, m_confParam(conf)
|
||||
, m_sequencingManager(seqManager)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::processUpdateFromSync(const ndn::Name& updateName,
|
||||
uint64_t seqNo, Nlsr& pnlsr)
|
||||
SyncLogicHandler::createSyncSocket(const ndn::Name& syncPrefix)
|
||||
{
|
||||
string chkString("LSA");
|
||||
int32_t lasPosition = util::getNameComponentPosition(updateName, chkString);
|
||||
if (lasPosition >= 0) {
|
||||
ndn::Name routerName = updateName.getSubName(lasPosition + 1);
|
||||
processRoutingUpdateFromSync(routerName, seqNo, pnlsr);
|
||||
if (m_syncSocket != nullptr) {
|
||||
_LOG_WARN("Trying to create Sync socket, but Sync socket already exists");
|
||||
return;
|
||||
}
|
||||
|
||||
m_syncPrefix = syncPrefix;
|
||||
|
||||
// Build LSA sync update prefix
|
||||
buildUpdatePrefix();
|
||||
|
||||
_LOG_DEBUG("Creating Sync socket. Sync Prefix: " << m_syncPrefix);
|
||||
|
||||
// The face's lifetime is managed in main.cpp; SyncSocket should not manage the memory
|
||||
// of the object
|
||||
ndn::shared_ptr<ndn::Face> facePtr(&m_syncFace, NullDeleter<ndn::Face>());
|
||||
|
||||
m_syncSocket = ndn::make_shared<Sync::SyncSocket>(m_syncPrefix, m_validator, facePtr,
|
||||
ndn::bind(&SyncLogicHandler::onNsyncUpdate,
|
||||
this, _1, _2),
|
||||
ndn::bind(&SyncLogicHandler::onNsyncRemoval,
|
||||
this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::processRoutingUpdateFromSync(const ndn::Name& routerName,
|
||||
uint64_t seqNo, Nlsr& pnlsr)
|
||||
SyncLogicHandler::onNsyncUpdate(const vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket)
|
||||
{
|
||||
ndn::Name rName = routerName;
|
||||
if (routerName != pnlsr.getConfParameter().getRouterPrefix()) {
|
||||
SequencingManager sm(seqNo);
|
||||
sm.writeLog();
|
||||
_LOG_DEBUG(routerName);
|
||||
try {
|
||||
if (pnlsr.getLsdb().isNameLsaNew(rName.append("name"), sm.getNameLsaSeq())) {
|
||||
_LOG_DEBUG("Updated Name LSA. Need to fetch it");
|
||||
ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
|
||||
interestName.append(routerName);
|
||||
interestName.append("name");
|
||||
interestName.appendNumber(sm.getNameLsaSeq());
|
||||
pnlsr.getLsdb().expressInterest(interestName, 0);
|
||||
}
|
||||
if (pnlsr.getLsdb().isAdjLsaNew(rName.append("adjacency"), sm.getAdjLsaSeq())) {
|
||||
_LOG_DEBUG("Updated Adj LSA. Need to fetch it");
|
||||
ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
|
||||
interestName.append(routerName);
|
||||
interestName.append("adjacency");
|
||||
interestName.appendNumber(sm.getAdjLsaSeq());
|
||||
pnlsr.getLsdb().expressInterest(interestName, 0);
|
||||
}
|
||||
if (pnlsr.getLsdb().isCoordinateLsaNew(rName.append("coordinate"),
|
||||
sm.getCorLsaSeq())) {
|
||||
_LOG_DEBUG("Updated Cor LSA. Need to fetch it");
|
||||
ndn::Name interestName(pnlsr.getConfParameter().getLsaPrefix());
|
||||
interestName.append(routerName);
|
||||
interestName.append("coordinate");
|
||||
interestName.appendNumber(sm.getCorLsaSeq());
|
||||
pnlsr.getLsdb().expressInterest(interestName, 0);
|
||||
}
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
_LOG_DEBUG("Received Nsync update event");
|
||||
|
||||
for (size_t i = 0; i < v.size(); i++){
|
||||
_LOG_DEBUG("Update Name: " << v[i].prefix << " Seq no: " << v[i].high.getSeq());
|
||||
|
||||
SyncUpdate update(v[i].prefix, v[i].high.getSeq());
|
||||
|
||||
processUpdateFromSync(update);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::publishRoutingUpdate(SequencingManager& sm,
|
||||
const ndn::Name& updatePrefix)
|
||||
SyncLogicHandler::onNsyncRemoval(const string& prefix)
|
||||
{
|
||||
sm.writeSeqNoToFile();
|
||||
publishSyncUpdate(updatePrefix, sm.getCombinedSeqNo());
|
||||
_LOG_DEBUG("Received Nsync removal event");
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::publishSyncUpdate(const ndn::Name& updatePrefix,
|
||||
uint64_t seqNo)
|
||||
SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
|
||||
{
|
||||
_LOG_DEBUG("Publishing Sync Update. Prefix: " << updatePrefix << "Seq no: " << seqNo);
|
||||
ndn::Name originRouter;
|
||||
|
||||
try {
|
||||
originRouter = update.getOriginRouter();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_WARN("Received malformed sync update");
|
||||
return;
|
||||
}
|
||||
|
||||
// A router should not try to fetch its own LSA
|
||||
if (originRouter != m_confParam.getRouterPrefix()) {
|
||||
|
||||
update.getSequencingManager().writeLog();
|
||||
|
||||
if (isLsaNew(originRouter, NameLsa::TYPE_STRING, update.getNameLsaSeqNo())) {
|
||||
_LOG_DEBUG("Received sync update with higher Name LSA sequence number than entry in LSDB");
|
||||
|
||||
expressInterestForLsa(update, NameLsa::TYPE_STRING, update.getNameLsaSeqNo());
|
||||
}
|
||||
|
||||
if (isLsaNew(originRouter, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo())) {
|
||||
_LOG_DEBUG("Received sync update with higher Adj LSA sequence number than entry in LSDB");
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
if (update.getAdjLsaSeqNo() != 0) {
|
||||
_LOG_ERROR("Tried to fetch an adjacency LSA when hyperbolic routing"
|
||||
<< " is enabled.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
expressInterestForLsa(update, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo());
|
||||
}
|
||||
}
|
||||
|
||||
if (isLsaNew(originRouter, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo())) {
|
||||
_LOG_DEBUG("Received sync update with higher Cor LSA sequence number than entry in LSDB");
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
if (update.getCorLsaSeqNo() != 0) {
|
||||
_LOG_ERROR("Tried to fetch a coordinate LSA when link-state"
|
||||
<< " is enabled.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
SyncLogicHandler::isLsaNew(const ndn::Name& originRouter, const std::string& lsaType,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
ndn::Name lsaKey = originRouter;
|
||||
lsaKey.append(lsaType);
|
||||
|
||||
if (lsaType == NameLsa::TYPE_STRING)
|
||||
{
|
||||
return m_lsdb.isNameLsaNew(lsaKey, seqNo);
|
||||
}
|
||||
else if (lsaType == AdjLsa::TYPE_STRING)
|
||||
{
|
||||
return m_lsdb.isAdjLsaNew(lsaKey, seqNo);
|
||||
}
|
||||
else if (lsaType == CoordinateLsa::TYPE_STRING)
|
||||
{
|
||||
return m_lsdb.isCoordinateLsaNew(lsaKey, seqNo);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::expressInterestForLsa(const SyncUpdate& update, std::string lsaType,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
ndn::Name interest(update.getName());
|
||||
interest.append(lsaType);
|
||||
interest.appendNumber(seqNo);
|
||||
|
||||
m_lsdb.expressInterest(interest, 0);
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::publishRoutingUpdate()
|
||||
{
|
||||
if (m_syncSocket == nullptr) {
|
||||
_LOG_FATAL("Cannot publish routing update; SyncSocket does not exist");
|
||||
|
||||
throw SyncLogicHandler::Error("Cannot publish routing update; SyncSocket does not exist");
|
||||
}
|
||||
|
||||
m_sequencingManager.writeSeqNoToFile();
|
||||
|
||||
publishSyncUpdate(m_updatePrefix, m_sequencingManager.getCombinedSeqNo());
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::buildUpdatePrefix()
|
||||
{
|
||||
m_updatePrefix = m_confParam.getLsaPrefix();
|
||||
m_updatePrefix.append(m_confParam.getSiteName());
|
||||
m_updatePrefix.append(m_confParam.getRouterName());
|
||||
}
|
||||
|
||||
void
|
||||
SyncLogicHandler::publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Publishing Sync Update. Prefix: " << updatePrefix << " Seq No: " << seqNo);
|
||||
|
||||
ndn::Name updateName(updatePrefix);
|
||||
string data("NoData");
|
||||
m_syncSocket->publishData(updateName.toUri(), 0, data.c_str(), data.size(),
|
||||
1000,
|
||||
seqNo);
|
||||
|
||||
m_syncSocket->publishData(updateName.toUri(), 0, data.c_str(), data.size(), 1000, seqNo);
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, 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.
|
||||
@@ -15,82 +16,92 @@
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_SYNC_LOGIC_HANDLER_HPP
|
||||
#define NLSR_SYNC_LOGIC_HANDLER_HPP
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/security/validator-null.hpp>
|
||||
#include <nsync/sync-socket.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <nsync/sync-socket.h>
|
||||
#include <ndn-cxx/security/validator-null.hpp>
|
||||
|
||||
#include "sequencing-manager.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <unistd.h>
|
||||
}
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
class InterestManager;
|
||||
class ConfParameter;
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class ConfParameter;
|
||||
class Lsdb;
|
||||
class SequencingManager;
|
||||
class SyncUpdate;
|
||||
|
||||
class SyncLogicHandler
|
||||
{
|
||||
public:
|
||||
SyncLogicHandler(boost::asio::io_service& ioService)
|
||||
: m_validator(new ndn::ValidatorNull())
|
||||
, m_syncFace(new ndn::Face(ioService))
|
||||
class Error : public std::runtime_error
|
||||
{
|
||||
}
|
||||
public:
|
||||
explicit
|
||||
Error(const std::string& what)
|
||||
: std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
SyncLogicHandler(ndn::Face& face, Lsdb& lsdb, ConfParameter& conf, SequencingManager& seqManager);
|
||||
|
||||
void
|
||||
createSyncSocket(Nlsr& pnlsr);
|
||||
onNsyncUpdate(const std::vector<Sync::MissingDataInfo>& v, Sync::SyncSocket* socket);
|
||||
|
||||
void
|
||||
nsyncUpdateCallBack(const std::vector<Sync::MissingDataInfo>& v,
|
||||
Sync::SyncSocket* socket, Nlsr& pnlsr);
|
||||
onNsyncRemoval(const std::string& prefix);
|
||||
|
||||
void
|
||||
nsyncRemoveCallBack(const std::string& prefix, Nlsr& pnlsr);
|
||||
publishRoutingUpdate();
|
||||
|
||||
void
|
||||
removeRouterFromSyncing(const ndn::Name& routerPrefix);
|
||||
|
||||
void
|
||||
publishRoutingUpdate(SequencingManager& sm, const ndn::Name& updatePrefix);
|
||||
|
||||
void
|
||||
setSyncPrefix(const std::string& sp)
|
||||
{
|
||||
m_syncPrefix.clear();
|
||||
m_syncPrefix.set(sp);
|
||||
}
|
||||
createSyncSocket(const ndn::Name& syncPrefix);
|
||||
|
||||
private:
|
||||
void
|
||||
processUpdateFromSync(const ndn::Name& updateName, uint64_t seqNo,
|
||||
Nlsr& pnlsr);
|
||||
buildUpdatePrefix();
|
||||
|
||||
void
|
||||
processRoutingUpdateFromSync(const ndn::Name& routerName, uint64_t seqNo,
|
||||
Nlsr& pnlsr);
|
||||
processUpdateFromSync(const SyncUpdate& updateName);
|
||||
|
||||
bool
|
||||
isLsaNew(const ndn::Name& originRouter, const std::string& lsaType, uint64_t seqNo);
|
||||
|
||||
void
|
||||
expressInterestForLsa(const SyncUpdate& updateName, std::string lsaType, uint64_t seqNo);
|
||||
|
||||
void
|
||||
publishSyncUpdate(const ndn::Name& updatePrefix, uint64_t seqNo);
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::ValidatorNull> m_validator;
|
||||
ndn::shared_ptr<ndn::Face> m_syncFace;
|
||||
ndn::Face& m_syncFace;
|
||||
ndn::shared_ptr<Sync::SyncSocket> m_syncSocket;
|
||||
ndn::Name m_syncPrefix;
|
||||
|
||||
private:
|
||||
Lsdb& m_lsdb;
|
||||
ConfParameter& m_confParam;
|
||||
const SequencingManager& m_sequencingManager;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::Name m_updatePrefix;
|
||||
|
||||
private:
|
||||
static const std::string NLSR_COMPONENT;
|
||||
static const std::string LSA_COMPONENT;
|
||||
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
|
||||
+301
-143
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,29 +17,129 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
* \author Minsheng Zhang <mzhang4@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <ndn-cxx/name.hpp>
|
||||
#include <ndn-cxx/util/face-uri.hpp>
|
||||
|
||||
// boost needs to be included after ndn-cxx, otherwise there will be conflict with _1, _2, ...
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/property_tree/info_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "adjacent.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
#include "update/prefix-update-processor.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <class T>
|
||||
class ConfigurationVariable
|
||||
{
|
||||
public:
|
||||
typedef ndn::function<void(T)> ConfParameterCallback;
|
||||
typedef boost::property_tree::ptree ConfigSection;
|
||||
|
||||
ConfigurationVariable(const std::string& key, const ConfParameterCallback& setter)
|
||||
: m_key(key)
|
||||
, m_setterCallback(setter)
|
||||
, m_minValue(0)
|
||||
, m_maxValue(0)
|
||||
, m_shouldCheckRange(false)
|
||||
, m_isRequired(true)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
parseFromConfigSection(const ConfigSection& section)
|
||||
{
|
||||
try {
|
||||
T value = section.get<T>(m_key);
|
||||
|
||||
if (!isValidValue(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_setterCallback(value);
|
||||
return true;
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
|
||||
if (m_isRequired) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cerr << "Missing required configuration variable" << std::endl;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
m_setterCallback(m_defaultValue);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
setMinAndMaxValue(T min, T max)
|
||||
{
|
||||
m_minValue = min;
|
||||
m_maxValue = max;
|
||||
m_shouldCheckRange = true;
|
||||
}
|
||||
|
||||
void
|
||||
setOptional(T defaultValue)
|
||||
{
|
||||
m_isRequired = false;
|
||||
m_defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
printOutOfRangeError(T value)
|
||||
{
|
||||
std::cerr << "Invalid value for " << m_key << ": "
|
||||
<< value << ". "
|
||||
<< "Valid values: "
|
||||
<< m_minValue << " - "
|
||||
<< m_maxValue << std::endl;
|
||||
}
|
||||
|
||||
bool
|
||||
isValidValue(T value)
|
||||
{
|
||||
if (!m_shouldCheckRange) {
|
||||
return true;
|
||||
}
|
||||
else if (value < m_minValue || value > m_maxValue)
|
||||
{
|
||||
printOutOfRangeError(value);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_key;
|
||||
const ConfParameterCallback m_setterCallback;
|
||||
T m_defaultValue;
|
||||
|
||||
T m_minValue;
|
||||
T m_maxValue;
|
||||
|
||||
bool m_shouldCheckRange;
|
||||
bool m_isRequired;
|
||||
};
|
||||
|
||||
bool
|
||||
ConfFileProcessor::processConfFile()
|
||||
{
|
||||
@@ -153,54 +254,54 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int32_t lsaRefreshTime = section.get<int32_t>("lsa-refresh-time");
|
||||
if (lsaRefreshTime >= LSA_REFRESH_TIME_MIN &&
|
||||
lsaRefreshTime <= LSA_REFRESH_TIME_MAX) {
|
||||
m_nlsr.getConfParameter().setLsaRefreshTime(lsaRefreshTime);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for lsa-refresh-time ";
|
||||
std::cerr << "Allowed value: " << LSA_REFRESH_TIME_MIN << "-";;
|
||||
std::cerr << LSA_REFRESH_TIME_MAX << std::endl;
|
||||
return false;
|
||||
}
|
||||
// lsa-refresh-time
|
||||
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);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
else {
|
||||
std::cerr << "Wrong value for lsa-refresh-time ";
|
||||
std::cerr << "Allowed value: " << LSA_REFRESH_TIME_MIN << "-";;
|
||||
std::cerr << LSA_REFRESH_TIME_MAX << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int lifetime = section.get<int>("lsa-interest-lifetime");
|
||||
if (lifetime >= LSA_INTEREST_LIFETIME_MIN && lifetime <= LSA_INTEREST_LIFETIME_MAX) {
|
||||
m_nlsr.getConfParameter().setLsaInterestLifetime(ndn::time::seconds(lifetime));
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for lsa-interest-timeout. "
|
||||
<< "Allowed value:" << LSA_INTEREST_LIFETIME_MIN << "-"
|
||||
<< LSA_INTEREST_LIFETIME_MAX << std::endl;
|
||||
return false;
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
// return false;
|
||||
else {
|
||||
std::cerr << "Value of router-dead-interval must be larger than lsa-refresh-time" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
std::string logLevel = section.get<string>("log-level");
|
||||
if ( boost::iequals(logLevel, "info") || boost::iequals(logLevel, "debug")) {
|
||||
m_nlsr.getConfParameter().setLogLevel(logLevel);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for log-level ";
|
||||
std::cerr << "Allowed value: INFO, DEBUG" << std::endl;
|
||||
return false;
|
||||
}
|
||||
// lsa-interest-lifetime
|
||||
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));
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
else {
|
||||
std::cerr << "Wrong value for lsa-interest-timeout. "
|
||||
<< "Allowed value:" << LSA_INTEREST_LIFETIME_MIN << "-"
|
||||
<< LSA_INTEREST_LIFETIME_MAX << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// log-level
|
||||
std::string logLevel = section.get<string>("log-level", "INFO");
|
||||
|
||||
if (isValidLogLevel(logLevel)) {
|
||||
m_nlsr.getConfParameter().setLogLevel(logLevel);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Invalid value for log-level ";
|
||||
std::cerr << "Valid values: ALL, TRACE, DEBUG, INFO, WARN, ERROR, NONE" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -228,7 +329,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "Log directory provided does not exists" << std::endl;
|
||||
std::cerr << "Provided log directory <" << logDir << "> does not exist" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -237,6 +338,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
std::cerr << ex.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
std::string seqDir = section.get<string>("seq-dir");
|
||||
if (boost::filesystem::exists(seqDir)) {
|
||||
@@ -261,7 +363,7 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "Seq directory provided does not exists" << std::endl;
|
||||
std::cerr << "Provided sequence directory <" << seqDir << "> does not exist" << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -271,58 +373,99 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
std::string log4cxxPath = section.get<string>("log4cxx-conf");
|
||||
|
||||
if (log4cxxPath == "") {
|
||||
std::cerr << "No value provided for log4cxx-conf" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (boost::filesystem::exists(log4cxxPath)) {
|
||||
m_nlsr.getConfParameter().setLog4CxxConfPath(log4cxxPath);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Provided path for log4cxx-conf <" << log4cxxPath
|
||||
<< "> does not exist" << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
// Variable is optional so default configuration will be used; continue processing file
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
{
|
||||
try {
|
||||
int retrials = section.get<int>("hello-retries");
|
||||
if (retrials >= HELLO_RETRIES_MIN && retrials <= HELLO_RETRIES_MAX) {
|
||||
m_nlsr.getConfParameter().setInterestRetryNumber(retrials);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-retries. ";
|
||||
std::cerr << "Allowed value:" << HELLO_RETRIES_MIN << "-";
|
||||
std::cerr << HELLO_RETRIES_MAX << std::endl;
|
||||
return false;
|
||||
}
|
||||
// hello-retries
|
||||
int retrials = section.get<int>("hello-retries", HELLO_RETRIES_DEFAULT);
|
||||
|
||||
if (retrials >= HELLO_RETRIES_MIN && retrials <= HELLO_RETRIES_MAX) {
|
||||
m_nlsr.getConfParameter().setInterestRetryNumber(retrials);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-retries." << std::endl;
|
||||
std::cerr << "Allowed value:" << HELLO_RETRIES_MIN << "-";
|
||||
std::cerr << HELLO_RETRIES_MAX << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int timeOut = section.get<int>("hello-timeout");
|
||||
if (timeOut >= HELLO_TIMEOUT_MIN && timeOut <= HELLO_TIMEOUT_MAX) {
|
||||
m_nlsr.getConfParameter().setInterestResendTime(timeOut);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-timeout. ";
|
||||
std::cerr << "Allowed value:" << HELLO_TIMEOUT_MIN << "-";
|
||||
std::cerr << HELLO_TIMEOUT_MAX << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// hello-timeout
|
||||
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);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-timeout. ";
|
||||
std::cerr << "Allowed value:" << HELLO_TIMEOUT_MIN << "-";
|
||||
std::cerr << HELLO_TIMEOUT_MAX << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int interval = section.get<int>("hello-interval");
|
||||
if (interval >= HELLO_INTERVAL_MIN && interval <= HELLO_INTERVAL_MAX) {
|
||||
m_nlsr.getConfParameter().setInfoInterestInterval(interval);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-interval. ";
|
||||
std::cerr << "Allowed value:" << HELLO_INTERVAL_MIN << "-";
|
||||
std::cerr << HELLO_INTERVAL_MAX << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// hello-interval
|
||||
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);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
else {
|
||||
std::cerr << "Wrong value for hello-interval. ";
|
||||
std::cerr << "Allowed value:" << HELLO_INTERVAL_MIN << "-";
|
||||
std::cerr << HELLO_INTERVAL_MAX << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Event intervals
|
||||
// adj-lsa-build-interval
|
||||
ConfigurationVariable<uint32_t> adjLsaBuildInterval("adj-lsa-build-interval",
|
||||
bind(&ConfParameter::setAdjLsaBuildInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
adjLsaBuildInterval.setMinAndMaxValue(ADJ_LSA_BUILD_INTERVAL_MIN, ADJ_LSA_BUILD_INTERVAL_MAX);
|
||||
adjLsaBuildInterval.setOptional(ADJ_LSA_BUILD_INTERVAL_DEFAULT);
|
||||
|
||||
if (!adjLsaBuildInterval.parseFromConfigSection(section)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// first-hello-interval
|
||||
ConfigurationVariable<uint32_t> firstHelloInterval("first-hello-interval",
|
||||
bind(&ConfParameter::setFirstHelloInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
firstHelloInterval.setMinAndMaxValue(FIRST_HELLO_INTERVAL_MIN, FIRST_HELLO_INTERVAL_MAX);
|
||||
firstHelloInterval.setOptional(FIRST_HELLO_INTERVAL_DEFAULT);
|
||||
|
||||
if (!firstHelloInterval.parseFromConfigSection(section)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ConfigSection::const_iterator tn =
|
||||
section.begin(); tn != section.end(); ++tn) {
|
||||
|
||||
@@ -332,11 +475,19 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
ConfigSection CommandAttriTree = tn->second;
|
||||
std::string name = CommandAttriTree.get<std::string>("name");
|
||||
std::string faceUri = CommandAttriTree.get<std::string>("face-uri");
|
||||
|
||||
ndn::util::FaceUri uri;
|
||||
|
||||
if (!uri.parse(faceUri)) {
|
||||
std::cerr << "Malformed face-uri <" << faceUri << "> for " << name << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
double linkCost = CommandAttriTree.get<double>("link-cost",
|
||||
Adjacent::DEFAULT_LINK_COST);
|
||||
ndn::Name neighborName(name);
|
||||
if (!neighborName.empty()) {
|
||||
Adjacent adj(name, faceUri, linkCost, ADJACENT_STATUS_INACTIVE, 0, 0);
|
||||
Adjacent adj(name, faceUri, linkCost, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
m_nlsr.getAdjacencyList().insert(adj);
|
||||
}
|
||||
else {
|
||||
@@ -356,26 +507,22 @@ ConfFileProcessor::processConfSectionNeighbors(const ConfigSection& section)
|
||||
bool
|
||||
ConfFileProcessor::processConfSectionHyperbolic(const ConfigSection& section)
|
||||
{
|
||||
std::string state;
|
||||
try {
|
||||
state= section.get<string>("state","off");
|
||||
if (boost::iequals(state, "off")) {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_OFF);
|
||||
}
|
||||
else if (boost::iequals(state, "on")) {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
|
||||
}
|
||||
else if (state == "dry-run") {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong format for hyperbolic state." << std::endl;
|
||||
std::cerr << "Allowed value: off, on, dry-run" << std::endl;
|
||||
return false;
|
||||
}
|
||||
// state
|
||||
std::string state = section.get<string>("state", "off");
|
||||
|
||||
if (boost::iequals(state, "off")) {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_OFF);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
std::cerr << ex.what() << std::endl;
|
||||
else if (boost::iequals(state, "on")) {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
|
||||
}
|
||||
else if (state == "dry-run") {
|
||||
m_nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong format for hyperbolic state." << std::endl;
|
||||
std::cerr << "Allowed value: off, on, dry-run" << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -405,24 +552,32 @@ ConfFileProcessor::processConfSectionHyperbolic(const ConfigSection& section)
|
||||
bool
|
||||
ConfFileProcessor::processConfSectionFib(const ConfigSection& section)
|
||||
{
|
||||
try {
|
||||
int maxFacesPerPrefixNumber =
|
||||
section.get<int>("max-faces-per-prefix");
|
||||
if (maxFacesPerPrefixNumber >= MAX_FACES_PER_PREFIX_MIN &&
|
||||
maxFacesPerPrefixNumber <= MAX_FACES_PER_PREFIX_MAX)
|
||||
{
|
||||
m_nlsr.getConfParameter().setMaxFacesPerPrefix(maxFacesPerPrefixNumber);
|
||||
}
|
||||
else {
|
||||
std::cerr << "Wrong value for max-faces-per-prefix. ";
|
||||
std::cerr << MAX_FACES_PER_PREFIX_MIN << std::endl;
|
||||
return false;
|
||||
}
|
||||
// max-faces-per-prefix
|
||||
int maxFacesPerPrefix = section.get<int>("max-faces-per-prefix", MAX_FACES_PER_PREFIX_DEFAULT);
|
||||
|
||||
if (maxFacesPerPrefix >= MAX_FACES_PER_PREFIX_MIN &&
|
||||
maxFacesPerPrefix <= MAX_FACES_PER_PREFIX_MAX)
|
||||
{
|
||||
m_nlsr.getConfParameter().setMaxFacesPerPrefix(maxFacesPerPrefix);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
cerr << ex.what() << endl;
|
||||
else {
|
||||
std::cerr << "Wrong value for max-faces-per-prefix. ";
|
||||
std::cerr << MAX_FACES_PER_PREFIX_MIN << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// routing-calc-interval
|
||||
ConfigurationVariable<uint32_t> routingCalcInterval("routing-calc-interval",
|
||||
bind(&ConfParameter::setRoutingCalcInterval,
|
||||
&m_nlsr.getConfParameter(), _1));
|
||||
routingCalcInterval.setMinAndMaxValue(ROUTING_CALC_INTERVAL_MIN, ROUTING_CALC_INTERVAL_MAX);
|
||||
routingCalcInterval.setOptional(ROUTING_CALC_INTERVAL_DEFAULT);
|
||||
|
||||
if (!routingCalcInterval.parseFromConfigSection(section)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -457,37 +612,40 @@ ConfFileProcessor::processConfSectionSecurity(const ConfigSection& section)
|
||||
{
|
||||
ConfigSection::const_iterator it = section.begin();
|
||||
|
||||
if (it == section.end() || it->first != "validator")
|
||||
{
|
||||
std::cerr << "Error: Expect validator section!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (it == section.end() || it->first != "validator") {
|
||||
std::cerr << "Error: Expect validator section!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nlsr.loadValidator(it->second, m_confFileName);
|
||||
it++;
|
||||
|
||||
for (; it != section.end(); it++)
|
||||
{
|
||||
it++;
|
||||
if (it != section.end() && it->first == "prefix-update-validator") {
|
||||
m_nlsr.getPrefixUpdateProcessor().enable();
|
||||
m_nlsr.getPrefixUpdateProcessor().loadValidator(it->second, m_confFileName);
|
||||
|
||||
it++;
|
||||
for (; it != section.end(); it++) {
|
||||
using namespace boost::filesystem;
|
||||
if (it->first != "cert-to-publish")
|
||||
{
|
||||
std::cerr << "Error: Expect cert-to-publish!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (it->first != "cert-to-publish") {
|
||||
std::cerr << "Error: Expect cert-to-publish!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string file = it->second.data();
|
||||
path certfilePath = absolute(file, path(m_confFileName).parent_path());
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> idCert =
|
||||
shared_ptr<ndn::IdentityCertificate> idCert =
|
||||
ndn::io::load<ndn::IdentityCertificate>(certfilePath.string());
|
||||
|
||||
if (!static_cast<bool>(idCert))
|
||||
{
|
||||
std::cerr << "Error: Cannot load cert-to-publish: " << file << "!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (idCert == nullptr) {
|
||||
std::cerr << "Error: Cannot load cert-to-publish: " << file << "!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_nlsr.loadCertToPublish(idCert);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -34,19 +35,25 @@ ConfParameter::writeLog()
|
||||
_LOG_DEBUG("Site Name: " << m_siteName);
|
||||
_LOG_DEBUG("Network: " << m_network);
|
||||
_LOG_DEBUG("Router Prefix: " << m_routerPrefix);
|
||||
_LOG_DEBUG("ChronoSync sync Prifex: " << m_chronosyncPrefix);
|
||||
_LOG_DEBUG("ChronoSync sync Prefix: " << m_chronosyncPrefix);
|
||||
_LOG_DEBUG("ChronoSync LSA prefix: " << m_lsaPrefix);
|
||||
_LOG_DEBUG("Hello Interest retry number: " << m_interestRetryNumber);
|
||||
_LOG_DEBUG("Hello Interest resend second: " << m_interestResendTime);
|
||||
_LOG_DEBUG("Info Interest interval: " << m_infoInterestInterval);
|
||||
_LOG_DEBUG("LSA refresh time: " << m_lsaRefreshTime);
|
||||
_LOG_DEBUG("LSA Interest lifetime: " << getLsaInterestLifetime());
|
||||
_LOG_DEBUG("Router dead interval: " << getRouterDeadInterval());
|
||||
_LOG_DEBUG("Max Faces Per Prefix: " << m_maxFacesPerPrefix);
|
||||
_LOG_DEBUG("Hyperbolic ROuting: " << m_hyperbolicState);
|
||||
_LOG_DEBUG("Hyperbolic Routing: " << m_hyperbolicState);
|
||||
_LOG_DEBUG("Hyp R: " << m_corR);
|
||||
_LOG_DEBUG("Hyp theta: " << m_corTheta);
|
||||
_LOG_DEBUG("Log Directory: " << m_logDir);
|
||||
_LOG_DEBUG("Seq Directory: " << m_seqFileDir);
|
||||
|
||||
// Event Intervals
|
||||
_LOG_DEBUG("Adjacency LSA build interval: " << m_adjLsaBuildInterval);
|
||||
_LOG_DEBUG("First Hello Interest interval: " << m_firstHelloInterval);
|
||||
_LOG_DEBUG("Routing calculation interval: " << m_routingCalcInterval);
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
+108
-25
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,10 +17,8 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef CONF_PARAMETER_HPP
|
||||
#define CONF_PARAMETER_HPP
|
||||
|
||||
@@ -45,6 +44,24 @@ enum {
|
||||
LSA_INTEREST_LIFETIME_MAX = 60
|
||||
};
|
||||
|
||||
enum {
|
||||
ADJ_LSA_BUILD_INTERVAL_MIN = 0,
|
||||
ADJ_LSA_BUILD_INTERVAL_DEFAULT = 5,
|
||||
ADJ_LSA_BUILD_INTERVAL_MAX = 5
|
||||
};
|
||||
|
||||
enum {
|
||||
FIRST_HELLO_INTERVAL_MIN = 0,
|
||||
FIRST_HELLO_INTERVAL_DEFAULT = 10,
|
||||
FIRST_HELLO_INTERVAL_MAX = 10
|
||||
};
|
||||
|
||||
enum {
|
||||
ROUTING_CALC_INTERVAL_MIN = 0,
|
||||
ROUTING_CALC_INTERVAL_DEFAULT = 15,
|
||||
ROUTING_CALC_INTERVAL_MAX = 15
|
||||
};
|
||||
|
||||
enum {
|
||||
HELLO_RETRIES_MIN = 1,
|
||||
HELLO_RETRIES_DEFAULT = 3,
|
||||
@@ -65,13 +82,15 @@ enum {
|
||||
|
||||
enum {
|
||||
MAX_FACES_PER_PREFIX_MIN = 0,
|
||||
MAX_FACES_PER_PREFIX_DEFAULT = 0,
|
||||
MAX_FACES_PER_PREFIX_MAX = 60
|
||||
};
|
||||
|
||||
enum {
|
||||
enum HyperbolicState {
|
||||
HYPERBOLIC_STATE_OFF = 0,
|
||||
HYPERBOLIC_STATE_ON = 1,
|
||||
HYPERBOLIC_STATE_DRY_RUN = 2
|
||||
HYPERBOLIC_STATE_DRY_RUN = 2,
|
||||
HYPERBOLIC_STATE_DEFAULT = 0
|
||||
};
|
||||
|
||||
class ConfParameter
|
||||
@@ -80,8 +99,11 @@ 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_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
|
||||
, m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT)
|
||||
, m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
|
||||
, m_logLevel("INFO")
|
||||
, m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
|
||||
, m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
|
||||
@@ -90,6 +112,7 @@ public:
|
||||
, m_corR(0)
|
||||
, m_corTheta(0)
|
||||
, m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
|
||||
, m_isLog4cxxConfAvailable(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -164,13 +187,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setLsaRefreshTime(int32_t lrt)
|
||||
setLsaRefreshTime(uint32_t lrt)
|
||||
{
|
||||
m_lsaRefreshTime = lrt;
|
||||
m_routerDeadInterval = 2 * m_lsaRefreshTime;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getLsaRefreshTime() const
|
||||
{
|
||||
return m_lsaRefreshTime;
|
||||
@@ -189,12 +211,48 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setRouterDeadInterval(int64_t rdt)
|
||||
setAdjLsaBuildInterval(uint32_t interval)
|
||||
{
|
||||
m_adjLsaBuildInterval = interval;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getAdjLsaBuildInterval() const
|
||||
{
|
||||
return m_adjLsaBuildInterval;
|
||||
}
|
||||
|
||||
void
|
||||
setFirstHelloInterval(uint32_t interval)
|
||||
{
|
||||
m_firstHelloInterval = interval;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getFirstHelloInterval() const
|
||||
{
|
||||
return m_firstHelloInterval;
|
||||
}
|
||||
|
||||
void
|
||||
setRoutingCalcInterval(uint32_t interval)
|
||||
{
|
||||
m_routingCalcInterval = interval;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
getRoutingCalcInterval() const
|
||||
{
|
||||
return m_routingCalcInterval;
|
||||
}
|
||||
|
||||
void
|
||||
setRouterDeadInterval(uint32_t rdt)
|
||||
{
|
||||
m_routerDeadInterval = rdt;
|
||||
}
|
||||
|
||||
int64_t
|
||||
uint32_t
|
||||
getRouterDeadInterval() const
|
||||
{
|
||||
return m_routerDeadInterval;
|
||||
@@ -225,25 +283,25 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setInterestResendTime(int32_t irt)
|
||||
setInterestResendTime(uint32_t irt)
|
||||
{
|
||||
m_interestResendTime = irt;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getInterestResendTime() const
|
||||
{
|
||||
return m_interestResendTime;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getInfoInterestInterval() const
|
||||
{
|
||||
return m_infoInterestInterval;
|
||||
}
|
||||
|
||||
void
|
||||
setInfoInterestInterval(int32_t iii)
|
||||
setInfoInterestInterval(uint32_t iii)
|
||||
{
|
||||
m_infoInterestInterval = iii;
|
||||
}
|
||||
@@ -289,12 +347,12 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setMaxFacesPerPrefix(int32_t mfpp)
|
||||
setMaxFacesPerPrefix(uint32_t mfpp)
|
||||
{
|
||||
m_maxFacesPerPrefix = mfpp;
|
||||
}
|
||||
|
||||
int32_t
|
||||
uint32_t
|
||||
getMaxFacesPerPrefix() const
|
||||
{
|
||||
return m_maxFacesPerPrefix;
|
||||
@@ -324,6 +382,25 @@ public:
|
||||
return m_seqFileDir;
|
||||
}
|
||||
|
||||
bool
|
||||
isLog4CxxConfAvailable() const
|
||||
{
|
||||
return m_isLog4cxxConfAvailable;
|
||||
}
|
||||
|
||||
void
|
||||
setLog4CxxConfPath(const std::string& path)
|
||||
{
|
||||
m_log4CxxConfPath = path;
|
||||
m_isLog4cxxConfAvailable = true;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getLog4CxxConfPath() const
|
||||
{
|
||||
return m_log4CxxConfPath;
|
||||
}
|
||||
|
||||
void
|
||||
writeLog();
|
||||
|
||||
@@ -338,26 +415,32 @@ private:
|
||||
ndn::Name m_chronosyncPrefix;
|
||||
ndn::Name m_lsaPrefix;
|
||||
|
||||
int32_t m_lsaRefreshTime;
|
||||
uint32_t m_lsaRefreshTime;
|
||||
|
||||
uint32_t m_adjLsaBuildInterval;
|
||||
uint32_t m_firstHelloInterval;
|
||||
uint32_t m_routingCalcInterval;
|
||||
|
||||
ndn::time::seconds m_lsaInterestLifetime;
|
||||
int64_t m_routerDeadInterval;
|
||||
uint32_t m_routerDeadInterval;
|
||||
std::string m_logLevel;
|
||||
|
||||
uint32_t m_interestRetryNumber;
|
||||
int32_t m_interestResendTime;
|
||||
uint32_t m_interestResendTime;
|
||||
|
||||
|
||||
int32_t m_infoInterestInterval;
|
||||
uint32_t m_infoInterestInterval;
|
||||
|
||||
int32_t m_hyperbolicState;
|
||||
double m_corR;
|
||||
double m_corTheta;
|
||||
|
||||
int32_t m_maxFacesPerPrefix;
|
||||
uint32_t m_maxFacesPerPrefix;
|
||||
|
||||
std::string m_logDir;
|
||||
std::string m_seqFileDir;
|
||||
|
||||
bool m_isLog4cxxConfAvailable;
|
||||
std::string m_log4CxxConfPath;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
+23
-41
@@ -74,9 +74,10 @@ HelloProtocol::sendScheduledInterest(uint32_t seconds)
|
||||
void
|
||||
HelloProtocol::scheduleInterest(uint32_t seconds)
|
||||
{
|
||||
m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(seconds),
|
||||
ndn::bind(&HelloProtocol::sendScheduledInterest,
|
||||
this, seconds));
|
||||
_LOG_DEBUG("Scheduling HELLO Interests in " << ndn::time::seconds(seconds));
|
||||
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(seconds),
|
||||
ndn::bind(&HelloProtocol::sendScheduledInterest, this, seconds));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -102,7 +103,7 @@ HelloProtocol::processInterest(const ndn::Name& name,
|
||||
_LOG_DEBUG("Sending out data for name: " << interest.getName());
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor);
|
||||
if (adjacent->getStatus() == 0) {
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_INACTIVE) {
|
||||
if(adjacent->getFaceId() != 0){
|
||||
/* interest name: /<neighbor>/NLSR/INFO/<router> */
|
||||
ndn::Name interestName(neighbor);
|
||||
@@ -132,7 +133,9 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
ndn::Name neighbor = interestName.getPrefix(-3);
|
||||
_LOG_DEBUG("Neighbor: " << neighbor);
|
||||
m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor);
|
||||
int status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
|
||||
Adjacent::Status status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
|
||||
uint32_t infoIntTimedOutCount =
|
||||
m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor);
|
||||
_LOG_DEBUG("Status: " << status);
|
||||
@@ -146,18 +149,11 @@ HelloProtocol::processInterestTimedOut(const ndn::Interest& interest)
|
||||
expressInterest(interestName,
|
||||
m_nlsr.getConfParameter().getInterestResendTime());
|
||||
}
|
||||
else if ((status == 1) &&
|
||||
else if ((status == Adjacent::STATUS_ACTIVE) &&
|
||||
(infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 0);
|
||||
m_nlsr.incrementAdjBuildCount();
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
_LOG_DEBUG("Scheduling scheduledAdjLsaBuild");
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
// event here
|
||||
m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
|
||||
ndn::bind(&Lsdb::scheduledAdjLsaBuild,
|
||||
&m_nlsr.getLsdb()));
|
||||
}
|
||||
m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_INACTIVE);
|
||||
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,24 +180,17 @@ HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
_LOG_DEBUG("Data validation successful for INFO(name): " << dataName);
|
||||
if (dataName.get(-3).toUri() == INFO_COMPONENT) {
|
||||
ndn::Name neighbor = dataName.getPrefix(-4);
|
||||
int oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, 1);
|
||||
|
||||
Adjacent::Status oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_ACTIVE);
|
||||
m_nlsr.getAdjacencyList().setTimedOutInterestCount(neighbor, 0);
|
||||
int newStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
Adjacent::Status newStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor);
|
||||
|
||||
_LOG_DEBUG("Neighbor : " << neighbor);
|
||||
_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus);
|
||||
// change in Adjacency list
|
||||
if ((oldStatus - newStatus) != 0) {
|
||||
m_nlsr.incrementAdjBuildCount();
|
||||
// Need to schedule event for Adjacency LSA building
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
_LOG_DEBUG("Scheduling scheduledAdjLsaBuild");
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
// event here
|
||||
m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
|
||||
ndn::bind(&Lsdb::scheduledAdjLsaBuild,
|
||||
ndn::ref(m_nlsr.getLsdb())));
|
||||
}
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,22 +261,15 @@ HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error,
|
||||
Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(name);
|
||||
if (adjacent != 0) {
|
||||
adjacent->setInterestTimedOutNo(adjacent->getInterestTimedOutNo() + 1);
|
||||
int status = adjacent->getStatus();
|
||||
Adjacent::Status status = adjacent->getStatus();
|
||||
uint32_t infoIntTimedOutCount = adjacent->getInterestTimedOutNo();
|
||||
|
||||
if (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()) {
|
||||
if ( status == 1) {
|
||||
adjacent->setStatus(0);
|
||||
}
|
||||
m_nlsr.incrementAdjBuildCount();
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
_LOG_DEBUG("Scheduling scheduledAdjLsaBuild");
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
// event here
|
||||
m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(5),
|
||||
ndn::bind(&Lsdb::scheduledAdjLsaBuild,
|
||||
&m_nlsr.getLsdb()));
|
||||
if (status == Adjacent::STATUS_ACTIVE) {
|
||||
adjacent->setStatus(Adjacent::STATUS_INACTIVE);
|
||||
}
|
||||
|
||||
m_nlsr.getLsdb().scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-9
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,15 +17,15 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_HELLO_PROTOCOL_HPP
|
||||
#define NLSR_HELLO_PROTOCOL_HPP
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-parameters.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
@@ -33,14 +34,13 @@ class Nlsr;
|
||||
|
||||
class HelloProtocol
|
||||
{
|
||||
|
||||
public:
|
||||
HelloProtocol(Nlsr& nlsr)
|
||||
HelloProtocol(Nlsr& nlsr, ndn::Scheduler& scheduler)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
void
|
||||
scheduleInterest(uint32_t seconds);
|
||||
|
||||
@@ -60,9 +60,11 @@ private:
|
||||
void
|
||||
onContent(const ndn::Interest& interest, const ndn::Data& data);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
private:
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg);
|
||||
@@ -80,6 +82,8 @@ private:
|
||||
double linkCost, const ndn::time::milliseconds& timeout);
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
static const std::string INFO_COMPONENT;
|
||||
static const std::string NLSR_COMPONENT;
|
||||
};
|
||||
|
||||
+42
-4
@@ -22,29 +22,67 @@
|
||||
**/
|
||||
#include <log4cxx/logger.h>
|
||||
#include <log4cxx/basicconfigurator.h>
|
||||
#include <log4cxx/xml/domconfigurator.h>
|
||||
#include <log4cxx/propertyconfigurator.h>
|
||||
#include <log4cxx/patternlayout.h>
|
||||
#include <log4cxx/level.h>
|
||||
#include <log4cxx/helpers/exception.h>
|
||||
#include <log4cxx/rollingfileappender.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "logger.hpp"
|
||||
|
||||
void
|
||||
INIT_LOGGERS(const std::string& logDir)
|
||||
INIT_LOG4CXX(const std::string& log4cxxConfPath)
|
||||
{
|
||||
if (boost::filesystem::path(log4cxxConfPath).extension().string() == ".xml") {
|
||||
log4cxx::xml::DOMConfigurator::configure(log4cxxConfPath);
|
||||
}
|
||||
else {
|
||||
log4cxx::PropertyConfigurator::configure(log4cxxConfPath);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
INIT_LOGGERS(const std::string& logDir, const std::string& logLevel)
|
||||
{
|
||||
static bool configured = false;
|
||||
if (configured) return;
|
||||
|
||||
if (configured) {
|
||||
return;
|
||||
}
|
||||
|
||||
log4cxx::PatternLayoutPtr
|
||||
layout(new log4cxx::PatternLayout("%date{yyyyMMddHHmmssSSS} %c %L: %m%n"));
|
||||
layout(new log4cxx::PatternLayout("%date{yyyyMMddHHmmssSSS} %p: [%c] %m%n"));
|
||||
|
||||
log4cxx::RollingFileAppender* rollingFileAppender =
|
||||
new log4cxx::RollingFileAppender(layout, logDir+"/nlsr.log", true);
|
||||
|
||||
rollingFileAppender->setMaxFileSize("10MB");
|
||||
rollingFileAppender->setMaxBackupIndex(10);
|
||||
|
||||
log4cxx::helpers::Pool p;
|
||||
rollingFileAppender->activateOptions(p);
|
||||
|
||||
log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender));
|
||||
log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug());
|
||||
|
||||
if (boost::iequals(logLevel, "none")) {
|
||||
log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getOff());
|
||||
}
|
||||
else {
|
||||
log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::toLevel(logLevel));
|
||||
}
|
||||
|
||||
configured = true;
|
||||
}
|
||||
|
||||
bool
|
||||
isValidLogLevel(const std::string& logLevel)
|
||||
{
|
||||
return boost::iequals(logLevel, "all") || boost::iequals(logLevel, "trace") ||
|
||||
boost::iequals(logLevel, "debug") || boost::iequals(logLevel, "info") ||
|
||||
boost::iequals(logLevel, "warn") || boost::iequals(logLevel, "error") ||
|
||||
boost::iequals(logLevel, "none");
|
||||
}
|
||||
+21
-3
@@ -20,22 +20,40 @@
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_LOGGER_HPP
|
||||
#define NLSR_LOGGER_HPP
|
||||
|
||||
#include <log4cxx/logger.h>
|
||||
|
||||
|
||||
#define INIT_LOGGER(name) \
|
||||
static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger(name)
|
||||
|
||||
#define _LOG_TRACE(x) \
|
||||
LOG4CXX_TRACE(staticModuleLogger, x)
|
||||
|
||||
#define _LOG_DEBUG(x) \
|
||||
LOG4CXX_DEBUG(staticModuleLogger,x)
|
||||
LOG4CXX_DEBUG(staticModuleLogger, x)
|
||||
|
||||
#define _LOG_INFO(x) \
|
||||
LOG4CXX_INFO(staticModuleLogger, x)
|
||||
|
||||
#define _LOG_WARN(x) \
|
||||
LOG4CXX_WARN(staticModuleLogger, x)
|
||||
|
||||
#define _LOG_ERROR(x) \
|
||||
LOG4CXX_ERROR(staticModuleLogger, x)
|
||||
|
||||
#define _LOG_FATAL(x) \
|
||||
LOG4CXX_FATAL(staticModuleLogger, x);
|
||||
|
||||
void
|
||||
INIT_LOGGERS(const std::string& logDir);
|
||||
INIT_LOGGERS(const std::string& logDir, const std::string& logLevel);
|
||||
|
||||
void
|
||||
INIT_LOG4CXX(const std::string& log4cxxConfPath);
|
||||
|
||||
bool
|
||||
isValidLogLevel(const std::string& logLevel);
|
||||
|
||||
#endif // NLSR_LOGGER_HPP
|
||||
+64
-41
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,10 +17,8 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -42,20 +41,24 @@ INIT_LOGGER("Lsa");
|
||||
|
||||
using namespace std;
|
||||
|
||||
const std::string NameLsa::TYPE_STRING = "name";
|
||||
const std::string AdjLsa::TYPE_STRING = "adjacency";
|
||||
const std::string CoordinateLsa::TYPE_STRING = "coordinate";
|
||||
|
||||
const ndn::Name
|
||||
NameLsa::getKey() const
|
||||
{
|
||||
ndn::Name key = m_origRouter;
|
||||
key.append("name");
|
||||
key.append(NameLsa::TYPE_STRING);
|
||||
return key;
|
||||
}
|
||||
|
||||
NameLsa::NameLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
NameLsa::NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl)
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
std::list<ndn::Name>& nl = npl.getNameList();
|
||||
@@ -68,7 +71,7 @@ string
|
||||
NameLsa::getData()
|
||||
{
|
||||
string nameLsaData;
|
||||
nameLsaData = m_origRouter.toUri() + "|" + "name" + "|"
|
||||
nameLsaData = m_origRouter.toUri() + "|" + NameLsa::TYPE_STRING + "|"
|
||||
+ boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
|
||||
+ ndn::time::toIsoString(m_expirationTimePoint);
|
||||
nameLsaData += "|";
|
||||
@@ -94,12 +97,16 @@ NameLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != NameLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numName = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numName; i++) {
|
||||
@@ -127,13 +134,12 @@ NameLsa::writeLog()
|
||||
_LOG_DEBUG("name_lsa_end");
|
||||
}
|
||||
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst,
|
||||
uint32_t lsn,
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta)
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_corRad = r;
|
||||
@@ -144,7 +150,7 @@ const ndn::Name
|
||||
CoordinateLsa::getKey() const
|
||||
{
|
||||
ndn::Name key = m_origRouter;
|
||||
key.append("coordinate");
|
||||
key.append(CoordinateLsa::TYPE_STRING);
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -162,7 +168,7 @@ CoordinateLsa::getData()
|
||||
{
|
||||
string corLsaData;
|
||||
corLsaData = m_origRouter.toUri() + "|";
|
||||
corLsaData += "coordinate";
|
||||
corLsaData += CoordinateLsa::TYPE_STRING;
|
||||
corLsaData += "|";
|
||||
corLsaData += (boost::lexical_cast<std::string>(m_lsSeqNo) + "|");
|
||||
corLsaData += (ndn::time::toIsoString(m_expirationTimePoint) + "|");
|
||||
@@ -183,13 +189,17 @@ CoordinateLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != CoordinateLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
m_corRad = boost::lexical_cast<double>(*tok_iter++);
|
||||
m_corTheta = boost::lexical_cast<double>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -204,21 +214,21 @@ CoordinateLsa::writeLog()
|
||||
_LOG_DEBUG(" Ls Seq No: " << m_lsSeqNo);
|
||||
_LOG_DEBUG(" Ls Lifetime: " << m_expirationTimePoint);
|
||||
_LOG_DEBUG(" Hyperbolic Radius: " << m_corRad);
|
||||
_LOG_DEBUG(" Hyperbolic Theta: " << m_corRad);
|
||||
_LOG_DEBUG(" Hyperbolic Theta: " << m_corTheta);
|
||||
}
|
||||
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl)
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_noLink = nl;
|
||||
std::list<Adjacent> al = adl.getAdjList();
|
||||
for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++) {
|
||||
if ((*it).getStatus() == 1) {
|
||||
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
addAdjacent((*it));
|
||||
}
|
||||
}
|
||||
@@ -228,7 +238,7 @@ const ndn::Name
|
||||
AdjLsa::getKey() const
|
||||
{
|
||||
ndn::Name key = m_origRouter;
|
||||
key.append("adjacency");
|
||||
key.append(AdjLsa::TYPE_STRING);
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -243,7 +253,7 @@ string
|
||||
AdjLsa::getData()
|
||||
{
|
||||
string adjLsaData;
|
||||
adjLsaData = m_origRouter.toUri() + "|" + "adjacency" + "|"
|
||||
adjLsaData = m_origRouter.toUri() + "|" + AdjLsa::TYPE_STRING + "|"
|
||||
+ boost::lexical_cast<std::string>(m_lsSeqNo) + "|"
|
||||
+ ndn::time::toIsoString(m_expirationTimePoint);
|
||||
adjLsaData += "|";
|
||||
@@ -273,12 +283,16 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != AdjLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numLink = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numLink; i++) {
|
||||
@@ -286,10 +300,11 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
ndn::Name adjName(*tok_iter++);
|
||||
std::string connectingFaceUri(*tok_iter++);
|
||||
double linkCost = boost::lexical_cast<double>(*tok_iter++);
|
||||
Adjacent adjacent(adjName, connectingFaceUri, linkCost, 0, 0, 0);
|
||||
Adjacent adjacent(adjName, connectingFaceUri, linkCost, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
addAdjacent(adjacent);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -317,22 +332,30 @@ AdjLsa::removeNptEntries(Nlsr& pnlsr)
|
||||
void
|
||||
AdjLsa::writeLog()
|
||||
{
|
||||
_LOG_DEBUG("Adj Lsa: ");
|
||||
_LOG_DEBUG(" Origination Router: " << m_origRouter);
|
||||
_LOG_DEBUG(" Ls Type: " << m_lsType);
|
||||
_LOG_DEBUG(" Ls Seq No: " << m_lsSeqNo);
|
||||
_LOG_DEBUG(" Ls Lifetime: " << m_expirationTimePoint);
|
||||
_LOG_DEBUG(" Adjacents: ");
|
||||
int i = 1;
|
||||
std::list<Adjacent> al = m_adl.getAdjList();
|
||||
for (std::list<Adjacent>::iterator it = al.begin(); it != al.end(); it++)
|
||||
{
|
||||
_LOG_DEBUG(" Adjacent " << i << ": ");;
|
||||
_LOG_DEBUG(" Adjacent Name: " << (*it).getName());
|
||||
_LOG_DEBUG(" Connecting FaceUri: " << (*it).getConnectingFaceUri());
|
||||
_LOG_DEBUG(" Link Cost: " << (*it).getLinkCost());
|
||||
}
|
||||
_LOG_DEBUG("adj_lsa_end");
|
||||
_LOG_DEBUG(*this);
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const AdjLsa& adjLsa)
|
||||
{
|
||||
os << "Adj Lsa:\n"
|
||||
<< " Origination Router: " << adjLsa.getOrigRouter() << "\n"
|
||||
<< " Ls Type: " << adjLsa.getLsType() << "\n"
|
||||
<< " Ls Seq No: " << adjLsa.getLsSeqNo() << "\n"
|
||||
<< " Ls Lifetime: " << adjLsa.getExpirationTimePoint() << "\n"
|
||||
<< " Adjacents: \n";
|
||||
|
||||
int adjacencyIndex = 1;
|
||||
|
||||
for (const Adjacent& adjacency : adjLsa) {
|
||||
os << " Adjacent " << adjacencyIndex++ << ":\n"
|
||||
<< " Adjacent Name: " << adjacency.getName() << "\n"
|
||||
<< " Connecting FaceUri: " << adjacency.getConnectingFaceUri() << "\n"
|
||||
<< " Link Cost: " << adjacency.getLinkCost() << "\n";
|
||||
}
|
||||
os << "adj_lsa_end";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
+40
-24
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,10 +17,8 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_LSA_HPP
|
||||
#define NLSR_LSA_HPP
|
||||
|
||||
@@ -33,24 +32,20 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Lsa
|
||||
{
|
||||
public:
|
||||
Lsa()
|
||||
Lsa(const std::string& lsaType)
|
||||
: m_origRouter()
|
||||
, m_lsType(lsaType)
|
||||
, m_lsSeqNo()
|
||||
, m_expirationTimePoint()
|
||||
, m_expiringEventId()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setLsType(const std::string& lst)
|
||||
{
|
||||
m_lsType = lst;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getLsType() const
|
||||
{
|
||||
@@ -107,7 +102,7 @@ public:
|
||||
|
||||
protected:
|
||||
ndn::Name m_origRouter;
|
||||
std::string m_lsType;
|
||||
const std::string m_lsType;
|
||||
uint32_t m_lsSeqNo;
|
||||
ndn::time::system_clock::TimePoint m_expirationTimePoint;
|
||||
ndn::EventId m_expiringEventId;
|
||||
@@ -117,13 +112,12 @@ class NameLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
NameLsa()
|
||||
: Lsa()
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
, m_npl()
|
||||
{
|
||||
setLsType("name");
|
||||
}
|
||||
|
||||
NameLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl);
|
||||
|
||||
@@ -159,20 +153,22 @@ public:
|
||||
|
||||
private:
|
||||
NamePrefixList m_npl;
|
||||
|
||||
public:
|
||||
static const std::string TYPE_STRING;
|
||||
};
|
||||
|
||||
class AdjLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
typedef AdjacencyList::const_iterator const_iterator;
|
||||
|
||||
AdjLsa()
|
||||
: Lsa()
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
, m_adl()
|
||||
{
|
||||
setLsType("adjacency");
|
||||
}
|
||||
|
||||
AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl);
|
||||
|
||||
@@ -215,23 +211,38 @@ public:
|
||||
void
|
||||
writeLog();
|
||||
|
||||
public:
|
||||
const_iterator
|
||||
begin() const
|
||||
{
|
||||
return m_adl.begin();
|
||||
}
|
||||
|
||||
const_iterator
|
||||
end() const
|
||||
{
|
||||
return m_adl.end();
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t m_noLink;
|
||||
AdjacencyList m_adl;
|
||||
|
||||
public:
|
||||
static const std::string TYPE_STRING;
|
||||
};
|
||||
|
||||
class CoordinateLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
CoordinateLsa()
|
||||
: Lsa()
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
, m_corRad(0)
|
||||
, m_corTheta(0)
|
||||
{
|
||||
setLsType("coordinate");
|
||||
}
|
||||
|
||||
CoordinateLsa(const ndn::Name& origR, const std::string lst, uint32_t lsn,
|
||||
CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta);
|
||||
|
||||
@@ -278,8 +289,13 @@ private:
|
||||
double m_corRad;
|
||||
double m_corTheta;
|
||||
|
||||
public:
|
||||
static const std::string TYPE_STRING;
|
||||
};
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const AdjLsa& adjLsa);
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
#endif //NLSR_LSA_HPP
|
||||
+289
-234
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,31 +17,121 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "lsdb.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "publisher/segment-publisher.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("Lsdb");
|
||||
|
||||
const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
|
||||
class LsaContentPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
public:
|
||||
LsaContentPublisher(ndn::Face& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
const ndn::time::milliseconds& freshnessPeriod,
|
||||
const std::string& content)
|
||||
: SegmentPublisher(face, keyChain, freshnessPeriod)
|
||||
, m_content(content)
|
||||
{
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) {
|
||||
size_t totalLength = 0;
|
||||
totalLength += outBuffer.prependByteArray(reinterpret_cast<const uint8_t*>(m_content.c_str()),
|
||||
m_content.size());
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_content;
|
||||
};
|
||||
|
||||
const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
|
||||
const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
|
||||
const steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE = steady_clock::TimePoint::min();
|
||||
|
||||
Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
, m_sync(sync)
|
||||
, m_lsaRefreshTime(0)
|
||||
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Failed to fetch LSA: " << lsaName << ", Error code: " << errorCode
|
||||
<< ", Message: " << msg);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
// If the SegmentFetcher failed due to an Interest timeout, it is safe to re-express
|
||||
// immediately since at the least the LSA Interest lifetime has elapsed.
|
||||
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
||||
// the potential for constant Interest flooding.
|
||||
ndn::time::seconds delay = m_nlsr.getConfParameter().getLsaInterestLifetime();
|
||||
|
||||
if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||
delay = ndn::time::seconds(0);
|
||||
}
|
||||
|
||||
m_scheduler.scheduleEvent(delay, std::bind(&Lsdb::expressInterest, this,
|
||||
interestName, retransmitNo + 1, deadline));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, ndn::Name& interestName)
|
||||
{
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(ndn::Name(interestName));
|
||||
data->setContent(bufferPtr);
|
||||
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data->getName());
|
||||
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo > m_highestSeqNo[lsaName]) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo < m_highestSeqNo[lsaName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
onContentValidated(data);
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
|
||||
{
|
||||
m_nlsr.getScheduler().cancelEvent(eid);
|
||||
m_scheduler.cancelEvent(eid);
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -49,12 +140,10 @@ nameLsaCompareByKey(const NameLsa& nlsa1, const ndn::Name& key)
|
||||
return nlsa1.getKey() == key;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::buildAndInstallOwnNameLsa()
|
||||
{
|
||||
NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
"name",
|
||||
m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getNamePrefixList());
|
||||
@@ -93,9 +182,8 @@ ndn::EventId
|
||||
Lsdb::scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_nlsr.getScheduler().scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshNameLsa,
|
||||
this, key, seqNo));
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshNameLsa, this, key, seqNo));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -153,6 +241,9 @@ Lsdb::installNameLsa(NameLsa& nlsa)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chkNameLsa->getNpl().sort();
|
||||
|
||||
std::list<ndn::Name> nameToRemove;
|
||||
std::set_difference(chkNameLsa->getNpl().getNameList().begin(),
|
||||
chkNameLsa->getNpl().getNameList().end(),
|
||||
@@ -246,6 +337,12 @@ Lsdb::writeNameLsdbLog()
|
||||
}
|
||||
}
|
||||
|
||||
const std::list<NameLsa>&
|
||||
Lsdb::getNameLsdb()
|
||||
{
|
||||
return m_nameLsdb;
|
||||
}
|
||||
|
||||
// Cor LSA and LSDB related Functions start here
|
||||
|
||||
static bool
|
||||
@@ -258,13 +355,19 @@ bool
|
||||
Lsdb::buildAndInstallOwnCoordinateLsa()
|
||||
{
|
||||
CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
"coordinate",
|
||||
m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getConfParameter().getCorR(),
|
||||
m_nlsr.getConfParameter().getCorTheta());
|
||||
m_nlsr.getSequencingManager().increaseCorLsaSeq();
|
||||
|
||||
// Sync coordinate LSAs if using HR or HR dry run.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getSequencingManager().increaseCorLsaSeq();
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
|
||||
installCoordinateLsa(corLsa);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -299,9 +402,9 @@ ndn::EventId
|
||||
Lsdb::scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_nlsr.getScheduler().scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
|
||||
this, key, seqNo));
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshCoordinateLsa,
|
||||
this, key, seqNo));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -315,11 +418,12 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
clsa.writeLog();
|
||||
addCoordinateLsa(clsa);
|
||||
|
||||
// Register the LSA's origin router prefix
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
|
||||
clsa.getOrigRouter());
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
@@ -383,12 +487,12 @@ Lsdb::removeCoordinateLsa(const ndn::Name& key)
|
||||
_1, key));
|
||||
if (it != m_corLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
(*it).writeLog();
|
||||
if ((*it).getOrigRouter() !=
|
||||
m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
|
||||
(*it).getOrigRouter());
|
||||
it->writeLog();
|
||||
|
||||
if (it->getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry(it->getOrigRouter(), it->getOrigRouter());
|
||||
}
|
||||
|
||||
m_corLsdb.erase(it);
|
||||
return true;
|
||||
}
|
||||
@@ -418,6 +522,12 @@ Lsdb::writeCorLsdbLog()
|
||||
}
|
||||
}
|
||||
|
||||
const std::list<CoordinateLsa>&
|
||||
Lsdb::getCoordinateLsdb()
|
||||
{
|
||||
return m_corLsdb;
|
||||
}
|
||||
|
||||
// Adj LSA and LSDB related function starts here
|
||||
|
||||
static bool
|
||||
@@ -427,34 +537,57 @@ adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::scheduledAdjLsaBuild()
|
||||
Lsdb::scheduleAdjLsaBuild()
|
||||
{
|
||||
_LOG_DEBUG("scheduledAdjLsaBuild Called");
|
||||
m_nlsr.incrementAdjBuildCount();
|
||||
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
// Don't build adjacency LSAs in hyperbolic routing
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
_LOG_DEBUG("Scheduling Adjacency LSA build in " << m_adjLsaBuildInterval);
|
||||
|
||||
m_scheduler.scheduleEvent(m_adjLsaBuildInterval, ndn::bind(&Lsdb::buildAdjLsa, this));
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::buildAdjLsa()
|
||||
{
|
||||
_LOG_TRACE("Lsdb::buildAdjLsa called");
|
||||
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(false);
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
|
||||
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
|
||||
int adjBuildCount = m_nlsr.getAdjBuildCount();
|
||||
|
||||
// Is the adjacency LSA build still necessary, or has another build
|
||||
// fulfilled this request?
|
||||
if (adjBuildCount > 0) {
|
||||
if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
|
||||
_LOG_DEBUG("Building and installing Adj LSA");
|
||||
_LOG_DEBUG("Building and installing own Adj LSA");
|
||||
buildAndInstallOwnAdjLsa();
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors")
|
||||
ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
|
||||
key.append("adjacency");
|
||||
key.append(AdjLsa::TYPE_STRING);
|
||||
|
||||
removeAdjLsa(key);
|
||||
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
|
||||
// Since more adjacency LSA builds may have been scheduled while this build
|
||||
// was in progress, decrease the build count by the number of scheduled
|
||||
// builds at the beginning of this build.
|
||||
m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
|
||||
m_nlsr.getConfParameter().getInterestResendTime();
|
||||
m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(schedulingTime),
|
||||
ndn::bind(&Lsdb::scheduledAdjLsaBuild,
|
||||
this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -505,9 +638,8 @@ ndn::EventId
|
||||
Lsdb::scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const ndn::time::seconds& expTime)
|
||||
{
|
||||
return m_nlsr.getScheduler().scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshAdjLsa,
|
||||
this, key, seqNo));
|
||||
return m_scheduler.scheduleEvent(expTime + GRACE_PERIOD,
|
||||
ndn::bind(&Lsdb::exprireOrRefreshAdjLsa, this, key, seqNo));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -562,20 +694,17 @@ bool
|
||||
Lsdb::buildAndInstallOwnAdjLsa()
|
||||
{
|
||||
AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
"adjacency",
|
||||
m_nlsr.getSequencingManager().getAdjLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
|
||||
m_nlsr.getAdjacencyList());
|
||||
m_nlsr.getSequencingManager().increaseAdjLsaSeq();
|
||||
// publish routing update
|
||||
//ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
//lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
|
||||
ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
|
||||
m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
|
||||
lsaPrefix);
|
||||
|
||||
//Sync adjacency LSAs if link-state or dry-run HR is enabled.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getSequencingManager().increaseAdjLsaSeq();
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
|
||||
return installAdjLsa(adjLsa);
|
||||
}
|
||||
|
||||
@@ -607,7 +736,7 @@ Lsdb::doesAdjLsaExist(const ndn::Name& key)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::list<AdjLsa>&
|
||||
const std::list<AdjLsa>&
|
||||
Lsdb::getAdjLsdb()
|
||||
{
|
||||
return m_adjLsdb;
|
||||
@@ -620,7 +749,7 @@ Lsdb::setLsaRefreshTime(const seconds& lsaRefreshTime)
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::setThisRouterPrefix(string trp)
|
||||
Lsdb::setThisRouterPrefix(std::string trp)
|
||||
{
|
||||
m_thisRouterPrefix = trp;
|
||||
}
|
||||
@@ -647,14 +776,7 @@ Lsdb::exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
chkNameLsa->setExpiringEventId(scheduleNameLsaExpiration(chkNameLsa->getKey(),
|
||||
chkNameLsa->getLsSeqNo(),
|
||||
m_lsaRefreshTime));
|
||||
// publish routing update
|
||||
//ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
//lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
|
||||
ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
|
||||
m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
|
||||
lsaPrefix);
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Other's Name LSA, so removing form LSDB");
|
||||
@@ -686,14 +808,7 @@ Lsdb::exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo)
|
||||
chkAdjLsa->setExpiringEventId(scheduleAdjLsaExpiration(chkAdjLsa->getKey(),
|
||||
chkAdjLsa->getLsSeqNo(),
|
||||
m_lsaRefreshTime));
|
||||
// publish routing update
|
||||
//ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
//lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
|
||||
ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
|
||||
m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
|
||||
lsaPrefix);
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Other's Adj LSA, so removing form LSDB");
|
||||
@@ -720,7 +835,10 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
|
||||
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
}
|
||||
|
||||
chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
|
||||
_LOG_DEBUG("Adding Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
@@ -729,84 +847,85 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
chkCorLsa->getKey(),
|
||||
chkCorLsa->getLsSeqNo(),
|
||||
m_lsaRefreshTime));
|
||||
// publish routing update
|
||||
//ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
//lsaPrefix.append(m_nlsr.getConfParameter().getRouterPrefix());
|
||||
ndn::Name lsaPrefix = m_nlsr.getConfParameter().getLsaPrefix();
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getSiteName());
|
||||
lsaPrefix.append(m_nlsr.getConfParameter().getRouterName());
|
||||
m_nlsr.getSyncLogicHandler().publishRoutingUpdate(m_nlsr.getSequencingManager(),
|
||||
lsaPrefix);
|
||||
// Only sync coordinate LSAs if link-state routing is disabled
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Other's Cor LSA, so removing form LSDB");
|
||||
removeCoordinateLsa(lsaKey);
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline/* = steady_clock::TimePoint::min()*/)
|
||||
steady_clock::TimePoint deadline)
|
||||
{
|
||||
if (deadline == steady_clock::TimePoint::min()) {
|
||||
deadline = steady_clock::now() + m_lsaRefreshTime;
|
||||
if (deadline == DEFAULT_LSA_RETRIEVAL_DEADLINE) {
|
||||
deadline = steady_clock::now() + ndn::time::seconds(static_cast<int>(LSA_REFRESH_TIME_MAX));
|
||||
}
|
||||
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo > m_highestSeqNo[lsaName]) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo < m_highestSeqNo[lsaName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
uint64_t interestedLsSeqNo = interestName[-1].toNumber();
|
||||
_LOG_DEBUG("Expressing Interest for LSA(name): " << interestName
|
||||
<< " Seq number: " << interestedLsSeqNo);
|
||||
interest.setInterestLifetime(m_nlsr.getConfParameter().getLsaInterestLifetime());
|
||||
m_nlsr.getNlsrFace().expressInterest(interest,
|
||||
ndn::bind(&Lsdb::onContent,
|
||||
this, _2, deadline),
|
||||
ndn::bind(&Lsdb::processInterestTimedOut,
|
||||
this, _1, timeoutCount, deadline));
|
||||
|
||||
_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
|
||||
m_nlsr.getValidator(),
|
||||
ndn::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
|
||||
ndn::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
|
||||
timeoutCount, deadline, lsaName, seqNo));
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
{
|
||||
const ndn::Name& intName(interest.getName());
|
||||
_LOG_DEBUG("Interest recevied for LSA(name): " << intName);
|
||||
string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(),
|
||||
chkString);
|
||||
const ndn::Name& interestName(interest.getName());
|
||||
_LOG_DEBUG("Interest received for LSA: " << interestName);
|
||||
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
std::string interestedLsType;
|
||||
uint64_t interestedLsSeqNo;
|
||||
ndn::Name origRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
origRouter.append(intName.getSubName(lsaPosition + 1,
|
||||
interest.getName().size() - lsaPosition - 3));
|
||||
interestedLsType = intName[-2].toUri();
|
||||
interestedLsSeqNo = intName[-1].toNumber();
|
||||
_LOG_DEBUG("LSA sequence number from interest: " << interestedLsSeqNo);
|
||||
if (interestedLsType == "name") {
|
||||
processInterestForNameLsa(interest,
|
||||
origRouter.append(interestedLsType),
|
||||
interestedLsSeqNo);
|
||||
return;
|
||||
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
originRouter.append(interestName.getSubName(lsaPosition + 1,
|
||||
interest.getName().size() - lsaPosition - 3));
|
||||
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
_LOG_DEBUG("LSA sequence number from interest: " << seqNo);
|
||||
|
||||
std::string interestedLsType = interestName[-2].toUri();
|
||||
|
||||
if (interestedLsType == NameLsa::TYPE_STRING) {
|
||||
processInterestForNameLsa(interest, originRouter.append(interestedLsType), seqNo);
|
||||
}
|
||||
else if (interestedLsType == "adjacency") {
|
||||
processInterestForAdjacencyLsa(interest,
|
||||
origRouter.append(interestedLsType),
|
||||
interestedLsSeqNo);
|
||||
return;
|
||||
else if (interestedLsType == AdjLsa::TYPE_STRING) {
|
||||
processInterestForAdjacencyLsa(interest, originRouter.append(interestedLsType), seqNo);
|
||||
}
|
||||
else if (interestedLsType == "coordinate") {
|
||||
processInterestForCoordinateLsa(interest,
|
||||
origRouter.append(interestedLsType),
|
||||
interestedLsSeqNo);
|
||||
return;
|
||||
else if (interestedLsType == CoordinateLsa::TYPE_STRING) {
|
||||
processInterestForCoordinateLsa(interest, originRouter.append(interestedLsType), seqNo);
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Unrecognized LSA Type :(");
|
||||
_LOG_WARN("Received unrecognized LSA type: " << interestedLsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -814,26 +933,22 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
void
|
||||
Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
|
||||
{
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(m_lsaRefreshTime);
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
|
||||
m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
|
||||
ndn::SignatureSha256WithRsa signature(data->getSignature());
|
||||
ndn::Name signingCertName = signature.getKeyLocator().getName();
|
||||
_LOG_DEBUG("Sending data for LSA(name): " << interest.getName());
|
||||
_LOG_DEBUG("Data signed with: " << signingCertName);
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
|
||||
m_nlsr.getKeyChain(),
|
||||
m_lsaRefreshTime,
|
||||
content);
|
||||
publisher.publish(interest.getName(),
|
||||
ndn::security::signingByCertificate(m_nlsr.getDefaultCertName()));
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint32_t interestedlsSeqNo)
|
||||
uint64_t seqNo)
|
||||
{
|
||||
NameLsa* nameLsa = m_nlsr.getLsdb().findNameLsa(lsaKey);
|
||||
if (nameLsa != 0) {
|
||||
if (nameLsa->getLsSeqNo() >= interestedlsSeqNo) {
|
||||
if (nameLsa->getLsSeqNo() == seqNo) {
|
||||
std::string content = nameLsa->getData();
|
||||
putLsaData(interest,content);
|
||||
}
|
||||
@@ -843,11 +958,15 @@ Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
|
||||
void
|
||||
Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint32_t interestedlsSeqNo)
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
_LOG_ERROR("Received interest for an adjacency LSA when hyperbolic routing is enabled.");
|
||||
}
|
||||
|
||||
AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
|
||||
if (adjLsa != 0) {
|
||||
if (adjLsa->getLsSeqNo() >= interestedlsSeqNo) {
|
||||
if (adjLsa->getLsSeqNo() == seqNo) {
|
||||
std::string content = adjLsa->getData();
|
||||
putLsaData(interest,content);
|
||||
}
|
||||
@@ -857,110 +976,58 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
void
|
||||
Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint32_t interestedlsSeqNo)
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
_LOG_ERROR("Received Interest for a coordinate LSA when link-state routing is enabled.");
|
||||
}
|
||||
|
||||
CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
|
||||
if (corLsa != 0) {
|
||||
if (corLsa->getLsSeqNo() >= interestedlsSeqNo) {
|
||||
if (corLsa->getLsSeqNo() == seqNo) {
|
||||
std::string content = corLsa->getData();
|
||||
putLsaData(interest,content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContent(const ndn::Data& data,
|
||||
const steady_clock::TimePoint& deadline)
|
||||
{
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data.getName());
|
||||
if (data.getSignature().hasKeyLocator()) {
|
||||
if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline)
|
||||
{
|
||||
_LOG_DEBUG("Retrying validation of LSA(name): " << data->getName());
|
||||
if (data->getSignature().hasKeyLocator()) {
|
||||
if (data->getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data->getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(*data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline));
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
|
||||
{
|
||||
const ndn::Name& dataName = data->getName();
|
||||
_LOG_DEBUG("Data validation successful for LSA(name): " << dataName);
|
||||
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
string chkString("LSA");
|
||||
_LOG_DEBUG("Data validation successful for LSA: " << dataName);
|
||||
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
std::string interestedLsType;
|
||||
uint64_t interestedLsSeqNo;
|
||||
ndn::Name origRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
origRouter.append(dataName.getSubName(lsaPosition + 1,
|
||||
dataName.size() - lsaPosition - 4));
|
||||
interestedLsType = dataName[-3].toUri();
|
||||
interestedLsSeqNo = dataName[-2].toNumber();
|
||||
if (interestedLsType == "name") {
|
||||
processContentNameLsa(origRouter.append(interestedLsType),
|
||||
interestedLsSeqNo, dataContent);
|
||||
return;
|
||||
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 3));
|
||||
|
||||
uint64_t seqNo = dataName[-1].toNumber();
|
||||
std::string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
|
||||
std::string interestedLsType = dataName[-2].toUri();
|
||||
|
||||
if (interestedLsType == NameLsa::TYPE_STRING) {
|
||||
processContentNameLsa(originRouter.append(interestedLsType), seqNo, dataContent);
|
||||
}
|
||||
else if (interestedLsType == "adjacency") {
|
||||
processContentAdjacencyLsa(origRouter.append(interestedLsType),
|
||||
interestedLsSeqNo, dataContent);
|
||||
return;
|
||||
else if (interestedLsType == AdjLsa::TYPE_STRING) {
|
||||
processContentAdjacencyLsa(originRouter.append(interestedLsType), seqNo, dataContent);
|
||||
}
|
||||
else if (interestedLsType == "coordinate") {
|
||||
processContentCoordinateLsa(origRouter.append(interestedLsType),
|
||||
interestedLsSeqNo, dataContent);
|
||||
return;
|
||||
else if (interestedLsType == CoordinateLsa::TYPE_STRING) {
|
||||
processContentCoordinateLsa(originRouter.append(interestedLsType), seqNo, dataContent);
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Unrecognized LSA Type :(");
|
||||
_LOG_WARN("Received unrecognized LSA Type: " << interestedLsType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg,
|
||||
const steady_clock::TimePoint& deadline)
|
||||
{
|
||||
_LOG_DEBUG("Validation Error: " << msg);
|
||||
|
||||
// Delay re-validation by LSA Interest Lifetime. When error callback will have an error
|
||||
// code, re-validation should be done only when some keys from certification chain failed
|
||||
// to be fetched. After that change, delaying will no longer be necessary.
|
||||
|
||||
// Stop retrying if delayed re-validation will be scheduled pass the deadline
|
||||
if (steady_clock::now() + m_nlsr.getConfParameter().getLsaInterestLifetime() < deadline) {
|
||||
_LOG_DEBUG("Scheduling revalidation");
|
||||
m_nlsr.getScheduler().scheduleEvent(m_nlsr.getConfParameter().getLsaInterestLifetime(),
|
||||
ndn::bind(&Lsdb::retryContentValidation,
|
||||
this, data, deadline));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
|
||||
uint32_t lsSeqNo, std::string& dataContent)
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
{
|
||||
if (isNameLsaNew(lsaKey, lsSeqNo)) {
|
||||
NameLsa nameLsa;
|
||||
@@ -975,7 +1042,7 @@ Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
|
||||
|
||||
void
|
||||
Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
|
||||
uint32_t lsSeqNo, std::string& dataContent)
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
{
|
||||
if (isAdjLsaNew(lsaKey, lsSeqNo)) {
|
||||
AdjLsa adjLsa;
|
||||
@@ -990,7 +1057,7 @@ Lsdb::processContentAdjacencyLsa(const ndn::Name& lsaKey,
|
||||
|
||||
void
|
||||
Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint32_t lsSeqNo, std::string& dataContent)
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
{
|
||||
if (isCoordinateLsaNew(lsaKey, lsSeqNo)) {
|
||||
CoordinateLsa corLsa;
|
||||
@@ -1003,18 +1070,6 @@ Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline)
|
||||
{
|
||||
const ndn::Name& interestName = interest.getName();
|
||||
_LOG_DEBUG("Interest timed out for LSA(name): " << interestName);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
expressInterest(interestName, retransmitNo + 1, deadline);
|
||||
}
|
||||
}
|
||||
|
||||
ndn::time::system_clock::TimePoint
|
||||
Lsdb::getLsaExpirationTimePoint()
|
||||
{
|
||||
@@ -1038,13 +1093,13 @@ Lsdb::writeAdjLsdbLog()
|
||||
bool
|
||||
Lsdb::doesLsaExist(const ndn::Name& key, const std::string& lsType)
|
||||
{
|
||||
if (lsType == "name") {
|
||||
if (lsType == NameLsa::TYPE_STRING) {
|
||||
return doesNameLsaExist(key);
|
||||
}
|
||||
else if (lsType == "adjacency") {
|
||||
else if (lsType == AdjLsa::TYPE_STRING) {
|
||||
return doesAdjLsaExist(key);
|
||||
}
|
||||
else if (lsType == "coordinate") {
|
||||
else if (lsType == CoordinateLsa::TYPE_STRING) {
|
||||
return doesCoordinateLsaExist(key);
|
||||
}
|
||||
return false;
|
||||
|
||||
+99
-53
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,40 +17,37 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_LSDB_HPP
|
||||
#define NLSR_LSDB_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
#include "lsa.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
using namespace ndn::time;
|
||||
|
||||
class Nlsr;
|
||||
class SyncLogicHandler;
|
||||
|
||||
class Lsdb
|
||||
{
|
||||
public:
|
||||
Lsdb(Nlsr& nlsr)
|
||||
: m_nlsr(nlsr)
|
||||
, m_lsaRefreshTime(0)
|
||||
{
|
||||
}
|
||||
|
||||
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync);
|
||||
|
||||
bool
|
||||
doesLsaExist(const ndn::Name& key, const std::string& lsType);
|
||||
// function related to Name LSDB
|
||||
|
||||
// functions related to Name LSDB
|
||||
bool
|
||||
buildAndInstallOwnNameLsa();
|
||||
|
||||
@@ -68,7 +66,10 @@ public:
|
||||
void
|
||||
writeNameLsdbLog();
|
||||
|
||||
//function related to Cor LSDB
|
||||
const std::list<NameLsa>&
|
||||
getNameLsdb();
|
||||
|
||||
// functions related to Cor LSDB
|
||||
bool
|
||||
buildAndInstallOwnCoordinateLsa();
|
||||
|
||||
@@ -87,9 +88,12 @@ public:
|
||||
void
|
||||
writeCorLsdbLog();
|
||||
|
||||
//function related to Adj LSDB
|
||||
const std::list<CoordinateLsa>&
|
||||
getCoordinateLsdb();
|
||||
|
||||
// functions related to Adj LSDB
|
||||
void
|
||||
scheduledAdjLsaBuild();
|
||||
scheduleAdjLsaBuild();
|
||||
|
||||
bool
|
||||
buildAndInstallOwnAdjLsa();
|
||||
@@ -99,15 +103,28 @@ public:
|
||||
|
||||
bool
|
||||
isAdjLsaNew(const ndn::Name& key, uint64_t seqNo);
|
||||
|
||||
bool
|
||||
installAdjLsa(AdjLsa& alsa);
|
||||
|
||||
AdjLsa*
|
||||
findAdjLsa(const ndn::Name& key);
|
||||
|
||||
std::list<AdjLsa>&
|
||||
const std::list<AdjLsa>&
|
||||
getAdjLsdb();
|
||||
|
||||
void
|
||||
setAdjLsaBuildInterval(uint32_t interval)
|
||||
{
|
||||
m_adjLsaBuildInterval = ndn::time::seconds(interval);
|
||||
}
|
||||
|
||||
const ndn::time::seconds&
|
||||
getAdjLsaBuildInterval() const
|
||||
{
|
||||
return m_adjLsaBuildInterval;
|
||||
}
|
||||
|
||||
void
|
||||
writeAdjLsdbLog();
|
||||
|
||||
@@ -117,6 +134,13 @@ public:
|
||||
void
|
||||
setThisRouterPrefix(std::string trp);
|
||||
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
bool
|
||||
addNameLsa(NameLsa& nlsa);
|
||||
@@ -131,6 +155,9 @@ private:
|
||||
bool
|
||||
doesCoordinateLsaExist(const ndn::Name& key);
|
||||
|
||||
void
|
||||
buildAdjLsa();
|
||||
|
||||
bool
|
||||
addAdjLsa(AdjLsa& alsa);
|
||||
|
||||
@@ -144,10 +171,12 @@ private:
|
||||
void
|
||||
exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
ndn::EventId
|
||||
scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
|
||||
const seconds& expTime);
|
||||
|
||||
private:
|
||||
void
|
||||
exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
|
||||
|
||||
@@ -158,80 +187,88 @@ private:
|
||||
void
|
||||
exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
public:
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = steady_clock::TimePoint::min());
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
void
|
||||
putLsaData(const ndn::Interest& interest, const std::string& content);
|
||||
|
||||
void
|
||||
processInterestForNameLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint32_t interestedlsSeqNo);
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint32_t interestedlsSeqNo);
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint32_t interestedlsSeqNo);
|
||||
|
||||
void
|
||||
onContent(const ndn::Data& data, const steady_clock::TimePoint& deadline);
|
||||
|
||||
/**
|
||||
* @brief Retry validation after it fails
|
||||
*
|
||||
* Data packet validation can fail either because the packet does not have
|
||||
* valid signature (fatal) or because some of the certificate chain Data packets
|
||||
* failed to be fetched (non-fatal). Currently, the library does not provide
|
||||
* clear indication (besides plain-text message in error callback) of what is
|
||||
* the reason for failure and we will try to re-validate for as long as it the deadline.
|
||||
*/
|
||||
void
|
||||
retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline);
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, const std::string& msg,
|
||||
const steady_clock::TimePoint& deadline);
|
||||
|
||||
void
|
||||
processContentNameLsa(const ndn::Name& lsaKey,
|
||||
uint32_t lsSeqNo, std::string& dataContent);
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
|
||||
void
|
||||
processContentAdjacencyLsa(const ndn::Name& lsaKey,
|
||||
uint32_t lsSeqNo, std::string& dataContent);
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
|
||||
void
|
||||
processContentCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint32_t lsSeqNo, std::string& dataContent);
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/**
|
||||
* @brief Error callback when SegmentFetcher fails to return an LSA
|
||||
*
|
||||
* In all error cases, a reattempt to fetch the LSA will be made.
|
||||
*
|
||||
* Segment validation can fail either because the packet does not have a
|
||||
* valid signature (fatal) or because some of the certificates in the trust chain
|
||||
* could not be fetched (non-fatal).
|
||||
*
|
||||
* Currently, the library does not provide clear indication (besides a plain-text message
|
||||
* in the error callback) of the reason for the failure nor the segment that failed
|
||||
* to be validated, thus we will continue to try to fetch the LSA until the deadline
|
||||
* is reached.
|
||||
*/
|
||||
void
|
||||
processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const steady_clock::TimePoint& deadline);
|
||||
onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
/**
|
||||
* @brief Success callback when SegmentFetcher returns a valid LSA
|
||||
*
|
||||
* \param The base Interest used to fetch the LSA in the format:
|
||||
* /<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
|
||||
*/
|
||||
void
|
||||
afterFetchLsa(const ndn::ConstBufferPtr& data, ndn::Name& interestName);
|
||||
|
||||
private:
|
||||
system_clock::TimePoint
|
||||
getLsaExpirationTimePoint();
|
||||
|
||||
private:
|
||||
void
|
||||
cancelScheduleLsaExpiringEvent(ndn::EventId eid);
|
||||
|
||||
public:
|
||||
static const ndn::Name::Component NAME_COMPONENT;
|
||||
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
SyncLogicHandler& m_sync;
|
||||
|
||||
std::list<NameLsa> m_nameLsdb;
|
||||
std::list<AdjLsa> m_adjLsdb;
|
||||
std::list<CoordinateLsa> m_corLsdb;
|
||||
@@ -239,7 +276,16 @@ private:
|
||||
seconds m_lsaRefreshTime;
|
||||
std::string m_thisRouterPrefix;
|
||||
|
||||
typedef std::map<ndn::Name, uint64_t> SequenceNumberMap;
|
||||
|
||||
// Maps the name of an LSA to its highest known sequence number from sync;
|
||||
// Used to stop NLSR from trying to fetch outdated LSAs
|
||||
SequenceNumberMap m_highestSeqNo;
|
||||
|
||||
static const ndn::time::seconds GRACE_PERIOD;
|
||||
static const steady_clock::TimePoint DEFAULT_LSA_RETRIEVAL_DEADLINE;
|
||||
|
||||
ndn::time::seconds m_adjLsaBuildInterval;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
+25
-45
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,34 +17,29 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
* \author Yingdi Yu <yingdi@cs.ucla.edu>
|
||||
*
|
||||
**/
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "nlsr.hpp"
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
#include "nlsr-runner.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
int
|
||||
main(int32_t argc, char** argv)
|
||||
{
|
||||
Nlsr nlsr;
|
||||
using namespace nlsr;
|
||||
|
||||
std::string programName(argv[0]);
|
||||
nlsr.setConfFileName("nlsr.conf");
|
||||
|
||||
std::string configFileName = "nlsr.conf";
|
||||
bool isDaemonProcess = false;
|
||||
|
||||
int32_t opt;
|
||||
while ((opt = getopt(argc, argv, "df:hV")) != -1) {
|
||||
switch (opt)
|
||||
{
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
nlsr.setConfFileName(optarg);
|
||||
configFileName = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
nlsr.setIsDaemonProcess(true);
|
||||
isDaemonProcess = true;
|
||||
break;
|
||||
case 'V':
|
||||
std::cout << NLSR_VERSION_BUILD_STRING << std::endl;
|
||||
@@ -51,36 +47,20 @@ main(int32_t argc, char** argv)
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
nlsr.usage(programName);
|
||||
NlsrRunner::printUsage(programName);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
ConfFileProcessor cfp(nlsr, nlsr.getConfFileName());
|
||||
if (!cfp.processConfFile()) {
|
||||
std::cerr << "Error in configuration file processing! Exiting from NLSR" << std::endl;
|
||||
|
||||
NlsrRunner runner(configFileName, isDaemonProcess);
|
||||
|
||||
try {
|
||||
runner.run();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
INIT_LOGGERS(nlsr.getConfParameter().getLogDir());
|
||||
INIT_LOGGER("Main");
|
||||
nlsr.initialize();
|
||||
if (nlsr.getIsSetDaemonProcess()) {
|
||||
nlsr.daemonize();
|
||||
}
|
||||
try {
|
||||
nlsr.startEventLoop();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
nlsr.getFib().clean();
|
||||
nlsr.destroyFaces();
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
int
|
||||
main(int32_t argc, char** argv)
|
||||
{
|
||||
return nlsr::main(argc, argv);
|
||||
}
|
||||
+12
-10
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,15 +17,14 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -48,7 +48,7 @@ nameCompare(const ndn::Name& name1, const ndn::Name& name2)
|
||||
return name1 == name2;
|
||||
}
|
||||
|
||||
int32_t
|
||||
bool
|
||||
NamePrefixList::insert(const ndn::Name& name)
|
||||
{
|
||||
std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
|
||||
@@ -56,13 +56,13 @@ NamePrefixList::insert(const ndn::Name& name)
|
||||
ndn::bind(&nameCompare, _1 ,
|
||||
ndn::cref(name)));
|
||||
if (it != m_nameList.end()) {
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
m_nameList.push_back(name);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t
|
||||
bool
|
||||
NamePrefixList::remove(const ndn::Name& name)
|
||||
{
|
||||
std::list<ndn::Name>::iterator it = std::find_if(m_nameList.begin(),
|
||||
@@ -71,8 +71,10 @@ NamePrefixList::remove(const ndn::Name& name)
|
||||
ndn::cref(name)));
|
||||
if (it != m_nameList.end()) {
|
||||
m_nameList.erase(it);
|
||||
return true;
|
||||
}
|
||||
return -1;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,10 +17,8 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_NAME_PREFIX_LIST_HPP
|
||||
#define NLSR_NAME_PREFIX_LIST_HPP
|
||||
|
||||
@@ -38,10 +37,16 @@ public:
|
||||
|
||||
~NamePrefixList();
|
||||
|
||||
int32_t
|
||||
/** \brief inserts name into NamePrefixList
|
||||
* \return true if the name is inserted, otherwise false
|
||||
*/
|
||||
bool
|
||||
insert(const ndn::Name& name);
|
||||
|
||||
int32_t
|
||||
/** \brief removes name from NamePrefixList
|
||||
* \return true if the name is removed, otherwise false
|
||||
*/
|
||||
bool
|
||||
remove(const ndn::Name& name);
|
||||
|
||||
void
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include "nlsr-runner.hpp"
|
||||
|
||||
#include "conf-file-processor.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("NlsrRunner");
|
||||
|
||||
NlsrRunner::NlsrRunner(std::string& configFileName, bool isDaemonProcess)
|
||||
: m_scheduler(m_ioService)
|
||||
, m_face(m_ioService)
|
||||
, m_nlsr(m_ioService, m_scheduler, m_face)
|
||||
{
|
||||
m_nlsr.setConfFileName(configFileName);
|
||||
m_nlsr.setIsDaemonProcess(isDaemonProcess);
|
||||
}
|
||||
|
||||
void
|
||||
NlsrRunner::run()
|
||||
{
|
||||
ConfFileProcessor configProcessor(m_nlsr, m_nlsr.getConfFileName());
|
||||
|
||||
if (!configProcessor.processConfFile()) {
|
||||
throw Error("Error in configuration file processing! Exiting from NLSR");
|
||||
}
|
||||
|
||||
if (m_nlsr.getConfParameter().isLog4CxxConfAvailable()) {
|
||||
INIT_LOG4CXX(m_nlsr.getConfParameter().getLog4CxxConfPath());
|
||||
}
|
||||
else {
|
||||
INIT_LOGGERS(m_nlsr.getConfParameter().getLogDir(), m_nlsr.getConfParameter().getLogLevel());
|
||||
}
|
||||
|
||||
m_nlsr.initialize();
|
||||
|
||||
if (m_nlsr.getIsSetDaemonProcess()) {
|
||||
m_nlsr.daemonize();
|
||||
}
|
||||
|
||||
try {
|
||||
m_nlsr.startEventLoop();
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_FATAL("ERROR: " << e.what());
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
|
||||
m_nlsr.getFib().clean();
|
||||
m_nlsr.destroyFaces();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NlsrRunner::printUsage(const std::string& programName)
|
||||
{
|
||||
std::cout << "Usage: " << programName << " [OPTIONS...]" << std::endl;
|
||||
std::cout << " NDN routing...." << std::endl;
|
||||
std::cout << " -d Run in daemon mode" << 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
|
||||
@@ -0,0 +1,66 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#ifndef NLSR_NLSR_RUNNER_HPP
|
||||
#define NLSR_NLSR_RUNNER_HPP
|
||||
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
|
||||
// boost needs to be included after ndn-cxx, otherwise there will be conflict with _1, _2, ...
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class NlsrRunner
|
||||
{
|
||||
public:
|
||||
class Error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
Error(const std::string& what)
|
||||
: std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
NlsrRunner(std::string& configFileName, bool isDaemonProcess);
|
||||
|
||||
void
|
||||
run();
|
||||
|
||||
static void
|
||||
printUsage(const std::string& programName);
|
||||
|
||||
private:
|
||||
boost::asio::io_service m_ioService;
|
||||
ndn::Scheduler m_scheduler;
|
||||
ndn::Face m_face;
|
||||
|
||||
Nlsr m_nlsr;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_NLSR_RUNNER_HPP
|
||||
+159
-51
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,10 +17,8 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@@ -35,9 +34,50 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER("nlsr");
|
||||
|
||||
const ndn::Name Nlsr::LOCALHOST_PREFIX = ndn::Name("/localhost/nlsr");
|
||||
|
||||
using namespace ndn;
|
||||
using namespace std;
|
||||
|
||||
Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face)
|
||||
: m_nlsrFace(face)
|
||||
, m_scheduler(scheduler)
|
||||
, m_confParam()
|
||||
, m_adjacencyList()
|
||||
, m_namePrefixList()
|
||||
, m_sequencingManager()
|
||||
, m_isDaemonProcess(false)
|
||||
, m_configFileName("nlsr.conf")
|
||||
, m_nlsrLsdb(*this, scheduler, m_syncLogicHandler)
|
||||
, 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_syncLogicHandler(m_nlsrFace, m_nlsrLsdb, m_confParam, m_sequencingManager)
|
||||
, m_lsdbDatasetHandler(m_nlsrLsdb,
|
||||
m_nlsrFace,
|
||||
m_keyChain)
|
||||
, m_helloProtocol(*this, scheduler)
|
||||
, m_certificateCache(new ndn::CertificateCacheTtl(ioService))
|
||||
, m_validator(m_nlsrFace, DEFAULT_BROADCAST_PREFIX, m_certificateCache, m_certStore)
|
||||
, m_prefixUpdateProcessor(m_nlsrFace,
|
||||
m_namePrefixList,
|
||||
m_nlsrLsdb,
|
||||
m_syncLogicHandler,
|
||||
DEFAULT_BROADCAST_PREFIX,
|
||||
m_keyChain,
|
||||
m_certificateCache,
|
||||
m_certStore)
|
||||
, m_faceMonitor(m_nlsrFace)
|
||||
, m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
|
||||
{
|
||||
m_faceMonitor.onNotification.connect(bind(&Nlsr::onFaceEventNotification, this, _1));
|
||||
m_faceMonitor.start();
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registrationFailed(const ndn::Name& name)
|
||||
{
|
||||
@@ -48,6 +88,20 @@ Nlsr::registrationFailed(const ndn::Name& name)
|
||||
void
|
||||
Nlsr::onRegistrationSuccess(const ndn::Name& name)
|
||||
{
|
||||
_LOG_DEBUG("Successfully registered prefix: " << name);
|
||||
|
||||
if (name.equals(m_confParam.getRouterPrefix())) {
|
||||
m_lsdbDatasetHandler.startListeningOnRouterPrefix();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::onLocalhostRegistrationSuccess(const ndn::Name& name)
|
||||
{
|
||||
_LOG_DEBUG("Successfully registered prefix: " << name);
|
||||
|
||||
m_prefixUpdateProcessor.startListening();
|
||||
m_lsdbDatasetHandler.startListeningOnLocalhost();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -56,11 +110,11 @@ Nlsr::setInfoInterestFilter()
|
||||
ndn::Name name(m_confParam.getRouterPrefix());
|
||||
_LOG_DEBUG("Setting interest filter for name: " << name);
|
||||
getNlsrFace().setInterestFilter(name,
|
||||
ndn::bind(&HelloProtocol::processInterest,
|
||||
std::bind(&HelloProtocol::processInterest,
|
||||
&m_helloProtocol, _1, _2),
|
||||
ndn::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_defaultIdentity,
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
@@ -72,20 +126,22 @@ Nlsr::setLsaInterestFilter()
|
||||
name.append(m_confParam.getRouterName());
|
||||
_LOG_DEBUG("Setting interest filter for name: " << name);
|
||||
getNlsrFace().setInterestFilter(name,
|
||||
ndn::bind(&Lsdb::processInterest,
|
||||
std::bind(&Lsdb::processInterest,
|
||||
&m_nlsrLsdb, _1, _2),
|
||||
ndn::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_defaultIdentity,
|
||||
std::bind(&Nlsr::onRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::setStrategies()
|
||||
{
|
||||
std::string strategy("ndn:/localhost/nfd/strategy/broadcast");
|
||||
const std::string strategy("ndn:/localhost/nfd/strategy/multicast");
|
||||
|
||||
ndn::Name broadcastKeyPrefix = DEFAULT_BROADCAST_PREFIX;
|
||||
broadcastKeyPrefix.append("KEYS");
|
||||
|
||||
m_fib.setStrategy(m_confParam.getLsaPrefix(), strategy, 0);
|
||||
m_fib.setStrategy(broadcastKeyPrefix, strategy, 0);
|
||||
m_fib.setStrategy(m_confParam.getChronosyncPrefix(), strategy, 0);
|
||||
@@ -122,12 +178,15 @@ Nlsr::initialize()
|
||||
{
|
||||
_LOG_DEBUG("Initializing Nlsr");
|
||||
m_confParam.buildRouterPrefix();
|
||||
m_lsdbDatasetHandler.setRouterNameCommandPrefix(m_confParam.getRouterPrefix());
|
||||
m_nlsrLsdb.setLsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()));
|
||||
m_nlsrLsdb.setThisRouterPrefix(m_confParam.getRouterPrefix().toUri());
|
||||
m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
|
||||
m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
|
||||
m_sequencingManager.initiateSeqNoFromFile();
|
||||
m_syncLogicHandler.setSyncPrefix(m_confParam.getChronosyncPrefix().toUri());
|
||||
m_sequencingManager.initiateSeqNoFromFile(m_confParam.getHyperbolicState());
|
||||
|
||||
m_syncLogicHandler.createSyncSocket(m_confParam.getChronosyncPrefix());
|
||||
|
||||
/* Logging start */
|
||||
m_confParam.writeLog();
|
||||
m_adjacencyList.writeLog();
|
||||
@@ -135,31 +194,52 @@ Nlsr::initialize()
|
||||
/* Logging end */
|
||||
initializeKey();
|
||||
setStrategies();
|
||||
_LOG_DEBUG("Default NLSR identity: " << m_defaultIdentity);
|
||||
_LOG_DEBUG("Default NLSR identity: " << m_signingInfo.getSignerName());
|
||||
setInfoInterestFilter();
|
||||
setLsaInterestFilter();
|
||||
|
||||
// Set event intervals
|
||||
setFirstHelloInterval(m_confParam.getFirstHelloInterval());
|
||||
m_nlsrLsdb.setAdjLsaBuildInterval(m_confParam.getAdjLsaBuildInterval());
|
||||
m_routingTable.setRoutingCalcInterval(m_confParam.getRoutingCalcInterval());
|
||||
|
||||
m_nlsrLsdb.buildAndInstallOwnNameLsa();
|
||||
m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
|
||||
m_syncLogicHandler.createSyncSocket(boost::ref(*this));
|
||||
|
||||
// Install coordinate LSAs if using HR or dry-run HR.
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
|
||||
}
|
||||
|
||||
registerKeyPrefix();
|
||||
m_helloProtocol.scheduleInterest(10);
|
||||
registerLocalhostPrefix();
|
||||
|
||||
m_helloProtocol.scheduleInterest(m_firstHelloInterval);
|
||||
|
||||
// Need to set direct neighbors' costs to 0 for hyperbolic routing
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
|
||||
std::list<Adjacent>& neighbors = m_adjacencyList.getAdjList();
|
||||
|
||||
for (std::list<Adjacent>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) {
|
||||
it->setLinkCost(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::initializeKey()
|
||||
{
|
||||
m_defaultIdentity = m_confParam.getRouterPrefix();
|
||||
m_defaultIdentity.append("NLSR");
|
||||
ndn::Name defaultIdentity = m_confParam.getRouterPrefix();
|
||||
defaultIdentity.append("NLSR");
|
||||
|
||||
try
|
||||
{
|
||||
m_keyChain.deleteIdentity(m_defaultIdentity);
|
||||
try {
|
||||
m_keyChain.deleteIdentity(defaultIdentity);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
catch (std::exception& e) {
|
||||
}
|
||||
m_signingInfo = ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID, defaultIdentity);
|
||||
|
||||
ndn::Name keyName = m_keyChain.generateRsaKeyPairAsDefault(m_defaultIdentity, true);
|
||||
ndn::Name keyName = m_keyChain.generateRsaKeyPairAsDefault(defaultIdentity, true);
|
||||
|
||||
ndn::shared_ptr<ndn::IdentityCertificate> certificate =
|
||||
ndn::make_shared<ndn::IdentityCertificate>();
|
||||
@@ -187,15 +267,25 @@ Nlsr::registerKeyPrefix()
|
||||
ndn::Name keyPrefix = DEFAULT_BROADCAST_PREFIX;
|
||||
keyPrefix.append("KEYS");
|
||||
m_nlsrFace.setInterestFilter(keyPrefix,
|
||||
ndn::bind(&Nlsr::onKeyInterest,
|
||||
std::bind(&Nlsr::onKeyInterest,
|
||||
this, _1, _2),
|
||||
ndn::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_defaultIdentity,
|
||||
std::bind(&Nlsr::onKeyPrefixRegSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1),
|
||||
m_signingInfo,
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::registerLocalhostPrefix()
|
||||
{
|
||||
_LOG_TRACE("Registering prefix: " << LOCALHOST_PREFIX);
|
||||
|
||||
m_nlsrFace.registerPrefix(LOCALHOST_PREFIX,
|
||||
std::bind(&Nlsr::onLocalhostRegistrationSuccess, this, _1),
|
||||
std::bind(&Nlsr::registrationFailed, this, _1));
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::onKeyInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
{
|
||||
@@ -247,8 +337,8 @@ Nlsr::destroyFaces()
|
||||
for (std::list<Adjacent>::iterator it = adjacents.begin();
|
||||
it != adjacents.end(); it++) {
|
||||
m_fib.destroyFace((*it).getConnectingFaceUri(),
|
||||
ndn::bind(&Nlsr::onDestroyFaceSuccess, this, _1),
|
||||
ndn::bind(&Nlsr::onDestroyFaceFailure, this, _1, _2));
|
||||
std::bind(&Nlsr::onDestroyFaceSuccess, this, _1),
|
||||
std::bind(&Nlsr::onDestroyFaceFailure, this, _1, _2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,15 +348,45 @@ Nlsr::destroyFaces()
|
||||
void
|
||||
Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification)
|
||||
{
|
||||
_LOG_TRACE("Nlsr::onFaceEventNotification called");
|
||||
ndn::nfd::FaceEventKind kind = faceEventNotification.getKind();
|
||||
_LOG_DEBUG("Nlsr::onFaceEventNotification called");
|
||||
|
||||
if (kind == ndn::nfd::FACE_EVENT_DESTROYED) {
|
||||
uint64_t faceId = faceEventNotification.getFaceId();
|
||||
Adjacent *adjacent = m_adjacencyList.findAdjacent(faceId);
|
||||
if (adjacent != 0) {
|
||||
_LOG_DEBUG("Face to " << adjacent->getName() << " with face id: "
|
||||
<< faceId << " deleted");
|
||||
|
||||
Adjacent* adjacent = m_adjacencyList.findAdjacent(faceId);
|
||||
|
||||
if (adjacent != nullptr) {
|
||||
_LOG_DEBUG("Face to " << adjacent->getName() << " with face id: " << faceId << " destroyed");
|
||||
|
||||
adjacent->setFaceId(0);
|
||||
|
||||
// Only trigger an Adjacency LSA build if this node is changing from ACTIVE to INACTIVE
|
||||
// since this rebuild will effectively cancel the previous Adjacency LSA refresh event
|
||||
// and schedule a new one further in the future.
|
||||
//
|
||||
// Continuously scheduling the refresh in the future will block the router from refreshing
|
||||
// its Adjacency LSA. Since other routers' Name prefixes' expiration times are updated
|
||||
// when this router refreshes its Adjacency LSA, the other routers' prefixes will expire
|
||||
// and be removed from the RIB.
|
||||
//
|
||||
// This check is required to fix Bug #2733 for now. This check would be unnecessary
|
||||
// to fix Bug #2733 when Issue #2732 is completed, but the check also helps with
|
||||
// optimization so it can remain even when Issue #2732 is implemented.
|
||||
if (adjacent->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
adjacent->setStatus(Adjacent::STATUS_INACTIVE);
|
||||
|
||||
// A new adjacency LSA cannot be built until the neighbor is marked INACTIVE and
|
||||
// has met the HELLO retry threshold
|
||||
adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
|
||||
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
getRoutingTable().scheduleRoutingTableCalculation(*this);
|
||||
}
|
||||
else {
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,16 +398,4 @@ Nlsr::startEventLoop()
|
||||
m_nlsrFace.processEvents();
|
||||
}
|
||||
|
||||
void
|
||||
Nlsr::usage(const string& progname)
|
||||
{
|
||||
std::cout << "Usage: " << progname << " [OPTIONS...]" << std::endl;
|
||||
std::cout << " NDN routing...." << std::endl;
|
||||
std::cout << " -d Run in daemon mode" << 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
|
||||
+84
-64
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,10 +17,8 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_HPP
|
||||
#define NLSR_HPP
|
||||
|
||||
@@ -33,18 +32,23 @@
|
||||
#include <ndn-cxx/management/nfd-face-event-notification.hpp>
|
||||
#include <ndn-cxx/management/nfd-face-monitor.hpp>
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "sequencing-manager.hpp"
|
||||
#include "route/routing-table.hpp"
|
||||
#include "route/name-prefix-table.hpp"
|
||||
#include "route/fib.hpp"
|
||||
#include "communication/sync-logic-handler.hpp"
|
||||
#include "common.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "hello-protocol.hpp"
|
||||
|
||||
#include "lsdb.hpp"
|
||||
#include "name-prefix-list.hpp"
|
||||
#include "sequencing-manager.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "validator.hpp"
|
||||
#include "communication/sync-logic-handler.hpp"
|
||||
#include "publisher/lsdb-dataset-interest-handler.hpp"
|
||||
#include "route/fib.hpp"
|
||||
#include "route/name-prefix-table.hpp"
|
||||
#include "route/routing-table.hpp"
|
||||
#include "security/certificate-store.hpp"
|
||||
#include "update/prefix-update-processor.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
|
||||
namespace nlsr {
|
||||
@@ -64,33 +68,7 @@ class Nlsr
|
||||
};
|
||||
|
||||
public:
|
||||
Nlsr()
|
||||
: m_scheduler(m_nlsrFace.getIoService())
|
||||
, m_confParam()
|
||||
, m_adjacencyList()
|
||||
, m_namePrefixList()
|
||||
, m_sequencingManager()
|
||||
, m_isDaemonProcess(false)
|
||||
, m_configFileName("nlsr.conf")
|
||||
, m_nlsrLsdb(*this)
|
||||
, m_adjBuildCount(0)
|
||||
, m_isBuildAdjLsaSheduled(false)
|
||||
, m_isRouteCalculationScheduled(false)
|
||||
, m_isRoutingTableCalculating(false)
|
||||
, m_routingTable()
|
||||
, m_fib(*this, m_nlsrFace)
|
||||
, m_namePrefixTable(*this)
|
||||
, m_syncLogicHandler(m_nlsrFace.getIoService())
|
||||
, m_helloProtocol(*this)
|
||||
|
||||
, m_certificateCache(new ndn::CertificateCacheTtl(m_nlsrFace.getIoService()))
|
||||
, m_validator(m_nlsrFace, DEFAULT_BROADCAST_PREFIX, m_certificateCache)
|
||||
|
||||
, m_faceMonitor(m_nlsrFace)
|
||||
{
|
||||
m_faceMonitor.onNotification += ndn::bind(&Nlsr::onFaceEventNotification, this, _1);
|
||||
m_faceMonitor.start();
|
||||
}
|
||||
Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::Face& face);
|
||||
|
||||
void
|
||||
registrationFailed(const ndn::Name& name);
|
||||
@@ -98,6 +76,9 @@ public:
|
||||
void
|
||||
onRegistrationSuccess(const ndn::Name& name);
|
||||
|
||||
void
|
||||
onLocalhostRegistrationSuccess(const ndn::Name& name);
|
||||
|
||||
void
|
||||
setInfoInterestFilter();
|
||||
|
||||
@@ -107,9 +88,6 @@ public:
|
||||
void
|
||||
startEventLoop();
|
||||
|
||||
void
|
||||
usage(const std::string& progname);
|
||||
|
||||
std::string
|
||||
getConfFileName() const
|
||||
{
|
||||
@@ -152,12 +130,6 @@ public:
|
||||
return m_namePrefixList;
|
||||
}
|
||||
|
||||
ndn::Scheduler&
|
||||
getScheduler()
|
||||
{
|
||||
return m_scheduler;
|
||||
}
|
||||
|
||||
ndn::Face&
|
||||
getNlsrFace()
|
||||
{
|
||||
@@ -254,6 +226,12 @@ public:
|
||||
return m_syncLogicHandler;
|
||||
}
|
||||
|
||||
LsdbDatasetInterestHandler&
|
||||
getLsdbDatasetHandler()
|
||||
{
|
||||
return m_lsdbDatasetHandler;
|
||||
}
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
||||
@@ -276,20 +254,18 @@ public:
|
||||
void
|
||||
loadCertToPublish(ndn::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
if (static_cast<bool>(certificate))
|
||||
m_certToPublish[certificate->getName().getPrefix(-1)] = certificate; // key is cert name
|
||||
// without version
|
||||
m_certStore.insert(certificate);
|
||||
}
|
||||
|
||||
ndn::shared_ptr<const ndn::IdentityCertificate>
|
||||
getCertificate(const ndn::Name& certificateNameWithoutVersion)
|
||||
{
|
||||
CertMap::iterator it = m_certToPublish.find(certificateNameWithoutVersion);
|
||||
shared_ptr<const ndn::IdentityCertificate> cert =
|
||||
m_certStore.find(certificateNameWithoutVersion);
|
||||
|
||||
if (it != m_certToPublish.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
if (cert != nullptr) {
|
||||
return cert;
|
||||
}
|
||||
|
||||
return m_certificateCache->getCertificate(certificateNameWithoutVersion);
|
||||
}
|
||||
@@ -306,6 +282,12 @@ public:
|
||||
return m_defaultCertName;
|
||||
}
|
||||
|
||||
update::PrefixUpdateProcessor&
|
||||
getPrefixUpdateProcessor()
|
||||
{
|
||||
return m_prefixUpdateProcessor;
|
||||
}
|
||||
|
||||
void
|
||||
createFace(const std::string& faceUri,
|
||||
const CommandSucceedCallback& onSuccess,
|
||||
@@ -320,10 +302,34 @@ public:
|
||||
void
|
||||
daemonize();
|
||||
|
||||
uint32_t
|
||||
getFirstHelloInterval() const
|
||||
{
|
||||
return m_firstHelloInterval;
|
||||
}
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
addCertificateToCache(ndn::shared_ptr<ndn::IdentityCertificate> certificate)
|
||||
{
|
||||
if (certificate != nullptr) {
|
||||
m_certificateCache->insertCertificate(certificate);
|
||||
}
|
||||
}
|
||||
|
||||
security::CertificateStore&
|
||||
getCertificateStore()
|
||||
{
|
||||
return m_certStore;
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
registerKeyPrefix();
|
||||
|
||||
void
|
||||
registerLocalhostPrefix();
|
||||
|
||||
void
|
||||
onKeyInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
@@ -339,11 +345,18 @@ private:
|
||||
void
|
||||
onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification);
|
||||
|
||||
private:
|
||||
typedef std::map<ndn::Name, ndn::shared_ptr<ndn::IdentityCertificate> > CertMap;
|
||||
void
|
||||
setFirstHelloInterval(uint32_t interval)
|
||||
{
|
||||
m_firstHelloInterval = interval;
|
||||
}
|
||||
|
||||
ndn::Face m_nlsrFace;
|
||||
ndn::Scheduler m_scheduler;
|
||||
public:
|
||||
static const ndn::Name LOCALHOST_PREFIX;
|
||||
|
||||
private:
|
||||
ndn::Face& m_nlsrFace;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
ConfParameter m_confParam;
|
||||
AdjacencyList m_adjacencyList;
|
||||
NamePrefixList m_namePrefixList;
|
||||
@@ -359,16 +372,23 @@ private:
|
||||
Fib m_fib;
|
||||
NamePrefixTable m_namePrefixTable;
|
||||
SyncLogicHandler m_syncLogicHandler;
|
||||
LsdbDatasetInterestHandler m_lsdbDatasetHandler;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
CertMap m_certToPublish;
|
||||
security::CertificateStore m_certStore;
|
||||
Validator m_validator;
|
||||
ndn::KeyChain m_keyChain;
|
||||
ndn::Name m_defaultIdentity;
|
||||
ndn::security::SigningInfo m_signingInfo;
|
||||
ndn::Name m_defaultCertName;
|
||||
update::PrefixUpdateProcessor m_prefixUpdateProcessor;
|
||||
|
||||
ndn::nfd::FaceMonitor m_faceMonitor;
|
||||
|
||||
uint32_t m_firstHelloInterval;
|
||||
};
|
||||
|
||||
} //namespace nlsr
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
*
|
||||
* NLSR is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Foundation,
|
||||
* either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include "lsa-publisher.hpp"
|
||||
|
||||
#include "lsa.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
const ndn::Name::Component AdjacencyLsaPublisher::DATASET_COMPONENT =
|
||||
ndn::Name::Component("adjacencies");
|
||||
|
||||
AdjacencyLsaPublisher::AdjacencyLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain)
|
||||
: LsaPublisher(face, keyChain)
|
||||
, m_adjacencyLsas(lsdb.getAdjLsdb())
|
||||
{
|
||||
}
|
||||
|
||||
std::list<tlv::AdjacencyLsa>
|
||||
AdjacencyLsaPublisher::getTlvLsas()
|
||||
{
|
||||
std::list<tlv::AdjacencyLsa> lsas;
|
||||
|
||||
for (AdjLsa lsa : m_adjacencyLsas) {
|
||||
tlv::AdjacencyLsa tlvLsa;
|
||||
|
||||
std::shared_ptr<tlv::LsaInfo> tlvLsaInfo = tlv::makeLsaInfo(lsa);
|
||||
tlvLsa.setLsaInfo(*tlvLsaInfo);
|
||||
|
||||
for (const Adjacent& adj : lsa.getAdl().getAdjList()) {
|
||||
tlv::Adjacency tlvAdj;
|
||||
tlvAdj.setName(adj.getName());
|
||||
tlvAdj.setUri(adj.getConnectingFaceUri());
|
||||
tlvAdj.setCost(adj.getLinkCost());
|
||||
tlvLsa.addAdjacency(tlvAdj);
|
||||
}
|
||||
|
||||
lsas.push_back(tlvLsa);
|
||||
}
|
||||
|
||||
return lsas;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
const ndn::Name::Component CoordinateLsaPublisher::DATASET_COMPONENT =
|
||||
ndn::Name::Component("coordinates");
|
||||
|
||||
CoordinateLsaPublisher::CoordinateLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain)
|
||||
: LsaPublisher(face, keyChain)
|
||||
, m_coordinateLsas(lsdb.getCoordinateLsdb())
|
||||
{
|
||||
}
|
||||
|
||||
std::list<tlv::CoordinateLsa>
|
||||
CoordinateLsaPublisher::getTlvLsas()
|
||||
{
|
||||
std::list<tlv::CoordinateLsa> lsas;
|
||||
|
||||
for (const CoordinateLsa lsa : m_coordinateLsas) {
|
||||
tlv::CoordinateLsa tlvLsa;
|
||||
|
||||
std::shared_ptr<tlv::LsaInfo> tlvLsaInfo = tlv::makeLsaInfo(lsa);
|
||||
tlvLsa.setLsaInfo(*tlvLsaInfo);
|
||||
|
||||
tlvLsa.setHyperbolicRadius(lsa.getCorRadius());
|
||||
tlvLsa.setHyperbolicAngle(lsa.getCorTheta());
|
||||
|
||||
lsas.push_back(tlvLsa);
|
||||
}
|
||||
|
||||
return lsas;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
const ndn::Name::Component NameLsaPublisher::DATASET_COMPONENT =
|
||||
ndn::Name::Component("names");
|
||||
|
||||
NameLsaPublisher::NameLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain)
|
||||
: LsaPublisher(face, keyChain)
|
||||
, m_nameLsas(lsdb.getNameLsdb())
|
||||
{
|
||||
}
|
||||
|
||||
std::list<tlv::NameLsa>
|
||||
NameLsaPublisher::getTlvLsas()
|
||||
{
|
||||
std::list<tlv::NameLsa> lsas;
|
||||
|
||||
for (NameLsa lsa : m_nameLsas) {
|
||||
tlv::NameLsa tlvLsa;
|
||||
|
||||
std::shared_ptr<tlv::LsaInfo> tlvLsaInfo = tlv::makeLsaInfo(lsa);
|
||||
tlvLsa.setLsaInfo(*tlvLsaInfo);
|
||||
|
||||
for (const ndn::Name& name : lsa.getNpl().getNameList()) {
|
||||
tlvLsa.addName(name);
|
||||
}
|
||||
|
||||
lsas.push_back(tlvLsa);
|
||||
}
|
||||
|
||||
return lsas;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -0,0 +1,131 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, 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_PUBLISHER_LSA_PUBLISHER_HPP
|
||||
#define NLSR_PUBLISHER_LSA_PUBLISHER_HPP
|
||||
|
||||
#include "lsdb.hpp"
|
||||
#include "segment-publisher.hpp"
|
||||
#include "tlv/adjacency-lsa.hpp"
|
||||
#include "tlv/coordinate-lsa.hpp"
|
||||
#include "tlv/name-lsa.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
template <class TlvType>
|
||||
class LsaPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
public:
|
||||
LsaPublisher(ndn::Face& face, ndn::KeyChain& keyChain)
|
||||
: SegmentPublisher<ndn::Face>(face, keyChain)
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~LsaPublisher()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer)
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
for (const TlvType& lsaTlv : getTlvLsas()) {
|
||||
totalLength += lsaTlv.wireEncode(outBuffer);
|
||||
}
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
virtual std::list<TlvType>
|
||||
getTlvLsas() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish adjacency lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class AdjacencyLsaPublisher : public LsaPublisher<tlv::AdjacencyLsa>
|
||||
{
|
||||
public:
|
||||
AdjacencyLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
std::list<tlv::AdjacencyLsa>
|
||||
getTlvLsas();
|
||||
|
||||
public:
|
||||
static const ndn::Name::Component DATASET_COMPONENT;
|
||||
|
||||
private:
|
||||
const std::list<AdjLsa>& m_adjacencyLsas;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish coordinate lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class CoordinateLsaPublisher : public LsaPublisher<tlv::CoordinateLsa>
|
||||
{
|
||||
public:
|
||||
CoordinateLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
std::list<tlv::CoordinateLsa>
|
||||
getTlvLsas();
|
||||
|
||||
public:
|
||||
static const ndn::Name::Component DATASET_COMPONENT;
|
||||
|
||||
private:
|
||||
const std::list<CoordinateLsa>& m_coordinateLsas;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish name lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class NameLsaPublisher : public LsaPublisher<tlv::NameLsa>
|
||||
{
|
||||
public:
|
||||
NameLsaPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
std::list<tlv::NameLsa>
|
||||
getTlvLsas();
|
||||
|
||||
public:
|
||||
static const ndn::Name::Component DATASET_COMPONENT;
|
||||
|
||||
private:
|
||||
const std::list<NameLsa>& m_nameLsas;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_PUBLISHER_LSA_PUBLISHER_HPP
|
||||
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, 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 "lsdb-dataset-interest-handler.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-response.hpp>
|
||||
#include <ndn-cxx/util/regex.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("LsdbDatasetInterestHandler");
|
||||
|
||||
const uint32_t LsdbDatasetInterestHandler::ERROR_CODE_MALFORMED_COMMAND = 400;
|
||||
const uint32_t LsdbDatasetInterestHandler::ERROR_CODE_UNSUPPORTED_COMMAND = 501;
|
||||
|
||||
LsdbDatasetInterestHandler::LsdbDatasetInterestHandler(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain)
|
||||
: LOCALHOST_COMMAND_PREFIX(ndn::Name(Nlsr::LOCALHOST_PREFIX).append(Lsdb::NAME_COMPONENT))
|
||||
, m_face(face)
|
||||
, m_keyChain(keyChain)
|
||||
, m_adjacencyLsaPublisher(lsdb, face, keyChain)
|
||||
, m_coordinateLsaPublisher(lsdb, face, keyChain)
|
||||
, m_nameLsaPublisher(lsdb, face, keyChain)
|
||||
, m_lsdbStatusPublisher(lsdb, face, keyChain,
|
||||
m_adjacencyLsaPublisher,
|
||||
m_coordinateLsaPublisher,
|
||||
m_nameLsaPublisher)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LsdbDatasetInterestHandler::startListeningOnLocalhost()
|
||||
{
|
||||
_LOG_DEBUG("Setting interest filter for: " << LOCALHOST_COMMAND_PREFIX);
|
||||
m_face.setInterestFilter(LOCALHOST_COMMAND_PREFIX,
|
||||
std::bind(&LsdbDatasetInterestHandler::onInterest, this, _2,
|
||||
std::cref(LOCALHOST_COMMAND_PREFIX)));
|
||||
}
|
||||
|
||||
void
|
||||
LsdbDatasetInterestHandler::startListeningOnRouterPrefix()
|
||||
{
|
||||
_LOG_DEBUG("Setting interest filter for: " << m_routerNameCommandPrefix);
|
||||
m_face.setInterestFilter(m_routerNameCommandPrefix,
|
||||
std::bind(&LsdbDatasetInterestHandler::onInterest, this, _2,
|
||||
std::cref(m_routerNameCommandPrefix)));
|
||||
}
|
||||
|
||||
void
|
||||
LsdbDatasetInterestHandler::onInterest(const ndn::Interest& interest,
|
||||
const ndn::Name& commandPrefix)
|
||||
{
|
||||
if (!isValidCommandPrefix(interest, commandPrefix))
|
||||
{
|
||||
_LOG_DEBUG("Received malformed interest: " << interest.getName());
|
||||
|
||||
sendErrorResponse(interest.getName(), ERROR_CODE_MALFORMED_COMMAND, "Malformed command");
|
||||
return;
|
||||
}
|
||||
|
||||
ndn::Name::Component command = interest.getName().get(commandPrefix.size());
|
||||
processCommand(interest, command);
|
||||
}
|
||||
|
||||
bool
|
||||
LsdbDatasetInterestHandler::isValidCommandPrefix(const ndn::Interest& interest,
|
||||
const ndn::Name& commandPrefix)
|
||||
{
|
||||
size_t commandSize = interest.getName().size();
|
||||
|
||||
// Does the Interest match the command prefix with one additional component?
|
||||
return (commandSize == commandPrefix.size() + 1 && commandPrefix.isPrefixOf(interest.getName()));
|
||||
}
|
||||
|
||||
void
|
||||
LsdbDatasetInterestHandler::processCommand(const ndn::Interest& interest,
|
||||
const ndn::Name::Component& command)
|
||||
{
|
||||
_LOG_TRACE("Received interest with command: " << command);
|
||||
|
||||
if (command.equals(AdjacencyLsaPublisher::DATASET_COMPONENT)) {
|
||||
m_adjacencyLsaPublisher.publish(interest.getName());
|
||||
}
|
||||
else if (command.equals(CoordinateLsaPublisher::DATASET_COMPONENT)) {
|
||||
m_coordinateLsaPublisher.publish(interest.getName());
|
||||
}
|
||||
else if (command.equals(NameLsaPublisher::DATASET_COMPONENT)) {
|
||||
m_nameLsaPublisher.publish(interest.getName());
|
||||
}
|
||||
else if (command.equals(LsdbStatusPublisher::DATASET_COMPONENT)) {
|
||||
m_lsdbStatusPublisher.publish(interest.getName());
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Unsupported command: " << command);
|
||||
sendErrorResponse(interest.getName(), ERROR_CODE_UNSUPPORTED_COMMAND, "Unsupported command");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LsdbDatasetInterestHandler::sendErrorResponse(const ndn::Name& name,
|
||||
uint32_t code,
|
||||
const std::string& error)
|
||||
{
|
||||
ndn::nfd::ControlResponse response(code, error);
|
||||
|
||||
std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(name);
|
||||
data->setContent(response.wireEncode());
|
||||
|
||||
m_keyChain.sign(*data);
|
||||
m_face.put(*data);
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -0,0 +1,109 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, 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_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
|
||||
#define NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
|
||||
|
||||
#include "lsa-publisher.hpp"
|
||||
#include "lsdb-status-publisher.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish all lsa dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbDatasetInterestHandler
|
||||
{
|
||||
public:
|
||||
class Error : std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
Error(const std::string& what)
|
||||
: std::runtime_error(what)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
LsdbDatasetInterestHandler(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
void
|
||||
startListeningOnLocalhost();
|
||||
|
||||
void
|
||||
startListeningOnRouterPrefix();
|
||||
|
||||
const ndn::Name&
|
||||
getLocalhostCommandPrefix()
|
||||
{
|
||||
return LOCALHOST_COMMAND_PREFIX;
|
||||
}
|
||||
|
||||
ndn::Name&
|
||||
getRouterNameCommandPrefix()
|
||||
{
|
||||
return m_routerNameCommandPrefix;
|
||||
}
|
||||
|
||||
void
|
||||
setRouterNameCommandPrefix(const ndn::Name& routerName) {
|
||||
m_routerNameCommandPrefix = routerName;
|
||||
m_routerNameCommandPrefix.append(Lsdb::NAME_COMPONENT);
|
||||
}
|
||||
|
||||
private:
|
||||
void
|
||||
onInterest(const ndn::Interest& interest, const ndn::Name& commandPrefix);
|
||||
|
||||
bool
|
||||
isValidCommandPrefix(const ndn::Interest& interest, const ndn::Name& commandPrefix);
|
||||
|
||||
void
|
||||
processCommand(const ndn::Interest& interest, const ndn::Name::Component& command);
|
||||
|
||||
void
|
||||
sendErrorResponse(const ndn::Name& name, uint32_t code, const std::string& error);
|
||||
|
||||
private:
|
||||
const ndn::Name LOCALHOST_COMMAND_PREFIX;
|
||||
ndn::Name m_routerNameCommandPrefix;
|
||||
|
||||
ndn::Face& m_face;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
|
||||
AdjacencyLsaPublisher m_adjacencyLsaPublisher;
|
||||
CoordinateLsaPublisher m_coordinateLsaPublisher;
|
||||
NameLsaPublisher m_nameLsaPublisher;
|
||||
LsdbStatusPublisher m_lsdbStatusPublisher;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
static const uint32_t ERROR_CODE_MALFORMED_COMMAND;
|
||||
static const uint32_t ERROR_CODE_UNSUPPORTED_COMMAND;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_PUBLISHER_LSDB_DATASET_INTEREST_HANDLER_HPP
|
||||
@@ -0,0 +1,69 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, 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 "lsdb-status-publisher.hpp"
|
||||
|
||||
#include "lsa.hpp"
|
||||
#include "tlv/lsdb-status.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
const ndn::Name::Component LsdbStatusPublisher::DATASET_COMPONENT = ndn::Name::Component("list");
|
||||
|
||||
LsdbStatusPublisher::LsdbStatusPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
AdjacencyLsaPublisher& adjacencyLsaPublisher,
|
||||
CoordinateLsaPublisher& coordinateLsaPublisher,
|
||||
NameLsaPublisher& nameLsaPublisher)
|
||||
: SegmentPublisher<ndn::Face>(face, keyChain)
|
||||
, m_adjacencyLsaPublisher(adjacencyLsaPublisher)
|
||||
, m_coordinateLsaPublisher(coordinateLsaPublisher)
|
||||
, m_nameLsaPublisher(nameLsaPublisher)
|
||||
{
|
||||
}
|
||||
|
||||
size_t
|
||||
LsdbStatusPublisher::generate(ndn::EncodingBuffer& outBuffer)
|
||||
{
|
||||
size_t totalLength = 0;
|
||||
|
||||
tlv::LsdbStatus lsdbStatus;
|
||||
for (const tlv::AdjacencyLsa& tlvLsa : m_adjacencyLsaPublisher.getTlvLsas()) {
|
||||
lsdbStatus.addAdjacencyLsa(tlvLsa);
|
||||
}
|
||||
|
||||
for (const tlv::CoordinateLsa& tlvLsa : m_coordinateLsaPublisher.getTlvLsas()) {
|
||||
lsdbStatus.addCoordinateLsa(tlvLsa);
|
||||
}
|
||||
|
||||
for (const tlv::NameLsa& tlvLsa : m_nameLsaPublisher.getTlvLsas()) {
|
||||
lsdbStatus.addNameLsa(tlvLsa);
|
||||
}
|
||||
|
||||
totalLength += lsdbStatus.wireEncode(outBuffer);
|
||||
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -0,0 +1,62 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, 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_PUBLISHER_LSDB_STATUS_PUBLISHER_HPP
|
||||
#define NLSR_PUBLISHER_LSDB_STATUS_PUBLISHER_HPP
|
||||
|
||||
#include "lsa-publisher.hpp"
|
||||
#include "lsdb.hpp"
|
||||
#include "segment-publisher.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
/**
|
||||
* @brief Abstraction to publish lsdb status dataset
|
||||
* \sa http://redmine.named-data.net/projects/nlsr/wiki/LSDB_DataSet
|
||||
*/
|
||||
class LsdbStatusPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
public:
|
||||
LsdbStatusPublisher(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
AdjacencyLsaPublisher& adjacencyLsaPublisher,
|
||||
CoordinateLsaPublisher& coordinateLsaPublisher,
|
||||
NameLsaPublisher& nameLsaPublisher);
|
||||
|
||||
protected:
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer);
|
||||
|
||||
private:
|
||||
AdjacencyLsaPublisher& m_adjacencyLsaPublisher;
|
||||
CoordinateLsaPublisher& m_coordinateLsaPublisher;
|
||||
NameLsaPublisher& m_nameLsaPublisher;
|
||||
|
||||
public:
|
||||
static const ndn::Name::Component DATASET_COMPONENT;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_PUBLISHER_LSDB_STATUS_PUBLISHER_HPP
|
||||
@@ -0,0 +1,130 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, 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 http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
|
||||
*/
|
||||
template <class FaceBase>
|
||||
class SegmentPublisher : ndn::noncopyable
|
||||
{
|
||||
public:
|
||||
SegmentPublisher(FaceBase& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
const ndn::time::milliseconds& freshnessPeriod = getDefaultFreshness())
|
||||
: m_face(face)
|
||||
, m_keyChain(keyChain)
|
||||
, m_freshnessPeriod(freshnessPeriod)
|
||||
{
|
||||
}
|
||||
|
||||
virtual
|
||||
~SegmentPublisher()
|
||||
{
|
||||
}
|
||||
|
||||
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 provided prefix
|
||||
*/
|
||||
void
|
||||
publish(const ndn::Name& prefix,
|
||||
const ndn::security::SigningInfo& signingInfo = ndn::security::KeyChain::DEFAULT_SIGNING_INFO)
|
||||
{
|
||||
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);
|
||||
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::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, signingInfo);
|
||||
++segmentNo;
|
||||
} while (segmentBegin < end);
|
||||
}
|
||||
|
||||
protected:
|
||||
/** \brief In a derived class, write the octets into outBuffer.
|
||||
*/
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) = 0;
|
||||
|
||||
private:
|
||||
void
|
||||
publishSegment(ndn::shared_ptr<ndn::Data>& data, const ndn::security::SigningInfo& signingInfo)
|
||||
{
|
||||
m_keyChain.sign(*data, signingInfo);
|
||||
m_face.put(*data);
|
||||
}
|
||||
|
||||
private:
|
||||
FaceBase& m_face;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
const ndn::time::milliseconds m_freshnessPeriod;
|
||||
};
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_PUBLISHER_SEGMENT_PUBLISHER_HPP
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "face-map.hpp"
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define NLSR_FACE_MAP_HPP
|
||||
|
||||
#include <ndn-cxx/common.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
|
||||
+93
-76
@@ -24,14 +24,14 @@
|
||||
#include <cmath>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
#include "nlsr.hpp"
|
||||
#include "adjacency-list.hpp"
|
||||
#include "common.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "nexthop-list.hpp"
|
||||
#include "face-map.hpp"
|
||||
#include "fib.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("Fib");
|
||||
@@ -44,13 +44,13 @@ using namespace ndn;
|
||||
static bool
|
||||
fibEntryNameCompare(const FibEntry& fibEntry, const ndn::Name& name)
|
||||
{
|
||||
return fibEntry.getName() == name ;
|
||||
return fibEntry.getName() == name;
|
||||
}
|
||||
|
||||
void
|
||||
Fib::cancelScheduledExpiringEvent(EventId eid)
|
||||
{
|
||||
m_nlsr.getScheduler().cancelEvent(eid);
|
||||
m_scheduler.cancelEvent(eid);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ Fib::scheduleEntryExpiration(const ndn::Name& name, int32_t feSeqNum,
|
||||
{
|
||||
_LOG_DEBUG("Fib::scheduleEntryExpiration Called");
|
||||
_LOG_INFO("Name: " << name << " Seq Num: " << feSeqNum);
|
||||
return m_nlsr.getScheduler().scheduleEvent(expTime,
|
||||
ndn::bind(&Fib::remove, this, name));
|
||||
|
||||
return m_scheduler.scheduleEvent(expTime, ndn::bind(&Fib::remove, this, name));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -93,84 +93,102 @@ compareFaceUri(const NextHop& hop, const std::string& faceUri)
|
||||
}
|
||||
|
||||
void
|
||||
Fib::addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& nextHopList)
|
||||
Fib::addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd)
|
||||
{
|
||||
const ndn::Name& name = entry.getName();
|
||||
|
||||
nextHopList.sort();
|
||||
|
||||
int numFaces = 0;
|
||||
int maxFaces = getNumberOfFacesForName(nextHopList,
|
||||
m_nlsr.getConfParameter().getMaxFacesPerPrefix());
|
||||
|
||||
for (NexthopList::iterator hopIt = nextHopList.begin();
|
||||
hopIt != nextHopList.end() && numFaces < maxFaces; ++hopIt, ++numFaces)
|
||||
for (NexthopList::iterator it = hopsToAdd.begin(); it != hopsToAdd.end(); ++it)
|
||||
{
|
||||
// Add nexthop to FIB entry
|
||||
entry.getNexthopList().addNextHop(*hopIt);
|
||||
entry.getNexthopList().addNextHop(*it);
|
||||
|
||||
if (isPrefixUpdatable(name)) {
|
||||
// Add nexthop to NDN-FIB
|
||||
registerPrefix(name, hopIt->getConnectingFaceUri(),
|
||||
hopIt->getRouteCostAsAdjustedInteger(),
|
||||
registerPrefix(name, it->getConnectingFaceUri(),
|
||||
it->getRouteCostAsAdjustedInteger(),
|
||||
ndn::time::seconds(m_refreshTime + GRACE_PERIOD),
|
||||
ndn::nfd::ROUTE_FLAG_CAPTURE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
entry.getNexthopList().sort();
|
||||
}
|
||||
|
||||
void
|
||||
Fib::removeOldNextHopsFromFibEntryAndNfd(FibEntry& entry, const NexthopList& installedHops)
|
||||
{
|
||||
_LOG_DEBUG("Fib::removeOldNextHopsFromFibEntryAndNfd Called");
|
||||
|
||||
const ndn::Name& name = entry.getName();
|
||||
NexthopList& entryHopList = entry.getNexthopList();
|
||||
|
||||
for (NexthopList::iterator it = entryHopList.begin(); it != entryHopList.end();) {
|
||||
|
||||
const std::string& faceUri = it->getConnectingFaceUri();
|
||||
|
||||
// See if the nexthop is installed in NFD's FIB
|
||||
NexthopList::const_iterator foundIt = std::find_if(installedHops.cbegin(),
|
||||
installedHops.cend(),
|
||||
bind(&compareFaceUri, _1, faceUri));
|
||||
|
||||
// The next hop is not installed
|
||||
if (foundIt == installedHops.cend()) {
|
||||
|
||||
if (isPrefixUpdatable(name)) {
|
||||
// Remove the nexthop from NDN's FIB
|
||||
unregisterPrefix(name, it->getConnectingFaceUri());
|
||||
}
|
||||
|
||||
// Remove the next hop from the FIB entry
|
||||
_LOG_DEBUG("Removing " << it->getConnectingFaceUri() << " from " << name);
|
||||
// Since the iterator will be invalidated on removal, dereference the original
|
||||
// and increment the copy
|
||||
entryHopList.removeNextHop(*(it++));
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Fib::removeOldNextHopsFromFibEntryAndNfd(FibEntry& entry, NexthopList& newHopList)
|
||||
Fib::update(const ndn::Name& name, NexthopList& allHops)
|
||||
{
|
||||
_LOG_DEBUG("Fib::removeOldNextHopsFromFibEntryAndNfd Called");
|
||||
const ndn::Name& name = entry.getName();
|
||||
NexthopList& entryHopList = entry.getNexthopList();
|
||||
NexthopList itHopList = entryHopList;
|
||||
_LOG_DEBUG("Fib::update called");
|
||||
|
||||
for (NexthopList::iterator it = itHopList.begin(); it != itHopList.end(); ++it) {
|
||||
// Sort all of the next hops so lower cost hops are prioritized
|
||||
allHops.sort();
|
||||
|
||||
// See if the nexthop is in the new nexthop list
|
||||
const std::string& faceUri = it->getConnectingFaceUri();
|
||||
NexthopList::iterator foundIt = std::find_if(newHopList.begin(),
|
||||
newHopList.end(),
|
||||
bind(&compareFaceUri, _1, faceUri));
|
||||
// Get the max possible faces which is the minumum of the configuration setting and
|
||||
// the length of the list of all next hops.
|
||||
unsigned int maxFaces = getNumberOfFacesForName(allHops);
|
||||
|
||||
// The next hop is not in the new nexthop list
|
||||
if (foundIt == newHopList.end()) {
|
||||
// Remove the next hop from the FIB entry
|
||||
_LOG_DEBUG("Removing " << it->getConnectingFaceUri() << " from " << name);
|
||||
entryHopList.removeNextHop(*it);
|
||||
NexthopList hopsToAdd;
|
||||
unsigned int nFaces = 0;
|
||||
|
||||
if (isPrefixUpdatable(name)) {
|
||||
// Remove the nexthop from NDN-FIB
|
||||
unregisterPrefix(name, it->getConnectingFaceUri());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Fib::update(const ndn::Name& name, NexthopList& nextHopList)
|
||||
{
|
||||
_LOG_DEBUG("Fib::updateFib Called");
|
||||
// Create a list of next hops to be installed with length == maxFaces
|
||||
for (NexthopList::iterator it = allHops.begin(); it != allHops.end() && nFaces < maxFaces;
|
||||
++it, ++nFaces)
|
||||
{
|
||||
hopsToAdd.addNextHop(*it);
|
||||
}
|
||||
|
||||
std::list<FibEntry>::iterator entryIt = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&fibEntryNameCompare, _1, name));
|
||||
|
||||
// New FIB entry
|
||||
if (entryIt == m_table.end()) {
|
||||
_LOG_DEBUG("New FIB Entry");
|
||||
|
||||
// Don't create an entry for a name with no nexthops
|
||||
if (nextHopList.getSize() == 0) {
|
||||
if (hopsToAdd.getSize() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
FibEntry entry(name);
|
||||
|
||||
addNextHopsToFibEntryAndNfd(entry, nextHopList);
|
||||
|
||||
entry.getNexthopList().sort();
|
||||
addNextHopsToFibEntryAndNfd(entry, hopsToAdd);
|
||||
|
||||
// Set entry's expiration time point and sequence number
|
||||
entry.setExpirationTimePoint(ndn::time::system_clock::now() +
|
||||
@@ -189,15 +207,14 @@ Fib::update(const ndn::Name& name, NexthopList& nextHopList)
|
||||
FibEntry& entry = *entryIt;
|
||||
|
||||
// Remove empty FIB entry
|
||||
if (nextHopList.getSize() == 0) {
|
||||
if (hopsToAdd.getSize() == 0) {
|
||||
remove(name);
|
||||
return;
|
||||
}
|
||||
|
||||
addNextHopsToFibEntryAndNfd(entry, nextHopList);
|
||||
removeOldNextHopsFromFibEntryAndNfd(entry, nextHopList);
|
||||
addNextHopsToFibEntryAndNfd(entry, hopsToAdd);
|
||||
|
||||
entry.getNexthopList().sort();
|
||||
removeOldNextHopsFromFibEntryAndNfd(entry, hopsToAdd);
|
||||
|
||||
// Set entry's expiration time point
|
||||
entry.setExpirationTimePoint(ndn::time::system_clock::now() +
|
||||
@@ -205,8 +222,8 @@ Fib::update(const ndn::Name& name, NexthopList& nextHopList)
|
||||
// Increment sequence number
|
||||
entry.setSeqNo(entry.getSeqNo() + 1);
|
||||
|
||||
// Cancel previosuly scheduled event
|
||||
m_nlsr.getScheduler().cancelEvent(entry.getExpiringEventId());
|
||||
// Cancel previously scheduled event
|
||||
m_scheduler.cancelEvent(entry.getExpiringEventId());
|
||||
|
||||
// Schedule entry to be refreshed
|
||||
entry.setExpiringEventId(scheduleEntryExpiration(name , entry.getSeqNo(),
|
||||
@@ -234,23 +251,24 @@ Fib::clean()
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
Fib::getNumberOfFacesForName(NexthopList& nextHopList,
|
||||
uint32_t maxFacesPerPrefix)
|
||||
unsigned int
|
||||
Fib::getNumberOfFacesForName(NexthopList& nextHopList)
|
||||
{
|
||||
int endFace = 0;
|
||||
if ((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix)) {
|
||||
return nextHopList.getSize();
|
||||
uint32_t nNextHops = static_cast<uint32_t>(nextHopList.getNextHops().size());
|
||||
uint32_t nMaxFaces = m_confParameter.getMaxFacesPerPrefix();
|
||||
|
||||
// Allow all faces
|
||||
if (nMaxFaces == 0) {
|
||||
return nNextHops;
|
||||
}
|
||||
else {
|
||||
return maxFacesPerPrefix;
|
||||
return std::min(nNextHops, nMaxFaces);
|
||||
}
|
||||
return endFace;
|
||||
}
|
||||
|
||||
bool
|
||||
Fib::isPrefixUpdatable(const ndn::Name& name) {
|
||||
if (!m_nlsr.getAdjacencyList().isNeighbor(name)) {
|
||||
if (!m_adjacencyList.isNeighbor(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -277,12 +295,7 @@ Fib::createFace(const std::string& faceUri,
|
||||
const CommandSucceedCallback& onSuccess,
|
||||
const CommandFailCallback& onFailure)
|
||||
{
|
||||
ndn::nfd::ControlParameters faceParameters;
|
||||
faceParameters
|
||||
.setUri(faceUri);
|
||||
m_controller.start<ndn::nfd::FaceCreateCommand>(faceParameters,
|
||||
onSuccess,
|
||||
onFailure);
|
||||
m_faceController.createFace(faceUri, onSuccess, onFailure);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -313,7 +326,7 @@ Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
|
||||
uint64_t faceCost, const ndn::time::milliseconds& timeout,
|
||||
uint64_t flags, uint8_t times)
|
||||
{
|
||||
uint64_t faceId = m_nlsr.getAdjacencyList().getFaceId(faceUri);
|
||||
uint64_t faceId = m_adjacencyList.getFaceId(faceUri);
|
||||
if (faceId != 0) {
|
||||
ndn::nfd::ControlParameters faceParameters;
|
||||
faceParameters
|
||||
@@ -333,6 +346,11 @@ Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
|
||||
}
|
||||
}
|
||||
|
||||
typedef void(Fib::*RegisterPrefixCallback)(const ndn::nfd::ControlParameters&,
|
||||
const ndn::nfd::ControlParameters&, uint8_t,
|
||||
const CommandSucceedCallback&,
|
||||
const CommandFailCallback&);
|
||||
|
||||
void
|
||||
Fib::registerPrefix(const ndn::Name& namePrefix,
|
||||
const std::string& faceUri,
|
||||
@@ -352,9 +370,8 @@ Fib::registerPrefix(const ndn::Name& namePrefix,
|
||||
.setExpirationPeriod(timeout)
|
||||
.setOrigin(128);
|
||||
createFace(faceUri,
|
||||
ndn::bind(&Fib::registerPrefixInNfd, this,_1,
|
||||
parameters,
|
||||
times, onSuccess, onFailure),
|
||||
ndn::bind(static_cast<RegisterPrefixCallback>(&Fib::registerPrefixInNfd),
|
||||
this, _1, parameters, times, onSuccess, onFailure),
|
||||
onFailure);
|
||||
}
|
||||
|
||||
|
||||
+26
-11
@@ -30,26 +30,33 @@
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
#include "face-map.hpp"
|
||||
#include "fib-entry.hpp"
|
||||
#include "test-access-control.hpp"
|
||||
#include "utility/face-controller.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
typedef ndn::function<void(const ndn::nfd::ControlParameters&)> CommandSucceedCallback;
|
||||
typedef ndn::function<void(uint32_t/*code*/,const std::string&/*reason*/)> CommandFailCallback;
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class AdjacencyList;
|
||||
class ConfParameter;
|
||||
|
||||
class Fib
|
||||
{
|
||||
public:
|
||||
Fib(Nlsr& nlsr, ndn::Face& face)
|
||||
: m_nlsr(nlsr)
|
||||
Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList, ConfParameter& conf,
|
||||
ndn::KeyChain& keyChain)
|
||||
: m_scheduler(scheduler)
|
||||
, m_table()
|
||||
, m_refreshTime(0)
|
||||
, m_controller(face)
|
||||
, m_controller(face, keyChain)
|
||||
, m_faceController(face.getIoService(), m_controller)
|
||||
, m_faceMap()
|
||||
, m_adjacencyList(adjacencyList)
|
||||
, m_confParameter(conf)
|
||||
{
|
||||
}
|
||||
|
||||
~Fib()
|
||||
{
|
||||
}
|
||||
@@ -58,7 +65,7 @@ public:
|
||||
remove(const ndn::Name& name);
|
||||
|
||||
void
|
||||
update(const ndn::Name& name, NexthopList& nextHopList);
|
||||
update(const ndn::Name& name, NexthopList& allHops);
|
||||
|
||||
void
|
||||
clean();
|
||||
@@ -74,17 +81,17 @@ private:
|
||||
isPrefixUpdatable(const ndn::Name& name);
|
||||
|
||||
void
|
||||
addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& nextHopList);
|
||||
addNextHopsToFibEntryAndNfd(FibEntry& entry, NexthopList& hopsToAdd);
|
||||
|
||||
void
|
||||
removeOldNextHopsFromFibEntryAndNfd(FibEntry& entry, NexthopList& newHopList);
|
||||
removeOldNextHopsFromFibEntryAndNfd(FibEntry& entry, const NexthopList& installedHops);
|
||||
|
||||
void
|
||||
removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
|
||||
const ndn::Name& name);
|
||||
|
||||
int
|
||||
getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix);
|
||||
unsigned int
|
||||
getNumberOfFacesForName(NexthopList& nextHopList);
|
||||
|
||||
ndn::EventId
|
||||
scheduleEntryExpiration(const ndn::Name& name, int32_t feSeqNum,
|
||||
@@ -177,12 +184,20 @@ private:
|
||||
const std::string& message);
|
||||
|
||||
private:
|
||||
Nlsr& m_nlsr;
|
||||
ndn::Scheduler& m_scheduler;
|
||||
|
||||
std::list<FibEntry> m_table;
|
||||
int32_t m_refreshTime;
|
||||
ndn::nfd::Controller m_controller;
|
||||
util::FaceController m_faceController;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
FaceMap m_faceMap;
|
||||
|
||||
private:
|
||||
AdjacencyList& m_adjacencyList;
|
||||
ConfParameter& m_confParameter;
|
||||
|
||||
static const uint64_t GRACE_PERIOD;
|
||||
};
|
||||
|
||||
|
||||
@@ -112,6 +112,14 @@ Map::createFromAdjLsdb(Nlsr& pnlsr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::createFromCoordinateLsdb(Nlsr& nlsr)
|
||||
{
|
||||
for (CoordinateLsa lsa : nlsr.getLsdb().getCoordinateLsdb()) {
|
||||
addEntry(lsa.getOrigRouter());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::reset()
|
||||
{
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
void
|
||||
createFromAdjLsdb(Nlsr& pnlsr);
|
||||
|
||||
void
|
||||
createFromCoordinateLsdb(Nlsr& nlsr);
|
||||
|
||||
const ndn::Name
|
||||
getRouterNameByMappingNo(int32_t mn);
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,14 +17,11 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include <list>
|
||||
#include <utility>
|
||||
|
||||
#include "name-prefix-table-entry.hpp"
|
||||
#include "routing-table-entry.hpp"
|
||||
|
||||
#include "common.hpp"
|
||||
#include "nexthop.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
@@ -31,8 +29,6 @@ namespace nlsr {
|
||||
|
||||
INIT_LOGGER("NamePrefixTableEntry");
|
||||
|
||||
using namespace std;
|
||||
|
||||
void
|
||||
NamePrefixTableEntry::generateNhlfromRteList()
|
||||
{
|
||||
@@ -103,4 +99,16 @@ NamePrefixTableEntry::writeLog()
|
||||
m_nexthopList.writeLog();
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTableEntry& entry)
|
||||
{
|
||||
os << "Name: " << entry.getNamePrefix() << "\n";
|
||||
|
||||
for (const RoutingTableEntry& rte : entry.getRteList()) {
|
||||
os << "Destination: " << rte.getDestination() << "\n";
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,18 +17,15 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
#define NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
|
||||
#include "routing-table-entry.hpp"
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include "routing-table-entry.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
@@ -50,8 +48,8 @@ public:
|
||||
return m_namePrefix;
|
||||
}
|
||||
|
||||
std::list<RoutingTableEntry>&
|
||||
getRteList()
|
||||
const std::list<RoutingTableEntry>&
|
||||
getRteList() const
|
||||
{
|
||||
return m_rteList;
|
||||
}
|
||||
@@ -97,6 +95,9 @@ private:
|
||||
NexthopList m_nexthopList;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTableEntry& entry);
|
||||
|
||||
#endif //NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_NAME_PREFIX_TABLE_ENTRY_HPP
|
||||
+109
-74
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,60 +17,70 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include "name-prefix-table.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "routing-table.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
|
||||
#include "nlsr.hpp"
|
||||
#include "name-prefix-table.hpp"
|
||||
#include "name-prefix-table-entry.hpp"
|
||||
#include "routing-table.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("NamePrefixTable");
|
||||
|
||||
using namespace std;
|
||||
|
||||
static bool
|
||||
npteCompare(NamePrefixTableEntry& npte, const ndn::Name& name)
|
||||
{
|
||||
return npte.getNamePrefix() == name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
NamePrefixTable::addEntry(const ndn::Name& name, RoutingTableEntry& rte)
|
||||
{
|
||||
std::list<NamePrefixTableEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&npteCompare, _1, name));
|
||||
NptEntryList::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
if (it == m_table.end()) {
|
||||
NamePrefixTableEntry newEntry(name);
|
||||
newEntry.addRoutingTableEntry(rte);
|
||||
newEntry.generateNhlfromRteList();
|
||||
newEntry.getNexthopList().sort();
|
||||
m_table.push_back(newEntry);
|
||||
_LOG_TRACE("Adding origin: " << rte.getDestination() << " to new name prefix: " << name);
|
||||
|
||||
NamePrefixTableEntry entry(name);
|
||||
|
||||
entry.addRoutingTableEntry(rte);
|
||||
|
||||
entry.generateNhlfromRteList();
|
||||
entry.getNexthopList().sort();
|
||||
|
||||
m_table.push_back(entry);
|
||||
|
||||
if (rte.getNexthopList().getSize() > 0) {
|
||||
m_nlsr.getFib().update(name, newEntry.getNexthopList());
|
||||
_LOG_TRACE("Updating FIB with next hops for " << entry);
|
||||
m_nlsr.getFib().update(name, entry.getNexthopList());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (rte.getNexthopList().getSize() > 0) {
|
||||
(*it).addRoutingTableEntry(rte);
|
||||
(*it).generateNhlfromRteList();
|
||||
(*it).getNexthopList().sort();
|
||||
m_nlsr.getFib().update(name, (*it).getNexthopList());
|
||||
_LOG_TRACE("Adding origin: " << rte.getDestination() << " to existing prefix: " << *it);
|
||||
|
||||
it->addRoutingTableEntry(rte);
|
||||
|
||||
it->generateNhlfromRteList();
|
||||
it->getNexthopList().sort();
|
||||
|
||||
if (it->getNexthopList().getSize() > 0) {
|
||||
_LOG_TRACE("Updating FIB with next hops for " << *it);
|
||||
m_nlsr.getFib().update(name, it->getNexthopList());
|
||||
}
|
||||
else {
|
||||
(*it).resetRteListNextHop();
|
||||
(*it).getNexthopList().reset();
|
||||
// The routing table may recalculate and add a routing table entry with no next hops to
|
||||
// replace an existing routing table entry. In this case, the name prefix is no longer
|
||||
// reachable through a next hop and should be removed from the FIB. But, the prefix
|
||||
// should remain in the Name Prefix Table as a future routing table calculation may
|
||||
// add next hops.
|
||||
_LOG_TRACE(*it << " has no next hops; removing from FIB");
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
}
|
||||
@@ -78,38 +89,50 @@ NamePrefixTable::addEntry(const ndn::Name& name, RoutingTableEntry& rte)
|
||||
void
|
||||
NamePrefixTable::removeEntry(const ndn::Name& name, RoutingTableEntry& rte)
|
||||
{
|
||||
std::list<NamePrefixTableEntry>::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
ndn::bind(&npteCompare, _1, name));
|
||||
NptEntryList::iterator it = std::find_if(m_table.begin(),
|
||||
m_table.end(),
|
||||
bind(&npteCompare, _1, name));
|
||||
if (it != m_table.end()) {
|
||||
ndn::Name destRouter = rte.getDestination();
|
||||
(*it).removeRoutingTableEntry(rte);
|
||||
if (((*it).getRteListSize() == 0) &&
|
||||
(!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/name"),
|
||||
std::string("name"))) &&
|
||||
(!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/adjacency"),
|
||||
std::string("adjacency"))) &&
|
||||
(!m_nlsr.getLsdb().doesLsaExist(destRouter.append("/coordinate"),
|
||||
std::string("coordinate")))) {
|
||||
_LOG_TRACE("Removing origin: " << rte.getDestination() << " from prefix: " << *it);
|
||||
|
||||
it->removeRoutingTableEntry(rte);
|
||||
|
||||
// If the prefix is a router prefix and it does not have any other routing table entries,
|
||||
// the Adjacency/Coordinate LSA associated with that origin router has been removed from
|
||||
// the LSDB and so the router prefix should be removed from the Name Prefix Table.
|
||||
//
|
||||
// If the prefix is an advertised name prefix:
|
||||
// If another router advertises this name prefix, the RteList should have another entry
|
||||
// for that router; the next hops should be recalculated and installed in the FIB.
|
||||
//
|
||||
// If no other router advertises this name prefix, the RteList should be empty and the
|
||||
// prefix can be removed from the Name Prefix Table. Once a new Name LSA advertises this
|
||||
// prefix, a new entry for the prefix will be created.
|
||||
//
|
||||
if (it->getRteListSize() == 0) {
|
||||
_LOG_TRACE(*it << " has no routing table entries; removing from table and FIB");
|
||||
m_table.erase(it);
|
||||
m_nlsr.getFib().remove(name);
|
||||
}
|
||||
else {
|
||||
(*it).generateNhlfromRteList();
|
||||
m_nlsr.getFib().update(name, (*it).getNexthopList());
|
||||
_LOG_TRACE(*it << " has other routing table entries; updating FIB with next hops");
|
||||
it->generateNhlfromRteList();
|
||||
it->getNexthopList().sort();
|
||||
|
||||
m_nlsr.getFib().update(name, it->getNexthopList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
{
|
||||
//
|
||||
RoutingTableEntry* rteCheck =
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
if (rteCheck != 0) {
|
||||
addEntry(name, *(rteCheck));
|
||||
_LOG_DEBUG("Adding origin: " << destRouter << " to " << name);
|
||||
|
||||
RoutingTableEntry* rteCheck = m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
|
||||
if (rteCheck != nullptr) {
|
||||
addEntry(name, *rteCheck);
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
@@ -120,11 +143,12 @@ NamePrefixTable::addEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
void
|
||||
NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
{
|
||||
//
|
||||
RoutingTableEntry* rteCheck =
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
if (rteCheck != 0) {
|
||||
removeEntry(name, *(rteCheck));
|
||||
_LOG_DEBUG("Removing origin: " << destRouter << " from " << name);
|
||||
|
||||
RoutingTableEntry* rteCheck = m_nlsr.getRoutingTable().findRoutingTableEntry(destRouter);
|
||||
|
||||
if (rteCheck != nullptr) {
|
||||
removeEntry(name, *rteCheck);
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte(destRouter);
|
||||
@@ -135,19 +159,23 @@ NamePrefixTable::removeEntry(const ndn::Name& name, const ndn::Name& destRouter)
|
||||
void
|
||||
NamePrefixTable::updateWithNewRoute()
|
||||
{
|
||||
for (std::list<NamePrefixTableEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end(); ++it) {
|
||||
std::list<RoutingTableEntry> rteList = (*it).getRteList();
|
||||
for (std::list<RoutingTableEntry>::iterator rteit = rteList.begin();
|
||||
rteit != rteList.end(); ++rteit) {
|
||||
_LOG_DEBUG("Updating table with newly calculated routes");
|
||||
|
||||
// Update each name prefix entry in the Name Prefix Table with newly calculated next hops
|
||||
for (const NamePrefixTableEntry& prefixEntry : m_table) {
|
||||
for (const RoutingTableEntry& routingEntry : prefixEntry.getRteList()) {
|
||||
_LOG_TRACE("Updating next hops to origin: " << routingEntry.getDestination()
|
||||
<< " for prefix: " << prefixEntry);
|
||||
|
||||
RoutingTableEntry* rteCheck =
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
|
||||
if (rteCheck != 0) {
|
||||
addEntry((*it).getNamePrefix(), *(rteCheck));
|
||||
m_nlsr.getRoutingTable().findRoutingTableEntry(routingEntry.getDestination());
|
||||
|
||||
if (rteCheck != nullptr) {
|
||||
addEntry(prefixEntry.getNamePrefix(), *rteCheck);
|
||||
}
|
||||
else {
|
||||
RoutingTableEntry rte((*rteit).getDestination());
|
||||
addEntry((*it).getNamePrefix(), rte);
|
||||
RoutingTableEntry rte(routingEntry.getDestination());
|
||||
addEntry(prefixEntry.getNamePrefix(), rte);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,12 +184,19 @@ NamePrefixTable::updateWithNewRoute()
|
||||
void
|
||||
NamePrefixTable::writeLog()
|
||||
{
|
||||
_LOG_DEBUG("----------------NPT----------------------");
|
||||
for (std::list<NamePrefixTableEntry>::iterator it = m_table.begin();
|
||||
it != m_table.end();
|
||||
++it) {
|
||||
(*it).writeLog();
|
||||
}
|
||||
_LOG_DEBUG(*this);
|
||||
}
|
||||
|
||||
} //namespace nlsr
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTable& table)
|
||||
{
|
||||
os << "----------------NPT----------------------\n";
|
||||
|
||||
for (const NamePrefixTableEntry& entry : table) {
|
||||
os << entry << std::endl;
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace nlsr
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,25 +17,26 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef NLSR_NAME_PREFIX_TABLE_HPP
|
||||
#define NLSR_NAME_PREFIX_TABLE_HPP
|
||||
|
||||
#include <list>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include "name-prefix-table-entry.hpp"
|
||||
#include "routing-table-entry.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
|
||||
class NamePrefixTable
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::list<NamePrefixTableEntry> NptEntryList;
|
||||
typedef NptEntryList::const_iterator const_iterator;
|
||||
|
||||
NamePrefixTable(Nlsr& nlsr)
|
||||
: m_nlsr(nlsr)
|
||||
{
|
||||
@@ -52,6 +54,12 @@ public:
|
||||
void
|
||||
writeLog();
|
||||
|
||||
const_iterator
|
||||
begin() const;
|
||||
|
||||
const_iterator
|
||||
end() const;
|
||||
|
||||
private:
|
||||
void
|
||||
addEntry(const ndn::Name& name, RoutingTableEntry& rte);
|
||||
@@ -64,6 +72,21 @@ private:
|
||||
std::list<NamePrefixTableEntry> m_table;
|
||||
};
|
||||
|
||||
}//namespace nlsr
|
||||
inline NamePrefixTable::const_iterator
|
||||
NamePrefixTable::begin() const
|
||||
{
|
||||
return m_table.begin();
|
||||
}
|
||||
|
||||
#endif //NLSR_NAME_PREFIX_TABLE_HPP
|
||||
inline NamePrefixTable::const_iterator
|
||||
NamePrefixTable::end() const
|
||||
{
|
||||
return m_table.end();
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
operator<<(std::ostream& os, const NamePrefixTable& table);
|
||||
|
||||
} // namespace nlsr
|
||||
|
||||
#endif // NLSR_NAME_PREFIX_TABLE_HPP
|
||||
Loaded 100 of 180 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user