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

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

+ Inheritance diagram for GlobalRoutingProtocolTestCase:
+ Collaboration diagram for GlobalRoutingProtocolTestCase:

Public Member Functions

 GlobalRoutingProtocolTestCase ()
 
 ~GlobalRoutingProtocolTestCase () override
 
- Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 
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...
 
- Static Public Attributes inherited from ns3::TestCase
static constexpr auto QUICK = Duration::QUICK
 Deprecated test duration simple enums.
 
static constexpr auto EXTENSIVE = Duration::EXTENSIVE
 
static constexpr auto TAKES_FOREVER = Duration::TAKES_FOREVER
 
- 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 1406 of file ipv4-global-routing-test-suite.cc.

Constructor & Destructor Documentation

◆ GlobalRoutingProtocolTestCase()

GlobalRoutingProtocolTestCase::GlobalRoutingProtocolTestCase ( )

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

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

+ Here is the call graph for this function:

◆ ~GlobalRoutingProtocolTestCase()

GlobalRoutingProtocolTestCase::~GlobalRoutingProtocolTestCase ( )
override

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

Member Function Documentation

◆ CheckPath()

void GlobalRoutingProtocolTestCase::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 1505 of file ipv4-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 GlobalRoutingProtocolTestCase::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

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

References CheckPath(), ns3::Simulator::Destroy(), ns3::NodeContainer::Get(), nodes, ns3::Ipv4GlobalRoutingHelper::PopulateRoutingTables(), ns3::GlobalRouteManager::ResetRouterId(), ns3::Simulator::Run(), ns3::Seconds(), and ns3::Simulator::Stop().

+ Here is the call graph for this function:

◆ DoSetup()

void GlobalRoutingProtocolTestCase::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 1558 of file ipv4-global-routing-test-suite.cc.

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

+ Here is the call graph for this function:

◆ MyErrorCallback()

void GlobalRoutingProtocolTestCase::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 1481 of file ipv4-global-routing-test-suite.cc.

References NS_LOG_DEBUG, and NS_TEST_ASSERT_MSG_EQ.

Referenced by GlobalRoutingProtocolTestCase().

+ Here is the caller graph for this function:

◆ MyLocalDeliverCallback()

void GlobalRoutingProtocolTestCase::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 1472 of file ipv4-global-routing-test-suite.cc.

References NS_LOG_DEBUG.

Referenced by GlobalRoutingProtocolTestCase().

+ Here is the caller graph for this function:

◆ MyUnicastCallback()

void GlobalRoutingProtocolTestCase::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 1462 of file ipv4-global-routing-test-suite.cc.

References m_lastRoute, and NS_LOG_DEBUG.

Referenced by GlobalRoutingProtocolTestCase().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_ecb

Ipv4RoutingProtocol::ErrorCallback GlobalRoutingProtocolTestCase::m_ecb
private

Error callback.

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

Referenced by GlobalRoutingProtocolTestCase(), and CheckPath().

◆ m_lastRoute

Ptr<Ipv4Route> GlobalRoutingProtocolTestCase::m_lastRoute
private

Route to be tested.

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

Referenced by CheckPath(), and MyUnicastCallback().

◆ m_lcb

Ipv4RoutingProtocol::LocalDeliverCallback GlobalRoutingProtocolTestCase::m_lcb
private

Local delivery callback.

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

Referenced by GlobalRoutingProtocolTestCase(), and CheckPath().

◆ m_mcb

Ipv4RoutingProtocol::MulticastForwardCallback GlobalRoutingProtocolTestCase::m_mcb
private

Multicast forward callback.

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

Referenced by CheckPath().

◆ m_ucb

Ipv4RoutingProtocol::UnicastForwardCallback GlobalRoutingProtocolTestCase::m_ucb
private

Unicast forward callback.

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

Referenced by GlobalRoutingProtocolTestCase(), and CheckPath().

◆ nodes

NodeContainer GlobalRoutingProtocolTestCase::nodes
private

Nodes used in the test.

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

Referenced by DoRun(), and DoSetup().


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