Compare commits
11
Commits
NLSR-0.2.2
...
NLSR-0.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
800833b7ac | ||
|
|
e8e03ac303 | ||
|
|
5ec9ae4271 | ||
|
|
f7eec4f4c0 | ||
|
|
5c467f0ca8 | ||
|
|
aa3b085384 | ||
|
|
d02c3880d5 | ||
|
|
3ac0728e5a | ||
|
|
c778e814db | ||
|
|
af909fcc13 | ||
|
|
c69da0a350 |
No files matched your search
@@ -10,6 +10,7 @@ if has OSX $NODE_LABELS && ! has OSX-10.8-c++11-64bit $NODE_LABELS; then
|
||||
brew update
|
||||
brew upgrade
|
||||
brew install boost pkg-config sqlite cryptopp log4cxx protobuf openssl
|
||||
brew link --force openssl log4cxx protobuf
|
||||
brew cleanup
|
||||
fi
|
||||
|
||||
|
||||
+18
-9
@@ -1,15 +1,24 @@
|
||||
sudo: true
|
||||
language: cpp
|
||||
os:
|
||||
- linux
|
||||
compiler:
|
||||
- gcc
|
||||
sudo: required
|
||||
language: generic
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=g++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
|
||||
- os: osx
|
||||
env:
|
||||
- CXX=clang++
|
||||
- NODE_LABELS="OSX OSX-10.9"
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
||||
on_failure: always
|
||||
env:
|
||||
global:
|
||||
- NODE_LABELS="Linux Ubuntu Ubuntu-12.04 Ubuntu-12.04-64bit Boost1.48"
|
||||
script:
|
||||
- ./.jenkins
|
||||
+8
-3
@@ -28,6 +28,8 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* Minsheng Zhang <mzhang4@memphis.edu>
|
||||
* Syed Obaid Amin <http://obaidamin.weebly.com/>
|
||||
* Vince Lehman <http://vslehman.com>
|
||||
* Muktadir R Chowdhury <mrchwdhr@memphis.edu>
|
||||
* Nicholas Gordon <nmgordon@memphis.edu>
|
||||
|
||||
* University of California, Los Angeles
|
||||
|
||||
@@ -36,9 +38,12 @@ NLSR is an open source project includes contributions from the members of the
|
||||
* Spyridon Mastorakis <http://cs.ucla.edu/~mastorakis/>
|
||||
* Jiewen Tan <alanwake@ucla.edu>
|
||||
|
||||
* University of Arizona
|
||||
|
||||
* Junxiao Shi <https://www.cs.arizona.edu/people/shijunxiao/>
|
||||
|
||||
|
||||
## Queries about NLSR
|
||||
|
||||
Any general question related to NLSR should be directed to Vince Lehman
|
||||
(vslehman@memphis.edu) and security related question should be directed to
|
||||
Yingdi Yu (yingdi@cs.ucla.edu)
|
||||
Any question related to NLSR should be directed to Ashlesh Gawande (agawande@memphis.edu),
|
||||
Muktadir R Chowdhury (mrchwdhr@memphis.edu), and Nicholas Gordon (nmgordon@memphis.edu).
|
||||
@@ -1,6 +1,32 @@
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
NLSR version 0.3.0 (changes since version 0.2.2)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Release date: August 1, 2016
|
||||
|
||||
**Code changes**:
|
||||
|
||||
- Do not advertise Adjacency LSAs when hyperbolic routing is enabled (:issue:`2402`)
|
||||
|
||||
- Do not distribute coordinate LSAs when using link-state routing. (:issue:`3661`)
|
||||
|
||||
- LSAs should be segmented before they are published (:issue:`2965`)
|
||||
|
||||
- Don't use DummyClientFace::sentDatas (:issue:`3383`)
|
||||
|
||||
- Remove disabled security files (:issue:`2960`)
|
||||
|
||||
- Lsa type should be argument for base class LSA constructor (:issue:`2788`)
|
||||
|
||||
- Use ndn-cxx/DummyClientFace (:issue:`2637`)
|
||||
|
||||
**Bug fixes**:
|
||||
|
||||
- Unit tests cases are installed with `./waf install` (:issue:`3359`)
|
||||
|
||||
|
||||
NLSR version 0.2.2 (changes since version 0.2.1)
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ configuration commands follows:
|
||||
log-level INFO ; default value INFO, valid value DEBUG, INFO
|
||||
log-dir /var/log/nlsr/
|
||||
seq-dir /var/lib/nlsr/
|
||||
; log4cxx-conf /path/to/log4cxx-conf
|
||||
}
|
||||
|
||||
; the neighbors section contains the configuration for router's neighbors and hello's behavior
|
||||
@@ -104,6 +105,17 @@ configuration commands follows:
|
||||
|
||||
hello-interval 60 ; interest sending interval in seconds. Default value 60
|
||||
; valid values 30-90
|
||||
|
||||
; adj-lsa-build-interval is the time to wait in seconds after an Adjacency LSA build is scheduled
|
||||
; before actually building the Adjacency LSA
|
||||
|
||||
adj-lsa-build-interval 5 ; default value 5. Valid values 0-5. It is recommended that
|
||||
; adj-lsa-build-interval have a lower value than routing-calc-interval
|
||||
|
||||
; first-hello-interval is the time to wait in seconds before sending the first Hello Interest
|
||||
|
||||
first-hello-interval 10 ; Default value 10. Valid values 0-10
|
||||
|
||||
; neighbor command is used to configure router's neighbor. Each neighbor will need
|
||||
; one block of neighbor command
|
||||
|
||||
|
||||
@@ -187,7 +187,8 @@ security
|
||||
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><ksk-.*><ID-CERT>$
|
||||
k-expand \\1
|
||||
h-relation equal
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><>$
|
||||
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
|
||||
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
|
||||
p-expand \\1\\2
|
||||
}
|
||||
}
|
||||
|
||||
+19
-20
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,19 +17,16 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
|
||||
*
|
||||
**/
|
||||
#include <algorithm>
|
||||
#include <ndn-cxx/common.hpp>
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
|
||||
#include "adjacent.hpp"
|
||||
#include "common.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("AdjacencyList");
|
||||
@@ -197,25 +195,26 @@ AdjacencyList::getAdjList()
|
||||
}
|
||||
|
||||
bool
|
||||
AdjacencyList::isAdjLsaBuildable(Nlsr& pnlsr)
|
||||
AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
|
||||
{
|
||||
uint32_t nbrCount = 0;
|
||||
for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end() ; it++) {
|
||||
uint32_t nTimedOutNeighbors = 0;
|
||||
|
||||
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
nbrCount++;
|
||||
for (const Adjacent& adjacency : m_adjList) {
|
||||
|
||||
if (adjacency.getStatus() == Adjacent::STATUS_ACTIVE) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if ((*it).getInterestTimedOutNo() >=
|
||||
pnlsr.getConfParameter().getInterestRetryNumber()) {
|
||||
nbrCount++;
|
||||
}
|
||||
else if (adjacency.getInterestTimedOutNo() >= interestRetryNo) {
|
||||
nTimedOutNeighbors++;
|
||||
}
|
||||
}
|
||||
if (nbrCount == m_adjList.size()) {
|
||||
|
||||
if (nTimedOutNeighbors == m_adjList.size()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "adjacent.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
class Nlsr;
|
||||
|
||||
class AdjacencyList
|
||||
{
|
||||
@@ -74,7 +73,7 @@ public:
|
||||
addAdjacents(AdjacencyList& adl);
|
||||
|
||||
bool
|
||||
isAdjLsaBuildable(Nlsr& pnlsr);
|
||||
isAdjLsaBuildable(const uint32_t interestRetryNo) const;
|
||||
|
||||
int32_t
|
||||
getNumOfActiveNeighbor();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -201,8 +201,7 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
|
||||
|
||||
update.getSequencingManager().writeLog();
|
||||
|
||||
try {
|
||||
if (isLsaNew(originRouter, NameLsa::TYPE_STRING, update.getNameLsaSeqNo())) {
|
||||
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());
|
||||
@@ -210,20 +209,29 @@ SyncLogicHandler::processUpdateFromSync(const SyncUpdate& update)
|
||||
|
||||
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 (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
if (update.getAdjLsaSeqNo() != 0) {
|
||||
_LOG_ERROR("Tried to fetch an adjacency LSA when hyperbolic routing"
|
||||
<< " is enabled.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
expressInterestForLsa(update, AdjLsa::TYPE_STRING, update.getAdjLsaSeqNo());
|
||||
}
|
||||
}
|
||||
|
||||
if (isLsaNew(originRouter, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo())) {
|
||||
_LOG_DEBUG("Received sync update with higher Cor LSA sequence number than entry in LSDB");
|
||||
|
||||
expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
|
||||
if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
if (update.getCorLsaSeqNo() != 0) {
|
||||
_LOG_ERROR("Tried to fetch a coordinate LSA when link-state"
|
||||
<< " is enabled.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
expressInterestForLsa(update, CoordinateLsa::TYPE_STRING, update.getCorLsaSeqNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -86,7 +86,7 @@ enum {
|
||||
MAX_FACES_PER_PREFIX_MAX = 60
|
||||
};
|
||||
|
||||
enum {
|
||||
enum HyperbolicState {
|
||||
HYPERBOLIC_STATE_OFF = 0,
|
||||
HYPERBOLIC_STATE_ON = 1,
|
||||
HYPERBOLIC_STATE_DRY_RUN = 2,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -22,7 +22,8 @@
|
||||
#ifndef NLSR_HELLO_PROTOCOL_HPP
|
||||
#define NLSR_HELLO_PROTOCOL_HPP
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include "test-access-control.hpp"
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/management/nfd-control-parameters.hpp>
|
||||
#include <ndn-cxx/util/scheduler.hpp>
|
||||
@@ -59,9 +60,11 @@ private:
|
||||
void
|
||||
onContent(const ndn::Interest& interest, const ndn::Data& data);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
onContentValidated(const ndn::shared_ptr<const ndn::Data>& data);
|
||||
|
||||
private:
|
||||
void
|
||||
onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const std::string& msg);
|
||||
|
||||
+23
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -53,12 +53,12 @@ NameLsa::getKey() const
|
||||
return key;
|
||||
}
|
||||
|
||||
NameLsa::NameLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
NameLsa::NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl)
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
std::list<ndn::Name>& nl = npl.getNameList();
|
||||
@@ -97,12 +97,16 @@ NameLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != NameLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numName = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numName; i++) {
|
||||
@@ -130,13 +134,12 @@ NameLsa::writeLog()
|
||||
_LOG_DEBUG("name_lsa_end");
|
||||
}
|
||||
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, const string lst,
|
||||
uint32_t lsn,
|
||||
CoordinateLsa::CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta)
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_corRad = r;
|
||||
@@ -186,13 +189,17 @@ CoordinateLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != CoordinateLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
m_corRad = boost::lexical_cast<double>(*tok_iter++);
|
||||
m_corTheta = boost::lexical_cast<double>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -210,12 +217,12 @@ CoordinateLsa::writeLog()
|
||||
_LOG_DEBUG(" Hyperbolic Theta: " << m_corTheta);
|
||||
}
|
||||
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, const string& lst, uint32_t lsn,
|
||||
AdjLsa::AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl)
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
{
|
||||
m_origRouter = origR;
|
||||
m_lsType = lst;
|
||||
m_lsSeqNo = lsn;
|
||||
m_expirationTimePoint = lt;
|
||||
m_noLink = nl;
|
||||
@@ -276,12 +283,16 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
m_lsType = *tok_iter++;
|
||||
if (*tok_iter++ != AdjLsa::TYPE_STRING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lsSeqNo = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
m_expirationTimePoint = ndn::time::fromIsoString(*tok_iter++);
|
||||
numLink = boost::lexical_cast<uint32_t>(*tok_iter++);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
for (uint32_t i = 0; i < numLink; i++) {
|
||||
@@ -293,6 +304,7 @@ AdjLsa::initializeFromContent(const std::string& content)
|
||||
addAdjacent(adjacent);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
_LOG_ERROR(e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-19
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -32,24 +32,20 @@
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class Nlsr;
|
||||
|
||||
class Lsa
|
||||
{
|
||||
public:
|
||||
Lsa()
|
||||
Lsa(const std::string& lsaType)
|
||||
: m_origRouter()
|
||||
, m_lsType(lsaType)
|
||||
, m_lsSeqNo()
|
||||
, m_expirationTimePoint()
|
||||
, m_expiringEventId()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setLsType(const std::string& lst)
|
||||
{
|
||||
m_lsType = lst;
|
||||
}
|
||||
|
||||
const std::string&
|
||||
getLsType() const
|
||||
{
|
||||
@@ -106,7 +102,7 @@ public:
|
||||
|
||||
protected:
|
||||
ndn::Name m_origRouter;
|
||||
std::string m_lsType;
|
||||
const std::string m_lsType;
|
||||
uint32_t m_lsSeqNo;
|
||||
ndn::time::system_clock::TimePoint m_expirationTimePoint;
|
||||
ndn::EventId m_expiringEventId;
|
||||
@@ -116,13 +112,12 @@ class NameLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
NameLsa()
|
||||
: Lsa()
|
||||
: Lsa(NameLsa::TYPE_STRING)
|
||||
, m_npl()
|
||||
{
|
||||
setLsType(NameLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
NameLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
NameLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
NamePrefixList& npl);
|
||||
|
||||
@@ -168,13 +163,12 @@ public:
|
||||
typedef AdjacencyList::const_iterator const_iterator;
|
||||
|
||||
AdjLsa()
|
||||
: Lsa()
|
||||
: Lsa(AdjLsa::TYPE_STRING)
|
||||
, m_adl()
|
||||
{
|
||||
setLsType(AdjLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
AdjLsa(const ndn::Name& origR, const std::string& lst, uint32_t lsn,
|
||||
AdjLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
uint32_t nl , AdjacencyList& adl);
|
||||
|
||||
@@ -242,14 +236,13 @@ class CoordinateLsa: public Lsa
|
||||
{
|
||||
public:
|
||||
CoordinateLsa()
|
||||
: Lsa()
|
||||
: Lsa(CoordinateLsa::TYPE_STRING)
|
||||
, m_corRad(0)
|
||||
, m_corTheta(0)
|
||||
{
|
||||
setLsType(CoordinateLsa::TYPE_STRING);
|
||||
}
|
||||
|
||||
CoordinateLsa(const ndn::Name& origR, const std::string lst, uint32_t lsn,
|
||||
CoordinateLsa(const ndn::Name& origR, uint32_t lsn,
|
||||
const ndn::time::system_clock::TimePoint& lt,
|
||||
double r, double theta);
|
||||
|
||||
|
||||
+175
-140
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -19,24 +19,114 @@
|
||||
* NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
**/
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "lsdb.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include "logger.hpp"
|
||||
#include "nlsr.hpp"
|
||||
#include "publisher/segment-publisher.hpp"
|
||||
#include "utility/name-helper.hpp"
|
||||
|
||||
#include <ndn-cxx/security/signing-helpers.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
INIT_LOGGER("Lsdb");
|
||||
|
||||
class LsaContentPublisher : public SegmentPublisher<ndn::Face>
|
||||
{
|
||||
public:
|
||||
LsaContentPublisher(ndn::Face& face,
|
||||
ndn::KeyChain& keyChain,
|
||||
const ndn::time::milliseconds& freshnessPeriod,
|
||||
const std::string& content)
|
||||
: SegmentPublisher(face, keyChain, freshnessPeriod)
|
||||
, m_content(content)
|
||||
{
|
||||
}
|
||||
|
||||
virtual size_t
|
||||
generate(ndn::EncodingBuffer& outBuffer) {
|
||||
size_t totalLength = 0;
|
||||
totalLength += outBuffer.prependByteArray(reinterpret_cast<const uint8_t*>(m_content.c_str()),
|
||||
m_content.size());
|
||||
return totalLength;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_content;
|
||||
};
|
||||
|
||||
const ndn::Name::Component Lsdb::NAME_COMPONENT = ndn::Name::Component("lsdb");
|
||||
const ndn::time::seconds Lsdb::GRACE_PERIOD = ndn::time::seconds(10);
|
||||
const steady_clock::TimePoint Lsdb::DEFAULT_LSA_RETRIEVAL_DEADLINE = steady_clock::TimePoint::min();
|
||||
|
||||
using namespace std;
|
||||
Lsdb::Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync)
|
||||
: m_nlsr(nlsr)
|
||||
, m_scheduler(scheduler)
|
||||
, m_sync(sync)
|
||||
, m_lsaRefreshTime(0)
|
||||
, m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Failed to fetch LSA: " << lsaName << ", Error code: " << errorCode
|
||||
<< ", Message: " << msg);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
// If the SegmentFetcher failed due to an Interest timeout, it is safe to re-express
|
||||
// immediately since at the least the LSA Interest lifetime has elapsed.
|
||||
// Otherwise, it is necessary to delay the Interest re-expression to prevent
|
||||
// the potential for constant Interest flooding.
|
||||
ndn::time::seconds delay = m_nlsr.getConfParameter().getLsaInterestLifetime();
|
||||
|
||||
if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
|
||||
delay = ndn::time::seconds(0);
|
||||
}
|
||||
|
||||
m_scheduler.scheduleEvent(delay, std::bind(&Lsdb::expressInterest, this,
|
||||
interestName, retransmitNo + 1, deadline));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::afterFetchLsa(const ndn::ConstBufferPtr& bufferPtr, ndn::Name& interestName)
|
||||
{
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(ndn::Name(interestName));
|
||||
data->setContent(bufferPtr);
|
||||
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data->getName());
|
||||
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo > m_highestSeqNo[lsaName]) {
|
||||
m_highestSeqNo[lsaName] = seqNo;
|
||||
}
|
||||
else if (seqNo < m_highestSeqNo[lsaName]) {
|
||||
return;
|
||||
}
|
||||
|
||||
onContentValidated(data);
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::cancelScheduleLsaExpiringEvent(ndn::EventId eid)
|
||||
@@ -50,12 +140,10 @@ nameLsaCompareByKey(const NameLsa& nlsa1, const ndn::Name& key)
|
||||
return nlsa1.getKey() == key;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Lsdb::buildAndInstallOwnNameLsa()
|
||||
{
|
||||
NameLsa nameLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
NameLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getNameLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getNamePrefixList());
|
||||
@@ -267,13 +355,19 @@ bool
|
||||
Lsdb::buildAndInstallOwnCoordinateLsa()
|
||||
{
|
||||
CoordinateLsa corLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
CoordinateLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getCorLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getConfParameter().getCorR(),
|
||||
m_nlsr.getConfParameter().getCorTheta());
|
||||
m_nlsr.getSequencingManager().increaseCorLsaSeq();
|
||||
|
||||
// Sync coordinate LSAs if using HR or HR dry run.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getSequencingManager().increaseCorLsaSeq();
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
|
||||
installCoordinateLsa(corLsa);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -324,11 +418,12 @@ Lsdb::installCoordinateLsa(CoordinateLsa& clsa)
|
||||
clsa.writeLog();
|
||||
addCoordinateLsa(clsa);
|
||||
|
||||
// Register the LSA's origin router prefix
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().addEntry(clsa.getOrigRouter(),
|
||||
clsa.getOrigRouter());
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
if (clsa.getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
@@ -392,12 +487,12 @@ Lsdb::removeCoordinateLsa(const ndn::Name& key)
|
||||
_1, key));
|
||||
if (it != m_corLsdb.end()) {
|
||||
_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
(*it).writeLog();
|
||||
if ((*it).getOrigRouter() !=
|
||||
m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry((*it).getOrigRouter(),
|
||||
(*it).getOrigRouter());
|
||||
it->writeLog();
|
||||
|
||||
if (it->getOrigRouter() != m_nlsr.getConfParameter().getRouterPrefix()) {
|
||||
m_nlsr.getNamePrefixTable().removeEntry(it->getOrigRouter(), it->getOrigRouter());
|
||||
}
|
||||
|
||||
m_corLsdb.erase(it);
|
||||
return true;
|
||||
}
|
||||
@@ -446,6 +541,11 @@ Lsdb::scheduleAdjLsaBuild()
|
||||
{
|
||||
m_nlsr.incrementAdjBuildCount();
|
||||
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
// Don't build adjacency LSAs in hyperbolic routing
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_nlsr.getIsBuildAdjLsaSheduled() == false) {
|
||||
_LOG_DEBUG("Scheduling Adjacency LSA build in " << m_adjLsaBuildInterval);
|
||||
|
||||
@@ -457,32 +557,37 @@ Lsdb::scheduleAdjLsaBuild()
|
||||
void
|
||||
Lsdb::buildAdjLsa()
|
||||
{
|
||||
_LOG_TRACE("buildAdjLsa called");
|
||||
_LOG_TRACE("Lsdb::buildAdjLsa called");
|
||||
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(false);
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr)) {
|
||||
|
||||
if (m_nlsr.getAdjacencyList().isAdjLsaBuildable(m_nlsr.getConfParameter().getInterestRetryNumber())) {
|
||||
|
||||
int adjBuildCount = m_nlsr.getAdjBuildCount();
|
||||
|
||||
// Is the adjacency LSA build still necessary, or has another build
|
||||
// fulfilled this request?
|
||||
if (adjBuildCount > 0) {
|
||||
if (m_nlsr.getAdjacencyList().getNumOfActiveNeighbor() > 0) {
|
||||
_LOG_DEBUG("Building and installing Adj LSA");
|
||||
_LOG_DEBUG("Building and installing own Adj LSA");
|
||||
buildAndInstallOwnAdjLsa();
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Removing own Adj LSA; no ACTIVE neighbors")
|
||||
ndn::Name key = m_nlsr.getConfParameter().getRouterPrefix();
|
||||
key.append(AdjLsa::TYPE_STRING);
|
||||
|
||||
removeAdjLsa(key);
|
||||
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
|
||||
// Since more adjacency LSA builds may have been scheduled while this build
|
||||
// was in progress, decrease the build count by the number of scheduled
|
||||
// builds at the beginning of this build.
|
||||
m_nlsr.setAdjBuildCount(m_nlsr.getAdjBuildCount() - adjBuildCount);
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_nlsr.setIsBuildAdjLsaSheduled(true);
|
||||
int schedulingTime = m_nlsr.getConfParameter().getInterestRetryNumber() *
|
||||
m_nlsr.getConfParameter().getInterestResendTime();
|
||||
m_scheduler.scheduleEvent(ndn::time::seconds(schedulingTime),
|
||||
ndn::bind(&Lsdb::buildAdjLsa, this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -589,15 +694,16 @@ bool
|
||||
Lsdb::buildAndInstallOwnAdjLsa()
|
||||
{
|
||||
AdjLsa adjLsa(m_nlsr.getConfParameter().getRouterPrefix(),
|
||||
AdjLsa::TYPE_STRING,
|
||||
m_nlsr.getSequencingManager().getAdjLsaSeq() + 1,
|
||||
getLsaExpirationTimePoint(),
|
||||
m_nlsr.getAdjacencyList().getNumOfActiveNeighbor(),
|
||||
m_nlsr.getAdjacencyList());
|
||||
|
||||
m_nlsr.getSequencingManager().increaseAdjLsaSeq();
|
||||
|
||||
m_sync.publishRoutingUpdate();
|
||||
//Sync adjacency LSAs if link-state or dry-run HR is enabled.
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getSequencingManager().increaseAdjLsaSeq();
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
|
||||
return installAdjLsa(adjLsa);
|
||||
}
|
||||
@@ -643,7 +749,7 @@ Lsdb::setLsaRefreshTime(const seconds& lsaRefreshTime)
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::setThisRouterPrefix(string trp)
|
||||
Lsdb::setThisRouterPrefix(std::string trp)
|
||||
{
|
||||
m_thisRouterPrefix = trp;
|
||||
}
|
||||
@@ -729,7 +835,10 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
_LOG_DEBUG("Deleting Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
chkCorLsa->setLsSeqNo(chkCorLsa->getLsSeqNo() + 1);
|
||||
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsr.getSequencingManager().setCorLsaSeq(chkCorLsa->getLsSeqNo());
|
||||
}
|
||||
|
||||
chkCorLsa->setExpirationTimePoint(getLsaExpirationTimePoint());
|
||||
_LOG_DEBUG("Adding Coordinate Lsa");
|
||||
chkCorLsa->writeLog();
|
||||
@@ -738,20 +847,22 @@ Lsdb::exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
chkCorLsa->getKey(),
|
||||
chkCorLsa->getLsSeqNo(),
|
||||
m_lsaRefreshTime));
|
||||
m_sync.publishRoutingUpdate();
|
||||
// Only sync coordinate LSAs if link-state routing is disabled
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_sync.publishRoutingUpdate();
|
||||
}
|
||||
}
|
||||
else {
|
||||
_LOG_DEBUG("Other's Cor LSA, so removing form LSDB");
|
||||
removeCoordinateLsa(lsaKey);
|
||||
}
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() >= HYPERBOLIC_STATE_ON) {
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
m_nlsr.getRoutingTable().scheduleRoutingTableCalculation(m_nlsr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline)
|
||||
@@ -761,8 +872,6 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
}
|
||||
|
||||
ndn::Name lsaName = interestName.getSubName(0, interestName.size()-1);
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
uint64_t seqNo = interestName[-1].toNumber();
|
||||
|
||||
if (m_highestSeqNo.find(lsaName) == m_highestSeqNo.end()) {
|
||||
@@ -775,14 +884,15 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
return;
|
||||
}
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
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, lsaName, seqNo),
|
||||
ndn::bind(&Lsdb::processInterestTimedOut,
|
||||
this, _1, timeoutCount, deadline, lsaName, seqNo));
|
||||
_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
|
||||
ndn::util::SegmentFetcher::fetch(m_nlsr.getNlsrFace(), interest,
|
||||
m_nlsr.getValidator(),
|
||||
ndn::bind(&Lsdb::afterFetchLsa, this, _1, interestName),
|
||||
ndn::bind(&Lsdb::onFetchLsaError, this, _1, _2, interestName,
|
||||
timeoutCount, deadline, lsaName, seqNo));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -791,7 +901,7 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
const ndn::Name& interestName(interest.getName());
|
||||
_LOG_DEBUG("Interest received for LSA: " << interestName);
|
||||
|
||||
string chkString("LSA");
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(interest.getName(), chkString);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
@@ -823,16 +933,12 @@ Lsdb::processInterest(const ndn::Name& name, const ndn::Interest& interest)
|
||||
void
|
||||
Lsdb::putLsaData(const ndn::Interest& interest, const std::string& content)
|
||||
{
|
||||
ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
|
||||
data->setName(ndn::Name(interest.getName()).appendVersion());
|
||||
data->setFreshnessPeriod(m_lsaRefreshTime);
|
||||
data->setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.size());
|
||||
m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName());
|
||||
ndn::SignatureSha256WithRsa signature(data->getSignature());
|
||||
ndn::Name signingCertName = signature.getKeyLocator().getName();
|
||||
_LOG_DEBUG("Sending data for LSA(name): " << interest.getName());
|
||||
_LOG_DEBUG("Data signed with: " << signingCertName);
|
||||
m_nlsr.getNlsrFace().put(*data);
|
||||
LsaContentPublisher publisher(m_nlsr.getNlsrFace(),
|
||||
m_nlsr.getKeyChain(),
|
||||
m_lsaRefreshTime,
|
||||
content);
|
||||
publisher.publish(interest.getName(),
|
||||
ndn::security::signingByCertificate(m_nlsr.getDefaultCertName()));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -854,6 +960,10 @@ Lsdb::processInterestForAdjacencyLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
_LOG_ERROR("Received interest for an adjacency LSA when hyperbolic routing is enabled.");
|
||||
}
|
||||
|
||||
AdjLsa* adjLsa = m_nlsr.getLsdb().findAdjLsa(lsaKey);
|
||||
if (adjLsa != 0) {
|
||||
if (adjLsa->getLsSeqNo() == seqNo) {
|
||||
@@ -868,6 +978,10 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
if (m_nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
_LOG_ERROR("Received Interest for a coordinate LSA when link-state routing is enabled.");
|
||||
}
|
||||
|
||||
CoordinateLsa* corLsa = m_nlsr.getLsdb().findCoordinateLsa(lsaKey);
|
||||
if (corLsa != 0) {
|
||||
if (corLsa->getLsSeqNo() == seqNo) {
|
||||
@@ -877,59 +991,24 @@ Lsdb::processInterestForCoordinateLsa(const ndn::Interest& interest,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::onContent(const ndn::Data& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Received data for LSA(name): " << data.getName());
|
||||
if (data.getSignature().hasKeyLocator()) {
|
||||
if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline, lsaName, seqNo));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Retrying validation of LSA(name): " << data->getName());
|
||||
if (data->getSignature().hasKeyLocator()) {
|
||||
if (data->getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) {
|
||||
_LOG_DEBUG("Data signed with: " << data->getSignature().getKeyLocator().getName());
|
||||
}
|
||||
}
|
||||
m_nlsr.getValidator().validate(*data,
|
||||
ndn::bind(&Lsdb::onContentValidated, this, _1),
|
||||
ndn::bind(&Lsdb::onContentValidationFailed, this, _1, _2,
|
||||
deadline, 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: " << dataName);
|
||||
|
||||
string chkString("LSA");
|
||||
std::string chkString("LSA");
|
||||
int32_t lsaPosition = util::getNameComponentPosition(dataName, chkString);
|
||||
|
||||
if (lsaPosition >= 0) {
|
||||
|
||||
ndn::Name originRouter = m_nlsr.getConfParameter().getNetwork();
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 4));
|
||||
originRouter.append(dataName.getSubName(lsaPosition + 1, dataName.size() - lsaPosition - 3));
|
||||
|
||||
uint64_t seqNo = dataName[-2].toNumber();
|
||||
string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
uint64_t seqNo = dataName[-1].toNumber();
|
||||
std::string dataContent(reinterpret_cast<const char*>(data->getContent().value()));
|
||||
|
||||
std::string interestedLsType = dataName[-3].toUri();
|
||||
std::string interestedLsType = dataName[-2].toUri();
|
||||
|
||||
if (interestedLsType == NameLsa::TYPE_STRING) {
|
||||
processContentNameLsa(originRouter.append(interestedLsType), seqNo, dataContent);
|
||||
@@ -946,32 +1025,6 @@ 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, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
_LOG_DEBUG("Validation Error: " << msg);
|
||||
|
||||
// Delay re-validation by LSA Interest Lifetime. When error callback will have an error
|
||||
// code, re-validation should be done only when some keys from certification chain failed
|
||||
// to be fetched. After that change, delaying will no longer be necessary.
|
||||
|
||||
// Stop retrying if delayed re-validation will be scheduled pass the deadline
|
||||
if (steady_clock::now() + m_nlsr.getConfParameter().getLsaInterestLifetime() < deadline) {
|
||||
|
||||
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,
|
||||
uint64_t lsSeqNo, std::string& dataContent)
|
||||
@@ -1017,24 +1070,6 @@ Lsdb::processContentCoordinateLsa(const ndn::Name& lsaKey,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Lsdb::processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo)
|
||||
{
|
||||
const ndn::Name& interestName = interest.getName();
|
||||
_LOG_DEBUG("Interest timed out for LSA: " << interestName);
|
||||
|
||||
if (ndn::time::steady_clock::now() < deadline) {
|
||||
|
||||
SequenceNumberMap::const_iterator it = m_highestSeqNo.find(lsaName);
|
||||
|
||||
if (it != m_highestSeqNo.end() && it->second == seqNo) {
|
||||
expressInterest(interestName, retransmitNo + 1, deadline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ndn::time::system_clock::TimePoint
|
||||
Lsdb::getLsaExpirationTimePoint()
|
||||
{
|
||||
|
||||
+43
-47
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <utility>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/util/time.hpp>
|
||||
|
||||
@@ -41,19 +42,12 @@ class SyncLogicHandler;
|
||||
class Lsdb
|
||||
{
|
||||
public:
|
||||
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))
|
||||
{
|
||||
}
|
||||
Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler, SyncLogicHandler& sync);
|
||||
|
||||
bool
|
||||
doesLsaExist(const ndn::Name& key, const std::string& lsType);
|
||||
// function related to Name LSDB
|
||||
|
||||
// functions related to Name LSDB
|
||||
bool
|
||||
buildAndInstallOwnNameLsa();
|
||||
|
||||
@@ -75,7 +69,7 @@ public:
|
||||
const std::list<NameLsa>&
|
||||
getNameLsdb();
|
||||
|
||||
//function related to Cor LSDB
|
||||
// functions related to Cor LSDB
|
||||
bool
|
||||
buildAndInstallOwnCoordinateLsa();
|
||||
|
||||
@@ -97,8 +91,7 @@ public:
|
||||
const std::list<CoordinateLsa>&
|
||||
getCoordinateLsdb();
|
||||
|
||||
//function related to Adj LSDB
|
||||
|
||||
// functions related to Adj LSDB
|
||||
void
|
||||
scheduleAdjLsaBuild();
|
||||
|
||||
@@ -141,6 +134,13 @@ public:
|
||||
void
|
||||
setThisRouterPrefix(std::string trp);
|
||||
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
bool
|
||||
addNameLsa(NameLsa& nlsa);
|
||||
@@ -187,15 +187,7 @@ private:
|
||||
void
|
||||
exprireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
public:
|
||||
void
|
||||
expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
|
||||
steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
|
||||
|
||||
void
|
||||
processInterest(const ndn::Name& name, const ndn::Interest& interest);
|
||||
|
||||
private:
|
||||
void
|
||||
putLsaData(const ndn::Interest& interest, const std::string& content);
|
||||
|
||||
@@ -214,32 +206,9 @@ private:
|
||||
const ndn::Name& lsaKey,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
onContent(const ndn::Data& data, const steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName, uint64_t seqNo);
|
||||
|
||||
/**
|
||||
* @brief Retry validation after it fails
|
||||
*
|
||||
* Data packet validation can fail either because the packet does not have
|
||||
* valid signature (fatal) or because some of the certificate chain Data packets
|
||||
* failed to be fetched (non-fatal). Currently, the library does not provide
|
||||
* clear indication (besides plain-text message in error callback) of what is
|
||||
* the reason for failure and we will try to re-validate for as long as it the deadline.
|
||||
*/
|
||||
void
|
||||
retryContentValidation(const ndn::shared_ptr<const ndn::Data>& data,
|
||||
const steady_clock::TimePoint& deadline, 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, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
void
|
||||
processContentNameLsa(const ndn::Name& lsaKey,
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
@@ -253,10 +222,37 @@ private:
|
||||
uint64_t lsSeqNo, std::string& dataContent);
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
/**
|
||||
* @brief Error callback when SegmentFetcher fails to return an LSA
|
||||
*
|
||||
* In all error cases, a reattempt to fetch the LSA will be made.
|
||||
*
|
||||
* Segment validation can fail either because the packet does not have a
|
||||
* valid signature (fatal) or because some of the certificates in the trust chain
|
||||
* could not be fetched (non-fatal).
|
||||
*
|
||||
* Currently, the library does not provide clear indication (besides a plain-text message
|
||||
* in the error callback) of the reason for the failure nor the segment that failed
|
||||
* to be validated, thus we will continue to try to fetch the LSA until the deadline
|
||||
* is reached.
|
||||
*/
|
||||
void
|
||||
processInterestTimedOut(const ndn::Interest& interest, uint32_t retransmitNo,
|
||||
const steady_clock::TimePoint& deadline, ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
onFetchLsaError(uint32_t errorCode,
|
||||
const std::string& msg,
|
||||
ndn::Name& interestName,
|
||||
uint32_t retransmitNo,
|
||||
const ndn::time::steady_clock::TimePoint& deadline,
|
||||
ndn::Name lsaName,
|
||||
uint64_t seqNo);
|
||||
|
||||
/**
|
||||
* @brief Success callback when SegmentFetcher returns a valid LSA
|
||||
*
|
||||
* \param The base Interest used to fetch the LSA in the format:
|
||||
* /<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
|
||||
*/
|
||||
void
|
||||
afterFetchLsa(const ndn::ConstBufferPtr& data, ndn::Name& interestName);
|
||||
|
||||
private:
|
||||
system_clock::TimePoint
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+15
-6
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -57,11 +57,10 @@ Nlsr::Nlsr(boost::asio::io_service& ioService, ndn::Scheduler& scheduler, ndn::F
|
||||
, 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_helloProtocol(*this, scheduler)
|
||||
, m_certificateCache(new ndn::CertificateCacheTtl(ioService))
|
||||
, m_validator(m_nlsrFace, DEFAULT_BROADCAST_PREFIX, m_certificateCache, m_certStore)
|
||||
, m_prefixUpdateProcessor(m_nlsrFace,
|
||||
@@ -179,11 +178,12 @@ Nlsr::initialize()
|
||||
{
|
||||
_LOG_DEBUG("Initializing Nlsr");
|
||||
m_confParam.buildRouterPrefix();
|
||||
m_lsdbDatasetHandler.setRouterNameCommandPrefix(m_confParam.getRouterPrefix());
|
||||
m_nlsrLsdb.setLsaRefreshTime(ndn::time::seconds(m_confParam.getLsaRefreshTime()));
|
||||
m_nlsrLsdb.setThisRouterPrefix(m_confParam.getRouterPrefix().toUri());
|
||||
m_fib.setEntryRefreshTime(2 * m_confParam.getLsaRefreshTime());
|
||||
m_sequencingManager.setSeqFileName(m_confParam.getSeqFileDir());
|
||||
m_sequencingManager.initiateSeqNoFromFile();
|
||||
m_sequencingManager.initiateSeqNoFromFile(m_confParam.getHyperbolicState());
|
||||
|
||||
m_syncLogicHandler.createSyncSocket(m_confParam.getChronosyncPrefix());
|
||||
|
||||
@@ -204,7 +204,11 @@ Nlsr::initialize()
|
||||
m_routingTable.setRoutingCalcInterval(m_confParam.getRoutingCalcInterval());
|
||||
|
||||
m_nlsrLsdb.buildAndInstallOwnNameLsa();
|
||||
m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
|
||||
|
||||
// Install coordinate LSAs if using HR or dry-run HR.
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
m_nlsrLsdb.buildAndInstallOwnCoordinateLsa();
|
||||
}
|
||||
|
||||
registerKeyPrefix();
|
||||
registerLocalhostPrefix();
|
||||
@@ -376,7 +380,12 @@ Nlsr::onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNo
|
||||
// has met the HELLO retry threshold
|
||||
adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
|
||||
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
if (m_confParam.getHyperbolicState() != HYPERBOLIC_STATE_OFF) {
|
||||
getRoutingTable().scheduleRoutingTableCalculation(*this);
|
||||
}
|
||||
else {
|
||||
m_nlsrLsdb.scheduleAdjLsaBuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -226,6 +226,12 @@ public:
|
||||
return m_syncLogicHandler;
|
||||
}
|
||||
|
||||
LsdbDatasetInterestHandler&
|
||||
getLsdbDatasetHandler()
|
||||
{
|
||||
return m_lsdbDatasetHandler;
|
||||
}
|
||||
|
||||
void
|
||||
initialize();
|
||||
|
||||
@@ -366,9 +372,11 @@ private:
|
||||
Fib m_fib;
|
||||
NamePrefixTable m_namePrefixTable;
|
||||
SyncLogicHandler m_syncLogicHandler;
|
||||
HelloProtocol m_helloProtocol;
|
||||
LsdbDatasetInterestHandler m_lsdbDatasetHandler;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
HelloProtocol m_helloProtocol;
|
||||
|
||||
private:
|
||||
ndn::shared_ptr<ndn::CertificateCacheTtl> m_certificateCache;
|
||||
security::CertificateStore m_certStore;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -37,10 +37,8 @@ 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)
|
||||
@@ -66,10 +64,10 @@ LsdbDatasetInterestHandler::startListeningOnLocalhost()
|
||||
void
|
||||
LsdbDatasetInterestHandler::startListeningOnRouterPrefix()
|
||||
{
|
||||
_LOG_DEBUG("Setting interest filter for: " << ROUTER_NAME_COMMAND_PREFIX);
|
||||
m_face.setInterestFilter(ROUTER_NAME_COMMAND_PREFIX,
|
||||
_LOG_DEBUG("Setting interest filter for: " << m_routerNameCommandPrefix);
|
||||
m_face.setInterestFilter(m_routerNameCommandPrefix,
|
||||
std::bind(&LsdbDatasetInterestHandler::onInterest, this, _2,
|
||||
std::cref(ROUTER_NAME_COMMAND_PREFIX)));
|
||||
std::cref(m_routerNameCommandPrefix)));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -48,7 +48,6 @@ public:
|
||||
|
||||
LsdbDatasetInterestHandler(Lsdb& lsdb,
|
||||
ndn::Face& face,
|
||||
const ndn::Name& routerName,
|
||||
ndn::KeyChain& keyChain);
|
||||
|
||||
void
|
||||
@@ -63,10 +62,16 @@ public:
|
||||
return LOCALHOST_COMMAND_PREFIX;
|
||||
}
|
||||
|
||||
const ndn::Name&
|
||||
ndn::Name&
|
||||
getRouterNameCommandPrefix()
|
||||
{
|
||||
return ROUTER_NAME_COMMAND_PREFIX;
|
||||
return m_routerNameCommandPrefix;
|
||||
}
|
||||
|
||||
void
|
||||
setRouterNameCommandPrefix(const ndn::Name& routerName) {
|
||||
m_routerNameCommandPrefix = routerName;
|
||||
m_routerNameCommandPrefix.append(Lsdb::NAME_COMPONENT);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -84,7 +89,7 @@ private:
|
||||
|
||||
private:
|
||||
const ndn::Name LOCALHOST_COMMAND_PREFIX;
|
||||
const ndn::Name ROUTER_NAME_COMMAND_PREFIX;
|
||||
ndn::Name m_routerNameCommandPrefix;
|
||||
|
||||
ndn::Face& m_face;
|
||||
ndn::KeyChain& m_keyChain;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, Regents of the University of California,
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -68,7 +68,8 @@ public:
|
||||
/** \brief Publish data under provided prefix
|
||||
*/
|
||||
void
|
||||
publish(const ndn::Name& prefix)
|
||||
publish(const ndn::Name& prefix,
|
||||
const ndn::security::SigningInfo& signingInfo = ndn::security::KeyChain::DEFAULT_SIGNING_INFO)
|
||||
{
|
||||
ndn::EncodingBuffer buffer;
|
||||
generate(buffer);
|
||||
@@ -99,7 +100,7 @@ public:
|
||||
data->setFinalBlockId(segmentName[-1]);
|
||||
}
|
||||
|
||||
publishSegment(data);
|
||||
publishSegment(data, signingInfo);
|
||||
++segmentNo;
|
||||
} while (segmentBegin < end);
|
||||
}
|
||||
@@ -112,9 +113,9 @@ protected:
|
||||
|
||||
private:
|
||||
void
|
||||
publishSegment(ndn::shared_ptr<ndn::Data>& data)
|
||||
publishSegment(ndn::shared_ptr<ndn::Data>& data, const ndn::security::SigningInfo& signingInfo)
|
||||
{
|
||||
m_keyChain.sign(*data);
|
||||
m_keyChain.sign(*data, signingInfo);
|
||||
m_face.put(*data);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,14 @@ Map::createFromAdjLsdb(Nlsr& pnlsr)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::createFromCoordinateLsdb(Nlsr& nlsr)
|
||||
{
|
||||
for (CoordinateLsa lsa : nlsr.getLsdb().getCoordinateLsdb()) {
|
||||
addEntry(lsa.getOrigRouter());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Map::reset()
|
||||
{
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
void
|
||||
createFromAdjLsdb(Nlsr& pnlsr);
|
||||
|
||||
void
|
||||
createFromCoordinateLsdb(Nlsr& nlsr);
|
||||
|
||||
const ndn::Name
|
||||
getRouterNameByMappingNo(int32_t mn);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -49,9 +49,20 @@ RoutingTable::calculate(Nlsr& pnlsr)
|
||||
if (pnlsr.getIsRoutingTableCalculating() == false) {
|
||||
//setting routing table calculation
|
||||
pnlsr.setIsRoutingTableCalculating(true);
|
||||
if (pnlsr.getLsdb().doesLsaExist(
|
||||
pnlsr.getConfParameter().getRouterPrefix().toUri() + "/" + "adjacency",
|
||||
std::string("adjacency"))) {
|
||||
|
||||
bool isHrEnabled = pnlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF;
|
||||
|
||||
if ((!isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
|
||||
+ "/" + "adjacency", std::string("adjacency")))
|
||||
||
|
||||
(isHrEnabled
|
||||
&&
|
||||
pnlsr.getLsdb()
|
||||
.doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri()
|
||||
+ "/" + "coordinate", std::string("coordinate")))) {
|
||||
if (pnlsr.getIsBuildAdjLsaSheduled() != 1) {
|
||||
_LOG_TRACE("Clearing old routing table");
|
||||
clearRoutingTable();
|
||||
@@ -127,7 +138,7 @@ void
|
||||
RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
|
||||
{
|
||||
Map map;
|
||||
map.createFromAdjLsdb(nlsr);
|
||||
map.createFromCoordinateLsdb(nlsr);
|
||||
map.writeLog();
|
||||
|
||||
size_t nRouters = map.getMapSize();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -62,15 +62,34 @@ SequencingManager::writeSeqNoToFile() const
|
||||
}
|
||||
|
||||
void
|
||||
SequencingManager::initiateSeqNoFromFile()
|
||||
SequencingManager::initiateSeqNoFromFile(int hypState)
|
||||
{
|
||||
_LOG_DEBUG("Seq File Name: " << m_seqFileNameWithPath);
|
||||
std::ifstream inputFile(m_seqFileNameWithPath.c_str(), ios::binary);
|
||||
if (inputFile.good()) {
|
||||
inputFile >> m_combinedSeqNo;
|
||||
splitSequenceNo(m_combinedSeqNo);
|
||||
m_adjLsaSeq += 10;
|
||||
m_corLsaSeq += 10;
|
||||
|
||||
// Increment the adjacency LSA seq. no. if link-state or dry HR is enabled
|
||||
if (hypState != HYPERBOLIC_STATE_ON) {
|
||||
if (m_corLsaSeq != 0) {
|
||||
_LOG_WARN("This router was previously configured for hyperbolic"
|
||||
<< " routing without clearing the seq. no. file.");
|
||||
m_corLsaSeq = 0;
|
||||
}
|
||||
m_adjLsaSeq += 10;
|
||||
}
|
||||
|
||||
// Similarly, increment the coordinate LSA seq. no only if link-state is disabled.
|
||||
if (hypState != HYPERBOLIC_STATE_OFF) {
|
||||
if (m_adjLsaSeq != 0 &&
|
||||
hypState == HYPERBOLIC_STATE_ON) {
|
||||
_LOG_WARN("This router was previously configured for link-state"
|
||||
<< " routing without clearing the seq. no. file.");
|
||||
m_adjLsaSeq = 0;
|
||||
}
|
||||
m_corLsaSeq += 10;
|
||||
}
|
||||
m_nameLsaSeq += 10;
|
||||
combineSequenceNo();
|
||||
inputFile.close();
|
||||
@@ -111,5 +130,3 @@ SequencingManager::writeLog() const
|
||||
}
|
||||
|
||||
}//namespace nlsr
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -28,7 +28,10 @@
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
class SequencingManager
|
||||
{
|
||||
public:
|
||||
@@ -124,7 +127,7 @@ public:
|
||||
writeSeqNoToFile() const;
|
||||
|
||||
void
|
||||
initiateSeqNoFromFile();
|
||||
initiateSeqNoFromFile(int hypState);
|
||||
|
||||
void
|
||||
setSeqFileName(std::string filePath);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
/* -*- 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_TEST_DUMMY_FACE_HPP
|
||||
#define NLSR_TEST_DUMMY_FACE_HPP
|
||||
|
||||
#include <ndn-cxx/face.hpp>
|
||||
#include <ndn-cxx/transport/transport.hpp>
|
||||
|
||||
namespace ndn {
|
||||
|
||||
class DummyTransport : public Transport
|
||||
{
|
||||
public:
|
||||
void
|
||||
receive(const Block& block)
|
||||
{
|
||||
m_receiveCallback(block);
|
||||
}
|
||||
|
||||
virtual void
|
||||
close()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void
|
||||
pause()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void
|
||||
resume()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void
|
||||
send(const Block& wire)
|
||||
{
|
||||
if (wire.type() == tlv::Interest) {
|
||||
m_sentInterests->push_back(Interest(wire));
|
||||
}
|
||||
else if (wire.type() == tlv::Data) {
|
||||
m_sentDatas->push_back(Data(wire));
|
||||
}
|
||||
}
|
||||
|
||||
virtual void
|
||||
send(const Block& header, const Block& payload)
|
||||
{
|
||||
this->send(payload);
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<Interest>* m_sentInterests;
|
||||
std::vector<Data>* m_sentDatas;
|
||||
};
|
||||
|
||||
|
||||
/** \brief a Face for unit testing
|
||||
*/
|
||||
class DummyFace : public Face
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
DummyFace(shared_ptr<DummyTransport> transport)
|
||||
: Face(transport)
|
||||
, m_transport(transport)
|
||||
{
|
||||
m_transport->m_sentInterests = &m_sentInterests;
|
||||
m_transport->m_sentDatas = &m_sentDatas;
|
||||
}
|
||||
|
||||
/** \brief cause the Face to receive a packet
|
||||
*/
|
||||
template<typename Packet>
|
||||
void
|
||||
receive(const Packet& packet)
|
||||
{
|
||||
m_transport->receive(packet.wireEncode());
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<Interest> m_sentInterests;
|
||||
std::vector<Data> m_sentDatas;
|
||||
|
||||
private:
|
||||
shared_ptr<DummyTransport> m_transport;
|
||||
};
|
||||
|
||||
inline shared_ptr<DummyFace>
|
||||
makeDummyFace()
|
||||
{
|
||||
return make_shared<DummyFace>(make_shared<DummyTransport>());
|
||||
}
|
||||
|
||||
} // namespace ndn
|
||||
|
||||
#endif // NLSR_TEST_DUMMY_FACE_HPP
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -33,7 +33,7 @@ class PublisherFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
PublisherFixture()
|
||||
: face(ndn::util::makeDummyClientFace())
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, lsdb(nlsr, g_scheduler, nlsr.getSyncLogicHandler())
|
||||
{
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
CoordinateLsa
|
||||
createCoordinateLsa(const std::string& origin, double radius, double angle)
|
||||
{
|
||||
CoordinateLsa lsa(origin, CoordinateLsa::TYPE_STRING, 1, ndn::time::system_clock::now(),
|
||||
CoordinateLsa lsa(origin, 1, ndn::time::system_clock::now(),
|
||||
radius, angle);
|
||||
|
||||
return lsa;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -59,8 +59,8 @@ BOOST_AUTO_TEST_CASE(AdjacencyLsaPublisherBasic)
|
||||
publisher.publish(publishingPrefix);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
|
||||
ndn::Block parser = face->sentDatas[0].getContent();
|
||||
BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
|
||||
ndn::Block parser = face->sentData[0].getContent();
|
||||
parser.parse();
|
||||
|
||||
// Check RouterB LSA
|
||||
@@ -93,8 +93,8 @@ BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
|
||||
publisher.publish(publishingPrefix);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
|
||||
ndn::Block parser = face->sentDatas[0].getContent();
|
||||
BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
|
||||
ndn::Block parser = face->sentData[0].getContent();
|
||||
parser.parse();
|
||||
|
||||
// Check RouterC LSA
|
||||
@@ -136,8 +136,8 @@ BOOST_AUTO_TEST_CASE(NameLsaBasic)
|
||||
publisher.publish(publishingPrefix);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
|
||||
ndn::Block parser = face->sentDatas[0].getContent();
|
||||
BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
|
||||
ndn::Block parser = face->sentData[0].getContent();
|
||||
parser.parse();
|
||||
|
||||
// Check RouterB LSA
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -36,8 +36,8 @@ processDatasetInterest(shared_ptr<ndn::util::DummyClientFace> face,
|
||||
{
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
|
||||
ndn::Block parser(face->sentDatas[0].getContent());
|
||||
BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
|
||||
ndn::Block parser(face->sentData[0].getContent());
|
||||
parser.parse();
|
||||
|
||||
ndn::Block::element_const_iterator it = parser.elements_begin();
|
||||
@@ -46,18 +46,18 @@ processDatasetInterest(shared_ptr<ndn::util::DummyClientFace> face,
|
||||
|
||||
BOOST_CHECK(it == parser.elements_end());
|
||||
|
||||
face->sentDatas.clear();
|
||||
face->sentData.clear();
|
||||
}
|
||||
|
||||
void
|
||||
checkErrorResponse(shared_ptr<ndn::util::DummyClientFace> face, uint64_t expectedCode)
|
||||
{
|
||||
BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
|
||||
|
||||
ndn::nfd::ControlResponse response(face->sentDatas[0].getContent().blockFromValue());
|
||||
ndn::nfd::ControlResponse response(face->sentData[0].getContent().blockFromValue());
|
||||
BOOST_CHECK_EQUAL(response.getCode(), expectedCode);
|
||||
|
||||
face->sentDatas.clear();
|
||||
face->sentData.clear();
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(PublisherTestLsdbDatasetInterestHandler, PublisherFixture)
|
||||
@@ -81,7 +81,9 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
lsdb.installNameLsa(nameLsa);
|
||||
|
||||
ndn::Name thisRouter("/This/Router");
|
||||
LsdbDatasetInterestHandler publisher(lsdb, *face, thisRouter, keyChain);
|
||||
LsdbDatasetInterestHandler publisher(lsdb, *face, keyChain);
|
||||
publisher.setRouterNameCommandPrefix(thisRouter);
|
||||
|
||||
publisher.startListeningOnLocalhost();
|
||||
|
||||
face->processEvents(ndn::time::milliseconds(10));
|
||||
@@ -136,7 +138,8 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
BOOST_AUTO_TEST_CASE(InvalidCommand)
|
||||
{
|
||||
ndn::Name thisRouter("/This/Router");
|
||||
LsdbDatasetInterestHandler publisher(lsdb, *face, thisRouter, keyChain);
|
||||
LsdbDatasetInterestHandler publisher(lsdb, *face, keyChain);
|
||||
publisher.setRouterNameCommandPrefix(thisRouter);
|
||||
|
||||
// Localhost prefix
|
||||
publisher.startListeningOnLocalhost();
|
||||
@@ -179,7 +182,7 @@ BOOST_AUTO_TEST_CASE(InvalidCommand)
|
||||
face->receive(ndn::Interest(ndn::Name(thisRouter).append("malformed")));
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
|
||||
BOOST_CHECK_EQUAL(face->sentData.size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -90,9 +90,9 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
publisher.publish(publishingPrefix);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
|
||||
BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
|
||||
|
||||
ndn::Block parser = face->sentDatas[0].getContent();
|
||||
ndn::Block parser = face->sentData[0].getContent();
|
||||
parser.parse();
|
||||
|
||||
ndn::Block::element_const_iterator it = parser.elements_begin();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, Regents of the University of California,
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -89,7 +89,7 @@ class SegmentPublisherFixture
|
||||
{
|
||||
public:
|
||||
SegmentPublisherFixture()
|
||||
: m_face(ndn::util::makeDummyClientFace())
|
||||
: m_face(std::make_shared<ndn::util::DummyClientFace>())
|
||||
, m_expectedFreshnessPeriod(ndn::time::milliseconds(111))
|
||||
, m_publisher(*m_face, m_keyChain, m_expectedFreshnessPeriod)
|
||||
, m_publishingPrefix("/localhost/nfd/SegmentPublisherFixture")
|
||||
@@ -158,8 +158,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Generate, T, DatasetSizes, SegmentPublisherFixt
|
||||
nSegments == 0)
|
||||
++nSegments;
|
||||
|
||||
BOOST_CHECK_EQUAL(this->m_face->sentDatas.size(), nSegments);
|
||||
for (const ndn::Data& data : this->m_face->sentDatas) {
|
||||
BOOST_CHECK_EQUAL(this->m_face->sentData.size(), nSegments);
|
||||
for (const ndn::Data& data : this->m_face->sentData) {
|
||||
this->validate(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014 University of Memphis,
|
||||
* Regents of the University of California
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
* This file is part of NLSR (Named-data Link State Routing).
|
||||
* See AUTHORS.md for complete list of NLSR authors and contributors.
|
||||
@@ -16,23 +17,23 @@
|
||||
*
|
||||
* 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 Ashlesh Gawande <agawande@memphis.edu>
|
||||
*
|
||||
**/
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
|
||||
#include "adjacent.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
|
||||
namespace test {
|
||||
|
||||
using namespace std;
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(TestAdjacenctList)
|
||||
BOOST_AUTO_TEST_SUITE(TestAdjacencyList)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AdjacenctListBasic)
|
||||
BOOST_AUTO_TEST_CASE(Basic)
|
||||
{
|
||||
const string ADJ_NAME_1 = "testname";
|
||||
const string ADJ_NAME_2 = "testname2";
|
||||
@@ -63,7 +64,65 @@ BOOST_AUTO_TEST_CASE(AdjacenctListBasic)
|
||||
BOOST_CHECK_EQUAL(adjacentList1.getStatusOfNeighbor(n1), Adjacent::STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AdjLsaIsBuildableWithOneNodeActive)
|
||||
{
|
||||
Adjacent adjacencyA("/router/A");
|
||||
Adjacent adjacencyB("/router/B");
|
||||
|
||||
adjacencyA.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
adjacencyB.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
|
||||
AdjacencyList adjacencies;
|
||||
adjacencies.insert(adjacencyA);
|
||||
adjacencies.insert(adjacencyB);
|
||||
|
||||
ConfParameter conf;
|
||||
BOOST_CHECK(adjacencies.isAdjLsaBuildable(conf.getInterestRetryNumber()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AdjLsaIsBuildableWithAllNodesTimedOut)
|
||||
{
|
||||
Adjacent adjacencyA("/router/A");
|
||||
Adjacent adjacencyB("/router/B");
|
||||
|
||||
adjacencyA.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
adjacencyB.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
|
||||
adjacencyA.setInterestTimedOutNo(HELLO_RETRIES_DEFAULT);
|
||||
adjacencyB.setInterestTimedOutNo(HELLO_RETRIES_DEFAULT);
|
||||
|
||||
AdjacencyList adjacencies;
|
||||
adjacencies.insert(adjacencyA);
|
||||
adjacencies.insert(adjacencyB);
|
||||
|
||||
ConfParameter conf;
|
||||
conf.setInterestRetryNumber(HELLO_RETRIES_DEFAULT);
|
||||
|
||||
BOOST_CHECK(adjacencies.isAdjLsaBuildable(conf.getInterestRetryNumber()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(AdjLsaIsNotBuildable)
|
||||
{
|
||||
Adjacent adjacencyA("/router/A");
|
||||
Adjacent adjacencyB("/router/B");
|
||||
|
||||
adjacencyA.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
adjacencyB.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
|
||||
adjacencyA.setInterestTimedOutNo(HELLO_RETRIES_DEFAULT);
|
||||
adjacencyB.setInterestTimedOutNo(0);
|
||||
|
||||
AdjacencyList adjacencies;
|
||||
adjacencies.insert(adjacencyA);
|
||||
adjacencies.insert(adjacencyB);
|
||||
|
||||
ConfParameter conf;
|
||||
conf.setInterestRetryNumber(HELLO_RETRIES_DEFAULT);
|
||||
|
||||
BOOST_CHECK(!adjacencies.isAdjLsaBuildable(conf.getInterestRetryNumber()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} //namespace tests
|
||||
} //namespace nlsr
|
||||
} // namespace tests
|
||||
} // namespace nlsr
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
**/
|
||||
|
||||
#include "test-common.hpp"
|
||||
#include "dummy-face.hpp"
|
||||
#include "logger.hpp"
|
||||
|
||||
#include <fstream>
|
||||
@@ -31,10 +30,11 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::DummyFace;
|
||||
using ndn::shared_ptr;
|
||||
|
||||
const std::string SECTION_GENERAL =
|
||||
@@ -132,7 +132,7 @@ class ConfFileProcessorFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
ConfFileProcessorFixture()
|
||||
: face(ndn::makeDummyFace())
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, CONFIG_FILE("unit-test-nlsr.conf")
|
||||
, m_logConfigFileName(boost::filesystem::unique_path().native())
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::DummyFace> face;
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
|
||||
private:
|
||||
|
||||
+5
-5
@@ -21,25 +21,25 @@
|
||||
|
||||
#include "test-common.hpp"
|
||||
#include "control-commands.hpp"
|
||||
#include "dummy-face.hpp"
|
||||
|
||||
#include "route/fib.hpp"
|
||||
|
||||
#include "adjacency-list.hpp"
|
||||
#include "conf-parameter.hpp"
|
||||
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::DummyFace;
|
||||
using ndn::shared_ptr;
|
||||
|
||||
class FibFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
FibFixture()
|
||||
: face(ndn::makeDummyFace())
|
||||
, interests(face->m_sentInterests)
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, interests(face->sentInterests)
|
||||
{
|
||||
INIT_LOGGERS("/tmp", "DEBUG");
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::DummyFace> face;
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
ndn::KeyChain keyChain;
|
||||
shared_ptr<Fib> fib;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
**/
|
||||
|
||||
#include "test-common.hpp"
|
||||
#include "dummy-face.hpp"
|
||||
|
||||
#include "route/routing-table-calculator.hpp"
|
||||
|
||||
@@ -33,10 +32,11 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::DummyFace;
|
||||
using ndn::shared_ptr;
|
||||
using ndn::time::system_clock;
|
||||
static const system_clock::TimePoint MAX_TIME = system_clock::TimePoint::max();
|
||||
@@ -45,7 +45,7 @@ class HyperbolicCalculatorFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
HyperbolicCalculatorFixture()
|
||||
: face(ndn::makeDummyFace())
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, routingTable(nlsr.getRoutingTable())
|
||||
, adjacencies(nlsr.getAdjacencyList())
|
||||
@@ -67,10 +67,10 @@ public:
|
||||
adjacencies.insert(b);
|
||||
adjacencies.insert(c);
|
||||
|
||||
AdjLsa adjA(a.getName(), AdjLsa::TYPE_STRING, 1, MAX_TIME, 2, adjacencies);
|
||||
AdjLsa adjA(a.getName(), 1, MAX_TIME, 2, adjacencies);
|
||||
lsdb.installAdjLsa(adjA);
|
||||
|
||||
CoordinateLsa coordA(adjA.getOrigRouter(), CoordinateLsa::TYPE_STRING, 1, MAX_TIME, 16.23, 2.97);
|
||||
CoordinateLsa coordA(adjA.getOrigRouter(), 1, MAX_TIME, 16.23, 2.97);
|
||||
lsdb.installCoordinateLsa(coordA);
|
||||
|
||||
// Router B
|
||||
@@ -81,10 +81,10 @@ public:
|
||||
adjacencyListB.insert(a);
|
||||
adjacencyListB.insert(c);
|
||||
|
||||
AdjLsa adjB(b.getName(), AdjLsa::TYPE_STRING, 1, MAX_TIME, 2, adjacencyListB);
|
||||
AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
|
||||
lsdb.installAdjLsa(adjB);
|
||||
|
||||
CoordinateLsa coordB(adjB.getOrigRouter(), CoordinateLsa::TYPE_STRING, 1, MAX_TIME, 16.59, 3.0);
|
||||
CoordinateLsa coordB(adjB.getOrigRouter(), 1, MAX_TIME, 16.59, 3.0);
|
||||
lsdb.installCoordinateLsa(coordB);
|
||||
|
||||
// Router C
|
||||
@@ -95,17 +95,17 @@ public:
|
||||
adjacencyListC.insert(a);
|
||||
adjacencyListC.insert(b);
|
||||
|
||||
AdjLsa adjC(c.getName(), AdjLsa::TYPE_STRING, 1, MAX_TIME, 2, adjacencyListC);
|
||||
AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
|
||||
lsdb.installAdjLsa(adjC);
|
||||
|
||||
CoordinateLsa coordC(adjC.getOrigRouter(), CoordinateLsa::TYPE_STRING, 1, MAX_TIME, 14.11, 2.99);
|
||||
CoordinateLsa coordC(adjC.getOrigRouter(), 1, MAX_TIME, 14.11, 2.99);
|
||||
lsdb.installCoordinateLsa(coordC);
|
||||
|
||||
map.createFromAdjLsdb(nlsr);
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<DummyFace> face;
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
Map map;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -41,7 +41,7 @@ class LinkStateCalculatorFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
LinkStateCalculatorFixture()
|
||||
: face(ndn::util::makeDummyClientFace(g_ioService))
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, routingTable(nlsr.getRoutingTable())
|
||||
, lsdb(nlsr.getLsdb())
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
adjacencyListA.insert(b);
|
||||
adjacencyListA.insert(c);
|
||||
|
||||
AdjLsa adjA(a.getName(), AdjLsa::TYPE_STRING, 1, MAX_TIME, 2, adjacencyListA);
|
||||
AdjLsa adjA(a.getName(), 1, MAX_TIME, 2, adjacencyListA);
|
||||
lsdb.installAdjLsa(adjA);
|
||||
|
||||
// Router B
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
adjacencyListB.insert(a);
|
||||
adjacencyListB.insert(c);
|
||||
|
||||
AdjLsa adjB(b.getName(), AdjLsa::TYPE_STRING, 1, MAX_TIME, 2, adjacencyListB);
|
||||
AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
|
||||
lsdb.installAdjLsa(adjB);
|
||||
|
||||
// Router C
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
adjacencyListC.insert(a);
|
||||
adjacencyListC.insert(b);
|
||||
|
||||
AdjLsa adjC(c.getName(), AdjLsa::TYPE_STRING, 1, MAX_TIME, 2, adjacencyListC);
|
||||
AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
|
||||
lsdb.installAdjLsa(adjC);
|
||||
|
||||
map.createFromAdjLsdb(nlsr);
|
||||
|
||||
+64
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -44,9 +44,10 @@ BOOST_AUTO_TEST_CASE(NameLsaBasic)
|
||||
npl1.insert(s1);
|
||||
npl1.insert(s2);
|
||||
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
|
||||
//lsType is 1 for NameLsa, 3rd arg is seqNo. which will be a random number I just put in 12.
|
||||
NameLsa nlsa1("router1", NameLsa::TYPE_STRING, 12, testTimePoint, npl1);
|
||||
NameLsa nlsa2("router2", NameLsa::TYPE_STRING, 12, testTimePoint, npl1);
|
||||
|
||||
//3rd arg is seqNo. which will be a random number I just put in 12.
|
||||
NameLsa nlsa1("router1", 12, testTimePoint, npl1);
|
||||
NameLsa nlsa2("router2", 12, testTimePoint, npl1);
|
||||
|
||||
BOOST_CHECK_EQUAL(nlsa1.getLsType(), NameLsa::TYPE_STRING);
|
||||
|
||||
@@ -68,7 +69,7 @@ BOOST_AUTO_TEST_CASE(AdjacentLsaConstructorAndGetters)
|
||||
activeAdjacency.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
activeAdjacencies.insert(activeAdjacency);
|
||||
|
||||
AdjLsa alsa1(routerName, AdjLsa::TYPE_STRING, seqNo, testTimePoint,
|
||||
AdjLsa alsa1(routerName, seqNo, testTimePoint,
|
||||
activeAdjacencies.getSize(), activeAdjacencies);
|
||||
BOOST_CHECK_EQUAL(alsa1.getAdl().getSize(), 1);
|
||||
BOOST_CHECK_EQUAL(alsa1.getLsType(), AdjLsa::TYPE_STRING);
|
||||
@@ -83,7 +84,7 @@ BOOST_AUTO_TEST_CASE(AdjacentLsaConstructorAndGetters)
|
||||
inactiveAdjacency.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
inactiveAdjacencies.insert(inactiveAdjacency);
|
||||
|
||||
AdjLsa alsa2(routerName, AdjLsa::TYPE_STRING, seqNo, testTimePoint,
|
||||
AdjLsa alsa2(routerName, seqNo, testTimePoint,
|
||||
inactiveAdjacencies.getSize(), inactiveAdjacencies);
|
||||
BOOST_CHECK_EQUAL(alsa2.getAdl().getSize(), 0);
|
||||
|
||||
@@ -91,7 +92,7 @@ BOOST_AUTO_TEST_CASE(AdjacentLsaConstructorAndGetters)
|
||||
BOOST_CHECK_EQUAL(alsa1.isEqualContent(alsa2), false);
|
||||
|
||||
// Create a duplicate of alsa1 which should have equal content
|
||||
AdjLsa alsa3(routerName, AdjLsa::TYPE_STRING, seqNo, testTimePoint,
|
||||
AdjLsa alsa3(routerName, seqNo, testTimePoint,
|
||||
activeAdjacencies.getSize(), activeAdjacencies);
|
||||
BOOST_CHECK(alsa1.isEqualContent(alsa3));
|
||||
}
|
||||
@@ -99,9 +100,8 @@ BOOST_AUTO_TEST_CASE(AdjacentLsaConstructorAndGetters)
|
||||
BOOST_AUTO_TEST_CASE(CoordinateLsaConstructorAndGetters)
|
||||
{
|
||||
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
|
||||
//For CoordinateLsa, lsType is 3.
|
||||
CoordinateLsa clsa1("router1", CoordinateLsa::TYPE_STRING, 12, testTimePoint, 2.5, 30.0);
|
||||
CoordinateLsa clsa2("router1", CoordinateLsa::TYPE_STRING, 12, testTimePoint, 2.5, 30.0);
|
||||
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, 30.0);
|
||||
CoordinateLsa clsa2("router1", 12, testTimePoint, 2.5, 30.0);
|
||||
|
||||
BOOST_CHECK_CLOSE(clsa1.getCorRadius(), 2.5, 0.0001);
|
||||
BOOST_CHECK_CLOSE(clsa1.getCorTheta(), 30.0, 0.0001);
|
||||
@@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE(IncrementAdjacentNumber)
|
||||
|
||||
const std::string TEST_TIME_POINT_STRING = ss.str();
|
||||
|
||||
AdjLsa lsa("router1", AdjLsa::TYPE_STRING, 12, testTimePoint, 1, adjList);
|
||||
AdjLsa lsa("router1", 12, testTimePoint, adjList.getSize(), adjList);
|
||||
|
||||
std::string EXPECTED_OUTPUT =
|
||||
"Adj Lsa:\n"
|
||||
@@ -155,6 +155,59 @@ BOOST_AUTO_TEST_CASE(IncrementAdjacentNumber)
|
||||
BOOST_CHECK_EQUAL(os.str(), EXPECTED_OUTPUT);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestInitializeFromContent)
|
||||
{
|
||||
//Adj LSA
|
||||
Adjacent adj1("adjacent1");
|
||||
Adjacent adj2("adjacent2");
|
||||
|
||||
adj1.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
adj2.setStatus(Adjacent::STATUS_ACTIVE);
|
||||
|
||||
//If we don't do this the test will fail
|
||||
//Adjacent has default cost of 10 but no default
|
||||
//connecting face URI, so initializeFromContent fails
|
||||
adj1.setConnectingFaceUri("10.0.0.1");
|
||||
adj2.setConnectingFaceUri("10.0.0.2");
|
||||
|
||||
AdjacencyList adjList;
|
||||
adjList.insert(adj1);
|
||||
adjList.insert(adj2);
|
||||
|
||||
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
|
||||
|
||||
AdjLsa adjlsa1("router1", 1, testTimePoint, adjList.getSize(), adjList);
|
||||
AdjLsa adjlsa2;
|
||||
|
||||
BOOST_CHECK(adjlsa2.initializeFromContent(adjlsa1.getData()));
|
||||
|
||||
BOOST_CHECK(adjlsa1.isEqualContent(adjlsa2));
|
||||
|
||||
//Name LSA
|
||||
NamePrefixList npl1;
|
||||
|
||||
std::string s1 = "name1";
|
||||
std::string s2 = "name2";
|
||||
|
||||
npl1.insert(s1);
|
||||
npl1.insert(s2);
|
||||
|
||||
NameLsa nlsa1("router1", 1, testTimePoint, npl1);
|
||||
NameLsa nlsa2;
|
||||
|
||||
BOOST_CHECK(nlsa2.initializeFromContent(nlsa1.getData()));
|
||||
|
||||
BOOST_CHECK_EQUAL(nlsa1.getData(), nlsa2.getData());
|
||||
|
||||
//Coordinate LSA
|
||||
CoordinateLsa clsa1("router1", 12, testTimePoint, 2.5, 30.0);
|
||||
CoordinateLsa clsa2;
|
||||
|
||||
BOOST_CHECK(clsa2.initializeFromContent(clsa1.getData()));
|
||||
|
||||
BOOST_CHECK_EQUAL(clsa1.getData(), clsa2.getData());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace test
|
||||
|
||||
+86
-16
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -20,7 +20,6 @@
|
||||
**/
|
||||
|
||||
#include "test-common.hpp"
|
||||
#include "dummy-face.hpp"
|
||||
|
||||
#include "lsdb.hpp"
|
||||
#include "nlsr.hpp"
|
||||
@@ -28,17 +27,19 @@
|
||||
#include "name-prefix-list.hpp"
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::DummyFace;
|
||||
using ndn::shared_ptr;
|
||||
|
||||
class LsdbFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
LsdbFixture()
|
||||
: face(ndn::makeDummyFace())
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, sync(*face, nlsr.getLsdb(), nlsr.getConfParameter(), nlsr.getSequencingManager())
|
||||
, lsdb(nlsr.getLsdb())
|
||||
@@ -53,7 +54,7 @@ public:
|
||||
nlsr.initialize();
|
||||
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
face->m_sentInterests.clear();
|
||||
face->sentInterests.clear();
|
||||
|
||||
INIT_LOGGERS("/tmp", "DEBUG");
|
||||
}
|
||||
@@ -89,7 +90,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<DummyFace> face;
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
SyncLogicHandler sync;
|
||||
|
||||
@@ -113,7 +114,7 @@ BOOST_AUTO_TEST_CASE(LsdbSync)
|
||||
lsdb.expressInterest(oldInterestName, 0);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
std::vector<ndn::Interest>& interests = face->m_sentInterests;
|
||||
std::vector<ndn::Interest>& interests = face->sentInterests;
|
||||
|
||||
BOOST_REQUIRE(interests.size() > 0);
|
||||
std::vector<ndn::Interest>::iterator it = interests.begin();
|
||||
@@ -122,10 +123,11 @@ BOOST_AUTO_TEST_CASE(LsdbSync)
|
||||
interests.clear();
|
||||
|
||||
steady_clock::TimePoint deadline = steady_clock::now() +
|
||||
ndn::time::seconds(static_cast<int>(LSA_REFRESH_TIME_MAX));
|
||||
ndn::time::seconds(LSA_REFRESH_TIME_MAX);
|
||||
|
||||
// Simulate an LSA interest timeout
|
||||
lsdb.processInterestTimedOut(oldInterestName, 0, deadline, interestName, oldSeqNo);
|
||||
lsdb.onFetchLsaError(ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout",
|
||||
oldInterestName, 0, deadline, interestName, oldSeqNo);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_REQUIRE(interests.size() > 0);
|
||||
@@ -149,13 +151,81 @@ BOOST_AUTO_TEST_CASE(LsdbSync)
|
||||
interests.clear();
|
||||
|
||||
// Simulate an LSA interest timeout where the sequence number is outdated
|
||||
lsdb.processInterestTimedOut(oldInterestName, 0, deadline, interestName, oldSeqNo);
|
||||
lsdb.onFetchLsaError(ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT, "Timeout",
|
||||
oldInterestName, 0, deadline, interestName, oldSeqNo);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
// Interest should not be expressed for outdated sequence number
|
||||
BOOST_CHECK_EQUAL(interests.size(), 0);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SegmentLsaData)
|
||||
{
|
||||
ndn::Name router("/ndn/cs/%C1.Router/router1");
|
||||
uint64_t seqNo = 12;
|
||||
NamePrefixList prefixList;
|
||||
|
||||
NameLsa lsa(router, seqNo, ndn::time::system_clock::now(), prefixList);
|
||||
|
||||
ndn::Name prefix("/ndn/edu/memphis/netlab/research/nlsr/test/prefix/");
|
||||
|
||||
int nPrefixes = 0;
|
||||
while (lsa.getData().size() < ndn::MAX_NDN_PACKET_SIZE) {
|
||||
lsa.addName(ndn::Name(prefix).appendNumber(++nPrefixes));
|
||||
}
|
||||
|
||||
std::string expectedDataContent = lsa.getData();
|
||||
lsdb.installNameLsa(lsa);
|
||||
|
||||
ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/");
|
||||
interestName.appendNumber(seqNo);
|
||||
|
||||
ndn::Interest interest(interestName);
|
||||
|
||||
lsdb.processInterest(ndn::Name(), interest);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
std::vector<ndn::Data> data = face->sentData;
|
||||
std::string recvDataContent;
|
||||
for (unsigned int i = 0; i < data.size(); ++i)
|
||||
{
|
||||
const ndn::Block& nameBlock = data[i].getContent();
|
||||
|
||||
std::string nameBlockContent(reinterpret_cast<char const*>(nameBlock.value()),
|
||||
nameBlock.value_size());
|
||||
recvDataContent += nameBlockContent;
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(expectedDataContent, recvDataContent);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ReceiveSegmentedLsaData)
|
||||
{
|
||||
ndn::Name router("/ndn/cs/%C1.Router/router1");
|
||||
uint64_t seqNo = 12;
|
||||
NamePrefixList prefixList;
|
||||
|
||||
NameLsa lsa(router, seqNo, ndn::time::system_clock::now(), prefixList);
|
||||
|
||||
ndn::Name prefix("/prefix/");
|
||||
|
||||
for (int nPrefixes = 0; nPrefixes < 3; ++nPrefixes) {
|
||||
lsa.addName(ndn::Name(prefix).appendNumber(nPrefixes));
|
||||
}
|
||||
|
||||
ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/name/");
|
||||
interestName.appendNumber(seqNo);
|
||||
|
||||
const ndn::ConstBufferPtr bufferPtr = make_shared<ndn::Buffer>(lsa.getData().c_str(),
|
||||
lsa.getData().size());
|
||||
lsdb.afterFetchLsa(bufferPtr, interestName);
|
||||
|
||||
NameLsa* foundLsa = lsdb.findNameLsa(lsa.getKey());
|
||||
BOOST_REQUIRE(foundLsa != nullptr);
|
||||
|
||||
BOOST_CHECK_EQUAL(foundLsa->getData(), lsa.getData());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists)
|
||||
{
|
||||
ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
|
||||
@@ -171,7 +241,7 @@ BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists)
|
||||
//For NameLsa lsType is name.
|
||||
//12 is seqNo, randomly generated.
|
||||
//1800 is the default life time.
|
||||
NameLsa nlsa1(ndn::Name("/router1/1"), NameLsa::TYPE_STRING, 12, testTimePoint, npl1);
|
||||
NameLsa nlsa1(ndn::Name("/router1/1"), 12, testTimePoint, npl1);
|
||||
|
||||
Lsdb lsdb1(nlsr, g_scheduler, nlsr.getSyncLogicHandler());
|
||||
|
||||
@@ -198,7 +268,7 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
std::string otherRouter("/ndn/site/%C1.router/other-router");
|
||||
ndn::time::system_clock::TimePoint MAX_TIME = ndn::time::system_clock::TimePoint::max();
|
||||
|
||||
NameLsa lsa(otherRouter, NameLsa::TYPE_STRING, 1, MAX_TIME, prefixes);
|
||||
NameLsa lsa(otherRouter, 1, MAX_TIME, prefixes);
|
||||
lsdb.installNameLsa(lsa);
|
||||
|
||||
BOOST_REQUIRE_EQUAL(lsdb.doesLsaExist(otherRouter + "/name", NameLsa::TYPE_STRING), true);
|
||||
@@ -210,7 +280,7 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
ndn::Name name3("/ndn/name3");
|
||||
prefixes.insert(name3);
|
||||
|
||||
NameLsa addLsa(otherRouter, NameLsa::TYPE_STRING, 2, MAX_TIME, prefixes);
|
||||
NameLsa addLsa(otherRouter, 2, MAX_TIME, prefixes);
|
||||
lsdb.installNameLsa(addLsa);
|
||||
|
||||
// Lsa should include name1, name2, and name3
|
||||
@@ -219,7 +289,7 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
// Remove a prefix: name2
|
||||
prefixes.remove(name2);
|
||||
|
||||
NameLsa removeLsa(otherRouter, NameLsa::TYPE_STRING, 3, MAX_TIME, prefixes);
|
||||
NameLsa removeLsa(otherRouter, 3, MAX_TIME, prefixes);
|
||||
lsdb.installNameLsa(removeLsa);
|
||||
|
||||
// Lsa should include name1 and name3
|
||||
@@ -229,7 +299,7 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
prefixes.insert(name2);
|
||||
prefixes.remove(name3);
|
||||
|
||||
NameLsa addAndRemoveLsa(otherRouter, NameLsa::TYPE_STRING, 4, MAX_TIME, prefixes);
|
||||
NameLsa addAndRemoveLsa(otherRouter, 4, MAX_TIME, prefixes);
|
||||
lsdb.installNameLsa(addAndRemoveLsa);
|
||||
|
||||
// Lsa should include name1 and name2
|
||||
@@ -243,7 +313,7 @@ BOOST_AUTO_TEST_CASE(InstallNameLsa)
|
||||
newPrefixes.insert(name4);
|
||||
newPrefixes.insert(name5);
|
||||
|
||||
NameLsa newLsa(otherRouter, NameLsa::TYPE_STRING, 5, MAX_TIME, newPrefixes);
|
||||
NameLsa newLsa(otherRouter, 5, MAX_TIME, newPrefixes);
|
||||
lsdb.installNameLsa(newLsa);
|
||||
|
||||
// Lsa should include name4 and name5
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ class NamePrefixTableFixture : public UnitTestTimeFixture
|
||||
{
|
||||
public:
|
||||
NamePrefixTableFixture()
|
||||
: face(ndn::util::makeDummyClientFace(g_ioService))
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, lsdb(nlsr.getLsdb())
|
||||
, npt(nlsr.getNamePrefixTable())
|
||||
@@ -69,9 +69,7 @@ BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
|
||||
|
||||
// This router's Adjacency LSA
|
||||
nlsr.getAdjacencyList().insert(bupt);
|
||||
AdjLsa thisRouterAdjLsa(thisRouter.getName(),
|
||||
AdjLsa::TYPE_STRING,
|
||||
1,
|
||||
AdjLsa thisRouterAdjLsa(thisRouter.getName(), 1,
|
||||
ndn::time::system_clock::now() + ndn::time::seconds::max(),
|
||||
2,
|
||||
nlsr.getAdjacencyList());
|
||||
@@ -81,9 +79,7 @@ BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
|
||||
// BUPT Adjacency LSA
|
||||
AdjacencyList buptAdjacencies;
|
||||
buptAdjacencies.insert(thisRouter);
|
||||
AdjLsa buptAdjLsa(buptRouterName,
|
||||
AdjLsa::TYPE_STRING,
|
||||
1,
|
||||
AdjLsa buptAdjLsa(buptRouterName, 1,
|
||||
ndn::time::system_clock::now() + ndn::time::seconds(5),
|
||||
0 , buptAdjacencies);
|
||||
|
||||
@@ -95,10 +91,7 @@ BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
|
||||
NamePrefixList buptNames;
|
||||
buptNames.insert(buptAdvertisedName);
|
||||
|
||||
NameLsa buptNameLsa(buptRouterName,
|
||||
NameLsa::TYPE_STRING,
|
||||
1,
|
||||
ndn::time::system_clock::now(),
|
||||
NameLsa buptNameLsa(buptRouterName, 1, ndn::time::system_clock::now(),
|
||||
buptNames);
|
||||
|
||||
lsdb.installNameLsa(buptNameLsa);
|
||||
@@ -111,8 +104,7 @@ BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
|
||||
BOOST_REQUIRE(it == npt.end());
|
||||
|
||||
// Install new name LSA
|
||||
NameLsa buptNewNameLsa(buptRouterName, NameLsa::TYPE_STRING,
|
||||
12,
|
||||
NameLsa buptNewNameLsa(buptRouterName, 12,
|
||||
ndn::time::system_clock::now() + ndn::time::seconds(3600),
|
||||
buptNames);
|
||||
|
||||
@@ -121,8 +113,7 @@ BOOST_FIXTURE_TEST_CASE(Bupt, NamePrefixTableFixture)
|
||||
this->advanceClocks(ndn::time::seconds(1));
|
||||
|
||||
// Install new adjacency LSA
|
||||
AdjLsa buptNewAdjLsa(buptRouterName, AdjLsa::TYPE_STRING,
|
||||
12,
|
||||
AdjLsa buptNewAdjLsa(buptRouterName, 12,
|
||||
ndn::time::system_clock::now() + ndn::time::seconds(3600),
|
||||
0, buptAdjacencies);
|
||||
lsdb.installAdjLsa(buptNewAdjLsa);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+118
-32
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include "test-common.hpp"
|
||||
#include "control-commands.hpp"
|
||||
#include "dummy-face.hpp"
|
||||
|
||||
#include "nlsr.hpp"
|
||||
|
||||
@@ -31,19 +30,42 @@
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::DummyFace;
|
||||
using ndn::shared_ptr;
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestNlsr, BaseFixture)
|
||||
class NlsrFixture : public UnitTestTimeFixture
|
||||
{
|
||||
public:
|
||||
NlsrFixture()
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, lsdb(nlsr.getLsdb())
|
||||
, neighbors(nlsr.getAdjacencyList())
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
receiveHelloData(const ndn::Name& sender, const ndn::Name& receiver)
|
||||
{
|
||||
ndn::Name dataName(sender);
|
||||
dataName.append("NLSR").append("INFO").append(receiver.wireEncode()).appendVersion();
|
||||
|
||||
shared_ptr<ndn::Data> data = make_shared<ndn::Data>(dataName);
|
||||
|
||||
nlsr.m_helloProtocol.onContentValidated(data);
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
Lsdb& lsdb;
|
||||
AdjacencyList& neighbors;
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestNlsr, NlsrFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(HyperbolicOn_ZeroCostNeighbors)
|
||||
{
|
||||
shared_ptr<DummyFace> face = ndn::makeDummyFace();
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
|
||||
// Simulate loading configuration file
|
||||
AdjacencyList& neighbors = nlsr.getAdjacencyList();
|
||||
|
||||
Adjacent neighborA("/ndn/neighborA", "uri://faceA", 25, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
neighbors.insert(neighborA);
|
||||
|
||||
@@ -65,12 +87,7 @@ BOOST_AUTO_TEST_CASE(HyperbolicOn_ZeroCostNeighbors)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(HyperbolicOff_LinkStateCost)
|
||||
{
|
||||
shared_ptr<DummyFace> face = ndn::makeDummyFace();
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
|
||||
// Simulate loading configuration file
|
||||
AdjacencyList& neighbors = nlsr.getAdjacencyList();
|
||||
|
||||
Adjacent neighborA("/ndn/neighborA", "uri://faceA", 25, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
neighbors.insert(neighborA);
|
||||
|
||||
@@ -90,9 +107,6 @@ BOOST_AUTO_TEST_CASE(HyperbolicOff_LinkStateCost)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SetEventIntervals)
|
||||
{
|
||||
shared_ptr<DummyFace> face = ndn::makeDummyFace();
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
|
||||
// Simulate loading configuration file
|
||||
ConfParameter& conf = nlsr.getConfParameter();
|
||||
conf.setAdjLsaBuildInterval(3);
|
||||
@@ -111,7 +125,7 @@ BOOST_AUTO_TEST_CASE(SetEventIntervals)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
{
|
||||
shared_ptr<ndn::util::DummyClientFace> face = ndn::util::makeDummyClientFace(g_ioService);
|
||||
shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
Lsdb& lsdb = nlsr.getLsdb();
|
||||
|
||||
@@ -125,7 +139,6 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
|
||||
// Add active neighbors
|
||||
AdjacencyList& neighbors = nlsr.getAdjacencyList();
|
||||
|
||||
uint64_t destroyFaceId = 128;
|
||||
|
||||
// Create a neighbor whose Face will be destroyed
|
||||
@@ -146,15 +159,14 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
// This router
|
||||
Adjacent thisRouter(conf.getRouterPrefix(), "uri://faceB", 10, Adjacent::STATUS_ACTIVE, 0, 256);
|
||||
|
||||
AdjLsa ownAdjLsa(conf.getRouterPrefix(), AdjLsa::TYPE_STRING, 10, ndn::time::system_clock::now(),
|
||||
1, neighbors);
|
||||
AdjLsa ownAdjLsa(conf.getRouterPrefix(), 10, ndn::time::system_clock::now(), 1, neighbors);
|
||||
lsdb.installAdjLsa(ownAdjLsa);
|
||||
|
||||
// Router that will fail
|
||||
AdjacencyList failAdjacencies;
|
||||
failAdjacencies.insert(thisRouter);
|
||||
|
||||
AdjLsa failAdjLsa("/ndn/neighborA", AdjLsa::TYPE_STRING, 10,
|
||||
AdjLsa failAdjLsa("/ndn/neighborA", 10,
|
||||
ndn::time::system_clock::now() + ndn::time::seconds(3600), 1, failAdjacencies);
|
||||
|
||||
lsdb.installAdjLsa(failAdjLsa);
|
||||
@@ -163,7 +175,7 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
AdjacencyList otherAdjacencies;
|
||||
otherAdjacencies.insert(thisRouter);
|
||||
|
||||
AdjLsa otherAdjLsa("/ndn/neighborB", AdjLsa::TYPE_STRING, 10,
|
||||
AdjLsa otherAdjLsa("/ndn/neighborB", 10,
|
||||
ndn::time::system_clock::now() + ndn::time::seconds(3600), 1, otherAdjacencies);
|
||||
|
||||
lsdb.installAdjLsa(otherAdjLsa);
|
||||
@@ -224,7 +236,7 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
|
||||
// refresh will not cause RIB entries for other nodes' name prefixes to be refreshed.
|
||||
BOOST_FIXTURE_TEST_CASE(FaceDestroyEventInactive, UnitTestTimeFixture)
|
||||
{
|
||||
shared_ptr<ndn::util::DummyClientFace> face = ndn::util::makeDummyClientFace(g_ioService);
|
||||
shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
Lsdb& lsdb = nlsr.getLsdb();
|
||||
|
||||
@@ -256,7 +268,7 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEventInactive, UnitTestTimeFixture)
|
||||
ndn::Name nameToAdvertise("/ndn/neighborB/name");
|
||||
nameList.insert(nameToAdvertise);
|
||||
|
||||
NameLsa nameLsa("/ndn/neighborB", "name", 25, ndn::time::system_clock::now(), nameList);
|
||||
NameLsa nameLsa("/ndn/neighborB", 25, ndn::time::system_clock::now(), nameList);
|
||||
lsdb.installNameLsa(nameLsa);
|
||||
|
||||
nlsr.initialize();
|
||||
@@ -268,15 +280,14 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEventInactive, UnitTestTimeFixture)
|
||||
// This router
|
||||
Adjacent thisRouter(conf.getRouterPrefix(), "uri://faceB", 25, Adjacent::STATUS_ACTIVE, 0, 256);
|
||||
|
||||
AdjLsa ownAdjLsa(conf.getRouterPrefix(), AdjLsa::TYPE_STRING, 10, ndn::time::system_clock::now(),
|
||||
1, neighbors);
|
||||
AdjLsa ownAdjLsa(conf.getRouterPrefix(), 10, ndn::time::system_clock::now(), 1, neighbors);
|
||||
lsdb.installAdjLsa(ownAdjLsa);
|
||||
|
||||
// Other ACTIVE router
|
||||
AdjacencyList otherAdjacencies;
|
||||
otherAdjacencies.insert(thisRouter);
|
||||
|
||||
AdjLsa otherAdjLsa("/ndn/neighborB", AdjLsa::TYPE_STRING, 10,
|
||||
AdjLsa otherAdjLsa("/ndn/neighborB", 10,
|
||||
ndn::time::system_clock::now() + ndn::time::seconds(3600), 1, otherAdjacencies);
|
||||
|
||||
lsdb.installAdjLsa(otherAdjLsa);
|
||||
@@ -327,11 +338,8 @@ BOOST_FIXTURE_TEST_CASE(FaceDestroyEventInactive, UnitTestTimeFixture)
|
||||
BOOST_CHECK_EQUAL(parameters.getName(), nameToAdvertise);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(GetCertificate, UnitTestTimeFixture)
|
||||
BOOST_AUTO_TEST_CASE(GetCertificate)
|
||||
{
|
||||
shared_ptr<ndn::util::DummyClientFace> face = ndn::util::makeDummyClientFace(g_ioService);
|
||||
Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
|
||||
// Create certificate
|
||||
ndn::Name identity("/TestNLSR/identity");
|
||||
identity.appendVersion();
|
||||
@@ -359,6 +367,84 @@ BOOST_FIXTURE_TEST_CASE(GetCertificate, UnitTestTimeFixture)
|
||||
BOOST_CHECK(nlsr.getCertificate(certKey) != nullptr);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SetRouterCommandPrefix)
|
||||
{
|
||||
// Simulate loading configuration file
|
||||
ConfParameter& conf = nlsr.getConfParameter();
|
||||
conf.setNetwork("/ndn");
|
||||
conf.setSiteName("/site");
|
||||
conf.setRouterName("/%C1.router/this-router");
|
||||
|
||||
nlsr.initialize();
|
||||
|
||||
BOOST_CHECK_EQUAL(nlsr.getLsdbDatasetHandler().getRouterNameCommandPrefix(),
|
||||
ndn::Name("/ndn/site/%C1.router/this-router/lsdb"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(BuildAdjLsaAfterHelloResponse)
|
||||
{
|
||||
// Configure NLSR
|
||||
ConfParameter& conf = nlsr.getConfParameter();
|
||||
conf.setNetwork("/ndn");
|
||||
conf.setSiteName("/site");
|
||||
|
||||
ndn::Name routerName("/%C1.Router/this-router");
|
||||
conf.setRouterName(routerName);
|
||||
|
||||
conf.setAdjLsaBuildInterval(1);
|
||||
|
||||
// Add neighbors
|
||||
// Router A
|
||||
ndn::Name neighborAName("/ndn/site/%C1.router/routerA");
|
||||
Adjacent neighborA(neighborAName, "uri://faceA", 0, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
neighbors.insert(neighborA);
|
||||
|
||||
// Router B
|
||||
ndn::Name neighborBName("/ndn/site/%C1.router/routerB");
|
||||
Adjacent neighborB(neighborBName, "uri://faceA", 0, Adjacent::STATUS_INACTIVE, 0, 0);
|
||||
neighbors.insert(neighborB);
|
||||
|
||||
nlsr.initialize();
|
||||
this->advanceClocks(ndn::time::milliseconds(1));
|
||||
|
||||
// Receive HELLO response from Router A
|
||||
receiveHelloData(neighborAName, conf.getRouterPrefix());
|
||||
this->advanceClocks(ndn::time::seconds(1));
|
||||
|
||||
ndn::Name lsaKey = ndn::Name(conf.getRouterPrefix()).append(AdjLsa::TYPE_STRING);
|
||||
|
||||
// Adjacency LSA should be built even though other router is INACTIVE
|
||||
AdjLsa* lsa = lsdb.findAdjLsa(lsaKey);
|
||||
BOOST_REQUIRE(lsa != nullptr);
|
||||
BOOST_CHECK_EQUAL(lsa->getAdl().getSize(), 1);
|
||||
|
||||
// Receive HELLO response from Router B
|
||||
receiveHelloData(neighborBName, conf.getRouterPrefix());
|
||||
|
||||
// Both routers become INACTIVE and HELLO Interests have timed out
|
||||
for (Adjacent& adjacency : neighbors.getAdjList()) {
|
||||
adjacency.setStatus(Adjacent::STATUS_INACTIVE);
|
||||
adjacency.setInterestTimedOutNo(HELLO_RETRIES_DEFAULT);
|
||||
}
|
||||
|
||||
this->advanceClocks(ndn::time::seconds(1));
|
||||
|
||||
// Adjacency LSA should have been removed since this router's adjacencies are INACTIVE
|
||||
// and have timed out
|
||||
lsa = lsdb.findAdjLsa(lsaKey);
|
||||
BOOST_CHECK(lsa == nullptr);
|
||||
|
||||
// Receive HELLO response from Router A and B
|
||||
receiveHelloData(neighborAName, conf.getRouterPrefix());
|
||||
receiveHelloData(neighborBName, conf.getRouterPrefix());
|
||||
this->advanceClocks(ndn::time::seconds(1));
|
||||
|
||||
// Adjacency LSA should be built
|
||||
lsa = lsdb.findAdjLsa(lsaKey);
|
||||
BOOST_REQUIRE(lsa != nullptr);
|
||||
BOOST_CHECK_EQUAL(lsa->getAdl().getSize(), 2);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} //namespace test
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -20,22 +20,22 @@
|
||||
**/
|
||||
|
||||
#include "test-common.hpp"
|
||||
#include "dummy-face.hpp"
|
||||
|
||||
#include "nlsr.hpp"
|
||||
#include "communication/sync-logic-handler.hpp"
|
||||
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
|
||||
using ndn::DummyFace;
|
||||
using ndn::shared_ptr;
|
||||
|
||||
class SyncLogicFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
SyncLogicFixture()
|
||||
: face(ndn::makeDummyFace())
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, nlsr(g_ioService, g_scheduler, ndn::ref(*face))
|
||||
, sync(nlsr.getSyncLogicHandler())
|
||||
, CONFIG_NETWORK("/ndn")
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
receiveUpdate(std::string prefix, uint64_t seqNo)
|
||||
receiveUpdate(std::string prefix, uint64_t seqNo, SyncLogicHandler& p_sync)
|
||||
{
|
||||
Sync::MissingDataInfo info = {prefix, 0, seqNo};
|
||||
|
||||
@@ -57,15 +57,15 @@ public:
|
||||
updates.push_back(info);
|
||||
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
face->m_sentInterests.clear();
|
||||
face->sentInterests.clear();
|
||||
|
||||
sync.onNsyncUpdate(updates, NULL);
|
||||
p_sync.onNsyncUpdate(updates, NULL);
|
||||
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<DummyFace> face;
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
Nlsr nlsr;
|
||||
SyncLogicHandler& sync;
|
||||
|
||||
@@ -76,34 +76,114 @@ public:
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOther)
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
|
||||
{
|
||||
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
|
||||
CONFIG_SITE + "/%C1.Router/other-router/";
|
||||
|
||||
receiveUpdate(updateName, 1);
|
||||
uint64_t syncSeqNo = 1;
|
||||
receiveUpdate(updateName, syncSeqNo, sync);
|
||||
|
||||
std::vector<ndn::Interest>& interests = face->m_sentInterests;
|
||||
BOOST_REQUIRE_EQUAL(interests.size(), 3);
|
||||
std::vector<ndn::Interest>& interests = face->sentInterests;
|
||||
|
||||
std::vector<ndn::Interest>::iterator it = interests.begin();
|
||||
|
||||
BOOST_REQUIRE_EQUAL(interests.size(), 2);
|
||||
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
|
||||
|
||||
++it;
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
|
||||
{
|
||||
Nlsr nlsr_hr(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
SyncLogicHandler& sync_hr(nlsr_hr.getSyncLogicHandler());
|
||||
|
||||
nlsr_hr.getConfParameter().setNetwork(CONFIG_NETWORK);
|
||||
nlsr_hr.getConfParameter().setSiteName(CONFIG_SITE);
|
||||
nlsr_hr.getConfParameter().setRouterName(CONFIG_ROUTER_NAME);
|
||||
nlsr_hr.getConfParameter().buildRouterPrefix();
|
||||
|
||||
nlsr_hr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
|
||||
|
||||
nlsr_hr.initialize();
|
||||
|
||||
std::string updateName = nlsr_hr.getConfParameter().getLsaPrefix().toUri() +
|
||||
CONFIG_SITE + "/%C1.Router/other-router/";
|
||||
|
||||
uint64_t syncSeqNo = 0;
|
||||
syncSeqNo = syncSeqNo | (static_cast<uint64_t>(1) << 20);
|
||||
|
||||
receiveUpdate(updateName, syncSeqNo, sync_hr);
|
||||
|
||||
std::vector<ndn::Interest>& interests = face->sentInterests;
|
||||
std::vector<ndn::Interest>::iterator it = interests.begin();
|
||||
|
||||
BOOST_REQUIRE_EQUAL(interests.size(), 2);
|
||||
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
|
||||
|
||||
++it;
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
|
||||
{
|
||||
|
||||
Nlsr nlsr_hrdry(g_ioService, g_scheduler, ndn::ref(*face));
|
||||
SyncLogicHandler& sync_hrdry(nlsr_hrdry.getSyncLogicHandler());
|
||||
|
||||
nlsr_hrdry.getConfParameter().setNetwork(CONFIG_NETWORK);
|
||||
nlsr_hrdry.getConfParameter().setSiteName(CONFIG_SITE);
|
||||
nlsr_hrdry.getConfParameter().setRouterName(CONFIG_ROUTER_NAME);
|
||||
nlsr_hrdry.getConfParameter().buildRouterPrefix();
|
||||
|
||||
nlsr_hrdry.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
|
||||
|
||||
nlsr_hrdry.initialize();
|
||||
|
||||
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
|
||||
CONFIG_SITE + "/%C1.Router/other-router/";
|
||||
|
||||
|
||||
uint64_t syncSeqNo = 1;
|
||||
syncSeqNo = syncSeqNo | (static_cast<uint64_t>(1) << 20);
|
||||
receiveUpdate(updateName, syncSeqNo, sync_hrdry);
|
||||
|
||||
std::vector<ndn::Interest>& interests = face->sentInterests;
|
||||
std::vector<ndn::Interest>::iterator it = interests.begin();
|
||||
|
||||
BOOST_REQUIRE_EQUAL(interests.size(), 3);
|
||||
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + NameLsa::TYPE_STRING + "/");
|
||||
|
||||
if (nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
|
||||
++it;
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
|
||||
}
|
||||
else if (nlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) {
|
||||
++it;
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + CoordinateLsa::TYPE_STRING + "/");
|
||||
|
||||
++it;
|
||||
BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + AdjLsa::TYPE_STRING + "/");
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
|
||||
{
|
||||
std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
|
||||
CONFIG_SITE + CONFIG_ROUTER_NAME;
|
||||
|
||||
receiveUpdate(updateName, 1);
|
||||
receiveUpdate(updateName, 1, sync);
|
||||
|
||||
std::vector<ndn::Interest>& interests = face->m_sentInterests;
|
||||
std::vector<ndn::Interest>& interests = face->sentInterests;
|
||||
BOOST_CHECK_EQUAL(interests.size(), 0);
|
||||
}
|
||||
|
||||
@@ -112,7 +192,7 @@ BOOST_AUTO_TEST_CASE(MalformedUpdate)
|
||||
std::string updateName = CONFIG_SITE + nlsr.getConfParameter().getLsaPrefix().toUri() +
|
||||
CONFIG_ROUTER_NAME;
|
||||
|
||||
std::vector<ndn::Interest>& interests = face->m_sentInterests;
|
||||
std::vector<ndn::Interest>& interests = face->sentInterests;
|
||||
BOOST_CHECK_EQUAL(interests.size(), 0);
|
||||
}
|
||||
|
||||
@@ -124,17 +204,17 @@ BOOST_AUTO_TEST_CASE(SequenceNumber)
|
||||
|
||||
// Install Name LSA
|
||||
NamePrefixList nameList;
|
||||
NameLsa lsa(originRouter, NameLsa::TYPE_STRING, 999, ndn::time::system_clock::TimePoint::max(), nameList);
|
||||
NameLsa lsa(originRouter, 999, ndn::time::system_clock::TimePoint::max(), nameList);
|
||||
lsdb.installNameLsa(lsa);
|
||||
|
||||
// Install Adj LSA
|
||||
AdjacencyList adjList;
|
||||
AdjLsa adjLsa(originRouter, AdjLsa::TYPE_STRING, 1000, ndn::time::system_clock::TimePoint::max(),
|
||||
AdjLsa adjLsa(originRouter, 1000, ndn::time::system_clock::TimePoint::max(),
|
||||
3 , adjList);
|
||||
lsdb.installAdjLsa(adjLsa);
|
||||
|
||||
// Install Cor LSA
|
||||
CoordinateLsa corLsa(originRouter, CoordinateLsa::TYPE_STRING, 1000, ndn::time::system_clock::TimePoint::max(),
|
||||
CoordinateLsa corLsa(originRouter, 1000, ndn::time::system_clock::TimePoint::max(),
|
||||
0,0);
|
||||
lsdb.installCoordinateLsa(corLsa);
|
||||
|
||||
@@ -143,23 +223,23 @@ BOOST_AUTO_TEST_CASE(SequenceNumber)
|
||||
|
||||
// Lower NameLSA sequence number
|
||||
uint64_t lowerSeqNo = static_cast<uint64_t>(998) << 40;
|
||||
receiveUpdate(updateName, lowerSeqNo);
|
||||
receiveUpdate(updateName, lowerSeqNo, sync);
|
||||
|
||||
std::vector<ndn::Interest>& interests = face->m_sentInterests;
|
||||
std::vector<ndn::Interest>& interests = face->sentInterests;
|
||||
BOOST_REQUIRE_EQUAL(interests.size(), 0);
|
||||
|
||||
// Same NameLSA sequence number
|
||||
uint64_t sameSeqNo = static_cast<uint64_t>(999) << 40;
|
||||
receiveUpdate(updateName, sameSeqNo);
|
||||
receiveUpdate(updateName, sameSeqNo, sync);
|
||||
|
||||
interests = face->m_sentInterests;
|
||||
interests = face->sentInterests;
|
||||
BOOST_REQUIRE_EQUAL(interests.size(), 0);
|
||||
|
||||
// Higher NameLSA sequence number
|
||||
uint64_t higherSeqNo = static_cast<uint64_t>(1000) << 40;
|
||||
receiveUpdate(updateName, higherSeqNo);
|
||||
receiveUpdate(updateName, higherSeqNo, sync);
|
||||
|
||||
interests = face->m_sentInterests;
|
||||
interests = face->sentInterests;
|
||||
BOOST_REQUIRE_EQUAL(interests.size(), 1);
|
||||
|
||||
std::vector<ndn::Interest>::iterator it = interests.begin();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(LsaInfoOutputStream)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(LsaInfoMake)
|
||||
{
|
||||
Lsa lsa;
|
||||
Lsa lsa("lsa-type");
|
||||
lsa.setOrigRouter("/test/lsa/info/tlv");
|
||||
lsa.setLsSeqNo(128);
|
||||
lsa.setExpirationTimePoint(ndn::time::system_clock::now());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -43,7 +43,7 @@ class PrefixUpdateFixture : public nlsr::test::BaseFixture
|
||||
{
|
||||
public:
|
||||
PrefixUpdateFixture()
|
||||
: face(ndn::util::makeDummyClientFace(g_ioService))
|
||||
: face(make_shared<ndn::util::DummyClientFace>(g_ioService))
|
||||
, siteIdentity(ndn::Name("/ndn/edu/test-site").appendVersion())
|
||||
, opIdentity(ndn::Name(siteIdentity).append(ndn::Name("%C1.Operator")).appendVersion())
|
||||
, nlsr(g_ioService, g_scheduler, *face)
|
||||
@@ -160,23 +160,23 @@ public:
|
||||
{
|
||||
const ndn::Name& lsaPrefix = nlsr.getConfParameter().getLsaPrefix();
|
||||
|
||||
const auto& it = std::find_if(face->sentDatas.begin(), face->sentDatas.end(),
|
||||
const auto& it = std::find_if(face->sentData.begin(), face->sentData.end(),
|
||||
[lsaPrefix] (const ndn::Data& data) {
|
||||
return lsaPrefix.isPrefixOf(data.getName());
|
||||
});
|
||||
|
||||
return (it != face->sentDatas.end());
|
||||
return (it != face->sentData.end());
|
||||
}
|
||||
|
||||
void
|
||||
checkResponseCode(const Name& commandPrefix, uint64_t expectedCode)
|
||||
{
|
||||
std::vector<Data>::iterator it = std::find_if(face->sentDatas.begin(),
|
||||
face->sentDatas.end(),
|
||||
std::vector<Data>::iterator it = std::find_if(face->sentData.begin(),
|
||||
face->sentData.end(),
|
||||
[commandPrefix] (const Data& data) {
|
||||
return commandPrefix.isPrefixOf(data.getName());
|
||||
});
|
||||
BOOST_REQUIRE(it != face->sentDatas.end());
|
||||
BOOST_REQUIRE(it != face->sentData.end());
|
||||
|
||||
ndn::nfd::ControlResponse response(it->getContent().blockFromValue());
|
||||
BOOST_CHECK_EQUAL(response.getCode(), expectedCode);
|
||||
@@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
BOOST_CHECK_EQUAL(namePrefixList.getNameList().front(), parameters.getName());
|
||||
|
||||
BOOST_CHECK(wasRoutingUpdatePublished());
|
||||
face->sentDatas.clear();
|
||||
face->sentData.clear();
|
||||
|
||||
// Withdraw
|
||||
ndn::Name withdrawCommand("/localhost/nlsr/prefix-update/withdraw");
|
||||
@@ -266,12 +266,12 @@ BOOST_AUTO_TEST_CASE(DisabledAndEnabled)
|
||||
face->receive(*advertiseInterest);
|
||||
face->processEvents(ndn::time::milliseconds(1));
|
||||
|
||||
BOOST_REQUIRE(!face->sentDatas.empty());
|
||||
BOOST_REQUIRE(!face->sentData.empty());
|
||||
|
||||
const ndn::MetaInfo& metaInfo = face->sentDatas.front().getMetaInfo();
|
||||
const ndn::MetaInfo& metaInfo = face->sentData.front().getMetaInfo();
|
||||
BOOST_CHECK_EQUAL(metaInfo.getType(), ndn::tlv::ContentType_Nack);
|
||||
|
||||
face->sentDatas.clear();
|
||||
face->sentData.clear();
|
||||
|
||||
// Enable PrefixUpdateProcessor so commands will be processed
|
||||
updateProcessor.enable();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
@@ -21,12 +21,12 @@
|
||||
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/control-commands.hpp"
|
||||
#include "tests/dummy-face.hpp"
|
||||
|
||||
#include "utility/face-controller.hpp"
|
||||
|
||||
#include <ndn-cxx/security/key-chain.hpp>
|
||||
#include <ndn-cxx/management/nfd-controller.hpp>
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
namespace nlsr {
|
||||
namespace test {
|
||||
@@ -39,8 +39,8 @@ class FaceControllerFixture : public BaseFixture
|
||||
{
|
||||
public:
|
||||
FaceControllerFixture()
|
||||
: face(ndn::makeDummyFace())
|
||||
, interests(face->m_sentInterests)
|
||||
: face(make_shared<ndn::util::DummyClientFace>())
|
||||
, interests(face->sentInterests)
|
||||
, controller(*face, keyChain)
|
||||
, faceController(g_ioService, controller)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
shared_ptr<ndn::DummyFace> face;
|
||||
shared_ptr<ndn::util::DummyClientFace> face;
|
||||
ndn::KeyChain keyChain;
|
||||
std::vector<Interest>& interests;
|
||||
ndn::nfd::Controller controller;
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ def build(bld):
|
||||
source=bld.path.ant_glob(['nsync/**/*.cc']),
|
||||
use='nsync-objects unit-tests-main',
|
||||
includes='.',
|
||||
install_prefix=None,
|
||||
install_path=None,
|
||||
)
|
||||
|
||||
# nlsr tests
|
||||
@@ -49,5 +49,5 @@ def build(bld):
|
||||
source=bld.path.ant_glob(['nlsr/**/*.cpp']),
|
||||
use='nlsr-objects unit-tests-main',
|
||||
includes='.',
|
||||
install_prefix=None,
|
||||
install_path=None,
|
||||
)
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2015, The University of Memphis,
|
||||
* Copyright (c) 2014-2016, The University of Memphis,
|
||||
* Regents of the University of California,
|
||||
* Arizona Board of Regents.
|
||||
*
|
||||
|
||||
@@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with
|
||||
NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
VERSION = '0.2.2'
|
||||
VERSION = '0.3.0'
|
||||
APPNAME = "nlsr"
|
||||
BUGREPORT = "http://redmine.named-data.net/projects/nlsr"
|
||||
URL = "http://named-data.net/doc/NLSR/"
|
||||
|
||||
Reference in new issue
Block a user