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 | |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 21 | #include "model/ndn-net-device-link-service.hpp" |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 22 | |
| 23 | #include "../tests-common.hpp" |
| 24 | |
| 25 | namespace ns3 { |
| 26 | namespace ndn { |
| 27 | |
Alexander Afanasyev | 91971b7 | 2015-08-13 16:53:37 -0700 | [diff] [blame] | 28 | BOOST_FIXTURE_TEST_SUITE(ModelNdnNetDeviceFace, ScenarioHelperWithCleanupFixture) |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | 91971b7 | 2015-08-13 16:53:37 -0700 | [diff] [blame] | 30 | BOOST_AUTO_TEST_CASE(Basic) |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 31 | { |
Alexander Afanasyev | 91971b7 | 2015-08-13 16:53:37 -0700 | [diff] [blame] | 32 | Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps")); |
| 33 | Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms")); |
| 34 | Config::SetDefault("ns3::DropTailQueue::MaxPackets", StringValue("20")); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 35 | |
Alexander Afanasyev | 91971b7 | 2015-08-13 16:53:37 -0700 | [diff] [blame] | 36 | createTopology({ |
| 37 | {"1", "2"}, |
Alexander Afanasyev | a9d889b | 2016-09-08 18:34:25 -0700 | [diff] [blame^] | 38 | }, false); |
| 39 | |
| 40 | getNetDevice("1", "2")->SetAttribute("Address", StringValue("00:00:00:ff:ff:01")); |
| 41 | getNetDevice("2", "1")->SetAttribute("Address", StringValue("00:00:00:ff:ff:02")); |
| 42 | |
| 43 | getStackHelper().InstallAll(); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 44 | |
Alexander Afanasyev | 91971b7 | 2015-08-13 16:53:37 -0700 | [diff] [blame] | 45 | addRoutes({ |
| 46 | {"1", "2", "/prefix", 1}, |
| 47 | }); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 48 | |
Alexander Afanasyev | 91971b7 | 2015-08-13 16:53:37 -0700 | [diff] [blame] | 49 | addApps({ |
| 50 | {"1", "ns3::ndn::ConsumerCbr", |
| 51 | {{"Prefix", "/prefix"}, {"Frequency", "10"}}, |
| 52 | "0s", "9.99s"}, |
| 53 | {"2", "ns3::ndn::Producer", |
| 54 | {{"Prefix", "/prefix"}, {"PayloadSize", "1024"}}, |
| 55 | "0s", "100s"} |
| 56 | }); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 57 | |
Spyridon Mastorakis | 1662253 | 2015-07-18 20:29:46 -0700 | [diff] [blame] | 58 | Simulator::Stop(Seconds(20.001)); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 59 | Simulator::Run(); |
| 60 | |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 61 | BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nOutInterests, 100); |
| 62 | BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nInData, 100); |
Spyridon Mastorakis | 1662253 | 2015-07-18 20:29:46 -0700 | [diff] [blame] | 63 | |
Xuxiang Tian | 9101873 | 2016-08-17 16:24:47 -0700 | [diff] [blame] | 64 | BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nInInterests, 100); |
| 65 | BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nOutData, 100); |
Alexander Afanasyev | a9d889b | 2016-09-08 18:34:25 -0700 | [diff] [blame^] | 66 | |
| 67 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(*getFace("1", "2")), "netdev://[00:00:00:ff:ff:01]"); |
| 68 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(*getFace("2", "1")), "netdev://[00:00:00:ff:ff:02]"); |
| 69 | |
| 70 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(getFace("1", "2")->getLocalUri()), "netdev://[00:00:00:ff:ff:01]"); |
| 71 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(getFace("1", "2")->getRemoteUri()), "netdev://[00:00:00:ff:ff:02]"); |
| 72 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(getFace("2", "1")->getLocalUri()), "netdev://[00:00:00:ff:ff:02]"); |
| 73 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(getFace("2", "1")->getRemoteUri()), "netdev://[00:00:00:ff:ff:01]"); |
Yuanzhi Gao | dd516fe | 2015-04-23 04:18:24 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | BOOST_AUTO_TEST_SUITE_END() |
| 77 | |
| 78 | } // namespace ndn |
| 79 | } // namespace ns3 |