A Discrete-Event Network Simulator
API
icmp-test.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Ritsumeikan University, Shiga, Japan.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
18  */
19 
20 // Test program for the Internet Control Message Protocol (ICMP) responses.
21 //
22 // IcmpEchoReplyTestCase scenario:
23 //
24 // n0 <------------------> n1
25 // i(0,0) i(1,0)
26 //
27 // Test that sends a single ICMP echo packet with TTL = 1 from n0 to n1,
28 // n1 receives the packet and send an ICMP echo reply.
29 //
30 //
31 // IcmpTimeExceedTestCase scenario:
32 //
33 // channel1 channel2
34 // n0 <------------------> n1 <---------------------> n2
35 // i(0,0) i(1,0) i2(1,0)
36 // i2(0,0)
37 //
38 // Test that sends a single ICMP echo packet with TTL = 1 from n0 to n4,
39 // however, the TTL is not enough and n1 reply to n0 with an ICMP time exceed.
40 //
41 //
42 // IcmpV6EchoReplyTestCase scenario:
43 //
44 // n0 <-------------------> n1
45 // i(0,1) i(1,1)
46 //
47 // Test that sends a single ICMPV6 ECHO request with hopLimit = 1 from n0 to n1,
48 // n1 receives the packet and send an ICMPV6 echo reply.
49 //
50 // IcmpV6TimeExceedTestCase scenario:
51 //
52 // channel1 channel2
53 // n0 <------------------> n1 <---------------------> n2
54 // i(0,0) i(1,0) i2(1,0)
55 // i2(0,0)
56 //
57 // Test that sends a single ICMPV6 echo packet with hopLimit = 1 from n0 to n4,
58 // however, the hopLimit is not enough and n1 reply to n0 with an ICMPV6 time exceed error.
59 
60 #include "ns3/assert.h"
61 #include "ns3/icmpv4.h"
62 #include "ns3/icmpv6-header.h"
63 #include "ns3/internet-stack-helper.h"
64 #include "ns3/ipv4-address-helper.h"
65 #include "ns3/ipv4-global-routing-helper.h"
66 #include "ns3/ipv6-address-helper.h"
67 #include "ns3/ipv6-routing-helper.h"
68 #include "ns3/ipv6-static-routing-helper.h"
69 #include "ns3/log.h"
70 #include "ns3/node.h"
71 #include "ns3/simple-net-device-helper.h"
72 #include "ns3/simple-net-device.h"
73 #include "ns3/simulator.h"
74 #include "ns3/socket-factory.h"
75 #include "ns3/socket.h"
76 #include "ns3/test.h"
77 #include "ns3/uinteger.h"
78 
79 using namespace ns3;
80 
93 {
94  public:
96  ~IcmpEchoReplyTestCase() override;
97 
103  void SendData(Ptr<Socket> socket, Ipv4Address dst);
108  void ReceivePkt(Ptr<Socket> socket);
109 
110  private:
111  void DoRun() override;
113 };
114 
116  : TestCase("ICMP:EchoReply test case")
117 {
118 }
119 
121 {
122 }
123 
124 void
126 {
127  Ptr<Packet> p = Create<Packet>();
128  Icmpv4Echo echo;
129  echo.SetSequenceNumber(1);
130  echo.SetIdentifier(0);
131  p->AddHeader(echo);
132 
133  Icmpv4Header header;
134  header.SetType(Icmpv4Header::ICMPV4_ECHO);
135  header.SetCode(0);
136  p->AddHeader(header);
137 
138  Address realTo = InetSocketAddress(dst, 1234);
139 
140  NS_TEST_EXPECT_MSG_EQ(socket->SendTo(p, 0, realTo),
141  (int)p->GetSize(),
142  " Unable to send ICMP Echo Packet");
143 }
144 
145 void
147 {
148  Address from;
149  Ptr<Packet> p = socket->RecvFrom(0xffffffff, 0, from);
150  m_receivedPacket = p->Copy();
151 
153  p->RemoveHeader(ipv4);
154  NS_TEST_EXPECT_MSG_EQ(ipv4.GetProtocol(), 1, " The received Packet is not an ICMP packet");
155 
156  Icmpv4Header icmp;
157  p->RemoveHeader(icmp);
158 
160  Icmpv4Header::ICMPV4_ECHO_REPLY,
161  " The received Packet is not a ICMPV4_ECHO_REPLY");
162 }
163 
164 void
166 {
167  NodeContainer n;
168  n.Create(2);
169 
171  internet.Install(n);
172 
173  // link the two nodes
174  Ptr<SimpleNetDevice> txDev = CreateObject<SimpleNetDevice>();
175  Ptr<SimpleNetDevice> rxDev = CreateObject<SimpleNetDevice>();
176  n.Get(0)->AddDevice(txDev);
177  n.Get(1)->AddDevice(rxDev);
178  Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
179  rxDev->SetChannel(channel1);
180  txDev->SetChannel(channel1);
182  d.Add(txDev);
183  d.Add(rxDev);
184 
186 
187  ipv4.SetBase("10.0.0.0", "255.255.255.252");
188  Ipv4InterfaceContainer i = ipv4.Assign(d);
189 
190  Ptr<Socket> socket;
191  socket = Socket::CreateSocket(n.Get(0), TypeId::LookupByName("ns3::Ipv4RawSocketFactory"));
192  socket->SetAttribute("Protocol", UintegerValue(1)); // ICMP protocol
194 
195  InetSocketAddress src = InetSocketAddress(Ipv4Address::GetAny(), 0);
196  NS_TEST_EXPECT_MSG_EQ(socket->Bind(src), 0, " Socket Binding failed");
197 
198  // Set a TTL big enough
199  socket->SetIpTtl(1);
200  Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
201  Seconds(0),
203  this,
204  socket,
205  i.GetAddress(1, 0));
206  Simulator::Run();
207 
209  28,
210  " Unexpected ICMPV4_ECHO_REPLY packet size");
211 
212  Simulator::Destroy();
213 }
214 
222 {
223  public:
225  ~IcmpTimeExceedTestCase() override;
226 
232  void SendData(Ptr<Socket> socket, Ipv4Address dst);
237  void ReceivePkt(Ptr<Socket> socket);
238 
239  private:
240  void DoRun() override;
242 };
243 
245  : TestCase("ICMP:TimeExceedReply test case")
246 {
247 }
248 
250 {
251 }
252 
253 void
255 {
256  Ptr<Packet> p = Create<Packet>();
257  Icmpv4Echo echo;
258  echo.SetSequenceNumber(1);
259  echo.SetIdentifier(0);
260  p->AddHeader(echo);
261 
262  Icmpv4Header header;
263  header.SetType(Icmpv4Header::ICMPV4_ECHO);
264  header.SetCode(0);
265  p->AddHeader(header);
266 
267  Address realTo = InetSocketAddress(dst, 1234);
268 
269  NS_TEST_EXPECT_MSG_EQ(socket->SendTo(p, 0, realTo),
270  (int)p->GetSize(),
271  " Unable to send ICMP Echo Packet");
272 }
273 
274 void
276 {
277  Address from;
278  Ptr<Packet> p = socket->RecvFrom(0xffffffff, 0, from);
279  m_receivedPacket = p->Copy();
280 
282  p->RemoveHeader(ipv4);
283  NS_TEST_EXPECT_MSG_EQ(ipv4.GetProtocol(), 1, "The received packet is not an ICMP packet");
284 
285  NS_TEST_EXPECT_MSG_EQ(ipv4.GetSource(),
286  Ipv4Address("10.0.0.2"),
287  "ICMP Time Exceed Response should come from 10.0.0.2");
288 
289  Icmpv4Header icmp;
290  p->RemoveHeader(icmp);
291 
293  Icmpv4Header::ICMPV4_TIME_EXCEEDED,
294  "The received packet is not a ICMPV4_TIME_EXCEEDED packet ");
295 }
296 
297 void
299 {
300  NodeContainer n;
301  NodeContainer n0n1;
303  n.Create(3);
304  n0n1.Add(n.Get(0));
305  n0n1.Add(n.Get(1));
306  n1n2.Add(n.Get(1));
307  n1n2.Add(n.Get(2));
308 
309  Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
310  Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
311 
312  SimpleNetDeviceHelper simpleHelper;
313  simpleHelper.SetNetDevicePointToPointMode(true);
314 
315  SimpleNetDeviceHelper simpleHelper2;
316  simpleHelper2.SetNetDevicePointToPointMode(true);
317 
319  devices = simpleHelper.Install(n0n1, channel);
320  NetDeviceContainer devices2;
321  devices2 = simpleHelper2.Install(n1n2, channel2);
322 
324  internet.Install(n);
325 
327  address.SetBase("10.0.0.0", "255.255.255.255");
329 
330  address.SetBase("10.0.1.0", "255.255.255.255");
331  Ipv4InterfaceContainer i2 = address.Assign(devices2);
332 
333  Ipv4GlobalRoutingHelper::PopulateRoutingTables();
334 
335  Ptr<Socket> socket;
336  socket = Socket::CreateSocket(n.Get(0), TypeId::LookupByName("ns3::Ipv4RawSocketFactory"));
337  socket->SetAttribute("Protocol", UintegerValue(1)); // ICMP protocol
339 
340  InetSocketAddress src = InetSocketAddress(Ipv4Address::GetAny(), 0);
341  NS_TEST_EXPECT_MSG_EQ(socket->Bind(src), 0, " Socket Binding failed");
342 
343  // The ttl is not big enough , causing an ICMP Time Exceeded response
344  socket->SetIpTtl(1);
345  Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
346  Seconds(0),
348  this,
349  socket,
350  i2.GetAddress(1, 0));
351  Simulator::Run();
352 
354  56,
355  " Unexpected ICMP Time Exceed Response packet size");
356 
357  Simulator::Destroy();
358 }
359 
367 {
368  public:
370  ~IcmpV6EchoReplyTestCase() override;
371 
377  void SendData(Ptr<Socket> socket, Ipv6Address dst);
382  void ReceivePkt(Ptr<Socket> socket);
383 
384  private:
385  void DoRun() override;
387 };
388 
390  : TestCase("ICMPV6:EchoReply test case")
391 {
392 }
393 
395 {
396 }
397 
398 void
400 {
401  Ptr<Packet> p = Create<Packet>();
402  Icmpv6Echo echo(true);
403  echo.SetSeq(1);
404  echo.SetId(0XB1ED);
405  p->AddHeader(echo);
406 
407  Icmpv6Header header;
408  header.SetType(Icmpv6Header::ICMPV6_ECHO_REQUEST);
409  header.SetCode(0);
410  p->AddHeader(header);
411 
412  Address realTo = Inet6SocketAddress(dst, 1234);
413 
414  NS_TEST_EXPECT_MSG_EQ(socket->SendTo(p, 0, realTo),
415  (int)p->GetSize(),
416  " Unable to send ICMP Echo Packet");
417 }
418 
419 void
421 {
422  Address from;
423  Ptr<Packet> p = socket->RecvFrom(from);
424  Ptr<Packet> pkt = p->Copy();
425 
426  if (Inet6SocketAddress::IsMatchingType(from))
427  {
428  Ipv6Header ipv6;
429  p->RemoveHeader(ipv6);
430 
432  Ipv6Header::IPV6_ICMPV6,
433  "The received Packet is not an ICMPV6 packet");
434  Icmpv6Header icmpv6;
435  p->RemoveHeader(icmpv6);
436 
437  if (icmpv6.GetType() == Icmpv6Header::ICMPV6_ECHO_REPLY)
438  {
439  m_receivedPacket = pkt->Copy();
440  }
441  }
442 }
443 
444 void
446 {
447  NodeContainer n;
448  n.Create(2);
449 
451  internet.Install(n);
452 
453  // link the two nodes
454  Ptr<SimpleNetDevice> txDev = CreateObject<SimpleNetDevice>();
455  Ptr<SimpleNetDevice> rxDev = CreateObject<SimpleNetDevice>();
456  txDev->SetAddress(Mac48Address("00:00:00:00:00:01"));
457  rxDev->SetAddress(Mac48Address("00:00:00:00:00:02"));
458  n.Get(0)->AddDevice(txDev);
459  n.Get(1)->AddDevice(rxDev);
460  Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
461  rxDev->SetChannel(channel1);
462  txDev->SetChannel(channel1);
464  d.Add(txDev);
465  d.Add(rxDev);
466 
467  Ipv6AddressHelper ipv6;
468 
469  ipv6.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
470  Ipv6InterfaceContainer i = ipv6.Assign(d);
471 
472  Ptr<Socket> socket;
473  socket = Socket::CreateSocket(n.Get(0), TypeId::LookupByName("ns3::Ipv6RawSocketFactory"));
474  socket->SetAttribute("Protocol", UintegerValue(Ipv6Header::IPV6_ICMPV6));
476 
477  Inet6SocketAddress src = Inet6SocketAddress(Ipv6Address::GetAny(), 0);
478  NS_TEST_EXPECT_MSG_EQ(socket->Bind(src), 0, " SocketV6 Binding failed");
479 
480  // Set a TTL big enough
481  socket->SetIpTtl(1);
482 
483  Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
484  Seconds(0),
486  this,
487  socket,
488  i.GetAddress(1, 1));
489  Simulator::Run();
490 
492  52,
493  " Unexpected ICMPV6_ECHO_REPLY packet size");
494 
495  Simulator::Destroy();
496 }
497 
505 {
506  public:
508  ~IcmpV6TimeExceedTestCase() override;
509 
515  void SendData(Ptr<Socket> socket, Ipv6Address dst);
520  void ReceivePkt(Ptr<Socket> socket);
521 
522  private:
523  void DoRun() override;
525 };
526 
528  : TestCase("ICMPV6:TimeExceed test case")
529 {
530 }
531 
533 {
534 }
535 
536 void
538 {
539  Ptr<Packet> p = Create<Packet>();
540  Icmpv6Echo echo(true);
541  echo.SetSeq(1);
542  echo.SetId(0XB1ED);
543  p->AddHeader(echo);
544 
545  Icmpv6Header header;
546  header.SetType(Icmpv6Header::ICMPV6_ECHO_REQUEST);
547  header.SetCode(0);
548  p->AddHeader(header);
549 
550  Address realTo = Inet6SocketAddress(dst, 1234);
551 
552  socket->SendTo(p, 0, realTo);
553 }
554 
555 void
557 {
558  Address from;
559  Ptr<Packet> p = socket->RecvFrom(from);
560  Ptr<Packet> pkt = p->Copy();
561 
562  if (Inet6SocketAddress::IsMatchingType(from))
563  {
564  Ipv6Header ipv6;
565  p->RemoveHeader(ipv6);
566 
568  Ipv6Header::IPV6_ICMPV6,
569  "The received Packet is not an ICMPV6 packet");
570 
571  Icmpv6Header icmpv6;
572  p->RemoveHeader(icmpv6);
573 
574  // Ignore any packet except ICMPV6_ERROR_TIME_EXCEEDED
575  if (icmpv6.GetType() == Icmpv6Header::ICMPV6_ERROR_TIME_EXCEEDED)
576  {
577  m_receivedPacket = pkt->Copy();
578  }
579  }
580 }
581 
582 void
584 {
585  NodeContainer n;
586  NodeContainer n0n1;
588  n.Create(3);
589  n0n1.Add(n.Get(0));
590  n0n1.Add(n.Get(1));
591  n1n2.Add(n.Get(1));
592  n1n2.Add(n.Get(2));
593 
594  Ptr<SimpleChannel> channel = CreateObject<SimpleChannel>();
595  Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
596 
597  SimpleNetDeviceHelper simpleHelper;
598  simpleHelper.SetNetDevicePointToPointMode(true);
599 
600  SimpleNetDeviceHelper simpleHelper2;
601  simpleHelper2.SetNetDevicePointToPointMode(true);
602 
604  devices = simpleHelper.Install(n0n1, channel);
605 
606  NetDeviceContainer devices2;
607  devices2 = simpleHelper2.Install(n1n2, channel2);
608 
610  internet.Install(n);
611 
613 
614  address.NewNetwork();
615  address.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
616 
618  interfaces.SetForwarding(1, true);
619  interfaces.SetDefaultRouteInAllNodes(1);
620  address.SetBase(Ipv6Address("2001:2::"), Ipv6Prefix(64));
621  Ipv6InterfaceContainer interfaces2 = address.Assign(devices2);
622 
623  interfaces2.SetForwarding(0, true);
624  interfaces2.SetDefaultRouteInAllNodes(0);
625 
626  Ptr<Socket> socket;
627  socket = Socket::CreateSocket(n.Get(0), TypeId::LookupByName("ns3::Ipv6RawSocketFactory"));
628  socket->SetAttribute("Protocol", UintegerValue(Ipv6Header::IPV6_ICMPV6));
630 
631  Inet6SocketAddress src = Inet6SocketAddress(Ipv6Address::GetAny(), 0);
632  NS_TEST_EXPECT_MSG_EQ(socket->Bind(src), 0, " SocketV6 Binding failed");
633 
634  // In Ipv6 TTL is renamed hop limit in IPV6.
635  // The hop limit is not big enough , causing an ICMPV6 Time Exceeded error
636  socket->SetIpv6HopLimit(1);
637 
638  Simulator::ScheduleWithContext(socket->GetNode()->GetId(),
639  Seconds(0),
641  this,
642  socket,
643  interfaces2.GetAddress(1, 1));
644  Simulator::Run();
645 
647  100,
648  " Unexpected ICMPV6_ECHO_REPLY packet size");
649 
650  Simulator::Destroy();
651 }
652 
660 class IcmpTestSuite : public TestSuite
661 {
662  public:
663  IcmpTestSuite();
664 };
665 
667  : TestSuite("icmp", UNIT)
668 {
669  AddTestCase(new IcmpEchoReplyTestCase, TestCase::QUICK);
670  AddTestCase(new IcmpTimeExceedTestCase, TestCase::QUICK);
671  AddTestCase(new IcmpV6EchoReplyTestCase, TestCase::QUICK);
672  AddTestCase(new IcmpV6TimeExceedTestCase, TestCase::QUICK);
673 }
674 
NodeContainer n1n2
Nodecontainer n1 + n2.
ICMP Echo Reply Test.
Definition: icmp-test.cc:93
void DoRun() override
Implementation to actually run this TestCase.
Definition: icmp-test.cc:165
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:146
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Definition: icmp-test.cc:125
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:112
~IcmpEchoReplyTestCase() override
Definition: icmp-test.cc:120
ICMP TestSuite.
Definition: icmp-test.cc:661
ICMP Time Exceed Reply Test.
Definition: icmp-test.cc:222
~IcmpTimeExceedTestCase() override
Definition: icmp-test.cc:249
void DoRun() override
Implementation to actually run this TestCase.
Definition: icmp-test.cc:298
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:275
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:241
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Definition: icmp-test.cc:254
ICMPV6 Echo Reply Test.
Definition: icmp-test.cc:367
~IcmpV6EchoReplyTestCase() override
Definition: icmp-test.cc:394
void DoRun() override
Implementation to actually run this TestCase.
Definition: icmp-test.cc:445
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:386
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
Definition: icmp-test.cc:399
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:420
ICMPV6 Time Exceed response test.
Definition: icmp-test.cc:505
void DoRun() override
Implementation to actually run this TestCase.
Definition: icmp-test.cc:583
~IcmpV6TimeExceedTestCase() override
Definition: icmp-test.cc:532
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:556
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:524
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
Definition: icmp-test.cc:537
a polymophic address class
Definition: address.h:101
ICMP Echo header.
Definition: icmpv4.h:110
void SetIdentifier(uint16_t id)
Set the Echo identifier.
Definition: icmpv4.cc:150
void SetSequenceNumber(uint16_t seq)
Set the Echo sequence number.
Definition: icmpv4.cc:157
Base class for all the ICMP packet headers.
Definition: icmpv4.h:43
void SetCode(uint8_t code)
Set ICMP code.
Definition: icmpv4.cc:123
void SetType(uint8_t type)
Set ICMP type.
Definition: icmpv4.cc:116
uint8_t GetType() const
Get ICMP type.
Definition: icmpv4.cc:130
ICMPv6 Echo message.
void SetId(uint16_t id)
Set the ID of the packet.
void SetSeq(uint16_t seq)
Set the sequence number.
ICMPv6 header.
Definition: icmpv6-header.h:38
uint8_t GetType() const
Get the type field.
void SetCode(uint8_t code)
Set the code field.
void SetType(uint8_t type)
Set the type.
An Inet6 address class.
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.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Packet header for IPv4.
Definition: ipv4-header.h:34
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
Definition: ipv6-address.h:49
Packet header for IPv6.
Definition: ipv6-header.h:35
uint8_t GetNextHeader() const
Get the next header.
Definition: ipv6-header.cc:88
Keep track of a set of IPv6 interfaces.
void SetForwarding(uint32_t i, bool state)
Set the state of the stack (act as a router or as an host) for the specified index.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
an EUI-48 address
Definition: mac48-address.h:46
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:138
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
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition: packet.cc:131
build a set of SimpleNetDevice objects
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Definition: socket.cc:510
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
Definition: socket.cc:535
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
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
Hold an unsigned integer type.
Definition: uinteger.h:45
#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
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
static IcmpTestSuite icmpTestSuite
Static variable for test initialization.
Definition: icmp-test.cc:675
address
Definition: first.py:47
devices
Definition: first.py:42
interfaces
Definition: first.py:50
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