A Discrete-Event Network Simulator
API
ipv4-deduplication-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Universita' di Firenze
4  * Copyright (c) 2019 Caliola Engineering, LLC : RFC 6621 multicast packet de-duplication
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
20  * Modified (2019): Jared Dulmage <jared.dulmage@caliola.com>
21  * Tests dissemination of multicast packets across a mesh
22  * network to all nodes over multiple hops. Tests check
23  * the number of received packets and dropped packets
24  * with RFC 6621 de-duplication enabled or disabled.
25  */
26 
27 #include "ns3/test.h"
28 #include "ns3/simulator.h"
29 #include "ns3/simple-channel.h"
30 #include "ns3/simple-net-device.h"
31 #include "ns3/socket.h"
32 #include "ns3/boolean.h"
33 #include "ns3/double.h"
34 #include "ns3/uinteger.h"
35 #include "ns3/string.h"
36 #include "ns3/config.h"
37 
38 #include "ns3/names.h"
39 #include "ns3/log.h"
40 #include "ns3/node.h"
41 #include "ns3/inet-socket-address.h"
42 #include "ns3/random-variable-stream.h"
43 
44 #include "ns3/ipv4-l3-protocol.h"
45 #include "ns3/ipv4-static-routing.h"
46 #include "ns3/udp-socket-factory.h"
47 #include "ns3/udp-socket.h"
48 #include "ns3/internet-stack-helper.h"
49 #include "ns3/ipv4-list-routing-helper.h"
50 #include "ns3/ipv4-static-routing-helper.h"
51 #include "ns3/ipv4-address-helper.h"
52 #include "ns3/simple-net-device-helper.h"
53 
54 #include "ns3/traffic-control-layer.h"
55 
56 #include <string>
57 #include <limits>
58 #include <functional>
59 
60 using namespace ns3;
61 
88 {
94  void DoSendData (Ptr<Socket> socket, std::string to);
101  void DoSendPacket (Ptr<Socket> socket, Ptr<Packet> packet, std::string to);
107  void SendData (Ptr<Socket> socket, std::string to);
108 
115  void SendPacket (Ptr<Socket> socket, Ptr<Packet> packet, std::string to);
116 
121  void CheckPackets (const std::string &name);
122 
127  void CheckDrops (const std::string &name);
128 
129  static const Time DELAY;
130  static std::string MakeName (bool enable, Time expire);
131 
132  enum MODE {ENABLED = 0,
134  DEGENERATE}; // enabled, but expiration time too low
137  std::map<std::string, uint32_t> m_packetCountMap;
138  std::map<std::string, uint32_t> m_dropCountMap;
139 
140 public:
141  virtual void DoRun (void);
142  Ipv4DeduplicationTest (bool enable, Time expire = Seconds (1));
143 
148  void ReceivePkt (Ptr<Socket> socket);
149 
158  void DropPkt (const Ipv4Header &ipHeader,
160  Ptr<Ipv4> ipv4, uint32_t interface);
161 };
162 
163 const Time
165 
167  : TestCase (MakeName (enable, expire))
168  , m_mode (ENABLED)
169  , m_expire (expire)
170 {
171  if (!enable)
172  {
173  m_mode = DISABLED;
174  }
175  else if (m_expire < DELAY)
176  {
177  m_mode = DEGENERATE;
178  }
179 }
180 
182 {
183  uint32_t availableData;
184  availableData = socket->GetRxAvailable ();
185  Ptr<Packet> packet = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
186  NS_ASSERT (availableData == packet->GetSize ());
187 
188  auto node = socket->GetNode ();
189  std::string name = Names::FindName (node);
190  m_packetCountMap.insert ({name, 0}); // only inserts when not there
191  ++m_packetCountMap[name];
192 }
193 
194 void
197  Ptr<Ipv4> ipv4, uint32_t interface)
198 {
199  switch (m_mode)
200  {
201  case ENABLED:
202  NS_TEST_EXPECT_MSG_EQ (reason, Ipv4L3Protocol::DROP_DUPLICATE, "Wrong reason for drop");
203  break;
204  case DISABLED:
205  NS_TEST_EXPECT_MSG_EQ (reason, Ipv4L3Protocol::DROP_TTL_EXPIRED, "Wrong reason for drop");
206  break;
207  case DEGENERATE:
208  // reason can be either
209  break;
210  };
211  auto node = ipv4->GetNetDevice (interface)->GetNode ();
212  std::string name = Names::FindName (node);
213  m_dropCountMap.insert ({name, 0});
214  ++m_dropCountMap[name];
215 }
216 
217 void
219 {
220  SendPacket (socket, Create<Packet> (123), to);
221 }
222 
223 void
225 {
226  Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 1234);
227  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (packet, 0, realTo), 123, "100");
228 }
229 
230 void
232 {
233  DoSendData(socket, to);
234 }
235 
236 void
238 {
239  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), MilliSeconds (50),
240  &Ipv4DeduplicationTest::DoSendPacket, this, socket, packet, to);
241 }
242 
243 std::string
244 Ipv4DeduplicationTest::MakeName (bool enabled, Time expire)
245 {
246  std::ostringstream oss;
247  oss << "IP v4 RFC 6621 De-duplication: ";
248  if (!enabled)
249  {
250  oss << "disabled";
251  }
252  else if (expire > DELAY)
253  {
254  oss << "enabled";
255  }
256  else
257  {
258  oss << "degenerate";
259  }
260  oss << ", expire = " << expire.ToDouble (Time::MS) << "ms";
261 
262  return oss.str ();
263 }
264 
265 void
267 {
268  // multicast target
269  const std::string targetAddr = "239.192.100.1";
270  Config::SetDefault ("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection", BooleanValue (m_mode != DISABLED));
271  Config::SetDefault ("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue (m_expire));
272 
273  // Create topology
274 
275  // Create nodes
276  auto nodes = NodeContainer ();
277  nodes.Create (5);
278 
279  // Name nodes
280  Names::Add ("A", nodes.Get (0));
281  Names::Add ("B", nodes.Get (1));
282  Names::Add ("C", nodes.Get (2));
283  Names::Add ("D", nodes.Get (3));
284  Names::Add ("E", nodes.Get (4));
285 
286  SimpleNetDeviceHelper simplenet;
287  auto devices = simplenet.Install (nodes);
288  // name devices
289  Names::Add ("A/dev", devices.Get (0));
290  Names::Add ("B/dev", devices.Get (1));
291  Names::Add ("C/dev", devices.Get (2));
292  Names::Add ("D/dev", devices.Get (3));
293  Names::Add ("E/dev", devices.Get (4));
294 
295  Ipv4ListRoutingHelper listRouting;
296  Ipv4StaticRoutingHelper staticRouting;
297  listRouting.Add (staticRouting, 0);
298 
299  InternetStackHelper internet;
300  internet.SetIpv6StackInstall (false);
301  internet.SetIpv4ArpJitter (true);
302  internet.SetRoutingHelper (listRouting);
303  internet.Install (nodes);
304 
305  Ipv4AddressHelper ipv4address;
306  ipv4address.SetBase ("10.0.0.0", "255.255.255.0");
307  ipv4address.Assign (devices);
308 
309  // add static routes for each node / device
310  auto diter = devices.Begin ();
311  for (auto end = nodes.End (),
312  iter = nodes.Begin (); iter != end; ++iter)
313  {
314  // route for forwarding
315  staticRouting.AddMulticastRoute (*iter, Ipv4Address::GetAny (), targetAddr.c_str (), *diter, NetDeviceContainer (*diter));
316 
317  // route for host
318  // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
325  auto ipv4 = (*iter)->GetObject <Ipv4> ();
326  NS_ASSERT_MSG ((bool) ipv4, "Node " << Names::FindName (*iter) << " does not have Ipv4 aggregate");
327  auto routing = staticRouting.GetStaticRouting (ipv4);
328  routing->AddHostRouteTo (targetAddr.c_str (), ipv4->GetInterfaceForDevice (*diter), 0);
329 
330  ++diter;
331  }
332 
333  // set the topology, by default fully-connected
334  auto channel = devices.Get (0)->GetChannel ();
335  auto simplechannel = channel->GetObject <SimpleChannel> ();
336  // ensure some time progress between re-transmissions
337  simplechannel->SetAttribute ("Delay", TimeValue (DELAY));
338  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("A/dev"), Names::Find <SimpleNetDevice> ("D/dev"));
339  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("D/dev"), Names::Find <SimpleNetDevice> ("A/dev"));
340 
341  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("A/dev"), Names::Find <SimpleNetDevice> ("E/dev"));
342  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("E/dev"), Names::Find <SimpleNetDevice> ("A/dev"));
343 
344  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("B/dev"), Names::Find <SimpleNetDevice> ("E/dev"));
345  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("E/dev"), Names::Find <SimpleNetDevice> ("B/dev"));
346 
347  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("C/dev"), Names::Find <SimpleNetDevice> ("E/dev"));
348  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("E/dev"), Names::Find <SimpleNetDevice> ("C/dev"));
349 
350  // Create the UDP sockets
351  std::list<Ptr<Socket> > sockets;
352  for (auto end = nodes.End (),
353  iter = nodes.Begin (); iter != end; ++iter)
354  {
355  auto SocketFactory = (*iter)->GetObject<UdpSocketFactory> ();
356  auto socket = SocketFactory->CreateSocket ();
357  socket->SetAllowBroadcast (true);
358  NS_TEST_EXPECT_MSG_EQ (socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 1234)), 0,
359  "Could not bind socket for node " << Names::FindName (*iter));
360 
361  auto udpSocket = socket->GetObject<UdpSocket> ();
362  udpSocket->MulticastJoinGroup (0, Ipv4Address (targetAddr.c_str ())); // future proof?
363  udpSocket->SetAttribute ("IpMulticastTtl", StringValue ("4"));
364 
365  socket->SetRecvCallback (MakeCallback (&Ipv4DeduplicationTest::ReceivePkt, this));
366  sockets.push_back (socket);
367  }
368 
369  // connect up drop traces
370  Config::ConnectWithoutContext ("/NodeList/*/$ns3::Ipv4L3Protocol/Drop",
372 
373  // start TX from A
374  auto txSocket = sockets.front ();
375 
376  // ------ Now the tests ------------
377 
378  // Broadcast 1 packet
379  SendData (txSocket, targetAddr);
380  Simulator::Run ();
381  Simulator::Destroy ();
382 
383  for (auto end = nodes.End (),
384  iter = nodes.Begin (); iter != end; ++iter)
385  {
386  std::string name = Names::FindName (*iter);
387  CheckPackets (name);
388  CheckDrops (name);
389  }
390 
391  m_packetCountMap.clear ();
392  sockets.clear ();
393  Names::Clear ();
394 }
395 
396 // NOTE:
397 // The de-duplicate disabled received packets and drops can be
398 // computed by forming the connectivity matrix C with 1's in
399 // coordinates (row, column) where row and column nodes are connected.
400 // Reception of packets with TTL n are v_(n-1) = v_n * C where
401 // v_TTL = [1 0 0 0 0] (corresponding to nodes [A B C D E]).
402 // The number of drops for each node is v_0 and the number of received
403 // packets at each node is sum (v_TTL-1, ..., v_0).
404 void
405 Ipv4DeduplicationTest::CheckPackets (const std::string &name)
406 {
407  // a priori determined packet receptions based on initial TTL of 4, disabled de-dup
408  std::map <std::string, uint32_t> packets = {
409  {"A", 14}, {"B", 16}, {"C", 16}, {"D", 16}, {"E", 4}
410  };
411  // a priori determined packet receptions based on initial TTL of 4, degenerate de-dup
412  // There are TTL (4) rounds of packets. Each round a node will register a
413  // received packet if another connected node transmits. A misses the 1st round
414  // since it is the only one transmitting. D is not connected to A in 1st round
415  // either. E only hears a packet in the 3rd and 4th rounds.
416  std::map <std::string, uint32_t> degenerates = {
417  {"A", 3}, {"B", 4}, {"C", 4}, {"D", 3}, {"E", 2}
418  };
419 
420  NS_TEST_ASSERT_MSG_NE ((m_packetCountMap.find (name) == m_packetCountMap.end ()), true,
421  "No packets received for node " << name);
422  switch (m_mode)
423  {
424  case ENABLED:
425  NS_TEST_EXPECT_MSG_EQ (m_packetCountMap[name], 1, "Wrong number of packets received for node " << name);
426  break;
427  case DISABLED:
428  NS_TEST_EXPECT_MSG_EQ (m_packetCountMap[name], packets[name], "Wrong number of packets received for node " << name);
429  break;
430  case DEGENERATE:
431  NS_TEST_EXPECT_MSG_EQ (m_packetCountMap[name], degenerates[name], "Wrong number of packets received for node " << name);
432  break;
433  };
434 }
435 
436 void
437 Ipv4DeduplicationTest::CheckDrops (const std::string &name)
438 {
439  std::map <std::string, uint32_t> drops;
440  switch (m_mode)
441  {
442  case ENABLED:
443  // a priori determined packet drops based on initial TTL of 4, enabled de-dup;
444  // A hears from B & C
445  // D hears from B, C, AND E
446  // B (C) hears from A, C (B), D, and A again
447  drops = {{"A", 1}, {"B", 3}, {"C", 3}, {"D", 2}, {"E", 0}};
448  break;
449  case DISABLED:
450  // a priori determined packet drops based on initial TTL of 4, disabled de-dup
451  drops = {{"A", 10}, {"B", 9}, {"C", 9}, {"D", 12}, {"E", 2}};
452  break;
453  case DEGENERATE:
454  // a priori determined packet drops based on initial TTL of 4, degenerate de-dup
455  // There are TTL (4) rounds of transmissions. Since all transmitters are
456  // synchronized, multiple packets are received each round when there are
457  // multiple transmitters. Only 1 packet per round is delivered, others are
458  // dropped. So this can be computed via "disabled" procedure described
459  // in check packets, but with only a 1 for each node in each round when packets
460  // are received. Drops are the sum of receptions using these indicator receive vectors
461  // subtracting 1 for each node (for the delivered packet) and adding 1
462  // at all nodes for TTL expiry.
463  drops = {{"A", 4}, {"B", 5}, {"C", 5}, {"D", 5}, {"E", 1}};
464  break;
465  }
466 
467  if (drops[name])
468  {
469  NS_TEST_ASSERT_MSG_NE ((m_dropCountMap.find (name) == m_dropCountMap.end ()), true, "No drops for node " << name);
470  NS_TEST_EXPECT_MSG_EQ (m_dropCountMap[name], drops[name], "Wrong number of drops for node " << name);
471  }
472  else
473  {
474  NS_TEST_EXPECT_MSG_EQ ((m_dropCountMap.find (name) == m_dropCountMap.end ()), true, "Non-0 drops for node " << name);
475  }
476 }
477 
485 {
486 public:
488 private:
489 };
490 
492  : TestSuite ("ipv4-deduplication", UNIT)
493 {
494 
495  AddTestCase (new Ipv4DeduplicationTest (true), TestCase::QUICK);
496  AddTestCase (new Ipv4DeduplicationTest (false), TestCase::QUICK);
497  // degenerate case is enabled RFC but with too short an expiry
498  AddTestCase (new Ipv4DeduplicationTest (true, MicroSeconds (50)), TestCase::QUICK);
499 }
500 
502 
503 
504 
530 {
531  public:
533  virtual void DoRun (void);
534  private:
535  std::vector <Ptr<Socket> > m_sockets;
536  std::vector <uint8_t> m_txPackets;
537  uint8_t m_target;
538  void DoSendData (Ptr<Socket> socket, Address to, uint8_t socketIndex);
539 };
540 
542  : TestCase ("Ipv4Deduplication performance test")
543 {
544  m_target = 40;
545 }
546 
547 void
549 {
550  // multicast target
551  const std::string targetAddr = "239.192.100.1";
552  Config::SetDefault ("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection", BooleanValue (true));
553  Config::SetDefault ("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue (Time ("10s")));
554 
555  // Create nodes
556  auto nodes = NodeContainer ();
557  nodes.Create (20);
558 
559  SimpleNetDeviceHelper simplenet;
560  auto devices = simplenet.Install (nodes);
561 
562  Ipv4ListRoutingHelper listRouting;
563  Ipv4StaticRoutingHelper staticRouting;
564  listRouting.Add (staticRouting, 0);
565 
566  InternetStackHelper internet;
567  internet.SetIpv6StackInstall (false);
568  internet.SetIpv4ArpJitter (true);
569  internet.SetRoutingHelper (listRouting);
570  internet.Install (nodes);
571 
572  Ipv4AddressHelper ipv4address;
573  ipv4address.SetBase ("10.0.0.0", "255.255.255.0");
574  ipv4address.Assign (devices);
575 
576  // add static routes for each node / device
577  auto diter = devices.Begin ();
578  for (auto iter = nodes.Begin (); iter != nodes.End (); ++iter)
579  {
580  // route for forwarding
581  staticRouting.AddMulticastRoute (*iter, Ipv4Address::GetAny (), targetAddr.c_str (), *diter, NetDeviceContainer (*diter));
582 
583  // route for host
584  // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
591  auto ipv4 = (*iter)->GetObject <Ipv4> ();
592  NS_ASSERT_MSG ((bool) ipv4, "Node " << (*iter)->GetId () << " does not have Ipv4 aggregate");
593  auto routing = staticRouting.GetStaticRouting (ipv4);
594  routing->AddHostRouteTo (targetAddr.c_str (), ipv4->GetInterfaceForDevice (*diter), 0);
595 
596  ++diter;
597  }
598 
599 
600  // Create the UDP sockets
601  Ptr<UniformRandomVariable> jitter = CreateObjectWithAttributes <UniformRandomVariable> ("Max", DoubleValue (4));
602  Address to = InetSocketAddress (Ipv4Address (targetAddr.c_str ()), 1234);
603  for (auto iter = nodes.Begin (); iter != nodes.End (); ++iter)
604  {
605  Ptr<SocketFactory> udpSocketFactory = (*iter)->GetObject<UdpSocketFactory> ();
606  m_sockets.push_back (udpSocketFactory->CreateSocket ());
607  m_txPackets.push_back (0);
608  }
609 
610  for (uint8_t i = 0; i<nodes.GetN (); i++)
611  {
612  Simulator::ScheduleWithContext (m_sockets[i]->GetNode ()->GetId (), Seconds (4+Seconds(jitter->GetValue ())),
614  }
615 
616  Simulator::Run ();
617  NS_LOG_UNCOND ("Executed " << Simulator::GetEventCount () << " events");
618 
619  for (auto iter = m_sockets.begin (); iter != m_sockets.end (); iter++)
620  {
621  (*iter)->Close ();
622  }
623 
624  Simulator::Destroy ();
625 }
626 
627 void
629 {
630  socket->SendTo (Create<Packet> (512), 0, to);
631  if (m_txPackets[socketIndex] < m_target)
632  {
633  m_txPackets[socketIndex] += 1;
634  Simulator::ScheduleWithContext (m_sockets[socketIndex]->GetNode ()->GetId (), Seconds (.5),
635  &Ipv4DeduplicationPerformanceTest::DoSendData, this, m_sockets[socketIndex], to, socketIndex);
636  }
637 }
638 
639 
647 {
648 public:
650 };
651 
653  : TestSuite ("ipv4-deduplication-performance", PERFORMANCE)
654 {
655  AddTestCase (new Ipv4DeduplicationPerformanceTest, TestCase::EXTENSIVE);
656 }
657 
(abstract) base class of all UdpSockets
Definition: udp-socket.h:47
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
an Inet address class
Ipv4DeduplicationTest(bool enable, Time expire=Seconds(1))
AttributeValue implementation for Boolean.
Definition: boolean.h:36
uint32_t GetId(void) const
Definition: node.cc:107
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
Hold variables of type string.
Definition: string.h:41
void SetIpv4ArpJitter(bool enable)
Enable/disable IPv4 ARP Jitter.
A suite of tests to run.
Definition: test.h:1343
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
aggregate IP/TCP/UDP functionality to existing Nodes.
#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:283
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:511
virtual Ptr< Socket > CreateSocket(void)=0
void DoSendData(Ptr< Socket > socket, Address to, uint8_t socketIndex)
encapsulates test code
Definition: test.h:1153
virtual Ptr< NetDevice > GetNetDevice(uint32_t interface)=0
Object to create transport layer instances that provide a socket API to applications.
a polymophic address class
Definition: address.h:90
channel
Definition: third.py:92
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> ...
DropReason
Reason why a packet has been dropped.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Packet header for IPv4.
Definition: ipv4-header.h:33
static Ipv4DeduplicationTestSuite g_ipv4DeduplicationTestSuite
Static variable for test initialization.
static Ipv4DeduplicationPerformanceTestSuite g_ipv4DeduplicationPerformanceTestSuite
Static variable for test initialization.
virtual int MulticastJoinGroup(uint32_t interface, const Address &groupAddress)=0
Corresponds to socket option MCAST_JOIN_GROUP.
nodes
Definition: first.py:32
#define max(a, b)
Definition: 80211b.c:43
AttributeValue implementation for Time.
Definition: nstime.h:1132
void DoSendPacket(Ptr< Socket > socket, Ptr< Packet > packet, std::string to)
Send data.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
IPv4 Deduplication Performance Test.
holds a vector of ns3::NetDevice pointers
IPv4 Deduplication Test.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1610
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:862
IPv4 Deduplication Performance TestSuite.
void CheckPackets(const std::string &name)
Check packet receptions.
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:76
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:464
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
void DropPkt(const Ipv4Header &ipHeader, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
Register dropped packet.
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
#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:622
void SendPacket(Ptr< Socket > socket, Ptr< Packet > packet, std::string to)
Send data.
Helper class that adds ns3::Ipv4StaticRouting objects.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
A simple channel, for simple things and testing.
std::map< std::string, uint32_t > m_packetCountMap
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:812
Helper class that adds ns3::Ipv4ListRouting objects.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
std::vector< Ptr< Socket > > m_sockets
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1086
std::map< std::string, uint32_t > m_dropCountMap
API to create UDP socket instances.
devices
Definition: first.py:39
build a set of SimpleNetDevice objects
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
IPv4 Deduplication TestSuite.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:187
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
static std::string MakeName(bool enable, Time expire)
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
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 SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
void CheckDrops(const std::string &name)
Check packet drops.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.