9#include "ns3/address.h"
10#include "ns3/boolean.h"
11#include "ns3/callback.h"
12#include "ns3/data-rate.h"
13#include "ns3/double.h"
15#include "ns3/error-model.h"
16#include "ns3/mac48-address.h"
18#include "ns3/packet.h"
19#include "ns3/pointer.h"
21#include "ns3/simple-channel.h"
22#include "ns3/simple-net-device.h"
23#include "ns3/simulator.h"
24#include "ns3/string.h"
48 void DoRun()
override;
60 :
TestCase(
"Packet dropped for missing protocol handler fires MacRxDrop (issue #370)")
87 b->AddDevice(receiver);
90 sender->SetChannel(channel);
94 receiver->SetChannel(channel);
97 receiver->TraceConnectWithoutContext(
108 receiver->GetAddress(),
109 static_cast<uint16_t
>(0x8888));
116 "Packet dropped due to missing protocol handler was not traced "
117 "(issue #370): expected the MacRxDrop trace to fire once.");
137 void DoRun()
override;
160 :
TestCase(
"ReceiveErrorModel drops a packet and fires PhyRxDrop")
183 for (
bool corrupt : {
false,
true})
204 sender->SetChannel(channel);
206 receiver->SetChannel(channel);
215 receiver->SetAttribute(
"ReceiveErrorModel",
PointerValue(em));
219 receiver->TraceConnectWithoutContext(
228 receiver->GetAddress(),
229 static_cast<uint16_t
>(0x0800));
263 void DoRun()
override;
279 :
TestCase(
"DataRate attribute governs the transmission time")
315 sender->SetChannel(channel);
317 receiver->SetChannel(channel);
328 receiver->GetAddress(),
329 static_cast<uint16_t
>(0x0800));
336 "A 1000-bit packet at 1 Mbps should be received after 1 ms");
Tests that the DataRate attribute governs the transmission time.
Time m_rxTime
Time the packet was received.
void DoRun() override
Implementation to actually run this TestCase.
bool Rx(Ptr< NetDevice > d, Ptr< const Packet > p, uint16_t proto, const Address &from)
Receive callback recording the reception time.
SimpleNetDeviceDataRateTestCase()
Tests that a ReceiveErrorModel discards the packet and fires PhyRxDrop.
void PhyDrop(Ptr< const Packet > p)
PhyRxDrop trace sink.
uint32_t m_deliveries
Number of packets delivered to the callback.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_phyDrops
Number of PhyRxDrop events observed.
bool Rx(Ptr< NetDevice > d, Ptr< const Packet > p, uint16_t proto, const Address &from)
Receive callback counting delivered packets.
SimpleNetDeviceErrorModelTestCase()
Regression test for Issue 370: a received packet with no matching protocol handler must be traced,...
SimpleNetDeviceNoHandlerDropTestCase()
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_drops
Number of MacRxDrop events observed.
void DropEvent(Ptr< const Packet > p)
MacRxDrop trace sink.
Test suite exercising SimpleNetDevice reception behavior.
SimpleNetDeviceTestSuite()
a polymophic address class
Class for representing data rates.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
static Mac48Address Allocate()
Allocate a new Mac48Address.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
Template class for packet Queues.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
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.
Simulation virtual time values and global simulation resolution.
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
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.
Time Seconds(double 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.
static SimpleNetDeviceTestSuite g_simpleNetDeviceTestSuite
Static variable for test init.