fib: add EndpointId field in NextHop record
refs: #4284 Change-Id: If0cfc21cfa81d6fa3c1590ecdce8fbbc1ea95e13
This commit is contained in:
1 parent
feddc3c054
commit
3ad49db6ea
22 files changed
+263
-153
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -137,7 +137,7 @@ AccessStrategy::sendToLastNexthop(const Face& inFace, const Interest& interest,
|
||||
}
|
||||
|
||||
Face* outFace = this->getFace(mi.lastNexthop);
|
||||
if (outFace == nullptr || !fibEntry.hasNextHop(*outFace)) {
|
||||
if (outFace == nullptr || !fibEntry.hasNextHop(*outFace, 0)) {
|
||||
NFD_LOG_DEBUG(pitEntry->getInterest() << " last-nexthop-gone");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -81,7 +81,7 @@ NccStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
|
||||
size_t nUpstreams = nexthops.size();
|
||||
|
||||
shared_ptr<Face> bestFace = meInfo.getBestFace();
|
||||
if (bestFace != nullptr && fibEntry.hasNextHop(*bestFace) &&
|
||||
if (bestFace != nullptr && fibEntry.hasNextHop(*bestFace, 0) &&
|
||||
!wouldViolateScope(inFace, interest, *bestFace) &&
|
||||
canForwardToLegacy(*pitEntry, *bestFace)) {
|
||||
// TODO Should we use `randlow = 100 + nrand48(h->seed) % 4096U;` ?
|
||||
@@ -111,7 +111,7 @@ NccStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
|
||||
}
|
||||
|
||||
shared_ptr<Face> previousFace = meInfo.previousFace.lock();
|
||||
if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
|
||||
if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace, 0) &&
|
||||
!wouldViolateScope(inFace, interest, *previousFace) &&
|
||||
canForwardToLegacy(*pitEntry, *previousFace)) {
|
||||
--nUpstreams;
|
||||
@@ -157,7 +157,7 @@ NccStrategy::doPropagate(FaceId inFaceId, weak_ptr<pit::Entry> pitEntryWeak)
|
||||
MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
|
||||
|
||||
shared_ptr<Face> previousFace = meInfo.previousFace.lock();
|
||||
if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
|
||||
if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace, 0) &&
|
||||
!wouldViolateScope(*inFace, interest, *previousFace) &&
|
||||
canForwardToLegacy(*pitEntry, *previousFace)) {
|
||||
this->sendInterest(pitEntry, *previousFace, interest);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -78,7 +78,7 @@ FibManager::addNextHop(const Name& topPrefix, const Interest& interest,
|
||||
}
|
||||
|
||||
fib::Entry* entry = m_fib.insert(prefix).first;
|
||||
entry->addNextHop(*face, cost);
|
||||
entry->addOrUpdateNextHop(*face, 0, cost);
|
||||
|
||||
NFD_LOG_TRACE("fib/add-nexthop(" << prefix << ',' << faceId << ',' << cost << "): OK");
|
||||
return done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
|
||||
@@ -107,7 +107,7 @@ FibManager::removeNextHop(const Name& topPrefix, const Interest& interest,
|
||||
return;
|
||||
}
|
||||
|
||||
entry->removeNextHop(*face);
|
||||
entry->removeNextHop(*face, 0);
|
||||
if (!entry->hasNextHops()) {
|
||||
m_fib.erase(*entry);
|
||||
NFD_LOG_TRACE("fib/remove-nexthop(" << prefix << ',' << faceId << "): OK entry-erased");
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -169,7 +169,7 @@ Nfd::initializeManagement()
|
||||
|
||||
// add FIB entry for NFD Management Protocol
|
||||
Name topPrefix("/localhost/nfd");
|
||||
m_forwarder->getFib().insert(topPrefix).first->addNextHop(*m_internalFace, 0);
|
||||
m_forwarder->getFib().insert(topPrefix).first->addOrUpdateNextHop(*m_internalFace, 0, 0);
|
||||
m_dispatcher->addTopPrefix(topPrefix, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -36,7 +36,7 @@ cleanupOnFaceRemoval(NameTree& nt, Fib& fib, Pit& pit, const Face& face)
|
||||
for (const name_tree::Entry& nte : nt) {
|
||||
fib::Entry* fibEntry = nte.getFibEntry();
|
||||
if (fibEntry != nullptr) {
|
||||
fib.removeNextHop(*fibEntry, face);
|
||||
fib.removeNextHopByFace(*fibEntry, face);
|
||||
}
|
||||
|
||||
for (const auto& pitEntry : nte.getPitEntries()) {
|
||||
|
||||
+22
-13
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -35,42 +35,51 @@ Entry::Entry(const Name& prefix)
|
||||
}
|
||||
|
||||
NextHopList::iterator
|
||||
Entry::findNextHop(const Face& face)
|
||||
Entry::findNextHop(const Face& face, uint64_t endpointId)
|
||||
{
|
||||
return std::find_if(m_nextHops.begin(), m_nextHops.end(),
|
||||
[&face] (const NextHop& nexthop) {
|
||||
return &nexthop.getFace() == &face;
|
||||
[&face, endpointId] (const NextHop& nexthop) {
|
||||
return &nexthop.getFace() == &face && nexthop.getEndpointId() == endpointId;
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
Entry::hasNextHop(const Face& face) const
|
||||
Entry::hasNextHop(const Face& face, uint64_t endpointId) const
|
||||
{
|
||||
return const_cast<Entry*>(this)->findNextHop(face) != m_nextHops.end();
|
||||
return const_cast<Entry*>(this)->findNextHop(face, endpointId) != m_nextHops.end();
|
||||
}
|
||||
|
||||
void
|
||||
Entry::addNextHop(Face& face, uint64_t cost)
|
||||
Entry::addOrUpdateNextHop(Face& face, uint64_t endpointId, uint64_t cost)
|
||||
{
|
||||
auto it = this->findNextHop(face);
|
||||
auto it = this->findNextHop(face, endpointId);
|
||||
if (it == m_nextHops.end()) {
|
||||
m_nextHops.emplace_back(face);
|
||||
m_nextHops.emplace_back(face, endpointId);
|
||||
it = std::prev(m_nextHops.end());
|
||||
}
|
||||
|
||||
it->setCost(cost);
|
||||
this->sortNextHops();
|
||||
}
|
||||
|
||||
void
|
||||
Entry::removeNextHop(const Face& face)
|
||||
Entry::removeNextHop(const Face& face, uint64_t endpointId)
|
||||
{
|
||||
auto it = this->findNextHop(face);
|
||||
auto it = this->findNextHop(face, endpointId);
|
||||
if (it != m_nextHops.end()) {
|
||||
m_nextHops.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Entry::removeNextHopByFace(const Face& face)
|
||||
{
|
||||
auto it = std::remove_if(m_nextHops.begin(), m_nextHops.end(),
|
||||
[&face] (const NextHop& nexthop) {
|
||||
return &nexthop.getFace() == &face;
|
||||
});
|
||||
m_nextHops.erase(it, m_nextHops.end());
|
||||
}
|
||||
|
||||
void
|
||||
Entry::sortNextHops()
|
||||
{
|
||||
|
||||
+15
-11
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -74,32 +74,36 @@ public:
|
||||
return !m_nextHops.empty();
|
||||
}
|
||||
|
||||
/** \return whether there is a NextHop record for \p face
|
||||
/** \return whether there is a NextHop record for \p face with the given \p endpointId
|
||||
*/
|
||||
bool
|
||||
hasNextHop(const Face& face) const;
|
||||
hasNextHop(const Face& face, uint64_t endpointId) const;
|
||||
|
||||
/** \brief adds a NextHop record
|
||||
*
|
||||
* If a NextHop record for \p face already exists, its cost is updated.
|
||||
* If a NextHop record for \p face and \p endpointId already exists,
|
||||
* its cost is updated.
|
||||
*/
|
||||
void
|
||||
addNextHop(Face& face, uint64_t cost);
|
||||
addOrUpdateNextHop(Face& face, uint64_t endpointId, uint64_t cost);
|
||||
|
||||
/** \brief removes a NextHop record
|
||||
*
|
||||
* If no NextHop record for face exists, do nothing.
|
||||
/** \brief removes the NextHop record for \p face with the given \p endpointId
|
||||
*/
|
||||
void
|
||||
removeNextHop(const Face& face);
|
||||
removeNextHop(const Face& face, uint64_t endpointId);
|
||||
|
||||
/** \brief removes all NextHop records on \p face for any \p endpointId
|
||||
*/
|
||||
void
|
||||
removeNextHopByFace(const Face& face);
|
||||
|
||||
private:
|
||||
/** \note This method is non-const because mutable iterators are needed by callers.
|
||||
*/
|
||||
NextHopList::iterator
|
||||
findNextHop(const Face& face);
|
||||
findNextHop(const Face& face, uint64_t endpointId);
|
||||
|
||||
/** \brief sorts the nexthop list
|
||||
/** \brief sorts the nexthop list by cost
|
||||
*/
|
||||
void
|
||||
sortNextHops();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -28,8 +28,9 @@
|
||||
namespace nfd {
|
||||
namespace fib {
|
||||
|
||||
NextHop::NextHop(Face& face)
|
||||
NextHop::NextHop(Face& face, uint64_t endpointId)
|
||||
: m_face(&face)
|
||||
, m_endpointId(endpointId)
|
||||
, m_cost(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -39,7 +39,7 @@ class NextHop
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
NextHop(Face& face);
|
||||
NextHop(Face& face, uint64_t endpointId);
|
||||
|
||||
Face&
|
||||
getFace() const
|
||||
@@ -47,6 +47,12 @@ public:
|
||||
return *m_face;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getEndpointId() const
|
||||
{
|
||||
return m_endpointId;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
getCost() const
|
||||
{
|
||||
@@ -61,6 +67,7 @@ public:
|
||||
|
||||
private:
|
||||
Face* m_face;
|
||||
uint64_t m_endpointId;
|
||||
uint64_t m_cost;
|
||||
};
|
||||
|
||||
|
||||
+16
-4
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -134,16 +134,28 @@ Fib::erase(const Entry& entry)
|
||||
}
|
||||
|
||||
void
|
||||
Fib::removeNextHop(Entry& entry, const Face& face)
|
||||
Fib::eraseIfEmpty(Entry& entry)
|
||||
{
|
||||
entry.removeNextHop(face);
|
||||
|
||||
if (!entry.hasNextHops()) {
|
||||
name_tree::Entry* nte = m_nameTree.getEntry(entry);
|
||||
this->erase(nte, false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Fib::removeNextHop(Entry& entry, const Face& face, uint64_t endpointId)
|
||||
{
|
||||
entry.removeNextHop(face, endpointId);
|
||||
this->eraseIfEmpty(entry);
|
||||
}
|
||||
|
||||
void
|
||||
Fib::removeNextHopByFace(Entry& entry, const Face& face)
|
||||
{
|
||||
entry.removeNextHopByFace(face);
|
||||
this->eraseIfEmpty(entry);
|
||||
}
|
||||
|
||||
Fib::Range
|
||||
Fib::getRange() const
|
||||
{
|
||||
|
||||
+13
-3
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -105,10 +105,15 @@ public: // mutation
|
||||
void
|
||||
erase(const Entry& entry);
|
||||
|
||||
/** \brief removes the NextHop record for face
|
||||
/** \brief removes the NextHop record for \p face with a given \p endpointId
|
||||
*/
|
||||
void
|
||||
removeNextHop(Entry& entry, const Face& face);
|
||||
removeNextHop(Entry& entry, const Face& face, uint64_t endpointId);
|
||||
|
||||
/** \brief removes the NextHop record for \p face for any \p endpointId
|
||||
*/
|
||||
void
|
||||
removeNextHopByFace(Entry& entry, const Face& face);
|
||||
|
||||
public: // enumeration
|
||||
typedef boost::transformed_range<name_tree::GetTableEntry<Entry>, const name_tree::Range> Range;
|
||||
@@ -144,6 +149,11 @@ private:
|
||||
void
|
||||
erase(name_tree::Entry* nte, bool canDeleteNte = true);
|
||||
|
||||
/** \brief erase \p entry if it contains no nexthop record
|
||||
*/
|
||||
void
|
||||
eraseIfEmpty(Entry& entry);
|
||||
|
||||
Range
|
||||
getRange() const;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -78,9 +78,9 @@ BOOST_FIXTURE_TEST_SUITE(TestBestRouteStrategy2, BestRouteStrategy2Fixture)
|
||||
BOOST_AUTO_TEST_CASE(Forward)
|
||||
{
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face1, 10);
|
||||
fibEntry.addNextHop(*face2, 20);
|
||||
fibEntry.addNextHop(*face3, 30);
|
||||
fibEntry.addOrUpdateNextHop(*face1, 0, 10);
|
||||
fibEntry.addOrUpdateNextHop(*face2, 0, 20);
|
||||
fibEntry.addOrUpdateNextHop(*face3, 0, 30);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("ndn:/BzgFBchqA");
|
||||
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
|
||||
@@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(Forward)
|
||||
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[4].outFaceId, face1->getId());
|
||||
BOOST_CHECK_EQUAL(strategy.sendInterestHistory[5].outFaceId, face3->getId());
|
||||
|
||||
fibEntry.removeNextHop(*face1);
|
||||
fibEntry.removeNextHop(*face1, 0);
|
||||
|
||||
strategy.sendInterestHistory.clear();
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(SimpleExchange)
|
||||
forwarder.addFace(face2);
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib.insert("/A").first->addNextHop(*face2, 0);
|
||||
fib.insert("/A").first->addOrUpdateNextHop(*face2, 0, 0);
|
||||
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().nInInterests, 0);
|
||||
BOOST_CHECK_EQUAL(forwarder.getCounters().nOutInterests, 0);
|
||||
@@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(CsMatched)
|
||||
dataA->setTag(make_shared<lp::IncomingFaceIdTag>(face3->getId()));
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib.insert("/A").first->addNextHop(*face2, 0);
|
||||
fib.insert("/A").first->addOrUpdateNextHop(*face2, 0, 0);
|
||||
|
||||
Pit& pit = forwarder.getPit();
|
||||
BOOST_CHECK_EQUAL(pit.size(), 0);
|
||||
@@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(NextHopFaceId)
|
||||
forwarder.addFace(face3);
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib.insert("/A").first->addNextHop(*face3, 0);
|
||||
fib.insert("/A").first->addOrUpdateNextHop(*face3, 0, 0);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/A/B");
|
||||
interest->setTag(make_shared<lp::NextHopFaceIdTag>(face2->getId()));
|
||||
@@ -498,7 +498,7 @@ BOOST_AUTO_TEST_CASE(InterestLoopNack)
|
||||
forwarder.addFace(face4);
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib.insert("/zT4XwK0Hnx").first->addNextHop(*face4, 0);
|
||||
fib.insert("/zT4XwK0Hnx").first->addOrUpdateNextHop(*face4, 0, 0);
|
||||
|
||||
// receive Interest on face1
|
||||
face1->sentNacks.clear();
|
||||
@@ -550,7 +550,7 @@ BOOST_FIXTURE_TEST_CASE(InterestLoopWithShortLifetime, UnitTestTimeFixture) // B
|
||||
});
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib.insert("/A").first->addNextHop(*face2, 0);
|
||||
fib.insert("/A").first->addOrUpdateNextHop(*face2, 0, 0);
|
||||
|
||||
// receive an Interest
|
||||
shared_ptr<Interest> interest = makeInterest("ndn:/A/1");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -70,9 +70,9 @@ BOOST_FIXTURE_TEST_SUITE(TestMulticastStrategy, MulticastStrategyFixture)
|
||||
BOOST_AUTO_TEST_CASE(Forward2)
|
||||
{
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face1, 0);
|
||||
fibEntry.addNextHop(*face2, 0);
|
||||
fibEntry.addNextHop(*face3, 0);
|
||||
fibEntry.addOrUpdateNextHop(*face1, 0, 0);
|
||||
fibEntry.addOrUpdateNextHop(*face2, 0, 0);
|
||||
fibEntry.addOrUpdateNextHop(*face3, 0, 0);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("ndn:/H0D6i5fc");
|
||||
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
|
||||
@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(Forward2)
|
||||
BOOST_AUTO_TEST_CASE(RejectLoopback)
|
||||
{
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face1, 0);
|
||||
fibEntry.addOrUpdateNextHop(*face1, 0, 0);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("ndn:/H0D6i5fc");
|
||||
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -63,8 +63,8 @@ BOOST_AUTO_TEST_CASE(FavorRespondingUpstream)
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face1, 10);
|
||||
fibEntry.addNextHop(*face2, 20);
|
||||
fibEntry.addOrUpdateNextHop(*face1, 0, 10);
|
||||
fibEntry.addOrUpdateNextHop(*face2, 0, 20);
|
||||
|
||||
Pit& pit = forwarder.getPit();
|
||||
|
||||
@@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(Bug1853)
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face1, 10);
|
||||
fibEntry.addOrUpdateNextHop(*face1, 0, 10);
|
||||
|
||||
Pit& pit = forwarder.getPit();
|
||||
|
||||
@@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE(Bug1853)
|
||||
strategy.afterReceiveInterest(*face3, *interest2, pitEntry2);
|
||||
|
||||
// FIB entry is changed before doPropagate executes
|
||||
fibEntry.addNextHop(*face2, 20);
|
||||
fibEntry.addOrUpdateNextHop(*face2, 0, 20);
|
||||
this->advanceClocks(time::milliseconds(10), time::milliseconds(1000));// should not crash
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ BOOST_AUTO_TEST_CASE(Bug1961)
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face1, 10);
|
||||
fibEntry.addNextHop(*face2, 20);
|
||||
fibEntry.addOrUpdateNextHop(*face1, 0, 10);
|
||||
fibEntry.addOrUpdateNextHop(*face2, 0, 20);
|
||||
|
||||
Pit& pit = forwarder.getPit();
|
||||
|
||||
@@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(Bug1971)
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face2, 10);
|
||||
fibEntry.addOrUpdateNextHop(*face2, 0, 10);
|
||||
|
||||
Pit& pit = forwarder.getPit();
|
||||
|
||||
@@ -273,8 +273,8 @@ BOOST_AUTO_TEST_CASE(Bug1998)
|
||||
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face1, 10); // face1 is top-ranked nexthop
|
||||
fibEntry.addNextHop(*face2, 20);
|
||||
fibEntry.addOrUpdateNextHop(*face1, 0, 10); // face1 is top-ranked nexthop
|
||||
fibEntry.addOrUpdateNextHop(*face2, 0, 20);
|
||||
|
||||
Pit& pit = forwarder.getPit();
|
||||
|
||||
@@ -376,7 +376,7 @@ BOOST_AUTO_TEST_CASE(PredictionAdjustment) // Bug 3411
|
||||
// NccStrategy has selected one path as the best.
|
||||
// When we reduce the RTT of the other path, ideally it should be selected as the best face.
|
||||
// However, this won't happen due to a weakness in NccStrategy.
|
||||
// See http://redmine.named-data.net/issues/3411#note-4
|
||||
// See https://redmine.named-data.net/issues/3411#note-4
|
||||
shared_ptr<Face> bestFace1 = getMeInfo()->bestFace.lock();
|
||||
if (bestFace1.get() == &linkAB->getFace(nodeA)) {
|
||||
linkCD->setDelay(time::milliseconds(5));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -96,9 +96,9 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(OneUpstream,
|
||||
S, Strategies, StrategyNackReturnFixture<S>)
|
||||
{
|
||||
fib::Entry& fibEntry = *this->fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*this->face3, 10);
|
||||
fibEntry.addNextHop(*this->face4, 20);
|
||||
fibEntry.addNextHop(*this->face5, 30);
|
||||
fibEntry.addOrUpdateNextHop(*this->face3, 0, 10);
|
||||
fibEntry.addOrUpdateNextHop(*this->face4, 0, 20);
|
||||
fibEntry.addOrUpdateNextHop(*this->face5, 0, 30);
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("/McQYjMbm", 992);
|
||||
shared_ptr<Interest> interest2 = makeInterest("/McQYjMbm", 114);
|
||||
@@ -131,9 +131,9 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(TwoUpstreams,
|
||||
S, Strategies, StrategyNackReturnFixture<S>)
|
||||
{
|
||||
fib::Entry& fibEntry = *this->fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*this->face3, 10);
|
||||
fibEntry.addNextHop(*this->face4, 20);
|
||||
fibEntry.addNextHop(*this->face5, 30);
|
||||
fibEntry.addOrUpdateNextHop(*this->face3, 0, 10);
|
||||
fibEntry.addOrUpdateNextHop(*this->face4, 0, 20);
|
||||
fibEntry.addOrUpdateNextHop(*this->face5, 0, 30);
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("/aS9FAyUV19", 286);
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest1).first;
|
||||
@@ -164,9 +164,9 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(Timeout,
|
||||
S, Strategies, StrategyNackReturnFixture<S>)
|
||||
{
|
||||
fib::Entry& fibEntry = *this->fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*this->face3, 10);
|
||||
fibEntry.addNextHop(*this->face4, 20);
|
||||
fibEntry.addNextHop(*this->face5, 30);
|
||||
fibEntry.addOrUpdateNextHop(*this->face3, 0, 10);
|
||||
fibEntry.addOrUpdateNextHop(*this->face4, 0, 20);
|
||||
fibEntry.addOrUpdateNextHop(*this->face5, 0, 30);
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("/sIYw0TXWDj", 115);
|
||||
interest1->setInterestLifetime(time::milliseconds(400));
|
||||
@@ -317,9 +317,9 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(CombineReasons, Combination, NackReasonCombinat
|
||||
StrategyNackReturnFixture<BestRouteStrategy2>)
|
||||
{
|
||||
fib::Entry& fibEntry = *fib.insert(Name()).first;
|
||||
fibEntry.addNextHop(*face3, 10);
|
||||
fibEntry.addNextHop(*face4, 20);
|
||||
fibEntry.addNextHop(*face5, 30);
|
||||
fibEntry.addOrUpdateNextHop(*face3, 0, 10);
|
||||
fibEntry.addOrUpdateNextHop(*face4, 0, 20);
|
||||
fibEntry.addOrUpdateNextHop(*face5, 0, 30);
|
||||
|
||||
shared_ptr<Interest> interest1 = makeInterest("/F6sEwB24I", 282);
|
||||
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
void
|
||||
insertFibEntry(StrategyNoRouteFixture<S>* fixture)
|
||||
{
|
||||
fixture->fib.insert(Name()).first->addNextHop(*fixture->face1, 10);
|
||||
fixture->fib.insert(Name()).first->addOrUpdateNextHop(*fixture->face1, 0, 10);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
void
|
||||
insertFibEntry(StrategyNoRouteFixture<S>* fixture)
|
||||
{
|
||||
fixture->fib.insert("/localhop").first->addNextHop(*fixture->face2, 10);
|
||||
fixture->fib.insert("/localhop").first->addOrUpdateNextHop(*fixture->face2, 0, 10);
|
||||
// face1 and face2 are both non-local; Interest from face1 cannot be forwarded to face2
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2017, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -118,7 +118,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToLocal,
|
||||
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
|
||||
{
|
||||
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
|
||||
fibEntry->addNextHop(*this->localFace4, 10);
|
||||
fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 10);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/localhost/A/1");
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
|
||||
@@ -137,7 +137,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToNonLocal,
|
||||
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
|
||||
{
|
||||
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
|
||||
fibEntry->addNextHop(*this->nonLocalFace2, 10);
|
||||
fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/localhost/A/1");
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
|
||||
@@ -159,8 +159,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToLocalAndNonLocal,
|
||||
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
|
||||
{
|
||||
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
|
||||
fibEntry->addNextHop(*this->nonLocalFace2, 10);
|
||||
fibEntry->addNextHop(*this->localFace4, 20);
|
||||
fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
|
||||
fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 20);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/localhost/A/1");
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
|
||||
@@ -180,7 +180,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopInterestToNonLocal,
|
||||
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
|
||||
{
|
||||
fib::Entry* fibEntry = this->fib.insert("/localhop/A").first;
|
||||
fibEntry->addNextHop(*this->nonLocalFace2, 10);
|
||||
fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/localhop/A/1");
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
|
||||
@@ -202,8 +202,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopInterestToNonLocalAndLocal,
|
||||
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
|
||||
{
|
||||
fib::Entry* fibEntry = this->fib.insert("/localhop/A").first;
|
||||
fibEntry->addNextHop(*this->nonLocalFace2, 10);
|
||||
fibEntry->addNextHop(*this->localFace4, 20);
|
||||
fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 10);
|
||||
fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 20);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/localhop/A/1");
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
|
||||
@@ -223,8 +223,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostNackToNonLocal,
|
||||
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
|
||||
{
|
||||
fib::Entry* fibEntry = this->fib.insert("/localhost/A").first;
|
||||
fibEntry->addNextHop(*this->localFace4, 10);
|
||||
fibEntry->addNextHop(*this->nonLocalFace2, 20);
|
||||
fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 10);
|
||||
fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 20);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/localhost/A/1", 1460);
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
|
||||
@@ -248,8 +248,8 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopNackToNonLocal,
|
||||
T, Tests, StrategyScopeControlFixture<typename T::Strategy>)
|
||||
{
|
||||
fib::Entry* fibEntry = this->fib.insert("/localhop/A").first;
|
||||
fibEntry->addNextHop(*this->localFace4, 10);
|
||||
fibEntry->addNextHop(*this->nonLocalFace2, 20);
|
||||
fibEntry->addOrUpdateNextHop(*this->localFace4, 0, 10);
|
||||
fibEntry->addOrUpdateNextHop(*this->nonLocalFace2, 0, 20);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest("/localhop/A/1", 1377);
|
||||
shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -241,7 +241,7 @@ TopologyTester::registerPrefix(TopologyNode i, const Face& face, const Name& pre
|
||||
{
|
||||
Forwarder& forwarder = this->getForwarder(i);
|
||||
Fib& fib = forwarder.getFib();
|
||||
fib.insert(prefix).first->addNextHop(const_cast<Face&>(face), cost);
|
||||
fib.insert(prefix).first->addOrUpdateNextHop(const_cast<Face&>(face), 0, cost);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2018, Regents of the University of California,
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -301,9 +301,9 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
BOOST_REQUIRE_NE(face3, face::INVALID_FACEID);
|
||||
|
||||
fib::Entry* entry = m_fib.insert("/hello").first;
|
||||
entry->addNextHop(*m_faceTable.get(face1), 101);
|
||||
entry->addNextHop(*m_faceTable.get(face2), 202);
|
||||
entry->addNextHop(*m_faceTable.get(face3), 303);
|
||||
entry->addOrUpdateNextHop(*m_faceTable.get(face1), 0, 101);
|
||||
entry->addOrUpdateNextHop(*m_faceTable.get(face2), 0, 202);
|
||||
entry->addOrUpdateNextHop(*m_faceTable.get(face3), 0, 303);
|
||||
|
||||
testRemoveNextHop(makeParameters("/hello", face1));
|
||||
BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
|
||||
@@ -354,8 +354,8 @@ BOOST_AUTO_TEST_CASE(ImplicitFaceId)
|
||||
};
|
||||
|
||||
fib::Entry* entry = m_fib.insert("/hello").first;
|
||||
entry->addNextHop(*m_faceTable.get(face1), 101);
|
||||
entry->addNextHop(*m_faceTable.get(face2), 202);
|
||||
entry->addOrUpdateNextHop(*m_faceTable.get(face1), 0, 101);
|
||||
entry->addOrUpdateNextHop(*m_faceTable.get(face2), 0, 202);
|
||||
|
||||
testWithImplicitFaceId(ControlParameters().setName("/hello").setFaceId(0), face1);
|
||||
BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
|
||||
@@ -385,7 +385,7 @@ BOOST_AUTO_TEST_CASE(RecordNotExist)
|
||||
receiveInterest(req);
|
||||
};
|
||||
|
||||
m_fib.insert("/hello").first->addNextHop(*m_faceTable.get(face1), 101);
|
||||
m_fib.insert("/hello").first->addOrUpdateNextHop(*m_faceTable.get(face1), 0, 101);
|
||||
|
||||
testRemoveNextHop(makeParameters("/hello", face2 + 100));
|
||||
BOOST_REQUIRE_EQUAL(m_responses.size(), 1); // face does not exist
|
||||
@@ -410,8 +410,8 @@ BOOST_AUTO_TEST_CASE(FibDataset)
|
||||
Name prefix = Name("test").appendSegment(i);
|
||||
actualPrefixes.insert(prefix);
|
||||
fib::Entry* fibEntry = m_fib.insert(prefix).first;
|
||||
fibEntry->addNextHop(*m_faceTable.get(addFace()), std::numeric_limits<uint8_t>::max() - 1);
|
||||
fibEntry->addNextHop(*m_faceTable.get(addFace()), std::numeric_limits<uint8_t>::max() - 2);
|
||||
fibEntry->addOrUpdateNextHop(*m_faceTable.get(addFace()), 0, std::numeric_limits<uint8_t>::max() - 1);
|
||||
fibEntry->addOrUpdateNextHop(*m_faceTable.get(addFace()), 0, std::numeric_limits<uint8_t>::max() - 2);
|
||||
}
|
||||
|
||||
receiveInterest(Interest("/localhost/nfd/fib/list").setCanBePrefix(true));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
Name name = Name("/P").appendVersion(i);
|
||||
|
||||
fib::Entry* fibEntry = fib.insert(name).first;
|
||||
fibEntry->addNextHop(*face1, 0);
|
||||
fibEntry->addOrUpdateNextHop(*face1, 0, 0);
|
||||
|
||||
shared_ptr<Interest> interest = makeInterest(name);
|
||||
shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
|
||||
@@ -89,24 +89,24 @@ BOOST_AUTO_TEST_CASE(RemoveFibNexthops)
|
||||
BOOST_CHECK_EQUAL(fib.size(), 0);
|
||||
|
||||
fib::Entry* entryA = fib.insert("/A").first;
|
||||
entryA->addNextHop(*face1, 0);
|
||||
entryA->addNextHop(*face2, 0);
|
||||
entryA->addOrUpdateNextHop(*face1, 0, 0);
|
||||
entryA->addOrUpdateNextHop(*face2, 0, 0);
|
||||
// {'/A':[1,2]}
|
||||
|
||||
fib::Entry* entryB = fib.insert("/B").first;
|
||||
entryB->addNextHop(*face1, 0);
|
||||
entryB->addOrUpdateNextHop(*face1, 0, 0);
|
||||
// {'/A':[1,2], '/B':[1]}
|
||||
|
||||
fib::Entry* entryC = fib.insert("/C").first;
|
||||
entryC->addNextHop(*face2, 1);
|
||||
entryC->addOrUpdateNextHop(*face2, 0, 1);
|
||||
// {'/A':[1,2], '/B':[1], '/C':[2]}
|
||||
|
||||
fib::Entry* entryB1 = fib.insert("/B/1").first;
|
||||
entryB1->addNextHop(*face1, 0);
|
||||
entryB1->addOrUpdateNextHop(*face1, 0, 0);
|
||||
// {'/A':[1,2], '/B':[1], '/B/1':[1], '/C':[2]}
|
||||
|
||||
fib::Entry* entryB12 = fib.insert("/B/1/2").first;
|
||||
entryB12->addNextHop(*face1, 0);
|
||||
entryB12->addOrUpdateNextHop(*face1, 0, 0);
|
||||
// {'/A':[1,2], '/B':[1], '/B/1':[1], '/B/1/2':[1], '/C':[2]}
|
||||
|
||||
// ---- close face1 ----
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/**
|
||||
* Copyright (c) 2014-2016, Regents of the University of California,
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -51,71 +51,138 @@ BOOST_AUTO_TEST_CASE(FibEntry)
|
||||
// []
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 0);
|
||||
|
||||
entry.addNextHop(*face1, 20);
|
||||
// [(face1,20)]
|
||||
// [(face, cost, endpointId)]
|
||||
entry.addOrUpdateNextHop(*face1, 200, 20);
|
||||
// [(face1,200,20)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
|
||||
BOOST_CHECK_EQUAL(&entry.getNextHops().begin()->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 200);
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 20);
|
||||
|
||||
entry.addNextHop(*face1, 30);
|
||||
// [(face1,30)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
|
||||
BOOST_CHECK_EQUAL(&entry.getNextHops().begin()->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 30);
|
||||
|
||||
entry.addNextHop(*face2, 40);
|
||||
// [(face1,30), (face2,40)]
|
||||
entry.addOrUpdateNextHop(*face1, 300, 30);
|
||||
// [(face1,200,20), (face1,300,30)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
|
||||
BOOST_CHECK_EQUAL(&entry.getNextHops().begin()->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 200);
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 20);
|
||||
|
||||
entry.addOrUpdateNextHop(*face2, 400, 40);
|
||||
// [(face1,200,20), (face1,300,30), (face2,400,40)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 3);
|
||||
{
|
||||
NextHopList::const_iterator it = entry.getNextHops().begin();
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 200);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 20);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 300);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 30);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 400);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 40);
|
||||
|
||||
++it;
|
||||
BOOST_CHECK(it == entry.getNextHops().end());
|
||||
}
|
||||
|
||||
entry.addNextHop(*face2, 10);
|
||||
// [(face2,10), (face1,30)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
|
||||
entry.addOrUpdateNextHop(*face2, 100, 10);
|
||||
// [(face2,100,10), (face1,200,20), (face1,300,30), (face2,400,40)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 4);
|
||||
{
|
||||
NextHopList::const_iterator it = entry.getNextHops().begin();
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 100);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 10);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 200);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 20);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 300);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 30);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 400);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 40);
|
||||
|
||||
++it;
|
||||
BOOST_CHECK(it == entry.getNextHops().end());
|
||||
}
|
||||
|
||||
entry.removeNextHop(*face1);
|
||||
// [(face2,10)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
|
||||
entry.addOrUpdateNextHop(*face1, 200, 50);
|
||||
// [(face2,100,10), (face1,300,30), (face2,400,40), (face1,200,50)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 4);
|
||||
{
|
||||
NextHopList::const_iterator it = entry.getNextHops().begin();
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 100);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 10);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 300);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 30);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face2.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 400);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 40);
|
||||
|
||||
++it;
|
||||
BOOST_REQUIRE(it != entry.getNextHops().end());
|
||||
BOOST_CHECK_EQUAL(&it->getFace(), face1.get());
|
||||
BOOST_CHECK_EQUAL(it->getEndpointId(), 200);
|
||||
BOOST_CHECK_EQUAL(it->getCost(), 50);
|
||||
|
||||
++it;
|
||||
BOOST_CHECK(it == entry.getNextHops().end());
|
||||
}
|
||||
|
||||
entry.removeNextHop(*face1, 200);
|
||||
// [(face2,100,10), (face1,300,30), (face2,400,40)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 3);
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getFace().getId(), face2->getId());
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 100);
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 10);
|
||||
|
||||
entry.removeNextHop(*face1);
|
||||
// [(face2,10)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
|
||||
entry.removeNextHop(*face1, 200);
|
||||
// [(face2,100,10), (face1,300,30), (face2,400,40)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 3);
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getFace().getId(), face2->getId());
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getEndpointId(), 100);
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().begin()->getCost(), 10);
|
||||
|
||||
entry.removeNextHop(*face2);
|
||||
entry.removeNextHop(*face2,100);
|
||||
// [(face1,300,30), (face2,400,40)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 2);
|
||||
|
||||
entry.removeNextHop(*face2,400);
|
||||
// [(face1,300,30)]
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 1);
|
||||
|
||||
entry.removeNextHop(*face1,300);
|
||||
// []
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 0);
|
||||
|
||||
entry.removeNextHop(*face2);
|
||||
entry.removeNextHop(*face1,300);
|
||||
// []
|
||||
BOOST_CHECK_EQUAL(entry.getNextHops().size(), 0);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user