communication: add SVS support

Change-Id: I74c5a091c8b1c05dd186a0c10849aa5bb4f39e50
Signed-off-by: Varun Patil <varunpatil@ucla.edu>
This commit is contained in:
Varun Patil committed 2022-12-05 15:27:56 +00:00
1 parent 65ee992149
commit 7d2d689d89
11 files changed
+208 -26

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
set -exo pipefail
PROJ=ndn-svs
pushd "$CACHE_DIR" >/dev/null
INSTALLED_VERSION=
NDN_CXX=$(ndnsec version)
OLD_NDN_CXX=$(cat "$PROJ-ndn-cxx.txt" || :)
if [[ $OLD_NDN_CXX != $NDN_CXX ]]; then
echo "$NDN_CXX" > "$PROJ-ndn-cxx.txt"
INSTALLED_VERSION=NONE
fi
if [[ -z $INSTALLED_VERSION ]]; then
INSTALLED_VERSION=$(git -C "$PROJ" rev-parse HEAD 2>/dev/null || echo NONE)
fi
sudo rm -rf "$PROJ-latest"
git clone --depth 1 "https://github.com/named-data/$PROJ.git" "$PROJ-latest"
LATEST_VERSION=$(git -C "$PROJ-latest" rev-parse HEAD 2>/dev/null || echo UNKNOWN)
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
sudo rm -rf "$PROJ"
mv "$PROJ-latest" "$PROJ"
else
sudo rm -rf "$PROJ-latest"
fi
sudo rm -fr /usr/local/include/"$PROJ"
sudo rm -f /usr/local/lib{,64}/lib"$PROJ"*
sudo rm -f /usr/local/lib{,64}/pkgconfig/"$PROJ".pc
pushd "$PROJ" >/dev/null
./waf --color=yes configure
./waf --color=yes build
sudo ./waf --color=yes install
popd >/dev/null
popd >/dev/null
if [[ $ID_LIKE == *fedora* ]]; then
sudo tee /etc/ld.so.conf.d/ndn.conf >/dev/null <<< /usr/local/lib64
fi
if [[ $ID_LIKE == *linux* ]]; then
sudo ldconfig
fi
+1 -1
View File
@@ -27,7 +27,7 @@ if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
fi
# Build in debug mode with tests
./waf --color=yes configure --debug --with-chronosync --with-tests $ASAN $COVERAGE
./waf --color=yes configure --debug --with-psync --with-chronosync --with-svs --with-tests $ASAN $COVERAGE
./waf --color=yes build
# (tests will be run against the debug version)
+3
View File
@@ -15,6 +15,9 @@ NLSR relies on third-party software, licensed under the following licenses:
- PSync is licensed under the terms of the
[GNU Lesser General Public License version 3](https://github.com/named-data/PSync/blob/master/COPYING.md)
- ndn-svs is licensed under the terms of the
[GNU Lesser General Public License v2.1](https://github.com/named-data/ndn-svs/blob/master/COPYING.md)
- The waf build system is licensed under the terms of the
[BSD license](https://github.com/named-data/NLSR/blob/master/waf)
+6
View File
@@ -23,6 +23,12 @@ Prerequisites
the ChronoSync library and build it according to the instructions available at
https://github.com/named-data/ChronoSync#build
- [Optional] SVS library
NLSR can be used with State Vector Sync as the underlying Sync protocol. Download
the ndn-svs library and build it according to the instructions available at
https://github.com/named-data/ndn-svs#installation
Build
-----
+36 -6
View File
@@ -18,10 +18,11 @@ A beginners guide to installing and testing NLSR on Fedora
The following instructions are based on the information provided at the
Named Data Networking project web page [NDNmain]_.
Before installing NLSR it is necessary to install different libraries and
programs: ndn-cxx, NFD, ChronoSync [optional], and PSync. This document describes
the necessary steps to correctly install these programs (§ `2 <#ndncxx>`__,
`3 <#nfd>`__ and `4 <#nlsr>`__) and a brief guide on how to configure
and test NLSR using a simple two-node network (§ `5 <#test>`__).
programs: ndn-cxx, NFD, ChronoSync [optional], ndn-svs [optional] and PSync.
This document describes the necessary steps to correctly install these
programs (§ `2 <#ndncxx>`__, `3 <#nfd>`__ and `4 <#nlsr>`__) and a brief
guide on how to configure and test NLSR using a simple two-node
network (§ `5 <#test>`__).
Many of the commands in this guide need to be executed as *root*.
Starting from Fedora 28, there is no need to set a root user
@@ -383,7 +384,36 @@ This command should display a line similar to the following:
libChronoSync.so.0.5.0 -> libChronoSync.so.0.5.0
4.3 Downloading and installing NLSR
4.3 [Optional] Installing SVS
-----------------------------
NLSR can also use State Vector Sync as the underlying Sync protocol,
using the ndn-svs library.
This library may be installed by running the following commands as a
regular user and at the directory defined at § `1 <#intro>`__:
::
$ git clone --depth 1 https://github.com/named-data/ndn-svs.git
$ cd ndn-svs
$ ./waf configure
$ ./waf
$ sudo ./waf install
The following command needs to be used again to configure the libraries:
::
$ sudo ldconfig -v | grep ndn-svs
This command should display a line similar to the following:
::
libndn-svs.so.0.0.1 -> libndn-svs.so.0.0.1
4.4 Downloading and installing NLSR
-----------------------------------
NLSR is downloaded and installed in a folder called *NLSR* which should
@@ -404,7 +434,7 @@ If ChronoSync support is needed for testing, please configure NLSR with:
$ ./waf configure --with-chronosync
4.4 Configuring NLSR
4.5 Configuring NLSR
--------------------
Create and configure the following directory by running the following
+1 -1
View File
@@ -19,7 +19,7 @@ general
; InterestLifetime (in seconds) for LSA fetching
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
; select sync protocol: chronosync or psync
; select sync protocol: chronosync / psync / svs
sync-protocol psync
; sync interest lifetime of ChronoSync/PSync in milliseconds
+41 -4
View File
@@ -58,7 +58,8 @@ SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face,
chronosync::Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME,
FIXED_SESSION);
break;
#endif
#endif // HAVE_CHRONOSYNC
#ifdef HAVE_PSYNC
case SyncProtocol::PSYNC:
NDN_LOG_DEBUG("Using PSync");
m_psyncLogic = std::make_shared<psync::FullProducer>(face,
@@ -69,6 +70,15 @@ SyncProtocolAdapter::SyncProtocolAdapter(ndn::Face& face,
[this] (auto&&... args) { onPSyncUpdate(std::forward<decltype(args)>(args)...); },
syncInterestLifetime);
break;
#endif // HAVE_PSYNC
#ifdef HAVE_SVS
case SyncProtocol::SVS:
NDN_LOG_DEBUG("Using SVS");
m_svsCore = std::make_shared<ndn::svs::SVSyncCore>(face,
syncPrefix,
[this] (auto&&... args) { onSvsUpdate(std::forward<decltype(args)>(args)...); });
break;
#endif // HAVE_SVS
default:
NDN_CXX_UNREACHABLE;
}
@@ -82,10 +92,16 @@ SyncProtocolAdapter::addUserNode(const ndn::Name& userPrefix)
case SyncProtocol::CHRONOSYNC:
m_chronoSyncLogic->addUserNode(userPrefix, chronosync::Logic::DEFAULT_NAME, FIXED_SESSION);
break;
#endif
#endif // HAVE_CHRONOSYNC
#ifdef HAVE_PSYNC
case SyncProtocol::PSYNC:
m_psyncLogic->addUserNode(userPrefix);
break;
#endif // HAVE_PSYNC
#ifdef HAVE_SVS
case SyncProtocol::SVS:
break;
#endif // HAVE_SVS
default:
NDN_CXX_UNREACHABLE;
}
@@ -99,10 +115,17 @@ SyncProtocolAdapter::publishUpdate(const ndn::Name& userPrefix, uint64_t seq)
case SyncProtocol::CHRONOSYNC:
m_chronoSyncLogic->updateSeqNo(seq, userPrefix);
break;
#endif
#endif // HAVE_CHRONOSYNC
#ifdef HAVE_PSYNC
case SyncProtocol::PSYNC:
m_psyncLogic->publishName(userPrefix, seq);
break;
#endif // HAVE_PSYNC
#ifdef HAVE_SVS
case SyncProtocol::SVS:
m_svsCore->updateSeqNo(seq, userPrefix);
break;
#endif // HAVE_SVS
default:
NDN_CXX_UNREACHABLE;
}
@@ -119,8 +142,9 @@ SyncProtocolAdapter::onChronoSyncUpdate(const std::vector<chronosync::MissingDat
m_syncUpdateCallback(update.session.getPrefix(-1), update.high, 0);
}
}
#endif
#endif // HAVE_CHRONOSYNC
#ifdef HAVE_PSYNC
void
SyncProtocolAdapter::onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates)
{
@@ -130,5 +154,18 @@ SyncProtocolAdapter::onPSyncUpdate(const std::vector<psync::MissingDataInfo>& up
m_syncUpdateCallback(update.prefix, update.highSeq, update.incomingFace);
}
}
#endif // HAVE_PSYNC
#ifdef HAVE_SVS
void
SyncProtocolAdapter::onSvsUpdate(const std::vector<ndn::svs::MissingDataInfo>& updates)
{
NLSR_LOG_TRACE("Received SVS update event");
for (const auto& update : updates) {
m_syncUpdateCallback(update.nodeId, update.high, 0);
}
}
#endif // HAVE_SVS
} // namespace nlsr
+29 -7
View File
@@ -30,7 +30,12 @@
#ifdef HAVE_CHRONOSYNC
#include <ChronoSync/logic.hpp>
#endif
#ifdef HAVE_PSYNC
#include <PSync/full-producer.hpp>
#endif
#ifdef HAVE_SVS
#include <ndn-svs/core.hpp>
#endif
namespace nlsr {
@@ -48,14 +53,14 @@ public:
ndn::time::milliseconds syncInterestLifetime,
SyncUpdateCallback syncUpdateCallback);
/*! \brief Add user node to ChronoSync or PSync
/*! \brief Add user node to Sync
*
* \param userPrefix the Name under which the application will publishData
*/
void
addUserNode(const ndn::Name& userPrefix);
/*! \brief Publish update to ChronoSync or PSync
/*! \brief Publish update to Sync
*
* NLSR forces sequences number on the sync protocol
* as it manages is its own sequence number by storing it in a file.
@@ -72,24 +77,36 @@ PUBLIC_WITH_TESTS_ELSE_PRIVATE:
*
* This function packages the sync information into discrete updates
* and passes those off to another function, m_syncUpdateCallback.
* \sa m_syncUpdateCallback
*
* \param v A container with the new information sync has received
* \param updates A container with the new information sync has received
*/
void
onChronoSyncUpdate(const std::vector<chronosync::MissingDataInfo>& updates);
#endif
#endif // HAVE_CHRONOSYNC
#ifdef HAVE_PSYNC
/*! \brief Hook function to call whenever PSync detects new data.
*
* This function packages the sync information into discrete updates
* and passes those off to another function, m_syncUpdateCallback.
* \sa m_syncUpdateCallback
*
* \param v A container with the new information sync has received
* \param updates A container with the new information sync has received
*/
void
onPSyncUpdate(const std::vector<psync::MissingDataInfo>& updates);
#endif // HAVE_PSYNC
#ifdef HAVE_SVS
/*! \brief Hook function to call whenever SVS detects new data.
*
* This function packages the sync information into discrete updates
* and passes those off to another function, m_syncUpdateCallback.
*
* \param updates A container with the new information sync has received
*/
void
onSvsUpdate(const std::vector<ndn::svs::MissingDataInfo>& updates);
#endif // HAVE_SVS
private:
SyncProtocol m_syncProtocol;
@@ -98,7 +115,12 @@ private:
#ifdef HAVE_CHRONOSYNC
std::shared_ptr<chronosync::Logic> m_chronoSyncLogic;
#endif
#ifdef HAVE_PSYNC
std::shared_ptr<psync::FullProducer> m_psyncLogic;
#endif
#ifdef HAVE_SVS
std::shared_ptr<ndn::svs::SVSyncCore> m_svsCore;
#endif
};
} // namespace nlsr
+15 -3
View File
@@ -289,17 +289,29 @@ ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
#ifdef HAVE_CHRONOSYNC
m_confParam.setSyncProtocol(SyncProtocol::CHRONOSYNC);
#else
std::cerr << "NLSR was compiled without ChronoSync support!\n"
<< "Only PSync support is currently available ('sync-protocol psync')\n";
std::cerr << "NLSR was compiled without ChronoSync support!\n";
return false;
#endif
}
else if (syncProtocol == "psync") {
#ifdef HAVE_PSYNC
m_confParam.setSyncProtocol(SyncProtocol::PSYNC);
#else
std::cerr << "NLSR was compiled without PSync support!\n";
return false;
#endif
}
else if (syncProtocol == "svs") {
#ifdef HAVE_SVS
m_confParam.setSyncProtocol(SyncProtocol::SVS);
#else
std::cerr << "NLSR was compiled without SVS support!\n";
return false;
#endif
}
else {
std::cerr << "Sync protocol '" << syncProtocol << "' is not supported!\n"
<< "Use either 'chronosync' or 'psync'\n";
<< "Use 'chronosync' or 'psync' or 'svs'\n";
return false;
}
+1
View File
@@ -38,6 +38,7 @@ namespace nlsr {
enum class SyncProtocol {
CHRONOSYNC,
PSYNC,
SVS,
};
enum {
+26 -4
View File
@@ -36,8 +36,21 @@ def options(opt):
optgrp = opt.add_option_group('NLSR Options')
optgrp.add_option('--with-tests', action='store_true', default=False,
help='Build unit tests')
optgrp.add_option('--with-chronosync', action='store_true', default=False,
optgrp.add_option('--with-chronosync', dest='with_chronosync', action='store_true', default=False,
help='Build with ChronoSync support')
optgrp.add_option('--without-chronosync', dest='with_chronosync', action='store_false', default=False,
help='Build without ChronoSync support')
optgrp.add_option('--with-psync', dest='with_psync', action='store_true', default=True,
help='Build with PSync support')
optgrp.add_option('--without-psync', dest='with_psync', action='store_false', default=True,
help='Build without PSync support')
optgrp.add_option('--with-svs', dest='with_svs', action='store_true', default=False,
help='Build with State Vector Sync support')
optgrp.add_option('--without-svs', dest='with_svs', action='store_false', default=False,
help='Build without State Vector Sync support')
def configure(conf):
conf.load(['compiler_cxx', 'gnu_dirs',
@@ -71,8 +84,17 @@ def configure(conf):
conf.check_cfg(package='ChronoSync', args=['ChronoSync >= 0.5.4', '--cflags', '--libs'],
uselib_store='CHRONOSYNC', pkg_config_path=pkg_config_path)
conf.check_cfg(package='PSync', args=['PSync >= 0.3.0', '--cflags', '--libs'],
uselib_store='PSYNC', pkg_config_path=pkg_config_path)
if conf.options.with_psync:
conf.check_cfg(package='PSync', args=['PSync >= 0.3.0', '--cflags', '--libs'],
uselib_store='PSYNC', pkg_config_path=pkg_config_path)
if conf.options.with_svs:
conf.check_cfg(package='libndn-svs', args=['libndn-svs >= 0.1.0', '--cflags', '--libs'],
uselib_store='SVS', pkg_config_path=pkg_config_path)
if not any((conf.options.with_chronosync, conf.options.with_psync, conf.options.with_svs)):
conf.fatal('Cannot compile without any Sync protocol. '
'Specify at least one of --with-psync or --with-svs or --with-chronosync')
conf.check_compiler_flags()
@@ -108,7 +130,7 @@ def build(bld):
target='nlsr-objects',
source=bld.path.ant_glob('src/**/*.cpp',
excl=['src/main.cpp']),
use='NDN_CXX BOOST CHRONOSYNC PSYNC',
use='NDN_CXX BOOST CHRONOSYNC PSYNC SVS',
includes='. src',
export_includes='. src')