34#include "ns3/boolean.h"
35#include "ns3/iana-internet-protocol-numbers.h"
36#include "ns3/icmpv4.h"
37#include "ns3/inet-socket-address.h"
38#include "ns3/internet-stack-helper.h"
39#include "ns3/ipv4-address.h"
40#include "ns3/ipv4-l3-protocol.h"
41#include "ns3/ipv4-raw-socket-factory.h"
42#include "ns3/ipv4-static-routing-helper.h"
43#include "ns3/ipv4-static-routing.h"
47#include "ns3/packet.h"
48#include "ns3/rng-seed-manager.h"
49#include "ns3/simple-net-device-helper.h"
50#include "ns3/simple-net-device.h"
51#include "ns3/simulator.h"
52#include "ns3/socket-factory.h"
53#include "ns3/socket.h"
55#include "ns3/uinteger.h"
92 void DoRun()
override;
118 :
TestCase(
"ICMP net-unreachable on no-route forwarding failure (issue #825)")
133 socket->SendTo(p, 0, realTo);
134 NS_LOG_DEBUG(
"A sent " << p->GetSize() <<
" bytes to un-routable " << dst);
141 Ptr<Packet> p = socket->RecvFrom(0xffffffff, 0, from);
149 if (p->GetSize() < ipv4.GetSerializedSize())
153 p->RemoveHeader(ipv4);
161 p->RemoveHeader(icmp);
167 NS_LOG_DEBUG(
"A received ICMP Destination Unreachable from " << ipv4.GetSource());
197 internet.Install(aAndR);
203 ipv4 = nodeA->GetObject<
Ipv4>();
204 ifIndex = ipv4->AddInterface(net0.
Get(0));
205 ipv4->AddAddress(ifIndex,
207 ipv4->SetUp(ifIndex);
210 ipv4 = nodeR->GetObject<
Ipv4>();
212 ipv4->AddAddress(rIfToA,
216 uint32_t rIfNet1 = ipv4->AddInterface(net1.
Get(0));
217 ipv4->AddAddress(rIfNet1,
219 ipv4->SetUp(rIfNet1);
230 aRouting->SetDefaultRoute(
Ipv4Address(
"10.0.0.2"), 1);
239 Ptr<Socket> aIcmpSocket = rawFactory->CreateSocket();
243 "Failed to bind the raw ICMP socket on A");
248 Ptr<Socket> aSendSocket = rawFactory->CreateSocket();
252 "Failed to bind the raw sending socket on A");
269 "Source A should receive exactly one ICMP Destination Unreachable "
270 "(net-unreachable) from the router on a no-route forwarding failure "
275 "The ICMP Destination Unreachable should be sourced from the router R "
Regression test for Issue 825: a router that cannot forward a packet (no matching route) must reply t...
uint32_t m_icmpUnreachCount
Number of ICMP Dest Unreachable msgs received by A.
~Ipv4IcmpNoRouteTestCase() override
Ipv4Address m_icmpSource
Source address of the received ICMP error.
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send a single raw IPv4 packet from A toward the un-routable destination.
Ipv4IcmpNoRouteTestCase()
void DoRun() override
Implementation to actually run this TestCase.
void ReceiveIcmp(Ptr< Socket > socket)
Receive callback for the raw ICMP socket on node A.
Test suite for the ICMP no-route regression (Issue 825).
Ipv4IcmpNoRouteTestSuite()
a polymophic address class
aggregate IP/TCP/UDP functionality to existing Nodes.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
API to create RAW socket instances.
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
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().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Hold an unsigned integer type.
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...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static Ipv4IcmpNoRouteTestSuite g_ipv4IcmpNoRouteTestSuite
Static variable for test initialization.
constexpr uint8_t ICMP
Internet Control Message for IPV4 [RFC792].
Every class exported by the ns3 library is enclosed in the ns3 namespace.