A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-deduplication-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 Universita' di Firenze
3 * Copyright (c) 2019 Caliola Engineering, LLC : RFC 6621 multicast packet de-duplication
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
8 * Modified (2019): Jared Dulmage <jared.dulmage@caliola.com>
9 * Tests dissemination of multicast packets across a mesh
10 * network to all nodes over multiple hops. Tests check
11 * the number of received packets and dropped packets
12 * with RFC 6621 de-duplication enabled or disabled.
13 */
14
15#include "ns3/boolean.h"
16#include "ns3/config.h"
17#include "ns3/double.h"
18#include "ns3/inet-socket-address.h"
19#include "ns3/internet-stack-helper.h"
20#include "ns3/ipv4-address-helper.h"
21#include "ns3/ipv4-l3-protocol.h"
22#include "ns3/ipv4-list-routing-helper.h"
23#include "ns3/ipv4-static-routing-helper.h"
24#include "ns3/ipv4-static-routing.h"
25#include "ns3/log.h"
26#include "ns3/names.h"
27#include "ns3/node.h"
28#include "ns3/random-variable-stream.h"
29#include "ns3/simple-channel.h"
30#include "ns3/simple-net-device-helper.h"
31#include "ns3/simple-net-device.h"
32#include "ns3/simulator.h"
33#include "ns3/socket.h"
34#include "ns3/string.h"
35#include "ns3/test.h"
36#include "ns3/traffic-control-layer.h"
37#include "ns3/udp-socket-factory.h"
38#include "ns3/udp-socket.h"
39#include "ns3/uinteger.h"
40
41#include <functional>
42#include <limits>
43#include <string>
44
45using namespace ns3;
46
47/**
48 * \ingroup internet-test
49 *
50 * \brief IPv4 Deduplication Test
51 *
52 * Tests topology:
53 *
54 * /---- B ----\
55 * A ---- | ---- D ---- E
56 * \---- C ----/
57 *
58 * This test case counts the number of packets received
59 * and dropped at each node across the topology. Every
60 * node is configured to forward the multicast packet
61 * which originates at node A.
62 *
63 * With RFC 6621 de-duplication enabled, one 1 packet
64 * is received while some number of duplicate relayed
65 * packets are dropped by RFC 6621 at each node.
66 *
67 * When RFC6621 is disabled, the original packet has TTL = 4.
68 * Multiple packets are received at each node and several packets
69 * are dropped due to TTL expiry at each node.
70 */
72{
73 /**
74 * \brief Send data.
75 * \param socket The sending socket.
76 * \param to Destination address.
77 */
78 void DoSendData(Ptr<Socket> socket, std::string to);
79 /**
80 * \brief Send data.
81 * \param socket The sending socket.
82 * \param packet The packet to send.
83 * \param to Destination address.
84 */
85 void DoSendPacket(Ptr<Socket> socket, Ptr<Packet> packet, std::string to);
86 /**
87 * \brief Send data.
88 * \param socket The sending socket.
89 * \param to Destination address.
90 */
91 void SendData(Ptr<Socket> socket, std::string to);
92
93 /**
94 * \brief Send data.
95 * \param socket The sending socket.
96 * \param packet The packet to send.
97 * \param to Destination address.
98 */
99 void SendPacket(Ptr<Socket> socket, Ptr<Packet> packet, std::string to);
100
101 /**
102 * \brief Check packet receptions
103 * \param name Node name
104 */
105 void CheckPackets(const std::string& name);
106
107 /**
108 * \brief Check packet drops
109 * \param name Node name
110 */
111 void CheckDrops(const std::string& name);
112
113 static const Time DELAY; //!< Channel delay
114
115 /**
116 * Creates the test name according to the parameters
117 * \param enable deduplication enabled
118 * \param expire expiration delay for duplicate cache entries
119 * \returns A string describing the test
120 */
121 static std::string MakeName(bool enable, Time expire);
122
123 /**
124 * Enum of test types
125 */
126 enum MODE
127 {
131 }; // enabled, but expiration time too low
132
133 MODE m_mode; //!< Test type
134 Time m_expire; //!< Expiration delay for duplicate cache entries
135 std::map<std::string, uint32_t>
136 m_packetCountMap; //!< map of received packets (node name, counter)
137 std::map<std::string, uint32_t>
138 m_dropCountMap; //!< map of received packets (node name, counter)
139
140 public:
141 void DoRun() override;
142
143 /**
144 * Constructor
145 * \param enable deduplication enabled
146 * \param expire expiration delay for duplicate cache entries
147 */
148 Ipv4DeduplicationTest(bool enable, Time expire = Seconds(1));
149
150 /**
151 * \brief Receive data.
152 * \param [in] socket The receive socket.
153 */
154 void ReceivePkt(Ptr<Socket> socket);
155
156 /**
157 * \brief Register dropped packet.
158 * \param [in] ipHeader IP header
159 * \param [in] packet Packet that was dropped
160 * \param [in] reason Reason for dropping packet
161 * \param [in] ipv4 Ipv4 instance
162 * \param [in] interface Interface number
163 */
164 void DropPkt(const Ipv4Header& ipHeader,
165 Ptr<const Packet> packet,
167 Ptr<Ipv4> ipv4,
168 uint32_t interface);
169};
170
172
174 : TestCase(MakeName(enable, expire)),
175 m_mode(ENABLED),
176 m_expire(expire)
177{
178 if (!enable)
179 {
181 }
182 else if (m_expire < DELAY)
183 {
185 }
186}
187
188void
190{
191 uint32_t availableData;
192 availableData = socket->GetRxAvailable();
193 Ptr<Packet> packet = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
194 NS_TEST_ASSERT_MSG_EQ(availableData,
195 packet->GetSize(),
196 "Received packet size is not equal to the Rx buffer size");
197
198 auto node = socket->GetNode();
199 std::string name = Names::FindName(node);
200 m_packetCountMap.insert({name, 0}); // only inserts when not there
201 ++m_packetCountMap[name];
202}
203
204void
206 Ptr<const Packet> packet,
208 Ptr<Ipv4> ipv4,
209 uint32_t interface)
210{
211 switch (m_mode)
212 {
213 case ENABLED:
214 NS_TEST_EXPECT_MSG_EQ(reason, Ipv4L3Protocol::DROP_DUPLICATE, "Wrong reason for drop");
215 break;
216 case DISABLED:
217 NS_TEST_EXPECT_MSG_EQ(reason, Ipv4L3Protocol::DROP_TTL_EXPIRED, "Wrong reason for drop");
218 break;
219 case DEGENERATE:
220 // reason can be either
221 break;
222 };
223 auto node = ipv4->GetNetDevice(interface)->GetNode();
224 std::string name = Names::FindName(node);
225 m_dropCountMap.insert({name, 0});
226 ++m_dropCountMap[name];
227}
228
229void
231{
232 SendPacket(socket, Create<Packet>(123), to);
233}
234
235void
237{
238 Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
239 NS_TEST_EXPECT_MSG_EQ(socket->SendTo(packet, 0, realTo), 123, "100");
240}
241
242void
244{
245 DoSendData(socket, to);
246}
247
248void
250{
251 Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
252 MilliSeconds(50),
254 this,
255 socket,
256 packet,
257 to);
258}
259
260std::string
262{
263 std::ostringstream oss;
264 oss << "IP v4 RFC 6621 De-duplication: ";
265 if (!enabled)
266 {
267 oss << "disabled";
268 }
269 else if (expire > DELAY)
270 {
271 oss << "enabled";
272 }
273 else
274 {
275 oss << "degenerate";
276 }
277 oss << ", expire = " << expire.ToDouble(Time::MS) << "ms";
278
279 return oss.str();
280}
281
282void
284{
285 // multicast target
286 const std::string targetAddr = "239.192.100.1";
287 Config::SetDefault("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection",
289 Config::SetDefault("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue(m_expire));
290
291 // Create topology
292
293 // Create nodes
294 auto nodes = NodeContainer();
295 nodes.Create(5);
296
297 // Name nodes
298 Names::Add("A", nodes.Get(0));
299 Names::Add("B", nodes.Get(1));
300 Names::Add("C", nodes.Get(2));
301 Names::Add("D", nodes.Get(3));
302 Names::Add("E", nodes.Get(4));
303
304 SimpleNetDeviceHelper simplenet;
305 auto devices = simplenet.Install(nodes);
306 // name devices
307 Names::Add("A/dev", devices.Get(0));
308 Names::Add("B/dev", devices.Get(1));
309 Names::Add("C/dev", devices.Get(2));
310 Names::Add("D/dev", devices.Get(3));
311 Names::Add("E/dev", devices.Get(4));
312
313 Ipv4ListRoutingHelper listRouting;
314 Ipv4StaticRoutingHelper staticRouting;
315 listRouting.Add(staticRouting, 0);
316
317 InternetStackHelper internet;
318 internet.SetIpv6StackInstall(false);
319 internet.SetIpv4ArpJitter(true);
320 internet.SetRoutingHelper(listRouting);
321 internet.Install(nodes);
322
323 Ipv4AddressHelper ipv4address;
324 ipv4address.SetBase("10.0.0.0", "255.255.255.0");
325 ipv4address.Assign(devices);
326
327 // add static routes for each node / device
328 auto diter = devices.Begin();
329 for (auto end = nodes.End(), iter = nodes.Begin(); iter != end; ++iter)
330 {
331 // route for forwarding
332 staticRouting.AddMulticastRoute(*iter,
334 targetAddr.c_str(),
335 *diter,
336 NetDeviceContainer(*diter));
337
338 // route for host
339 // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
340 //// Note: Multicast routes for outbound packets are stored in the
341 //// normal unicast table. An implication of this is that it is not
342 //// possible to source multicast datagrams on multiple interfaces.
343 //// This is a well-known property of sockets implementation on
344 //// many Unix variants.
345 //// So, we just log it and fall through to LookupStatic ()
346 auto ipv4 = (*iter)->GetObject<Ipv4>();
347 NS_TEST_ASSERT_MSG_EQ((bool)ipv4,
348 true,
349 "Node " << Names::FindName(*iter) << " does not have Ipv4 aggregate");
350 auto routing = staticRouting.GetStaticRouting(ipv4);
351 routing->AddHostRouteTo(targetAddr.c_str(), ipv4->GetInterfaceForDevice(*diter), 0);
352
353 ++diter;
354 }
355
356 // set the topology, by default fully-connected
357 auto channel = devices.Get(0)->GetChannel();
358 auto simplechannel = channel->GetObject<SimpleChannel>();
359 // ensure some time progress between re-transmissions
360 simplechannel->SetAttribute("Delay", TimeValue(DELAY));
361 simplechannel->BlackList(Names::Find<SimpleNetDevice>("A/dev"),
363 simplechannel->BlackList(Names::Find<SimpleNetDevice>("D/dev"),
365
366 simplechannel->BlackList(Names::Find<SimpleNetDevice>("A/dev"),
368 simplechannel->BlackList(Names::Find<SimpleNetDevice>("E/dev"),
370
371 simplechannel->BlackList(Names::Find<SimpleNetDevice>("B/dev"),
373 simplechannel->BlackList(Names::Find<SimpleNetDevice>("E/dev"),
375
376 simplechannel->BlackList(Names::Find<SimpleNetDevice>("C/dev"),
378 simplechannel->BlackList(Names::Find<SimpleNetDevice>("E/dev"),
380
381 // Create the UDP sockets
382 std::list<Ptr<Socket>> sockets;
383 for (auto end = nodes.End(), iter = nodes.Begin(); iter != end; ++iter)
384 {
385 auto SocketFactory = (*iter)->GetObject<UdpSocketFactory>();
386 auto socket = SocketFactory->CreateSocket();
387 socket->SetAllowBroadcast(true);
389 0,
390 "Could not bind socket for node " << Names::FindName(*iter));
391
392 auto udpSocket = socket->GetObject<UdpSocket>();
393 udpSocket->MulticastJoinGroup(0, Ipv4Address(targetAddr.c_str())); // future proof?
394 udpSocket->SetAttribute("IpMulticastTtl", StringValue("4"));
395
396 socket->SetRecvCallback(MakeCallback(&Ipv4DeduplicationTest::ReceivePkt, this));
397 sockets.push_back(socket);
398 }
399
400 // connect up drop traces
401 Config::ConnectWithoutContext("/NodeList/*/$ns3::Ipv4L3Protocol/Drop",
403
404 // start TX from A
405 auto txSocket = sockets.front();
406
407 // ------ Now the tests ------------
408
409 // Broadcast 1 packet
410 SendData(txSocket, targetAddr);
413
414 for (auto end = nodes.End(), iter = nodes.Begin(); iter != end; ++iter)
415 {
416 std::string name = Names::FindName(*iter);
417 CheckPackets(name);
418 CheckDrops(name);
419 }
420
421 m_packetCountMap.clear();
422 sockets.clear();
423 Names::Clear();
424}
425
426// NOTE:
427// The de-duplicate disabled received packets and drops can be
428// computed by forming the connectivity matrix C with 1's in
429// coordinates (row, column) where row and column nodes are connected.
430// Reception of packets with TTL n are v_(n-1) = v_n * C where
431// v_TTL = [1 0 0 0 0] (corresponding to nodes [A B C D E]).
432// The number of drops for each node is v_0 and the number of received
433// packets at each node is sum (v_TTL-1, ..., v_0).
434void
436{
437 // a priori determined packet receptions based on initial TTL of 4, disabled de-dup
438 std::map<std::string, uint32_t> packets = {
439 {"A", 14},
440 {"B", 16},
441 {"C", 16},
442 {"D", 16},
443 {"E", 4},
444 };
445
446 // a priori determined packet receptions based on
447 std::map<std::string, uint32_t> packetsDuped = {
448 {"A", 0},
449 {"B", 1},
450 {"C", 1},
451 {"D", 1},
452 {"E", 1},
453 };
454 // a priori determined packet receptions based on initial TTL of 4, degenerate de-dup
455 // There are TTL (4) rounds of packets. Each round a node will register a
456 // received packet if another connected node transmits. A misses the 1st round
457 // since it is the only one transmitting. D is not connected to A in 1st round
458 // either. E only hears a packet in the 3rd and 4th rounds.
459 std::map<std::string, uint32_t> degenerates = {
460 {"A", 3},
461 {"B", 4},
462 {"C", 4},
463 {"D", 3},
464 {"E", 2},
465 };
466
467 switch (m_mode)
468 {
469 case ENABLED:
471 packetsDuped[name],
472 "Wrong number of packets received for node " << name);
473 break;
474 case DISABLED:
476 packets[name],
477 "Wrong number of packets received for node " << name);
478 break;
479 case DEGENERATE:
481 degenerates[name],
482 "Wrong number of packets received for node " << name);
483 break;
484 };
485}
486
487void
488Ipv4DeduplicationTest::CheckDrops(const std::string& name)
489{
490 std::map<std::string, uint32_t> drops;
491 switch (m_mode)
492 {
493 case ENABLED:
494 // a priori determined packet drops based on initial TTL of 4, enabled de-dup;
495 // A hears from B & C -- > 2 drops
496 // D hears from B, C, AND E
497 // B (C) hears from A, C (B), D,
498 drops = {{"A", 2}, {"B", 2}, {"C", 2}, {"D", 2}, {"E", 0}};
499 break;
500 case DISABLED:
501 // a priori determined packet drops based on initial TTL of 4, disabled de-dup
502 drops = {{"A", 10}, {"B", 9}, {"C", 9}, {"D", 12}, {"E", 2}};
503 break;
504 case DEGENERATE:
505 // a priori determined packet drops based on initial TTL of 4, degenerate de-dup
506 // There are TTL (4) rounds of transmissions. Since all transmitters are
507 // synchronized, multiple packets are received each round when there are
508 // multiple transmitters. Only 1 packet per round is delivered, others are
509 // dropped. So this can be computed via "disabled" procedure described
510 // in check packets, but with only a 1 for each node in each round when packets
511 // are received. Drops are the sum of receptions using these indicator receive vectors
512 // subtracting 1 for each node (for the delivered packet) and adding 1
513 // at all nodes for TTL expiry.
514 drops = {{"A", 4}, {"B", 5}, {"C", 5}, {"D", 5}, {"E", 1}};
515 break;
516 }
517
518 if (drops[name])
519 {
521 true,
522 "No drops for node " << name);
524 drops[name],
525 "Wrong number of drops for node " << name);
526 }
527 else
528 {
530 true,
531 "Non-0 drops for node " << name);
532 }
533}
534
535/**
536 * \ingroup internet-test
537 *
538 * \brief IPv4 Deduplication TestSuite
539 */
541{
542 public:
544
545 private:
546};
547
549 : TestSuite("ipv4-deduplication", Type::UNIT)
550{
551 AddTestCase(new Ipv4DeduplicationTest(true), TestCase::Duration::QUICK);
552 AddTestCase(new Ipv4DeduplicationTest(false), TestCase::Duration::QUICK);
553 // degenerate case is enabled RFC but with too short an expiry
554 AddTestCase(new Ipv4DeduplicationTest(true, MicroSeconds(50)), TestCase::Duration::QUICK);
555}
556
558 g_ipv4DeduplicationTestSuite; //!< Static variable for test initialization
559
560/**
561 * \ingroup internet-test
562 *
563 * \brief IPv4 Deduplication Performance Test
564 *
565 * This test case sets up a fully connected network of
566 * 10 nodes. Each node transmits 2 packets / second
567 * for about 20 seconds. Packets are relayed from
568 * every receiver. The test outputs the number of
569 * events that have been processed during the course
570 * of the simulation. Test runtime is also a metric.
571 *
572 * The de-duplication cache entry expiration algorithm
573 * has evolved from an event-per-expiry (EPE) algorithm to
574 * a periodic event, batch purge (PBP) algorithm. The
575 * current metrics are taken from tests on the development
576 * box. Periodic batch purge period defaults to 1s.
577 *
578 * Events Runtime
579 * EVE 656140 29s
580 * PBP 337420 29s
581 *
582 */
584{
585 public:
587 void DoRun() override;
588
589 private:
590 std::vector<Ptr<Socket>> m_sockets; //!< sockets in use
591 std::vector<uint8_t> m_txPackets; //!< transmitted packets for each socket
592 uint8_t m_target; //!< number of packets to transmit on each socket
593
594 /**
595 * Send data
596 * \param socket output socket
597 * \param to destination address
598 * \param socketIndex index of the socket
599 */
600 void DoSendData(Ptr<Socket> socket, Address to, uint8_t socketIndex);
601};
602
604 : TestCase("Ipv4Deduplication performance test")
605{
606 m_target = 40;
607}
608
609void
611{
612 // multicast target
613 const std::string targetAddr = "239.192.100.1";
614 Config::SetDefault("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection", BooleanValue(true));
615 Config::SetDefault("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue(Time("10s")));
616
617 // Create nodes
618 auto nodes = NodeContainer();
619 nodes.Create(20);
620
621 SimpleNetDeviceHelper simplenet;
622 auto devices = simplenet.Install(nodes);
623
624 Ipv4ListRoutingHelper listRouting;
625 Ipv4StaticRoutingHelper staticRouting;
626 listRouting.Add(staticRouting, 0);
627
628 InternetStackHelper internet;
629 internet.SetIpv6StackInstall(false);
630 internet.SetIpv4ArpJitter(true);
631 internet.SetRoutingHelper(listRouting);
632 internet.Install(nodes);
633
634 Ipv4AddressHelper ipv4address;
635 ipv4address.SetBase("10.0.0.0", "255.255.255.0");
636 ipv4address.Assign(devices);
637
638 // add static routes for each node / device
639 auto diter = devices.Begin();
640 for (auto iter = nodes.Begin(); iter != nodes.End(); ++iter)
641 {
642 // route for forwarding
643 staticRouting.AddMulticastRoute(*iter,
645 targetAddr.c_str(),
646 *diter,
647 NetDeviceContainer(*diter));
648
649 // route for host
650 // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
651 //// Note: Multicast routes for outbound packets are stored in the
652 //// normal unicast table. An implication of this is that it is not
653 //// possible to source multicast datagrams on multiple interfaces.
654 //// This is a well-known property of sockets implementation on
655 //// many Unix variants.
656 //// So, we just log it and fall through to LookupStatic ()
657 auto ipv4 = (*iter)->GetObject<Ipv4>();
658 NS_TEST_ASSERT_MSG_EQ((bool)ipv4,
659 true,
660 "Node " << (*iter)->GetId() << " does not have Ipv4 aggregate");
661 auto routing = staticRouting.GetStaticRouting(ipv4);
662 routing->AddHostRouteTo(targetAddr.c_str(), ipv4->GetInterfaceForDevice(*diter), 0);
663
664 ++diter;
665 }
666
667 // Create the UDP sockets
670 Address to = InetSocketAddress(Ipv4Address(targetAddr.c_str()), 1234);
671 for (auto iter = nodes.Begin(); iter != nodes.End(); ++iter)
672 {
673 Ptr<SocketFactory> udpSocketFactory = (*iter)->GetObject<UdpSocketFactory>();
674 m_sockets.push_back(udpSocketFactory->CreateSocket());
675 m_txPackets.push_back(0);
676 }
677
678 for (uint32_t i = 0; i < nodes.GetN(); i++)
679 {
680 Simulator::ScheduleWithContext(m_sockets[i]->GetNode()->GetId(),
681 Seconds(4 + jitter->GetValue()),
683 this,
684 m_sockets[i],
685 to,
686 i);
687 }
688
690 NS_LOG_UNCOND("Executed " << Simulator::GetEventCount() << " events");
691
692 for (auto iter = m_sockets.begin(); iter != m_sockets.end(); iter++)
693 {
694 (*iter)->Close();
695 }
696
698}
699
700void
702{
703 socket->SendTo(Create<Packet>(512), 0, to);
704 if (m_txPackets[socketIndex] < m_target)
705 {
706 m_txPackets[socketIndex] += 1;
707 Simulator::ScheduleWithContext(m_sockets[socketIndex]->GetNode()->GetId(),
708 Seconds(.5),
710 this,
711 m_sockets[socketIndex],
712 to,
713 socketIndex);
714 }
715}
716
717/**
718 * \ingroup internet-test
719 *
720 * \brief IPv4 Deduplication Performance TestSuite
721 */
727
729 : TestSuite("ipv4-deduplication-performance", Type::PERFORMANCE)
730{
731 AddTestCase(new Ipv4DeduplicationPerformanceTest, TestCase::Duration::EXTENSIVE);
732}
733
735 g_ipv4DeduplicationPerformanceTestSuite; //!< Static variable for test initialization
IPv4 Deduplication Performance Test.
std::vector< Ptr< Socket > > m_sockets
sockets in use
uint8_t m_target
number of packets to transmit on each socket
void DoRun() override
Implementation to actually run this TestCase.
void DoSendData(Ptr< Socket > socket, Address to, uint8_t socketIndex)
Send data.
std::vector< uint8_t > m_txPackets
transmitted packets for each socket
IPv4 Deduplication Performance TestSuite.
IPv4 Deduplication Test.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Ipv4DeduplicationTest(bool enable, Time expire=Seconds(1))
Constructor.
std::map< std::string, uint32_t > m_dropCountMap
map of received packets (node name, counter)
void CheckDrops(const std::string &name)
Check packet drops.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
Time m_expire
Expiration delay for duplicate cache entries.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void DoRun() override
Implementation to actually run this TestCase.
static const Time DELAY
Channel delay.
static std::string MakeName(bool enable, Time expire)
Creates the test name according to the parameters.
void DoSendPacket(Ptr< Socket > socket, Ptr< Packet > packet, std::string to)
Send data.
void DropPkt(const Ipv4Header &ipHeader, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
Register dropped packet.
std::map< std::string, uint32_t > m_packetCountMap
map of received packets (node name, counter)
void SendPacket(Ptr< Socket > socket, Ptr< Packet > packet, std::string to)
Send data.
void CheckPackets(const std::string &name)
Check packet receptions.
IPv4 Deduplication TestSuite.
a polymophic address class
Definition address.h:90
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
Packet header for IPv4.
Definition ipv4-header.h:23
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
DropReason
Reason why a packet has been dropped.
@ DROP_DUPLICATE
Duplicate packet received.
@ DROP_TTL_EXPIRED
Packet TTL has expired.
Helper class that adds ns3::Ipv4ListRouting objects.
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
void AddMulticastRoute(Ptr< Node > n, Ipv4Address source, Ipv4Address group, Ptr< NetDevice > input, NetDeviceContainer output)
Add a multicast route to a node and net device using explicit Ptr<Node> and Ptr<NetDevice>
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
Definition names.cc:764
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition names.h:443
static void Clear()
Clear the list of objects associated with names.
Definition names.cc:832
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and,...
Definition names.cc:818
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition object.h:511
Smart pointer class similar to boost::intrusive_ptr.
A simple channel, for simple things and testing.
build a set of SimpleNetDevice objects
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:131
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition simulator.h:577
static void Run()
Run the simulation.
Definition simulator.cc:167
static uint64_t GetEventCount()
Get the number of events executed.
Definition simulator.cc:313
Object to create transport layer instances that provide a socket API to applications.
virtual Ptr< Socket > CreateSocket()=0
Hold variables of type string.
Definition string.h:45
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
@ MS
millisecond
Definition nstime.h:106
double ToDouble(Unit unit) const
Get the Time value expressed in a particular unit.
Definition nstime.h:562
API to create UDP socket instances.
(abstract) base class of all UdpSockets
Definition udp-socket.h:37
virtual int MulticastJoinGroup(uint32_t interface, const Address &groupAddress)=0
Corresponds to socket option MCAST_JOIN_GROUP.
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:883
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition config.cc:943
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
#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:134
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition test.h:241
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Definition test.h:554
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1332
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
static Ipv4DeduplicationPerformanceTestSuite g_ipv4DeduplicationPerformanceTestSuite
Static variable for test initialization.
static Ipv4DeduplicationTestSuite g_ipv4DeduplicationTestSuite
Static variable for test initialization.
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684