fw: replace Link with forwarding hint
Forwarding now processes forwarding hint on Interests,
and no longer considers the Link object.
refs #4055
Change-Id: I0331687ee8ec31afa2f1a105e903670689647c4d
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index c669454..c01859f 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -588,61 +588,6 @@
BOOST_CHECK_EQUAL(pit.size(), 0);
}
-
-class MalformedPacketFixture : public UnitTestTimeFixture
-{
-protected:
- MalformedPacketFixture()
- : face1(make_shared<DummyFace>())
- , face2(make_shared<DummyFace>())
- {
- forwarder.addFace(face1);
- forwarder.addFace(face2);
- }
-
- void
- processInterest(shared_ptr<Interest> badInterest)
- {
- forwarder.startProcessInterest(*face1, *badInterest);
- this->continueProcessPacket();
- }
-
- // processData
-
- // processNack
-
-private:
- void
- continueProcessPacket()
- {
- this->advanceClocks(time::milliseconds(10), time::seconds(6));
- }
-
-protected:
- Forwarder forwarder;
- shared_ptr<DummyFace> face1; // face of incoming bad packet
- shared_ptr<DummyFace> face2; // another face for setting up states
-};
-
-BOOST_FIXTURE_TEST_SUITE(MalformedPacket, MalformedPacketFixture)
-
-BOOST_AUTO_TEST_CASE(BadLink)
-{
- shared_ptr<Interest> goodInterest = makeInterest("ndn:/");
- Block wire = goodInterest->wireEncode();
- wire.push_back(ndn::encoding::makeEmptyBlock(tlv::Data)); // bad Link
- wire.encode();
-
- auto badInterest = make_shared<Interest>();
- BOOST_REQUIRE_NO_THROW(badInterest->wireDecode(wire));
- BOOST_REQUIRE(badInterest->hasLink());
- BOOST_REQUIRE_THROW(badInterest->getLink(), tlv::Error);
-
- BOOST_CHECK_NO_THROW(this->processInterest(badInterest));
-}
-
-BOOST_AUTO_TEST_SUITE_END() // MalformedPacket
-
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/daemon/fw/link-forwarding.t.cpp b/tests/daemon/fw/forwarding-hint.t.cpp
similarity index 79%
rename from tests/daemon/fw/link-forwarding.t.cpp
rename to tests/daemon/fw/forwarding-hint.t.cpp
index 8bf1dfb..7d0d37d 100644
--- a/tests/daemon/fw/link-forwarding.t.cpp
+++ b/tests/daemon/fw/forwarding-hint.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -34,7 +34,7 @@
using namespace nfd::tests;
BOOST_AUTO_TEST_SUITE(Fw)
-BOOST_AUTO_TEST_SUITE(TestLinkForwarding)
+BOOST_AUTO_TEST_SUITE(TestForwardingHint)
/**
* /arizona/cs/avenir
@@ -95,8 +95,6 @@
topo.registerPrefix(nodeH, linkHC->getFace(nodeH), "/ucla", 20);
topo.registerPrefix(nodeC, linkCS->getFace(nodeC), "/ucla", 10);
topo.registerPrefix(nodeS, linkSQ->getFace(nodeS), "/net/ndnsim", 10);
-
- linkObject = makeLink("/net/ndnsim", {{10, "/telia/terabits"}, {20, "/ucla/cs"}});
}
/** \brief express an Interest with Link object from consumerA
@@ -105,7 +103,7 @@
consumerExpressInterest(int seq)
{
auto interest = makeInterest(Name("/net/ndnsim").appendNumber(seq));
- interest->setLink(linkObject->wireEncode());
+ interest->setForwardingHint({delTelia, delUcla});
consumerA->getClientFace().expressInterest(*interest, nullptr, nullptr, nullptr);
}
@@ -114,7 +112,9 @@
TopologyNode nodeA, nodeH, nodeT, nodeP, nodeC, nodeS, nodeQ;
shared_ptr<TopologyLink> linkAH, linkHT, linkTP, linkHC, linkCS, linkSQ;
shared_ptr<TopologyAppLink> consumerA, producerP, producerQ;
- shared_ptr<Link> linkObject;
+
+ Delegation delTelia = {10, "/telia/terabits"};
+ Delegation delUcla = {20, "/ucla/cs"};
};
BOOST_FIXTURE_TEST_SUITE(NdnsimTeliaUclaTopology, NdnsimTeliaUclaTopologyFixture)
@@ -124,24 +124,20 @@
this->consumerExpressInterest(1);
this->advanceClocks(time::milliseconds(11), 20);
- // A forwards Interest according to default route, no change to Link and SelectedDelegation
+ // 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.hasLink(), true);
- BOOST_CHECK_EQUAL(interestAH.hasSelectedDelegation(), false);
+ BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), DelegationList({delTelia, delUcla}));
- // H prefers T, and sets SelectedDelegation
+ // 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.hasLink(), true);
- BOOST_CHECK_EQUAL(interestHT.hasSelectedDelegation(), true);
- BOOST_CHECK_EQUAL(interestHT.getSelectedDelegation(), "/telia/terabits");
+ BOOST_CHECK_EQUAL(interestHT.getForwardingHint(), DelegationList({delTelia, delUcla}));
- // T forwards to P, Link and SelectedDelegation are stripped when Interest reaches producer region
+ // T forwards to P, forwarding hint stripped when Interest reaches producer region
BOOST_CHECK_EQUAL(linkTP->getFace(nodeT).getCounters().nOutInterests, 1);
const Interest& interestTP = topo.getPcap(linkTP->getFace(nodeT)).sentInterests.at(0);
- BOOST_CHECK_EQUAL(interestTP.hasLink(), false);
- BOOST_CHECK_EQUAL(interestTP.hasSelectedDelegation(), false);
+ BOOST_CHECK(interestTP.getForwardingHint().empty());
// Data is served by P and reaches A
BOOST_CHECK_EQUAL(producerP->getForwarderFace().getCounters().nInData, 1);
@@ -157,31 +153,25 @@
this->consumerExpressInterest(1);
this->advanceClocks(time::milliseconds(11), 20);
- // A forwards Interest according to default route, no change to Link and SelectedDelegation
+ // 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.hasLink(), true);
- BOOST_CHECK_EQUAL(interestAH.hasSelectedDelegation(), false);
+ BOOST_CHECK_EQUAL(interestAH.getForwardingHint(), DelegationList({delTelia, delUcla}));
- // H forwards to C, and sets SelectedDelegation
+ // 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.hasLink(), true);
- BOOST_CHECK_EQUAL(interestHC.hasSelectedDelegation(), true);
- BOOST_CHECK_EQUAL(interestHC.getSelectedDelegation(), "/ucla/cs");
+ BOOST_CHECK_EQUAL(interestHC.getForwardingHint(), DelegationList({delTelia, delUcla}));
- // C forwards to S, no change to Link and SelectedDelegation
+ // 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.hasLink(), true);
- BOOST_CHECK_EQUAL(interestCS.hasSelectedDelegation(), true);
- BOOST_CHECK_EQUAL(interestCS.getSelectedDelegation(), "/ucla/cs");
+ BOOST_CHECK_EQUAL(interestCS.getForwardingHint(), DelegationList({delTelia, delUcla}));
- // S forwards to Q, Link and SelectedDelegation are stripped when Interest reaches producer region
+ // S forwards to Q, forwarding hint stripped when Interest reaches producer region
BOOST_CHECK_EQUAL(linkSQ->getFace(nodeS).getCounters().nOutInterests, 1);
const Interest& interestSQ = topo.getPcap(linkSQ->getFace(nodeS)).sentInterests.at(0);
- BOOST_CHECK_EQUAL(interestSQ.hasLink(), false);
- BOOST_CHECK_EQUAL(interestSQ.hasSelectedDelegation(), false);
+ BOOST_CHECK(interestSQ.getForwardingHint().empty());
// Data is served by Q and reaches A
BOOST_CHECK_EQUAL(producerQ->getForwarderFace().getCounters().nInData, 1);
@@ -190,7 +180,7 @@
BOOST_AUTO_TEST_SUITE_END() // NdnsimTeliaUclaTopology
-BOOST_AUTO_TEST_SUITE_END() // TestLinkForwarding
+BOOST_AUTO_TEST_SUITE_END() // TestForwardingHint
BOOST_AUTO_TEST_SUITE_END() // Fw
} // namespace tests
diff --git a/tests/daemon/table/network-region-table.t.cpp b/tests/daemon/table/network-region-table.t.cpp
index f4ab6e1..68f1a03 100644
--- a/tests/daemon/table/network-region-table.t.cpp
+++ b/tests/daemon/table/network-region-table.t.cpp
@@ -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-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -35,24 +35,24 @@
BOOST_AUTO_TEST_CASE(InProducerRegion)
{
- shared_ptr<Link> link = makeLink("/net/ndnsim", {{10, "/telia/terabits"}, {20, "/ucla/cs"}});
+ DelegationList fh{{10, "/telia/terabits"}, {20, "/ucla/cs"}};
NetworkRegionTable nrt1;
nrt1.insert("/verizon");
- BOOST_CHECK_EQUAL(nrt1.isInProducerRegion(*link), false);
+ BOOST_CHECK_EQUAL(nrt1.isInProducerRegion(fh), false);
NetworkRegionTable nrt2;
nrt2.insert("/ucla");
- BOOST_CHECK_EQUAL(nrt2.isInProducerRegion(*link), false);
+ BOOST_CHECK_EQUAL(nrt2.isInProducerRegion(fh), false);
NetworkRegionTable nrt3;
nrt3.insert("/ucla/cs");
- BOOST_CHECK_EQUAL(nrt3.isInProducerRegion(*link), true);
+ BOOST_CHECK_EQUAL(nrt3.isInProducerRegion(fh), true);
NetworkRegionTable nrt4;
nrt4.insert("/ucla/cs/software");
nrt4.insert("/ucla/cs/irl");
- BOOST_CHECK_EQUAL(nrt4.isInProducerRegion(*link), true);
+ BOOST_CHECK_EQUAL(nrt4.isInProducerRegion(fh), true);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/daemon/table/pit-entry.t.cpp b/tests/daemon/table/pit-entry.t.cpp
index 73cf7de..effb624 100644
--- a/tests/daemon/table/pit-entry.t.cpp
+++ b/tests/daemon/table/pit-entry.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -55,8 +55,7 @@
BOOST_CHECK_EQUAL(entry.canMatch(*interest3), true);
shared_ptr<Interest> interest4 = makeInterest("/A");
- shared_ptr<Link> link4 = makeLink("/net/ndnsim", {{10, "/telia/terabits"}, {20, "/ucla/cs"}});
- interest4->setLink(link4->wireEncode());
+ interest4->setForwardingHint({{10, "/telia/terabits"}, {20, "/ucla/cs"}});
BOOST_CHECK_EQUAL(entry.canMatch(*interest4), false); // expected failure until #3162
shared_ptr<Interest> interest5 = makeInterest("/A");