blob: 9cecd15673a2b0cd7b83c6c8aa2ff3f3b673d505 [file] [log] [blame]
Junxiao Shi986b8492014-08-20 12:07:14 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi192af1f2015-01-13 23:19:39 -07003 * Copyright (c) 2014-2015, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
Junxiao Shi986b8492014-08-20 12:07:14 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "fw/best-route-strategy2.hpp"
Junxiao Shi986b8492014-08-20 12:07:14 -070027
28#include "tests/test-common.hpp"
Junxiao Shi986b8492014-08-20 12:07:14 -070029#include "tests/daemon/face/dummy-face.hpp"
Junxiao Shi5e5e4452015-09-24 16:56:52 -070030#include "strategy-tester.hpp"
31#include "topology-tester.hpp"
Junxiao Shi986b8492014-08-20 12:07:14 -070032
33namespace nfd {
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080034namespace fw {
Junxiao Shi986b8492014-08-20 12:07:14 -070035namespace tests {
36
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -080037using namespace nfd::tests;
38
Junxiao Shi5e5e4452015-09-24 16:56:52 -070039BOOST_AUTO_TEST_SUITE(Fw)
40
41class BestRouteStrategy2Fixture : public UnitTestTimeFixture
42{
43protected:
44 BestRouteStrategy2Fixture()
45 : strategy(forwarder)
46 , fib(forwarder.getFib())
47 , pit(forwarder.getPit())
48 , face1(make_shared<DummyFace>())
49 , face2(make_shared<DummyFace>())
50 , face3(make_shared<DummyFace>())
51 , face4(make_shared<DummyFace>())
52 , face5(make_shared<DummyFace>())
53 {
54 forwarder.addFace(face1);
55 forwarder.addFace(face2);
56 forwarder.addFace(face3);
57 forwarder.addFace(face4);
58 forwarder.addFace(face5);
59 }
60
61public:
62 Forwarder forwarder;
63 StrategyTester<fw::BestRouteStrategy2> strategy;
64 Fib& fib;
65 Pit& pit;
66
67 shared_ptr<DummyFace> face1;
68 shared_ptr<DummyFace> face2;
69 shared_ptr<DummyFace> face3;
70 shared_ptr<DummyFace> face4;
71 shared_ptr<DummyFace> face5;
72};
73
74BOOST_FIXTURE_TEST_SUITE(TestBestRouteStrategy2, BestRouteStrategy2Fixture)
Junxiao Shi986b8492014-08-20 12:07:14 -070075
76BOOST_AUTO_TEST_CASE(Forward)
77{
Junxiao Shi986b8492014-08-20 12:07:14 -070078 shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
79 fibEntry->addNextHop(face1, 10);
80 fibEntry->addNextHop(face2, 20);
81 fibEntry->addNextHop(face3, 30);
82
83 shared_ptr<Interest> interest = makeInterest("ndn:/BzgFBchqA");
Junxiao Shi986b8492014-08-20 12:07:14 -070084 shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
85
Junxiao Shi584a5692014-12-13 21:55:28 -070086 const time::nanoseconds TICK = time::duration_cast<time::nanoseconds>(
Junxiao Shi52e85402015-11-11 06:06:58 -070087 BestRouteStrategy2::RETX_SUPPRESSION_INITIAL * 0.1);
Junxiao Shi986b8492014-08-20 12:07:14 -070088
Junxiao Shi1f30aac2014-11-04 18:45:56 -070089 // first Interest goes to nexthop with lowest FIB cost,
90 // however face1 is downstream so it cannot be used
Junxiao Shi986b8492014-08-20 12:07:14 -070091 pitEntry->insertOrUpdateInRecord(face1, *interest);
92 strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
Junxiao Shi5e5e4452015-09-24 16:56:52 -070093 BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 1);
94 BOOST_CHECK_EQUAL(strategy.sendInterestHistory.back().outFaceId, face2->getId());
Junxiao Shi986b8492014-08-20 12:07:14 -070095
Junxiao Shi1f30aac2014-11-04 18:45:56 -070096 // downstream retransmits frequently, but the strategy should not send Interests
Junxiao Shia788e252015-01-28 17:06:25 -070097 // more often than DEFAULT_MIN_RETX_INTERVAL
Junxiao Shi1f30aac2014-11-04 18:45:56 -070098 scheduler::EventId retxFrom4Evt;
Junxiao Shi5e5e4452015-09-24 16:56:52 -070099 size_t nSentLast = strategy.sendInterestHistory.size();
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700100 time::steady_clock::TimePoint timeSentLast = time::steady_clock::now();
Junxiao Shi913806d2014-11-14 11:43:52 -0700101 function<void()> periodicalRetxFrom4; // let periodicalRetxFrom4 lambda capture itself
102 periodicalRetxFrom4 = [&] {
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700103 pitEntry->insertOrUpdateInRecord(face4, *interest);
104 strategy.afterReceiveInterest(*face4, *interest, fibEntry, pitEntry);
Junxiao Shi986b8492014-08-20 12:07:14 -0700105
Junxiao Shi5e5e4452015-09-24 16:56:52 -0700106 size_t nSent = strategy.sendInterestHistory.size();
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700107 if (nSent > nSentLast) {
108 BOOST_CHECK_EQUAL(nSent - nSentLast, 1);
109 time::steady_clock::TimePoint timeSent = time::steady_clock::now();
Junxiao Shi684fa0f2015-02-23 21:39:57 -0700110 BOOST_CHECK_GE(timeSent - timeSentLast, TICK * 8);
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700111 nSentLast = nSent;
112 timeSentLast = timeSent;
113 }
Junxiao Shi986b8492014-08-20 12:07:14 -0700114
Junxiao Shi684fa0f2015-02-23 21:39:57 -0700115 retxFrom4Evt = scheduler::schedule(TICK * 5, periodicalRetxFrom4);
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700116 };
117 periodicalRetxFrom4();
Junxiao Shi52e85402015-11-11 06:06:58 -0700118 this->advanceClocks(TICK, BestRouteStrategy2::RETX_SUPPRESSION_MAX * 16);
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700119 scheduler::cancel(retxFrom4Evt);
Junxiao Shi986b8492014-08-20 12:07:14 -0700120
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700121 // nexthops for accepted retransmissions: follow FIB cost,
122 // later forward to an eligible upstream with earliest OutRecord
Junxiao Shi5e5e4452015-09-24 16:56:52 -0700123 BOOST_REQUIRE_GE(strategy.sendInterestHistory.size(), 6);
124 BOOST_CHECK_EQUAL(strategy.sendInterestHistory[1].outFaceId, face1->getId());
125 BOOST_CHECK_EQUAL(strategy.sendInterestHistory[2].outFaceId, face3->getId());
126 BOOST_CHECK_EQUAL(strategy.sendInterestHistory[3].outFaceId, face2->getId());
127 BOOST_CHECK_EQUAL(strategy.sendInterestHistory[4].outFaceId, face1->getId());
128 BOOST_CHECK_EQUAL(strategy.sendInterestHistory[5].outFaceId, face3->getId());
Junxiao Shi986b8492014-08-20 12:07:14 -0700129
130 fibEntry->removeNextHop(face1);
131
Junxiao Shi5e5e4452015-09-24 16:56:52 -0700132 strategy.sendInterestHistory.clear();
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700133 for (int i = 0; i < 3; ++i) {
Junxiao Shi52e85402015-11-11 06:06:58 -0700134 this->advanceClocks(TICK, BestRouteStrategy2::RETX_SUPPRESSION_MAX * 2);
Junxiao Shi1f30aac2014-11-04 18:45:56 -0700135 pitEntry->insertOrUpdateInRecord(face5, *interest);
136 strategy.afterReceiveInterest(*face5, *interest, fibEntry, pitEntry);
137 }
Junxiao Shi5e5e4452015-09-24 16:56:52 -0700138 BOOST_REQUIRE_EQUAL(strategy.sendInterestHistory.size(), 3);
139 BOOST_CHECK_NE(strategy.sendInterestHistory[0].outFaceId, face1->getId());
140 BOOST_CHECK_NE(strategy.sendInterestHistory[1].outFaceId, face1->getId());
141 BOOST_CHECK_NE(strategy.sendInterestHistory[2].outFaceId, face1->getId());
Junxiao Shi986b8492014-08-20 12:07:14 -0700142 // face1 cannot be used because it's gone from FIB entry
143}
144
Junxiao Shi5e5e4452015-09-24 16:56:52 -0700145BOOST_AUTO_TEST_SUITE(NoRouteNack) // send Nack-NoRoute if there's no usable FIB nexthop
146
147class EmptyNextHopList
148{
149public:
150 Name
151 getInterestName()
152 {
153 return "/P";
154 }
155
156 shared_ptr<fib::Entry>
157 makeFibEntry(BestRouteStrategy2Fixture* fixture)
158 {
159 return fixture->fib.insert(Name()).first;
160 }
161};
162
163class NextHopIsDownstream
164{
165public:
166 Name
167 getInterestName()
168 {
169 return "/P";
170 }
171
172 shared_ptr<fib::Entry>
173 makeFibEntry(BestRouteStrategy2Fixture* fixture)
174 {
175 shared_ptr<fib::Entry> fibEntry = fixture->fib.insert(Name()).first;
176 fibEntry->addNextHop(fixture->face1, 10);
177 return fibEntry;
178 }
179};
180
181class NextHopViolatesScope
182{
183public:
184 Name
185 getInterestName()
186 {
187 return "/localhop/P";
188 }
189
190 shared_ptr<fib::Entry>
191 makeFibEntry(BestRouteStrategy2Fixture* fixture)
192 {
193 shared_ptr<fib::Entry> fibEntry = fixture->fib.insert("/localhop").first;
194 fibEntry->addNextHop(fixture->face2, 10);
195 // face1 and face2 are both non-local; Interest from face1 cannot be forwarded to face2
196 return fibEntry;
197 }
198};
199
200typedef boost::mpl::vector<EmptyNextHopList, NextHopIsDownstream, NextHopViolatesScope> NoRouteScenarios;
201
202BOOST_AUTO_TEST_CASE_TEMPLATE(IncomingInterest, Scenario, NoRouteScenarios)
203{
204 Scenario scenario;
205
206 shared_ptr<Interest> interest = makeInterest(scenario.getInterestName());
207 shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
208 pitEntry->insertOrUpdateInRecord(face1, *interest);
209
210 shared_ptr<fib::Entry> fibEntry = scenario.makeFibEntry(this);
211
212 strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
213
214 BOOST_REQUIRE_EQUAL(strategy.rejectPendingInterestHistory.size(), 1);
215 BOOST_CHECK_EQUAL(strategy.rejectPendingInterestHistory[0].pitEntry, pitEntry);
216
217 BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1);
218 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
219 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId());
220 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), lp::NackReason::NO_ROUTE);
221}
222
223BOOST_AUTO_TEST_SUITE_END() // NoRouteNack
224
225BOOST_AUTO_TEST_SUITE(IncomingNack)
226
227BOOST_AUTO_TEST_CASE(OneUpstream) // one upstream, send Nack when Nack arrives
228{
229 shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
230 fibEntry->addNextHop(face3, 10);
231 fibEntry->addNextHop(face4, 20);
232 fibEntry->addNextHop(face5, 30);
233
234 shared_ptr<Interest> interest1 = makeInterest("/McQYjMbm", 992);
235 shared_ptr<Interest> interest2 = makeInterest("/McQYjMbm", 114);
236 shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
237 pitEntry->insertOrUpdateInRecord(face1, *interest1);
238 pitEntry->insertOrUpdateInRecord(face2, *interest2);
239 pitEntry->insertOrUpdateOutRecord(face3, *interest1);
240
241 lp::Nack nack3 = makeNack("/McQYjMbm", 992, lp::NackReason::CONGESTION);
242 pitEntry->getOutRecord(*face3)->setIncomingNack(nack3);
243 strategy.afterReceiveNack(*face3, nack3, fibEntry, pitEntry);
244
245 BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 2);
246 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
247 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), lp::NackReason::CONGESTION);
248 BOOST_CHECK_EQUAL(strategy.sendNackHistory[1].pitEntry, pitEntry);
249 BOOST_CHECK_EQUAL(strategy.sendNackHistory[1].header.getReason(), lp::NackReason::CONGESTION);
250 std::unordered_set<FaceId> nackFaceIds{strategy.sendNackHistory[0].outFaceId,
251 strategy.sendNackHistory[1].outFaceId};
252 std::unordered_set<FaceId> expectedNackFaceIds{face1->getId(), face2->getId()};
253 BOOST_CHECK_EQUAL_COLLECTIONS(nackFaceIds.begin(), nackFaceIds.end(),
254 expectedNackFaceIds.begin(), expectedNackFaceIds.end());
255}
256
257BOOST_AUTO_TEST_CASE(TwoUpstreams) // two upstreams, send Nack when both Nacks arrive
258{
259 shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
260 fibEntry->addNextHop(face3, 10);
261 fibEntry->addNextHop(face4, 20);
262 fibEntry->addNextHop(face5, 30);
263
264 shared_ptr<Interest> interest1 = makeInterest("/aS9FAyUV19", 286);
265 shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
266 pitEntry->insertOrUpdateInRecord(face1, *interest1);
267 pitEntry->insertOrUpdateOutRecord(face3, *interest1);
268 pitEntry->insertOrUpdateOutRecord(face4, *interest1);
269
270 lp::Nack nack3 = makeNack("/aS9FAyUV19", 286, lp::NackReason::CONGESTION);
271 pitEntry->getOutRecord(*face3)->setIncomingNack(nack3);
272 strategy.afterReceiveNack(*face3, nack3, fibEntry, pitEntry);
273
274 BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0); // don't send Nack until all upstreams have Nacked
275
276 lp::Nack nack4 = makeNack("/aS9FAyUV19", 286, lp::NackReason::CONGESTION);
277 pitEntry->getOutRecord(*face4)->setIncomingNack(nack4);
278 strategy.afterReceiveNack(*face4, nack4, fibEntry, pitEntry);
279
280 BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1);
281 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
282 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId());
283 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), lp::NackReason::CONGESTION);
284}
285
286BOOST_AUTO_TEST_CASE(Timeout) // two upstreams, one times out, don't send Nack
287{
288 shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
289 fibEntry->addNextHop(face3, 10);
290 fibEntry->addNextHop(face4, 20);
291 fibEntry->addNextHop(face5, 30);
292
293 shared_ptr<Interest> interest1 = makeInterest("/sIYw0TXWDj", 115);
294 interest1->setInterestLifetime(time::milliseconds(400));
295 shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
296 pitEntry->insertOrUpdateInRecord(face1, *interest1);
297 pitEntry->insertOrUpdateOutRecord(face3, *interest1);
298
299 this->advanceClocks(time::milliseconds(300));
300 shared_ptr<Interest> interest2 = makeInterest("/sIYw0TXWDj", 223);
301 pitEntry->insertOrUpdateInRecord(face1, *interest2);
302 pitEntry->insertOrUpdateOutRecord(face4, *interest2);
303
304 this->advanceClocks(time::milliseconds(200)); // face3 has timed out
305
306 lp::Nack nack4 = makeNack("/sIYw0TXWDj", 223, lp::NackReason::CONGESTION);
307 pitEntry->getOutRecord(*face4)->setIncomingNack(nack4);
308 strategy.afterReceiveNack(*face4, nack4, fibEntry, pitEntry);
309
310 BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0);
311}
312
313BOOST_FIXTURE_TEST_CASE(LiveDeadlock, UnitTestTimeFixture) // #3033 note-7
314{
315 /*
316 * /----------\
317 * | producer |
318 * \----------/
319 * |
320 * +---+
321 * | P |
322 * +---+
323 * |
324 * failed link
325 * |
326 * +---+
327 * | R |
328 * +---+
329 * ^ ^
330 * / \
331 * / \
332 * +---+ +---+
333 * | B | <---> | C |
334 * +---+ +---+
335 * ^ ^
336 * | |
337 * | |
338 * +---+ +---+
339 * | A | | D |
340 * +---+ +---+
341 * ^ ^
342 * | |
343 * /----------\ /----------\
344 * | consumer | | consumer |
345 * \----------/ \----------/
346 */
347
348 TopologyTester topo;
349 TopologyNode nodeP = topo.addForwarder("P"),
350 nodeR = topo.addForwarder("R"),
351 nodeA = topo.addForwarder("A"),
352 nodeB = topo.addForwarder("B"),
353 nodeC = topo.addForwarder("C"),
354 nodeD = topo.addForwarder("D");
355
356 for (TopologyNode node : {nodeP, nodeR, nodeA, nodeB, nodeC, nodeD}) {
357 topo.setStrategy<BestRouteStrategy2>(node);
358 }
359
360 const time::milliseconds LINK_DELAY(10);
361 shared_ptr<TopologyLink> linkPR = topo.addLink("PR", LINK_DELAY, {nodeP, nodeR}),
362 linkRB = topo.addLink("RB", LINK_DELAY, {nodeR, nodeB}),
363 linkRC = topo.addLink("RC", LINK_DELAY, {nodeR, nodeC}),
364 linkBC = topo.addLink("BC", LINK_DELAY, {nodeB, nodeC}),
365 linkBA = topo.addLink("BA", LINK_DELAY, {nodeB, nodeA}),
366 linkCD = topo.addLink("CD", LINK_DELAY, {nodeC, nodeD});
367
368 // TODO register the prefix on R->P but then set the face DOWN
369 // topo.registerPrefix(nodeR, linkPR->getFace(nodeR), "ndn:/P", 10);
370 topo.registerPrefix(nodeB, linkRB->getFace(nodeB), "ndn:/P", 20);
371 topo.registerPrefix(nodeB, linkBC->getFace(nodeB), "ndn:/P", 30);
372 topo.registerPrefix(nodeC, linkRC->getFace(nodeC), "ndn:/P", 20);
373 topo.registerPrefix(nodeC, linkBC->getFace(nodeC), "ndn:/P", 30);
374 topo.registerPrefix(nodeA, linkBA->getFace(nodeA), "ndn:/P", 30);
375 topo.registerPrefix(nodeD, linkCD->getFace(nodeD), "ndn:/P", 30);
376
377 ndn::Face& appA = topo.addAppFace("A", nodeA)->getClientFace();
378 ndn::Face& appD = topo.addAppFace("D", nodeD)->getClientFace();
379
380 int nNacksA = 0, nNacksD = 0;
381 appA.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksA]{ ++nNacksA; }), bind([]{}));
382 appD.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksD]{ ++nNacksD; }), bind([]{}));
383 this->advanceClocks(time::milliseconds(1), time::milliseconds(5));
384 appA.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksA]{ ++nNacksA; }), bind([]{}));
385 appD.expressInterest(Interest("/P/1"), bind([]{}), bind([&nNacksD]{ ++nNacksD; }), bind([]{}));
386 this->advanceClocks(time::milliseconds(1), time::milliseconds(100));
387
388 // As long as at least one Nack arrives at each client, strategy behavior is correct.
389 // Whether both Interests are Nacked is a client face behavior, not strategy behavior.
390 BOOST_CHECK_GT(nNacksA, 0);
391 BOOST_CHECK_GT(nNacksD, 0);
392}
393
394template<lp::NackReason X, lp::NackReason Y, lp::NackReason R>
395struct NackReasonCombination
396{
397 lp::NackReason
398 getX() const
399 {
400 return X;
401 }
402
403 lp::NackReason
404 getY() const
405 {
406 return Y;
407 }
408
409 lp::NackReason
410 getExpectedResult() const
411 {
412 return R;
413 }
414};
415
416typedef boost::mpl::vector<
417 NackReasonCombination<lp::NackReason::CONGESTION, lp::NackReason::CONGESTION, lp::NackReason::CONGESTION>,
418 NackReasonCombination<lp::NackReason::CONGESTION, lp::NackReason::DUPLICATE, lp::NackReason::CONGESTION>,
419 NackReasonCombination<lp::NackReason::CONGESTION, lp::NackReason::NO_ROUTE, lp::NackReason::CONGESTION>,
420 NackReasonCombination<lp::NackReason::DUPLICATE, lp::NackReason::CONGESTION, lp::NackReason::CONGESTION>,
421 NackReasonCombination<lp::NackReason::DUPLICATE, lp::NackReason::DUPLICATE, lp::NackReason::DUPLICATE>,
422 NackReasonCombination<lp::NackReason::DUPLICATE, lp::NackReason::NO_ROUTE, lp::NackReason::DUPLICATE>,
423 NackReasonCombination<lp::NackReason::NO_ROUTE, lp::NackReason::CONGESTION, lp::NackReason::CONGESTION>,
424 NackReasonCombination<lp::NackReason::NO_ROUTE, lp::NackReason::DUPLICATE, lp::NackReason::DUPLICATE>,
425 NackReasonCombination<lp::NackReason::NO_ROUTE, lp::NackReason::NO_ROUTE, lp::NackReason::NO_ROUTE>
426 > NackReasonCombinations;
427
428BOOST_AUTO_TEST_CASE_TEMPLATE(CombineReasons, Combination, NackReasonCombinations)
429{
430 Combination combination;
431
432 shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
433 fibEntry->addNextHop(face3, 10);
434 fibEntry->addNextHop(face4, 20);
435 fibEntry->addNextHop(face5, 30);
436
437 shared_ptr<Interest> interest1 = makeInterest("/F6sEwB24I", 282);
438 shared_ptr<pit::Entry> pitEntry = pit.insert(*interest1).first;
439 pitEntry->insertOrUpdateInRecord(face1, *interest1);
440 pitEntry->insertOrUpdateOutRecord(face3, *interest1);
441 pitEntry->insertOrUpdateOutRecord(face4, *interest1);
442
443 lp::Nack nack3 = makeNack("/F6sEwB24I", 282, combination.getX());
444 pitEntry->getOutRecord(*face3)->setIncomingNack(nack3);
445 strategy.afterReceiveNack(*face3, nack3, fibEntry, pitEntry);
446
447 BOOST_CHECK_EQUAL(strategy.sendNackHistory.size(), 0);
448
449 lp::Nack nack4 = makeNack("/F6sEwB24I", 282, combination.getY());
450 pitEntry->getOutRecord(*face4)->setIncomingNack(nack4);
451 strategy.afterReceiveNack(*face4, nack4, fibEntry, pitEntry);
452
453 BOOST_REQUIRE_EQUAL(strategy.sendNackHistory.size(), 1);
454 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].pitEntry, pitEntry);
455 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].outFaceId, face1->getId());
456 BOOST_CHECK_EQUAL(strategy.sendNackHistory[0].header.getReason(), combination.getExpectedResult());
457}
458
459BOOST_AUTO_TEST_SUITE_END() // IncomingNack
460
461BOOST_AUTO_TEST_SUITE_END() // TestBestRouteStrategy2
462BOOST_AUTO_TEST_SUITE_END() // Fw
Junxiao Shi986b8492014-08-20 12:07:14 -0700463
464} // namespace tests
Spyridon Mastorakisd0381c02015-02-19 10:29:41 -0800465} // namespace fw
Junxiao Shi986b8492014-08-20 12:07:14 -0700466} // namespace nfd