spirosmastorakis | 34eed98 | 2016-11-02 15:20:50 -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 | #include "helper/ndn-stack-helper.hpp" |
| 21 | #include "../tests-common.hpp" |
| 22 | |
| 23 | #include "ns3/point-to-point-module.h" |
| 24 | |
| 25 | namespace ns3 { |
| 26 | namespace ndn { |
| 27 | |
| 28 | BOOST_FIXTURE_TEST_SUITE(HelperStackHelper, CleanupFixture) |
| 29 | |
| 30 | BOOST_AUTO_TEST_CASE(TestNfdContentStorePolicy) |
| 31 | { |
| 32 | // setting default parameters for PointToPoint links and channels |
| 33 | Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps")); |
| 34 | Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms")); |
| 35 | Config::SetDefault("ns3::DropTailQueue::MaxPackets", StringValue("20")); |
| 36 | |
| 37 | // Creating nodes |
| 38 | NodeContainer nodes; |
| 39 | nodes.Create(2); |
| 40 | |
| 41 | // Connecting nodes using two links |
| 42 | PointToPointHelper p2p; |
| 43 | p2p.Install(nodes.Get(0), nodes.Get(1)); |
| 44 | |
| 45 | // Install NDN stack on all nodes |
| 46 | ndn::StackHelper ndnHelper; |
| 47 | ndnHelper.SetDefaultRoutes(true); |
| 48 | ndnHelper.setPolicy("nfd::cs::lru"); |
| 49 | ndnHelper.Install(nodes.Get(0)); |
| 50 | |
| 51 | // test which CS policy has be selected for node 0 |
| 52 | Ptr<L3Protocol> protoNode0 = L3Protocol::getL3Protocol(nodes.Get(0)); |
| 53 | BOOST_CHECK_EQUAL(protoNode0->getForwarder()->getCs().getPolicy()->getName(), "lru"); |
| 54 | |
| 55 | ndnHelper.setPolicy("nfd::cs::priority_fifo"); |
| 56 | ndnHelper.Install(nodes.Get(1)); |
| 57 | |
| 58 | Ptr<L3Protocol> protoNode1 = L3Protocol::getL3Protocol(nodes.Get(1)); |
| 59 | // test that the CS policy for node 0 did not change |
| 60 | BOOST_CHECK_EQUAL(protoNode0->getForwarder()->getCs().getPolicy()->getName(), "lru"); |
| 61 | // test which CS policy has be selected for node 1 |
| 62 | BOOST_CHECK_EQUAL(protoNode1->getForwarder()->getCs().getPolicy()->getName(), "fifo"); |
| 63 | } |
| 64 | |
| 65 | BOOST_AUTO_TEST_SUITE_END() |
| 66 | |
| 67 | } // namespace ndn |
| 68 | } // namespace ns3 |