A Discrete-Event Network Simulator
API
icmp-test.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2019 Ritsumeikan University, Shiga, Japan.
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: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
19 */
20
21// Test program for the Internet Control Message Protocol (ICMP) responses.
22//
23// IcmpEchoReplyTestCase scenario:
24//
25// n0 <------------------> n1
26// i(0,0) i(1,0)
27//
28// Test that sends a single ICMP echo packet with TTL = 1 from n0 to n1,
29// n1 receives the packet and send an ICMP echo reply.
30//
31//
32// IcmpTimeExceedTestCase scenario:
33//
34// channel1 channel2
35// n0 <------------------> n1 <---------------------> n2
36// i(0,0) i(1,0) i2(1,0)
37// i2(0,0)
38//
39// Test that sends a single ICMP echo packet with TTL = 1 from n0 to n4,
40// however, the TTL is not enough and n1 reply to n0 with an ICMP time exceed.
41//
42//
43// IcmpV6EchoReplyTestCase scenario:
44//
45// n0 <-------------------> n1
46// i(0,1) i(1,1)
47//
48// Test that sends a single ICMPV6 ECHO request with hopLimit = 1 from n0 to n1,
49// n1 receives the packet and send an ICMPV6 echo reply.
50//
51// IcmpV6TimeExceedTestCase scenario:
52//
53// channel1 channel2
54// n0 <------------------> n1 <---------------------> n2
55// i(0,0) i(1,0) i2(1,0)
56// i2(0,0)
57//
58// Test that sends a single ICMPV6 echo packet with hopLimit = 1 from n0 to n4,
59// however, the hopLimit is not enough and n1 reply to n0 with an ICMPV6 time exceed error.
60
61
62#include "ns3/ipv4-address-helper.h"
63#include "ns3/ipv6-address-helper.h"
64#include "ns3/simple-net-device.h"
65#include "ns3/simple-net-device-helper.h"
66#include "ns3/simulator.h"
67#include "ns3/icmpv6-header.h"
68#include "ns3/icmpv4.h"
69#include "ns3/socket.h"
70#include "ns3/socket-factory.h"
71#include "ns3/uinteger.h"
72#include "ns3/assert.h"
73#include "ns3/log.h"
74#include "ns3/ipv4-global-routing-helper.h"
75#include "ns3/ipv6-static-routing-helper.h"
76#include "ns3/ipv6-routing-helper.h"
77#include "ns3/log.h"
78#include "ns3/node.h"
79#include "ns3/internet-stack-helper.h"
80
81#include "ns3/test.h"
82
83using namespace ns3;
84
98{
99public:
101 virtual ~IcmpEchoReplyTestCase ();
102
108 void SendData (Ptr<Socket> socket, Ipv4Address dst);
113 void ReceivePkt (Ptr<Socket> socket);
114
115private:
116 virtual void DoRun (void);
118
119};
120
121
123 : TestCase ("ICMP:EchoReply test case")
124{
125
126}
127
128
130{
131
132}
133
134
135void
137{
138 Ptr<Packet> p = Create<Packet> ();
139 Icmpv4Echo echo;
140 echo.SetSequenceNumber (1);
141 echo.SetIdentifier (0);
142 p->AddHeader (echo);
143
144 Icmpv4Header header;
145 header.SetType (Icmpv4Header::ICMPV4_ECHO);
146 header.SetCode (0);
147 p->AddHeader (header);
148
149 Address realTo = InetSocketAddress (dst, 1234);
150
151 NS_TEST_EXPECT_MSG_EQ (socket->SendTo (p, 0, realTo),
152 (int) p->GetSize (), " Unable to send ICMP Echo Packet");
153
154}
155
156
157void
159{
160 Address from;
161 Ptr<Packet> p = socket->RecvFrom (0xffffffff, 0, from);
162 m_receivedPacket = p->Copy ();
163
164 Ipv4Header ipv4;
165 p->RemoveHeader (ipv4);
166 NS_TEST_EXPECT_MSG_EQ (ipv4.GetProtocol (), 1," The received Packet is not an ICMP packet");
167
168 Icmpv4Header icmp;
169 p->RemoveHeader (icmp);
170
171 NS_TEST_EXPECT_MSG_EQ (icmp.GetType (), Icmpv4Header::ICMPV4_ECHO_REPLY,
172 " The received Packet is not a ICMPV4_ECHO_REPLY");
173}
174
175
176void
178{
180 n.Create (2);
181
182 InternetStackHelper internet;
183 internet.Install (n);
184
185 // link the two nodes
186 Ptr<SimpleNetDevice> txDev = CreateObject<SimpleNetDevice> ();
187 Ptr<SimpleNetDevice> rxDev = CreateObject<SimpleNetDevice> ();
188 n.Get (0)->AddDevice (txDev);
189 n.Get (1)->AddDevice (rxDev);
190 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
191 rxDev->SetChannel (channel1);
192 txDev->SetChannel (channel1);
194 d.Add (txDev);
195 d.Add (rxDev);
196
198
199 ipv4.SetBase ("10.0.0.0", "255.255.255.252");
200 Ipv4InterfaceContainer i = ipv4.Assign (d);
201
202 Ptr<Socket> socket;
203 socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv4RawSocketFactory"));
204 socket->SetAttribute ("Protocol", UintegerValue (1)); // ICMP protocol
206
207 InetSocketAddress src = InetSocketAddress (Ipv4Address::GetAny (), 0);
208 NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," Socket Binding failed");
209
210 // Set a TTL big enough
211 socket->SetIpTtl (1);
212 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
213 &IcmpEchoReplyTestCase::SendData, this, socket, i.GetAddress (1,0));
214 Simulator::Run ();
215
216 NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 28, " Unexpected ICMPV4_ECHO_REPLY packet size");
217
218
219 Simulator::Destroy ();
220}
221
222
230{
231public:
233 virtual ~IcmpTimeExceedTestCase ();
234
240 void SendData (Ptr<Socket> socket, Ipv4Address dst);
245 void ReceivePkt (Ptr<Socket> socket);
246
247private:
248 virtual void DoRun (void);
250
251};
252
253
255 : TestCase ("ICMP:TimeExceedReply test case")
256{
257
258}
259
260
262{
263
264}
265
266
267void
269{
270 Ptr<Packet> p = Create<Packet> ();
271 Icmpv4Echo echo;
272 echo.SetSequenceNumber (1);
273 echo.SetIdentifier (0);
274 p->AddHeader (echo);
275
276 Icmpv4Header header;
277 header.SetType (Icmpv4Header::ICMPV4_ECHO);
278 header.SetCode (0);
279 p->AddHeader (header);
280
281 Address realTo = InetSocketAddress (dst, 1234);
282
283 NS_TEST_EXPECT_MSG_EQ (socket->SendTo (p, 0, realTo),
284 (int) p->GetSize (), " Unable to send ICMP Echo Packet");
285}
286
287
288void
290{
291 Address from;
292 Ptr<Packet> p = socket->RecvFrom (0xffffffff, 0, from);
293 m_receivedPacket = p->Copy ();
294
295 Ipv4Header ipv4;
296 p->RemoveHeader (ipv4);
297 NS_TEST_EXPECT_MSG_EQ (ipv4.GetProtocol (), 1,"The received packet is not an ICMP packet");
298
299 NS_TEST_EXPECT_MSG_EQ (ipv4.GetSource (),Ipv4Address ("10.0.0.2"),
300 "ICMP Time Exceed Response should come from 10.0.0.2");
301
302 Icmpv4Header icmp;
303 p->RemoveHeader (icmp);
304
305 NS_TEST_EXPECT_MSG_EQ (icmp.GetType (), Icmpv4Header::ICMPV4_TIME_EXCEEDED,
306 "The received packet is not a ICMPV4_TIME_EXCEEDED packet ");
307}
308
309
310void
312{
313 NodeContainer n, n0n1,n1n2;
314 n.Create (3);
315 n0n1.Add (n.Get (0));
316 n0n1.Add (n.Get (1));
317 n1n2.Add (n.Get (1));
318 n1n2.Add (n.Get (2));
319
320 Ptr<SimpleChannel> channel = CreateObject <SimpleChannel> ();
321 Ptr<SimpleChannel> channel2 = CreateObject <SimpleChannel> ();
322
323 SimpleNetDeviceHelper simpleHelper;
324 simpleHelper.SetNetDevicePointToPointMode (true);
325
326 SimpleNetDeviceHelper simpleHelper2;
327 simpleHelper2.SetNetDevicePointToPointMode (true);
328
330 devices = simpleHelper.Install (n0n1,channel);
331 NetDeviceContainer devices2;
332 devices2 = simpleHelper2.Install (n1n2,channel2);
333
334 InternetStackHelper internet;
335 internet.Install (n);
336
338 address.SetBase ("10.0.0.0","255.255.255.255");
340
341 address.SetBase ("10.0.1.0","255.255.255.255");
342 Ipv4InterfaceContainer i2 = address.Assign (devices2);
343
344 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
345
346 Ptr<Socket> socket;
347 socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv4RawSocketFactory"));
348 socket->SetAttribute ("Protocol", UintegerValue (1)); // ICMP protocol
350
351 InetSocketAddress src = InetSocketAddress (Ipv4Address::GetAny (), 0);
352 NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," Socket Binding failed");
353
354
355 // The ttl is not big enough , causing an ICMP Time Exceeded response
356 socket->SetIpTtl (1);
357 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
358 &IcmpTimeExceedTestCase::SendData, this, socket, i2.GetAddress (1,0));
359 Simulator::Run ();
360
361 NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 56, " Unexpected ICMP Time Exceed Response packet size");
362
363 Simulator::Destroy ();
364}
365
366
374{
375public:
377 virtual ~IcmpV6EchoReplyTestCase ();
378
384 void SendData (Ptr<Socket> socket, Ipv6Address dst);
389 void ReceivePkt (Ptr<Socket> socket);
390
391private:
392 virtual void DoRun (void);
394
395};
396
397
399 : TestCase ("ICMPV6:EchoReply test case")
400{
401
402}
403
404
406{
407
408}
409
410
411void
413{
414 Ptr<Packet> p = Create<Packet> ();
415 Icmpv6Echo echo (1);
416 echo.SetSeq (1);
417 echo.SetId (0XB1ED);
418 p->AddHeader (echo);
419
420 Icmpv6Header header;
421 header.SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST);
422 header.SetCode (0);
423 p->AddHeader (header);
424
425 Address realTo = Inet6SocketAddress (dst, 1234);
426
427 NS_TEST_EXPECT_MSG_EQ (socket->SendTo (p, 0, realTo),
428 (int) p->GetSize (), " Unable to send ICMP Echo Packet");
429
430}
431
432
433void
435{
436 Address from;
437 Ptr<Packet> p = socket->RecvFrom (from);
438 Ptr<Packet> pkt = p->Copy ();
439
440 if (Inet6SocketAddress::IsMatchingType (from))
441 {
442 Ipv6Header ipv6;
443 p->RemoveHeader (ipv6);
444
446 Ipv6Header::IPV6_ICMPV6,
447 "The received Packet is not an ICMPV6 packet");
448 Icmpv6Header icmpv6;
449 p->RemoveHeader (icmpv6);
450
451 if (icmpv6.GetType () == Icmpv6Header::ICMPV6_ECHO_REPLY)
452 {
453 m_receivedPacket = pkt->Copy ();
454 }
455 }
456}
457
458
459void
461{
463 n.Create (2);
464
465 InternetStackHelper internet;
466 internet.Install (n);
467
468 // link the two nodes
469 Ptr<SimpleNetDevice> txDev = CreateObject<SimpleNetDevice> ();
470 Ptr<SimpleNetDevice> rxDev = CreateObject<SimpleNetDevice> ();
471 txDev->SetAddress (Mac48Address ("00:00:00:00:00:01"));
472 rxDev->SetAddress (Mac48Address ("00:00:00:00:00:02"));
473 n.Get (0)->AddDevice (txDev);
474 n.Get (1)->AddDevice (rxDev);
475 Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
476 rxDev->SetChannel (channel1);
477 txDev->SetChannel (channel1);
479 d.Add (txDev);
480 d.Add (rxDev);
481
483
484 ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
485 Ipv6InterfaceContainer i = ipv6.Assign (d);
486
487 Ptr<Socket> socket;
488 socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"));
489 socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6));
491
492 Inet6SocketAddress src = Inet6SocketAddress (Ipv6Address::GetAny (), 0);
493 NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," SocketV6 Binding failed");
494
495 // Set a TTL big enough
496 socket->SetIpTtl (1);
497
498 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
499 &IcmpV6EchoReplyTestCase::SendData, this, socket, i.GetAddress (1,1));
500 Simulator::Run ();
501
502 NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 52, " Unexpected ICMPV6_ECHO_REPLY packet size");
503
504 Simulator::Destroy ();
505}
506
507
515{
516public:
518 virtual ~IcmpV6TimeExceedTestCase ();
519
525 void SendData (Ptr<Socket> socket, Ipv6Address dst);
530 void ReceivePkt (Ptr<Socket> socket);
531
532private:
533 virtual void DoRun (void);
535
536};
537
538
540 : TestCase ("ICMPV6:TimeExceed test case")
541{
542
543}
544
545
547{
548
549}
550
551
552void
554{
555 Ptr<Packet> p = Create<Packet> ();
556 Icmpv6Echo echo (1);
557 echo.SetSeq (1);
558 echo.SetId (0XB1ED);
559 p->AddHeader (echo);
560
561 Icmpv6Header header;
562 header.SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST);
563 header.SetCode (0);
564 p->AddHeader (header);
565
566 Address realTo = Inet6SocketAddress (dst, 1234);
567
568
569 socket->SendTo (p, 0, realTo);
570
571}
572
573
574void
576{
577 Address from;
578 Ptr<Packet> p = socket->RecvFrom (from);
579 Ptr<Packet> pkt = p->Copy ();
580
581 if (Inet6SocketAddress::IsMatchingType (from))
582 {
583 Ipv6Header ipv6;
584 p->RemoveHeader (ipv6);
585
586
588 Ipv6Header::IPV6_ICMPV6,
589 "The received Packet is not an ICMPV6 packet");
590
591 Icmpv6Header icmpv6;
592 p->RemoveHeader (icmpv6);
593
594 // Ignore any packet except ICMPV6_ERROR_TIME_EXCEEDED
595 if (icmpv6.GetType () == Icmpv6Header::ICMPV6_ERROR_TIME_EXCEEDED)
596 {
597 m_receivedPacket = pkt->Copy ();
598 }
599 }
600}
601
602
603void
605{
606 NodeContainer n, n0n1,n1n2;
607 n.Create (3);
608 n0n1.Add (n.Get (0));
609 n0n1.Add (n.Get (1));
610 n1n2.Add (n.Get (1));
611 n1n2.Add (n.Get (2));
612
613 Ptr<SimpleChannel> channel = CreateObject <SimpleChannel> ();
614 Ptr<SimpleChannel> channel2 = CreateObject <SimpleChannel> ();
615
616 SimpleNetDeviceHelper simpleHelper;
617 simpleHelper.SetNetDevicePointToPointMode (true);
618
619 SimpleNetDeviceHelper simpleHelper2;
620 simpleHelper2.SetNetDevicePointToPointMode (true);
621
623 devices = simpleHelper.Install (n0n1,channel);
624
625 NetDeviceContainer devices2;
626 devices2 = simpleHelper2.Install (n1n2,channel2);
627
628 InternetStackHelper internet;
629 internet.Install (n);
630
632
633 address.NewNetwork ();
634 address.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
635
637 interfaces.SetForwarding (1,true);
638 interfaces.SetDefaultRouteInAllNodes (1);
639 address.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
640 Ipv6InterfaceContainer interfaces2 = address.Assign (devices2);
641
642 interfaces2.SetForwarding (0,true);
643 interfaces2.SetDefaultRouteInAllNodes (0);
644
645 Ptr<Socket> socket;
646 socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"));
647 socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6));
649
650 Inet6SocketAddress src = Inet6SocketAddress (Ipv6Address::GetAny (), 0);
651 NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," SocketV6 Binding failed");
652
653 // In Ipv6 TTL is renamed hop limit in IPV6.
654 // The hop limit is not big enough , causing an ICMPV6 Time Exceeded error
655 socket->SetIpv6HopLimit (1);
656
657 Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
658 &IcmpV6TimeExceedTestCase::SendData, this, socket, interfaces2.GetAddress (1,1));
659 Simulator::Run ();
660
661 NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 100, " Unexpected ICMPV6_ECHO_REPLY packet size");
662
663 Simulator::Destroy ();
664}
665
666
675{
676public:
677 IcmpTestSuite ();
678};
679
681 : TestSuite ("icmp", UNIT)
682{
683 AddTestCase (new IcmpEchoReplyTestCase, TestCase::QUICK);
684 AddTestCase (new IcmpTimeExceedTestCase, TestCase::QUICK);
685 AddTestCase (new IcmpV6EchoReplyTestCase, TestCase::QUICK);
686 AddTestCase (new IcmpV6TimeExceedTestCase, TestCase::QUICK);
687}
688
690
NodeContainer n1n2
ICMP Echo Reply Test.
Definition: icmp-test.cc:98
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:158
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Definition: icmp-test.cc:136
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:177
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:117
virtual ~IcmpEchoReplyTestCase()
Definition: icmp-test.cc:129
ICMP TestSuite.
Definition: icmp-test.cc:675
ICMP Time Exceed Reply Test.
Definition: icmp-test.cc:230
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:311
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:289
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:249
virtual ~IcmpTimeExceedTestCase()
Definition: icmp-test.cc:261
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Definition: icmp-test.cc:268
ICMPV6 Echo Reply Test.
Definition: icmp-test.cc:374
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:393
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
Definition: icmp-test.cc:412
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:434
virtual ~IcmpV6EchoReplyTestCase()
Definition: icmp-test.cc:405
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:460
ICMPV6 Time Exceed response test.
Definition: icmp-test.cc:515
virtual ~IcmpV6TimeExceedTestCase()
Definition: icmp-test.cc:546
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:575
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:604
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:534
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
Definition: icmp-test.cc:553
a polymophic address class
Definition: address.h:91
ICMP Echo header.
Definition: icmpv4.h:108
void SetIdentifier(uint16_t id)
Set the Echo identifier.
Definition: icmpv4.cc:140
void SetSequenceNumber(uint16_t seq)
Set the Echo sequence number.
Definition: icmpv4.cc:146
Base class for all the ICMP packet headers.
Definition: icmpv4.h:41
void SetCode(uint8_t code)
Set ICMP code.
Definition: icmpv4.cc:115
void SetType(uint8_t type)
Set ICMP type.
Definition: icmpv4.cc:109
uint8_t GetType(void) const
Get ICMP type.
Definition: icmpv4.cc:121
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:39
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.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
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:41
Packet header for IPv4.
Definition: ipv4-header.h:34
Ipv4Address GetSource(void) const
Definition: ipv4-header.cc:291
uint8_t GetProtocol(void) const
Definition: ipv4-header.cc:272
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:50
Packet header for IPv6.
Definition: ipv6-header.h:36
uint8_t GetNextHeader(void) const
Get the next header.
Definition: ipv6-header.cc:80
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:456
an EUI-48 address
Definition: mac48-address.h:44
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(NodeContainer other)
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 GetId(void) const
Definition: node.cc:109
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:130
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
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:513
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 void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
Definition: socket.cc:538
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
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:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
Hold an unsigned integer type.
Definition: uinteger.h:44
#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:240
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
static IcmpTestSuite icmpTestSuite
Static variable for test initialization.
Definition: icmp-test.cc:689
address
Definition: first.py:44
devices
Definition: first.py:39
interfaces
Definition: first.py:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:1648
channel
Definition: third.py:92