blob: 9884292b2f1bad2d98ec424c3fb07d6668d76c3e [file] [log] [blame]
spirosmastorakis99ab82e2016-10-19 20:32:59 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
4 *
5 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
7 *
8 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20#include "helper/ndn-strategy-choice-helper.hpp"
21
22#include "ns3/ndnSIM/NFD/daemon/fw/strategy.hpp"
23
24#include "../tests-common.hpp"
25
26namespace ns3 {
27namespace ndn {
28
29class NccFixture : public ScenarioHelperWithCleanupFixture
30{
31public:
32 NccFixture()
33 {
34 Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps"));
35 Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("1ms"));
Alexander Afanasyev77f84c62018-10-08 13:37:42 -040036 Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("500p"));
spirosmastorakis99ab82e2016-10-19 20:32:59 -070037
38 // Creating a 3 node topology //
39 // //
40 // //
41 // +----+ +----+ +----+ //
42 // | | | | | | //
43 // | A1 | <---> | A2 | <---> | A3 | //
44 // | | | | | | //
45 // +----+ +----+ +----+ //
46 // //
47 // //
48 // //
49
50 createTopology({
51 {"A1", "A2"},
52 {"A2", "A3"}
53 });
54
55 addRoutes({
56 {"A1", "A2", "/prefix", 100},
57 {"A2", "A3", "/prefix", 100},
58 });
59
60 addApps({
61 {"A1", "ns3::ndn::ConsumerCbr",
62 {{"Prefix", "/prefix"}, {"Frequency", "1000"}},
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -050063 "0.1s", "1.1s"},
spirosmastorakis99ab82e2016-10-19 20:32:59 -070064 {"A3", "ns3::ndn::Producer",
65 {{"Prefix", "/prefix"}, {"PayloadSize", "1024"}},
66 "0s", "10s"},
67 });
68 }
69};
70
71BOOST_FIXTURE_TEST_SUITE(TestNccStrategy, NccFixture)
72
73BOOST_AUTO_TEST_CASE(DetachedPitEntries)
74{
75 StrategyChoiceHelper::Install(getNode("A1"), "/prefix", "/localhost/nfd/strategy/ncc");
76 StrategyChoiceHelper::Install(getNode("A2"), "/prefix", "/localhost/nfd/strategy/ncc");
77 StrategyChoiceHelper::Install(getNode("A3"), "/prefix", "/localhost/nfd/strategy/ncc");
78
79 Simulator::Stop(Seconds(5.2));
80 BOOST_CHECK_NO_THROW(Simulator::Run());
81
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -050082 BOOST_CHECK_EQUAL(getFace("A1", "A2")->getCounters().nOutInterests, 1000);
83 BOOST_CHECK_EQUAL(getFace("A2", "A3")->getCounters().nOutInterests, 1000);
spirosmastorakis99ab82e2016-10-19 20:32:59 -070084
Alexander Afanasyevdc3c3a32019-02-17 20:17:32 -050085 BOOST_CHECK_EQUAL(getFace("A3", "A2")->getCounters().nOutData, 1000);
86 BOOST_CHECK_EQUAL(getFace("A2", "A1")->getCounters().nOutData, 1000);
spirosmastorakis99ab82e2016-10-19 20:32:59 -070087}
88
89BOOST_AUTO_TEST_SUITE_END()
90
91} // namespace ndn
92} // namespace ns3