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...
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. | |
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.
| Ipv4IcmpNoRouteTestCase::Ipv4IcmpNoRouteTestCase | ( | ) |
Definition at line 117 of file ipv4-icmp-no-route-test-suite.cc.
References ns3::TestCase::TestCase().
|
override |
Definition at line 122 of file ipv4-icmp-no-route-test-suite.cc.
|
overrideprivatevirtual |
Implementation to actually run this TestCase.
Subclasses should override this method to conduct their tests.
Implements ns3::TestCase.
Definition at line 172 of file ipv4-icmp-no-route-test-suite.cc.
References ns3::CreateObject(), ns3::Simulator::Destroy(), ns3::NetDeviceContainer::Get(), ns3::Ipv4Address::GetAny(), ns3::Ipv4StaticRoutingHelper::GetStaticRouting(), ns3::iana::internetprotocolnumbers::ICMP, ns3::SimpleNetDeviceHelper::Install(), m_icmpSource, m_icmpUnreachCount, ns3::MakeCallback(), NS_TEST_EXPECT_MSG_EQ, ReceiveIcmp(), ns3::Simulator::Run(), ns3::Simulator::ScheduleWithContext(), ns3::Seconds(), SendData(), ns3::SimpleNetDeviceHelper::SetNetDevicePointToPointMode(), ns3::RngSeedManager::SetRun(), ns3::RngSeedManager::SetSeed(), and ns3::Simulator::Stop().
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.
| Socket | The 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().
|
private |
Send a single raw IPv4 packet from A toward the un-routable destination.
| Socket | The sending raw socket on node A. |
| dst | The (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().
|
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().
|
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().