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

TestCase to check calls to GlobalRoutingProtocol API. More...

Inheritance diagram for GlobalRoutingv4ProtocolTestCase:
Collaboration diagram for GlobalRoutingv4ProtocolTestCase:

Public Member Functions

 GlobalRoutingv4ProtocolTestCase ()
 ~GlobalRoutingv4ProtocolTestCase () 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
TestCaseoperator= (const TestCase &)=delete

Private Member Functions

void CheckPath (std::vector< Ptr< Node > > pathNodes, std::vector< Ipv4Address > path)
 Checks the Path taken by packets by calling RouteInput() and RouteOutput() APIs of GlobalRoutingProtocol.
void DoRun () override
 Implementation to actually run this TestCase.
void DoSetup () override
 Implementation to do any local setup required for this TestCase.
void MyErrorCallback (Ptr< const Packet > packet, const Ipv4Header &header, Socket::SocketErrno errno_)
 Callback function for RouteInput() API of GlobalRoutingProtocol.
void MyLocalDeliverCallback (Ptr< const Packet > packet, const Ipv4Header &header, uint32_t iif)
 Callback function for RouteInput() API of GlobalRoutingProtocol.
void MyUnicastCallback (Ptr< Ipv4Route > route, Ptr< const Packet > packet, const Ipv4Header &header)
 Callback function for RouteInput() API of GlobalRoutingProtocol.

Private Attributes

Ipv4RoutingProtocol::ErrorCallback m_ecb
 Error callback.
Ptr< Ipv4Routem_lastRoute
 Route to be tested.
Ipv4RoutingProtocol::LocalDeliverCallback m_lcb
 Local delivery callback.
Ipv4RoutingProtocol::MulticastForwardCallback m_mcb
 Multicast forward callback.
Ipv4RoutingProtocol::UnicastForwardCallback m_ucb
 Unicast forward callback.
NodeContainer nodes
 Nodes used in the test.

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.
TestCaseGetParent () 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

TestCase to check calls to GlobalRoutingProtocol API.

This TestCase Checks the output returned by the GlobalRoutingProtocol API to Ipv4L3 Layer.

Definition at line 2224 of file global-routing-test-suite.cc.

Constructor & Destructor Documentation

◆ GlobalRoutingv4ProtocolTestCase()

GlobalRoutingv4ProtocolTestCase::GlobalRoutingv4ProtocolTestCase ( )

Definition at line 2308 of file global-routing-test-suite.cc.

References ns3::TestCase::TestCase(), m_ecb, m_lcb, m_ucb, ns3::MakeCallback(), MyErrorCallback(), MyLocalDeliverCallback(), and MyUnicastCallback().

Here is the call graph for this function:

◆ ~GlobalRoutingv4ProtocolTestCase()

GlobalRoutingv4ProtocolTestCase::~GlobalRoutingv4ProtocolTestCase ( )
override

Definition at line 2318 of file global-routing-test-suite.cc.

Member Function Documentation

◆ CheckPath()

void GlobalRoutingv4ProtocolTestCase::CheckPath ( std::vector< Ptr< Node > > pathNodes,
std::vector< Ipv4Address > path )
private

Checks the Path taken by packets by calling RouteInput() and RouteOutput() APIs of GlobalRoutingProtocol.

This mimics how Ipv4L3Protocol calls these APIs.

Parameters
pathNodesVector of nodes in the path. This includes the source node,Intermediate nextHop nodes and the destination node.
pathVector of Ipv4Addresses in the path. This includes the source egress IpAddress, destination ingress IpAddress and intermediate nextHop Node's ingress Ipaddress that we need to check.It does not include the egress addresses for intermediate nodes.

Definition at line 2323 of file global-routing-test-suite.cc.

References ns3::Create(), m_ecb, m_lastRoute, m_lcb, m_mcb, m_ucb, NS_TEST_ASSERT_MSG_EQ, NS_TEST_ASSERT_MSG_NE, ns3::Ipv4Header::SetDestination(), and ns3::Ipv4Header::SetSource().

Referenced by DoRun().

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

◆ DoRun()

void GlobalRoutingv4ProtocolTestCase::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 2496 of file global-routing-test-suite.cc.

References CheckPath(), ns3::Simulator::Destroy(), nodes, ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables(), ns3::GlobalRouteManager< T >::ResetRouterId(), ns3::Simulator::Run(), ns3::Seconds(), and ns3::Simulator::Stop().

Here is the call graph for this function:

◆ DoSetup()

void GlobalRoutingv4ProtocolTestCase::DoSetup ( )
overrideprivatevirtual

Implementation to do any local setup required for this TestCase.

Subclasses should override this method to perform any costly per-test setup before DoRun is invoked.

This test case is designed to test the overall functionality of the GlobalRoutingProtocol. It tests the calls to the GlobalRoutingProtocol's RouteOutput() and RouteInput() APIs. It mimics how Ipv4L3Protocol calls these APIs. The topology covers most of the cases that are expected to be handled by the GlobalRoutingProtocol.

Reimplemented from ns3::TestCase.

Definition at line 2376 of file global-routing-test-suite.cc.

References ns3::NetDeviceContainer::Add(), ns3::CreateObject(), ns3::NetDeviceContainer::Get(), ns3::BridgeHelper::Install(), ns3::SimpleNetDeviceHelper::Install(), nodes, and ns3::SimpleNetDeviceHelper::SetNetDevicePointToPointMode().

Here is the call graph for this function:

◆ MyErrorCallback()

void GlobalRoutingv4ProtocolTestCase::MyErrorCallback ( Ptr< const Packet > packet,
const Ipv4Header & header,
Socket::SocketErrno errno_ )
private

Callback function for RouteInput() API of GlobalRoutingProtocol.

Parameters
packetPacket to be locally delivered
headerIPv4 header of the packet
errno_Socket error number

Definition at line 2299 of file global-routing-test-suite.cc.

References NS_LOG_DEBUG, and NS_TEST_ASSERT_MSG_EQ.

Referenced by GlobalRoutingv4ProtocolTestCase().

Here is the caller graph for this function:

◆ MyLocalDeliverCallback()

void GlobalRoutingv4ProtocolTestCase::MyLocalDeliverCallback ( Ptr< const Packet > packet,
const Ipv4Header & header,
uint32_t iif )
private

Callback function for RouteInput() API of GlobalRoutingProtocol.

Parameters
packetPacket to be locally delivered
headerIPv4 header of the packet
iifIngress Interface index

Definition at line 2290 of file global-routing-test-suite.cc.

References NS_LOG_DEBUG.

Referenced by GlobalRoutingv4ProtocolTestCase().

Here is the caller graph for this function:

◆ MyUnicastCallback()

void GlobalRoutingv4ProtocolTestCase::MyUnicastCallback ( Ptr< Ipv4Route > route,
Ptr< const Packet > packet,
const Ipv4Header & header )
private

Callback function for RouteInput() API of GlobalRoutingProtocol.

Parameters
routeRoute to be used for forwarding
packetPacket to be forwarded
headerIPv4 header of the packet

Definition at line 2280 of file global-routing-test-suite.cc.

References m_lastRoute, and NS_LOG_DEBUG.

Referenced by GlobalRoutingv4ProtocolTestCase().

Here is the caller graph for this function:

Member Data Documentation

◆ m_ecb

Ipv4RoutingProtocol::ErrorCallback GlobalRoutingv4ProtocolTestCase::m_ecb
private

Error callback.

Definition at line 2275 of file global-routing-test-suite.cc.

Referenced by GlobalRoutingv4ProtocolTestCase(), and CheckPath().

◆ m_lastRoute

Ptr<Ipv4Route> GlobalRoutingv4ProtocolTestCase::m_lastRoute
private

Route to be tested.

Definition at line 2271 of file global-routing-test-suite.cc.

Referenced by CheckPath(), and MyUnicastCallback().

◆ m_lcb

Ipv4RoutingProtocol::LocalDeliverCallback GlobalRoutingv4ProtocolTestCase::m_lcb
private

Local delivery callback.

Definition at line 2274 of file global-routing-test-suite.cc.

Referenced by GlobalRoutingv4ProtocolTestCase(), and CheckPath().

◆ m_mcb

Ipv4RoutingProtocol::MulticastForwardCallback GlobalRoutingv4ProtocolTestCase::m_mcb
private

Multicast forward callback.

Definition at line 2273 of file global-routing-test-suite.cc.

Referenced by CheckPath().

◆ m_ucb

Ipv4RoutingProtocol::UnicastForwardCallback GlobalRoutingv4ProtocolTestCase::m_ucb
private

Unicast forward callback.

Definition at line 2272 of file global-routing-test-suite.cc.

Referenced by GlobalRoutingv4ProtocolTestCase(), and CheckPath().

◆ nodes

NodeContainer GlobalRoutingv4ProtocolTestCase::nodes
private

Nodes used in the test.

Definition at line 2270 of file global-routing-test-suite.cc.

Referenced by DoRun(), and DoSetup().


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