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 
103  void SendData (Ptr<Socket> socket, Ipv4Address dst);
104  void DoSendData (Ptr<Socket> socket, Ipv4Address dst);
105  void ReceivePkt (Ptr<Socket> socket);
106 
107 private:
108  virtual void DoRun (void);
110 
111 };
112 
113 
115  : TestCase ("ICMP:EchoReply test case")
116 {
117 
118 }
119 
120 
122 {
123 
124 }
125 
126 
127 void
129 {
130  Ptr<Packet> p = Create<Packet> ();
131  Icmpv4Echo echo;
132  echo.SetSequenceNumber (1);
133  echo.SetIdentifier (0);
134  p->AddHeader (echo);
135 
136  Icmpv4Header header;
137  header.SetType (Icmpv4Header::ICMPV4_ECHO);
138  header.SetCode (0);
139  p->AddHeader (header);
140 
141  Address realTo = InetSocketAddress (dst, 1234);
142 
143  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (p, 0, realTo),
144  (int) p->GetSize (), " Unable to send ICMP Echo Packet");
145 
146 }
147 
148 
149 void
151 {
152  m_receivedPacket = Create<Packet> ();
153  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
154  &IcmpEchoReplyTestCase::DoSendData, this, socket, dst);
155  Simulator::Run ();
156 }
157 
158 void
160 {
161  Address from;
162  Ptr<Packet> p = socket->RecvFrom (0xffffffff, 0, from);
163  m_receivedPacket = p->Copy ();
164 
165  Ipv4Header ipv4;
166  p->RemoveHeader (ipv4);
167  NS_TEST_EXPECT_MSG_EQ (ipv4.GetProtocol (), 1," The received Packet is not an ICMP packet");
168 
169  Icmpv4Header icmp;
170  p->RemoveHeader (icmp);
171 
172  NS_TEST_EXPECT_MSG_EQ (icmp.GetType (), Icmpv4Header::ICMPV4_ECHO_REPLY,
173  " The received Packet is not a ICMPV4_ECHO_REPLY");
174 }
175 
176 
177 void
179 {
181  n.Create (2);
182 
183  InternetStackHelper internet;
184  internet.Install (n);
185 
186  // link the two nodes
187  Ptr<SimpleNetDevice> txDev = CreateObject<SimpleNetDevice> ();
188  Ptr<SimpleNetDevice> rxDev = CreateObject<SimpleNetDevice> ();
189  n.Get (0)->AddDevice (txDev);
190  n.Get (1)->AddDevice (rxDev);
191  Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel> ();
192  rxDev->SetChannel (channel1);
193  txDev->SetChannel (channel1);
195  d.Add (txDev);
196  d.Add (rxDev);
197 
198  Ipv4AddressHelper ipv4;
199 
200  ipv4.SetBase ("10.0.0.0", "255.255.255.252");
201  Ipv4InterfaceContainer i = ipv4.Assign (d);
202 
203  Ptr<Socket> socket;
204  socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv4RawSocketFactory"));
205  socket->SetAttribute ("Protocol", UintegerValue (1)); // ICMP protocol
207 
208  InetSocketAddress src = InetSocketAddress (Ipv4Address::GetAny (), 0);
209  NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," Socket Binding failed");
210 
211  // Set a TTL big enough
212  socket->SetIpTtl (1);
213  SendData (socket, i.GetAddress (1,0));
214 
215  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 28, " Unexpected ICMPV4_ECHO_REPLY packet size");
216 
217 
218  Simulator::Destroy ();
219 }
220 
221 
229 {
230 public:
232  virtual ~IcmpTimeExceedTestCase ();
233 
234  void SendData (Ptr<Socket> socket, Ipv4Address dst);
235  void DoSendData (Ptr<Socket> socket, Ipv4Address dst);
236  void ReceivePkt (Ptr<Socket> socket);
237 
238 private:
239  virtual void DoRun (void);
241 
242 };
243 
244 
246  : TestCase ("ICMP:TimeExceedReply test case")
247 {
248 
249 }
250 
251 
253 {
254 
255 }
256 
257 
258 void
260 {
261  Ptr<Packet> p = Create<Packet> ();
262  Icmpv4Echo echo;
263  echo.SetSequenceNumber (1);
264  echo.SetIdentifier (0);
265  p->AddHeader (echo);
266 
267  Icmpv4Header header;
268  header.SetType (Icmpv4Header::ICMPV4_ECHO);
269  header.SetCode (0);
270  p->AddHeader (header);
271 
272  Address realTo = InetSocketAddress (dst, 1234);
273 
274  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (p, 0, realTo),
275  (int) p->GetSize (), " Unable to send ICMP Echo Packet");
276 }
277 
278 
279 void
281 {
282  m_receivedPacket = Create<Packet> ();
283  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
284  &IcmpTimeExceedTestCase::DoSendData, this, socket, dst);
285  Simulator::Run ();
286 }
287 
288 
289 void
291 {
292  Address from;
293  Ptr<Packet> p = socket->RecvFrom (0xffffffff, 0, from);
294  m_receivedPacket = p->Copy ();
295 
296  Ipv4Header ipv4;
297  p->RemoveHeader (ipv4);
298  NS_TEST_EXPECT_MSG_EQ (ipv4.GetProtocol (), 1,"The received packet is not an ICMP packet");
299 
300  NS_TEST_EXPECT_MSG_EQ (ipv4.GetSource (),Ipv4Address ("10.0.0.2"),
301  "ICMP Time Exceed Response should come from 10.0.0.2");
302 
303  Icmpv4Header icmp;
304  p->RemoveHeader (icmp);
305 
306  NS_TEST_EXPECT_MSG_EQ (icmp.GetType (), Icmpv4Header::ICMPV4_TIME_EXCEEDED,
307  "The received packet is not a ICMPV4_TIME_EXCEEDED packet ");
308 }
309 
310 
311 void
313 {
314  NodeContainer n, n0n1,n1n2;
315  n.Create (3);
316  n0n1.Add (n.Get (0));
317  n0n1.Add (n.Get (1));
318  n1n2.Add (n.Get (1));
319  n1n2.Add (n.Get (2));
320 
321  Ptr<SimpleChannel> channel = CreateObject <SimpleChannel> ();
322  Ptr<SimpleChannel> channel2 = CreateObject <SimpleChannel> ();
323 
324  SimpleNetDeviceHelper simpleHelper;
325  simpleHelper.SetNetDevicePointToPointMode (true);
326 
327  SimpleNetDeviceHelper simpleHelper2;
328  simpleHelper2.SetNetDevicePointToPointMode (true);
329 
331  devices = simpleHelper.Install (n0n1,channel);
332  NetDeviceContainer devices2;
333  devices2 = simpleHelper2.Install (n1n2,channel2);
334 
335  InternetStackHelper internet;
336  internet.Install (n);
337 
339  address.SetBase ("10.0.0.0","255.255.255.255");
341 
342  address.SetBase ("10.0.1.0","255.255.255.255");
343  Ipv4InterfaceContainer i2 = address.Assign (devices2);
344 
345  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
346 
347  Ptr<Socket> socket;
348  socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv4RawSocketFactory"));
349  socket->SetAttribute ("Protocol", UintegerValue (1)); // ICMP protocol
351 
352  InetSocketAddress src = InetSocketAddress (Ipv4Address::GetAny (), 0);
353  NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," Socket Binding failed");
354 
355 
356  // The ttl is not big enough , causing an ICMP Time Exceeded response
357  socket->SetIpTtl (1);
358  SendData (socket, i2.GetAddress (1,0));
359 
360  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 56, " Unexpected ICMP Time Exceed Response packet size");
361 
362  Simulator::Destroy ();
363 }
364 
365 
373 {
374 public:
376  virtual ~IcmpV6EchoReplyTestCase ();
377 
378  void SendData (Ptr<Socket> socket, Ipv6Address dst);
379  void DoSendData (Ptr<Socket> socket, Ipv6Address dst);
380  void ReceivePkt (Ptr<Socket> socket);
381 
382 private:
383  virtual void DoRun (void);
385 
386 };
387 
388 
390  : TestCase ("ICMPV6:EchoReply test case")
391 {
392 
393 }
394 
395 
397 {
398 
399 }
400 
401 
402 void
404 {
405  Ptr<Packet> p = Create<Packet> ();
406  Icmpv6Echo echo (1);
407  echo.SetSeq (1);
408  echo.SetId (0XB1ED);
409  p->AddHeader (echo);
410 
411  Icmpv6Header header;
412  header.SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST);
413  header.SetCode (0);
414  p->AddHeader (header);
415 
416  Address realTo = Inet6SocketAddress (dst, 1234);
417 
418  NS_TEST_EXPECT_MSG_EQ (socket->SendTo (p, 0, realTo),
419  (int) p->GetSize (), " Unable to send ICMP Echo Packet");
420 
421 }
422 
423 
424 void
426 {
427  m_receivedPacket = Create<Packet> ();
428  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
429  &IcmpV6EchoReplyTestCase::DoSendData, this, socket, dst);
430  Simulator::Run ();
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  SendData (socket, i.GetAddress (1,1));
502 
503  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 72, " Unexpected ICMPV6_ECHO_REPLY packet size");
504 
505  Simulator::Destroy ();
506 }
507 
508 
516 {
517 public:
519  virtual ~IcmpV6TimeExceedTestCase ();
520 
521  void SendData (Ptr<Socket> socket, Ipv6Address dst);
522  void DoSendData (Ptr<Socket> socket, Ipv6Address dst);
523  void ReceivePkt (Ptr<Socket> socket);
524 
525 private:
526  virtual void DoRun (void);
528 
529 };
530 
531 
533  : TestCase ("ICMPV6:TimeExceed test case")
534 {
535 
536 }
537 
538 
540 {
541 
542 }
543 
544 
545 void
547 {
548  Ptr<Packet> p = Create<Packet> ();
549  Icmpv6Echo echo (1);
550  echo.SetSeq (1);
551  echo.SetId (0XB1ED);
552  p->AddHeader (echo);
553 
554  Icmpv6Header header;
555  header.SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST);
556  header.SetCode (0);
557  p->AddHeader (header);
558 
559  Address realTo = Inet6SocketAddress (dst, 1234);
560 
561 
562  socket->SendTo (p, 0, realTo);
563 
564 }
565 
566 
567 void
569 {
570  m_receivedPacket = Create<Packet> ();
571  Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (0),
572  &IcmpV6TimeExceedTestCase::DoSendData, this, socket, dst);
573  Simulator::Run ();
574 }
575 
576 void
578 {
579  Address from;
580  Ptr<Packet> p = socket->RecvFrom (from);
581  m_receivedPacket = p->Copy ();
582 
583  if (Inet6SocketAddress::IsMatchingType (from))
584  {
585  Ipv6Header ipv6;
586  p->RemoveHeader (ipv6);
587 
588 
590  Ipv6Header::IPV6_ICMPV6,
591  "The received Packet is not an ICMPV6 packet");
592 
593  Icmpv6Header icmpv6;
594  p->RemoveHeader (icmpv6);
595 
596  // Ignore the neighbor discovery (ICMPV6_ND) packets
597  if (!(((int)icmpv6.GetType () >= 133) && ((int)icmpv6.GetType () <= 137)))
598  {
599  NS_TEST_EXPECT_MSG_EQ ((int) icmpv6.GetType (),
600  Icmpv6Header::ICMPV6_ERROR_TIME_EXCEEDED,
601  "The received Packet is not a ICMPV6_ERROR_TIME_EXCEEDED");
602  }
603  }
604 }
605 
606 
607 void
609 {
610  NodeContainer n, n0n1,n1n2;
611  n.Create (3);
612  n0n1.Add (n.Get (0));
613  n0n1.Add (n.Get (1));
614  n1n2.Add (n.Get (1));
615  n1n2.Add (n.Get (2));
616 
617  Ptr<SimpleChannel> channel = CreateObject <SimpleChannel> ();
618  Ptr<SimpleChannel> channel2 = CreateObject <SimpleChannel> ();
619 
620  SimpleNetDeviceHelper simpleHelper;
621  simpleHelper.SetNetDevicePointToPointMode (true);
622 
623  SimpleNetDeviceHelper simpleHelper2;
624  simpleHelper2.SetNetDevicePointToPointMode (true);
625 
627  devices = simpleHelper.Install (n0n1,channel);
628 
629  NetDeviceContainer devices2;
630  devices2 = simpleHelper2.Install (n1n2,channel2);
631 
632  InternetStackHelper internet;
633  internet.Install (n);
634 
636 
637  address.NewNetwork ();
638  address.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
639 
641  interfaces.SetForwarding (1,true);
642  interfaces.SetDefaultRouteInAllNodes (1);
643  address.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
644  Ipv6InterfaceContainer interfaces2 = address.Assign (devices2);
645 
646  interfaces2.SetForwarding (0,true);
647  interfaces2.SetDefaultRouteInAllNodes (0);
648 
649  Ptr<Socket> socket;
650  socket = Socket::CreateSocket (n.Get (0), TypeId::LookupByName ("ns3::Ipv6RawSocketFactory"));
651  socket->SetAttribute ("Protocol", UintegerValue (Ipv6Header::IPV6_ICMPV6));
653 
654  Inet6SocketAddress src = Inet6SocketAddress (Ipv6Address::GetAny (), 0);
655  NS_TEST_EXPECT_MSG_EQ (socket->Bind (src),0," SocketV6 Binding failed");
656 
657  // In Ipv6 TTL is renamed hop limit in IPV6.
658  // The hop limit is not big enough , causing an ICMPV6 Time Exceeded error
659  socket->SetIpv6HopLimit (1);
660 
661  SendData (socket, interfaces2.GetAddress (1,1));
662 
663  NS_TEST_EXPECT_MSG_EQ (m_receivedPacket->GetSize (), 72, " Unexpected ICMPV6_ECHO_REPLY packet size");
664 
665  Simulator::Destroy ();
666 }
667 
668 
676 class IcmpTestSuite : public TestSuite
677 {
678 public:
679  IcmpTestSuite ();
680 };
681 
683  : TestSuite ("icmp", UNIT)
684 {
685  AddTestCase (new IcmpEchoReplyTestCase, TestCase::QUICK);
686  AddTestCase (new IcmpTimeExceedTestCase, TestCase::QUICK);
687  AddTestCase (new IcmpV6EchoReplyTestCase, TestCase::QUICK);
688  AddTestCase (new IcmpV6TimeExceedTestCase, TestCase::QUICK);
689 }
690 
692 
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)
Definition: icmp-test.cc:425
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:107
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:178
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:1342
void ReceivePkt(Ptr< Socket > socket)
Definition: icmp-test.cc:290
ICMP TestSuite.
Definition: icmp-test.cc:676
Ipv4Address GetSource(void) const
Definition: ipv4-header.cc:291
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Definition: icmp-test.cc:280
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: icmp-test.cc:312
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:285
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:1155
static IcmpTestSuite icmpTestSuite
Static variable for test initialization.
Definition: icmp-test.cc:691
ICMPV6 Time Exceed response test.
Definition: icmp-test.cc:515
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
Definition: icmp-test.cc:240
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:252
Packet header for IPv4.
Definition: ipv4-header.h:33
virtual ~IcmpV6EchoReplyTestCase()
Definition: icmp-test.cc:396
void SetType(uint8_t type)
Set the type.
ICMPv6 header.
Definition: icmpv6-header.h:38
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Definition: icmp-test.cc:150
virtual ~IcmpV6TimeExceedTestCase()
Definition: icmp-test.cc:539
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
Definition: icmp-test.cc:109
An Inet6 address class.
ICMP Echo Reply Test.
Definition: icmp-test.cc:97
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
void DoSendData(Ptr< Socket > socket, Ipv6Address dst)
Definition: icmp-test.cc:403
Ptr< Packet > m_receivedPacket
Definition: icmp-test.cc:527
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Definition: socket.cc:128
ICMP Time Exceed Reply Test.
Definition: icmp-test.cc:228
void DoSendData(Ptr< Socket > socket, Ipv6Address dst)
Definition: icmp-test.cc:546
void ReceivePkt(Ptr< Socket > socket)
Definition: icmp-test.cc:434
void DoSendData(Ptr< Socket > socket, Ipv4Address dst)
Definition: icmp-test.cc:259
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Ptr< Packet > m_receivedPacket
Definition: icmp-test.cc:384
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:608
address
Definition: first.py:37
void SetCode(uint8_t code)
Set the code field.
void DoSendData(Ptr< Socket > socket, Ipv4Address dst)
Definition: icmp-test.cc:128
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:372
virtual ~IcmpEchoReplyTestCase()
Definition: icmp-test.cc:121
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)
Definition: icmp-test.cc:568
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
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)
Definition: icmp-test.cc:159
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:1062
void ReceivePkt(Ptr< Socket > socket)
Definition: icmp-test.cc:577
interfaces
Definition: first.py:41
Describes an IPv6 prefix.
Definition: ipv6-address.h:449
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:32
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
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.