Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 1 | /* -*- 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-fib-helper.hpp" |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 21 | |
| 22 | #include "../tests-common.hpp" |
| 23 | |
| 24 | namespace ns3 { |
| 25 | namespace ndn { |
| 26 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 27 | BOOST_AUTO_TEST_SUITE(HelperNdnFibHelper) |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 28 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 29 | class AddRouteFixture : public ScenarioHelperWithCleanupFixture |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 30 | { |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 31 | public: |
| 32 | AddRouteFixture() |
| 33 | { |
| 34 | createTopology({ |
| 35 | {"1", "2"} |
| 36 | }); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 37 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 38 | addApps({ |
| 39 | {"1", "ns3::ndn::ConsumerCbr", |
| 40 | {{"Prefix", "/prefix"}, {"Frequency", "1"}}, |
| 41 | "0s", "9.99s"}, |
| 42 | {"2", "ns3::ndn::Producer", |
| 43 | {{"Prefix", "/prefix"}, {"PayloadSize", "1024"}}, |
| 44 | "0s", "100s"} |
| 45 | }); |
| 46 | } |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 47 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 48 | ~AddRouteFixture() |
| 49 | { |
| 50 | Simulator::Stop(Seconds(20.001)); |
| 51 | Simulator::Run(); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 52 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 53 | BOOST_CHECK_EQUAL(getFace("1", "2")->getFaceStatus().getNOutInterests(), 10); |
| 54 | BOOST_CHECK_EQUAL(getFace("1", "2")->getFaceStatus().getNInDatas(), 10); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 55 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 56 | BOOST_CHECK_EQUAL(getFace("2", "1")->getFaceStatus().getNInInterests(), 10); |
| 57 | BOOST_CHECK_EQUAL(getFace("2", "1")->getFaceStatus().getNOutDatas(), 10); |
| 58 | } |
| 59 | }; |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 60 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 61 | BOOST_FIXTURE_TEST_SUITE(AddRoute, AddRouteFixture) |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 62 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 63 | // static void |
| 64 | // AddRoute(Ptr<Node> node, const Name& prefix, shared_ptr<Face> face, int32_t metric); |
| 65 | BOOST_AUTO_TEST_CASE(Base) |
| 66 | { |
| 67 | FibHelper::AddRoute(getNode("1"), Name("/prefix"), getFace("1", "2"), 1); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Alexander Afanasyev | 823368d | 2015-08-13 16:52:50 -0700 | [diff] [blame] | 70 | |
| 71 | // static void |
| 72 | // AddRoute(const std::string& nodeName, const Name& prefix, uint32_t faceId, int32_t metric); |
| 73 | BOOST_AUTO_TEST_CASE(Helper1) |
| 74 | { |
| 75 | FibHelper::AddRoute("1", Name("/prefix"), getFace("1", "2")->getId(), 10); |
| 76 | } |
| 77 | |
| 78 | // static void |
| 79 | // AddRoute(Ptr<Node> node, const Name& prefix, uint32_t faceId, int32_t metric); |
| 80 | BOOST_AUTO_TEST_CASE(Helper2) |
| 81 | { |
| 82 | FibHelper::AddRoute(getNode("1"), Name("/prefix"), getFace("1", "2")->getId(), 10); |
| 83 | } |
| 84 | |
| 85 | // static void |
| 86 | // AddRoute(const std::string& nodeName, const Name& prefix, const std::string& otherNodeName, |
| 87 | // int32_t metric); |
| 88 | BOOST_AUTO_TEST_CASE(Helper3) |
| 89 | { |
| 90 | FibHelper::AddRoute("1", "/prefix", "2", 1); |
| 91 | } |
| 92 | |
| 93 | // static void |
| 94 | // AddRoute(Ptr<Node> node, const Name& prefix, Ptr<Node> otherNode, int32_t metric); |
| 95 | BOOST_AUTO_TEST_CASE(Helper4) |
| 96 | { |
| 97 | FibHelper::AddRoute(getNode("1"), Name("/prefix"), getNode("2"), 10); |
| 98 | } |
| 99 | |
| 100 | BOOST_AUTO_TEST_SUITE_END() // AddRoute |
| 101 | |
| 102 | BOOST_AUTO_TEST_SUITE_END() // HelperNdnFibHelper |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 103 | |
| 104 | } // namespace ndn |
| 105 | } // namespace ns3 |