11#include "ns3/boolean.h"
12#include "ns3/iana-ieee802-numbers.h"
13#include "ns3/mac16-address.h"
14#include "ns3/mac48-address.h"
16#include "ns3/packet.h"
17#include "ns3/simulator.h"
18#include "ns3/sixlowpan-header.h"
19#include "ns3/sixlowpan-mesh-under-routing.h"
20#include "ns3/sixlowpan-net-device.h"
21#include "ns3/sixlowpan-simple-flooding.h"
23#include "ns3/uinteger.h"
42 :
TestCase(
"Duplicate cache drops oldest entry when full")
54 policy->RecordPacket(orig, 1);
55 policy->RecordPacket(orig, 2);
56 policy->RecordPacket(orig, 3);
63 policy->RecordPacket(orig, 4);
67 "seq 1 should have been dropped (FIFO)");
85 :
TestCase(
"Overflowing one originator does not drop another's entries")
99 policy->RecordPacket(origB, 1);
100 policy->RecordPacket(origB, 2);
101 policy->RecordPacket(origA, 1);
102 policy->RecordPacket(origA, 2);
103 policy->RecordPacket(origA, 3);
125 :
TestCase(
"SimpleFlooding invokes the forward callback once")
143 policy->AssignStreams(1);
151 policy->OnPacketForward(packet, orig, 1, 5, cb);
214 node->AddDevice(
m_dev);
238 packet->AddHeader(uncompressedHdr);
242 packet->AddHeader(bc0Hdr);
248 packet->AddHeader(meshHdr);
268 uint16_t{iana::ieee802numbers::LoWPAN},
367 "Originator preserved");
495 m_dev->TraceConnectWithoutContext(
511 "Frame must not be delivered without UseMeshUnder");
514 "Frame must not be forwarded without UseMeshUnder");
518 "The drop reason must be DROP_MESH_NOT_ENABLED");
586 ?
"3-node chain: middle node relays to the far node"
587 :
"3-node chain: middle node outside the mesh, no relay"),
672 "Far node delivery depends on the middle node relaying");
699 :
TestCase(
"Default policy exists at construction; AssignStreams returns 2")
714 "Default policy must be SixLowPanSimpleFlooding");
Verify the FIFO drop policy of the duplicate-detection cache.
DuplicateCacheFifoDropTestCase()
void DoRun() override
Implementation to actually run this TestCase.
Verify per-originator cache partitioning under overflow.
DuplicateCachePerOriginatorTestCase()
void DoRun() override
Implementation to actually run this TestCase.
Three-node chain: the middle node decides whether the far node is reached.
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.
void DoRun() override
Implementation to actually run this TestCase.
bool CaptureUpFar(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source)
Count packets delivered on the far node.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
bool m_middleInMesh
Whether the middle node takes part in the mesh.
MeshUnderChainRelayTestCase(bool middleInMesh)
Constructor.
Ptr< SixLowPanNetDevice > m_devFar
Far node device under test.
uint32_t m_deliveredFar
Packets delivered on the far node.
Ptr< MockNetDevice > m_mockFar
Far node underlying (mock) device.
A mesh frame destined to the node is delivered locally.
MeshUnderDeviceDeliveryTestCase()
void DoRun() override
Implementation to actually run this TestCase.
The device forwards a new mesh frame once and drops duplicates.
MeshUnderDeviceForwardTestCase()
void DoRun() override
Implementation to actually run this TestCase.
Hop limit and broadcast handling on the receive path.
MeshUnderDeviceHopLimitTestCase()
void DoRun() override
Implementation to actually run this TestCase.
A node outside the mesh receiving a mesh frame reports and drops it.
void CaptureDrop(SixLowPanNetDevice::DropReason reason, Ptr< const Packet > packet, Ptr< SixLowPanNetDevice > device, uint32_t ifindex)
Capture drop-trace invocations.
uint32_t m_dropCount
Number of drop-trace invocations.
void DoRun() override
Implementation to actually run this TestCase.
MeshUnderDeviceMisconfigTestCase()
SixLowPanNetDevice::DropReason m_lastDropReason
Last reported drop reason.
A node in the mesh with ForwardMesh disabled receives but does not relay.
MeshUnderDeviceNoRelayTestCase()
void DoRun() override
Implementation to actually run this TestCase.
The device default policy and stream assignment match the historical behavior.
MeshUnderDeviceStreamsTestCase()
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
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.
std::vector< Ptr< Packet > > m_sentFrames
Frames re-broadcast by the device.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void SetupDevice(bool useMesh=true, bool forwardMesh=true)
Build the node, the underlying MockNetDevice and the 6LoWPAN device.
Ptr< SixLowPanNetDevice > m_dev
Device under test.
bool CaptureUp(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source)
Capture a locally delivered packet.
MeshUnderDeviceTestCase(std::string name)
Constructor.
static Ptr< Packet > BuildMeshFrame(Mac16Address originator, Mac16Address finalDst, uint8_t hopsLeft, uint8_t seqNo)
Build a mesh frame (MESH + BC0 + uncompressed IPv6 payload).
void ScheduleInject(Time when, Ptr< Packet > packet)
Schedule the injection of a frame, as if received from the channel.
uint32_t m_deliveredCount
Packets delivered locally.
Ptr< MockNetDevice > m_mock
Underlying (mock) device.
Verify the default policy schedules and invokes the forward callback.
int m_forwardCount
Number of times the forward callback was invoked.
Ptr< Packet > m_forwardedPacket
Packet captured at the forward callback.
SimpleFloodingForwardsTestCase()
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void RecordForward(Ptr< Packet > packet)
Callback used to capture forward invocations.
void DoRun() override
Implementation to actually run this TestCase.
6LoWPAN mesh-under forwarding test suite.
SixLowPanMeshUnderTestSuite()
a polymophic address class
This class can contain 16 bit addresses.
void Receive(Ptr< Packet > packet, uint16_t protocol, Address to, Address from, NetDevice::PacketType packetType)
Pretend that a packet has been received from a connected Channel.
PacketType
Packet types are used as they are in Linux.
@ PACKET_BROADCAST
Packet addressed to all.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
6LoWPAN BC0 header - see RFC 4944.
void SetSequenceNumber(uint8_t seqNumber)
Set the "Sequence Number" field.
uint8_t GetSequenceNumber() const
Get the "Sequence Number" field.
6LoWPAN IPv6 uncompressed header - see RFC 4944.
6LoWPAN Mesh header - see RFC 4944.
Address GetOriginator() const
Get the "Originator" address.
void SetHopsLeft(uint8_t hopsLeft)
Set the "Hops Left" field.
void SetFinalDst(Address finalDst)
Set the "Final Destination" address.
uint8_t GetHopsLeft() const
Get the "Hops Left" field.
Address GetFinalDst() const
Get the "Final Destination" address.
void SetOriginator(Address originator)
Set the "Originator" address.
Callback< void, Ptr< Packet > > ForwardCallback
Callback used by a policy to forward a packet.
DropReason
Enumeration of the dropping reasons in SixLoWPAN.
@ DROP_MESH_NOT_ENABLED
Mesh-under packet received with UseMeshUnder disabled.
@ DROP_FRAGMENT_TIMEOUT
Fragment timeout exceeded.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
@ UNIT
This test suite implements a Unit Test.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
static SixLowPanMeshUnderTestSuite g_sixLowPanMeshUnderTestSuite
Static suite registration.