11#include "ns3/ipv6-header.h"
13#include "ns3/mac48-address.h"
15#include "ns3/packet.h"
16#include "ns3/simulator.h"
17#include "ns3/sixlowpan-header.h"
18#include "ns3/sixlowpan-net-device.h"
20#include "ns3/uinteger.h"
71 void DoRun()
override;
75 :
TestCase(
"SixLowPanNetDevice compression threshold from device padding threshold")
99 node->AddDevice(mock);
102 mock->SetPaddingThreshold(paddingThreshold);
103 mock->SetSendCallback(
107 six->SetAttribute(
"CompressionThreshold",
UintegerValue(compressionThreshold));
108 node->AddDevice(six);
109 six->SetNetDevice(mock);
120 pkt->AddHeader(ipHdr);
136 constexpr uint16_t noPadding = 0;
137 constexpr uint16_t ethernetPadding = 46;
138 constexpr uint32_t defaultThreshold = 0;
139 constexpr uint32_t ethernetThreshold = 46;
142 constexpr uint32_t smallPayload = 4;
143 constexpr uint32_t largePayload = 20;
146 uint8_t dispatch =
SendOnePacket(noPadding, defaultThreshold, smallPayload);
149 "Expected IPHC dispatch on a non-padding device");
154 dispatch =
SendOnePacket(ethernetPadding, defaultThreshold, smallPayload);
157 "Expected uncompressed IPv6 dispatch on a padding device");
161 dispatch =
SendOnePacket(noPadding, ethernetThreshold, smallPayload);
164 "Expected uncompressed IPv6 dispatch with the attribute set");
168 dispatch =
SendOnePacket(noPadding, ethernetThreshold, largePayload);
171 "Expected IPHC dispatch for a packet above the threshold");
SixLowPanNetDevice compression threshold test.
bool ReceiveFromMockDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, NetDevice::PacketType packetType)
Callback for frames handed to the underlying mock device.
SixLowPanCompressionThresholdTest()
uint8_t SendOnePacket(uint16_t paddingThreshold, uint32_t compressionThreshold, uint32_t payloadSize)
Send one packet over a SixLowPanNetDevice.
uint8_t m_dispatch
First byte of the last transmitted frame.
void DoRun() override
Implementation to actually run this TestCase.
SixLowPanNetDevice compression threshold TestSuite.
SixLowPanCompressionThresholdTestSuite()
a polymophic address class
Describes an IPv6 address.
PacketType
Packet types are used as they are in Linux.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Dispatch_e GetDispatchType(uint8_t dispatch)
Get the Dispatch type.
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.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
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_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static SixLowPanCompressionThresholdTestSuite g_sixLowPanCompressionThresholdTestSuite
Static variable for test initialization.