blob: 59f487694978899db7e7f6487898968be16700ac [file] [log] [blame]
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -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-fib-helper.hpp"
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070021
22#include "../tests-common.hpp"
23
24namespace ns3 {
25namespace ndn {
26
Alexander Afanasyev823368d2015-08-13 16:52:50 -070027BOOST_AUTO_TEST_SUITE(HelperNdnFibHelper)
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070028
Alexander Afanasyev823368d2015-08-13 16:52:50 -070029class AddRouteFixture : public ScenarioHelperWithCleanupFixture
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070030{
Alexander Afanasyev823368d2015-08-13 16:52:50 -070031public:
32 AddRouteFixture()
33 {
34 createTopology({
35 {"1", "2"}
36 });
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070037
Alexander Afanasyev823368d2015-08-13 16:52:50 -070038 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 Gaodd516fe2015-04-23 04:18:24 -070047
Alexander Afanasyev823368d2015-08-13 16:52:50 -070048 ~AddRouteFixture()
49 {
50 Simulator::Stop(Seconds(20.001));
51 Simulator::Run();
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070052
Alexander Afanasyev823368d2015-08-13 16:52:50 -070053 BOOST_CHECK_EQUAL(getFace("1", "2")->getFaceStatus().getNOutInterests(), 10);
54 BOOST_CHECK_EQUAL(getFace("1", "2")->getFaceStatus().getNInDatas(), 10);
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070055
Alexander Afanasyev823368d2015-08-13 16:52:50 -070056 BOOST_CHECK_EQUAL(getFace("2", "1")->getFaceStatus().getNInInterests(), 10);
57 BOOST_CHECK_EQUAL(getFace("2", "1")->getFaceStatus().getNOutDatas(), 10);
58 }
59};
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070060
Alexander Afanasyev823368d2015-08-13 16:52:50 -070061BOOST_FIXTURE_TEST_SUITE(AddRoute, AddRouteFixture)
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070062
Alexander Afanasyev823368d2015-08-13 16:52:50 -070063// static void
64// AddRoute(Ptr<Node> node, const Name& prefix, shared_ptr<Face> face, int32_t metric);
65BOOST_AUTO_TEST_CASE(Base)
66{
67 FibHelper::AddRoute(getNode("1"), Name("/prefix"), getFace("1", "2"), 1);
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -070068}
69
Alexander Afanasyev823368d2015-08-13 16:52:50 -070070
71// static void
72// AddRoute(const std::string& nodeName, const Name& prefix, uint32_t faceId, int32_t metric);
73BOOST_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);
80BOOST_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);
88BOOST_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);
95BOOST_AUTO_TEST_CASE(Helper4)
96{
97 FibHelper::AddRoute(getNode("1"), Name("/prefix"), getNode("2"), 10);
98}
99
100BOOST_AUTO_TEST_SUITE_END() // AddRoute
101
102BOOST_AUTO_TEST_SUITE_END() // HelperNdnFibHelper
Yuanzhi Gaodd516fe2015-04-23 04:18:24 -0700103
104} // namespace ndn
105} // namespace ns3