71 Commits
Author SHA1 Message Date
Vince Lehman 5363c7946b docs: Prepare version 0.2.1 release notes
Change-Id: Ibde6faea916ca90f3c11b7d1189c7044ca9bc5ec
2015-06-30 06:51:31 -07:00
Vince Lehman f4772d4f21 Fix compilation after namespace change in ndn-cxx
refs: #2951

Change-Id: Ia9f3caee4733e7f137b5f6f22f7e154069b37f69
2015-06-29 15:06:29 -05:00
alvy 46ccaae829 tests: Remove FaceDestroyEvent test's reliance on nlsrSeqNo.txt
refs: #2881

Change-Id: I32d329d058e9715ca5cdca74867b6588775e93ff
2015-06-26 11:28:20 -05:00
alvy c69c9af931 tests: Check ACTIVE/INACTIVE Adjacencies in LSA construction
refs #2735

Change-Id: I5d0c4940c0bc688a895a71603c9ea93b87cfba42
2015-06-26 10:49:01 -05:00
Vince Lehman d33e5bc475 update: Disable PrefixUpdateProcessor when validator is not in config
refs: 2814

Change-Id: I2669dcd4af36ebe09f3e20189a99c812e0e6ad7b
2015-06-24 11:33:57 -07:00
alvy dce3f18229 src: Fix non-incrementing Adjacency number in AdjLsa::writeLog
refs #2594

Change-Id: I64ae57060ffb95c92e86da356eb6ba80f1d77f06
2015-06-24 10:54:43 -05:00
Vince Lehman cae33b69f2 route: Prevent incomplete removal of NPT entry
refs: #2785

Change-Id: Ic8ff955236784db76c55b94bf9300fb21ea9beae
2015-06-08 11:59:47 -05:00
Vince Lehman 18df0602d3 docs: Change toctree order
Change-Id: I121f41b54afc10225f90ebb0a98ad4e444058bfe
2015-05-13 14:32:29 -07:00
Vince Lehman 41b173ed54 route: Correct bidirectional links with differing costs
refs: #2801

Change-Id: Iacabcb5484f4ccab6c74700dd8ebcf7b1ad99917
2015-05-11 10:11:22 -05:00
Vince Lehman 9630fbf4e0 route: Fix component appending in NamePrefixTable::removeEntry
refs: #2322

Change-Id: I511414be322dccc713d3eaef737edd87a51e8b51
2015-05-09 11:13:42 -07:00
Alexander Afanasyev a6f3e645f5 build: Update waf to version 1.8.9 (with custom patches)
https://github.com/cawka/waf/tree/2a098b1e9bc626c19cbd47c1f670758c17edf54c

Change-Id: Ibacc49368d81e1d2b9059b8153a86bcfc026a295
Refs: #2792
2015-05-06 14:52:35 -07:00
Vince Lehman de5560cd3d docs: Prepare version 0.2.0 release notes
Change-Id: I80a660fe23bb1bf2bfc35265b68e287df8921fe5
2015-04-30 11:07:34 -05:00
Vince Lehman 9551edf4d8 docs: Add OpenSSL exemption to license
Change-Id: If03222c482655f78c6b7343122e40323723df419
2015-04-30 10:28:19 -05:00
Vince Lehman 52493c7c19 ci: Add OpenSSL to Jenkins' dependencies
Change-Id: Ia17bb38ac57b6cdc1cffa516ee058c8a43235162
2015-04-30 10:22:48 -05:00
Vince Lehman 59dfac3569 docs: add OpenSSL dependency
Change-Id: I9739a444db03c29281c024bce9fd512ccbe2fe42
2015-04-29 17:17:57 -05:00
Vince Lehman c2acdcbbb6 security: Add permanent certificate storage for validator
refs: #2779

Change-Id: I5d9588136474b7eff3adf258a60aff0b7909bead
2015-04-29 12:49:22 -07:00
Vince Lehman c439d66728 tools: Add nlsrc command line tool
refs: #1834

Change-Id: Ifbe75a3f49e2689930e61ebfd348d9932b04c975
2015-04-27 15:49:04 -05:00
Vince Lehman d6bb3fa306 publisher: Serve LSDB dataset on localhost prefix
refs: #2737

Change-Id: I4cc9bd1d07dea583937676dd491ab5c68fd821ea
2015-04-24 17:13:58 -05:00
alvy 297f4163c2 update: Process Name prefix update commands
refs #1834

Change-Id: I18c86d0743b4a10ce3a8681f202b59a86602e43f
2015-04-23 09:08:18 -07:00
Vince Lehman 9d09780605 comm: Create SyncSocket on initialization
refs: #2649

Change-Id: I9e5891b8ad5de9a6ff6ac4edab4bab1564a309c8
2015-04-11 13:19:11 -05:00
Vince Lehman 199e9cf8d9 Don't build Adjacency LSA when destroyed face belongs to INACTIVE node
refs: #2733

Change-Id: I2a53bce876486980b380e9d8226b410bc754b034
2015-04-09 11:04:11 -05:00
Alexander Afanasyev 24ed83aa5e ci: Update Jenkins-CI build scripts and adding script for Travis-CI
Change-Id: I333c6af0d92f57e222665a0ce982ada6c276ae52
2015-04-02 18:42:11 -07:00
Vince Lehman cec3885c43 route: Add sorting tiebreaker to NexthopList
refs: #2715

Change-Id: Ida39efcec9c6eb976edaffb235450ee30565c493
2015-04-01 08:31:07 -07:00
Alexander Afanasyev fb2adee968 build: Update waf to version 1.8.8-dev (with custom patches)
https://github.com/cawka/waf/tree/8f714a523d3b8c66f2949aaa8db91d6f7be55e55

This patch also embeds the default configuration for PKG_CONFIG_PATH variable.

Change-Id: Ia297fbc8c39ab77ce911e0a9d96dae605eb4cc6e
2015-03-31 22:55:49 -07:00
Jiewen Tan a0497d8f5c publisher: add LSDB dataset publishers
refs #2280

Change-Id: Ifb1920ef9b807610890b0d0a04f24141d39f011d
2015-03-19 07:43:26 -07:00
Vince Lehman 02e32996c7 Recalculate routing table after face destroy event
refs: #2635

Change-Id: I7abbb638515af4a55c4241c4242a496a8cf8ca88
2015-03-16 12:05:16 -05:00
Vince Lehman 50df6b7981 src: Fix first event-interval scheduling
refs: #2615, #2593

Change-Id: I17da4d9acb83299a5666159fb988c1a97220eda8
2015-03-03 12:13:46 -06:00
Jiewen Tan 7a56d1c7c1 tlv: add LSDB dataset tlv abstractions
refs #2280

Change-Id: I2d0d238686e28d1c25a7821a47352fcd589df823
2015-03-02 11:07:55 -06:00
Alexander Afanasyev 75b0ea543f communication: Avoid deprecated Name::set method
Change-Id: Ic9898c1c6afce65078ab57d8a3bfb8b94c20b9ab
Refs: #2505
2015-02-26 18:30:32 -08:00
Alexander Afanasyev c035206443 tests: Avoid deprecated Name::set method
Change-Id: I53b92fdac0ae5ca7949cc6b6446eeb0cc9d6bc1b
Refs: #2505
2015-02-26 00:39:23 -08:00
Spyridon Mastorakis c00650f1ad nsync: Change of ndn::ptr_lib to std namespace
Change-Id: I38c3ba68b701709a3a1b41cce327e030a391ba17
Refs: #2110
2015-02-22 23:21:15 -08:00
Vince Lehman 6151e957cf src: Correct bitmask used to copy Name LSA SeqNo
refs: #2323

Change-Id: Ie67513b6228039538666e218f0c9c868ec0c1af8
2015-02-16 14:17:04 -06:00
Vince Lehman 9dce0c9445 src: Log exceptions thrown in event loop
Change-Id: If6bbf71f82adc69db7678e5034a0e8729cf027f4
2015-02-10 09:57:57 -06:00
Vince Lehman 7ccf694ae1 tests: Rewrite FaceController tests to not use DNS
refs: #2449

Change-Id: I5fe7537e171d60fbec2ecb3f3cd36cd625a0c324
2015-02-10 09:54:59 -06:00
Vince Lehman f814205d5c src: Subscribe to notifications using connect
refs: #2350

Change-Id: Ic4acedf78d2a0ea035a433ce2a05016a884503c6
2015-01-23 14:01:05 -08:00
Vince Lehman c2e51f6b6b src: Update copyright notices for files modified in 2015
refs: #2398

Change-Id: I83b7ad4da70cf784aa478295a873bf6411428acb
2015-01-22 11:25:03 -06:00
alvy d5a13cdaea src: Make log-level in nlsr.conf optional
refs: #2335

Change-Id: I185b6200ad1d7f16e3ca4b646ec20af83f983787
2015-01-22 10:16:47 -06:00
alvy 49b1c0c23f src: Replace LSA string literals with constants
refs: #2310

Change-Id: I0823c320400fe03b6268982cec05578c04d82ca8
2015-01-22 08:01:13 -08:00
alvy 5a45495e3e src: ConfParameter variables should be consistent with their min and max values
refs: #2084

Change-Id: Iae71da80ae47fca44ec46f4a3f0d4d86c77e5094
2015-01-21 08:53:46 -08:00
Vince Lehman c11cc20948 comm: Fix sync update prefix initialization
refs: #2399

Change-Id: I35c454e46c0b9552dba2a38b674d1ad3629f8bef
2015-01-20 11:41:58 -06:00
Vince Lehman 0bcf9a361d comm: Make SyncLogic responsible for update prefix
refs: #2289

Change-Id: I7687e36c88853bdf58de654b1ca280662a826b4b
2015-01-15 10:07:39 -08:00
Junxiao Shi f09e2633a0 docs: minor documentation corrections
Change-Id: I2e7b2d385f44ce894dcc2981e0fc6670df74aff1
2015-01-14 09:29:55 -08:00
Vince Lehman b45eed2d28 build: Require OpenSSL
refs: #2375

Change-Id: I0fe7c44b9e025bbe9a2e58cf0cab95069e668945
2015-01-14 09:50:08 -06:00
alvy a2228c6e1f src: Make conf keys with default values optional
refs: #1949

Change-Id: Ia9ba8707d27f2db96264f0480ffc72fd44a75099
2014-12-18 08:06:22 -08:00
sfayer 93d9ec37ea build: Set appname correctly in wscript
Change-Id: Ie8af3c7db0c50cba7f53d975135f8aebd42abf5c
2014-12-16 13:15:31 -08:00
Vince Lehman fc7d5b6fc5 conf: Add router-dead-interval to conf
refs: #2277

Change-Id: Ie03159585f21fd1a1cf9d4d7f1f159b5e59a2269
2014-12-10 11:56:19 -06:00
alvy 2fe12879bd src: Check validity of FaceURIs while loading conf
refs: #2070

Change-Id: I2278ab0a6367910495208a48c801f3af83bd43ec
2014-12-02 11:11:21 -06:00
Muktadir R Chowdhury bfa2760c57 conf: Add log4cxx path to conf file
refs: #1950

Change-Id: I51f9217c6ee40fd49a53d5f8294b60fb306e82ee
2014-11-21 17:53:05 -06:00
Alexander Afanasyev b669f9c02d build: Fix compilation against the latest version of ndn-cxx
Change-Id: Ie19e6432231a586efa9be1975e5601cf78c2dce9
2014-11-14 12:41:54 -08:00
Vince Lehman c292d18cd9 docs: Update authors
refs: #2093

Change-Id: Id0369b04e57d351f2f623bfc37a8442147c7a687
2014-11-12 12:16:44 -08:00
Junxiao Shi ee29a03a66 utility: avoid deprecated ndn::nfd::Controller(Face&) constructor
refs #2039

Change-Id: I1ffa2219f86a3d704e67c018c9c3dd6f87476346
2014-11-12 00:48:59 -07:00
Vince Lehman b7079a11a3 route: Replace deprecated nfd::Controller(Face&)
refs: #2133

Change-Id: Ie369f50a6a2f9101dda3ec0b28a3f2705c24cde8
2014-11-04 12:47:41 -06:00
Vince Lehman 0a7da61b45 Always build in C++11 mode
refs: #1930

Change-Id: Iedad4a814e5c7e6a5486f2f7e16c45c356131792
2014-10-30 10:43:53 -07:00
Alexander Afanasyev 7c8882ffac sync: Avoid use of boost::serialization::null_deleter
Refs: #2072

Change-Id: Ie860c2d09d38025750be056d03d71b5de58f1c5b
2014-10-29 14:11:45 -07:00
Alexander Afanasyev 1cf1e10389 conf: Add general.router-dead-interval configuration setting
refs: #1878

Change-Id: I21f2837118cda424904e0b0e60708a12deeabc8e
2014-10-29 14:45:21 -05:00
Vince Lehman 7b616582ed conf: Make event intervals configurable
User can specify the intervals for the first Hello Interest,
AdjLsa building, and routing calculation in the conf file.

refs: #2071

Change-Id: Ic8eb29d433069086955178bc42b5f8fc8f4149d3
2014-10-22 17:56:20 -05:00
Vince Lehman 27f1add26d util: Create Face with canonical FaceUri
refs: #1911

Change-Id: I13cc6522b5456d91a793365e33b2e53f9bd13e46
2014-10-21 08:38:40 -07:00
Junxiao Shi 92e5ffba6e tests: avoid usage of deprecated namespace ndn::Tlv
refs #2079

Change-Id: Iab8865fb607f8f3f2e530397f6224f37b0fc6a05
2014-10-19 09:45:55 -07:00
Ashlesh Gawande 5bf83175c3 src: Stop outdated LSA retrieval
refs: #1987

Change-Id: I5c2bbe75e4bb0a09d971a35db87591873f81a84b
2014-10-16 10:24:16 -05:00
Vince Lehman 20fe4a9cb0 route: Fix hyperbolic cost adjustment
refs: #1974

Change-Id: Ic96c94d978487bbef2804235b75aa227c350d941
2014-10-09 13:33:06 -07:00
Vince Lehman 942eb7b67d route: Fix FIB next hop removal bug
refs: #2018

Change-Id: Id107c04d4cdce9cc756acad5d262e5c1e0cc29a8
2014-10-08 16:01:09 -07:00
Vince Lehman f1aa52389a src: Sort names before std::set_difference
refs: #2029

Change-Id: I170f17cd69fd5a109913c6ebe9a13ab5552132a3
2014-10-08 12:51:25 -07:00
Vince Lehman 0913112f4a src: Assign 0 cost to hyperbolic direct neighbors
refs: #1975

Change-Id: I4349a7935d1defca4772c0b4bf806a4dd12a8e50
2014-10-08 12:35:28 -07:00
Vince Lehman e875d1f0e6 tests: Fix keychain and NextHop rounding error
Change-Id: Idd19c9a218363304dcf9fecb37a5cc2009b58cd0
2014-10-07 15:10:35 -05:00
Vince Lehman 9a7090334d route: Allow 0 cost in hyperbolic calculation
refs: #1982

Change-Id: I6ffe677d59dcb559f344b7d648600e9537d9c4f5
2014-10-02 11:25:28 -05:00
Vince Lehman 904c2413b2 comm: Stop SyncLogicHandler from fetching own LSAs
refs: #2005

Change-Id: I717a5258673dd5308fdf6561dbdb626ae4c74e9f
2014-10-01 17:22:36 -05:00
Vince Lehman 9f51efdbcb conf: Fix typos in security section
refs: #1985

Change-Id: I585ff9d6436db3102bc6860e428c95ca12fd6724
2014-09-18 14:47:55 -05:00
Vince Lehman 7c60329b07 src: Remove Scheduler instance from Nlsr class
refs: #1981

Change-Id: Iecbe9f975c2740ce04df8593ccde03486d4b7be8
2014-09-11 17:54:26 -05:00
Alexander Afanasyev c0b97af1cc build: Fix build error with python3
Change-Id: I2a35d66744330feefeb2c7f95a0f6e4e4c339358
Refs: #1956
2014-09-01 13:34:08 -07:00
Vince Lehman cb76aded0a src: Change adjacency status from uint32_t to enum
refs: #1946

Change-Id: Ic1abd2610061860d0ac183074395a1d3796e870a
2014-08-29 12:28:43 -07:00
Vince Lehman f99b87fe07 src: Add additional log levels
refs: #1935

Change-Id: Ie3ef3f04fbcadd8fb9ee6f3aade4a35bd2a88105
2014-08-29 11:58:18 -05:00
165 changed files with 12230 additions and 1616 deletions

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
.DS*
.waf-1*
.waf3-*
.lock*
**/*.pyc
build/
+4 -3
View File
@@ -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
+24 -4
View File
@@ -1,7 +1,27 @@
#!/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 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
+19 -26
View File
@@ -1,38 +1,31 @@
#!/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"
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 --without-osx-keychain
./waf -j1 --color=yes
sudo ./waf install --color=yes
sudo ./waf install -j1 --color=yes
popd >/dev/null
popd >/dev/null
+25 -4
View File
@@ -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
+3
View File
@@ -1,4 +1,7 @@
#!/usr/bin/env bash
set -x
set -e
rm -Rf ~/.ndn
./build/unit-tests-nlsr -l test_suite
+9
View File
@@ -0,0 +1,9 @@
has() {
local p=$1
shift
local x
for x in "$@"; do
[[ "${x}" == "${p}" ]] && return 0
done
return 1
}
+15
View File
@@ -0,0 +1,15 @@
sudo: true
language: cpp
os:
- linux
compiler:
- gcc
notifications:
email:
on_success: always
on_failure: always
env:
global:
- NODE_LABELS="Linux Ubuntu Ubuntu-12.04 Ubuntu-12.04-64bit Boost1.48"
script:
- ./.jenkins
+30 -20
View File
@@ -1,29 +1,17 @@
# -*- 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
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']
else:
defaultFlags += ['-std=c++03']
# defaultFlags += ['-pedantic', '-Wall', '-Wno-long-long']
defaultFlags += ['-Wall', '-Wno-long-long']
defaultFlags = ['-std=c++0x', '-std=c++11',
'-stdlib=libc++', # clang on OSX < 10.9 by default uses a non
# C++11-compatible STL library
'-Wall', '-Wno-long-long']
if conf.options.debug:
conf.define('_DEBUG', 1)
@@ -32,7 +20,11 @@ def configure(conf):
'-g3',
'-fcolor-diagnostics', # clang
'-fdiagnostics-color', # gcc >= 4.9
'-Werror'
'-Werror',
'-Wno-error=deprecated-register',
'-Wno-error=maybe-uninitialized', # Bug #1615
'-Wno-error=unneeded-internal-declaration', # Bug #1588
'-Wno-nested-anon-types',
]
if areCustomCxxflagsPresent:
missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
@@ -47,17 +39,35 @@ def configure(conf):
if not areCustomCxxflagsPresent:
conf.add_supported_cxxflags(defaultFlags)
# clang on OSX < 10.9 by default uses a non C++11-compatible STL library
conf.add_supported_linkflags(['-stdlib=libc++'])
@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')
self.start_msg('Checking allowed compile-stage flags for c++ compiler')
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
"""
self.start_msg('Checking allowed link-stage flags for c++ compiler')
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
+3 -2
View File
@@ -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',
+13 -7
View File
@@ -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,21 @@ 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>
* 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>
## 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 general question related to NLSR should be directed to Vince Lehman
(vslehman@memphis.edu) and security related question should be directed to
Yingdi Yu (yingdi@cs.ucla.edu)
+45
View File
@@ -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
View File
@@ -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
---------------
+6 -3
View File
@@ -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
View File
@@ -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
+124 -17
View File
@@ -1,6 +1,122 @@
Release Notes
=============
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 +129,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
+5 -6
View File
@@ -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
-----------------------------------
@@ -137,7 +136,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
View File
@@ -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/"
+4 -4
View File
@@ -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
+1
View File
@@ -6,4 +6,5 @@ Manpages
.. toctree::
manpages/nlsr
manpages/nlsr.conf
manpages/nlsrc
:maxdepth: 1
+55
View File
@@ -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
+70
View File
@@ -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
+11
View File
@@ -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
+98 -13
View File
@@ -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
@@ -178,7 +212,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 +244,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.
}
+49
View File
@@ -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
+2 -2
View File
@@ -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;
+4 -4
View File
@@ -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);
+3 -3
View File
@@ -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> >
>
+6 -9
View File
@@ -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 ());
+7 -7
View File
@@ -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;
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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
+1 -4
View File
@@ -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 {
+6 -6
View File
@@ -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
+5 -13
View File
@@ -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);
}
}
+6 -6
View File
@@ -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;
+5 -5
View File
@@ -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)
+3 -3
View File
@@ -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
View File
@@ -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
View File
@@ -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)
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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
+2 -3
View File
@@ -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;
+20 -12
View File
@@ -32,7 +32,15 @@
#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 +146,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 +165,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 +340,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 +362,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 +374,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 +492,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 +557,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 +586,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 +722,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 +733,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
View File
@@ -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;
+1 -1
View File
@@ -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"
+8 -8
View File
@@ -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)
+1 -4
View File
@@ -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
View File
@@ -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.
*
+8 -1
View File
@@ -23,7 +23,14 @@
#include <boost/lexical_cast.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");
+2
View File
@@ -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>
+3 -3
View File
@@ -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
View File
@@ -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
View File
@@ -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;
};
+4 -7
View File
@@ -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;
}
+4 -4
View File
@@ -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;
};
+24 -16
View File
@@ -22,8 +22,10 @@
**/
#include <algorithm>
#include <ndn-cxx/common.hpp>
#include "adjacency-list.hpp"
#include "adjacent.hpp"
#include "common.hpp"
#include "nlsr.hpp"
#include "logger.hpp"
@@ -61,15 +63,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 +168,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);
}
}
@@ -192,9 +200,9 @@ bool
AdjacencyList::isAdjLsaBuildable(Nlsr& pnlsr)
{
uint32_t nbrCount = 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) {
nbrCount++;
}
else {
@@ -214,9 +222,9 @@ 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++;
}
}
+25 -11
View File
@@ -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-2015, 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
@@ -34,16 +33,18 @@ 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 +61,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);
@@ -110,8 +111,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
View File
@@ -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
View File
@@ -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;
};
+36
View File
@@ -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
+231 -81
View File
@@ -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-2015, 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,88 +36,188 @@ 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);
_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::onNsyncRemoval(const string& prefix)
{
_LOG_DEBUG("Received Nsync removal event");
}
void
SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
{
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();
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 (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 (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 (isLsaNew(originRouter, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo())) {
_LOG_DEBUG("Received sync update with higher Adj LSA sequence number than entry in LSDB");
expressInterestForLsa(update, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo());
}
if (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);
if (isLsaNew(originRouter, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo())) {
_LOG_DEBUG("Received sync update with higher Cor LSA sequence number than entry in LSDB");
expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
}
}
catch (std::exception& e) {
@@ -124,24 +227,71 @@ SyncLogicHandler::processRoutingUpdateFromSync(const ndn::Name& routerName,
}
}
void
SyncLogicHandler::publishRoutingUpdate(SequencingManager& sm,
const ndn::Name& updatePrefix)
bool
SyncLogicHandler::isLsaNew(const ndn::Name& originRouter, const std::string& lsaType,
uint64_t seqNo)
{
sm.writeSeqNoToFile();
publishSyncUpdate(updatePrefix, sm.getCombinedSeqNo());
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::publishSyncUpdate(const ndn::Name& updatePrefix,
uint64_t seqNo)
SyncLogicHandler::expressInterestForLsa(const SyncUpdate& update, std::string lsaType,
uint64_t seqNo)
{
_LOG_DEBUG("Publishing Sync Update. Prefix: " << updatePrefix << "Seq no: " << 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
+51 -40
View File
@@ -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-2015, 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
View File
@@ -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-2015, 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;
}
+9 -2
View File
@@ -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
+107 -24
View File
@@ -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-2015, 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 {
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
View File
@@ -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();
}
}
}
+9 -8
View File
@@ -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-2015, 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>
*
**/
#ifndef NLSR_HELLO_PROTOCOL_HPP
#define NLSR_HELLO_PROTOCOL_HPP
#include <boost/cstdint.hpp>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/management/nfd-control-parameters.hpp>
#include <ndn-cxx/util/scheduler.hpp>
namespace nlsr {
@@ -33,14 +33,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);
@@ -80,6 +79,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
View File
@@ -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
View File
@@ -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
+42 -31
View File
@@ -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-2015, 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,11 +41,15 @@ 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;
}
@@ -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 += "|";
@@ -144,7 +147,7 @@ const ndn::Name
CoordinateLsa::getKey() const
{
ndn::Name key = m_origRouter;
key.append("coordinate");
key.append(CoordinateLsa::TYPE_STRING);
return key;
}
@@ -162,7 +165,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) + "|");
@@ -204,7 +207,7 @@ 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,
@@ -218,7 +221,7 @@ AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
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 +231,7 @@ const ndn::Name
AdjLsa::getKey() const
{
ndn::Name key = m_origRouter;
key.append("adjacency");
key.append(AdjLsa::TYPE_STRING);
return key;
}
@@ -243,7 +246,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 += "|";
@@ -286,7 +289,7 @@ 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) {
@@ -317,22 +320,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
+32 -9
View File
@@ -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-2015, 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
@@ -120,7 +119,7 @@ public:
: Lsa()
, m_npl()
{
setLsType("name");
setLsType(NameLsa::TYPE_STRING);
}
NameLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
@@ -159,17 +158,20 @@ 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()
, m_adl()
{
setLsType("adjacency");
setLsType(AdjLsa::TYPE_STRING);
}
AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
@@ -215,9 +217,25 @@ 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
@@ -228,7 +246,7 @@ public:
, m_corRad(0)
, m_corTheta(0)
{
setLsType("coordinate");
setLsType(CoordinateLsa::TYPE_STRING);
}
CoordinateLsa(const ndn::Name& origR, const std::string lst, uint32_t lsn,
@@ -278,8 +296,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
+159 -139
View File
@@ -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-2015, 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 <utility>
@@ -33,14 +32,16 @@ namespace nlsr {
INIT_LOGGER("Lsdb");
const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
const steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE = steady_clock::TimePoint::min();
using namespace std;
void
Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
{
m_nlsr.getScheduler().cancelEvent(eid);
m_scheduler.cancelEvent(eid);
}
static bool
@@ -54,7 +55,7 @@ bool
Lsdb::buildAndInstallOwnNameLsa()
{
NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
"name",
NameLsa::TYPE_STRING,
m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
getLsaExpirationTimePoint(),
m_nlsr.getNamePrefixList());
@@ -93,9 +94,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 +153,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 +249,12 @@ Lsdb::writeNameLsdbLog()
}
}
const std::list<NameLsa>&
Lsdb::getNameLsdb()
{
return m_nameLsdb;
}
// Cor LSA and LSDB related Functions start here
static bool
@@ -258,7 +267,7 @@ bool
Lsdb::buildAndInstallOwnCoordinateLsa()
{
CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
"coordinate",
CoordinateLsa::TYPE_STRING,
m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
getLsaExpirationTimePoint(),
m_nlsr.getConfParameter().getCorR(),
@@ -299,9 +308,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
@@ -418,6 +427,12 @@ Lsdb::writeCorLsdbLog()
}
}
const std::list<CoordinateLsa>&
Lsdb::getCoordinateLsdb()
{
return m_corLsdb;
}
// Adj LSA and LSDB related function starts here
static bool
@@ -427,9 +442,23 @@ adjLsaCompareByKey(AdjLsa& alsa, const ndn::Name& key)
}
void
Lsdb::scheduledAdjLsaBuild()
Lsdb::scheduleAdjLsaBuild()
{
_LOG_DEBUG("scheduledAdjLsaBuild Called");
m_nlsr.incrementAdjBuildCount();
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("buildAdjLsa called");
m_nlsr.setIsBuildAdjLsaSheduled(false);
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
int adjBuildCount = m_nlsr.getAdjBuildCount();
@@ -440,7 +469,7 @@ Lsdb::scheduledAdjLsaBuild()
}
else {
ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
key.append("adjacency");
key.append(AdjLsa::TYPE_STRING);
removeAdjLsa(key);
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
}
@@ -451,9 +480,8 @@ Lsdb::scheduledAdjLsaBuild()
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));
m_scheduler.scheduleEvent(ndn::time::seconds(schedulingTime),
ndn::bind(&Lsdb::buildAdjLsa, this));
}
}
@@ -505,9 +533,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 +589,16 @@ bool
Lsdb::buildAndInstallOwnAdjLsa()
{
AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
"adjacency",
AdjLsa::TYPE_STRING,
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);
m_sync.publishRoutingUpdate();
return installAdjLsa(adjLsa);
}
@@ -607,7 +630,7 @@ Lsdb::doesAdjLsaExist(const ndn::Name& key)
return true;
}
std::list<AdjLsa>&
const std::list<AdjLsa>&
Lsdb::getAdjLsdb()
{
return m_adjLsdb;
@@ -647,14 +670,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 +702,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");
@@ -729,14 +738,7 @@ 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);
m_sync.publishRoutingUpdate();
}
else {
_LOG_DEBUG("Other's Cor LSA, so removing form LSDB");
@@ -752,61 +754,68 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
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);
ndn::Interest interest(interestName);
uint64_t interestedLsSeqNo = interestName[-1].toNumber();
_LOG_DEBUG("Expressing Interest for LSA(name): " << interestName
<< " Seq number: " << interestedLsSeqNo);
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;
}
interest.setInterestLifetime(m_nlsr.getConfParameter().getLsaInterestLifetime());
_LOG_DEBUG("Expressing Interest for LSA: " << interestName << " Seq number: " << seqNo);
m_nlsr.getNlsrFace().expressInterest(interest,
ndn::bind(&Lsdb::onContent,
this, _2, deadline),
this, _2, deadline, lsaName, seqNo),
ndn::bind(&Lsdb::processInterestTimedOut,
this, _1, timeoutCount, deadline));
this, _1, 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);
const ndn::Name& interestName(interest.getName());
_LOG_DEBUG("Interest received for LSA: " << interestName);
string chkString("LSA");
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(),
chkString);
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);
}
}
}
@@ -829,11 +838,11 @@ Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
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 +852,11 @@ Lsdb::processInterestForNameLsa(const ndn::Interest& interest,
void
Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
const ndn::Name& lsaKey,
uint32_t interestedlsSeqNo)
uint64_t seqNo)
{
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,11 +866,11 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
void
Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
const ndn::Name& lsaKey,
uint32_t interestedlsSeqNo)
uint64_t seqNo)
{
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);
}
@@ -870,7 +879,8 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
void
Lsdb::onContent(const ndn::Data& data,
const steady_clock::TimePoint& deadline)
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
uint64_t seqNo)
{
_LOG_DEBUG("Received data for LSA(name): " << data.getName());
if (data.getSignature().hasKeyLocator()) {
@@ -881,13 +891,14 @@ Lsdb::onContent(const ndn::Data& data,
m_nlsr.getValidator().validate(data,
ndn::bind(&Lsdb::onContentValidated, this, _1),
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
deadline));
deadline, lsaName, seqNo));
}
void
Lsdb::retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
const steady_clock::TimePoint& deadline)
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
uint64_t seqNo)
{
_LOG_DEBUG("Retrying validation of LSA(name): " << data->getName());
if (data->getSignature().hasKeyLocator()) {
@@ -898,42 +909,39 @@ Lsdb::retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
m_nlsr.getValidator().validate(*data,
ndn::bind(&Lsdb::onContentValidated, this, _1),
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
deadline));
deadline, lsaName, seqNo));
}
void
Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
{
const ndn::Name& dataName = data->getName();
_LOG_DEBUG("Data validation successful for LSA(name): " << dataName);
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
_LOG_DEBUG("Data validation successful for LSA: " << dataName);
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 - 4));
uint64_t seqNo = dataName[-2].toNumber();
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
std::string interestedLsType = dataName[-3].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);
}
}
}
@@ -941,7 +949,8 @@ Lsdb::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data)
void
Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
const std::string& msg,
const steady_clock::TimePoint& deadline)
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
uint64_t seqNo)
{
_LOG_DEBUG("Validation Error: " << msg);
@@ -951,16 +960,21 @@ Lsdb::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
// 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));
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
if (it != m_highestSeqNo.end() && it->second == seqNo) {
_LOG_DEBUG("Scheduling revalidation attempt");
m_scheduler.scheduleEvent(m_nlsr.getConfParameter().getLsaInterestLifetime(),
ndn::bind(&Lsdb::retryContentValidation, this, data,
deadline, lsaName, seqNo));
}
}
}
void
Lsdb::processContentNameLsa(const ndn::Name& lsaKey,
uint32_t lsSeqNo, std::string& dataContent)
uint64_t lsSeqNo, std::string& dataContent)
{
if (isNameLsaNew(lsaKey, lsSeqNo)) {
NameLsa nameLsa;
@@ -975,7 +989,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 +1004,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;
@@ -1005,13 +1019,19 @@ 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::time::steady_clock::TimePoint& deadline, ndn::Name lsaName,
uint64_t seqNo)
{
const ndn::Name& interestName = interest.getName();
_LOG_DEBUG("Interest timed out for LSA(name): " << interestName);
_LOG_DEBUG("Interest timed out for LSA: " << interestName);
if (ndn::time::steady_clock::now() < deadline) {
expressInterest(interestName, retransmitNo + 1, deadline);
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
if (it != m_highestSeqNo.end() && it->second == seqNo) {
expressInterest(interestName, retransmitNo + 1, deadline);
}
}
}
@@ -1038,13 +1058,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;
+71 -21
View File
@@ -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-2015, 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_LSDB_HPP
#define NLSR_LSDB_HPP
@@ -28,24 +27,29 @@
#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)
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
: m_nlsr(nlsr)
, m_scheduler(scheduler)
, m_sync(sync)
, m_lsaRefreshTime(0)
, m_adjLsaBuildInterval(static_cast<uint32_t>(ADJ_LSA_BUILD_INTERVAL_DEFAULT))
{
}
bool
doesLsaExist(const ndn::Name& key, const std::string& lsType);
// function related to Name LSDB
@@ -68,6 +72,9 @@ public:
void
writeNameLsdbLog();
const std::list<NameLsa>&
getNameLsdb();
//function related to Cor LSDB
bool
buildAndInstallOwnCoordinateLsa();
@@ -87,9 +94,13 @@ public:
void
writeCorLsdbLog();
const std::list<CoordinateLsa>&
getCoordinateLsdb();
//function related to Adj LSDB
void
scheduledAdjLsaBuild();
scheduleAdjLsaBuild();
bool
buildAndInstallOwnAdjLsa();
@@ -99,15 +110,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();
@@ -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);
@@ -161,7 +190,7 @@ private:
public:
void
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
steady_clock::TimePoint deadline = steady_clock::TimePoint::min());
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
void
processInterest(const ndn::Name& name, const ndn::Interest& interest);
@@ -173,20 +202,21 @@ private:
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);
uint64_t seqNo);
void
onContent(const ndn::Data& data, const steady_clock::TimePoint& deadline);
onContent(const ndn::Data& data, const steady_clock::TimePoint& deadline,
ndn::Name lsaName, uint64_t seqNo);
/**
* @brief Retry validation after it fails
@@ -199,39 +229,50 @@ private:
*/
void
retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
const steady_clock::TimePoint& deadline);
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
uint64_t seqNo);
void
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
void
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, const std::string& msg,
const steady_clock::TimePoint& deadline);
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
uint64_t seqNo);
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:
void
processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
const steady_clock::TimePoint& deadline);
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
uint64_t seqNo);
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 +280,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
+30 -11
View File
@@ -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-2015, 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,23 +17,30 @@
*
* 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 <ndn-cxx/util/scheduler.hpp>
#include "conf-file-processor.hpp"
#include "logger.hpp"
#include "nlsr.hpp"
#include "version.hpp"
// boost needs to be included after ndn-cxx, otherwise there will be conflict with _1, _2, ...
#include <boost/asio.hpp>
#include <boost/cstdint.hpp>
namespace nlsr {
int
main(int32_t argc, char** argv)
{
Nlsr nlsr;
boost::asio::io_service ioService;
ndn::Scheduler scheduler(ioService);
ndn::Face face(ioService);
Nlsr nlsr(ioService, scheduler, face);
std::string programName(argv[0]);
nlsr.setConfFileName("nlsr.conf");
int32_t opt;
@@ -55,13 +63,22 @@ main(int32_t argc, char** argv)
return EXIT_FAILURE;
}
}
ConfFileProcessor cfp(nlsr, nlsr.getConfFileName());
if (!cfp.processConfFile()) {
std::cerr << "Error in configuration file processing! Exiting from NLSR" << std::endl;
return EXIT_FAILURE;
}
INIT_LOGGERS(nlsr.getConfParameter().getLogDir());
if (nlsr.getConfParameter().isLog4CxxConfAvailable()) {
INIT_LOG4CXX(nlsr.getConfParameter().getLog4CxxConfPath());
}
else {
INIT_LOGGERS(nlsr.getConfParameter().getLogDir(), nlsr.getConfParameter().getLogLevel());
}
INIT_LOGGER("Main");
nlsr.initialize();
if (nlsr.getIsSetDaemonProcess()) {
nlsr.daemonize();
@@ -70,7 +87,9 @@ main(int32_t argc, char** argv)
nlsr.startEventLoop();
}
catch (std::exception& e) {
_LOG_FATAL("ERROR: " << e.what());
std::cerr << "ERROR: " << e.what() << std::endl;
nlsr.getFib().clean();
nlsr.destroyFaces();
}
@@ -83,4 +102,4 @@ int
main(int32_t argc, char** argv)
{
return nlsr::main(argc, argv);
}
}
+12 -10
View File
@@ -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-2015, 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
+12 -7
View File
@@ -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-2015, 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
+123 -13
View File
@@ -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-2015, 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,51 @@ 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_helloProtocol(*this, scheduler)
, m_lsdbDatasetHandler(m_nlsrLsdb,
m_nlsrFace,
m_confParam.getRouterPrefix(),
m_keyChain)
, 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 +89,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
@@ -127,7 +182,9 @@ Nlsr::initialize()
m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
m_sequencingManager.initiateSeqNoFromFile();
m_syncLogicHandler.setSyncPrefix(m_confParam.getChronosyncPrefix().toUri());
m_syncLogicHandler.createSyncSocket(m_confParam.getChronosyncPrefix());
/* Logging start */
m_confParam.writeLog();
m_adjacencyList.writeLog();
@@ -138,11 +195,29 @@ Nlsr::initialize()
_LOG_DEBUG("Default NLSR identity: " << m_defaultIdentity);
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));
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
@@ -196,6 +271,16 @@ Nlsr::registerKeyPrefix()
}
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)
{
@@ -258,15 +343,40 @@ 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());
m_nlsrLsdb.scheduleAdjLsaBuild();
}
}
}
}
+75 -60
View File
@@ -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-2015, 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();
@@ -152,12 +133,6 @@ public:
return m_namePrefixList;
}
ndn::Scheduler&
getScheduler()
{
return m_scheduler;
}
ndn::Face&
getNlsrFace()
{
@@ -276,20 +251,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 +279,12 @@ public:
return m_defaultCertName;
}
update::PrefixUpdateProcessor&
getPrefixUpdateProcessor()
{
return m_prefixUpdateProcessor;
}
void
createFace(const std::string& faceUri,
const CommandSucceedCallback& onSuccess,
@@ -320,10 +299,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 +342,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;
@@ -360,15 +370,20 @@ private:
NamePrefixTable m_namePrefixTable;
SyncLogicHandler m_syncLogicHandler;
HelloProtocol m_helloProtocol;
LsdbDatasetInterestHandler m_lsdbDatasetHandler;
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::Name m_defaultCertName;
update::PrefixUpdateProcessor m_prefixUpdateProcessor;
ndn::nfd::FaceMonitor m_faceMonitor;
uint32_t m_firstHelloInterval;
};
} //namespace nlsr
+137
View File
@@ -0,0 +1,137 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2015, 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
+131
View File
@@ -0,0 +1,131 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2015, 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,139 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2015, 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,
const ndn::Name& routerName,
ndn::KeyChain& keyChain)
: LOCALHOST_COMMAND_PREFIX(ndn::Name(Nlsr::LOCALHOST_PREFIX).append(Lsdb::NAME_COMPONENT))
, ROUTER_NAME_COMMAND_PREFIX(ndn::Name(routerName).append(Lsdb::NAME_COMPONENT))
, m_face(face)
, m_keyChain(keyChain)
, m_adjacencyLsaPublisher(lsdb, face, keyChain)
, 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: " << ROUTER_NAME_COMMAND_PREFIX);
m_face.setInterestFilter(ROUTER_NAME_COMMAND_PREFIX,
std::bind(&LsdbDatasetInterestHandler::onInterest, this, _2,
std::cref(ROUTER_NAME_COMMAND_PREFIX)));
}
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,104 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2015, 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,
const ndn::Name& routerName,
ndn::KeyChain& keyChain);
void
startListeningOnLocalhost();
void
startListeningOnRouterPrefix();
const ndn::Name&
getLocalhostCommandPrefix()
{
return LOCALHOST_COMMAND_PREFIX;
}
const ndn::Name&
getRouterNameCommandPrefix()
{
return ROUTER_NAME_COMMAND_PREFIX;
}
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;
const ndn::Name ROUTER_NAME_COMMAND_PREFIX;
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
+69
View File
@@ -0,0 +1,69 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2015, 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
+62
View File
@@ -0,0 +1,62 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2015, 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
+129
View File
@@ -0,0 +1,129 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2015, 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)
{
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);
++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)
{
m_keyChain.sign(*data);
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
+2
View File
@@ -23,6 +23,8 @@
#include <iostream>
#include <list>
#include <utility>
#include "common.hpp"
#include "logger.hpp"
#include "face-map.hpp"
+1
View File
@@ -24,6 +24,7 @@
#define NLSR_FACE_MAP_HPP
#include <ndn-cxx/common.hpp>
#include <algorithm>
namespace nlsr {
+93 -76
View File
@@ -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
View File
@@ -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;
};
+19 -11
View File
@@ -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-2015, 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
+13 -12
View File
@@ -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-2015, 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
View File
@@ -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-2015, 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
+33 -10
View File
@@ -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-2015, 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
+15 -6
View File
@@ -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-2015, 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,11 +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 <iostream>
#include "common.hpp"
#include "nexthop-list.hpp"
#include "nexthop.hpp"
#include "logger.hpp"
@@ -47,7 +48,15 @@ nexthopRemoveCompare(NextHop& nh1, NextHop& nh2)
static bool
nextHopSortingComparator(const NextHop& nh1, const NextHop& nh2)
{
return nh1.getRouteCost() < nh2.getRouteCost();
if (nh1.getRouteCostAsAdjustedInteger() < nh2.getRouteCostAsAdjustedInteger()) {
return true;
}
else if (nh1.getRouteCostAsAdjustedInteger() == nh2.getRouteCostAsAdjustedInteger()) {
return nh1.getConnectingFaceUri() < nh2.getConnectingFaceUri();
}
else {
return false;
}
}
/**
+13
View File
@@ -73,6 +73,7 @@ public:
}
typedef std::list<NextHop>::iterator iterator;
typedef std::list<NextHop>::const_iterator const_iterator;
iterator
begin()
@@ -86,6 +87,18 @@ public:
return m_nexthopList.end();
}
const_iterator
cbegin() const
{
return m_nexthopList.begin();
}
const_iterator
cend() const
{
return m_nexthopList.end();
}
void
writeLog();
+37
View File
@@ -0,0 +1,37 @@
/* -*- 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/>.
*
*
**/
#include "nexthop.hpp"
namespace nlsr {
std::ostream&
operator<<(std::ostream& os, const NextHop& hop)
{
os << "Nexthop("
<< "face-uri: " << hop.getConnectingFaceUri()
<< ", cost: " << hop.getRouteCost() << ")";
return os;
}
}//namespace nlsr
+42 -2
View File
@@ -23,6 +23,8 @@
#ifndef NLSR_NEXTHOP_HPP
#define NLSR_NEXTHOP_HPP
#include "test-access-control.hpp"
#include <iostream>
#include <cmath>
#include <boost/cstdint.hpp>
@@ -34,10 +36,12 @@ public:
NextHop()
: m_connectingFaceUri()
, m_routeCost(0)
, m_isHyperbolic(false)
{
}
NextHop(const std::string& cfu, double rc)
: m_isHyperbolic(false)
{
m_connectingFaceUri = cfu;
m_routeCost = rc;
@@ -58,7 +62,15 @@ public:
uint64_t
getRouteCostAsAdjustedInteger() const
{
return static_cast<uint64_t>(m_routeCost*HYPERBOLIC_COST_ADJUSTMENT_FACTOR);
if (m_isHyperbolic) {
// Round the cost to better preserve decimal cost differences
// e.g. Without rounding: 12.3456 > 12.3454 -> 12345 = 12345
// With rounding: 12.3456 > 12.3454 -> 12346 > 12345
return static_cast<uint64_t>(round(m_routeCost*HYPERBOLIC_COST_ADJUSTMENT_FACTOR));
}
else {
return static_cast<uint64_t>(m_routeCost);
}
}
double
@@ -73,12 +85,40 @@ public:
m_routeCost = rc;
}
void
setHyperbolic(bool b)
{
m_isHyperbolic = b;
}
bool
isHyperbolic() const
{
return m_isHyperbolic;
}
private:
std::string m_connectingFaceUri;
double m_routeCost;
static const uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 100;
bool m_isHyperbolic;
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/** \brief Used to adjust floating point route costs to integers
* Since NFD uses integer route costs in the FIB, hyperbolic paths with similar route costs
* will be rounded to integers and installed with identical nexthop costs.
*
* e.g. costs 12.34 and 12.35 will be equal in NFD's FIB
*
* This multiplier is used to differentiate similar route costs in the FIB.
*
* e.g costs 12.34 and 12.35 will be installed into NFD's FIB as 12340 and 12350
*/
static const uint64_t HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000;
};
std::ostream&
operator<<(std::ostream& os, const NextHop& hop);
}//namespace nlsr
#endif //NLSR_NEXTHOP_HPP
+180 -142
View File
@@ -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-2015, 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 <iostream>
#include <cmath>
#include "lsdb.hpp"
@@ -30,6 +29,8 @@
#include "nlsr.hpp"
#include "logger.hpp"
#include <boost/math/constants/constants.hpp>
namespace nlsr {
INIT_LOGGER("RoutingTableCalculator");
@@ -38,17 +39,18 @@ using namespace std;
void
RoutingTableCalculator::allocateAdjMatrix()
{
adjMatrix = new double*[numOfRouter];
for (int i = 0; i < numOfRouter; ++i) {
adjMatrix[i] = new double[numOfRouter];
adjMatrix = new double*[m_nRouters];
for (size_t i = 0; i < m_nRouters; ++i) {
adjMatrix[i] = new double[m_nRouters];
}
}
void
RoutingTableCalculator::initMatrix()
{
for (int i = 0; i < numOfRouter; i++) {
for (int j = 0; j < numOfRouter; j++) {
for (size_t i = 0; i < m_nRouters; i++) {
for (size_t j = 0; j < m_nRouters; j++) {
adjMatrix[i][j] = 0;
}
}
@@ -58,27 +60,62 @@ void
RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap)
{
std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb();
for (std::list<AdjLsa>::iterator it = adjLsdb.begin();
it != adjLsdb.end() ; it++) {
int row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
for (std::list<AdjLsa>::iterator it = adjLsdb.begin(); it != adjLsdb.end() ; it++) {
int32_t row = pMap.getMappingNoByRouterName((*it).getOrigRouter());
std::list<Adjacent> adl = (*it).getAdl().getAdjList();
for (std::list<Adjacent>::iterator itAdl = adl.begin();
itAdl != adl.end() ; itAdl++) {
int col = pMap.getMappingNoByRouterName((*itAdl).getName());
for (std::list<Adjacent>::iterator itAdl = adl.begin(); itAdl != adl.end() ; itAdl++) {
int32_t col = pMap.getMappingNoByRouterName((*itAdl).getName());
double cost = (*itAdl).getLinkCost();
if ((row >= 0 && row < numOfRouter) && (col >= 0 && col < numOfRouter)) {
if ((row >= 0 && row < static_cast<int32_t>(m_nRouters)) &&
(col >= 0 && col < static_cast<int32_t>(m_nRouters)))
{
adjMatrix[row][col] = cost;
}
}
}
// Links that do not have the same cost for both directions should have their
// costs corrected:
//
// If the cost of one side of the link is 0, both sides of the link should have their cost
// corrected to 0.
//
// Otherwise, both sides of the link should use the larger of the two costs.
//
for (size_t row = 0; row < m_nRouters; ++row) {
for (size_t col = 0; col < m_nRouters; ++col) {
double toCost = adjMatrix[row][col];
double fromCost = adjMatrix[col][row];
if (fromCost != toCost) {
double correctedCost = 0.0;
if (toCost != 0 && fromCost != 0) {
// If both sides of the link are up, use the larger cost
correctedCost = std::max(toCost, fromCost);
}
_LOG_WARN("Cost between [" << row << "][" << col << "] and [" << col << "][" << row <<
"] are not the same (" << toCost << " != " << fromCost << "). " <<
"Correcting to cost: " << correctedCost);
adjMatrix[row][col] = correctedCost;
adjMatrix[col][row] = correctedCost;
}
}
}
}
void
RoutingTableCalculator::writeAdjMatrixLog()
{
for (int i = 0; i < numOfRouter; i++) {
for (size_t i = 0; i < m_nRouters; i++) {
string line="";
for (int j = 0; j < numOfRouter; j++) {
for (size_t j = 0; j < m_nRouters; j++) {
line += boost::lexical_cast<std::string>(adjMatrix[i][j]);
line += " ";
}
@@ -89,7 +126,7 @@ RoutingTableCalculator::writeAdjMatrixLog()
void
RoutingTableCalculator::adjustAdMatrix(int source, int link, double linkCost)
{
for (int i = 0; i < numOfRouter; i++) {
for (int i = 0; i < static_cast<int>(m_nRouters); i++) {
if (i == link) {
adjMatrix[source][i] = linkCost;
}
@@ -103,7 +140,8 @@ int
RoutingTableCalculator::getNumOfLinkfromAdjMatrix(int sRouter)
{
int noLink = 0;
for (int i = 0; i < numOfRouter; i++) {
for (size_t i = 0; i < m_nRouters; i++) {
if (adjMatrix[sRouter][i] > 0) {
noLink++;
}
@@ -116,7 +154,8 @@ RoutingTableCalculator::getLinksFromAdjMatrix(int* links,
double* linkCosts, int source)
{
int j = 0;
for (int i = 0; i < numOfRouter; i++) {
for (size_t i = 0; i < m_nRouters; i++) {
if (adjMatrix[source][i] > 0) {
links[j] = i;
linkCosts[j] = adjMatrix[source][i];
@@ -128,7 +167,7 @@ RoutingTableCalculator::getLinksFromAdjMatrix(int* links,
void
RoutingTableCalculator::freeAdjMatrix()
{
for (int i = 0; i < numOfRouter; ++i) {
for (size_t i = 0; i < m_nRouters; ++i) {
delete [] adjMatrix[i];
}
delete [] adjMatrix;
@@ -203,25 +242,25 @@ LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter)
{
int i;
int v, u;
int* Q = new int[numOfRouter];
int* Q = new int[m_nRouters];
int head = 0;
/* Initiate the Parent */
for (i = 0 ; i < numOfRouter; i++) {
for (i = 0 ; i < static_cast<int>(m_nRouters); i++) {
m_parent[i] = EMPTY_PARENT;
m_distance[i] = INF_DISTANCE;
Q[i] = i;
}
if (sourceRouter != NO_MAPPING_NUM) {
m_distance[sourceRouter] = 0;
sortQueueByDistance(Q, m_distance, head, numOfRouter);
while (head < numOfRouter) {
sortQueueByDistance(Q, m_distance, head, m_nRouters);
while (head < static_cast<int>(m_nRouters)) {
u = Q[head];
if (m_distance[u] == INF_DISTANCE) {
break;
}
for (v = 0 ; v < numOfRouter; v++) {
for (v = 0 ; v < static_cast<int>(m_nRouters); v++) {
if (adjMatrix[u][v] > 0) {
if (isNotExplored(Q, v, head + 1, numOfRouter)) {
if (isNotExplored(Q, v, head + 1, m_nRouters)) {
if (m_distance[u] + adjMatrix[u][v] < m_distance[v]) {
m_distance[v] = m_distance[u] + adjMatrix[u][v] ;
m_parent[v] = u;
@@ -230,22 +269,27 @@ LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter)
}
}
head++;
sortQueueByDistance(Q, m_distance, head, numOfRouter);
sortQueueByDistance(Q, m_distance, head, m_nRouters);
}
}
delete [] Q;
}
void
LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr,
RoutingTable& rt, Map& pMap, int sourceRouter)
LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
Map& pMap, uint32_t sourceRouter)
{
_LOG_DEBUG("LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called");
int nextHopRouter = 0;
for (int i = 0; i < numOfRouter ; i++) {
for (size_t i = 0; i < m_nRouters ; i++) {
if (i != sourceRouter) {
nextHopRouter = getLsNextHop(i, sourceRouter);
if (nextHopRouter != NO_NEXT_HOP) {
double routeCost = m_distance[i];
ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
std::string nextHopFace =
@@ -305,13 +349,13 @@ LinkStateRoutingTableCalculator::isNotExplored(int* Q,
void
LinkStateRoutingTableCalculator::allocateParent()
{
m_parent = new int[numOfRouter];
m_parent = new int[m_nRouters];
}
void
LinkStateRoutingTableCalculator::allocateDistance()
{
m_distance = new double[numOfRouter];
m_distance = new double[m_nRouters];
}
void
@@ -325,144 +369,138 @@ void LinkStateRoutingTableCalculator::freeDistance()
delete [] m_distance;
}
const double HyperbolicRoutingCalculator::MATH_PI = boost::math::constants::pi<double>();
const double HyperbolicRoutingCalculator::UNKNOWN_DISTANCE = -1.0;
const double HyperbolicRoutingCalculator::UNKNOWN_RADIUS = -1.0;
const int32_t HyperbolicRoutingCalculator::ROUTER_NOT_FOUND = -1.0;
void
HypRoutingTableCalculator::calculatePath(Map& pMap,
RoutingTable& rt, Nlsr& pnlsr)
HyperbolicRoutingCalculator::calculatePaths(Map& map, RoutingTable& rt,
Lsdb& lsdb, AdjacencyList& adjacencies)
{
allocateAdjMatrix();
initMatrix();
makeAdjMatrix(pnlsr, pMap);
ndn::Name routerName = pnlsr.getConfParameter().getRouterPrefix();
int sourceRouter = pMap.getMappingNoByRouterName(routerName);
int noLink = getNumOfLinkfromAdjMatrix(sourceRouter);
setNoLink(noLink);
allocateLinks();
allocateLinkCosts();
getLinksFromAdjMatrix(links, linkCosts, sourceRouter);
for (int i = 0 ; i < numOfRouter ; ++i) {
int k = 0;
if (i != sourceRouter) {
allocateNexthopRouters();
allocateDistanceToNeighbor();
allocateDistFromNbrToDest();
for (int j = 0; j < vNoLink; j++) {
double distToNbr = getHyperbolicDistance(pnlsr, pMap,
sourceRouter, links[j]);
double distToDestFromNbr = getHyperbolicDistance(pnlsr,
pMap, links[j], i);
if (distToDestFromNbr >= 0) {
m_nexthopRouters[k] = links[j];
m_distanceToNeighbor[k] = distToNbr;
m_distFromNbrToDest[k] = distToDestFromNbr;
k++;
_LOG_TRACE("Calculating hyperbolic paths");
int thisRouter = map.getMappingNoByRouterName(m_thisRouterName);
// Iterate over directly connected neighbors
std::list<Adjacent> neighbors = adjacencies.getAdjList();
for (std::list<Adjacent>::iterator adj = neighbors.begin(); adj != neighbors.end(); ++adj) {
// Don't calculate nexthops using an inactive router
if (adj->getStatus() == Adjacent::STATUS_INACTIVE) {
_LOG_TRACE(adj->getName() << " is inactive; not using it as a nexthop");
continue;
}
ndn::Name srcRouterName = adj->getName();
// Don't calculate nexthops for this router to other routers
if (srcRouterName == m_thisRouterName) {
continue;
}
std::string srcFaceUri = adj->getConnectingFaceUri();
// Install nexthops for this router to the neighbor; direct neighbors have a 0 cost link
addNextHop(srcRouterName, srcFaceUri, 0, rt);
int src = map.getMappingNoByRouterName(srcRouterName);
if (src == ROUTER_NOT_FOUND) {
_LOG_WARN(adj->getName() << " does not exist in the router map!");
continue;
}
// Get hyperbolic distance from direct neighbor to every other router
for (int dest = 0; dest < static_cast<int>(m_nRouters); ++dest) {
// Don't calculate nexthops to this router or from a router to itself
if (dest != thisRouter && dest != src) {
ndn::Name destRouterName = map.getRouterNameByMappingNo(dest);
double distance = getHyperbolicDistance(map, lsdb, srcRouterName, destRouterName);
// Could not compute distance
if (distance == UNKNOWN_DISTANCE) {
_LOG_WARN("Could not calculate hyperbolic distance from " << srcRouterName << " to " <<
destRouterName);
continue;
}
}
addHypNextHopsToRoutingTable(pnlsr, pMap, rt, k, i);
freeNexthopRouters();
freeDistanceToNeighbor();
freeDistFromNbrToDest();
}
}
freeLinks();
freeLinksCosts();
freeAdjMatrix();
}
void
HypRoutingTableCalculator::addHypNextHopsToRoutingTable(Nlsr& pnlsr, Map& pMap,
RoutingTable& rt, int noFaces, int dest)
{
ndn::Name destRouter = pMap.getRouterNameByMappingNo(dest);
for (int i = 0 ; i < noFaces ; ++i) {
ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(m_nexthopRouters[i]);
std::string nextHopFaceUri =
pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFaceUri();
NextHop nh(nextHopFaceUri, m_distFromNbrToDest[i]);
if (m_isDryRun) {
rt.addNextHopToDryTable(destRouter, nh);
}
else {
rt.addNextHop(destRouter, nh);
addNextHop(destRouterName, srcFaceUri, distance, rt);
}
}
}
}
double
HypRoutingTableCalculator::getHyperbolicDistance(Nlsr& pnlsr,
Map& pMap, int src, int dest)
HyperbolicRoutingCalculator::getHyperbolicDistance(Map& map, Lsdb& lsdb,
ndn::Name src, ndn::Name dest)
{
double distance = 0.0;
ndn::Name srcRouterKey = pMap.getRouterNameByMappingNo(src);
srcRouterKey.append("coordinate");
ndn::Name destRouterKey = pMap.getRouterNameByMappingNo(dest);
destRouterKey.append("coordinate");
CoordinateLsa* srcLsa = pnlsr.getLsdb().findCoordinateLsa(srcRouterKey);
CoordinateLsa* destLsa = pnlsr.getLsdb().findCoordinateLsa(destRouterKey);
_LOG_TRACE("Calculating hyperbolic distance from " << src << " to " << dest);
if ((srcLsa == 0) || (destLsa == 0)) {
return -1;
double distance = UNKNOWN_DISTANCE;
ndn::Name srcLsaKey = src;
srcLsaKey.append("coordinate");
CoordinateLsa* srcLsa = lsdb.findCoordinateLsa(srcLsaKey);
ndn::Name destLsaKey = dest;
destLsaKey.append("coordinate");
CoordinateLsa* destLsa = lsdb.findCoordinateLsa(destLsaKey);
// Coordinate LSAs do not exist for these routers
if (srcLsa == NULL || destLsa == NULL) {
return UNKNOWN_DISTANCE;
}
double srcRadius = srcLsa->getCorRadius();
double srcTheta = srcLsa->getCorTheta();
double destRadius = destLsa->getCorRadius();
double destTheta = destLsa->getCorTheta();
double diffTheta = fabs(srcTheta - destTheta);
if (diffTheta > MATH_PI) {
diffTheta = 2 * MATH_PI - diffTheta;
}
if (srcRadius != -1 && destRadius != -1) {
if (diffTheta == 0) {
distance = fabs(srcRadius - destRadius);
}
else {
distance = acosh((cosh(srcRadius) * cosh(destRadius)) -
(sinh(srcRadius) * sinh(destRadius) * cos(diffTheta)));
}
double srcRadius = srcLsa->getCorRadius();
double destRadius = destLsa->getCorRadius();
if (srcRadius == UNKNOWN_RADIUS && destRadius == UNKNOWN_RADIUS) {
return UNKNOWN_DISTANCE;
}
if (diffTheta == 0) {
distance = fabs(srcRadius - destRadius);
}
else {
distance = -1;
distance = acosh((cosh(srcRadius) * cosh(destRadius)) -
(sinh(srcRadius) * sinh(destRadius) * cos(diffTheta)));
}
_LOG_TRACE("Distance from " << src << " to " << dest << " is " << distance);
return distance;
}
void
HypRoutingTableCalculator::allocateNexthopRouters()
void HyperbolicRoutingCalculator::addNextHop(ndn::Name dest, std::string faceUri,
double cost, RoutingTable& rt)
{
m_nexthopRouters = new uint32_t[vNoLink];
}
NextHop hop(faceUri, cost);
hop.setHyperbolic(true);
void
HypRoutingTableCalculator::allocateDistanceToNeighbor()
{
m_distanceToNeighbor = new double[vNoLink];
}
_LOG_TRACE("Calculated " << hop << " for destination: " << dest);
void
HypRoutingTableCalculator::allocateDistFromNbrToDest()
{
m_distFromNbrToDest = new double[vNoLink];
}
void
HypRoutingTableCalculator::freeNexthopRouters()
{
delete [] m_nexthopRouters;
}
void
HypRoutingTableCalculator::freeDistanceToNeighbor()
{
delete [] m_distanceToNeighbor;
}
void
HypRoutingTableCalculator::freeDistFromNbrToDest()
{
delete [] m_distFromNbrToDest;
if (m_isDryRun) {
rt.addNextHopToDryTable(dest, hop);
}
else {
rt.addNextHop(dest, hop);
}
}
}//namespace nlsr
Loaded 100 of 165 files, more files were not shown because too many files have changed in this diff. Show more