A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
79using namespace ns3;
80
81/**
82 * \ingroup internet-apps
83 * \defgroup icmp-test ICMP protocol tests
84 */
85
86/**
87 * \ingroup icmp-test
88 * \ingroup tests
89 *
90 * \brief ICMP Echo Reply Test
91 */
93{
94 public:
96 ~IcmpEchoReplyTestCase() override;
97
98 /**
99 * Send data
100 * \param socket output socket
101 * \param dst destination address
102 */
103 void SendData(Ptr<Socket> socket, Ipv4Address dst);
104 /**
105 * Receive data
106 * \param socket input socket
107 */
108 void ReceivePkt(Ptr<Socket> socket);
109
110 private:
111 void DoRun() override;
112 Ptr<Packet> m_receivedPacket; //!< received packet
113};
114
116 : TestCase("ICMP:EchoReply test case")
117{
118}
119
121{
122}
123
124void
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;
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
145void
147{
148 Address from;
149 Ptr<Packet> p = socket->RecvFrom(0xffffffff, 0, from);
150 m_receivedPacket = p->Copy();
151
152 Ipv4Header ipv4;
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
161 " The received Packet is not a ICMPV4_ECHO_REPLY");
162}
163
164void
166{
168 n.Create(2);
169
170 InternetStackHelper internet;
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
193 socket->SetRecvCallback(MakeCallback(&IcmpEchoReplyTestCase::ReceivePkt, this));
194
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));
207
209 28,
210 " Unexpected ICMPV4_ECHO_REPLY packet size");
211
213}
214
215/**
216 * \ingroup icmp-test
217 * \ingroup tests
218 *
219 * \brief ICMP Time Exceed Reply Test
220 */
222{
223 public:
225 ~IcmpTimeExceedTestCase() override;
226
227 /**
228 * Send data
229 * \param socket output socket
230 * \param dst destination address
231 */
232 void SendData(Ptr<Socket> socket, Ipv4Address dst);
233 /**
234 * Receive data
235 * \param socket input socket
236 */
237 void ReceivePkt(Ptr<Socket> socket);
238
239 private:
240 void DoRun() override;
241 Ptr<Packet> m_receivedPacket; //!< received packet
242};
243
245 : TestCase("ICMP:TimeExceedReply test case")
246{
247}
248
250{
251}
252
253void
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;
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
274void
276{
277 Address from;
278 Ptr<Packet> p = socket->RecvFrom(0xffffffff, 0, from);
279 m_receivedPacket = p->Copy();
280
281 Ipv4Header ipv4;
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
294 "The received packet is not a ICMPV4_TIME_EXCEEDED packet ");
295}
296
297void
299{
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
318 NetDeviceContainer devices;
319 devices = simpleHelper.Install(n0n1, channel);
320 NetDeviceContainer devices2;
321 devices2 = simpleHelper2.Install(n1n2, channel2);
322
323 InternetStackHelper internet;
324 internet.Install(n);
325
326 Ipv4AddressHelper address;
327 address.SetBase("10.0.0.0", "255.255.255.255");
328 Ipv4InterfaceContainer i = address.Assign(devices);
329
330 address.SetBase("10.0.1.0", "255.255.255.255");
331 Ipv4InterfaceContainer i2 = address.Assign(devices2);
332
334
335 Ptr<Socket> socket;
336 socket = Socket::CreateSocket(n.Get(0), TypeId::LookupByName("ns3::Ipv4RawSocketFactory"));
337 socket->SetAttribute("Protocol", UintegerValue(1)); // ICMP protocol
338 socket->SetRecvCallback(MakeCallback(&IcmpTimeExceedTestCase::ReceivePkt, this));
339
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));
352
354 56,
355 " Unexpected ICMP Time Exceed Response packet size");
356
358}
359
360/**
361 * \ingroup icmp-test
362 * \ingroup tests
363 *
364 * \brief ICMPV6 Echo Reply Test
365 */
367{
368 public:
370 ~IcmpV6EchoReplyTestCase() override;
371
372 /**
373 * Send data
374 * \param socket output socket
375 * \param dst destination address
376 */
377 void SendData(Ptr<Socket> socket, Ipv6Address dst);
378 /**
379 * Receive data
380 * \param socket input socket
381 */
382 void ReceivePkt(Ptr<Socket> socket);
383
384 private:
385 void DoRun() override;
386 Ptr<Packet> m_receivedPacket; //!< received packet
387};
388
390 : TestCase("ICMPV6:EchoReply test case")
391{
392}
393
395{
396}
397
398void
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;
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
419void
421{
422 Address from;
423 Ptr<Packet> p = socket->RecvFrom(from);
424 Ptr<Packet> pkt = p->Copy();
425
427 {
428 Ipv6Header ipv6;
429 p->RemoveHeader(ipv6);
430
433 "The received Packet is not an ICMPV6 packet");
434 Icmpv6Header icmpv6;
435 p->RemoveHeader(icmpv6);
436
438 {
439 m_receivedPacket = pkt->Copy();
440 }
441 }
442}
443
444void
446{
448 n.Create(2);
449
450 InternetStackHelper internet;
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
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));
475 socket->SetRecvCallback(MakeCallback(&IcmpV6EchoReplyTestCase::ReceivePkt, this));
476
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));
490
492 52,
493 " Unexpected ICMPV6_ECHO_REPLY packet size");
494
496}
497
498/**
499 * \ingroup icmp-test
500 * \ingroup tests
501 *
502 * \brief ICMPV6 Time Exceed response test
503 */
505{
506 public:
508 ~IcmpV6TimeExceedTestCase() override;
509
510 /**
511 * Send data
512 * \param socket output socket
513 * \param dst destination address
514 */
515 void SendData(Ptr<Socket> socket, Ipv6Address dst);
516 /**
517 * Receive data
518 * \param socket input socket
519 */
520 void ReceivePkt(Ptr<Socket> socket);
521
522 private:
523 void DoRun() override;
524 Ptr<Packet> m_receivedPacket; //!< received packet
525};
526
528 : TestCase("ICMPV6:TimeExceed test case")
529{
530}
531
533{
534}
535
536void
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;
547 header.SetCode(0);
548 p->AddHeader(header);
549
550 Address realTo = Inet6SocketAddress(dst, 1234);
551
552 socket->SendTo(p, 0, realTo);
553}
554
555void
557{
558 Address from;
559 Ptr<Packet> p = socket->RecvFrom(from);
560 Ptr<Packet> pkt = p->Copy();
561
563 {
564 Ipv6Header ipv6;
565 p->RemoveHeader(ipv6);
566
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
576 {
577 m_receivedPacket = pkt->Copy();
578 }
579 }
580}
581
582void
584{
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
603 NetDeviceContainer devices;
604 devices = simpleHelper.Install(n0n1, channel);
605
606 NetDeviceContainer devices2;
607 devices2 = simpleHelper2.Install(n1n2, channel2);
608
609 InternetStackHelper internet;
610 internet.Install(n);
611
612 Ipv6AddressHelper address;
613
614 address.NewNetwork();
615 address.SetBase(Ipv6Address("2001:1::"), Ipv6Prefix(64));
616
617 Ipv6InterfaceContainer interfaces = address.Assign(devices);
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));
629 socket->SetRecvCallback(MakeCallback(&IcmpV6TimeExceedTestCase::ReceivePkt, this));
630
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));
645
647 100,
648 " Unexpected ICMPV6_ECHO_REPLY packet size");
649
651}
652
653/**
654 * \ingroup icmp-test
655 * \ingroup tests
656 *
657 * \brief ICMP TestSuite
658 */
659
661{
662 public:
664};
665
667 : TestSuite("icmp", Type::UNIT)
668{
669 AddTestCase(new IcmpEchoReplyTestCase, TestCase::Duration::QUICK);
670 AddTestCase(new IcmpTimeExceedTestCase, TestCase::Duration::QUICK);
671 AddTestCase(new IcmpV6EchoReplyTestCase, TestCase::Duration::QUICK);
672 AddTestCase(new IcmpV6TimeExceedTestCase, TestCase::Duration::QUICK);
673}
674
675static IcmpTestSuite icmpTestSuite; //!< Static variable for test initialization
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
@ ICMPV4_TIME_EXCEEDED
Definition: icmpv4.h:53
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.
static bool IsMatchingType(const Address &addr)
If the address match.
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
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
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
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
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:135
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:861
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:588
static void Run()
Run the simulation.
Definition: simulator.cc:178
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Definition: socket.cc:72
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:836
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:252
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
static IcmpTestSuite icmpTestSuite
Static variable for test initialization.
Definition: icmp-test.cc:675
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:706