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

Three-node chain: the middle node decides whether the far node is reached. More...

Inheritance diagram for MeshUnderChainRelayTestCase:
Collaboration diagram for MeshUnderChainRelayTestCase:

Public Member Functions

 MeshUnderChainRelayTestCase (bool middleInMesh)
 Constructor.
Public Member Functions inherited from MeshUnderDeviceTestCase
 MeshUnderDeviceTestCase (std::string name)
 Constructor.
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

bool CaptureUpFar (Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source)
 Count packets delivered on the far node.
void DoRun () override
 Implementation to actually run this TestCase.
void DoTeardown () override
 Implementation to do any local setup required for this TestCase.
bool RelayToFarNode (Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, NetDevice::PacketType packetType)
 Deliver whatever the middle node transmits to the far node, as a channel would.

Private Attributes

uint32_t m_deliveredFar {0}
 Packets delivered on the far node.
Ptr< SixLowPanNetDevice > m_devFar
 Far node device under test.
bool m_middleInMesh
 Whether the middle node takes part in the mesh.
Ptr< MockNetDevice > m_mockFar
 Far node underlying (mock) device.

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 MeshUnderDeviceTestCase
bool CaptureSend (Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, NetDevice::PacketType packetType)
 Capture a frame the device re-broadcasts.
bool CaptureUp (Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source)
 Capture a locally delivered packet.
void DoTeardown () override
 Implementation to do any local setup required for this TestCase.
void ScheduleInject (Time when, Ptr< Packet > packet)
 Schedule the injection of a frame, as if received from the channel.
void SetupDevice (bool useMesh=true, bool forwardMesh=true)
 Build the node, the underlying MockNetDevice and the 6LoWPAN device.
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.
Static Protected Member Functions inherited from MeshUnderDeviceTestCase
static Ptr< Packet > BuildMeshFrame (Mac16Address originator, Mac16Address finalDst, uint8_t hopsLeft, uint8_t seqNo)
 Build a mesh frame (MESH + BC0 + uncompressed IPv6 payload).
Protected Attributes inherited from MeshUnderDeviceTestCase
uint32_t m_deliveredCount {0}
 Packets delivered locally.
Ptr< SixLowPanNetDevice > m_dev
 Device under test.
Ptr< MockNetDevice > m_mock
 Underlying (mock) device.
std::vector< Ptr< Packet > > m_sentFrames
 Frames re-broadcast by the device.

Detailed Description

Three-node chain: the middle node decides whether the far node is reached.

A frame from node A (00:02) to node C (00:03) arrives at the middle node B (00:01) only; whatever B transmits reaches C. When B is part of the mesh and forwards, C receives the packet. When B is outside the mesh, C receives nothing.

Definition at line 577 of file sixlowpan-mesh-under-test-suite.cc.

Constructor & Destructor Documentation

◆ MeshUnderChainRelayTestCase()

MeshUnderChainRelayTestCase::MeshUnderChainRelayTestCase ( bool middleInMesh)
inline

Constructor.

Parameters
middleInMeshWhether the middle node takes part in the mesh.

Definition at line 584 of file sixlowpan-mesh-under-test-suite.cc.

References MeshUnderDeviceTestCase::MeshUnderDeviceTestCase(), and m_middleInMesh.

Here is the call graph for this function:

Member Function Documentation

◆ CaptureUpFar()

bool MeshUnderChainRelayTestCase::CaptureUpFar ( Ptr< NetDevice > device,
Ptr< const Packet > packet,
uint16_t protocol,
const Address & source )
inlineprivate

Count packets delivered on the far node.

Parameters
deviceThe receiving device.
PacketThe delivered packet.
protocolThe protocol number.
sourceThe source address.
Returns
true

Definition at line 631 of file sixlowpan-mesh-under-test-suite.cc.

References m_deliveredFar.

Referenced by DoRun().

Here is the caller graph for this function:

◆ DoRun()

void MeshUnderChainRelayTestCase::DoRun ( )
inlineoverrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 640 of file sixlowpan-mesh-under-test-suite.cc.

References MeshUnderDeviceTestCase::BuildMeshFrame(), CaptureUpFar(), ns3::CreateObject(), MeshUnderDeviceTestCase::m_deliveredCount, m_deliveredFar, m_devFar, m_middleInMesh, MeshUnderDeviceTestCase::m_mock, m_mockFar, ns3::MakeCallback(), ns3::MilliSeconds(), NS_TEST_ASSERT_MSG_EQ, RelayToFarNode(), ns3::Simulator::Run(), MeshUnderDeviceTestCase::ScheduleInject(), MeshUnderDeviceTestCase::SetupDevice(), and ns3::Simulator::Stop().

Here is the call graph for this function:

◆ DoTeardown()

void MeshUnderChainRelayTestCase::DoTeardown ( )
inlineoverrideprivatevirtual

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 676 of file sixlowpan-mesh-under-test-suite.cc.

References MeshUnderDeviceTestCase::DoTeardown(), m_devFar, and m_mockFar.

Here is the call graph for this function:

◆ RelayToFarNode()

bool MeshUnderChainRelayTestCase::RelayToFarNode ( Ptr< NetDevice > device,
Ptr< const Packet > packet,
uint16_t protocol,
const Address & source,
const Address & destination,
NetDevice::PacketType packetType )
inlineprivate

Deliver whatever the middle node transmits to the far node, as a channel would.

Parameters
deviceThe sending device.
PacketThe transmitted frame.
protocolThe protocol number.
sourceThe source address.
destinationThe destination address.
packetTypeThe packet type.
Returns
true

Definition at line 604 of file sixlowpan-mesh-under-test-suite.cc.

References m_mockFar, ns3::MicroSeconds(), ns3::NetDevice::PACKET_BROADCAST, ns3::MockNetDevice::Receive(), and ns3::Simulator::ScheduleWithContext().

Referenced by DoRun().

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

Member Data Documentation

◆ m_deliveredFar

uint32_t MeshUnderChainRelayTestCase::m_deliveredFar {0}
private

Packets delivered on the far node.

Definition at line 686 of file sixlowpan-mesh-under-test-suite.cc.

Referenced by CaptureUpFar(), and DoRun().

◆ m_devFar

Ptr<SixLowPanNetDevice> MeshUnderChainRelayTestCase::m_devFar
private

Far node device under test.

Definition at line 685 of file sixlowpan-mesh-under-test-suite.cc.

Referenced by DoRun(), and DoTeardown().

◆ m_middleInMesh

bool MeshUnderChainRelayTestCase::m_middleInMesh
private

Whether the middle node takes part in the mesh.

Definition at line 683 of file sixlowpan-mesh-under-test-suite.cc.

Referenced by MeshUnderChainRelayTestCase(), and DoRun().

◆ m_mockFar

Ptr<MockNetDevice> MeshUnderChainRelayTestCase::m_mockFar
private

Far node underlying (mock) device.

Definition at line 684 of file sixlowpan-mesh-under-test-suite.cc.

Referenced by DoRun(), DoTeardown(), and RelayToFarNode().


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