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 
137  static std::string MakeName (bool enable, Time expire);
138 
142  enum MODE {ENABLED = 0,
144  DEGENERATE}; // enabled, but expiration time too low
147  std::map<std::string, uint32_t> m_packetCountMap;
148  std::map<std::string, uint32_t> m_dropCountMap;
149 
150 public:
151  virtual void DoRun (void);
152 
158  Ipv4DeduplicationTest (bool enable, Time expire = Seconds (1));
159 
164  void ReceivePkt (Ptr<Socket> socket);
165 
174  void DropPkt (const Ipv4Header &ipHeader,
176  Ptr<Ipv4> ipv4, uint32_t interface);
177 };
178 
179 const Time
181 
183  : TestCase (MakeName (enable, expire))
184  , m_mode (ENABLED)
185  , m_expire (expire)
186 {
187  if (!enable)
188  {
189  m_mode = DISABLED;
190  }
191  else if (m_expire < DELAY)
192  {
193  m_mode = DEGENERATE;
194  }
195 }
196 
198 {
199  uint32_t availableData;
200  availableData = socket->GetRxAvailable ();
201  Ptr<Packet> packet = socket->Recv (std::numeric_limits<uint32_t>::max (), 0);
202  NS_ASSERT (availableData == packet->GetSize ());
203 
204  auto node = socket->GetNode ();
205  std::string name = Names::FindName (node);
206  m_packetCountMap.insert ({name, 0}); // only inserts when not there
207  ++m_packetCountMap[name];
208 }
209 
210 void
213  Ptr<Ipv4> ipv4, uint32_t interface)
214 {
215  switch (m_mode)
216  {
217  case ENABLED:
218  NS_TEST_EXPECT_MSG_EQ (reason, Ipv4L3Protocol::DROP_DUPLICATE, "Wrong reason for drop");
219  break;
220  case DISABLED:
221  NS_TEST_EXPECT_MSG_EQ (reason, Ipv4L3Protocol::DROP_TTL_EXPIRED, "Wrong reason for drop");
222  break;
223  case DEGENERATE:
224  // reason can be either
225  break;
226  };
227  auto node = ipv4->GetNetDevice (interface)->GetNode ();
228  std::string name = Names::FindName (node);
229  m_dropCountMap.insert ({name, 0});
230  ++m_dropCountMap[name];
231 }
232 
233 void
235 {
236  SendPacket (socket, Create<Packet> (123), to);
237 }
238 
239 void
241 {
242  Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 1234);
243  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (packet, 0, realTo), 123, "100");
244 }
245 
246 void
248 {
249  DoSendData(socket, to);
250 }
251 
252 void
254 {
255  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), MilliSeconds (50),
256  &Ipv4DeduplicationTest::DoSendPacket, this, socket, packet, to);
257 }
258 
259 std::string
260 Ipv4DeduplicationTest::MakeName (bool enabled, Time expire)
261 {
262  std::ostringstream oss;
263  oss << "IP v4 RFC 6621 De-duplication: ";
264  if (!enabled)
265  {
266  oss << "disabled";
267  }
268  else if (expire > DELAY)
269  {
270  oss << "enabled";
271  }
272  else
273  {
274  oss << "degenerate";
275  }
276  oss << ", expire = " << expire.ToDouble (Time::MS) << "ms";
277 
278  return oss.str ();
279 }
280 
281 void
283 {
284  // multicast target
285  const std::string targetAddr = "239.192.100.1";
286  Config::SetDefault ("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection", BooleanValue (m_mode != DISABLED));
287  Config::SetDefault ("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue (m_expire));
288 
289  // Create topology
290 
291  // Create nodes
292  auto nodes = NodeContainer ();
293  nodes.Create (5);
294 
295  // Name nodes
296  Names::Add ("A", nodes.Get (0));
297  Names::Add ("B", nodes.Get (1));
298  Names::Add ("C", nodes.Get (2));
299  Names::Add ("D", nodes.Get (3));
300  Names::Add ("E", nodes.Get (4));
301 
302  SimpleNetDeviceHelper simplenet;
303  auto devices = simplenet.Install (nodes);
304  // name devices
305  Names::Add ("A/dev", devices.Get (0));
306  Names::Add ("B/dev", devices.Get (1));
307  Names::Add ("C/dev", devices.Get (2));
308  Names::Add ("D/dev", devices.Get (3));
309  Names::Add ("E/dev", devices.Get (4));
310 
311  Ipv4ListRoutingHelper listRouting;
312  Ipv4StaticRoutingHelper staticRouting;
313  listRouting.Add (staticRouting, 0);
314 
315  InternetStackHelper internet;
316  internet.SetIpv6StackInstall (false);
317  internet.SetIpv4ArpJitter (true);
318  internet.SetRoutingHelper (listRouting);
319  internet.Install (nodes);
320 
321  Ipv4AddressHelper ipv4address;
322  ipv4address.SetBase ("10.0.0.0", "255.255.255.0");
323  ipv4address.Assign (devices);
324 
325  // add static routes for each node / device
326  auto diter = devices.Begin ();
327  for (auto end = nodes.End (),
328  iter = nodes.Begin (); iter != end; ++iter)
329  {
330  // route for forwarding
331  staticRouting.AddMulticastRoute (*iter, Ipv4Address::GetAny (), targetAddr.c_str (), *diter, NetDeviceContainer (*diter));
332 
333  // route for host
334  // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
341  auto ipv4 = (*iter)->GetObject <Ipv4> ();
342  NS_ASSERT_MSG ((bool) ipv4, "Node " << Names::FindName (*iter) << " does not have Ipv4 aggregate");
343  auto routing = staticRouting.GetStaticRouting (ipv4);
344  routing->AddHostRouteTo (targetAddr.c_str (), ipv4->GetInterfaceForDevice (*diter), 0);
345 
346  ++diter;
347  }
348 
349  // set the topology, by default fully-connected
350  auto channel = devices.Get (0)->GetChannel ();
351  auto simplechannel = channel->GetObject <SimpleChannel> ();
352  // ensure some time progress between re-transmissions
353  simplechannel->SetAttribute ("Delay", TimeValue (DELAY));
354  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("A/dev"), Names::Find <SimpleNetDevice> ("D/dev"));
355  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("D/dev"), Names::Find <SimpleNetDevice> ("A/dev"));
356 
357  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("A/dev"), Names::Find <SimpleNetDevice> ("E/dev"));
358  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("E/dev"), Names::Find <SimpleNetDevice> ("A/dev"));
359 
360  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("B/dev"), Names::Find <SimpleNetDevice> ("E/dev"));
361  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("E/dev"), Names::Find <SimpleNetDevice> ("B/dev"));
362 
363  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("C/dev"), Names::Find <SimpleNetDevice> ("E/dev"));
364  simplechannel->BlackList (Names::Find <SimpleNetDevice> ("E/dev"), Names::Find <SimpleNetDevice> ("C/dev"));
365 
366  // Create the UDP sockets
367  std::list<Ptr<Socket> > sockets;
368  for (auto end = nodes.End (),
369  iter = nodes.Begin (); iter != end; ++iter)
370  {
371  auto SocketFactory = (*iter)->GetObject<UdpSocketFactory> ();
372  auto socket = SocketFactory->CreateSocket ();
373  socket->SetAllowBroadcast (true);
374  NS_TEST_EXPECT_MSG_EQ (socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 1234)), 0,
375  "Could not bind socket for node " << Names::FindName (*iter));
376 
377  auto udpSocket = socket->GetObject<UdpSocket> ();
378  udpSocket->MulticastJoinGroup (0, Ipv4Address (targetAddr.c_str ())); // future proof?
379  udpSocket->SetAttribute ("IpMulticastTtl", StringValue ("4"));
380 
381  socket->SetRecvCallback (MakeCallback (&Ipv4DeduplicationTest::ReceivePkt, this));
382  sockets.push_back (socket);
383  }
384 
385  // connect up drop traces
386  Config::ConnectWithoutContext ("/NodeList/*/$ns3::Ipv4L3Protocol/Drop",
388 
389  // start TX from A
390  auto txSocket = sockets.front ();
391 
392  // ------ Now the tests ------------
393 
394  // Broadcast 1 packet
395  SendData (txSocket, targetAddr);
396  Simulator::Run ();
397  Simulator::Destroy ();
398 
399  for (auto end = nodes.End (),
400  iter = nodes.Begin (); iter != end; ++iter)
401  {
402  std::string name = Names::FindName (*iter);
403  CheckPackets (name);
404  CheckDrops (name);
405  }
406 
407  m_packetCountMap.clear ();
408  sockets.clear ();
409  Names::Clear ();
410 }
411 
412 // NOTE:
413 // The de-duplicate disabled received packets and drops can be
414 // computed by forming the connectivity matrix C with 1's in
415 // coordinates (row, column) where row and column nodes are connected.
416 // Reception of packets with TTL n are v_(n-1) = v_n * C where
417 // v_TTL = [1 0 0 0 0] (corresponding to nodes [A B C D E]).
418 // The number of drops for each node is v_0 and the number of received
419 // packets at each node is sum (v_TTL-1, ..., v_0).
420 void
421 Ipv4DeduplicationTest::CheckPackets (const std::string &name)
422 {
423  // a priori determined packet receptions based on initial TTL of 4, disabled de-dup
424  std::map <std::string, uint32_t> packets = {
425  {"A", 14}, {"B", 16}, {"C", 16}, {"D", 16}, {"E", 4}
426  };
427 
428  // a priori determined packet receptions based on
429  std:: map <std::string, uint32_t> packetsDuped = {
430  {"A", 0}, {"B", 1}, {"C", 1}, {"D", 1}, {"E", 1}
431  };
432  // a priori determined packet receptions based on initial TTL of 4, degenerate de-dup
433  // There are TTL (4) rounds of packets. Each round a node will register a
434  // received packet if another connected node transmits. A misses the 1st round
435  // since it is the only one transmitting. D is not connected to A in 1st round
436  // either. E only hears a packet in the 3rd and 4th rounds.
437  std::map <std::string, uint32_t> degenerates = {
438  {"A", 3}, {"B", 4}, {"C", 4}, {"D", 3}, {"E", 2}
439  };
440 
441  switch (m_mode)
442  {
443  case ENABLED:
444  NS_TEST_ASSERT_MSG_EQ (m_packetCountMap[name], packetsDuped[name], "Wrong number of packets received for node " << name);
445  break;
446  case DISABLED:
447  NS_TEST_EXPECT_MSG_EQ (m_packetCountMap[name], packets[name], "Wrong number of packets received for node " << name);
448  break;
449  case DEGENERATE:
450  NS_TEST_EXPECT_MSG_EQ (m_packetCountMap[name], degenerates[name], "Wrong number of packets received for node " << name);
451  break;
452  };
453 }
454 
455 void
456 Ipv4DeduplicationTest::CheckDrops (const std::string &name)
457 {
458  std::map <std::string, uint32_t> drops;
459  switch (m_mode)
460  {
461  case ENABLED:
462  // a priori determined packet drops based on initial TTL of 4, enabled de-dup;
463  // A hears from B & C -- > 2 drops
464  // D hears from B, C, AND E
465  // B (C) hears from A, C (B), D,
466  drops = {{"A", 2}, {"B", 2}, {"C", 2}, {"D", 2}, {"E", 0}};
467  break;
468  case DISABLED:
469  // a priori determined packet drops based on initial TTL of 4, disabled de-dup
470  drops = {{"A", 10}, {"B", 9}, {"C", 9}, {"D", 12}, {"E", 2}};
471  break;
472  case DEGENERATE:
473  // a priori determined packet drops based on initial TTL of 4, degenerate de-dup
474  // There are TTL (4) rounds of transmissions. Since all transmitters are
475  // synchronized, multiple packets are received each round when there are
476  // multiple transmitters. Only 1 packet per round is delivered, others are
477  // dropped. So this can be computed via "disabled" procedure described
478  // in check packets, but with only a 1 for each node in each round when packets
479  // are received. Drops are the sum of receptions using these indicator receive vectors
480  // subtracting 1 for each node (for the delivered packet) and adding 1
481  // at all nodes for TTL expiry.
482  drops = {{"A", 4}, {"B", 5}, {"C", 5}, {"D", 5}, {"E", 1}};
483  break;
484  }
485 
486  if (drops[name])
487  {
488  NS_TEST_ASSERT_MSG_NE ((m_dropCountMap.find (name) == m_dropCountMap.end ()), true, "No drops for node " << name);
489  NS_TEST_EXPECT_MSG_EQ (m_dropCountMap[name], drops[name], "Wrong number of drops for node " << name);
490  }
491  else
492  {
493  NS_TEST_EXPECT_MSG_EQ ((m_dropCountMap.find (name) == m_dropCountMap.end ()), true, "Non-0 drops for node " << name);
494  }
495 }
496 
504 {
505 public:
507 private:
508 };
509 
511  : TestSuite ("ipv4-deduplication", UNIT)
512 {
513 
514  AddTestCase (new Ipv4DeduplicationTest (true), TestCase::QUICK);
515  AddTestCase (new Ipv4DeduplicationTest (false), TestCase::QUICK);
516  // degenerate case is enabled RFC but with too short an expiry
517  AddTestCase (new Ipv4DeduplicationTest (true, MicroSeconds (50)), TestCase::QUICK);
518 }
519 
521 
522 
523 
549 {
550  public:
552  virtual void DoRun (void);
553  private:
554  std::vector <Ptr<Socket> > m_sockets;
555  std::vector <uint8_t> m_txPackets;
556  uint8_t m_target;
557 
564  void DoSendData (Ptr<Socket> socket, Address to, uint8_t socketIndex);
565 };
566 
568  : TestCase ("Ipv4Deduplication performance test")
569 {
570  m_target = 40;
571 }
572 
573 void
575 {
576  // multicast target
577  const std::string targetAddr = "239.192.100.1";
578  Config::SetDefault ("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection", BooleanValue (true));
579  Config::SetDefault ("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue (Time ("10s")));
580 
581  // Create nodes
582  auto nodes = NodeContainer ();
583  nodes.Create (20);
584 
585  SimpleNetDeviceHelper simplenet;
586  auto devices = simplenet.Install (nodes);
587 
588  Ipv4ListRoutingHelper listRouting;
589  Ipv4StaticRoutingHelper staticRouting;
590  listRouting.Add (staticRouting, 0);
591 
592  InternetStackHelper internet;
593  internet.SetIpv6StackInstall (false);
594  internet.SetIpv4ArpJitter (true);
595  internet.SetRoutingHelper (listRouting);
596  internet.Install (nodes);
597 
598  Ipv4AddressHelper ipv4address;
599  ipv4address.SetBase ("10.0.0.0", "255.255.255.0");
600  ipv4address.Assign (devices);
601 
602  // add static routes for each node / device
603  auto diter = devices.Begin ();
604  for (auto iter = nodes.Begin (); iter != nodes.End (); ++iter)
605  {
606  // route for forwarding
607  staticRouting.AddMulticastRoute (*iter, Ipv4Address::GetAny (), targetAddr.c_str (), *diter, NetDeviceContainer (*diter));
608 
609  // route for host
610  // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
617  auto ipv4 = (*iter)->GetObject <Ipv4> ();
618  NS_ASSERT_MSG ((bool) ipv4, "Node " << (*iter)->GetId () << " does not have Ipv4 aggregate");
619  auto routing = staticRouting.GetStaticRouting (ipv4);
620  routing->AddHostRouteTo (targetAddr.c_str (), ipv4->GetInterfaceForDevice (*diter), 0);
621 
622  ++diter;
623  }
624 
625 
626  // Create the UDP sockets
627  Ptr<UniformRandomVariable> jitter = CreateObjectWithAttributes <UniformRandomVariable> ("Max", DoubleValue (4));
628  Address to = InetSocketAddress (Ipv4Address (targetAddr.c_str ()), 1234);
629  for (auto iter = nodes.Begin (); iter != nodes.End (); ++iter)
630  {
631  Ptr<SocketFactory> udpSocketFactory = (*iter)->GetObject<UdpSocketFactory> ();
632  m_sockets.push_back (udpSocketFactory->CreateSocket ());
633  m_txPackets.push_back (0);
634  }
635 
636  for (uint8_t i = 0; i<nodes.GetN (); i++)
637  {
638  Simulator::ScheduleWithContext (m_sockets[i]->GetNode ()->GetId (),
639  Seconds (4+jitter->GetValue ()),
641  }
642 
643  Simulator::Run ();
644  NS_LOG_UNCOND ("Executed " << Simulator::GetEventCount () << " events");
645 
646  for (auto iter = m_sockets.begin (); iter != m_sockets.end (); iter++)
647  {
648  (*iter)->Close ();
649  }
650 
651  Simulator::Destroy ();
652 }
653 
654 void
656 {
657  socket->SendTo (Create<Packet> (512), 0, to);
658  if (m_txPackets[socketIndex] < m_target)
659  {
660  m_txPackets[socketIndex] += 1;
661  Simulator::ScheduleWithContext (m_sockets[socketIndex]->GetNode ()->GetId (), Seconds (.5),
662  &Ipv4DeduplicationPerformanceTest::DoSendData, this, m_sockets[socketIndex], to, socketIndex);
663  }
664 }
665 
666 
674 {
675 public:
677 };
678 
680  : TestSuite ("ipv4-deduplication-performance", PERFORMANCE)
681 {
682  AddTestCase (new Ipv4DeduplicationPerformanceTest, TestCase::EXTENSIVE);
683 }
684 
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition: net-device-container.h:42
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::InetSocketAddress
an Inet address class
Definition: inet-socket-address.h:41
Ipv4DeduplicationPerformanceTest::Ipv4DeduplicationPerformanceTest
Ipv4DeduplicationPerformanceTest(void)
Definition: ipv4-deduplication-test.cc:567
Ipv4DeduplicationPerformanceTest::m_target
uint8_t m_target
number of packets to transmit on each socket
Definition: ipv4-deduplication-test.cc:556
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
ns3::UdpSocketFactory
API to create UDP socket instances.
Definition: udp-socket-factory.h:42
NS_ASSERT
#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
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
ns3::Node::GetId
uint32_t GetId(void) const
Definition: node.cc:109
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv4ListRoutingHelper
Helper class that adds ns3::Ipv4ListRouting objects.
Definition: ipv4-list-routing-helper.h:38
ns3::Ipv4AddressHelper
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Definition: ipv4-address-helper.h:48
Ipv4DeduplicationPerformanceTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: ipv4-deduplication-test.cc:574
ns3::MicroSeconds
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
ns3::Socket::GetNode
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
third.channel
channel
Definition: third.py:92
Ipv4DeduplicationTest::DoSendPacket
void DoSendPacket(Ptr< Socket > socket, Ptr< Packet > packet, std::string to)
Send data.
Definition: ipv4-deduplication-test.cc:240
ns3::Ipv4::GetNetDevice
virtual Ptr< NetDevice > GetNetDevice(uint32_t interface)=0
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::ObjectBase::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
ns3::Ipv4L3Protocol::DropReason
DropReason
Reason why a packet has been dropped.
Definition: ipv4-l3-protocol.h:98
ns3::Socket::SendTo
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
NS_TEST_ASSERT_MSG_NE
#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
Ipv4DeduplicationTest::ReceivePkt
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: ipv4-deduplication-test.cc:197
first.devices
devices
Definition: first.py:39
Ipv4DeduplicationTest::SendData
void SendData(Ptr< Socket > socket, std::string to)
Send data.
Definition: ipv4-deduplication-test.cc:247
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
first.nodes
nodes
Definition: first.py:32
Ipv4DeduplicationTestSuite::Ipv4DeduplicationTestSuite
Ipv4DeduplicationTestSuite()
Definition: ipv4-deduplication-test.cc:510
Ipv4DeduplicationTest::MakeName
static std::string MakeName(bool enable, Time expire)
Creates the test name according to the parameters.
Definition: ipv4-deduplication-test.cc:260
ns3::TestCase
encapsulates test code
Definition: test.h:1154
Ipv4DeduplicationTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: ipv4-deduplication-test.cc:282
Ipv4DeduplicationTest
IPv4 Deduplication Test.
Definition: ipv4-deduplication-test.cc:88
ns3::Ipv4AddressHelper::SetBase
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Definition: ipv4-address-helper.cc:64
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
ns3::Time::ToDouble
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:530
ns3::Ipv4StaticRoutingHelper
Helper class that adds ns3::Ipv4StaticRouting objects.
Definition: ipv4-static-routing-helper.h:43
ns3::Ptr< Socket >
g_ipv4DeduplicationPerformanceTestSuite
static Ipv4DeduplicationPerformanceTestSuite g_ipv4DeduplicationPerformanceTestSuite
Static variable for test initialization.
Definition: ipv4-deduplication-test.cc:685
ns3::Ipv4ListRoutingHelper::Add
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
Definition: ipv4-list-routing-helper.cc:55
ns3::Config::ConnectWithoutContext
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:901
ns3::UdpSocket
(abstract) base class of all UdpSockets
Definition: udp-socket.h:48
ns3::Ipv4StaticRoutingHelper::GetStaticRouting
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...
Definition: ipv4-static-routing-helper.cc:58
max
#define max(a, b)
Definition: 80211b.c:43
ns3::Address
a polymophic address class
Definition: address.h:91
Ipv4DeduplicationTest::DELAY
static const Time DELAY
Channel delay.
Definition: ipv4-deduplication-test.cc:129
ns3::InternetStackHelper::Install
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Definition: internet-stack-helper.cc:366
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
SendPacket
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
Definition: wifi-trans-example.cc:48
ns3::SimpleNetDeviceHelper
build a set of SimpleNetDevice objects
Definition: simple-net-device-helper.h:37
Ipv4DeduplicationPerformanceTest::m_txPackets
std::vector< uint8_t > m_txPackets
transmitted packets for each socket
Definition: ipv4-deduplication-test.cc:555
ns3::SocketFactory
Object to create transport layer instances that provide a socket API to applications.
Definition: socket-factory.h:49
ns3::UdpSocket::MulticastJoinGroup
virtual int MulticastJoinGroup(uint32_t interface, const Address &groupAddress)=0
Corresponds to socket option MCAST_JOIN_GROUP.
Ipv4DeduplicationPerformanceTestSuite::Ipv4DeduplicationPerformanceTestSuite
Ipv4DeduplicationPerformanceTestSuite()
Definition: ipv4-deduplication-test.cc:679
NS_TEST_EXPECT_MSG_EQ
#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
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
Ipv4DeduplicationTest::MODE
MODE
Enum of test types.
Definition: ipv4-deduplication-test.cc:142
ns3::InternetStackHelper::SetIpv6StackInstall
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
Definition: internet-stack-helper.cc:194
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
ns3::SimpleNetDeviceHelper::Install
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
Definition: simple-net-device-helper.cc:100
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Definition: log-macros-enabled.h:269
g_ipv4DeduplicationTestSuite
static Ipv4DeduplicationTestSuite g_ipv4DeduplicationTestSuite
Static variable for test initialization.
Definition: ipv4-deduplication-test.cc:520
Ipv4DeduplicationPerformanceTestSuite
IPv4 Deduplication Performance TestSuite.
Definition: ipv4-deduplication-test.cc:674
Ipv4DeduplicationTest::ENABLED
@ ENABLED
Definition: ipv4-deduplication-test.cc:142
Ipv4DeduplicationTest::m_mode
MODE m_mode
Test type.
Definition: ipv4-deduplication-test.cc:145
ns3::SocketFactory::CreateSocket
virtual Ptr< Socket > CreateSocket(void)=0
ns3::InternetStackHelper::SetIpv4ArpJitter
void SetIpv4ArpJitter(bool enable)
Enable/disable IPv4 ARP Jitter.
Definition: internet-stack-helper.cc:199
Ipv4DeduplicationTest::m_packetCountMap
std::map< std::string, uint32_t > m_packetCountMap
map of received packets (node name, counter)
Definition: ipv4-deduplication-test.cc:147
ns3::MakeCallback
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
ns3::StringValue
Hold variables of type string.
Definition: string.h:41
Ipv4DeduplicationTest::m_expire
Time m_expire
Expiration delay for duplicate cache entries.
Definition: ipv4-deduplication-test.cc:146
Ipv4DeduplicationTest::CheckDrops
void CheckDrops(const std::string &name)
Check packet drops.
Definition: ipv4-deduplication-test.cc:456
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
Ipv4DeduplicationTest::CheckPackets
void CheckPackets(const std::string &name)
Check packet receptions.
Definition: ipv4-deduplication-test.cc:421
Ipv4DeduplicationTest::DISABLED
@ DISABLED
Definition: ipv4-deduplication-test.cc:143
NS_TEST_ASSERT_MSG_EQ
#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:166
Ipv4DeduplicationPerformanceTest
IPv4 Deduplication Performance Test.
Definition: ipv4-deduplication-test.cc:549
ns3::Ipv4StaticRoutingHelper::AddMulticastRoute
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>
Definition: ipv4-static-routing-helper.cc:88
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::InternetStackHelper::SetRoutingHelper
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
Definition: internet-stack-helper.cc:175
ns3::Ipv4AddressHelper::Assign
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Definition: ipv4-address-helper.cc:135
ns3::SimpleChannel
A simple channel, for simple things and testing.
Definition: simple-channel.h:47
Ipv4DeduplicationPerformanceTest::m_sockets
std::vector< Ptr< Socket > > m_sockets
sockets in use
Definition: ipv4-deduplication-test.cc:554
Ipv4DeduplicationTest::DropPkt
void DropPkt(const Ipv4Header &ipHeader, Ptr< const Packet > packet, Ipv4L3Protocol::DropReason reason, Ptr< Ipv4 > ipv4, uint32_t interface)
Register dropped packet.
Definition: ipv4-deduplication-test.cc:211
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
ns3::NodeContainer
keep track of a set of node pointers.
Definition: node-container.h:39
Ipv4DeduplicationTestSuite
IPv4 Deduplication TestSuite.
Definition: ipv4-deduplication-test.cc:504
Ipv4DeduplicationTest::DoSendData
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
Definition: ipv4-deduplication-test.cc:234
Ipv4DeduplicationTest::Ipv4DeduplicationTest
Ipv4DeduplicationTest(bool enable, Time expire=Seconds(1))
Constructor.
Definition: ipv4-deduplication-test.cc:182
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
ns3::Socket::GetRxAvailable
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
ns3::InternetStackHelper
aggregate IP/TCP/UDP functionality to existing Nodes.
Definition: internet-stack-helper.h:88
Ipv4DeduplicationTest::m_dropCountMap
std::map< std::string, uint32_t > m_dropCountMap
map of received packets (node name, counter)
Definition: ipv4-deduplication-test.cc:148
Ipv4DeduplicationTest::DEGENERATE
@ DEGENERATE
Definition: ipv4-deduplication-test.cc:144
ns3::UniformRandomVariable::GetValue
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Definition: random-variable-stream.cc:182
Ipv4DeduplicationPerformanceTest::DoSendData
void DoSendData(Ptr< Socket > socket, Address to, uint8_t socketIndex)
Send data.
Definition: ipv4-deduplication-test.cc:655
Ipv4DeduplicationTest::SendPacket
void SendPacket(Ptr< Socket > socket, Ptr< Packet > packet, std::string to)
Send data.
Definition: ipv4-deduplication-test.cc:253
ns3::Socket::Recv
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.