fw+table: use Interest::Nonce instead of uint32_t
Change-Id: I2a4b83696db80d2d0b675121da53a73c309e059c
This commit is contained in:
1 parent
854866f424
commit
51cf75c8f0
9 files changed
+53
-76
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -75,7 +75,7 @@ canForwardToLegacy(const pit::Entry& pitEntry, const Face& face)
|
||||
}
|
||||
|
||||
int
|
||||
findDuplicateNonce(const pit::Entry& pitEntry, uint32_t nonce, const Face& face)
|
||||
findDuplicateNonce(const pit::Entry& pitEntry, Interest::Nonce nonce, const Face& face)
|
||||
{
|
||||
int dnw = DUPLICATE_NONCE_NONE;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -70,7 +70,7 @@ enum DuplicateNonceWhere {
|
||||
* \return OR'ed DuplicateNonceWhere
|
||||
*/
|
||||
int
|
||||
findDuplicateNonce(const pit::Entry& pitEntry, uint32_t nonce, const Face& face);
|
||||
findDuplicateNonce(const pit::Entry& pitEntry, Interest::Nonce nonce, const Face& face);
|
||||
|
||||
/** \brief determine whether \p pitEntry has any pending out-records
|
||||
* \return true if there is at least one out-record waiting for Data
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -87,14 +87,14 @@ DeadNonceList::size() const
|
||||
}
|
||||
|
||||
bool
|
||||
DeadNonceList::has(const Name& name, uint32_t nonce) const
|
||||
DeadNonceList::has(const Name& name, Interest::Nonce nonce) const
|
||||
{
|
||||
Entry entry = DeadNonceList::makeEntry(name, nonce);
|
||||
return m_ht.find(entry) != m_ht.end();
|
||||
}
|
||||
|
||||
void
|
||||
DeadNonceList::add(const Name& name, uint32_t nonce)
|
||||
DeadNonceList::add(const Name& name, Interest::Nonce nonce)
|
||||
{
|
||||
Entry entry = DeadNonceList::makeEntry(name, nonce);
|
||||
m_queue.push_back(entry);
|
||||
@@ -103,11 +103,12 @@ DeadNonceList::add(const Name& name, uint32_t nonce)
|
||||
}
|
||||
|
||||
DeadNonceList::Entry
|
||||
DeadNonceList::makeEntry(const Name& name, uint32_t nonce)
|
||||
DeadNonceList::makeEntry(const Name& name, Interest::Nonce nonce)
|
||||
{
|
||||
Block nameWire = name.wireEncode();
|
||||
return CityHash64WithSeed(reinterpret_cast<const char*>(nameWire.wire()), nameWire.size(),
|
||||
static_cast<uint64_t>(nonce));
|
||||
uint32_t n;
|
||||
std::memcpy(&n, nonce.data(), sizeof(n));
|
||||
return CityHash64WithSeed(reinterpret_cast<const char*>(nameWire.wire()), nameWire.size(), n);
|
||||
}
|
||||
|
||||
size_t
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -67,15 +67,15 @@ public:
|
||||
~DeadNonceList();
|
||||
|
||||
/** \brief Determines if name+nonce exists
|
||||
* \return true if name+nonce exists
|
||||
* \return true if name+nonce exists, false otherwise
|
||||
*/
|
||||
bool
|
||||
has(const Name& name, uint32_t nonce) const;
|
||||
has(const Name& name, Interest::Nonce nonce) const;
|
||||
|
||||
/** \brief Records name+nonce
|
||||
*/
|
||||
void
|
||||
add(const Name& name, uint32_t nonce);
|
||||
add(const Name& name, Interest::Nonce nonce);
|
||||
|
||||
/** \return number of stored Nonces
|
||||
* \note The return value does not contain non-Nonce entries in the index, if any.
|
||||
@@ -95,7 +95,7 @@ private: // Entry and Index
|
||||
typedef uint64_t Entry;
|
||||
|
||||
static Entry
|
||||
makeEntry(const Name& name, uint32_t nonce);
|
||||
makeEntry(const Name& name, Interest::Nonce nonce);
|
||||
|
||||
typedef boost::multi_index_container<
|
||||
Entry,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
return m_face;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Interest::Nonce
|
||||
getLastNonce() const
|
||||
{
|
||||
return m_lastNonce;
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
|
||||
private:
|
||||
Face& m_face;
|
||||
uint32_t m_lastNonce = 0;
|
||||
Interest::Nonce m_lastNonce{0, 0, 0, 0};
|
||||
time::steady_clock::TimePoint m_lastRenewed = time::steady_clock::TimePoint::min();
|
||||
time::steady_clock::TimePoint m_expiry = time::steady_clock::TimePoint::min();
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -340,16 +340,14 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce)
|
||||
topo.registerPrefix(nodeC, linkBC->getFace(nodeC), PRODUCER_PREFIX, 16);
|
||||
topo.registerPrefix(nodeB, linkBD->getFace(nodeB), PRODUCER_PREFIX, 80);
|
||||
|
||||
uint32_t nonce;
|
||||
|
||||
// Send 6 interest since probes can be scheduled b/w 0-5 seconds
|
||||
for (int i = 1; i < 7; i++) {
|
||||
// Send ping number i
|
||||
Name name(PRODUCER_PREFIX);
|
||||
name.appendTimestamp();
|
||||
shared_ptr<Interest> interest = makeInterest(name);
|
||||
auto interest = makeInterest(name);
|
||||
ping->getClientFace().expressInterest(*interest, nullptr, nullptr, nullptr);
|
||||
nonce = interest->getNonce();
|
||||
auto nonce = interest->getNonce();
|
||||
|
||||
// Don't know when the probe will be triggered since it is random between 0-5 seconds
|
||||
// or whether it will be triggered for this interest
|
||||
@@ -360,13 +358,12 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce)
|
||||
// Check if probe is sent to B else send another ping
|
||||
if (linkAB->getFace(nodeA).getCounters().nOutInterests == 1) {
|
||||
// Get pitEntry of node A
|
||||
shared_ptr<pit::Entry> pitEntry = topo.getForwarder(nodeA).getPit().find(*interest);
|
||||
//get outRecord associated with face towards B
|
||||
pit::OutRecordCollection::const_iterator outRecord = pitEntry->getOutRecord(linkAB->getFace(nodeA));
|
||||
auto pitEntry = topo.getForwarder(nodeA).getPit().find(*interest);
|
||||
// Get outRecord associated with face towards B
|
||||
auto outRecord = pitEntry->getOutRecord(linkAB->getFace(nodeA));
|
||||
BOOST_REQUIRE(outRecord != pitEntry->out_end());
|
||||
|
||||
BOOST_CHECK(outRecord != pitEntry->out_end());
|
||||
|
||||
//Check that Nonce of interest is not equal to Nonce of Probe
|
||||
// Check that Nonce of interest is not equal to Nonce of Probe
|
||||
BOOST_CHECK_NE(nonce, outRecord->getLastNonce());
|
||||
|
||||
// B should not have received the probe interest yet
|
||||
@@ -384,7 +381,6 @@ BOOST_AUTO_TEST_CASE(NoPitOutRecordAndProbeInterestNewNonce)
|
||||
|
||||
// Get outRecord associated with face towards D.
|
||||
outRecord = pitEntry->getOutRecord(linkBD->getFace(nodeB));
|
||||
|
||||
BOOST_CHECK(outRecord != pitEntry->out_end());
|
||||
|
||||
// RTT between B and D
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -39,8 +39,8 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
{
|
||||
Name nameA("ndn:/A");
|
||||
Name nameB("ndn:/B");
|
||||
const uint32_t nonce1 = 0x53b4eaa8;
|
||||
const uint32_t nonce2 = 0x1f46372b;
|
||||
const Interest::Nonce nonce1(0x53b4eaa8);
|
||||
const Interest::Nonce nonce2(0x1f46372b);
|
||||
|
||||
DeadNonceList dnl;
|
||||
BOOST_CHECK_EQUAL(dnl.size(), 0);
|
||||
@@ -64,13 +64,8 @@ class PeriodicalInsertionFixture : public GlobalIoTimeFixture
|
||||
protected:
|
||||
PeriodicalInsertionFixture()
|
||||
: dnl(LIFETIME)
|
||||
, name("ndn:/N")
|
||||
, lastNonce(0)
|
||||
, addNonceBatch(0)
|
||||
, addNonceInterval(LIFETIME / DeadNonceList::EXPECTED_MARK_COUNT)
|
||||
, timeUnit(addNonceInterval / 2)
|
||||
{
|
||||
this->addNonce();
|
||||
addNonce();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -86,7 +81,7 @@ protected:
|
||||
dnl.add(name, ++lastNonce);
|
||||
}
|
||||
|
||||
if (addNonceInterval > time::nanoseconds::zero()) {
|
||||
if (addNonceInterval > 0_ns) {
|
||||
addNonceEvent = getScheduler().schedule(addNonceInterval, [this] { addNonce(); });
|
||||
}
|
||||
}
|
||||
@@ -96,17 +91,17 @@ protected:
|
||||
void
|
||||
advanceClocksByLifetime(float t)
|
||||
{
|
||||
this->advanceClocks(timeUnit, time::duration_cast<time::nanoseconds>(LIFETIME * t));
|
||||
advanceClocks(timeUnit, time::duration_cast<time::nanoseconds>(LIFETIME * t));
|
||||
}
|
||||
|
||||
protected:
|
||||
static const time::nanoseconds LIFETIME;
|
||||
DeadNonceList dnl;
|
||||
Name name;
|
||||
uint32_t lastNonce;
|
||||
size_t addNonceBatch;
|
||||
time::nanoseconds addNonceInterval;
|
||||
time::nanoseconds timeUnit;
|
||||
Name name = "/N";
|
||||
uint32_t lastNonce = 0;
|
||||
size_t addNonceBatch = 0;
|
||||
const time::nanoseconds addNonceInterval = LIFETIME / DeadNonceList::EXPECTED_MARK_COUNT;
|
||||
const time::nanoseconds timeUnit = addNonceInterval / 2;
|
||||
scheduler::ScopedEventId addNonceEvent;
|
||||
};
|
||||
|
||||
@@ -121,7 +116,7 @@ BOOST_FIXTURE_TEST_CASE(Lifetime, PeriodicalInsertionFixture)
|
||||
this->advanceClocksByLifetime(10.0);
|
||||
|
||||
Name nameC("ndn:/C");
|
||||
const uint32_t nonceC = 0x25390656;
|
||||
const Interest::Nonce nonceC(0x25390656);
|
||||
BOOST_CHECK_EQUAL(dnl.has(nameC, nonceC), false);
|
||||
dnl.add(nameC, nonceC);
|
||||
BOOST_CHECK_EQUAL(dnl.has(nameC, nonceC), true);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -32,16 +32,14 @@ namespace tests {
|
||||
|
||||
shared_ptr<Interest>
|
||||
makeInterest(const Name& name, bool canBePrefix, optional<time::milliseconds> lifetime,
|
||||
optional<uint32_t> nonce)
|
||||
optional<Interest::Nonce> nonce)
|
||||
{
|
||||
auto interest = make_shared<Interest>(name);
|
||||
interest->setCanBePrefix(canBePrefix);
|
||||
if (lifetime) {
|
||||
interest->setInterestLifetime(*lifetime);
|
||||
}
|
||||
if (nonce) {
|
||||
interest->setNonce(*nonce);
|
||||
}
|
||||
interest->setNonce(nonce);
|
||||
return interest;
|
||||
}
|
||||
|
||||
@@ -59,7 +57,6 @@ signData(Data& data)
|
||||
fakeSignature.setValue(ndn::encoding::makeEmptyBlock(tlv::SignatureValue));
|
||||
data.setSignature(fakeSignature);
|
||||
data.wireEncode();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
+11
-23
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2019, Regents of the University of California,
|
||||
* Copyright (c) 2014-2020, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -52,7 +52,7 @@ namespace tests {
|
||||
shared_ptr<Interest>
|
||||
makeInterest(const Name& name, bool canBePrefix = false,
|
||||
optional<time::milliseconds> lifetime = nullopt,
|
||||
optional<uint32_t> nonce = nullopt);
|
||||
optional<Interest::Nonce> nonce = nullopt);
|
||||
|
||||
/** \brief create a Data with fake signature
|
||||
* \note Data may be modified afterwards without losing the fake signature.
|
||||
@@ -76,34 +76,22 @@ signData(shared_ptr<Data> data)
|
||||
}
|
||||
|
||||
/** \brief create a Nack
|
||||
* \param interest Interest
|
||||
* \param reason Nack reason
|
||||
*/
|
||||
lp::Nack
|
||||
makeNack(Interest interest, lp::NackReason reason);
|
||||
|
||||
/** \brief replace a name component
|
||||
* \param[inout] name name
|
||||
* \param index name component index
|
||||
* \param a arguments to name::Component constructor
|
||||
/** \brief replace a name component in a packet
|
||||
* \param[inout] pkt the packet
|
||||
* \param index the index of the name component to replace
|
||||
* \param args arguments to name::Component constructor
|
||||
*/
|
||||
template<typename... A>
|
||||
template<typename Packet, typename ...Args>
|
||||
void
|
||||
setNameComponent(Name& name, ssize_t index, A&&... a)
|
||||
setNameComponent(Packet& pkt, ssize_t index, Args&& ...args)
|
||||
{
|
||||
Name name2 = name.getPrefix(index);
|
||||
name2.append(name::Component(std::forward<A>(a)...));
|
||||
name2.append(name.getSubName(name2.size()));
|
||||
name = std::move(name2);
|
||||
}
|
||||
|
||||
template<typename Packet, typename... A>
|
||||
void
|
||||
setNameComponent(Packet& packet, ssize_t index, A&&... a)
|
||||
{
|
||||
Name name = packet.getName();
|
||||
setNameComponent(name, index, std::forward<A>(a)...);
|
||||
packet.setName(name);
|
||||
Name name = pkt.getName();
|
||||
name.set(index, name::Component(std::forward<Args>(args)...));
|
||||
pkt.setName(name);
|
||||
}
|
||||
|
||||
/** \brief create a prefix announcement without signing
|
||||
|
||||
Reference in new issue
Block a user