Alexander Afanasyev | b4102ce | 2016-06-26 21:37:40 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2011-2016 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 | |
| 21 | #include "../tests-common.hpp" |
| 22 | |
| 23 | namespace ns3 { |
| 24 | namespace ndn { |
| 25 | |
| 26 | BOOST_FIXTURE_TEST_SUITE(ModelNdnOldContentStore, ScenarioHelperWithCleanupFixture) |
| 27 | |
| 28 | BOOST_AUTO_TEST_CASE(RandomPolicy) |
| 29 | { |
| 30 | Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps")); |
| 31 | Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms")); |
| 32 | Config::SetDefault("ns3::DropTailQueue::MaxPackets", StringValue("20")); |
| 33 | |
| 34 | getStackHelper().SetOldContentStore("ns3::ndn::cs::Random", "MaxSize", "10"); |
| 35 | |
| 36 | createTopology({ |
| 37 | {"1", "2"}, |
| 38 | }); |
| 39 | |
| 40 | addRoutes({ |
| 41 | {"1", "2", "/prefix", 1}, |
| 42 | }); |
| 43 | |
| 44 | addApps({ |
| 45 | {"1", "ns3::ndn::ConsumerCbr", |
| 46 | {{"Prefix", "/prefix"}, {"Frequency", "10"}}, |
| 47 | "0s", "9.99s"}, |
| 48 | {"2", "ns3::ndn::Producer", |
| 49 | {{"Prefix", "/prefix"}, {"PayloadSize", "1024"}}, |
| 50 | "0s", "100s"} |
| 51 | }); |
| 52 | |
| 53 | Simulator::Stop(Seconds(20.001)); |
| 54 | Simulator::Run(); |
| 55 | |
| 56 | std::map<std::string, std::vector<Name>> entries; |
| 57 | for (const std::string& node : {"1", "2"}) { |
| 58 | auto cs = getNode(node)->GetObject<ContentStore>(); |
| 59 | auto& nodeCs = entries[node]; |
| 60 | for (auto it = cs->Begin(); it != cs->End(); it = cs->Next(it)) { |
| 61 | nodeCs.push_back(it->GetName()); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | BOOST_CHECK_EQUAL(entries["1"].size(), 10); |
| 66 | BOOST_CHECK_EQUAL(entries["2"].size(), 10); |
| 67 | BOOST_CHECK(entries["1"] != entries["2"]); // this test has a small chance of failing |
| 68 | } |
| 69 | |
| 70 | BOOST_AUTO_TEST_SUITE_END() |
| 71 | |
| 72 | } // namespace ndn |
| 73 | } // namespace ns3 |