A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lr-wpan-mac-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Tokushima University, Japan
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
18 */
19
20#include <ns3/constant-position-mobility-model.h>
21#include <ns3/core-module.h>
22#include <ns3/log.h>
23#include <ns3/lr-wpan-module.h>
24#include <ns3/packet.h>
25#include <ns3/propagation-delay-model.h>
26#include <ns3/propagation-loss-model.h>
27#include <ns3/simulator.h>
28#include <ns3/single-model-spectrum-channel.h>
29
30#include <iostream>
31
32using namespace ns3;
33using namespace ns3::lrwpan;
34
35NS_LOG_COMPONENT_DEFINE("lr-wpan-mac-test");
36
37/**
38 * \ingroup lr-wpan-test
39 * \ingroup tests
40 *
41 * \brief Test PHY going to TRX_OFF after CSMA failure (MAC->RxOnWhenIdle(false))
42 */
44{
45 public:
48
49 private:
50 /**
51 * Function called when a Data indication is invoked
52 * \param params MCPS data indication parameters
53 * \param p packet
54 */
56 /**
57 * Function called when a Data confirm is invoked (After Tx Attempt)
58 * \param params MCPS data confirm parameters
59 */
61 /**
62 * Function called when a the PHY state changes in Dev0 [00:01]
63 * \param context context
64 * \param now time at which the function is called
65 * \param oldState old PHY state
66 * \param newState new PHY state
67 */
68 void StateChangeNotificationDev0(std::string context,
69 Time now,
70 PhyEnumeration oldState,
71 PhyEnumeration newState);
72 /**
73 * Function called when a the PHY state changes in Dev2 [00:03]
74 * \param context context
75 * \param now time at which the function is called
76 * \param oldState old PHY state
77 * \param newState new PHY state
78 */
79 void StateChangeNotificationDev2(std::string context,
80 Time now,
81 PhyEnumeration oldState,
82 PhyEnumeration newState);
83
84 void DoRun() override;
85
86 PhyEnumeration m_dev0State; //!< Stores the PHY state of device 0 [00:01]
87};
88
90 : TestCase("Test PHY going to TRX_OFF state after CSMA failure")
91{
92}
93
95{
96}
97
98void
100{
101 NS_LOG_DEBUG("Received packet of size " << p->GetSize());
102}
103
104void
106{
107 if (params.m_status == MacStatus::SUCCESS)
108 {
109 NS_LOG_DEBUG("LrWpanMcpsDataConfirmStatus = Success");
110 }
111 else if (params.m_status == MacStatus::CHANNEL_ACCESS_FAILURE)
112 {
113 NS_LOG_DEBUG("LrWpanMcpsDataConfirmStatus = Channel Access Failure");
114 }
115}
116
117void
119 Time now,
120 PhyEnumeration oldState,
121 PhyEnumeration newState)
122{
124 << context << "PHY state change at " << now.As(Time::S) << " from "
125 << LrWpanHelper::LrWpanPhyEnumerationPrinter(oldState) << " to "
127
128 m_dev0State = newState;
129}
130
131void
133 Time now,
134 PhyEnumeration oldState,
135 PhyEnumeration newState)
136{
138 << context << "PHY state change at " << now.As(Time::S) << " from "
139 << LrWpanHelper::LrWpanPhyEnumerationPrinter(oldState) << " to "
141}
142
143void
145{
146 // [00:01] [00:02] [00:03]
147 // Node 0------>Node1<------Node2 (interferer)
148 //
149 // Test Setup:
150 //
151 // Start the test with a transmission from node 2 to node 1,
152 // soon after, node 0 will attempt to transmit a packet to node 1 as well but
153 // it will fail because node 2 is still transmitting.
154 //
155 // The test confirms that the PHY in node 0 goes to TRX_OFF
156 // after its CSMA failure because its MAC has been previously
157 // set with flag RxOnWhenIdle (false). To ensure that node 0 CSMA
158 // do not attempt to do multiple backoffs delays in its CSMA,
159 // macMinBE and MacMaxCSMABackoffs has been set to 0.
160
162
164 LogComponentEnable("LrWpanCsmaCa", LOG_LEVEL_DEBUG);
165 LogComponentEnable("lr-wpan-mac-test", LOG_LEVEL_DEBUG);
166
167 // Create 3 nodes, and a NetDevice for each one
168 Ptr<Node> n0 = CreateObject<Node>();
169 Ptr<Node> n1 = CreateObject<Node>();
170 Ptr<Node> interferenceNode = CreateObject<Node>();
171
172 Ptr<LrWpanNetDevice> dev0 = CreateObject<LrWpanNetDevice>();
173 Ptr<LrWpanNetDevice> dev1 = CreateObject<LrWpanNetDevice>();
174 Ptr<LrWpanNetDevice> dev2 = CreateObject<LrWpanNetDevice>();
175
176 dev0->SetAddress(Mac16Address("00:01"));
177 dev1->SetAddress(Mac16Address("00:02"));
178 dev2->SetAddress(Mac16Address("00:03"));
179
180 // Each device must be attached to the same channel
181 Ptr<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChannel>();
183 CreateObject<LogDistancePropagationLossModel>();
185 CreateObject<ConstantSpeedPropagationDelayModel>();
186 channel->AddPropagationLossModel(propModel);
187 channel->SetPropagationDelayModel(delayModel);
188
189 dev0->SetChannel(channel);
190 dev1->SetChannel(channel);
191 dev2->SetChannel(channel);
192
193 // To complete configuration, a LrWpanNetDevice must be added to a node
194 n0->AddDevice(dev0);
195 n1->AddDevice(dev1);
196 interferenceNode->AddDevice(dev2);
197
198 // Trace state changes in the phy
199 dev0->GetPhy()->TraceConnect(
200 "TrxState",
201 std::string("[address 00:01]"),
203 dev2->GetPhy()->TraceConnect(
204 "TrxState",
205 std::string("[address 00:03]"),
207
208 Ptr<ConstantPositionMobilityModel> sender0Mobility =
209 CreateObject<ConstantPositionMobilityModel>();
210 sender0Mobility->SetPosition(Vector(0, 0, 0));
211 dev0->GetPhy()->SetMobility(sender0Mobility);
212 Ptr<ConstantPositionMobilityModel> sender1Mobility =
213 CreateObject<ConstantPositionMobilityModel>();
214
215 sender1Mobility->SetPosition(Vector(0, 1, 0));
216 dev1->GetPhy()->SetMobility(sender1Mobility);
217
218 Ptr<ConstantPositionMobilityModel> sender3Mobility =
219 CreateObject<ConstantPositionMobilityModel>();
220
221 sender3Mobility->SetPosition(Vector(0, 2, 0));
222 dev2->GetPhy()->SetMobility(sender3Mobility);
223
226 dev0->GetMac()->SetMcpsDataConfirmCallback(cb0);
227
230 dev0->GetMac()->SetMcpsDataIndicationCallback(cb1);
231
234 dev1->GetMac()->SetMcpsDataConfirmCallback(cb2);
235
238 dev1->GetMac()->SetMcpsDataIndicationCallback(cb3);
239
240 dev0->GetMac()->SetRxOnWhenIdle(false);
241 dev1->GetMac()->SetRxOnWhenIdle(false);
242
243 // set CSMA min beacon exponent (BE) to 0 to make all backoff delays == to 0 secs.
244 dev0->GetCsmaCa()->SetMacMinBE(0);
245 dev2->GetCsmaCa()->SetMacMinBE(0);
246
247 // Only try once to do a backoff period before giving up.
248 dev0->GetCsmaCa()->SetMacMaxCSMABackoffs(0);
249 dev2->GetCsmaCa()->SetMacMaxCSMABackoffs(0);
250
251 // The below should trigger two callbacks when end-to-end data is working
252 // 1) DataConfirm callback is called
253 // 2) DataIndication callback is called with value of 50
254 Ptr<Packet> p0 = Create<Packet>(50); // 50 bytes of dummy data
256 params.m_dstPanId = 0;
257
258 params.m_srcAddrMode = SHORT_ADDR;
259 params.m_dstAddrMode = SHORT_ADDR;
260 params.m_dstAddr = Mac16Address("00:02");
261
262 params.m_msduHandle = 0;
263
264 // Send the packet that will be rejected due to channel access failure
266 Seconds(0.00033),
268 dev0->GetMac(),
269 params,
270 p0);
271
272 // Send interference packet
273 Ptr<Packet> p2 = Create<Packet>(60); // 60 bytes of dummy data
274 params.m_dstAddr = Mac16Address("00:02");
275
277 Seconds(0.0),
279 dev2->GetMac(),
280 params,
281 p2);
282
283 NS_LOG_DEBUG("----------- Start of TestRxOffWhenIdleAfterCsmaFailure -------------------");
285
287 PhyEnumeration::IEEE_802_15_4_PHY_TRX_OFF,
288 "Error, dev0 [00:01] PHY should be in TRX_OFF after CSMA failure");
289
291}
292
293/**
294 * \ingroup lr-wpan-test
295 * \ingroup tests
296 *
297 * \brief Test MAC Active Scan PAN descriptor reception and check some of its values.
298 */
300{
301 public:
304
305 private:
306 /**
307 * Function called in response to a MAC scan request.
308 *
309 * \param params MLME scan confirm parameters
310 */
312
313 /**
314 * Function used to notify the reception of a beacon with payload.
315 *
316 * \param params The MLME-BEACON-NOTIFY.indication parameters
317 */
319
320 void DoRun() override;
321
322 std::vector<PanDescriptor> m_panDescriptorList; //!< The list of PAN descriptors
323 //!< accumulated during the scan.
324 uint32_t g_beaconPayloadSize; //!< The size of the beacon payload received
325 //!< from a coordinator.
326};
327
329 : TestCase("Test the reception of PAN descriptors while performing an active scan")
330{
331}
332
334{
335}
336
337void
339{
340 if (params.m_status == MacStatus::SUCCESS)
341 {
342 m_panDescriptorList = params.m_panDescList;
343 }
344}
345
346void
348{
349 g_beaconPayloadSize = params.m_sdu->GetSize();
350}
351
352void
354{
355 /*
356 * [00:01] [00:02] [00:03]
357 * PAN Coordinator 1 (PAN: 5) End Device PAN Coordinator 2 (PAN: 7)
358 *
359 * |--------100 m----------------|----------106 m -----------------------|
360 * Channel 12 (Active Scan channels 11-14) Channel 14
361 *
362 * Test Setup:
363 *
364 * At the beginning of the simulation, PAN coordinators are set to
365 * non-beacon enabled mode and wait for any beacon requests.
366 *
367 * During the simulation, the end device do an Active scan (i.e. send beacon request commands to
368 * the scanned channels). On reception of such commands, coordinators reply with a single beacon
369 * which contains a PAN descriptor. The test makes sure that the PAN descriptors are received (2
370 * PAN descriptors) and because both PAN coordinators are set to a different distance from the
371 * end device, their LQI values should be below 255 but above 0. Likewise, Coordinator 2 LQI
372 * value should be less than Coordinator 1 LQI value. The exact expected value of LQI is not
373 * tested, this is dependable on the LQI implementation.
374 */
375
376 // Create 2 PAN coordinator nodes, and 1 end device
377 Ptr<Node> coord1 = CreateObject<Node>();
378 Ptr<Node> endNode = CreateObject<Node>();
379 Ptr<Node> coord2 = CreateObject<Node>();
380
381 Ptr<LrWpanNetDevice> coord1NetDevice = CreateObject<LrWpanNetDevice>();
382 Ptr<LrWpanNetDevice> endNodeNetDevice = CreateObject<LrWpanNetDevice>();
383 Ptr<LrWpanNetDevice> coord2NetDevice = CreateObject<LrWpanNetDevice>();
384
385 // PAN coordinators typically have a short address = 00:00 (e.g. Zigbee networks)
386 coord1NetDevice->GetMac()->SetExtendedAddress("00:00:00:00:00:00:CA:FE");
387 coord1NetDevice->GetMac()->SetShortAddress(Mac16Address("00:00"));
388
389 coord2NetDevice->GetMac()->SetExtendedAddress("00:00:00:00:00:00:BE:BE");
390 coord2NetDevice->GetMac()->SetShortAddress(Mac16Address("00:00"));
391
392 // An end device currently not associated (short address = ff:ff)
393 endNodeNetDevice->GetMac()->SetExtendedAddress("00:00:00:00:00:00:00:03");
394 endNodeNetDevice->GetMac()->SetShortAddress(Mac16Address("ff:ff"));
395
396 // Configure Spectrum channel
397 Ptr<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChannel>();
399 CreateObject<LogDistancePropagationLossModel>();
401 CreateObject<ConstantSpeedPropagationDelayModel>();
402 channel->AddPropagationLossModel(propModel);
403 channel->SetPropagationDelayModel(delayModel);
404
405 coord1NetDevice->SetChannel(channel);
406 endNodeNetDevice->SetChannel(channel);
407 coord2NetDevice->SetChannel(channel);
408
409 coord1->AddDevice(coord1NetDevice);
410 endNode->AddDevice(endNodeNetDevice);
411 coord2->AddDevice(coord2NetDevice);
412
413 // Mobility
415 CreateObject<ConstantPositionMobilityModel>();
416 coord1Mobility->SetPosition(Vector(0, 0, 0));
417 coord1NetDevice->GetPhy()->SetMobility(coord1Mobility);
418
419 Ptr<ConstantPositionMobilityModel> endNodeMobility =
420 CreateObject<ConstantPositionMobilityModel>();
421 endNodeMobility->SetPosition(Vector(100, 0, 0));
422 endNodeNetDevice->GetPhy()->SetMobility(endNodeMobility);
423
425 CreateObject<ConstantPositionMobilityModel>();
426 coord2Mobility->SetPosition(Vector(206, 0, 0));
427 coord2NetDevice->GetPhy()->SetMobility(coord2Mobility);
428
429 // MAC layer Callbacks hooks
432 endNodeNetDevice->GetMac()->SetMlmeScanConfirmCallback(cb0);
433
436 endNodeNetDevice->GetMac()->SetMlmeBeaconNotifyIndicationCallback(cb1);
437
438 /////////////////
439 // ACTIVE SCAN //
440 /////////////////
441
442 // PAN coordinator N0 (PAN 5) is set to channel 12 in non-beacon mode but answer to beacon
443 // requests.
445 params.m_panCoor = true;
446 params.m_PanId = 5;
447 params.m_bcnOrd = 15;
448 params.m_sfrmOrd = 15;
449 params.m_logCh = 12;
451 Seconds(2.0),
453 coord1NetDevice->GetMac(),
454 params);
455
456 // PAN coordinator N2 (PAN 7) is set to channel 14 in non-beacon mode but answer to beacon
457 // requests. The second coordinator includes a beacon payload of 25 bytes using the
458 // MLME-SET.request primitive.
459 Ptr<MacPibAttributes> pibAttribute = Create<MacPibAttributes>();
460 pibAttribute->macBeaconPayload = Create<Packet>(25);
461 coord2NetDevice->GetMac()->MlmeSetRequest(MacPibAttributeIdentifier::macBeaconPayload,
462 pibAttribute);
463
465 params2.m_panCoor = true;
466 params2.m_PanId = 7;
467 params2.m_bcnOrd = 15;
468 params2.m_sfrmOrd = 15;
469 params2.m_logCh = 14;
471 Seconds(2.0),
473 coord2NetDevice->GetMac(),
474 params2);
475
476 // End device N1 broadcast a single BEACON REQUEST for each channel (11, 12, 13, and 14).
477 // If a coordinator is present and in range, it will respond with a beacon broadcast.
478 // Scan Channels are represented by bits 0-26 (27 LSB)
479 // ch 14 ch 11
480 // | |
481 // 0x7800 = 0000000000000000111100000000000
482 MlmeScanRequestParams scanParams;
483 scanParams.m_chPage = 0;
484 scanParams.m_scanChannels = 0x7800;
485 scanParams.m_scanDuration = 14;
486 scanParams.m_scanType = MLMESCAN_ACTIVE;
488 Seconds(3.0),
490 endNodeNetDevice->GetMac(),
491 scanParams);
492
494 NS_LOG_DEBUG("----------- Start of TestActiveScanPanDescriptors -------------------");
496
498 2,
499 "Error, Beacons not received or PAN descriptors not found");
500
501 if (m_panDescriptorList.size() == 2)
502 {
504 255,
505 "Error, Coordinator 1 (PAN 5) LQI value should be less than 255.");
507 255,
508 "Error, Coordinator 2 (PAN 7) LQI value should be less than 255.");
510 0,
511 "Error, Coordinator 1 (PAN 5) LQI value should be greater than 0.");
513 0,
514 "Error, Coordinator 2 (PAN 7) LQI value should be greater than 0.");
515
517 m_panDescriptorList[0].m_linkQuality,
518 "Error, Coordinator 2 (PAN 7) LQI value should"
519 " be less than Coordinator 1 (PAN 5).");
520
522 25,
523 "Error, Beacon Payload not received or incorrect size (25 bytes)");
524 }
525
527}
528
529/**
530 * \ingroup lr-wpan-test
531 * \ingroup tests
532 *
533 * \brief Test MAC Orphan Scan Coordinator Realignment command reception and its values.
534 */
536{
537 public:
539 ~TestOrphanScan() override;
540
541 private:
542 /**
543 * Function called in response to a MAC scan request.
544 *
545 * \param params MLME scan confirm parameters
546 */
548
549 /**
550 * Function called as a result of receiving an orphan notification command
551 * on the coordinator
552 *
553 * \param params MLME orphan indication parameters
554 */
556
557 void DoRun() override;
558
559 Ptr<LrWpanNetDevice> coord1NetDevice; //!< The LrWpanNetDevice of coordinator 1
560 Ptr<LrWpanNetDevice> endNodeNetDevice; //!< The LrWpanNetDevice of the end device
561 bool m_orphanScanSuccess; //!< Indicates a successful orphan scan
562};
563
565 : TestCase("Test an orphan scan and the reception of the commands involved")
566{
567 m_orphanScanSuccess = false;
568}
569
571{
572}
573
574void
576{
577 if (params.m_status == MacStatus::SUCCESS)
578 {
579 m_orphanScanSuccess = true;
580 }
581}
582
583void
585{
586 // The steps taken by the coordinator on the event of an orphan indication
587 // are meant to be implemented by the next higher layer and are out of the scope of the
588 // standard. In this test, we assume that coordinator 2 already has
589 // the endDevice [00:00:00:00:00:00:00:03] registered and therefore reply to this device
590 // a with a coordidinator realignment command.
591
592 if (params.m_orphanAddr == Mac64Address("00:00:00:00:00:00:00:02"))
593 {
594 MlmeOrphanResponseParams respParams;
595 respParams.m_assocMember = true;
596 respParams.m_orphanAddr = params.m_orphanAddr;
597 respParams.m_shortAddr = Mac16Address("00:02");
598
600 coord1NetDevice->GetMac(),
601 respParams);
602 }
603}
604
605void
607{
608 // Create 2 PAN coordinator nodes, and 1 end device
609 Ptr<Node> coord1 = CreateObject<Node>();
610 Ptr<Node> endNode = CreateObject<Node>();
611
612 coord1NetDevice = CreateObject<LrWpanNetDevice>();
613 endNodeNetDevice = CreateObject<LrWpanNetDevice>();
614
615 // PAN Coordinators configurations require to set both, the EUI-64 (extended address)
616 // and to assign their own short address.
617 coord1NetDevice->GetMac()->SetExtendedAddress(Mac64Address("00:00:00:00:00:00:00:01"));
618 coord1NetDevice->GetMac()->SetShortAddress(Mac16Address("00:01"));
619
620 // Other devices must have only its EUI-64 and later on, their short address is
621 // potentially assigned by the coordinator.
622 endNodeNetDevice->GetMac()->SetExtendedAddress(Mac64Address("00:00:00:00:00:00:00:02"));
623
624 // Configure Spectrum channel
625 Ptr<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChannel>();
627 CreateObject<LogDistancePropagationLossModel>();
629 CreateObject<ConstantSpeedPropagationDelayModel>();
630 channel->AddPropagationLossModel(propModel);
631 channel->SetPropagationDelayModel(delayModel);
632
633 coord1NetDevice->SetChannel(channel);
634 endNodeNetDevice->SetChannel(channel);
635
636 coord1->AddDevice(coord1NetDevice);
637 endNode->AddDevice(endNodeNetDevice);
638
639 // Mobility
641 CreateObject<ConstantPositionMobilityModel>();
642 coord1Mobility->SetPosition(Vector(0, 0, 0));
643 coord1NetDevice->GetPhy()->SetMobility(coord1Mobility);
644
645 Ptr<ConstantPositionMobilityModel> endNodeMobility =
646 CreateObject<ConstantPositionMobilityModel>();
647 endNodeMobility->SetPosition(Vector(100, 0, 0));
648 endNodeNetDevice->GetPhy()->SetMobility(endNodeMobility);
649
650 // MAC layer Callbacks hooks
653 endNodeNetDevice->GetMac()->SetMlmeScanConfirmCallback(cb1);
654
657 coord1NetDevice->GetMac()->SetMlmeOrphanIndicationCallback(cb2);
658 /////////////////
659 // ORPHAN SCAN //
660 /////////////////
661
662 // PAN coordinator N0 (PAN 5) is set to channel 12 in non-beacon mode
663 // but answer to beacon request and orphan notification commands.
665 params.m_panCoor = true;
666 params.m_PanId = 5;
667 params.m_bcnOrd = 15;
668 params.m_sfrmOrd = 15;
669 params.m_logCh = 12;
671 Seconds(2.0),
673 coord1NetDevice->GetMac(),
674 params);
675
676 // End device N1 is set to scan 4 channels looking for the presence of a coordinator.
677 // On each channel, a single orphan notification command is sent and a response is
678 // waited for a maximum time of macResponseWaitTime. If a reply is received from a
679 // coordinator within this time (coordinator realignment command), the programmed scans on
680 // other channels is suspended.
681 // Scan Channels are represented by bits 0-26 (27 LSB)
682 // ch 14 ch 11
683 // | |
684 // 0x7800 = 0000000000000000111100000000000
685 MlmeScanRequestParams scanParams;
686 scanParams.m_chPage = 0;
687 scanParams.m_scanChannels = 0x7800;
688 scanParams.m_scanType = MLMESCAN_ORPHAN;
690 Seconds(3.0),
692 endNodeNetDevice->GetMac(),
693 scanParams);
694
696 NS_LOG_DEBUG("----------- Start of TestOrphanScan -------------------");
698
700 true,
701 "Error, no coordinator realignment commands"
702 " received during orphan scan");
704 {
705 NS_TEST_EXPECT_MSG_EQ(endNodeNetDevice->GetMac()->GetShortAddress(),
706 Mac16Address("00:02"),
707 "Error, end device did not receive short address"
708 " during orphan scan");
709 }
710
712}
713
714/**
715 * \ingroup lr-wpan-test
716 * \ingroup tests
717 *
718 * \brief LrWpan MAC TestSuite
719 */
721{
722 public:
724};
725
727 : TestSuite("lr-wpan-mac-test", Type::UNIT)
728{
729 AddTestCase(new TestRxOffWhenIdleAfterCsmaFailure, TestCase::Duration::QUICK);
730 AddTestCase(new TestActiveScanPanDescriptors, TestCase::Duration::QUICK);
731 AddTestCase(new TestOrphanScan, TestCase::Duration::QUICK);
732}
733
734static LrWpanMacTestSuite g_lrWpanMacTestSuite; //!< Static variable for test initialization
LrWpan MAC TestSuite.
Test MAC Active Scan PAN descriptor reception and check some of its values.
void ScanConfirm(MlmeScanConfirmParams params)
Function called in response to a MAC scan request.
uint32_t g_beaconPayloadSize
The size of the beacon payload received from a coordinator.
void BeaconNotifyIndication(MlmeBeaconNotifyIndicationParams params)
Function used to notify the reception of a beacon with payload.
std::vector< PanDescriptor > m_panDescriptorList
The list of PAN descriptors accumulated during the scan.
void DoRun() override
Implementation to actually run this TestCase.
Test MAC Orphan Scan Coordinator Realignment command reception and its values.
void DoRun() override
Implementation to actually run this TestCase.
void ScanConfirm(MlmeScanConfirmParams params)
Function called in response to a MAC scan request.
void OrphanIndicationCoord(MlmeOrphanIndicationParams params)
Function called as a result of receiving an orphan notification command on the coordinator.
~TestOrphanScan() override
Ptr< LrWpanNetDevice > coord1NetDevice
The LrWpanNetDevice of coordinator 1.
Ptr< LrWpanNetDevice > endNodeNetDevice
The LrWpanNetDevice of the end device.
bool m_orphanScanSuccess
Indicates a successful orphan scan.
Test PHY going to TRX_OFF after CSMA failure (MAC->RxOnWhenIdle(false))
void DataConfirm(McpsDataConfirmParams params)
Function called when a Data confirm is invoked (After Tx Attempt)
void StateChangeNotificationDev0(std::string context, Time now, PhyEnumeration oldState, PhyEnumeration newState)
Function called when a the PHY state changes in Dev0 [00:01].
PhyEnumeration m_dev0State
Stores the PHY state of device 0 [00:01].
void StateChangeNotificationDev2(std::string context, Time now, PhyEnumeration oldState, PhyEnumeration newState)
Function called when a the PHY state changes in Dev2 [00:03].
void DoRun() override
Implementation to actually run this TestCase.
void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when a Data indication is invoked.
static std::string LrWpanPhyEnumerationPrinter(lrwpan::PhyEnumeration e)
Transform the LrWpanPhyEnumeration enumeration into a printable string.
This class can contain 16 bit addresses.
Definition: mac16-address.h:44
an EUI-64 address
Definition: mac64-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Definition: simulator.h:588
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:605
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:415
@ S
second
Definition: nstime.h:116
void MlmeStartRequest(MlmeStartRequestParams params) override
IEEE 802.15.4-2006, section 7.1.14.1 MLME-START.request Request to allow a PAN coordinator to initiat...
Definition: lr-wpan-mac.cc:586
void MlmeOrphanResponse(MlmeOrphanResponseParams params) override
IEEE 802.15.4-2011, section 6.2.7.2 MLME-ORPHAN.response Primitive used to initiatte a response to an...
Definition: lr-wpan-mac.cc:805
void MlmeScanRequest(MlmeScanRequestParams params) override
IEEE 802.15.4-2011, section 6.2.10.1 MLME-SCAN.request Request primitive used to initiate a channel s...
Definition: lr-wpan-mac.cc:625
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.
Definition: lr-wpan-mac.cc:386
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
PhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:115
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Definition: test.h:710
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:252
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Definition: test.h:875
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
static LrWpanMacTestSuite g_lrWpanMacTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
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...
Definition: callback.h:706
LogLevel
Logging severity classes and levels.
Definition: log.h:94
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition: log.h:118
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
Definition: log.h:119
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition: log.h:113
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:320
MCPS-DATA.indication params.
MLME-BEACON-NOTIFY.indication params.
MLME-ORPHAN.indication params.
MLME-ORPHAN.response params.
bool m_assocMember
T = allocated with this coord | F = otherwise.
Mac64Address m_orphanAddr
The address of the orphaned device.
Mac16Address m_shortAddr
The short address allocated.
MlmeScanType m_scanType
Indicates the type of scan performed as described in IEEE 802.15.4-2011 (5.1.2.1).
uint32_t m_scanChannels
The channel numbers to be scanned.
uint8_t m_scanDuration
The factor (0-14) used to calculate the length of time to spend scanning.
uint32_t m_chPage
The channel page on which to perform scan.
MLME-START.request params.
uint8_t m_logCh
Logical channel on which to start using the new superframe configuration.
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
bool m_panCoor
On true this device will become coordinator.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
uint16_t m_PanId
Pan Identifier used by the device.