23#include "ns3/rng-seed-manager.h"
24#include <ns3/constant-position-mobility-model.h>
25#include <ns3/core-module.h>
27#include <ns3/lr-wpan-module.h>
28#include <ns3/packet.h>
29#include <ns3/propagation-delay-model.h>
30#include <ns3/propagation-loss-model.h>
31#include <ns3/simulator.h>
32#include <ns3/single-model-spectrum-channel.h>
100 void DoRun()
override;
114 :
TestCase(
"Test the 802.15.4 ACK handling")
184 RngSeedManager::SetSeed(1);
185 RngSeedManager::SetRun(6);
187 Packet::EnablePrinting();
191 std::string asciiPrefix;
197 m_dev0 = CreateObject<LrWpanNetDevice>();
198 m_dev1 = CreateObject<LrWpanNetDevice>();
214 CreateObject<LogDistancePropagationLossModel>();
216 CreateObject<ConstantSpeedPropagationDelayModel>();
217 channel->AddPropagationLossModel(propModel);
218 channel->SetPropagationDelayModel(delayModel);
228 CreateObject<ConstantPositionMobilityModel>();
229 sender0Mobility->SetPosition(Vector(0, 0, 0));
232 CreateObject<ConstantPositionMobilityModel>();
234 sender1Mobility->SetPosition(Vector(0, 10, 0));
255 uint8_t expectedAckCount = 0;
262 expectedAckCount = 1;
267 params.
m_dstAddr = Mac16Address::GetMulticast(Ipv6Address::GetAllNodesMulticast());
268 expectedAckCount = 0;
273 params.
m_dstAddr = Mac16Address::GetBroadcast();
274 expectedAckCount = 0;
280 expectedAckCount = 1;
287 Simulator::ScheduleNow(&LrWpanMac::McpsDataRequest,
m_dev0->
GetMac(), params, p0);
293 uint8_t ackCounter = 0;
294 std::string sub(
"Frame Type = 2");
295 for (std::string line; getline(traceFile, line);)
297 if (line.find(sub, 0) != std::string::npos)
308 "Sent the request before the reply (as expected)");
312 "The request was sent before the reply arrived (as expected)");
315 "The reply was sent before the reply arrived (as expected)");
318 "The right amount of ACKs have been seen on the channel (as expected)");
323 Simulator::Destroy();
@ 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.
helps to manage and create IEEE 802.15.4 NetDevice objects
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< LrWpanPhy > GetPhy() const
Get the PHY used by this NetDevice.
void SetAddress(Address address) override
This method indirects to LrWpanMac::SetShortAddress ()
This class can contain 16 bit addresses.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void AddTestCase(TestCase *testCase, TestDuration 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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
@ TX_OPTION_ACK
TX_OPTION_ACK.
@ TX_OPTION_NONE
TX_OPTION_NONE.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#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_GT(actual, limit, msg)
Test that an actual value is greater 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.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
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.
LrWpanAddressMode m_srcAddrMode
Source address mode.
Mac64Address m_dstExtAddr
Destination extended address.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
uint16_t m_dstPanId
Destination PAN identifier.
Mac16Address m_dstAddr
Destination address.
uint8_t m_msduHandle
MSDU handle.
uint8_t m_txOptions
Tx Options (bitfield)