12#include "ns3/rng-seed-manager.h"
13#include <ns3/constant-position-mobility-model.h>
14#include <ns3/core-module.h>
16#include <ns3/lr-wpan-module.h>
17#include <ns3/packet.h>
18#include <ns3/propagation-delay-model.h>
19#include <ns3/propagation-loss-model.h>
20#include <ns3/simulator.h>
21#include <ns3/single-model-spectrum-channel.h>
90 void DoRun()
override;
104 :
TestCase(
"Test the 802.15.4 ACK handling")
143 m_dev1->GetMac()->McpsDataRequest(replyParams, pkt);
181 std::string asciiPrefix;
194 m_dev1->AssignStreams(10);
205 sender0Mobility->SetPosition(Vector(0, 0, 0));
206 m_dev0->GetPhy()->SetMobility(sender0Mobility);
210 sender1Mobility->SetPosition(Vector(0, 10, 0));
211 m_dev1->GetPhy()->SetMobility(sender1Mobility);
215 m_dev0->GetMac()->SetMcpsDataConfirmCallback(cb0);
219 m_dev0->GetMac()->SetMcpsDataIndicationCallback(cb1);
223 m_dev1->GetMac()->SetMcpsDataConfirmCallback(cb2);
227 m_dev1->GetMac()->SetMcpsDataIndicationCallback(cb3);
231 uint8_t expectedAckCount = 0;
238 expectedAckCount = 1;
244 expectedAckCount = 0;
250 expectedAckCount = 0;
255 params.m_dstExtAddr =
Mac64Address(
"00:00:00:00:00:00:00:02");
256 expectedAckCount = 1;
259 params.m_dstPanId = 0;
260 params.m_msduHandle = 0;
269 uint8_t ackCounter = 0;
270 std::string sub(
"Frame Type = 2");
271 for (std::string line; getline(traceFile, line);)
273 if (line.find(sub, 0) != std::string::npos)
284 "Sent the request before the reply (as expected)");
287 "The request was sent (as expected)");
290 "The request was sent before the reply arrived (as expected)");
293 "The reply was sent before the reply arrived (as expected)");
296 "The right amount of ACKs have been seen on the channel (as expected)");
320 TestCase::Duration::QUICK);
323 TestCase::Duration::QUICK);
326 TestCase::Duration::QUICK);
329 TestCase::Duration::QUICK);
@ SHORT_ADDRESS_MULTICAST
short addresses, multicast
@ SHORT_ADDRESS_BROADCAST
short addresses, broadcast
@ EXTENDED_ADDRESS_UNICAST
extended addresses
@ SHORT_ADDRESS_UNICAST
short addresses, unicast
Time m_requestSentTime
Request successfully sent time.
void DataIndicationDev0(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when DataIndication is hit on dev0.
Time m_requestTime
Request time.
Time m_replyTime
Reply time.
void DataIndicationDev1(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when DataIndication is hit on dev1.
std::string m_prefix
Filename prefix.
Time m_replySentTime
Reply successfully sent time.
void DataConfirmDev0(McpsDataConfirmParams params)
Function called when DataConfirm is hit on dev0.
Ptr< LrWpanNetDevice > m_dev0
1st LrWpanNetDevice.
LrWpanAckTestCase(const char *const prefix, TestMode_e mode)
Create test case.
void DoRun() override
Implementation to actually run this TestCase.
TestMode_e m_mode
Test mode.
Ptr< LrWpanNetDevice > m_dev1
2nd LrWpanNetDevice.
Time m_replyArrivalTime
Reply arrival time.
void DataConfirmDev1(McpsDataConfirmParams params)
Function called when DataConfirm is hit on dev1.
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
helps to manage and create IEEE 802.15.4 NetDevice objects
NetDeviceContainer Install(NodeContainer c)
Install a LrWpanNetDevice and the associated structures (e.g., channel) in the nodes.
void SetPropagationDelayModel(std::string name, Ts &&... args)
void AddPropagationLossModel(std::string name, Ts &&... args)
This class can contain 16 bit addresses.
static Mac16Address GetMulticast(Ipv6Address address)
Returns the multicast address associated with an IPv6 address according to RFC 4944 Section 9.
static Mac16Address GetBroadcast()
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
static void EnablePrinting()
Enable printing packets metadata.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Simulation virtual time values and global simulation resolution.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
void McpsDataRequest(McpsDataRequestParams params, Ptr< Packet > p) override
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
Network layer to device interface.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
@ TX_OPTION_NONE
TX_OPTION_NONE.
@ TX_OPTION_ACK
TX_OPTION_ACK.
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_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static LrWpanAckTestSuite g_lrWpanAckTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
MCPS-DATA.confirm params.
MCPS-DATA.indication params.
MCPS-DATA.request params.
AddressMode m_dstAddrMode
Destination address mode.
Mac16Address m_dstAddr
Destination address.
Mac64Address m_dstExtAddr
Destination extended address.
uint16_t m_dstPanId
Destination PAN identifier.
AddressMode m_srcAddrMode
Source address mode.
uint8_t m_txOptions
Tx Options (bitfield)
uint8_t m_msduHandle
MSDU handle.