table+fw: update ForwardingHint format

refs #5187

Change-Id: Ic8e32c83caeb60404f1b035a4f7e9841cc513f0b
This commit is contained in:
Junxiao Shi committed 2022-01-11 18:40:04 +00:00
1 parent 80111b72f9
commit 727b61087a
7 files changed
+33 -25

No files matched your search

+3 -1
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -69,6 +69,7 @@
#include <ndn-cxx/util/optional.hpp>
#include <ndn-cxx/util/scheduler.hpp>
#include <ndn-cxx/util/signal.hpp>
#include <ndn-cxx/util/span.hpp>
#include <ndn-cxx/util/time.hpp>
#include <boost/asio.hpp>
@@ -97,6 +98,7 @@ using namespace std::string_literals;
using ndn::optional;
using ndn::nullopt;
using ndn::span;
using ndn::to_string;
using ndn::Block;
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -297,7 +297,7 @@ Strategy::lookupFib(const pit::Entry& pitEntry) const
const fib::Entry* fibEntry = nullptr;
for (const auto& delegation : fh) {
fibEntry = &fib.findLongestPrefixMatch(delegation.name);
fibEntry = &fib.findLongestPrefixMatch(delegation);
if (fibEntry->hasNextHops()) {
if (fibEntry->getPrefix().size() == 0) {
// in consumer region, return the default route
@@ -305,7 +305,7 @@ Strategy::lookupFib(const pit::Entry& pitEntry) const
}
else {
// in default-free zone, use the first delegation that finds a FIB entry
NFD_LOG_TRACE("lookupFib delegation=" << delegation.name << " found=" << fibEntry->getPrefix());
NFD_LOG_TRACE("lookupFib delegation=" << delegation << " found=" << fibEntry->getPrefix());
}
return *fibEntry;
}
+3 -3
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,11 +28,11 @@
namespace nfd {
bool
NetworkRegionTable::isInProducerRegion(const ndn::DelegationList& forwardingHint) const
NetworkRegionTable::isInProducerRegion(span<const Name> forwardingHint) const
{
for (const Name& regionName : *this) {
for (const auto& delegation : forwardingHint) {
if (delegation.name.isPrefixOf(regionName)) {
if (delegation.isPrefixOf(regionName)) {
return true;
}
}
+3 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -28,8 +28,6 @@
#include "core/common.hpp"
#include <ndn-cxx/delegation-list.hpp>
namespace nfd {
/** \brief stores a collection of producer region names
@@ -48,11 +46,11 @@ public:
* \retval false the Interest has not reached a producer region
*
* If any delegation name in the forwarding hint is a prefix of any region name,
* the Interest has reached the producer region and should be forwarded according to ‎its Name;
* the Interest has reached the producer region and should be forwarded according to its Name;
* otherwise, the Interest should be forwarded according to the forwarding hint.
*/
bool
isInProducerRegion(const ndn::DelegationList& forwardingHint) const;
isInProducerRegion(span<const Name> forwardingHint) const;
};
} // namespace nfd
+17 -9
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -34,6 +34,14 @@ namespace tests {
using namespace nfd::tests;
#define CHECK_FH_EQUAL(actual, ...) \
do { \
std::vector<Name> expected({__VA_ARGS__}); \
BOOST_CHECK_EQUAL_COLLECTIONS( \
(actual).getForwardingHint().begin(), (actual).getForwardingHint().end(), \
expected.begin(), expected.end()); \
} while (false)
BOOST_AUTO_TEST_SUITE(Fw)
BOOST_AUTO_TEST_SUITE(TestForwardingHint)
@@ -104,7 +112,7 @@ public:
consumerExpressInterest(int seq)
{
auto interest = makeInterest(Name("/net/ndnsim").appendNumber(seq));
interest->setForwardingHint({delTelia, delUcla});
interest->setForwardingHint({nameTelia, nameUcla});
consumerA->getClientFace().expressInterest(*interest, nullptr, nullptr, nullptr);
}
@@ -114,8 +122,8 @@ public:
shared_ptr<TopologyLink> linkAH, linkHT, linkTP, linkHC, linkCS, linkSQ;
shared_ptr<TopologyAppLink> consumerA, producerP, producerQ;
ndn::Delegation delTelia = {10, "/telia/terabits"};
ndn::Delegation delUcla = {20, "/ucla/cs"};
Name nameTelia = "/telia/terabits";
Name nameUcla = "/ucla/cs";
};
BOOST_FIXTURE_TEST_SUITE(NdnsimTeliaUclaTopology, NdnsimTeliaUclaTopologyFixture)
@@ -128,12 +136,12 @@ BOOST_AUTO_TEST_CASE(FetchTelia)
// A forwards Interest according to default route, no change to forwarding hint
BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
CHECK_FH_EQUAL(interestAH, nameTelia, nameUcla);
// H prefers T, no change to forwarding hint
BOOST_CHECK_EQUAL(linkHT->getFace(nodeH).getCounters().nOutInterests, 1);
const Interest& interestHT = topo.getPcap(linkHT->getFace(nodeH)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestHT.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
CHECK_FH_EQUAL(interestHT, nameTelia, nameUcla);
// T forwards to P, forwarding hint stripped when Interest reaches producer region
BOOST_CHECK_EQUAL(linkTP->getFace(nodeT).getCounters().nOutInterests, 1);
@@ -157,17 +165,17 @@ BOOST_AUTO_TEST_CASE(FetchUcla)
// A forwards Interest according to default route, no change to forwarding hint
BOOST_CHECK_EQUAL(linkAH->getFace(nodeA).getCounters().nOutInterests, 1);
const Interest& interestAH = topo.getPcap(linkAH->getFace(nodeA)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
CHECK_FH_EQUAL(interestAH, nameTelia, nameUcla);
// H forwards to C, no change to forwarding hint
BOOST_CHECK_EQUAL(linkHC->getFace(nodeH).getCounters().nOutInterests, 1);
const Interest& interestHC = topo.getPcap(linkHC->getFace(nodeH)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestHC.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
CHECK_FH_EQUAL(interestHC, nameTelia, nameUcla);
// C forwards to S, no change to forwarding hint
BOOST_CHECK_EQUAL(linkCS->getFace(nodeC).getCounters().nOutInterests, 1);
const Interest& interestCS = topo.getPcap(linkCS->getFace(nodeC)).sentInterests.at(0);
BOOST_CHECK_EQUAL(interestCS.getForwardingHint(), ndn::DelegationList({delTelia, delUcla}));
CHECK_FH_EQUAL(interestCS, nameTelia, nameUcla);
// S forwards to Q, forwarding hint stripped when Interest reaches producer region
BOOST_CHECK_EQUAL(linkSQ->getFace(nodeS).getCounters().nOutInterests, 1);
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2021, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -36,7 +36,7 @@ BOOST_FIXTURE_TEST_SUITE(TestNetworkRegionTable, GlobalIoFixture)
BOOST_AUTO_TEST_CASE(InProducerRegion)
{
ndn::DelegationList fh{{10, "/telia/terabits"}, {20, "/ucla/cs"}};
const std::vector<Name> fh{"/telia/terabits", "/ucla/cs"};
NetworkRegionTable nrt1;
nrt1.insert("/verizon");
+2 -2
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2020, Regents of the University of California,
* Copyright (c) 2014-2022, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(CanMatch)
BOOST_CHECK_EQUAL(entry.canMatch(*interest3), true);
auto interest4 = makeInterest("/A");
interest4->setForwardingHint({{10, "/telia/terabits"}, {20, "/ucla/cs"}});
interest4->setForwardingHint({"/telia/terabits", "/ucla/cs"});
BOOST_CHECK_EQUAL(entry.canMatch(*interest4), false); // expected failure until #3162
auto interest5 = makeInterest("/A", true);