A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flent-application-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 NITK Surathkal
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Bhaskar Kataria <bhaskar.k7920@gmail.com>
7 * Tom Henderson <tomh@tomh.org>
8 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
9 */
10
11/*
12 This test suite executes independent, self-contained test cases for FlentApplication.
13 Each test case:
14 - Runs a specific Flent configuration (rrul, tcp_upload, tcp_download, ping).
15 - Writes a .flent output file to the runner-managed temporary directory.
16 - Verifies the File integrity of the generated JSON metadata.
17 - Asserts that the calculated metrics (throughput and/or ICMP latency) fall within expected
18 baseline bounds.
19 */
20
21#include "nlohmann/json.hpp"
22
23#include "ns3/application-container.h"
24#include "ns3/boolean.h"
25#include "ns3/config.h"
26#include "ns3/data-rate.h"
27#include "ns3/flent-helper.h"
28#include "ns3/internet-stack-helper.h"
29#include "ns3/ipv4-address-helper.h"
30#include "ns3/ipv4-global-routing-helper.h"
31#include "ns3/ipv4-interface-container.h"
32#include "ns3/net-device-container.h"
33#include "ns3/node-container.h"
34#include "ns3/nstime.h"
35#include "ns3/queue-disc-container.h"
36#include "ns3/queue-size.h"
37#include "ns3/simple-net-device-helper.h"
38#include "ns3/simulator.h"
39#include "ns3/string.h"
40#include "ns3/test.h"
41#include "ns3/traffic-control-helper.h"
42#include "ns3/uinteger.h"
43
44#include <fstream>
45
46using namespace ns3;
47
48/**
49 * @brief Base test class providing Flent file integrity verification.
50 */
51class FlentTestCase : public TestCase
52{
53 public:
54 /**
55 * @brief Constructor
56 * @param name The name of the test case
57 */
58 FlentTestCase(std::string name);
59
60 protected:
61 /**
62 * @brief Verifies the structural integrity of the generated JSON data.
63 * @param root The parsed JSON root object.
64 * @param filename The name of the file being verified.
65 */
66 void VerifyFlentFileIntegrity(const nlohmann::json& root, const std::string& filename);
67};
68
70 : TestCase(name)
71{
72}
73
74void
75FlentTestCase::VerifyFlentFileIntegrity(const nlohmann::json& root, const std::string& filename)
76{
77 auto itr_name = root.begin();
78 NS_TEST_ASSERT_MSG_EQ((itr_name++).key(),
79 "metadata",
80 "in file " + filename + " metadata not available");
81 NS_TEST_ASSERT_MSG_EQ((itr_name++).key(),
82 "raw_values",
83 "in file " + filename + " raw_values not available");
84 NS_TEST_ASSERT_MSG_EQ((itr_name++).key(),
85 "results",
86 "in file " + filename + " results not available");
87 NS_TEST_ASSERT_MSG_EQ((itr_name++).key(),
88 "version",
89 "in file " + filename + " version not available");
90 NS_TEST_ASSERT_MSG_EQ((itr_name).key(),
91 "x_values",
92 "in file " + filename + " x_values not available");
93
94 for (auto itrRawValues = root["raw_values"].begin(), itrResults = root["results"].begin();
95 itrRawValues != root["raw_values"].end();
96 itrRawValues++, itrResults++)
97 {
98 NS_TEST_ASSERT_MSG_EQ(itrRawValues.key(),
99 itrResults.key(),
100 filename + " number of results and raw values do not match");
101 NS_TEST_ASSERT_MSG_EQ(root["results"][itrResults.key()].size(),
102 root["x_values"].size(),
103 filename + " number of results and raw values does not match");
104 }
105}
106
107/**
108 * Flent rrul test: verifies test execution, metadata integrity, throughput limits, and ICMP latency
109 * limits.
110 */
112{
113 public:
115 ~FlentApplicationRrul() override;
116
117 private:
118 void DoRun() override;
119};
120
125
129
130void
132{
133 std::string testName = "rrul";
134 Time rtt = MilliSeconds(80);
135 DataRate bw("50Mbps");
136 Time length = Seconds(60);
137 Time delay = Seconds(0);
138
139 // 2 MB of TCP buffer
140 Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue(1 << 21));
141 Config::SetDefault("ns3::TcpSocket::SndBufSize", UintegerValue(1 << 21));
142 Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpCubic"));
143 Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1448));
144 Config::SetDefault("ns3::TcpSocketState::EnablePacing", BooleanValue(true));
145
147 n.Create(4); // client <-> router1 <-> router2 <-> server
148 // Create node containers for configuring individual links
149 NodeContainer n0; // Group the client and router1 together
150 n0.Add(n.Get(0));
151 n0.Add(n.Get(1));
152 NodeContainer n1; // Group the routers together
153 n1.Add(n.Get(1));
154 n1.Add(n.Get(2));
155 NodeContainer n2; // Group the router2 and server together
156 n2.Add(n.Get(2));
157 n2.Add(n.Get(3));
158
159 SimpleNetDeviceHelper deviceHelper;
160 DataRate edgeRate(100 * bw.GetBitRate());
161 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(edgeRate));
162 deviceHelper.SetDeviceAttribute("PointToPointMode", BooleanValue(true));
163 deviceHelper.SetChannelAttribute("Delay", TimeValue(MicroSeconds(1)));
164 deviceHelper.SetQueue("ns3::DropTailQueue", "MaxSize", StringValue("1p"));
165 NetDeviceContainer devices0;
166 devices0 = deviceHelper.Install(n0);
167 NetDeviceContainer devices2;
168 devices2 = deviceHelper.Install(n2);
169 // The middle link has the bandwidth and delay constraints
170 NetDeviceContainer devices1;
171 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(bw));
172 deviceHelper.SetChannelAttribute("Delay", TimeValue(rtt / 2));
173 devices1 = deviceHelper.Install(n1);
174
175 // Configure the IP and traffic control layers
177 stack.InstallAll();
178
180 tch.SetRootQueueDisc("ns3::FqCoDelQueueDisc");
181 Config::SetDefault("ns3::FqCoDelQueueDisc::MaxSize", QueueSizeValue(QueueSize("200p")));
182 tch.SetQueueLimits("ns3::DynamicQueueLimits"); // enable BQL
183 QueueDiscContainer qdiscs;
184 qdiscs = tch.Install(devices0);
185 qdiscs = tch.Install(devices1);
186 qdiscs = tch.Install(devices2);
187
188 Ipv4AddressHelper address;
189 address.SetBase("10.1.1.0", "255.255.255.0");
190 Ipv4InterfaceContainer interfaces0 = address.Assign(devices0);
191 address.NewNetwork();
192 Ipv4InterfaceContainer interfaces1 = address.Assign(devices1);
193 address.NewNetwork();
194 Ipv4InterfaceContainer interfaces2 = address.Assign(devices2);
195
197
198 std::string outputFile = CreateTempDirFilename("rrul.flent");
199
200 // Configure with the help of FlentHelper
201 FlentHelper flentHelper(testName, interfaces2.GetAddress(1));
202 flentHelper.SetAttribute("StartTime", TimeValue(delay));
203 flentHelper.SetAttribute("StepSize", TimeValue(Seconds(0.2)));
204 flentHelper.SetAttribute("Length", TimeValue(length));
205 flentHelper.SetAttribute("OutputFilename", StringValue(outputFile));
206
207 ApplicationContainer flent = flentHelper.Install(n.Get(0));
208 flent.Start(delay);
209 flent.Stop(delay + length + Seconds(10));
210
211 Simulator::Stop(delay + length + Seconds(10) + Seconds(1));
212
215
216 std::ifstream testFile(outputFile, std::ifstream::binary);
217 NS_TEST_ASSERT_MSG_EQ(testFile.is_open(), true, "rrul.flent was not created in temp dir");
218 nlohmann::json root;
219 testFile >> root;
220
221 VerifyFlentFileIntegrity(root, "rrul.flent");
222
223 int count = 0;
224 double throughput = 0.0;
225 double pingLatency = 0.0;
226
227 for (auto itrTcpDownload = root["results"]["TCP download BE"].begin();
228 itrTcpDownload != root["results"]["TCP download BE"].end();
229 itrTcpDownload++)
230 {
231 if (itrTcpDownload->is_null() || itrTcpDownload->get<double>() == 0.0)
232 {
233 continue;
234 }
235 count += 1;
236 throughput += itrTcpDownload->get<double>();
237 }
239 12,
240 "TCP Download BE throughput should be less than 12");
242 11,
243 "TCP Download BE throughput should be greater than 11");
244
245 count = 0;
246 throughput = 0.0;
247 for (auto itrTcpDownload = root["results"]["TCP download BK"].begin();
248 itrTcpDownload != root["results"]["TCP download BK"].end();
249 itrTcpDownload++)
250 {
251 if (itrTcpDownload->is_null() || itrTcpDownload->get<double>() == 0.0)
252 {
253 continue;
254 }
255 count += 1;
256 throughput += itrTcpDownload->get<double>();
257 }
259 12,
260 "TCP Download BK throughput should be less than 12");
262 11,
263 "TCP Download BK throughput should be greater than 11");
264
265 count = 0;
266 for (auto itrPing = root["results"]["Ping (ms) ICMP"].begin();
267 itrPing != root["results"]["Ping (ms) ICMP"].end();
268 itrPing++)
269 {
270 if (itrPing->is_null() || itrPing->get<double>() == 0.0)
271 {
272 continue;
273 }
274 count += 1;
275 pingLatency += itrPing->get<double>();
276 }
277 NS_TEST_ASSERT_MSG_LT(pingLatency / count, 84, "Ping latency should be less than 84");
278 NS_TEST_ASSERT_MSG_GT(pingLatency / count,
279 80,
280 "Ping latency throughput should be greater than 80");
281}
282
283/**
284 * Flent tcp_upload test: verifies test execution, metadata integrity, throughput limits, and ICMP
285 * latency limits.
286 */
288{
289 public:
292
293 private:
294 void DoRun() override;
295};
296
301
305
306void
308{
309 std::string testName = "tcp_upload";
310 Time rtt = MilliSeconds(80);
311 DataRate bw("50Mbps");
312 Time length = Seconds(60);
313 Time delay = Seconds(0);
314
315 // 2 MB of TCP buffer
316 Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue(1 << 21));
317 Config::SetDefault("ns3::TcpSocket::SndBufSize", UintegerValue(1 << 21));
318 Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpCubic"));
319 Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1448));
320 Config::SetDefault("ns3::TcpSocketState::EnablePacing", BooleanValue(true));
321
323 n.Create(4); // client <-> router1 <-> router2 <-> server
324 // Create node containers for configuring individual links
325 NodeContainer n0; // Group the client and router1 together
326 n0.Add(n.Get(0));
327 n0.Add(n.Get(1));
328 NodeContainer n1; // Group the routers together
329 n1.Add(n.Get(1));
330 n1.Add(n.Get(2));
331 NodeContainer n2; // Group the router2 and server together
332 n2.Add(n.Get(2));
333 n2.Add(n.Get(3));
334
335 SimpleNetDeviceHelper deviceHelper;
336 DataRate edgeRate(100 * bw.GetBitRate());
337 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(edgeRate));
338 deviceHelper.SetDeviceAttribute("PointToPointMode", BooleanValue(true));
339 deviceHelper.SetChannelAttribute("Delay", TimeValue(MicroSeconds(1)));
340 deviceHelper.SetQueue("ns3::DropTailQueue", "MaxSize", StringValue("1p"));
341 NetDeviceContainer devices0;
342 devices0 = deviceHelper.Install(n0);
343 NetDeviceContainer devices2;
344 devices2 = deviceHelper.Install(n2);
345 // The middle link has the bandwidth and delay constraints
346 NetDeviceContainer devices1;
347 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(bw));
348 deviceHelper.SetChannelAttribute("Delay", TimeValue(rtt / 2));
349 devices1 = deviceHelper.Install(n1);
350
351 // Configure the IP and traffic control layers
353 stack.InstallAll();
354
356 tch.SetRootQueueDisc("ns3::FqCoDelQueueDisc");
357 Config::SetDefault("ns3::FqCoDelQueueDisc::MaxSize", QueueSizeValue(QueueSize("200p")));
358 tch.SetQueueLimits("ns3::DynamicQueueLimits"); // enable BQL
359 QueueDiscContainer qdiscs;
360 qdiscs = tch.Install(devices0);
361 qdiscs = tch.Install(devices1);
362 qdiscs = tch.Install(devices2);
363
364 Ipv4AddressHelper address;
365 address.SetBase("10.1.1.0", "255.255.255.0");
366 Ipv4InterfaceContainer interfaces0 = address.Assign(devices0);
367 address.NewNetwork();
368 Ipv4InterfaceContainer interfaces1 = address.Assign(devices1);
369 address.NewNetwork();
370 Ipv4InterfaceContainer interfaces2 = address.Assign(devices2);
371
373
374 std::string outputFile = CreateTempDirFilename("tcp_upload.flent");
375
376 // Configure with the help of FlentHelper
377 FlentHelper flentHelper(testName, interfaces2.GetAddress(1));
378 flentHelper.SetAttribute("StartTime", TimeValue(delay));
379 flentHelper.SetAttribute("StepSize", TimeValue(Seconds(0.2)));
380 flentHelper.SetAttribute("Length", TimeValue(length));
381 flentHelper.SetAttribute("OutputFilename", StringValue(outputFile));
382
383 ApplicationContainer flent = flentHelper.Install(n.Get(0));
384 flent.Start(delay);
385 flent.Stop(delay + length + Seconds(10));
386
387 Simulator::Stop(delay + length + Seconds(10) + Seconds(1));
388
391
392 std::ifstream testFile(outputFile, std::ifstream::binary);
393 NS_TEST_ASSERT_MSG_EQ(testFile.is_open(), true, "tcp_upload.flent was not created in temp dir");
394 nlohmann::json root;
395 testFile >> root;
396
397 VerifyFlentFileIntegrity(root, "tcp_upload.flent");
398
399 int count = 0;
400 double throughput = 0.0;
401 double pingLatency = 0.0;
402
403 for (auto itr = root["results"]["TCP upload"].begin();
404 itr != root["results"]["TCP upload"].end();
405 itr++)
406 {
407 if (itr->is_null() || itr->get<double>() == 0.0)
408 {
409 continue;
410 }
411 count++;
412 throughput += itr->get<double>();
413 }
414 NS_TEST_ASSERT_MSG_LT(throughput / count, 50, "TCP upload throughput should be less than 50");
416 43,
417 "TCP upload throughput should be greater than 43");
418
419 count = 0;
420 for (auto itr = root["results"]["Ping (ms) ICMP"].begin();
421 itr != root["results"]["Ping (ms) ICMP"].end();
422 itr++)
423 {
424 if (itr->is_null() || itr->get<double>() == 0.0)
425 {
426 continue;
427 }
428 count++;
429 pingLatency += itr->get<double>();
430 }
431 NS_TEST_ASSERT_MSG_LT(pingLatency / count, 82, "Ping latency should be less than 82");
432 NS_TEST_ASSERT_MSG_GT(pingLatency / count, 80, "Ping latency should be greater than 80");
433}
434
435/**
436 * Flent tcp_download test: verifies test execution, metadata integrity, throughput limits, and ICMP
437 * latency limits.
438 */
440{
441 public:
444
445 private:
446 void DoRun() override;
447};
448
453
457
458void
460{
461 std::string testName = "tcp_download";
462 Time rtt = MilliSeconds(80);
463 DataRate bw("50Mbps");
464 Time length = Seconds(60);
465 Time delay = Seconds(0);
466
467 // 2 MB of TCP buffer
468 Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue(1 << 21));
469 Config::SetDefault("ns3::TcpSocket::SndBufSize", UintegerValue(1 << 21));
470 Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpCubic"));
471 Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1448));
472 Config::SetDefault("ns3::TcpSocketState::EnablePacing", BooleanValue(true));
473
475 n.Create(4); // client <-> router1 <-> router2 <-> server
476 // Create node containers for configuring individual links
477 NodeContainer n0; // Group the client and router1 together
478 n0.Add(n.Get(0));
479 n0.Add(n.Get(1));
480 NodeContainer n1; // Group the routers together
481 n1.Add(n.Get(1));
482 n1.Add(n.Get(2));
483 NodeContainer n2; // Group the router2 and server together
484 n2.Add(n.Get(2));
485 n2.Add(n.Get(3));
486
487 SimpleNetDeviceHelper deviceHelper;
488 DataRate edgeRate(100 * bw.GetBitRate());
489 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(edgeRate));
490 deviceHelper.SetDeviceAttribute("PointToPointMode", BooleanValue(true));
491 deviceHelper.SetChannelAttribute("Delay", TimeValue(MicroSeconds(1)));
492 deviceHelper.SetQueue("ns3::DropTailQueue", "MaxSize", StringValue("1p"));
493 NetDeviceContainer devices0;
494 devices0 = deviceHelper.Install(n0);
495 NetDeviceContainer devices2;
496 devices2 = deviceHelper.Install(n2);
497 // The middle link has the bandwidth and delay constraints
498 NetDeviceContainer devices1;
499 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(bw));
500 deviceHelper.SetChannelAttribute("Delay", TimeValue(rtt / 2));
501 devices1 = deviceHelper.Install(n1);
502
503 // Configure the IP and traffic control layers
505 stack.InstallAll();
506
508 tch.SetRootQueueDisc("ns3::FqCoDelQueueDisc");
509 Config::SetDefault("ns3::FqCoDelQueueDisc::MaxSize", QueueSizeValue(QueueSize("200p")));
510 tch.SetQueueLimits("ns3::DynamicQueueLimits"); // enable BQL
511 QueueDiscContainer qdiscs;
512 qdiscs = tch.Install(devices0);
513 qdiscs = tch.Install(devices1);
514 qdiscs = tch.Install(devices2);
515
516 Ipv4AddressHelper address;
517 address.SetBase("10.1.1.0", "255.255.255.0");
518 Ipv4InterfaceContainer interfaces0 = address.Assign(devices0);
519 address.NewNetwork();
520 Ipv4InterfaceContainer interfaces1 = address.Assign(devices1);
521 address.NewNetwork();
522 Ipv4InterfaceContainer interfaces2 = address.Assign(devices2);
523
525
526 std::string outputFile = CreateTempDirFilename("tcp_download.flent");
527
528 // Configure with the help of FlentHelper
529 FlentHelper flentHelper(testName, interfaces2.GetAddress(1));
530 flentHelper.SetAttribute("StartTime", TimeValue(delay));
531 flentHelper.SetAttribute("StepSize", TimeValue(Seconds(0.2)));
532 flentHelper.SetAttribute("Length", TimeValue(length));
533 flentHelper.SetAttribute("OutputFilename", StringValue(outputFile));
534
535 ApplicationContainer flent = flentHelper.Install(n.Get(0));
536 flent.Start(delay);
537 flent.Stop(delay + length + Seconds(10));
538
539 Simulator::Stop(delay + length + Seconds(10) + Seconds(1));
540
543
544 std::ifstream testFile(outputFile, std::ifstream::binary);
545 NS_TEST_ASSERT_MSG_EQ(testFile.is_open(),
546 true,
547 "tcp_download.flent was not created in temp dir");
548 nlohmann::json root;
549 testFile >> root;
550
551 VerifyFlentFileIntegrity(root, "tcp_download.flent");
552
553 int count = 0;
554 double throughput = 0.0;
555 double pingLatency = 0.0;
556
557 for (auto itr = root["results"]["TCP download"].begin();
558 itr != root["results"]["TCP download"].end();
559 itr++)
560 {
561 if (itr->is_null() || itr->get<double>() == 0.0)
562 {
563 continue;
564 }
565 count++;
566 throughput += itr->get<double>();
567 }
568 NS_TEST_ASSERT_MSG_LT(throughput / count, 50, "TCP Download throughput should be less than 50");
570 42,
571 "TCP Download throughput should be greater than 42");
572
573 count = 0;
574 for (auto itr = root["results"]["Ping (ms) ICMP"].begin();
575 itr != root["results"]["Ping (ms) ICMP"].end();
576 itr++)
577 {
578 if (itr->is_null() || itr->get<double>() == 0.0)
579 {
580 continue;
581 }
582 count++;
583 pingLatency += itr->get<double>();
584 }
585 NS_TEST_ASSERT_MSG_LT(pingLatency / count, 82, "Ping latency should be less than 82");
586 NS_TEST_ASSERT_MSG_GT(pingLatency / count, 80, "Ping latency should be greater than 80");
587}
588
589/**
590 * Flent ping test: verifies test execution, metadata integrity, throughput limits, and ICMP latency
591 * limits.
592 */
594{
595 public:
597 ~FlentApplicationPing() override;
598
599 private:
600 void DoRun() override;
601};
602
607
611
612void
614{
615 std::string testName = "ping";
616 Time rtt = MilliSeconds(80);
617 DataRate bw("50Mbps");
618 Time length = Seconds(60);
619 Time delay = Seconds(0);
620
621 // 2 MB of TCP buffer
622 Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue(1 << 21));
623 Config::SetDefault("ns3::TcpSocket::SndBufSize", UintegerValue(1 << 21));
624 Config::SetDefault("ns3::TcpL4Protocol::SocketType", StringValue("ns3::TcpCubic"));
625 Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(1448));
626 Config::SetDefault("ns3::TcpSocketState::EnablePacing", BooleanValue(true));
627
629 n.Create(4); // client <-> router1 <-> router2 <-> server
630 // Create node containers for configuring individual links
631 NodeContainer n0; // Group the client and router1 together
632 n0.Add(n.Get(0));
633 n0.Add(n.Get(1));
634 NodeContainer n1; // Group the routers together
635 n1.Add(n.Get(1));
636 n1.Add(n.Get(2));
637 NodeContainer n2; // Group the router2 and server together
638 n2.Add(n.Get(2));
639 n2.Add(n.Get(3));
640
641 SimpleNetDeviceHelper deviceHelper;
642 DataRate edgeRate(100 * bw.GetBitRate());
643 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(edgeRate));
644 deviceHelper.SetDeviceAttribute("PointToPointMode", BooleanValue(true));
645 deviceHelper.SetChannelAttribute("Delay", TimeValue(MicroSeconds(1)));
646 deviceHelper.SetQueue("ns3::DropTailQueue", "MaxSize", StringValue("1p"));
647 NetDeviceContainer devices0;
648 devices0 = deviceHelper.Install(n0);
649 NetDeviceContainer devices2;
650 devices2 = deviceHelper.Install(n2);
651 // The middle link has the bandwidth and delay constraints
652 NetDeviceContainer devices1;
653 deviceHelper.SetDeviceAttribute("DataRate", DataRateValue(bw));
654 deviceHelper.SetChannelAttribute("Delay", TimeValue(rtt / 2));
655 devices1 = deviceHelper.Install(n1);
656
657 // Configure the IP and traffic control layers
659 stack.InstallAll();
660
662 tch.SetRootQueueDisc("ns3::FqCoDelQueueDisc");
663 Config::SetDefault("ns3::FqCoDelQueueDisc::MaxSize", QueueSizeValue(QueueSize("200p")));
664 tch.SetQueueLimits("ns3::DynamicQueueLimits"); // enable BQL
665 QueueDiscContainer qdiscs;
666 qdiscs = tch.Install(devices0);
667 qdiscs = tch.Install(devices1);
668 qdiscs = tch.Install(devices2);
669
670 Ipv4AddressHelper address;
671 address.SetBase("10.1.1.0", "255.255.255.0");
672 Ipv4InterfaceContainer interfaces0 = address.Assign(devices0);
673 address.NewNetwork();
674 Ipv4InterfaceContainer interfaces1 = address.Assign(devices1);
675 address.NewNetwork();
676 Ipv4InterfaceContainer interfaces2 = address.Assign(devices2);
677
679
680 std::string outputFile = CreateTempDirFilename("ping.flent");
681
682 // Configure with the help of FlentHelper
683 FlentHelper flentHelper(testName, interfaces2.GetAddress(1));
684 flentHelper.SetAttribute("StartTime", TimeValue(delay));
685 flentHelper.SetAttribute("StepSize", TimeValue(Seconds(0.2)));
686 flentHelper.SetAttribute("Length", TimeValue(length));
687 flentHelper.SetAttribute("OutputFilename", StringValue(outputFile));
688
689 ApplicationContainer flent = flentHelper.Install(n.Get(0));
690 flent.Start(delay);
691 flent.Stop(delay + length + Seconds(10));
692
693 Simulator::Stop(delay + length + Seconds(10) + Seconds(1));
694
697
698 std::ifstream testFile(outputFile, std::ifstream::binary);
699 NS_TEST_ASSERT_MSG_EQ(testFile.is_open(), true, "ping.flent was not created in temp dir");
700 nlohmann::json root;
701 testFile >> root;
702
703 VerifyFlentFileIntegrity(root, "ping.flent");
704
705 int count = 0;
706 double pingLatency = 0.0;
707
708 for (auto itr = root["results"]["Ping (ms) ICMP"].begin();
709 itr != root["results"]["Ping (ms) ICMP"].end();
710 itr++)
711 {
712 if (itr->is_null() || itr->get<double>() == 0.0)
713 {
714 continue;
715 }
716 count++;
717 pingLatency += itr->get<double>();
718 }
719 NS_TEST_ASSERT_MSG_LT(pingLatency / count, 82, "Ping latency should be less than 82");
720 NS_TEST_ASSERT_MSG_GT(pingLatency / count, 80, "Ping latency should be greater than 80");
721}
722
723/**
724 * @ingroup applications
725 * @brief Flent Application Test Suite
726 */
728{
729 public:
730 /**
731 * @brief Constructor
732 */
734};
735
744
746 g_FlentApplicationTestSuite; //!< Static variable for test initialization
Flent ping test: verifies test execution, metadata integrity, throughput limits, and ICMP latency lim...
void DoRun() override
Implementation to actually run this TestCase.
Flent rrul test: verifies test execution, metadata integrity, throughput limits, and ICMP latency lim...
void DoRun() override
Implementation to actually run this TestCase.
Flent tcp_download test: verifies test execution, metadata integrity, throughput limits,...
void DoRun() override
Implementation to actually run this TestCase.
Flent tcp_upload test: verifies test execution, metadata integrity, throughput limits,...
void DoRun() override
Implementation to actually run this TestCase.
Flent Application Test Suite.
void VerifyFlentFileIntegrity(const nlohmann::json &root, const std::string &filename)
Verifies the structural integrity of the generated JSON data.
FlentTestCase(std::string name)
Constructor.
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Class for representing data rates.
Definition data-rate.h:78
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition data-rate.cc:201
A helper to make it easier to instantiate an ns3::FlentApplication.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
ApplicationContainer Install(Ptr< Node > node) const
Install an ns3::FlentApplication on the node configured with all the attributes set with SetAttribute...
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Holds a vector of ns3::QueueDisc pointers.
Class for representing queue sizes.
Definition queue-size.h:85
build a set of SimpleNetDevice objects
void SetQueue(std::string type, Ts &&... args)
Each net device must have a queue to pass packets through.
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:125
static void Run()
Run the simulation.
Definition simulator.cc:161
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:169
Hold variables of type string.
Definition string.h:45
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:296
@ EXTENSIVE
Medium length test.
Definition test.h:1058
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Definition test.cc:436
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
Type
Type of test.
Definition test.h:1271
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:494
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
uint16_t SetRootQueueDisc(const std::string &type, Args &&... args)
Helper function used to set a root queue disc of the given type and with the given attributes.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices.
Hold an unsigned integer type.
Definition uinteger.h:34
static FlentApplicationTestSuite g_FlentApplicationTestSuite
Static variable for test initialization.
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Definition test.h:698
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition test.h:133
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition test.h:863
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1347
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1313
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1330
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ofstream throughput