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

ping basic tests More...

+ Inheritance diagram for PingTestCase:
+ Collaboration diagram for PingTestCase:

Public Member Functions

 PingTestCase (std::string name, bool useIpv6)
 Constructor.
 
void CheckReportLoss (uint16_t expectedReportLoss)
 Enable the check on Lost pings.
 
void CheckReportReceived (uint32_t expectedReportRx)
 Enable the check on Rx pings.
 
void CheckReportTime (Time expectedTime)
 Enable the check on average RTT.
 
void CheckReportTransmitted (uint32_t expectedReportTx)
 Enable the check on Tx pings.
 
void CheckTraceRtt (uint32_t expectedRtt)
 Enable the check on Rtt event count in Rtt trace source.
 
void CheckTraceTx (uint32_t expectedTx)
 Enable the check on Tx pings counted in Tx trace source.
 
void SetCount (uint32_t count)
 Set the number of pings to send.
 
void SetDestinationAddress (Address address)
 Set the destination address (either IPv4 or IPv6).
 
void SetDropList (const std::list< uint32_t > &dropList)
 Set the packet drop list on the Ping node's interface.
 
void SetInterval (Time interval)
 Set the interval of pings.
 
void SetSimulatorStopTime (Time stopTime)
 Set the Simulation stop time.
 
void SetSize (uint32_t size)
 Set the size of pings.
 
void SetStartTime (Time startTime)
 Set the PING start time.
 
void SetStopTime (Time stopTime)
 Set the PING stop time.
 
- 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 DoRun () override
 Implementation to actually run this TestCase.
 
void DoSetup () override
 Implementation to do any local setup required for this TestCase.
 
void DoTeardown () override
 Implementation to do any local setup required for this TestCase.
 
void DropTraceSink (uint16_t seq, Ping::DropReason reason)
 Trace Drop events.
 
void ReportTraceSink (const Ping::PingReport &report)
 Trace Report generation events.
 
void RttTraceSink (uint16_t seq, Time rttSample)
 Trace RTT events.
 
void TxTraceSink (uint16_t seq, Ptr< Packet > p)
 Trace TX events.
 

Private Attributes

bool m_checkReportLoss {false}
 Set to true to check the Loss number.
 
bool m_checkReportReceived {false}
 Set to true to check the Rx number.
 
bool m_checkReportTime {false}
 Set to true to check the Time.
 
bool m_checkReportTransmitted {false}
 Set to true to check the Tx number.
 
bool m_checkTraceRtt {false}
 Set to true to check the Rtt number.
 
bool m_checkTraceTx {false}
 Set to true to check the Tx number.
 
uint32_t m_countAttribute {0}
 Number of pings to send.
 
uint32_t m_countTraceRtt {0}
 Rtt trace counter.
 
uint32_t m_countTraceTx {0}
 Tx trace counter.
 
Address m_destination {Ipv4Address("10.0.0.2")}
 Destination address.
 
NetDeviceContainer m_devices
 The NetDevices.
 
std::list< uint32_tm_dropList
 Drop first reply (true)
 
uint16_t m_expectedReportLoss {0}
 Expected reported Loss.
 
uint32_t m_expectedReportRx {0}
 Expected reported Rx.
 
Time m_expectedReportTime
 Expected reported time.
 
uint32_t m_expectedReportTx {0}
 Expected reported Tx.
 
uint32_t m_expectedTraceRtt {0}
 Expected Rtt trace sink calls.
 
uint32_t m_expectedTraceTx {0}
 Expected Tx trace sink calls.
 
Time m_interpacketInterval {Seconds(1.0)}
 Time between pings.
 
Ipv4InterfaceContainer m_ipv4Interfaces
 The IPv4 interfaces.
 
Ipv6InterfaceContainer m_ipv6Interfaces
 The IPv6 interfaces.
 
Time m_lastTx
 Last ping Tx time.
 
uint32_t m_mtu {1500}
 Link MTU.
 
NodeContainer m_nodes
 The simulation nodes.
 
Time m_simulatorStopTime {Seconds(6)}
 Simulator stop time.
 
uint32_t m_sizeAttribute {56}
 Size of pings.
 
Time m_startTime {Seconds(1)}
 Start time.
 
Time m_stopTime {Seconds(5)}
 Stop time.
 
bool m_useIpv6 {false}
 Use IPv6 (true) or IPv4 (false)
 

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

ping basic tests

Definition at line 77 of file ping-test.cc.

Constructor & Destructor Documentation

◆ PingTestCase()

PingTestCase::PingTestCase ( std::string name,
bool useIpv6 )

Constructor.

Parameters
nameTestCase name.
useIpv6Use IPv6.

Definition at line 259 of file ping-test.cc.

Member Function Documentation

◆ CheckReportLoss()

void PingTestCase::CheckReportLoss ( uint16_t expectedReportLoss)

Enable the check on Lost pings.

Parameters
expectedReportLossExpected Lost.

Definition at line 336 of file ping-test.cc.

References m_checkReportLoss, and m_expectedReportLoss.

◆ CheckReportReceived()

void PingTestCase::CheckReportReceived ( uint32_t expectedReportRx)

Enable the check on Rx pings.

Parameters
expectedReportRxExpected Rx.

Definition at line 329 of file ping-test.cc.

References m_checkReportReceived, and m_expectedReportRx.

Referenced by PingTestSuite::PingTestSuite().

+ Here is the caller graph for this function:

◆ CheckReportTime()

void PingTestCase::CheckReportTime ( Time expectedTime)

Enable the check on average RTT.

Parameters
expectedTimeExpected RTT.

Definition at line 343 of file ping-test.cc.

References m_checkReportTime, and m_expectedReportTime.

Referenced by PingTestSuite::PingTestSuite().

+ Here is the caller graph for this function:

◆ CheckReportTransmitted()

void PingTestCase::CheckReportTransmitted ( uint32_t expectedReportTx)

Enable the check on Tx pings.

Parameters
expectedReportTxExpected Tx.

Definition at line 322 of file ping-test.cc.

References m_checkReportTransmitted, and m_expectedReportTx.

Referenced by PingTestSuite::PingTestSuite().

+ Here is the caller graph for this function:

◆ CheckTraceRtt()

void PingTestCase::CheckTraceRtt ( uint32_t expectedRtt)

Enable the check on Rtt event count in Rtt trace source.

Parameters
expectedRttExpected Rtt.

Definition at line 457 of file ping-test.cc.

References m_checkTraceRtt, and m_expectedTraceRtt.

◆ CheckTraceTx()

void PingTestCase::CheckTraceTx ( uint32_t expectedTx)

Enable the check on Tx pings counted in Tx trace source.

Parameters
expectedTxExpected Tx.

Definition at line 450 of file ping-test.cc.

References m_checkTraceTx, and m_expectedTraceTx.

◆ DoRun()

◆ DoSetup()

void PingTestCase::DoSetup ( )
overrideprivatevirtual

◆ DoTeardown()

void PingTestCase::DoTeardown ( )
overrideprivatevirtual

Implementation to do any local setup required for this TestCase.

Subclasses should override this method to perform any costly per-test teardown

Reimplemented from ns3::TestCase.

Definition at line 316 of file ping-test.cc.

References ns3::Simulator::Destroy().

+ Here is the call graph for this function:

◆ DropTraceSink()

void PingTestCase::DropTraceSink ( uint16_t seq,
Ping::DropReason reason )
private

Trace Drop events.

Parameters
seqSequence number.
reasonDrop reason.

Definition at line 398 of file ping-test.cc.

References ns3::Ping::DROP_HOST_UNREACHABLE, ns3::Ping::DROP_NET_UNREACHABLE, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by DoRun().

+ Here is the caller graph for this function:

◆ ReportTraceSink()

void PingTestCase::ReportTraceSink ( const Ping::PingReport & report)
private

Trace Report generation events.

Parameters
reportThe report sample.

Definition at line 416 of file ping-test.cc.

References ns3::Time::GetMicroSeconds(), m_checkReportLoss, m_checkReportReceived, m_checkReportTime, m_checkReportTransmitted, m_expectedReportLoss, m_expectedReportRx, m_expectedReportTime, m_expectedReportTx, ns3::Ping::PingReport::m_loss, ns3::Ping::PingReport::m_received, ns3::Ping::PingReport::m_rttMax, ns3::Ping::PingReport::m_rttMin, ns3::Ping::PingReport::m_transmitted, ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_TEST_ASSERT_MSG_EQ, NS_TEST_ASSERT_MSG_EQ_TOL, and NS_TEST_ASSERT_MSG_GT_OR_EQ.

Referenced by DoRun().

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

◆ RttTraceSink()

void PingTestCase::RttTraceSink ( uint16_t seq,
Time rttSample )
private

Trace RTT events.

Parameters
seqSequence number.
rttSampleRTT sample.

Definition at line 350 of file ping-test.cc.

References ns3::Time::As(), ns3::Time::GetSeconds(), m_countTraceRtt, m_sizeAttribute, m_useIpv6, ns3::Time::MS, NS_LOG_FUNCTION, and NS_TEST_ASSERT_MSG_EQ_TOL.

Referenced by DoRun().

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

◆ SetCount()

void PingTestCase::SetCount ( uint32_t count)
inline

Set the number of pings to send.

Parameters
countNumber of pings to send.

Definition at line 121 of file ping-test.cc.

References m_countAttribute.

Referenced by PingTestSuite::PingTestSuite().

+ Here is the caller graph for this function:

◆ SetDestinationAddress()

void PingTestCase::SetDestinationAddress ( Address address)

Set the destination address (either IPv4 or IPv6).

Parameters
addressThe destination address.

Definition at line 470 of file ping-test.cc.

References m_destination.

◆ SetDropList()

void PingTestCase::SetDropList ( const std::list< uint32_t > & dropList)
inline

Set the packet drop list on the Ping node's interface.

Parameters
dropListpacket drop list

Definition at line 148 of file ping-test.cc.

References m_dropList.

◆ SetInterval()

void PingTestCase::SetInterval ( Time interval)
inline

Set the interval of pings.

Parameters
intervalInterval of pings.

Definition at line 139 of file ping-test.cc.

References m_interpacketInterval.

◆ SetSimulatorStopTime()

void PingTestCase::SetSimulatorStopTime ( Time stopTime)

Set the Simulation stop time.

Parameters
stopTimeThe simulation stop time.

Definition at line 464 of file ping-test.cc.

References m_simulatorStopTime, and stopTime.

◆ SetSize()

void PingTestCase::SetSize ( uint32_t size)
inline

Set the size of pings.

Parameters
sizeSize of pings.

Definition at line 130 of file ping-test.cc.

References m_sizeAttribute.

Referenced by PingTestSuite::PingTestSuite().

+ Here is the caller graph for this function:

◆ SetStartTime()

void PingTestCase::SetStartTime ( Time startTime)
inline

Set the PING start time.

Parameters
startTimePing start time.

Definition at line 103 of file ping-test.cc.

References m_startTime.

Referenced by PingTestSuite::PingTestSuite().

+ Here is the caller graph for this function:

◆ SetStopTime()

void PingTestCase::SetStopTime ( Time stopTime)
inline

Set the PING stop time.

Parameters
stopTimePing stop time.

Definition at line 112 of file ping-test.cc.

References m_stopTime, and stopTime.

Referenced by PingTestSuite::PingTestSuite().

+ Here is the caller graph for this function:

◆ TxTraceSink()

void PingTestCase::TxTraceSink ( uint16_t seq,
Ptr< Packet > p )
private

Trace TX events.

Parameters
seqSequence number.
pTx packet.

Definition at line 380 of file ping-test.cc.

References m_countTraceTx, m_interpacketInterval, m_lastTx, ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_TEST_ASSERT_MSG_EQ, and ns3::Seconds().

Referenced by DoRun().

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

Member Data Documentation

◆ m_checkReportLoss

bool PingTestCase::m_checkReportLoss {false}
private

Set to true to check the Loss number.

Definition at line 242 of file ping-test.cc.

Referenced by CheckReportLoss(), and ReportTraceSink().

◆ m_checkReportReceived

bool PingTestCase::m_checkReportReceived {false}
private

Set to true to check the Rx number.

Definition at line 241 of file ping-test.cc.

Referenced by CheckReportReceived(), and ReportTraceSink().

◆ m_checkReportTime

bool PingTestCase::m_checkReportTime {false}
private

Set to true to check the Time.

Definition at line 243 of file ping-test.cc.

Referenced by CheckReportTime(), and ReportTraceSink().

◆ m_checkReportTransmitted

bool PingTestCase::m_checkReportTransmitted {false}
private

Set to true to check the Tx number.

Definition at line 240 of file ping-test.cc.

Referenced by CheckReportTransmitted(), and ReportTraceSink().

◆ m_checkTraceRtt

bool PingTestCase::m_checkTraceRtt {false}
private

Set to true to check the Rtt number.

Definition at line 233 of file ping-test.cc.

Referenced by CheckTraceRtt(), and DoRun().

◆ m_checkTraceTx

bool PingTestCase::m_checkTraceTx {false}
private

Set to true to check the Tx number.

Definition at line 232 of file ping-test.cc.

Referenced by CheckTraceTx(), and DoRun().

◆ m_countAttribute

uint32_t PingTestCase::m_countAttribute {0}
private

Number of pings to send.

Definition at line 223 of file ping-test.cc.

Referenced by DoRun(), and SetCount().

◆ m_countTraceRtt

uint32_t PingTestCase::m_countTraceRtt {0}
private

Rtt trace counter.

Definition at line 230 of file ping-test.cc.

Referenced by DoRun(), and RttTraceSink().

◆ m_countTraceTx

uint32_t PingTestCase::m_countTraceTx {0}
private

Tx trace counter.

Definition at line 229 of file ping-test.cc.

Referenced by DoRun(), and TxTraceSink().

◆ m_destination

Address PingTestCase::m_destination {Ipv4Address("10.0.0.2")}
private

Destination address.

Definition at line 221 of file ping-test.cc.

Referenced by DoRun(), and SetDestinationAddress().

◆ m_devices

NetDeviceContainer PingTestCase::m_devices
private

The NetDevices.

Definition at line 256 of file ping-test.cc.

Referenced by DoRun(), and DoSetup().

◆ m_dropList

std::list<uint32_t> PingTestCase::m_dropList
private

Drop first reply (true)

Definition at line 251 of file ping-test.cc.

Referenced by DoRun(), and SetDropList().

◆ m_expectedReportLoss

uint16_t PingTestCase::m_expectedReportLoss {0}
private

Expected reported Loss.

Definition at line 237 of file ping-test.cc.

Referenced by CheckReportLoss(), and ReportTraceSink().

◆ m_expectedReportRx

uint32_t PingTestCase::m_expectedReportRx {0}
private

Expected reported Rx.

Definition at line 236 of file ping-test.cc.

Referenced by CheckReportReceived(), and ReportTraceSink().

◆ m_expectedReportTime

Time PingTestCase::m_expectedReportTime
private

Expected reported time.

Definition at line 238 of file ping-test.cc.

Referenced by CheckReportTime(), and ReportTraceSink().

◆ m_expectedReportTx

uint32_t PingTestCase::m_expectedReportTx {0}
private

Expected reported Tx.

Definition at line 235 of file ping-test.cc.

Referenced by CheckReportTransmitted(), and ReportTraceSink().

◆ m_expectedTraceRtt

uint32_t PingTestCase::m_expectedTraceRtt {0}
private

Expected Rtt trace sink calls.

Definition at line 227 of file ping-test.cc.

Referenced by CheckTraceRtt(), and DoRun().

◆ m_expectedTraceTx

uint32_t PingTestCase::m_expectedTraceTx {0}
private

Expected Tx trace sink calls.

Definition at line 226 of file ping-test.cc.

Referenced by CheckTraceTx(), and DoRun().

◆ m_interpacketInterval

Time PingTestCase::m_interpacketInterval {Seconds(1.0)}
private

Time between pings.

Definition at line 249 of file ping-test.cc.

Referenced by DoRun(), SetInterval(), and TxTraceSink().

◆ m_ipv4Interfaces

Ipv4InterfaceContainer PingTestCase::m_ipv4Interfaces
private

The IPv4 interfaces.

Definition at line 254 of file ping-test.cc.

Referenced by DoRun(), and DoSetup().

◆ m_ipv6Interfaces

Ipv6InterfaceContainer PingTestCase::m_ipv6Interfaces
private

The IPv6 interfaces.

Definition at line 255 of file ping-test.cc.

Referenced by DoRun(), and DoSetup().

◆ m_lastTx

Time PingTestCase::m_lastTx
private

Last ping Tx time.

Definition at line 250 of file ping-test.cc.

Referenced by TxTraceSink().

◆ m_mtu

uint32_t PingTestCase::m_mtu {1500}
private

Link MTU.

Definition at line 222 of file ping-test.cc.

Referenced by DoSetup().

◆ m_nodes

NodeContainer PingTestCase::m_nodes
private

The simulation nodes.

Definition at line 253 of file ping-test.cc.

Referenced by DoRun(), and DoSetup().

◆ m_simulatorStopTime

Time PingTestCase::m_simulatorStopTime {Seconds(6)}
private

Simulator stop time.

Definition at line 247 of file ping-test.cc.

Referenced by DoRun(), and SetSimulatorStopTime().

◆ m_sizeAttribute

uint32_t PingTestCase::m_sizeAttribute {56}
private

Size of pings.

Definition at line 224 of file ping-test.cc.

Referenced by DoRun(), RttTraceSink(), and SetSize().

◆ m_startTime

Time PingTestCase::m_startTime {Seconds(1)}
private

Start time.

Definition at line 245 of file ping-test.cc.

Referenced by DoRun(), and SetStartTime().

◆ m_stopTime

Time PingTestCase::m_stopTime {Seconds(5)}
private

Stop time.

Definition at line 246 of file ping-test.cc.

Referenced by DoRun(), and SetStopTime().

◆ m_useIpv6

bool PingTestCase::m_useIpv6 {false}
private

Use IPv6 (true) or IPv4 (false)

Definition at line 248 of file ping-test.cc.

Referenced by DoRun(), DoSetup(), and RttTraceSink().


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