blob: ae2dc8e68a817468b33bb8e3abd30f1d4d86b694 [file] [log] [blame]
Spyridon Mastorakis8a74d0c2016-12-07 14:34:07 -08001/* -*- 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 "utils/tracers/ndn-l3-rate-tracer.hpp"
21
22#include <boost/filesystem.hpp>
23#include <boost/test/output_test_stream.hpp>
24
25#include "../../tests-common.hpp"
26
27namespace ns3 {
28namespace ndn {
29
30const boost::filesystem::path TEST_TRACE = boost::filesystem::path(TEST_CONFIG_PATH) / "trace.txt";
31
32class L3RateTracerFixture : public ScenarioHelperWithCleanupFixture
33{
34public:
35 L3RateTracerFixture()
36 {
37 boost::filesystem::create_directories(TEST_CONFIG_PATH);
38
39 // setting default parameters for PointToPoint links and channels
40 Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps"));
41 Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms"));
Spyridon Mastorakisf98a3412017-10-30 11:47:58 -070042 Config::SetDefault("ns3::QueueBase::MaxPackets", UintegerValue(20));
Spyridon Mastorakis8a74d0c2016-12-07 14:34:07 -080043
44 createTopology({
45 {"1"},
46 });
47
48 addApps({
49 {"1", "ns3::ndn::ConsumerCbr",
50 {{"Prefix", "/prefix"}, {"Frequency", "1"}},
51 "0s", "0.9s"} // send just one packet
52 });
53 }
54
55 ~L3RateTracerFixture()
56 {
57 boost::filesystem::remove(TEST_TRACE);
58 L3RateTracer::Destroy(); // additional cleanup
59 }
60};
61
62BOOST_FIXTURE_TEST_SUITE(UtilsTracersNdnL3RateTracer, L3RateTracerFixture)
63
64BOOST_AUTO_TEST_CASE(NackTracing)
65{
66 NodeContainer nodes;
67 nodes.Add(getNode("1"));
68
69 L3RateTracer::Install(nodes, TEST_TRACE.string(), Seconds(1));
70
71 Simulator::Stop(Seconds(1.5));
72 Simulator::Run();
73
74 L3RateTracer::Destroy(); // to force log to be written
75
76 boost::test_tools::output_test_stream os(TEST_TRACE.string().c_str(), true);
77
78 os << "Time Node FaceId FaceDescr Type Packets Kilobytes PacketRaw KilobytesRaw\n";
79 BOOST_CHECK(os.match_pattern());
80
81 os << "1 1 1 internal:// InInterests 0 0 0 0\n"
82 << "1 1 1 internal:// OutInterests 0 0 0 0\n"
83 << "1 1 1 internal:// InData 0 0 0 0\n"
84 << "1 1 1 internal:// OutData 0 0 0 0\n"
85 << "1 1 1 internal:// InNacks 0 0 0 0\n"
86 << "1 1 1 internal:// OutNacks 0 0 0 0\n"
87 << "1 1 1 internal:// InSatisfiedInterests 0 0 0 0\n"
88 << "1 1 1 internal:// InTimedOutInterests 0 0 0 0\n"
89 << "1 1 1 internal:// OutSatisfiedInterests 2.4 0 3 0\n"
90 << "1 1 1 internal:// OutTimedOutInterests 0 0 0 0\n";
91 BOOST_CHECK(os.match_pattern());
92
93 os << "1 1 256 internal:// InInterests 0 0 0 0\n"
94 << "1 1 256 internal:// OutInterests 0 0 0 0\n"
95 << "1 1 256 internal:// InData 0 0 0 0\n"
96 << "1 1 256 internal:// OutData 0 0 0 0\n"
97 << "1 1 256 internal:// InNacks 0 0 0 0\n"
98 << "1 1 256 internal:// OutNacks 0 0 0 0\n"
99 << "1 1 256 internal:// InSatisfiedInterests 2.4 0 3 0\n"
100 << "1 1 256 internal:// InTimedOutInterests 0 0 0 0\n"
101 << "1 1 256 internal:// OutSatisfiedInterests 0 0 0 0\n"
102 << "1 1 256 internal:// OutTimedOutInterests 0 0 0 0\n";
103 BOOST_CHECK(os.match_pattern());
104
105 os << "1 1 257 appFace:// InInterests 0.8 0 1 0\n"
106 << "1 1 257 appFace:// OutInterests 0 0 0 0\n"
107 << "1 1 257 appFace:// InData 0 0 0 0\n"
108 << "1 1 257 appFace:// OutData 0 0 0 0\n"
109 << "1 1 257 appFace:// InNacks 0 0 0 0\n"
110 << "1 1 257 appFace:// OutNacks 0.8 0 1 0\n"
111 << "1 1 257 appFace:// InSatisfiedInterests 0 0 0 0\n"
112 << "1 1 257 appFace:// InTimedOutInterests 0 0 0 0\n"
113 << "1 1 257 appFace:// OutSatisfiedInterests 0 0 0 0\n"
114 << "1 1 257 appFace:// OutTimedOutInterests 0 0 0 0\n";
115 BOOST_CHECK(os.match_pattern());
116
Alexander Afanasyeve93e8b02018-05-08 20:10:01 -0400117 os << "1 1 -1 all SatisfiedInterests 2.4 0 3 0\n"
118 << "1 1 -1 all TimedOutInterests 0.8 0 1 0\n";
Spyridon Mastorakis8a74d0c2016-12-07 14:34:07 -0800119 BOOST_CHECK(os.match_pattern());
120}
121
122BOOST_AUTO_TEST_SUITE_END()
123
124} // namespace ndn
125} // namespace ns3