A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::olsr::TcRegressionTest Class Reference

Less trivial test of OLSR Topology Control message generation. More...

#include "tc-regression-test.h"

+ Inheritance diagram for ns3::olsr::TcRegressionTest:
+ Collaboration diagram for ns3::olsr::TcRegressionTest:

Public Member Functions

 TcRegressionTest ()
 
 ~TcRegressionTest () 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 CreateNodes ()
 Create & configure test network.
 
void DoRun () override
 Implementation to actually run this TestCase.
 
void ReceivePktProbeA (Ptr< Socket > socket)
 Receive raw data on node A.
 
void ReceivePktProbeB (Ptr< Socket > socket)
 Receive raw data on node B.
 
void ReceivePktProbeC (Ptr< Socket > socket)
 Receive raw data on node C.
 

Private Attributes

uint8_t m_countA
 Packet counter on node A.
 
uint8_t m_countB
 Packet counter on node B.
 
uint8_t m_countC
 Packet counter on node C.
 
Ptr< Ipv4RawSocketImplm_rxSocketA
 Receiving socket on node A.
 
Ptr< Ipv4RawSocketImplm_rxSocketB
 Receiving socket on node B.
 
Ptr< Ipv4RawSocketImplm_rxSocketC
 Receiving socket on node C.
 
const Time m_time
 Total simulation time.
 

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...
 
using instead = Duration
 
- Static Public Attributes inherited from ns3::TestCase
static constexpr auto EXTENSIVE = Duration::EXTENSIVE
 
static constexpr auto QUICK = Duration::QUICK
 
static constexpr auto 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

Less trivial test of OLSR Topology Control message generation.

This test simulates 3 Wi-Fi stations with chain topology and runs OLSR without any extra traffic. It is expected that only second station will send TC messages.

Expected trace (20 seconds, note random b-cast jitter):

        1       2       3
        |<------|------>|              HELLO (empty) src = 10.1.1.2
        |       |<------|------>       HELLO (empty) src = 10.1.1.3
 <------|------>|       |              HELLO (empty) src = 10.1.1.1
 <------|------>|       |              HELLO (Link Type: Asymmetric, Neighbor: 10.1.1.2) src
= 10.1.1.1 |       |<------|------>       HELLO (Link Type: Asymmetric, Neighbor: 10.1.1.2) src
= 10.1.1.3
        |<------|------>|              HELLO (Link Type: Asymmetric, Neighbor: 10.1.1.3; Link Type:
Asymmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
        |<------|------>|              HELLO (Link Type: Asymmetric, Neighbor: 10.1.1.3; Link Type:
Asymmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
 <------|------>|       |              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.2) src
= 10.1.1.1 |       |<------|------>       HELLO (Link Type: Symmetric, Neighbor: 10.1.1.2) src
= 10.1.1.3
        |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type:
Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
 <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.1 |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.3
        |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type:
Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
 <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.1 |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.3
        |<======|======>|              TC (10.1.1.3; 10.1.1.1) + HELLO (Link Type: Symmetric,
Neighbor: 10.1.1.3; Link Type: Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2 | |<------|------>
HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src = 10.1.1.3
 <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.1
        |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type:
Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
 <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.1 |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.3
 <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.1 |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.3
        |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type:
Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
        |<======|======>|              TC (10.1.1.3; 10.1.1.1) src = 10.1.1.2
        |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.3
 <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.1
        |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type:
Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
 <------|------>|       |              HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.1 |       |<------|------>       HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src
= 10.1.1.3
        |<------|------>|              HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type:
Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2 

Definition at line 96 of file tc-regression-test.h.

Constructor & Destructor Documentation

◆ TcRegressionTest()

ns3::olsr::TcRegressionTest::TcRegressionTest ( )

Definition at line 46 of file tc-regression-test.cc.

◆ ~TcRegressionTest()

ns3::olsr::TcRegressionTest::~TcRegressionTest ( )
override

Definition at line 55 of file tc-regression-test.cc.

Member Function Documentation

◆ CreateNodes()

void ns3::olsr::TcRegressionTest::CreateNodes ( )
private

Create & configure test network.

Definition at line 76 of file tc-regression-test.cc.

References ns3::NodeContainer::Create(), ns3::NetDeviceContainer::Get(), ns3::NodeContainer::Get(), ns3::Object::GetObject(), ns3::SimpleNetDeviceHelper::Install(), m_rxSocketA, m_rxSocketB, m_rxSocketC, ns3::MakeCallback(), NS_TEST_EXPECT_MSG_EQ, ns3::UdpL4Protocol::PROT_NUMBER, ReceivePktProbeA(), ReceivePktProbeB(), ReceivePktProbeC(), ns3::SimpleNetDeviceHelper::SetChannelAttribute(), ns3::SimpleNetDeviceHelper::SetDeviceAttribute(), ns3::Ipv4RawSocketImpl::SetProtocol(), and ns3::Socket::SetRecvCallback().

Referenced by DoRun().

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

◆ DoRun()

void ns3::olsr::TcRegressionTest::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 60 of file tc-regression-test.cc.

References CreateNodes(), ns3::Simulator::Destroy(), m_rxSocketA, m_rxSocketB, m_rxSocketC, m_time, ns3::Simulator::Run(), ns3::RngSeedManager::SetRun(), ns3::RngSeedManager::SetSeed(), and ns3::Simulator::Stop().

+ Here is the call graph for this function:

◆ ReceivePktProbeA()

void ns3::olsr::TcRegressionTest::ReceivePktProbeA ( Ptr< Socket socket)
private

Receive raw data on node A.

Parameters
socketreceiving socket

Definition at line 127 of file tc-regression-test.cc.

References ns3::olsr::MessageHeader::GetHello(), ns3::olsr::MessageHeader::GetOriginatorAddress(), ns3::olsr::MessageHeader::GetTc(), ns3::olsr::MessageHeader::Hello::linkMessages, m_countA, ns3::olsr::MessageHeader::Tc::neighborAddresses, NS_ASSERT, and NS_TEST_EXPECT_MSG_EQ.

Referenced by CreateNodes().

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

◆ ReceivePktProbeB()

void ns3::olsr::TcRegressionTest::ReceivePktProbeB ( Ptr< Socket socket)
private

Receive raw data on node B.

Parameters
socketreceiving socket

Definition at line 230 of file tc-regression-test.cc.

References ns3::olsr::MessageHeader::GetHello(), ns3::olsr::MessageHeader::GetOriginatorAddress(), ns3::olsr::MessageHeader::Hello::linkMessages, m_countB, m_countC, NS_ASSERT, and NS_TEST_EXPECT_MSG_EQ.

Referenced by CreateNodes().

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

◆ ReceivePktProbeC()

void ns3::olsr::TcRegressionTest::ReceivePktProbeC ( Ptr< Socket socket)
private

Receive raw data on node C.

Parameters
socketreceiving socket

Definition at line 302 of file tc-regression-test.cc.

References ns3::olsr::MessageHeader::GetHello(), ns3::olsr::MessageHeader::GetOriginatorAddress(), ns3::olsr::MessageHeader::GetTc(), ns3::olsr::MessageHeader::Hello::linkMessages, m_countC, ns3::olsr::MessageHeader::Tc::neighborAddresses, NS_ASSERT, and NS_TEST_EXPECT_MSG_EQ.

Referenced by CreateNodes().

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

Member Data Documentation

◆ m_countA

uint8_t ns3::olsr::TcRegressionTest::m_countA
private

Packet counter on node A.

Definition at line 115 of file tc-regression-test.h.

Referenced by ReceivePktProbeA().

◆ m_countB

uint8_t ns3::olsr::TcRegressionTest::m_countB
private

Packet counter on node B.

Definition at line 125 of file tc-regression-test.h.

Referenced by ReceivePktProbeB().

◆ m_countC

uint8_t ns3::olsr::TcRegressionTest::m_countC
private

Packet counter on node C.

Definition at line 135 of file tc-regression-test.h.

Referenced by ReceivePktProbeB(), and ReceivePktProbeC().

◆ m_rxSocketA

Ptr<Ipv4RawSocketImpl> ns3::olsr::TcRegressionTest::m_rxSocketA
private

Receiving socket on node A.

Definition at line 117 of file tc-regression-test.h.

Referenced by CreateNodes(), and DoRun().

◆ m_rxSocketB

Ptr<Ipv4RawSocketImpl> ns3::olsr::TcRegressionTest::m_rxSocketB
private

Receiving socket on node B.

Definition at line 127 of file tc-regression-test.h.

Referenced by CreateNodes(), and DoRun().

◆ m_rxSocketC

Ptr<Ipv4RawSocketImpl> ns3::olsr::TcRegressionTest::m_rxSocketC
private

Receiving socket on node C.

Definition at line 137 of file tc-regression-test.h.

Referenced by CreateNodes(), and DoRun().

◆ m_time

const Time ns3::olsr::TcRegressionTest::m_time
private

Total simulation time.

Definition at line 104 of file tc-regression-test.h.

Referenced by DoRun().


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