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 
83 using namespace ns3;
84 
98 {
99 public:
101  virtual ~IcmpEchoReplyTestCase ();
102 
108  void SendData (Ptr<Socket> socket, Ipv4Address dst);
113  void ReceivePkt (Ptr<Socket> socket);
114 
115 private:
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 
135 void
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 
157 void
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 
176 void
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 
197  Ipv4AddressHelper ipv4;
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 {
231 public:
233  virtual ~IcmpTimeExceedTestCase ();
234 
240  void SendData (Ptr<Socket> socket, Ipv4Address dst);
245  void ReceivePkt (Ptr<Socket> socket);
246 
247 private:
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 
267 void
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 
288 void
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 
310 void
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 {
375 public:
377  virtual ~IcmpV6EchoReplyTestCase ();
378 
384  void SendData (Ptr<Socket> socket, Ipv6Address dst);
389  void ReceivePkt (Ptr<Socket> socket);
390 
391 private:
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 
411 void
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 
433 void
435 {
436  Address from;
437  Ptr<Packet> p = socket->RecvFrom (from);
438  m_receivedPacket = 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  // Ignore the neighbor discovery (ICMPV6_ND) packets
452  if (!(((int)icmpv6.GetType () >= 133) && ((int)icmpv6.GetType () <= 137)))
453  {
454  NS_TEST_EXPECT_MSG_EQ ((int) icmpv6.GetType (),
455  Icmpv6Header::ICMPV6_ECHO_REPLY,
456  "The received Packet is not a ICMPV6_ECHO_REPLY");
457  }
458  }
459 }
460 
461 
462 void
464 {
466  n.Create (2);
467 
468  InternetStackHelper internet;
469  internet.Install (n);
470 
471  // link the two nodes
472  Ptr<SimpleNetDevice> txDev = CreateObject<SimpleNetDevice> ();
473  Ptr<SimpleNetDevice> rxDev = CreateObject<SimpleNetDevice> ();
474  txDev->SetAddress (Mac48Address ("00:00:00:00:00:01"));
475  rxDev->SetAddress (Mac48Address ("00:00:00:00:00:02"));
476  n.Get (0)->AddDevice (txDev);
477  n.Get (1)->AddDevice (rxDev);
478  Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
479  rxDev->SetChannel (channel1);
480  txDev->SetChannel (channel1);
482  d.Add (txDev);
483  d.Add (rxDev);
484 
485  Ipv6AddressHelper ipv6;
486 
487  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
488  Ipv6InterfaceContainer i = ipv6.Assign (d);
489 
490  Ptr<Socket> socket;
491  socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"));
492  socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6));
494 
495  Inet6SocketAddress src = Inet6SocketAddress (Ipv6Address::GetAny (), 0);
496  NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," SocketV6 Binding failed");
497 
498  // Set a TTL big enough
499  socket->SetIpTtl (1);
500 
501  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
502  &IcmpV6EchoReplyTestCase::SendData, this, socket, i.GetAddress (1,1));
503  Simulator::Run ();
504 
505  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 72, " Unexpected ICMPV6_ECHO_REPLY packet size");
506 
507  Simulator::Destroy ();
508 }
509 
510 
518 {
519 public:
521  virtual ~IcmpV6TimeExceedTestCase ();
522 
528  void SendData (Ptr<Socket> socket, Ipv6Address dst);
533  void ReceivePkt (Ptr<Socket> socket);
534 
535 private:
536  virtual void DoRun (void);
538 
539 };
540 
541 
543  : TestCase ("ICMPV6:TimeExceed test case")
544 {
545 
546 }
547 
548 
550 {
551 
552 }
553 
554 
555 void
557 {
558  Ptr<Packet> p = Create<Packet> ();
559  Icmpv6Echo echo (1);
560  echo.SetSeq (1);
561  echo.SetId (0XB1ED);
562  p->AddHeader (echo);
563 
564  Icmpv6Header header;
565  header.SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST);
566  header.SetCode (0);
567  p->AddHeader (header);
568 
569  Address realTo = Inet6SocketAddress (dst, 1234);
570 
571 
572  socket->SendTo (p, 0, realTo);
573 
574 }
575 
576 
577 void
579 {
580  Address from;
581  Ptr<Packet> p = socket->RecvFrom (from);
582  m_receivedPacket = p->Copy ();
583 
584  if (Inet6SocketAddress::IsMatchingType (from))
585  {
586  Ipv6Header ipv6;
587  p->RemoveHeader (ipv6);
588 
589 
591  Ipv6Header::IPV6_ICMPV6,
592  "The received Packet is not an ICMPV6 packet");
593 
594  Icmpv6Header icmpv6;
595  p->RemoveHeader (icmpv6);
596 
597  // Ignore the neighbor discovery (ICMPV6_ND) packets
598  if (!(((int)icmpv6.GetType () >= 133) && ((int)icmpv6.GetType () <= 137)))
599  {
600  NS_TEST_EXPECT_MSG_EQ ((int) icmpv6.GetType (),
601  Icmpv6Header::ICMPV6_ERROR_TIME_EXCEEDED,
602  "The received Packet is not a ICMPV6_ERROR_TIME_EXCEEDED");
603  }
604  }
605 }
606 
607 
608 void
610 {
611  NodeContainer n, n0n1,n1n2;
612  n.Create (3);
613  n0n1.Add (n.Get (0));
614  n0n1.Add (n.Get (1));
615  n1n2.Add (n.Get (1));
616  n1n2.Add (n.Get (2));
617 
618  Ptr<SimpleChannel> channel = CreateObject <SimpleChannel> ();
619  Ptr<SimpleChannel> channel2 = CreateObject <SimpleChannel> ();
620 
621  SimpleNetDeviceHelper simpleHelper;
622  simpleHelper.SetNetDevicePointToPointMode (true);
623 
624  SimpleNetDeviceHelper simpleHelper2;
625  simpleHelper2.SetNetDevicePointToPointMode (true);
626 
628  devices = simpleHelper.Install (n0n1,channel);
629 
630  NetDeviceContainer devices2;
631  devices2 = simpleHelper2.Install (n1n2,channel2);
632 
633  InternetStackHelper internet;
634  internet.Install (n);
635 
637 
638  address.NewNetwork ();
639  address.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
640 
642  interfaces.SetForwarding (1,true);
643  interfaces.SetDefaultRouteInAllNodes (1);
644  address.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
645  Ipv6InterfaceContainer interfaces2 = address.Assign (devices2);
646 
647  interfaces2.SetForwarding (0,true);
648  interfaces2.SetDefaultRouteInAllNodes (0);
649 
650  Ptr<Socket> socket;
651  socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"));
652  socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6));
654 
655  Inet6SocketAddress src = Inet6SocketAddress (Ipv6Address::GetAny (), 0);
656  NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," SocketV6 Binding failed");
657 
658  // In Ipv6 TTL is renamed hop limit in IPV6.
659  // The hop limit is not big enough , causing an ICMPV6 Time Exceeded error
660  socket->SetIpv6HopLimit (1);
661 
662  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
663  &IcmpV6TimeExceedTestCase::SendData, this, socket, interfaces2.GetAddress (1,1));
664  Simulator::Run ();
665 
666  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 72, " Unexpected ICMPV6_ECHO_REPLY packet size");
667 
668  Simulator::Destroy ();
669 }
670 
671 
679 class IcmpTestSuite : public TestSuite
680 {
681 public:
682  IcmpTestSuite ();
683 };
684 
686  : TestSuite ("icmp", UNIT)
687 {
688  AddTestCase (new IcmpEchoReplyTestCase, TestCase::QUICK);
689  AddTestCase (new IcmpTimeExceedTestCase, TestCase::QUICK);
690  AddTestCase (new IcmpV6EchoReplyTestCase, TestCase::QUICK);
691  AddTestCase (new IcmpV6TimeExceedTestCase, TestCase::QUICK);
692 }
693 
695 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
Definition: icmp-test.cc:412
void SetType(uint8_t type)
Set ICMP type.
Definition: icmpv4.cc:109
Packet header for IPv6.
Definition: ipv6-header.h:34
an Inet address class
uint32_t GetId(void) const
Definition: node.cc:109
Keep track of a set of IPv6 interfaces.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:177
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
A suite of tests to run.
Definition: test.h:1343
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:289
ICMP TestSuite.
Definition: icmp-test.cc:679
Ipv4Address GetSource(void) const
Definition: ipv4-header.cc:291
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Definition: icmp-test.cc:268
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:311
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
encapsulates test code
Definition: test.h:1153
static IcmpTestSuite icmpTestSuite
Static variable for test initialization.
Definition: icmp-test.cc:694
ICMPV6 Time Exceed response test.
Definition: icmp-test.cc:517
Base class for all the ICMP packet headers.
Definition: icmpv4.h:40
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.
a polymophic address class
Definition: address.h:90
channel
Definition: third.py:92
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:249
uint8_t GetProtocol(void) const
Definition: ipv4-header.cc:272
void SetCode(uint8_t code)
Set ICMP code.
Definition: icmpv4.cc:115
virtual ~IcmpTimeExceedTestCase()
Definition: icmp-test.cc:261
Packet header for IPv4.
Definition: ipv4-header.h:33
virtual ~IcmpV6EchoReplyTestCase()
Definition: icmp-test.cc:405
void SetType(uint8_t type)
Set the type.
ICMPv6 header.
Definition: icmpv6-header.h:38
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Definition: icmp-test.cc:136
virtual ~IcmpV6TimeExceedTestCase()
Definition: icmp-test.cc:549
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Hold an unsigned integer type.
Definition: uinteger.h:44
holds a vector of ns3::NetDevice pointers
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:117
An Inet6 address class.
ICMP Echo Reply Test.
Definition: icmp-test.cc:97
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:537
ICMP Time Exceed Reply Test.
Definition: icmp-test.cc:229
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:434
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
Ptr< Packet > m_receivedPacket
received packet
Definition: icmp-test.cc:393
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:609
address
Definition: first.py:44
void SetCode(uint8_t code)
Set the code field.
ICMP Echo header.
Definition: icmpv4.h:107
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint8_t GetNextHeader(void) const
Get the next header.
Definition: ipv6-header.cc:80
an EUI-48 address
Definition: mac48-address.h:43
ICMPV6 Echo Reply Test.
Definition: icmp-test.cc:373
virtual ~IcmpEchoReplyTestCase()
Definition: icmp-test.cc:129
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
ICMPv6 Echo message.
Helper class to auto-assign global IPv6 unicast addresses.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
Definition: icmp-test.cc:556
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:158
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void SetSequenceNumber(uint16_t seq)
Set the Echo sequence number.
Definition: icmpv4.cc:146
virtual void SetAddress(Address address)
Set the address of this interface.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Definition: icmp-test.cc:578
interfaces
Definition: first.py:48
Describes an IPv6 prefix.
Definition: ipv6-address.h:466
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
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.
devices
Definition: first.py:39
build a set of SimpleNetDevice objects
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
Definition: socket.cc:538
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
NodeContainer n1n2
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:463
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Definition: socket.cc:513
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.