A Discrete-Event Network Simulator
API
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  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19  * Modified (2019): Jared Dulmage <jared.dulmage@caliola.com>
20  * Tests dissemination of multicast packets across a mesh
21  * network to all nodes over multiple hops. Tests check
22  * the number of received packets and dropped packets
23  * with RFC 6621 de-duplication enabled or disabled.
24  */
25 
26 #include "ns3/boolean.h"
27 #include "ns3/config.h"
28 #include "ns3/double.h"
29 #include "ns3/inet-socket-address.h"
30 #include "ns3/internet-stack-helper.h"
31 #include "ns3/ipv4-address-helper.h"
32 #include "ns3/ipv4-l3-protocol.h"
33 #include "ns3/ipv4-list-routing-helper.h"
34 #include "ns3/ipv4-static-routing-helper.h"
35 #include "ns3/ipv4-static-routing.h"
36 #include "ns3/log.h"
37 #include "ns3/names.h"
38 #include "ns3/node.h"
39 #include "ns3/random-variable-stream.h"
40 #include "ns3/simple-channel.h"
41 #include "ns3/simple-net-device-helper.h"
42 #include "ns3/simple-net-device.h"
43 #include "ns3/simulator.h"
44 #include "ns3/socket.h"
45 #include "ns3/string.h"
46 #include "ns3/test.h"
47 #include "ns3/traffic-control-layer.h"
48 #include "ns3/udp-socket-factory.h"
49 #include "ns3/udp-socket.h"
50 #include "ns3/uinteger.h"
51 
52 #include <functional>
53 #include <limits>
54 #include <string>
55 
56 using namespace ns3;
57 
83 {
89  void DoSendData(Ptr<Socket> socket, std::string to);
96  void DoSendPacket(Ptr<Socket> socket, Ptr<Packet> packet, std::string to);
102  void SendData(Ptr<Socket> socket, std::string to);
103 
110  void SendPacket(Ptr<Socket> socket, Ptr<Packet> packet, std::string to);
111 
116  void CheckPackets(const std::string& name);
117 
122  void CheckDrops(const std::string& name);
123 
124  static const Time DELAY;
125 
132  static std::string MakeName(bool enable, Time expire);
133 
137  enum MODE
138  {
139  ENABLED = 0,
141  DEGENERATE
142  }; // enabled, but expiration time too low
143 
146  std::map<std::string, uint32_t>
148  std::map<std::string, uint32_t>
150 
151  public:
152  void DoRun() override;
153 
159  Ipv4DeduplicationTest(bool enable, Time expire = Seconds(1));
160 
165  void ReceivePkt(Ptr<Socket> socket);
166 
175  void DropPkt(const Ipv4Header& ipHeader,
176  Ptr<const Packet> packet,
178  Ptr<Ipv4> ipv4,
179  uint32_t interface);
180 };
181 
183 
185  : TestCase(MakeName(enable, expire)),
186  m_mode(ENABLED),
187  m_expire(expire)
188 {
189  if (!enable)
190  {
191  m_mode = DISABLED;
192  }
193  else if (m_expire < DELAY)
194  {
195  m_mode = DEGENERATE;
196  }
197 }
198 
199 void
201 {
202  uint32_t availableData;
203  availableData = socket->GetRxAvailable();
204  Ptr<Packet> packet = socket->Recv(std::numeric_limits<uint32_t>::max(), 0);
205  NS_TEST_ASSERT_MSG_EQ(availableData,
206  packet->GetSize(),
207  "Received packet size is not equal to the Rx buffer size");
208 
209  auto node = socket->GetNode();
210  std::string name = Names::FindName(node);
211  m_packetCountMap.insert({name, 0}); // only inserts when not there
212  ++m_packetCountMap[name];
213 }
214 
215 void
217  Ptr<const Packet> packet,
219  Ptr<Ipv4> ipv4,
220  uint32_t interface)
221 {
222  switch (m_mode)
223  {
224  case ENABLED:
225  NS_TEST_EXPECT_MSG_EQ(reason, Ipv4L3Protocol::DROP_DUPLICATE, "Wrong reason for drop");
226  break;
227  case DISABLED:
228  NS_TEST_EXPECT_MSG_EQ(reason, Ipv4L3Protocol::DROP_TTL_EXPIRED, "Wrong reason for drop");
229  break;
230  case DEGENERATE:
231  // reason can be either
232  break;
233  };
234  auto node = ipv4->GetNetDevice(interface)->GetNode();
235  std::string name = Names::FindName(node);
236  m_dropCountMap.insert({name, 0});
237  ++m_dropCountMap[name];
238 }
239 
240 void
242 {
243  SendPacket(socket, Create<Packet>(123), to);
244 }
245 
246 void
248 {
249  Address realTo = InetSocketAddress(Ipv4Address(to.c_str()), 1234);
250  NS_TEST_EXPECT_MSG_EQ(socket->SendTo(packet, 0, realTo), 123, "100");
251 }
252 
253 void
255 {
256  DoSendData(socket, to);
257 }
258 
259 void
261 {
262  Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
263  MilliSeconds(50),
265  this,
266  socket,
267  packet,
268  to);
269 }
270 
271 std::string
273 {
274  std::ostringstream oss;
275  oss << "IP v4 RFC 6621 De-duplication: ";
276  if (!enabled)
277  {
278  oss << "disabled";
279  }
280  else if (expire > DELAY)
281  {
282  oss << "enabled";
283  }
284  else
285  {
286  oss << "degenerate";
287  }
288  oss << ", expire = " << expire.ToDouble(Time::MS) << "ms";
289 
290  return oss.str();
291 }
292 
293 void
295 {
296  // multicast target
297  const std::string targetAddr = "239.192.100.1";
298  Config::SetDefault("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection",
300  Config::SetDefault("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue(m_expire));
301 
302  // Create topology
303 
304  // Create nodes
305  auto nodes = NodeContainer();
306  nodes.Create(5);
307 
308  // Name nodes
309  Names::Add("A", nodes.Get(0));
310  Names::Add("B", nodes.Get(1));
311  Names::Add("C", nodes.Get(2));
312  Names::Add("D", nodes.Get(3));
313  Names::Add("E", nodes.Get(4));
314 
315  SimpleNetDeviceHelper simplenet;
316  auto devices = simplenet.Install(nodes);
317  // name devices
318  Names::Add("A/dev", devices.Get(0));
319  Names::Add("B/dev", devices.Get(1));
320  Names::Add("C/dev", devices.Get(2));
321  Names::Add("D/dev", devices.Get(3));
322  Names::Add("E/dev", devices.Get(4));
323 
324  Ipv4ListRoutingHelper listRouting;
325  Ipv4StaticRoutingHelper staticRouting;
326  listRouting.Add(staticRouting, 0);
327 
329  internet.SetIpv6StackInstall(false);
330  internet.SetIpv4ArpJitter(true);
331  internet.SetRoutingHelper(listRouting);
332  internet.Install(nodes);
333 
334  Ipv4AddressHelper ipv4address;
335  ipv4address.SetBase("10.0.0.0", "255.255.255.0");
336  ipv4address.Assign(devices);
337 
338  // add static routes for each node / device
339  auto diter = devices.Begin();
340  for (auto end = nodes.End(), iter = nodes.Begin(); iter != end; ++iter)
341  {
342  // route for forwarding
343  staticRouting.AddMulticastRoute(*iter,
344  Ipv4Address::GetAny(),
345  targetAddr.c_str(),
346  *diter,
347  NetDeviceContainer(*diter));
348 
349  // route for host
350  // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
357  auto ipv4 = (*iter)->GetObject<Ipv4>();
359  true,
360  "Node " << Names::FindName(*iter) << " does not have Ipv4 aggregate");
361  auto routing = staticRouting.GetStaticRouting(ipv4);
362  routing->AddHostRouteTo(targetAddr.c_str(), ipv4->GetInterfaceForDevice(*diter), 0);
363 
364  ++diter;
365  }
366 
367  // set the topology, by default fully-connected
368  auto channel = devices.Get(0)->GetChannel();
369  auto simplechannel = channel->GetObject<SimpleChannel>();
370  // ensure some time progress between re-transmissions
371  simplechannel->SetAttribute("Delay", TimeValue(DELAY));
372  simplechannel->BlackList(Names::Find<SimpleNetDevice>("A/dev"),
373  Names::Find<SimpleNetDevice>("D/dev"));
374  simplechannel->BlackList(Names::Find<SimpleNetDevice>("D/dev"),
375  Names::Find<SimpleNetDevice>("A/dev"));
376 
377  simplechannel->BlackList(Names::Find<SimpleNetDevice>("A/dev"),
378  Names::Find<SimpleNetDevice>("E/dev"));
379  simplechannel->BlackList(Names::Find<SimpleNetDevice>("E/dev"),
380  Names::Find<SimpleNetDevice>("A/dev"));
381 
382  simplechannel->BlackList(Names::Find<SimpleNetDevice>("B/dev"),
383  Names::Find<SimpleNetDevice>("E/dev"));
384  simplechannel->BlackList(Names::Find<SimpleNetDevice>("E/dev"),
385  Names::Find<SimpleNetDevice>("B/dev"));
386 
387  simplechannel->BlackList(Names::Find<SimpleNetDevice>("C/dev"),
388  Names::Find<SimpleNetDevice>("E/dev"));
389  simplechannel->BlackList(Names::Find<SimpleNetDevice>("E/dev"),
390  Names::Find<SimpleNetDevice>("C/dev"));
391 
392  // Create the UDP sockets
393  std::list<Ptr<Socket>> sockets;
394  for (auto end = nodes.End(), iter = nodes.Begin(); iter != end; ++iter)
395  {
396  auto SocketFactory = (*iter)->GetObject<UdpSocketFactory>();
397  auto socket = SocketFactory->CreateSocket();
398  socket->SetAllowBroadcast(true);
399  NS_TEST_EXPECT_MSG_EQ(socket->Bind(InetSocketAddress(Ipv4Address::GetAny(), 1234)),
400  0,
401  "Could not bind socket for node " << Names::FindName(*iter));
402 
403  auto udpSocket = socket->GetObject<UdpSocket>();
404  udpSocket->MulticastJoinGroup(0, Ipv4Address(targetAddr.c_str())); // future proof?
405  udpSocket->SetAttribute("IpMulticastTtl", StringValue("4"));
406 
407  socket->SetRecvCallback(MakeCallback(&Ipv4DeduplicationTest::ReceivePkt, this));
408  sockets.push_back(socket);
409  }
410 
411  // connect up drop traces
412  Config::ConnectWithoutContext("/NodeList/*/$ns3::Ipv4L3Protocol/Drop",
414 
415  // start TX from A
416  auto txSocket = sockets.front();
417 
418  // ------ Now the tests ------------
419 
420  // Broadcast 1 packet
421  SendData(txSocket, targetAddr);
422  Simulator::Run();
423  Simulator::Destroy();
424 
425  for (auto end = nodes.End(), iter = nodes.Begin(); iter != end; ++iter)
426  {
427  std::string name = Names::FindName(*iter);
428  CheckPackets(name);
429  CheckDrops(name);
430  }
431 
432  m_packetCountMap.clear();
433  sockets.clear();
434  Names::Clear();
435 }
436 
437 // NOTE:
438 // The de-duplicate disabled received packets and drops can be
439 // computed by forming the connectivity matrix C with 1's in
440 // coordinates (row, column) where row and column nodes are connected.
441 // Reception of packets with TTL n are v_(n-1) = v_n * C where
442 // v_TTL = [1 0 0 0 0] (corresponding to nodes [A B C D E]).
443 // The number of drops for each node is v_0 and the number of received
444 // packets at each node is sum (v_TTL-1, ..., v_0).
445 void
446 Ipv4DeduplicationTest::CheckPackets(const std::string& name)
447 {
448  // a priori determined packet receptions based on initial TTL of 4, disabled de-dup
449  std::map<std::string, uint32_t> packets = {
450  {"A", 14},
451  {"B", 16},
452  {"C", 16},
453  {"D", 16},
454  {"E", 4},
455  };
456 
457  // a priori determined packet receptions based on
458  std::map<std::string, uint32_t> packetsDuped = {
459  {"A", 0},
460  {"B", 1},
461  {"C", 1},
462  {"D", 1},
463  {"E", 1},
464  };
465  // a priori determined packet receptions based on initial TTL of 4, degenerate de-dup
466  // There are TTL (4) rounds of packets. Each round a node will register a
467  // received packet if another connected node transmits. A misses the 1st round
468  // since it is the only one transmitting. D is not connected to A in 1st round
469  // either. E only hears a packet in the 3rd and 4th rounds.
470  std::map<std::string, uint32_t> degenerates = {
471  {"A", 3},
472  {"B", 4},
473  {"C", 4},
474  {"D", 3},
475  {"E", 2},
476  };
477 
478  switch (m_mode)
479  {
480  case ENABLED:
482  packetsDuped[name],
483  "Wrong number of packets received for node " << name);
484  break;
485  case DISABLED:
487  packets[name],
488  "Wrong number of packets received for node " << name);
489  break;
490  case DEGENERATE:
492  degenerates[name],
493  "Wrong number of packets received for node " << name);
494  break;
495  };
496 }
497 
498 void
499 Ipv4DeduplicationTest::CheckDrops(const std::string& name)
500 {
501  std::map<std::string, uint32_t> drops;
502  switch (m_mode)
503  {
504  case ENABLED:
505  // a priori determined packet drops based on initial TTL of 4, enabled de-dup;
506  // A hears from B & C -- > 2 drops
507  // D hears from B, C, AND E
508  // B (C) hears from A, C (B), D,
509  drops = {{"A", 2}, {"B", 2}, {"C", 2}, {"D", 2}, {"E", 0}};
510  break;
511  case DISABLED:
512  // a priori determined packet drops based on initial TTL of 4, disabled de-dup
513  drops = {{"A", 10}, {"B", 9}, {"C", 9}, {"D", 12}, {"E", 2}};
514  break;
515  case DEGENERATE:
516  // a priori determined packet drops based on initial TTL of 4, degenerate de-dup
517  // There are TTL (4) rounds of transmissions. Since all transmitters are
518  // synchronized, multiple packets are received each round when there are
519  // multiple transmitters. Only 1 packet per round is delivered, others are
520  // dropped. So this can be computed via "disabled" procedure described
521  // in check packets, but with only a 1 for each node in each round when packets
522  // are received. Drops are the sum of receptions using these indicator receive vectors
523  // subtracting 1 for each node (for the delivered packet) and adding 1
524  // at all nodes for TTL expiry.
525  drops = {{"A", 4}, {"B", 5}, {"C", 5}, {"D", 5}, {"E", 1}};
526  break;
527  }
528 
529  if (drops[name])
530  {
532  true,
533  "No drops for node " << name);
535  drops[name],
536  "Wrong number of drops for node " << name);
537  }
538  else
539  {
541  true,
542  "Non-0 drops for node " << name);
543  }
544 }
545 
552 {
553  public:
555 
556  private:
557 };
558 
560  : TestSuite("ipv4-deduplication", UNIT)
561 {
562  AddTestCase(new Ipv4DeduplicationTest(true), TestCase::QUICK);
563  AddTestCase(new Ipv4DeduplicationTest(false), TestCase::QUICK);
564  // degenerate case is enabled RFC but with too short an expiry
565  AddTestCase(new Ipv4DeduplicationTest(true, MicroSeconds(50)), TestCase::QUICK);
566 }
567 
570 
595 {
596  public:
598  void DoRun() override;
599 
600  private:
601  std::vector<Ptr<Socket>> m_sockets;
602  std::vector<uint8_t> m_txPackets;
603  uint8_t m_target;
604 
611  void DoSendData(Ptr<Socket> socket, Address to, uint8_t socketIndex);
612 };
613 
615  : TestCase("Ipv4Deduplication performance test")
616 {
617  m_target = 40;
618 }
619 
620 void
622 {
623  // multicast target
624  const std::string targetAddr = "239.192.100.1";
625  Config::SetDefault("ns3::Ipv4L3Protocol::EnableDuplicatePacketDetection", BooleanValue(true));
626  Config::SetDefault("ns3::Ipv4L3Protocol::DuplicateExpire", TimeValue(Time("10s")));
627 
628  // Create nodes
629  auto nodes = NodeContainer();
630  nodes.Create(20);
631 
632  SimpleNetDeviceHelper simplenet;
633  auto devices = simplenet.Install(nodes);
634 
635  Ipv4ListRoutingHelper listRouting;
636  Ipv4StaticRoutingHelper staticRouting;
637  listRouting.Add(staticRouting, 0);
638 
640  internet.SetIpv6StackInstall(false);
641  internet.SetIpv4ArpJitter(true);
642  internet.SetRoutingHelper(listRouting);
643  internet.Install(nodes);
644 
645  Ipv4AddressHelper ipv4address;
646  ipv4address.SetBase("10.0.0.0", "255.255.255.0");
647  ipv4address.Assign(devices);
648 
649  // add static routes for each node / device
650  auto diter = devices.Begin();
651  for (auto iter = nodes.Begin(); iter != nodes.End(); ++iter)
652  {
653  // route for forwarding
654  staticRouting.AddMulticastRoute(*iter,
655  Ipv4Address::GetAny(),
656  targetAddr.c_str(),
657  *diter,
658  NetDeviceContainer(*diter));
659 
660  // route for host
661  // Use host routing entry according to note in Ipv4StaticRouting::RouteOutput:
668  auto ipv4 = (*iter)->GetObject<Ipv4>();
670  true,
671  "Node " << (*iter)->GetId() << " does not have Ipv4 aggregate");
672  auto routing = staticRouting.GetStaticRouting(ipv4);
673  routing->AddHostRouteTo(targetAddr.c_str(), ipv4->GetInterfaceForDevice(*diter), 0);
674 
675  ++diter;
676  }
677 
678  // Create the UDP sockets
680  CreateObjectWithAttributes<UniformRandomVariable>("Max", DoubleValue(4));
681  Address to = InetSocketAddress(Ipv4Address(targetAddr.c_str()), 1234);
682  for (auto iter = nodes.Begin(); iter != nodes.End(); ++iter)
683  {
684  Ptr<SocketFactory> udpSocketFactory = (*iter)->GetObject<UdpSocketFactory>();
685  m_sockets.push_back(udpSocketFactory->CreateSocket());
686  m_txPackets.push_back(0);
687  }
688 
689  for (uint32_t i = 0; i < nodes.GetN(); i++)
690  {
691  Simulator::ScheduleWithContext(m_sockets[i]->GetNode()->GetId(),
692  Seconds(4 + jitter->GetValue()),
694  this,
695  m_sockets[i],
696  to,
697  i);
698  }
699 
700  Simulator::Run();
701  NS_LOG_UNCOND("Executed " << Simulator::GetEventCount() << " events");
702 
703  for (auto iter = m_sockets.begin(); iter != m_sockets.end(); iter++)
704  {
705  (*iter)->Close();
706  }
707 
708  Simulator::Destroy();
709 }
710 
711 void
713 {
714  socket->SendTo(Create<Packet>(512), 0, to);
715  if (m_txPackets[socketIndex] < m_target)
716  {
717  m_txPackets[socketIndex] += 1;
718  Simulator::ScheduleWithContext(m_sockets[socketIndex]->GetNode()->GetId(),
719  Seconds(.5),
721  this,
722  m_sockets[socketIndex],
723  to,
724  socketIndex);
725  }
726 }
727 
734 {
735  public:
737 };
738 
740  : TestSuite("ipv4-deduplication-performance", PERFORMANCE)
741 {
742  AddTestCase(new Ipv4DeduplicationPerformanceTest, TestCase::EXTENSIVE);
743 }
744 
#define max(a, b)
Definition: 80211b.c:42
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:101
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
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.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:80
DropReason
Reason why a packet has been dropped.
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>
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.
uint32_t GetId() const
Definition: node.cc:117
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:204
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
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...
Object to create transport layer instances that provide a socket API to applications.
virtual Ptr< Socket > CreateSocket()=0
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
Hold variables of type string.
Definition: string.h:56
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
double ToDouble(Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:573
API to create UDP socket instances.
(abstract) base class of all UdpSockets
Definition: udp-socket.h:48
virtual int MulticastJoinGroup(uint32_t interface, const Address &groupAddress)=0
Corresponds to socket option MCAST_JOIN_GROUP.
double GetValue(double min, double max)
Get the next random value drawn from the distribution.
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:890
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:950
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#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:144
#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:251
#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:564
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
static Ipv4DeduplicationPerformanceTestSuite g_ipv4DeduplicationPerformanceTestSuite
Static variable for test initialization.
static Ipv4DeduplicationTestSuite g_ipv4DeduplicationTestSuite
Static variable for test initialization.
NodeContainer nodes
devices
Definition: first.py:42
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:839
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:704
channel
Definition: third.py:88
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...