catchunks: pass versioned name to onDiscoverySuccess signal
refs: #4556
Change-Id: I599bafcf70647bd806236f87f24d7a22f73a3505
diff --git a/tests/chunks/consumer.t.cpp b/tests/chunks/consumer.t.cpp
index ebedd61..f6d3e8a 100644
--- a/tests/chunks/consumer.t.cpp
+++ b/tests/chunks/consumer.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2018, Regents of the University of California,
+ * Copyright (c) 2016-2019, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -157,7 +157,10 @@
void
handleData(const Interest& interest, const Data& data) final
{
- this->emitSignal(onDiscoverySuccess, data);
+ if (!data.getName().empty() && data.getName()[-1].isVersion())
+ this->emitSignal(onDiscoverySuccess, data.getName());
+ else
+ this->emitSignal(onDiscoveryFailure, "Invalid versioned name");
}
public:
@@ -210,7 +213,8 @@
this->advanceClocks(io, time::nanoseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
- auto data = makeData(prefix.appendSegment(0));
+ // this Data packet answers the discovery Interest, so it must end with a version number
+ auto data = makeData(prefix.appendVersion(0));
face.receive(*data);
this->advanceClocks(io, time::nanoseconds(1));
diff --git a/tests/chunks/discover-version-fixture.hpp b/tests/chunks/discover-version-fixture.hpp
index 8d49537..ed18235 100644
--- a/tests/chunks/discover-version-fixture.hpp
+++ b/tests/chunks/discover-version-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2018, Regents of the University of California,
+ * Copyright (c) 2016-2019, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -80,12 +80,12 @@
}
virtual void
- onSuccess(const Data& data)
+ onSuccess(const Name& versionedName)
{
isDiscoveryFinished = true;
- if (data.getName()[name.size()].isVersion())
- discoveredVersion = data.getName()[name.size()].toVersion();
+ BOOST_REQUIRE(!versionedName.empty() && versionedName[-1].isVersion());
+ discoveredVersion = versionedName[-1].toVersion();
}
virtual void
diff --git a/tests/chunks/pipeline-interests-aimd.t.cpp b/tests/chunks/pipeline-interests-aimd.t.cpp
index 1335d67..0e6341e 100644
--- a/tests/chunks/pipeline-interests-aimd.t.cpp
+++ b/tests/chunks/pipeline-interests-aimd.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2018, Regents of the University of California,
+ * Copyright (c) 2016-2019, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -102,11 +102,11 @@
BOOST_REQUIRE_CLOSE(aimdPipeline->m_cwnd, 1, MARGIN);
double preCwnd = aimdPipeline->m_cwnd;
- runWithData(*makeDataWithSegment(0));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
- for (uint64_t i = 1; i < nDataSegments - 1; ++i) {
+ for (uint64_t i = 0; i < nDataSegments - 1; ++i) {
face.receive(*makeDataWithSegment(i));
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd - preCwnd, 1, MARGIN);
@@ -118,22 +118,22 @@
BOOST_AUTO_TEST_CASE(CongestionAvoidance)
{
- nDataSegments = 8;
+ nDataSegments = 7;
aimdPipeline->m_ssthresh = 4.0;
BOOST_REQUIRE_CLOSE(aimdPipeline->m_cwnd, 1, MARGIN);
double preCwnd = aimdPipeline->m_cwnd;
- runWithData(*makeDataWithSegment(0));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
- for (uint64_t i = 1; i < aimdPipeline->m_ssthresh; ++i) { // slow start
+ for (uint64_t i = 0; i < aimdPipeline->m_ssthresh; ++i) { // slow start
face.receive(*makeDataWithSegment(i));
advanceClocks(io, time::nanoseconds(1));
preCwnd = aimdPipeline->m_cwnd;
}
- BOOST_CHECK_CLOSE(preCwnd, aimdPipeline->m_ssthresh, MARGIN);
+ BOOST_CHECK_CLOSE(preCwnd, 4.25, MARGIN);
for (uint64_t i = aimdPipeline->m_ssthresh; i < nDataSegments - 1; ++i) { // congestion avoidance
face.receive(*makeDataWithSegment(i));
@@ -151,19 +151,19 @@
aimdPipeline->m_ssthresh = 4.0;
BOOST_REQUIRE_CLOSE(aimdPipeline->m_cwnd, 1, MARGIN);
- runWithData(*makeDataWithSegment(0));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
- // receive segment 1 and segment 2
- for (uint64_t i = 1; i < 3; ++i) {
+ // receive segment 0, 1, and 2
+ for (uint64_t i = 0; i < 3; ++i) {
face.receive(*makeDataWithSegment(i));
advanceClocks(io, time::nanoseconds(1));
}
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 3);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 3, MARGIN);
- BOOST_CHECK_EQUAL(face.sentInterests.size(), 5); // request for segment 5 has been sent
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4, MARGIN);
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), 7); // request for segment 7 has been sent
advanceClocks(io, time::milliseconds(100));
@@ -176,14 +176,14 @@
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.25, MARGIN);
- BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments - 1); // all the segment requests have been sent
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.5, MARGIN);
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all the segment requests have been sent
// timeout segment 3
advanceClocks(io, time::milliseconds(150));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.125, MARGIN); // window size drop to 1/2 of previous size
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.25, MARGIN); // window size drop to 1/2 of previous size
BOOST_CHECK_EQUAL(aimdPipeline->m_retxQueue.size(), 1);
// receive segment 6, retransmit 3
@@ -191,7 +191,7 @@
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.625, MARGIN); // congestion avoidance
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.75, MARGIN); // congestion avoidance
BOOST_CHECK_EQUAL(aimdPipeline->m_retxQueue.size(), 0);
BOOST_CHECK_EQUAL(aimdPipeline->m_retxCount[3], 1);
}
@@ -202,33 +202,33 @@
aimdPipeline->m_ssthresh = 4.0;
BOOST_REQUIRE_CLOSE(aimdPipeline->m_cwnd, 1, MARGIN);
- runWithData(*makeDataWithSegment(0));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
- // receive segments 1 to 4
- for (uint64_t i = 1; i < 5; ++i) {
+ // receive segments 0 to 4
+ for (uint64_t i = 0; i < 5; ++i) {
face.receive(*makeDataWithSegment(i));
advanceClocks(io, time::nanoseconds(1));
}
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.25, MARGIN);
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.5, MARGIN);
// receive segment 5 with congestion mark
face.receive(*makeDataWithSegmentAndCongMark(5));
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.125, MARGIN); // window size drops to 1/2 of previous size
- BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments - 1); // all interests have been sent
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.25, MARGIN); // window size drops to 1/2 of previous size
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
// receive the last segment with congestion mark
face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.125, MARGIN); // conservative window adaption (window size should not decrease)
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.25, MARGIN); // conservative window adaption (window size should not decrease)
BOOST_CHECK_EQUAL(aimdPipeline->m_retxQueue.size(), 0);
// make sure no interest is retransmitted for marked data packets
@@ -248,26 +248,26 @@
aimdPipeline->m_ssthresh = 4.0;
BOOST_REQUIRE_CLOSE(aimdPipeline->m_cwnd, 1, MARGIN);
- runWithData(*makeDataWithSegment(0));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
- // receive segments 1 to 4
- for (uint64_t i = 1; i < 5; ++i) {
+ // receive segments 0 to 4
+ for (uint64_t i = 0; i < 5; ++i) {
face.receive(*makeDataWithSegment(i));
advanceClocks(io, time::nanoseconds(1));
}
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 5);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.25, MARGIN);
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.5, MARGIN);
// receive segment 5 with congestion mark
face.receive(*makeDataWithSegmentAndCongMark(5));
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.125, MARGIN); // window size drops to 1/2 of previous size
- BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments - 1); // all interests have been sent
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 2.25, MARGIN); // window size drops to 1/2 of previous size
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
// receive the last segment with congestion mark
face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
@@ -295,26 +295,26 @@
aimdPipeline->m_ssthresh = 4.0;
BOOST_REQUIRE_CLOSE(aimdPipeline->m_cwnd, 1, MARGIN);
- runWithData(*makeDataWithSegment(0));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(face.sentInterests.size(), 1);
- // receive segments 1 to 5
- for (uint64_t i = 1; i < 6; ++i) {
+ // receive segments 0 to 5
+ for (uint64_t i = 0; i < 6; ++i) {
face.receive(*makeDataWithSegment(i));
advanceClocks(io, time::nanoseconds(1));
}
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 6);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.5, MARGIN);
- BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments - 1); // all interests have been sent
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.75, MARGIN);
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments); // all interests have been sent
// receive the last segment with congestion mark
face.receive(*makeDataWithSegmentAndCongMark(nDataSegments - 1));
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, nDataSegments);
- BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 4.75, MARGIN); // window size increases
+ BOOST_CHECK_CLOSE(aimdPipeline->m_cwnd, 5.0, MARGIN); // window size increases
BOOST_CHECK_EQUAL(aimdPipeline->m_retxQueue.size(), 0);
// make sure no interest is retransmitted for marked data packet
@@ -328,16 +328,19 @@
{
nDataSegments = 5;
aimdPipeline->m_cwnd = 10.0;
- runWithData(*makeDataWithSegment(0));
+ run(name);
+ advanceClocks(io, time::nanoseconds(1));
+
+ face.receive(*makeDataWithSegment(0));
advanceClocks(io, time::nanoseconds(1));
face.receive(*makeDataWithSegment(1));
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
- BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 4);
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 10);
- // receive a nack with NackReason::DUPLICATE for segment 2
+ // receive a nack with NackReason::DUPLICATE for segment 1
auto nack1 = makeNack(face.sentInterests[1], lp::NackReason::DUPLICATE);
face.receive(nack1);
advanceClocks(io, time::nanoseconds(1));
@@ -347,15 +350,15 @@
BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
BOOST_CHECK_EQUAL(aimdPipeline->m_retxQueue.size(), 0);
- // receive a nack with NackReason::CONGESTION for segment 3
+ // receive a nack with NackReason::CONGESTION for segment 2
auto nack2 = makeNack(face.sentInterests[2], lp::NackReason::CONGESTION);
face.receive(nack2);
advanceClocks(io, time::nanoseconds(1));
- // segment 3 is retransmitted
- BOOST_CHECK_EQUAL(aimdPipeline->m_retxCount[3], 1);
+ // segment 2 is retransmitted
+ BOOST_CHECK_EQUAL(aimdPipeline->m_retxCount[2], 1);
- // receive a nack with NackReason::NONE for segment 4
+ // receive a nack with NackReason::NONE for segment 3
auto nack3 = makeNack(face.sentInterests[3], lp::NackReason::NONE);
face.receive(nack3);
advanceClocks(io, time::nanoseconds(1));
@@ -369,28 +372,28 @@
{
nDataSegments = 4;
aimdPipeline->m_cwnd = 4;
- runWithData(*makeDataWithSegment(0, false));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
- // receive segment 1 without FinalBlockId
- face.receive(*makeDataWithSegment(1, false));
+ // receive segment 0 without FinalBlockId
+ face.receive(*makeDataWithSegment(0, false));
advanceClocks(io, time::nanoseconds(1));
- // interests for segment 1 - 6 have been sent
+ // interests for segment 0 - 5 have been sent
BOOST_CHECK_EQUAL(face.sentInterests.size(), 6);
- BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
+ BOOST_CHECK_EQUAL(pipeline->m_nReceived, 1);
BOOST_CHECK_EQUAL(aimdPipeline->m_hasFinalBlockId, false);
- // pending interests: segment 2, 3, 4, 5, 6
+ // pending interests: segment 1, 2, 3, 4, 5
BOOST_CHECK_EQUAL(face.getNPendingInterests(), 5);
- // receive segment 2 with FinalBlockId
- face.receive(*makeDataWithSegment(2));
+ // receive segment 1 with FinalBlockId
+ face.receive(*makeDataWithSegment(1));
advanceClocks(io, time::nanoseconds(1));
- BOOST_CHECK_EQUAL(pipeline->m_nReceived, 3);
+ BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
BOOST_CHECK_EQUAL(aimdPipeline->m_hasFinalBlockId, true);
- // pending interests for segment 2, 4, 5, 6 haven been removed
- BOOST_CHECK_EQUAL(face.getNPendingInterests(), 1);
+ // pending interests for segment 1, 4, 5 haven been removed
+ BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2);
}
BOOST_AUTO_TEST_CASE(FailureBeforeFinalBlockIdReceived)
@@ -401,17 +404,22 @@
nDataSegments = 4;
aimdPipeline->m_cwnd = 4;
- runWithData(*makeDataWithSegment(0, false));
+ run(name);
+ advanceClocks(io, time::nanoseconds(1));
+
+ // receive segment 0 without FinalBlockId
+ face.receive(*makeDataWithSegment(0, false));
advanceClocks(io, time::nanoseconds(1));
// receive segment 1 without FinalBlockId
face.receive(*makeDataWithSegment(1, false));
advanceClocks(io, time::nanoseconds(1));
- // interests for segment 1 - 6 have been sent
- BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 6);
+
+ // interests for segment 0 - 7 have been sent
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8);
// receive nack with NackReason::NONE for segment 3
- auto nack = makeNack(face.sentInterests[2], lp::NackReason::NONE);
+ auto nack = makeNack(face.sentInterests[3], lp::NackReason::NONE);
face.receive(nack);
advanceClocks(io, time::nanoseconds(1));
@@ -436,22 +444,27 @@
nDataSegments = 4;
aimdPipeline->m_cwnd = 4;
- runWithData(*makeDataWithSegment(0, false));
+ run(name);
+ advanceClocks(io, time::nanoseconds(1));
+
+ // receive segment 0 without FinalBlockId
+ face.receive(*makeDataWithSegment(0, false));
advanceClocks(io, time::nanoseconds(1));
// receive segment 1 without FinalBlockId
face.receive(*makeDataWithSegment(1, false));
advanceClocks(io, time::nanoseconds(1));
- // interests for segment 1 - 6 have been sent
- BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 6);
+
+ // interests for segment 0 - 7 have been sent
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 8);
// receive nack with NackReason::NONE for segment 4
- auto nack = makeNack(face.sentInterests[3], lp::NackReason::NONE);
+ auto nack = makeNack(face.sentInterests[4], lp::NackReason::NONE);
face.receive(nack);
advanceClocks(io, time::nanoseconds(1));
// error not triggered
- // pending interests for segment > 4 have been removed
+ // pending interests for segment > 3 have been removed
BOOST_CHECK_EQUAL(hasFailed, false);
BOOST_CHECK_EQUAL(face.getNPendingInterests(), 2);
@@ -479,14 +492,18 @@
nDataSegments = 3;
- runWithData(*makeDataWithSegment(0));
+ run(name);
+ advanceClocks(io, time::nanoseconds(1));
+
+ // receive segment 0
+ face.receive(*makeDataWithSegment(0));
advanceClocks(io, time::nanoseconds(1));
// receive segment 1
face.receive(*makeDataWithSegment(1));
advanceClocks(io, time::nanoseconds(1));
- BOOST_CHECK_EQUAL(face.sentInterests.size(), 2);
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), 3);
// check if segment 2's state is FirstTimeSent
auto it = aimdPipeline->m_segmentInfo.find(2);
@@ -496,7 +513,7 @@
// timeout segment 2 twice
advanceClocks(io, time::milliseconds(400), 3);
- BOOST_CHECK_EQUAL(face.sentInterests.size(), 4);
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), 5);
// check if segment 2's state is Retransmitted
it = aimdPipeline->m_segmentInfo.find(2);
@@ -524,7 +541,7 @@
// nothing changed
it = aimdPipeline->m_segmentInfo.find(2);
BOOST_CHECK(it == aimdPipeline->m_segmentInfo.end());
- BOOST_CHECK_EQUAL(face.sentInterests.size(), 4);
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), 5);
BOOST_CHECK_EQUAL(rttEstimator.getAvgRtt(), prevRtt);
BOOST_CHECK_EQUAL(rttEstimator.getEstimatedRto(), prevRto);
}
@@ -562,10 +579,10 @@
createPipeline();
nDataSegments = 1;
- runWithData(*makeDataWithSegment(0));
+ run(name);
advanceClocks(io, time::nanoseconds(1));
- face.receive(*makeDataWithSegment(1));
+ face.receive(*makeDataWithSegment(0));
advanceClocks(io, time::nanoseconds(1));
BOOST_CHECK_EQUAL(aimdPipeline->m_hasFinalBlockId, true);
diff --git a/tests/chunks/pipeline-interests-fixed-window.t.cpp b/tests/chunks/pipeline-interests-fixed-window.t.cpp
index c4d4aad..e75b4a2 100644
--- a/tests/chunks/pipeline-interests-fixed-window.t.cpp
+++ b/tests/chunks/pipeline-interests-fixed-window.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2018, Regents of the University of California,
+ * Copyright (c) 2016-2019, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -21,6 +21,7 @@
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*
* @author Andrea Tosatto
+ * @author Chavoosh Ghasemi
*/
#include "tools/chunks/catchunks/pipeline-interests-fixed-window.hpp"
@@ -61,53 +62,23 @@
BOOST_AUTO_TEST_SUITE(Chunks)
BOOST_FIXTURE_TEST_SUITE(TestPipelineInterestsFixedWindow, PipelineInterestFixedWindowFixture)
-BOOST_AUTO_TEST_CASE(FewerSegmentsThanPipelineCapacity)
-{
- nDataSegments = 3;
- BOOST_ASSERT(nDataSegments <= opt.maxPipelineSize);
-
- runWithData(*makeDataWithSegment(0));
- advanceClocks(io, time::nanoseconds(1), 1);
- BOOST_REQUIRE_EQUAL(face.sentInterests.size(), nDataSegments - 1);
-
- for (uint64_t i = 1; i < nDataSegments - 1; ++i) {
- face.receive(*makeDataWithSegment(i));
- advanceClocks(io, time::nanoseconds(1), 1);
-
- BOOST_CHECK_EQUAL(pipeline->m_nReceived, i + 1);
- BOOST_REQUIRE_EQUAL(face.sentInterests.size(), nDataSegments - 1);
- // check if the interest for the segment i+1 is well formed
- const auto& sentInterest = face.sentInterests[i];
- BOOST_CHECK_EQUAL(sentInterest.getExclude().size(), 0);
- BOOST_CHECK_EQUAL(sentInterest.getMaxSuffixComponents(), 1);
- BOOST_CHECK_EQUAL(sentInterest.getMustBeFresh(), opt.mustBeFresh);
- BOOST_CHECK_EQUAL(Name(name).isPrefixOf(sentInterest.getName()), true);
- BOOST_CHECK_EQUAL(getSegmentFromPacket(sentInterest), i + 1);
- }
-
- BOOST_CHECK_EQUAL(hasFailed, false);
-
- advanceClocks(io, ndn::DEFAULT_INTEREST_LIFETIME, opt.maxRetriesOnTimeoutOrNack + 1);
- BOOST_CHECK_EQUAL(hasFailed, true);
-}
-
BOOST_AUTO_TEST_CASE(FullPipeline)
{
nDataSegments = 13;
BOOST_ASSERT(nDataSegments > opt.maxPipelineSize);
- runWithData(*makeDataWithSegment(nDataSegments - 1));
+ run(name);
advanceClocks(io, time::nanoseconds(1), 1);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize);
for (uint64_t i = 0; i < nDataSegments - 1; ++i) {
face.receive(*makeDataWithSegment(i));
advanceClocks(io, time::nanoseconds(1), 1);
- BOOST_CHECK_EQUAL(pipeline->m_nReceived, i + 2);
+ BOOST_CHECK_EQUAL(pipeline->m_nReceived, i + 1);
- if (i < nDataSegments - opt.maxPipelineSize - 1) {
+ if (i < nDataSegments - opt.maxPipelineSize) {
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize + i + 1);
- // check if the interest for the segment i+1 is well formed
+ // check if the interest for the segment i is well formed
const auto& sentInterest = face.sentInterests[i];
BOOST_CHECK_EQUAL(sentInterest.getExclude().size(), 0);
BOOST_CHECK_EQUAL(sentInterest.getMaxSuffixComponents(), 1);
@@ -117,11 +88,14 @@
}
else {
// all the interests have been sent for all the segments
- BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments - 1);
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), nDataSegments);
}
}
BOOST_CHECK_EQUAL(hasFailed, false);
+
+ advanceClocks(io, ndn::DEFAULT_INTEREST_LIFETIME, opt.maxRetriesOnTimeoutOrNack + 1);
+ BOOST_CHECK_EQUAL(hasFailed, true);
}
BOOST_AUTO_TEST_CASE(TimeoutAllSegments)
@@ -129,14 +103,14 @@
nDataSegments = 13;
BOOST_ASSERT(nDataSegments > opt.maxPipelineSize);
- runWithData(*makeDataWithSegment(nDataSegments - 1));
+ run(name);
advanceClocks(io, time::nanoseconds(1), 1);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize);
for (int i = 0; i < opt.maxRetriesOnTimeoutOrNack; ++i) {
advanceClocks(io, opt.interestLifetime, 1);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize * (i + 2));
- BOOST_CHECK_EQUAL(pipeline->m_nReceived, 1);
+ BOOST_CHECK_EQUAL(pipeline->m_nReceived, 0);
// A single retry for every pipeline element
for (size_t j = 0; j < opt.maxPipelineSize; ++j) {
@@ -157,7 +131,7 @@
nDataSegments = 18;
BOOST_ASSERT(nDataSegments > opt.maxPipelineSize);
- runWithData(*makeDataWithSegment(nDataSegments - 1));
+ run(name);
advanceClocks(io, time::nanoseconds(1), 1);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize);
@@ -170,7 +144,7 @@
// send a single data packet for each pipeline element
advanceClocks(io, opt.interestLifetime, opt.maxRetriesOnTimeoutOrNack - 1);
- for (uint64_t i = 0; i < opt.maxPipelineSize - 1; ++i) {
+ for (uint64_t i = 0; i < opt.maxPipelineSize; ++i) {
face.receive(*makeDataWithSegment(opt.maxPipelineSize + i));
advanceClocks(io, time::nanoseconds(1), 1);
}
@@ -183,7 +157,7 @@
// these new segments should not generate new interests
advanceClocks(io, opt.interestLifetime, 1);
- for (uint64_t i = 0; i < opt.maxPipelineSize - 1; ++i) {
+ for (uint64_t i = 0; i < opt.maxPipelineSize; ++i) {
face.receive(*makeDataWithSegment(opt.maxPipelineSize * 2 + i - 1));
advanceClocks(io, time::nanoseconds(1), 1);
}
@@ -202,7 +176,7 @@
nDataSegments = 22;
BOOST_ASSERT(nDataSegments > opt.maxPipelineSize);
- runWithData(*makeDataWithSegment(nDataSegments - 1, false));
+ run(name);
advanceClocks(io, time::nanoseconds(1), 1);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize);
@@ -231,8 +205,8 @@
BOOST_CHECK_EQUAL(hasFailed, false);
// data for all the pipeline element, but not the second (segment #1)
- for (uint64_t i = opt.maxPipelineSize; i < nDataSegments - 1; ++i) {
- if (i == nDataSegments - 2) {
+ for (uint64_t i = opt.maxPipelineSize; i < nDataSegments; ++i) {
+ if (i == nDataSegments - 1) {
face.receive(*makeDataWithSegment(i, true));
}
else {
@@ -255,7 +229,7 @@
nDataSegments = 22;
BOOST_ASSERT(nDataSegments > opt.maxPipelineSize);
- runWithData(*makeDataWithSegment(nDataSegments - 1, false));
+ run(name);
advanceClocks(io, time::nanoseconds(1), 1);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize);
@@ -272,11 +246,11 @@
BOOST_CHECK_EQUAL(hasFailed, false);
// data for the first pipeline element (segment #0), this should trigger an error because the
- // others pipeline elements failed
+ // other pipeline elements failed
face.receive(*makeDataWithSegment(0, false));
advanceClocks(io, time::nanoseconds(1), 1);
- BOOST_CHECK_EQUAL(pipeline->m_nReceived, 2);
+ BOOST_CHECK_EQUAL(pipeline->m_nReceived, 1);
BOOST_CHECK_EQUAL(hasFailed, true);
}
@@ -285,13 +259,13 @@
nDataSegments = 13;
BOOST_ASSERT(nDataSegments > opt.maxPipelineSize);
- runWithData(*makeDataWithSegment(nDataSegments - 1));
+ run(name);
advanceClocks(io, time::nanoseconds(1), 1);
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), opt.maxPipelineSize);
// send nack for all the pipeline elements first interest
- for (size_t j = 0; j < opt.maxPipelineSize; j++) {
- auto nack = make_shared<lp::Nack>(face.sentInterests[j]);
+ for (size_t i = 0; i < opt.maxPipelineSize; i++) {
+ auto nack = make_shared<lp::Nack>(face.sentInterests[i]);
nack->setReason(lp::NackReason::CONGESTION);
face.receive(*nack);
advanceClocks(io, time::nanoseconds(1), 1);
diff --git a/tests/chunks/pipeline-interests-fixture.hpp b/tests/chunks/pipeline-interests-fixture.hpp
index c9979fd..0d456c3 100644
--- a/tests/chunks/pipeline-interests-fixture.hpp
+++ b/tests/chunks/pipeline-interests-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2016-2018, Regents of the University of California,
+ * Copyright (c) 2016-2019, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -70,9 +70,9 @@
}
void
- runWithData(const Data& data)
+ run(const Name& name, uint64_t version = 0)
{
- pipeline->run(data,
+ pipeline->run(Name(name).appendVersion(version),
[] (const Data&) {},
[this] (const std::string&) { hasFailed = true; });
}