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

Base for device-level mesh-under tests. More...

Inheritance diagram for MeshUnderDeviceTestCase:
Collaboration diagram for MeshUnderDeviceTestCase:

Public Member Functions

 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

Protected Member Functions

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

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

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.

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...

Detailed Description

Base for device-level mesh-under tests.

Builds a SixLowPanNetDevice over a MockNetDevice, injects mesh frames through the underlying device and captures both the frames the device re-broadcasts and the packets it delivers locally. Subclasses exercise the device public API end to end, verifying that the policy delegation preserves the historical device behavior.

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

Constructor & Destructor Documentation

◆ MeshUnderDeviceTestCase()

MeshUnderDeviceTestCase::MeshUnderDeviceTestCase ( std::string name)
inline

Constructor.

Parameters
nameThe test case name.

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

References ns3::TestCase::TestCase().

Referenced by MeshUnderChainRelayTestCase::MeshUnderChainRelayTestCase(), MeshUnderDeviceDeliveryTestCase::MeshUnderDeviceDeliveryTestCase(), MeshUnderDeviceForwardTestCase::MeshUnderDeviceForwardTestCase(), MeshUnderDeviceHopLimitTestCase::MeshUnderDeviceHopLimitTestCase(), MeshUnderDeviceMisconfigTestCase::MeshUnderDeviceMisconfigTestCase(), and MeshUnderDeviceNoRelayTestCase::MeshUnderDeviceNoRelayTestCase().

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

Member Function Documentation

◆ BuildMeshFrame()

Ptr< Packet > MeshUnderDeviceTestCase::BuildMeshFrame ( Mac16Address originator,
Mac16Address finalDst,
uint8_t hopsLeft,
uint8_t seqNo )
inlinestaticprotected

Build a mesh frame (MESH + BC0 + uncompressed IPv6 payload).

Parameters
originatorThe MESH originator address.
finalDstThe MESH final destination address.
hopsLeftThe MESH hops-left value.
seqNoThe BC0 sequence number.
Returns
The assembled frame.

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

References ns3::Create(), ns3::SixLowPanMesh::SetFinalDst(), ns3::SixLowPanMesh::SetHopsLeft(), ns3::SixLowPanMesh::SetOriginator(), and ns3::SixLowPanBc0::SetSequenceNumber().

Referenced by MeshUnderChainRelayTestCase::DoRun(), MeshUnderDeviceDeliveryTestCase::DoRun(), MeshUnderDeviceForwardTestCase::DoRun(), MeshUnderDeviceHopLimitTestCase::DoRun(), MeshUnderDeviceMisconfigTestCase::DoRun(), and MeshUnderDeviceNoRelayTestCase::DoRun().

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

◆ CaptureSend()

bool MeshUnderDeviceTestCase::CaptureSend ( Ptr< NetDevice > device,
Ptr< const Packet > packet,
uint16_t protocol,
const Address & source,
const Address & destination,
NetDevice::PacketType packetType )
inlineprotected

Capture a frame the device re-broadcasts.

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

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

References m_sentFrames.

Referenced by SetupDevice().

Here is the caller graph for this function:

◆ CaptureUp()

bool MeshUnderDeviceTestCase::CaptureUp ( Ptr< NetDevice > device,
Ptr< const Packet > packet,
uint16_t protocol,
const Address & source )
inlineprotected

Capture a locally delivered packet.

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

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

References m_deliveredCount.

Referenced by SetupDevice().

Here is the caller graph for this function:

◆ DoTeardown()

void MeshUnderDeviceTestCase::DoTeardown ( )
inlineoverrideprotectedvirtual

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

References ns3::Simulator::Destroy(), m_dev, and m_mock.

Referenced by MeshUnderChainRelayTestCase::DoTeardown().

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

◆ ScheduleInject()

void MeshUnderDeviceTestCase::ScheduleInject ( Time when,
Ptr< Packet > packet )
inlineprotected

Schedule the injection of a frame, as if received from the channel.

The event is scheduled with the node's context, as a channel would.

Parameters
whenThe injection time.
PacketThe frame to inject.

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

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

Referenced by MeshUnderChainRelayTestCase::DoRun(), MeshUnderDeviceDeliveryTestCase::DoRun(), MeshUnderDeviceForwardTestCase::DoRun(), MeshUnderDeviceHopLimitTestCase::DoRun(), MeshUnderDeviceMisconfigTestCase::DoRun(), and MeshUnderDeviceNoRelayTestCase::DoRun().

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

◆ SetupDevice()

void MeshUnderDeviceTestCase::SetupDevice ( bool useMesh = true,
bool forwardMesh = true )
inlineprotected

Build the node, the underlying MockNetDevice and the 6LoWPAN device.

The underlying device gets the MAC address 00:00:00:00:00:01, so the node's 16-bit mesh address is 00:01.

Parameters
useMeshThe device's UseMeshUnder attribute (mesh-under membership).
forwardMeshThe device's ForwardMesh attribute (relaying).

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

References CaptureSend(), CaptureUp(), ns3::CreateObject(), m_dev, m_mock, and ns3::MakeCallback().

Referenced by MeshUnderChainRelayTestCase::DoRun(), MeshUnderDeviceDeliveryTestCase::DoRun(), MeshUnderDeviceForwardTestCase::DoRun(), MeshUnderDeviceHopLimitTestCase::DoRun(), MeshUnderDeviceMisconfigTestCase::DoRun(), and MeshUnderDeviceNoRelayTestCase::DoRun().

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

Member Data Documentation

◆ m_deliveredCount

◆ m_dev

Ptr<SixLowPanNetDevice> MeshUnderDeviceTestCase::m_dev
protected

Device under test.

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

Referenced by MeshUnderDeviceMisconfigTestCase::DoRun(), DoTeardown(), and SetupDevice().

◆ m_mock

Ptr<MockNetDevice> MeshUnderDeviceTestCase::m_mock
protected

Underlying (mock) device.

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

Referenced by MeshUnderChainRelayTestCase::DoRun(), DoTeardown(), ScheduleInject(), and SetupDevice().

◆ m_sentFrames


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