A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
Ipv4IcmpNoRouteTestCase Class Reference

Regression test for Issue 825: a router that cannot forward a packet (no matching route) must reply to the source with an ICMP Destination Unreachable (net-unreachable) message. More...

Inheritance diagram for Ipv4IcmpNoRouteTestCase:
Collaboration diagram for Ipv4IcmpNoRouteTestCase:

Public Member Functions

 Ipv4IcmpNoRouteTestCase ()
 ~Ipv4IcmpNoRouteTestCase () override
Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 Caller graph was not generated because of its size.
virtual ~TestCase ()
 Destructor.
std::string GetName () const
TestCase & operator= (const TestCase &)=delete

Private Member Functions

void DoRun () override
 Implementation to actually run this TestCase.
void ReceiveIcmp (Ptr< Socket > socket)
 Receive callback for the raw ICMP socket on node A.
void SendData (Ptr< Socket > socket, Ipv4Address dst)
 Send a single raw IPv4 packet from A toward the un-routable destination.

Private Attributes

Ipv4Address m_icmpSource
 Source address of the received ICMP error.
uint32_t m_icmpUnreachCount {0}
 Number of ICMP Dest Unreachable msgs received by A.

Additional Inherited Members

Public Types inherited from ns3::TestCase
enum class  Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor.
void AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK)
 Add an individual child TestCase to this test suite.
TestCase * GetParent () const
 Get the parent of this TestCase.
bool IsStatusFailure () const
 Check if any tests failed.
bool IsStatusSuccess () const
 Check if all tests passed.
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found.
void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
 Log the failure of this TestCase.
bool MustAssertOnFailure () const
 Check if this run should assert on failure.
bool MustContinueOnFailure () const
 Check if this run should continue on failure.
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory.
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory.

Detailed Description

Regression test for Issue 825: a router that cannot forward a packet (no matching route) must reply to the source with an ICMP Destination Unreachable (net-unreachable) message.

Topology:

A (10.0.0.1) ---- net0 ---- (10.0.0.2) R (10.0.1.1) ---- net1 ---- (dangling)

- A: default route via R (10.0.0.2).
- R: IP forwarder, has interface routes for 10.0.0.0/24 and 10.0.1.0/24
     but NO route for the destination subnet 10.9.9.0/24.
- A opens a raw ICMP socket (protocol 1) to capture returned ICMP errors
  and sends a single raw packet to 10.9.9.9 (inside the un-routable D).

Pre-fix observation: A receives 0 ICMP errors (R drops silently), so the final assertion fails. Post-fix, A receives one ICMP type-3 message and the test passes.

Definition at line 85 of file ipv4-icmp-no-route-test-suite.cc.

Constructor & Destructor Documentation

◆ Ipv4IcmpNoRouteTestCase()

Ipv4IcmpNoRouteTestCase::Ipv4IcmpNoRouteTestCase ( )

Definition at line 117 of file ipv4-icmp-no-route-test-suite.cc.

References ns3::TestCase::TestCase().

Here is the call graph for this function:

◆ ~Ipv4IcmpNoRouteTestCase()

Ipv4IcmpNoRouteTestCase::~Ipv4IcmpNoRouteTestCase ( )
override

Definition at line 122 of file ipv4-icmp-no-route-test-suite.cc.

Member Function Documentation

◆ DoRun()

void Ipv4IcmpNoRouteTestCase::DoRun ( )
overrideprivatevirtual

◆ ReceiveIcmp()

void Ipv4IcmpNoRouteTestCase::ReceiveIcmp ( Ptr< Socket > socket)
private

Receive callback for the raw ICMP socket on node A.

Parses the received packet (full IPv4 datagram delivered by the raw socket: Ipv4Header followed by Icmpv4Header) and, if it is an ICMP Destination Unreachable, records it.

Parameters
SocketThe receiving raw ICMP socket on node A.

Definition at line 138 of file ipv4-icmp-no-route-test-suite.cc.

References ns3::Icmpv4Header::GetType(), ns3::iana::internetprotocolnumbers::ICMP, ns3::Icmpv4Header::ICMPV4_DEST_UNREACH, m_icmpSource, m_icmpUnreachCount, and NS_LOG_DEBUG.

Referenced by DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendData()

void Ipv4IcmpNoRouteTestCase::SendData ( Ptr< Socket > socket,
Ipv4Address dst )
private

Send a single raw IPv4 packet from A toward the un-routable destination.

Parameters
SocketThe sending raw socket on node A.
dstThe (un-routable) destination address inside subnet D.

Definition at line 127 of file ipv4-icmp-no-route-test-suite.cc.

References ns3::Create(), and NS_LOG_DEBUG.

Referenced by DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_icmpSource

Ipv4Address Ipv4IcmpNoRouteTestCase::m_icmpSource
private

Source address of the received ICMP error.

Definition at line 114 of file ipv4-icmp-no-route-test-suite.cc.

Referenced by DoRun(), and ReceiveIcmp().

◆ m_icmpUnreachCount

uint32_t Ipv4IcmpNoRouteTestCase::m_icmpUnreachCount {0}
private

Number of ICMP Dest Unreachable msgs received by A.

Definition at line 113 of file ipv4-icmp-no-route-test-suite.cc.

Referenced by DoRun(), and ReceiveIcmp().


The documentation for this class was generated from the following file: