comm: do not use localhop for SVS
SVS does not work with localhop; Sync Interests need to
be forwarded at the network layer to all nodes in the group.
Change-Id: I32cba55f98f5a77257dd249d1b7c92d78460b39b
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index b9ab454..33ae4a0 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, The University of Memphis,
+ * Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -212,6 +212,38 @@
bool
ConfFileProcessor::processConfSectionGeneral(const ConfigSection& section)
{
+ // sync-protocol
+ std::string syncProtocol = section.get<std::string>("sync-protocol", "psync");
+ if (syncProtocol == "chronosync") {
+#ifdef HAVE_CHRONOSYNC
+ m_confParam.setSyncProtocol(SyncProtocol::CHRONOSYNC);
+#else
+ 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 'chronosync' or 'psync' or 'svs'\n";
+ return false;
+ }
+
try {
std::string network = section.get<std::string>("network");
std::string site = section.get<std::string>("site");
@@ -283,38 +315,6 @@
return false;
}
- // sync-protocol
- std::string syncProtocol = section.get<std::string>("sync-protocol", "psync");
- if (syncProtocol == "chronosync") {
-#ifdef HAVE_CHRONOSYNC
- m_confParam.setSyncProtocol(SyncProtocol::CHRONOSYNC);
-#else
- 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 'chronosync' or 'psync' or 'svs'\n";
- return false;
- }
-
// sync-interest-lifetime
uint32_t syncInterestLifetime = section.get<uint32_t>("sync-interest-lifetime",
SYNC_INTEREST_LIFETIME_DEFAULT);
diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp
index d1c6412..81c92ca 100644
--- a/src/conf-parameter.cpp
+++ b/src/conf-parameter.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, The University of Memphis,
+ * Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -96,7 +96,9 @@
{
m_network = networkName;
- m_syncPrefix.append("localhop");
+ if (m_syncProtocol != SyncProtocol::SVS) {
+ m_syncPrefix.append("localhop");
+ }
m_syncPrefix.append(m_network);
m_syncPrefix.append("nlsr");
m_syncPrefix.append("sync");
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 06c041c..8373266 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, The University of Memphis,
+ * Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -48,6 +48,15 @@
" state-dir /tmp\n"
"}\n\n";
+const std::string SECTION_GENERAL_SVS =
+ "general\n"
+ "{\n"
+ " network /ndn/\n"
+ " site /memphis.edu/\n"
+ " router /cs/pollux/\n"
+ " sync-protocol svs\n"
+ "}\n\n";
+
const std::string SECTION_NEIGHBORS =
"neighbors\n"
"{\n"
@@ -119,6 +128,8 @@
SECTION_HYPERBOLIC_ANGLES_ON + SECTION_FIB +
SECTION_ADVERTISING;
+const std::string CONFIG_SVS = SECTION_GENERAL_SVS;
+
class ConfFileProcessorFixture : public IoKeyChainFixture
{
public:
@@ -209,6 +220,16 @@
BOOST_CHECK_EQUAL(conf.getNamePrefixList().size(), 2);
}
+BOOST_AUTO_TEST_CASE(SVSPrefix)
+{
+ processConfigurationString(CONFIG_SVS);
+ conf.buildRouterAndSyncUserPrefix();
+
+ // SVS does not use localhop
+ BOOST_CHECK_EQUAL(conf.getNetwork(), "/ndn/");
+ BOOST_CHECK_EQUAL(conf.getSyncPrefix(), ndn::Name("/ndn/nlsr/sync").appendVersion(ConfParameter::SYNC_VERSION));
+}
+
BOOST_AUTO_TEST_CASE(MalformedUri)
{
const std::string MALFORMED_URI =