A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lr-wpan-mac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 The Boeing Company
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors:
7 * Gary Pei <guangyu.pei@boeing.com>
8 * kwong yin <kwong-sang.yin@boeing.com>
9 * Tom Henderson <thomas.r.henderson@boeing.com>
10 * Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
11 * Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
12 */
13
14#ifndef LR_WPAN_MAC_H
15#define LR_WPAN_MAC_H
16
17#include "lr-wpan-fields.h"
18#include "lr-wpan-mac-base.h"
19#include "lr-wpan-phy.h"
20
21#include <ns3/event-id.h>
22#include <ns3/sequence-number.h>
23#include <ns3/traced-callback.h>
24#include <ns3/traced-value.h>
25
26#include <deque>
27#include <memory>
28
29namespace ns3
30{
31class Packet;
32
33namespace lrwpan
34{
35
36class LrWpanCsmaCa;
37
38/**
39 * \defgroup lr-wpan LR-WPAN models
40 *
41 * This section documents the API of the IEEE 802.15.4-related models. For a generic functional
42 * description, please refer to the ns-3 manual.
43 */
44
45/**
46 * \ingroup lr-wpan
47 *
48 * Tx options
49 */
51{
52 TX_OPTION_NONE = 0, //!< TX_OPTION_NONE
53 TX_OPTION_ACK = 1, //!< TX_OPTION_ACK
54 TX_OPTION_GTS = 2, //!< TX_OPTION_GTS
55 TX_OPTION_INDIRECT = 4 //!< TX_OPTION_INDIRECT
56};
57
58/**
59 * \ingroup lr-wpan
60 *
61 * MAC states
62 */
64{
65 MAC_IDLE, //!< MAC_IDLE
66 MAC_CSMA, //!< MAC_CSMA
67 MAC_SENDING, //!< MAC_SENDING
68 MAC_ACK_PENDING, //!< MAC_ACK_PENDING
69 CHANNEL_ACCESS_FAILURE, //!< CHANNEL_ACCESS_FAILURE
70 CHANNEL_IDLE, //!< CHANNEL_IDLE
71 SET_PHY_TX_ON, //!< SET_PHY_TX_ON
72 MAC_GTS, //!< MAC_GTS
73 MAC_INACTIVE, //!< MAC_INACTIVE
74 MAC_CSMA_DEFERRED //!< MAC_CSMA_DEFERRED
75};
76
77/**
78 * Overloaded operator to print the value of a MacState.
79 *
80 * \param os The output stream
81 * \param state The text value of the PHY state
82 * \return The output stream with text value of the MAC state
83 */
84std::ostream& operator<<(std::ostream& os, const MacState& state);
85
86/**
87 * \ingroup lr-wpan
88 *
89 * Superframe status
90 */
92{
93 BEACON, //!< The Beacon transmission or reception Period
94 CAP, //!< Contention Access Period
95 CFP, //!< Contention Free Period
96 INACTIVE //!< Inactive Period or unslotted CSMA-CA
97};
98
99/**
100 * \ingroup lr-wpan
101 *
102 * Superframe type
103 */
105{
106 OUTGOING = 0, //!< Outgoing Superframe
107 INCOMING = 1 //!< Incoming Superframe
109
110/**
111 * \ingroup lr-wpan
112 *
113 * Indicates a pending MAC primitive
114 */
116{
117 MLME_NONE = 0, //!< No pending primitive
118 MLME_START_REQ = 1, //!< Pending MLME-START.request primitive
119 MLME_SCAN_REQ = 2, //!< Pending MLME-SCAN.request primitive
120 MLME_ASSOC_REQ = 3, //!< Pending MLME-ASSOCIATION.request primitive
121 MLME_SYNC_REQ = 4 //!< Pending MLME-SYNC.request primitive
123
124namespace TracedValueCallback
125{
126
127/**
128 * \ingroup lr-wpan
129 * TracedValue callback signature for MacState.
130 *
131 * \param [in] oldValue original value of the traced variable
132 * \param [in] newValue new value of the traced variable
133 */
134typedef void (*MacState)(MacState oldValue, MacState newValue);
135
136/**
137 * \ingroup lr-wpan
138 * TracedValue callback signature for SuperframeStatus.
139 *
140 * \param [in] oldValue original value of the traced variable
141 * \param [in] newValue new value of the traced variable
142 */
143typedef void (*SuperframeStatus)(SuperframeStatus oldValue, SuperframeStatus newValue);
144
145} // namespace TracedValueCallback
146
147/**
148 * \ingroup lr-wpan
149 *
150 * Class that implements the LR-WPAN MAC state machine
151 */
153{
154 public:
155 /**
156 * Get the type ID.
157 *
158 * \return the object TypeId
159 */
160 static TypeId GetTypeId();
161
162 /**
163 * Default constructor.
164 */
165 LrWpanMac();
166 ~LrWpanMac() override;
167
168 /**
169 * Check if the receiver will be enabled when the MAC is idle.
170 *
171 * \return true, if the receiver is enabled during idle periods, false otherwise
172 */
173 bool GetRxOnWhenIdle() const;
174
175 /**
176 * Set if the receiver should be enabled when the MAC is idle.
177 *
178 * \param rxOnWhenIdle set to true to enable the receiver during idle periods
179 */
180 void SetRxOnWhenIdle(bool rxOnWhenIdle);
181
182 // XXX these setters will become obsolete if we use the attribute system
183 /**
184 * Set the short address of this MAC.
185 *
186 * \param address the new address
187 */
188 void SetShortAddress(Mac16Address address);
189
190 /**
191 * Get the short address of this MAC.
192 *
193 * \return the short address
194 */
196
197 /**
198 * Set the extended address of this MAC.
199 *
200 * \param address the new address
201 */
202 void SetExtendedAddress(Mac64Address address);
203
204 /**
205 * Get the extended address of this MAC.
206 *
207 * \return the extended address
208 */
210
211 /**
212 * Set the PAN id used by this MAC.
213 *
214 * \param panId the new PAN id.
215 */
216 void SetPanId(uint16_t panId);
217
218 /**
219 * Get the PAN id used by this MAC.
220 *
221 * \return the PAN id.
222 */
223 uint16_t GetPanId() const;
224
225 /**
226 * Get the coordinator short address currently associated to this device.
227 *
228 * \return The coordinator short address
229 */
231
232 /**
233 * Get the coordinator extended address currently associated to this device.
234 *
235 * \return The coordinator extended address
236 */
238
239 void McpsDataRequest(McpsDataRequestParams params, Ptr<Packet> p) override;
240
241 void MlmeStartRequest(MlmeStartRequestParams params) override;
242
243 void MlmeScanRequest(MlmeScanRequestParams params) override;
244
246
248
249 void MlmeOrphanResponse(MlmeOrphanResponseParams params) override;
250
251 void MlmeSyncRequest(MlmeSyncRequestParams params) override;
252
253 void MlmePollRequest(MlmePollRequestParams params) override;
254
256
258
259 /**
260 * Set the CSMA/CA implementation to be used by the MAC.
261 *
262 * \param csmaCa the CSMA/CA implementation
263 */
264 void SetCsmaCa(Ptr<LrWpanCsmaCa> csmaCa);
265
266 /**
267 * Set the underlying PHY for the MAC.
268 *
269 * \param phy the PHY
270 */
271 void SetPhy(Ptr<LrWpanPhy> phy);
272
273 /**
274 * Get the underlying PHY of the MAC.
275 *
276 * \return the PHY
277 */
279
280 ////////////////////////////////////
281 // Interfaces between MAC and PHY //
282 ////////////////////////////////////
283
284 /**
285 * IEEE 802.15.4-2006 section 6.2.1.3
286 * PD-DATA.indication
287 * Indicates the transfer of an MPDU from PHY to MAC (receiving)
288 * \param psduLength number of bytes in the PSDU
289 * \param p the packet to be transmitted
290 * \param lqi Link quality (LQI) value measured during reception of the PPDU
291 */
292 void PdDataIndication(uint32_t psduLength, Ptr<Packet> p, uint8_t lqi);
293
294 /**
295 * IEEE 802.15.4-2006 section 6.2.1.2
296 * Confirm the end of transmission of an MPDU to MAC
297 * \param status to report to MAC
298 * PHY PD-DATA.confirm status
299 */
300 void PdDataConfirm(PhyEnumeration status);
301
302 /**
303 * IEEE 802.15.4-2006 section 6.2.2.2
304 * PLME-CCA.confirm status
305 * \param status TRX_OFF, BUSY or IDLE
306 */
307 void PlmeCcaConfirm(PhyEnumeration status);
308
309 /**
310 * IEEE 802.15.4-2006 section 6.2.2.4
311 * PLME-ED.confirm status and energy level
312 * \param status SUCCESS, TRX_OFF or TX_ON
313 * \param energyLevel 0x00-0xff ED level for the channel
314 */
315 void PlmeEdConfirm(PhyEnumeration status, uint8_t energyLevel);
316
317 /**
318 * IEEE 802.15.4-2006 section 6.2.2.6
319 * PLME-GET.confirm
320 * Get attributes per definition from Table 23 in section 6.4.2
321 * \param status SUCCESS or UNSUPPORTED_ATTRIBUTE
322 * \param id the attributed identifier
323 * \param attribute the attribute value
324 */
327 Ptr<PhyPibAttributes> attribute);
328
329 /**
330 * IEEE 802.15.4-2006 section 6.2.2.8
331 * PLME-SET-TRX-STATE.confirm
332 * Set PHY state
333 * \param status in RX_ON,TRX_OFF,FORCE_TRX_OFF,TX_ON
334 */
336
337 /**
338 * IEEE 802.15.4-2006 section 6.2.2.10
339 * PLME-SET.confirm
340 * Set attributes per definition from Table 23 in section 6.4.2
341 * \param status SUCCESS, UNSUPPORTED_ATTRIBUTE, INVALID_PARAMETER, or READ_ONLY
342 * \param id the attributed identifier
343 */
345
346 /**
347 * CSMA-CA algorithm calls back the MAC after executing channel assessment.
348 *
349 * \param macState indicate BUSY or IDLE channel condition
350 */
351 void SetLrWpanMacState(MacState macState);
352
353 /**
354 * Set the max size of the transmit queue.
355 *
356 * \param queueSize The transmit queue size.
357 */
359
360 /**
361 * Set the max size of the indirect transmit queue (Pending Transaction list)
362 *
363 * \param queueSize The indirect transmit queue size.
364 */
366
367 // MAC PIB attributes
368
369 /**
370 * The time that the device transmitted its last beacon frame.
371 * It also indicates the start of the Active Period in the Outgoing superframe.
372 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
373 */
375
376 /**
377 * The time that the device received its last bit of the beacon frame.
378 * It does not indicate the start of the Active Period in the Incoming superframe.
379 * Not explicitly listed by the standard but its use is implied.
380 * Its purpose is somehow similar to m_macBeaconTxTime
381 */
383
384 /**
385 * The maximum time, in multiples of aBaseSuperframeDuration, a device
386 * shall wait for a response command frame to be available following a
387 * request command frame.
388 */
390
391 /**
392 * The maximum wait time for an association response command after the reception
393 * of data request command ACK during the association process. Not explicitly
394 * listed by the standard but its use is required for a device to react to the lost
395 * of the association response (failure of the association: NO_DATA)
396 */
398
399 /**
400 * The short address of the coordinator through which the device is
401 * associated.
402 * 0xFFFF indicates this value is unknown.
403 * 0xFFFE indicates the coordinator is only using its extended address.
404 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
405 */
407
408 /**
409 * The extended address of the coordinator through which the device
410 * is associated.
411 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
412 */
414
415 /**
416 * Symbol boundary is same as m_macBeaconTxTime.
417 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
418 */
420
421 /**
422 * Used by a PAN coordinator or coordinator.
423 * Defines how often the coordinator transmits its beacon
424 * (outgoing superframe). Range 0 - 15 with 15 meaning no beacons are being sent.
425 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
426 */
428
429 /**
430 * Used by a PAN coordinator or coordinator. The length of the active portion
431 * of the outgoing superframe, including the beacon frame.
432 * 0 - 15 with 15 means the superframe will not be active after the beacon.
433 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
434 */
436
437 /**
438 * The maximum time (in UNIT periods) that a transaction is stored by a
439 * coordinator and indicated in its beacon. This value establish the expiration
440 * time of the packets stored in the pending transaction list (indirect transmissions).
441 * 1 Unit Period:
442 * Beacon-enabled = aBaseSuperframeDuration * 2^BO
443 * Non-beacon enabled = aBaseSuperframeDuration
444 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
445 */
447
448 /**
449 * The total size of the received beacon in symbols.
450 * Its value is used to calculate the end CAP time of the incoming superframe.
451 */
453
454 /**
455 * Indication of the Slot where the CAP portion of the OUTGOING Superframe ends.
456 */
458
459 /**
460 * The beaconOrder value of the INCOMING frame. Used by all devices that have a parent.
461 * Specification of how often the parent coordinator transmits its beacon.
462 * 0 - 15 with 15 means the parent is not currently transmitting beacons.
463 */
465
466 /**
467 * Used by all devices that have a parent.
468 * The length of the active portion of the INCOMING superframe, including the
469 * beacon frame.
470 * 0 - 15 with 15 meaning the superframe will not be active after the beacon.
471 */
473
474 /**
475 * Indication of the Slot where the CAP portion of the INCOMING Superframe ends.
476 */
478
479 /**
480 * Indicates if MAC sublayer is in receive all mode. True mean accept all
481 * frames from PHY.
482 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
483 */
485
486 /**
487 * 16 bits id of PAN on which this device is operating. 0xffff means not
488 * associated.
489 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
490 */
491 uint16_t m_macPanId;
492
493 /**
494 * Temporally stores the value of the current m_macPanId when a MLME-SCAN.request is performed.
495 * See IEEE 802.15.4-2011, section 5.1.2.1.2.
496 */
498
499 /**
500 * Sequence number added to transmitted data or MAC command frame, 00-ff.
501 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
502 */
504
505 /**
506 * Sequence number added to transmitted beacon frame, 00-ff.
507 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
508 */
510
511 /**
512 * The set with the contents of the beacon payload.
513 * This value is set directly by the MLME-SET primitive.
514 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
515 */
516 std::vector<uint8_t> m_macBeaconPayload;
517
518 /**
519 * The length, in octets, of the beacon payload.
520 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
521 */
523
524 /**
525 * The maximum number of retries allowed after a transmission failure.
526 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
527 */
529
530 /**
531 * Indication of whether the MAC sublayer is to enable its receiver during
532 * idle periods.
533 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
534 */
536
537 /**
538 * The minimum time forming a Long InterFrame Spacing (LIFS) period.
539 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
540 */
542
543 /**
544 * The minimum time forming a Short InterFrame Spacing (SIFS) period.
545 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
546 */
548
549 /**
550 * Indication of whether a coordinator is currently allowing association.
551 * A value of TRUE indicates that the association is permitted.
552 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
553 */
555
556 /**
557 * Indication of whether a device automatically sends data request command
558 * if its address is listed in the beacon frame.
559 * TRUE = request command automatically is sent. This command also affects
560 * the generation of MLME-BEACON-NOTIFY.indication (6.2.4.1)
561 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
562 */
564
565 /**
566 * The maximum energy level detected during ED scan on the current channel.
567 */
569
570 /**
571 * The value of the necessary InterFrame Space after the transmission of a packet.
572 */
574
575 /**
576 * Indication of whether the current device is the PAN coordinator
577 */
579
580 /**
581 * Indicates if the current device is a coordinator type
582 */
583 bool m_coor;
584
585 /**
586 * Indication of the Interval used by the coordinator to transmit beacon frames
587 * expressed in symbols.
588 */
590
591 /**
592 * Indication of the superframe duration in symbols.
593 * (e.g. 1 symbol = 4 bits in a 250kbps O-QPSK PHY)
594 */
596
597 /**
598 * Indication of the interval a node should receive a superframe
599 * expressed in symbols.
600 */
602
603 /**
604 * Indication of the superframe duration in symbols
605 * (e.g. 1 symbol = 4 bits in a 250kbps O-QPSK PHY)
606 */
608
609 /**
610 * Indication of current device capability (FFD or RFD)
611 */
613
614 /**
615 * Indication of whether the current device is tracking incoming beacons.
616 */
618
619 /**
620 * The number of consecutive loss beacons in a beacon tracking operation.
621 */
623
624 /**
625 * Get the macAckWaitDuration attribute value.
626 *
627 * \return the maximum number symbols to wait for an acknowledgment frame
628 */
629 uint64_t GetMacAckWaitDuration() const;
630
631 /**
632 * Get the macMaxFrameRetries attribute value.
633 *
634 * \return the maximum number of retries
635 */
636 uint8_t GetMacMaxFrameRetries() const;
637
638 /**
639 * Print the number of elements in the packet transmit queue.
640 */
642
643 /**
644 * Set the macMaxFrameRetries attribute value.
645 *
646 * \param retries the maximum number of retries
647 */
648 void SetMacMaxFrameRetries(uint8_t retries);
649
650 /**
651 * Check if the packet destination is its coordinator
652 *
653 * \return True if m_txPkt (packet awaiting to be sent) destination is its coordinator
654 */
655 bool IsCoordDest();
656
657 /**
658 * Check if the packet destination is its coordinator
659 *
660 * \param mac The coordinator short MAC Address
661 */
663
664 /**
665 * Check if the packet destination is its coordinator
666 *
667 * \param mac The coordinator extended MAC Address
668 */
670
671 /**
672 * Get the size of the Interframe Space according to MPDU size (m_txPkt).
673 *
674 * \return the IFS size in symbols
675 */
677
678 /**
679 * Obtain the number of symbols in the packet which is currently being sent by the MAC layer.
680 *
681 * \return packet number of symbols
682 */
683 uint64_t GetTxPacketSymbols();
684
685 /**
686 * Check if the packet to transmit requires acknowledgment
687 *
688 * \return True if the Tx packet requires acknowledgment
689 */
690 bool IsTxAckReq();
691
692 /**
693 * Print the Pending transaction list.
694 * \param os The reference to the output stream used by this print function.
695 */
696 void PrintPendingTxQueue(std::ostream& os) const;
697
698 /**
699 * Print the Transmit Queue.
700 * \param os The reference to the output stream used by this print function.
701 */
702 void PrintTxQueue(std::ostream& os) const;
703
704 /**
705 * Assign a fixed random variable stream number to the random variables
706 * used by this model. Return the number of streams that have been assigned.
707 *
708 * \param stream first stream index to use
709 * \return the number of stream indices assigned by this model
710 */
711 int64_t AssignStreams(int64_t stream);
712
713 /**
714 * TracedCallback signature for sent packets.
715 *
716 * \param [in] packet The packet.
717 * \param [in] retries The number of retries.
718 * \param [in] backoffs The number of CSMA backoffs.
719 */
720 typedef void (*SentTracedCallback)(Ptr<const Packet> packet, uint8_t retries, uint8_t backoffs);
721
722 /**
723 * TracedCallback signature for MacState change events.
724 *
725 * \param [in] oldValue The original state value.
726 * \param [in] newValue The new state value.
727 * \deprecated The MacState is now accessible as the
728 * TracedValue \c MacStateValue. The \c MacState TracedCallback will
729 * be removed in a future release.
730 */
731 // NS_DEPRECATED() - tag for future removal
732 typedef void (*StateTracedCallback)(MacState oldState, MacState newState);
733
734 protected:
735 // Inherited from Object.
736 void DoInitialize() override;
737 void DoDispose() override;
738
739 private:
740 /**
741 * Helper structure for managing transmission queue elements.
742 */
743 struct TxQueueElement : public SimpleRefCount<TxQueueElement>
744 {
745 uint8_t txQMsduHandle; //!< MSDU Handle
746 Ptr<Packet> txQPkt; //!< Queued packet
747 };
748
749 /**
750 * Helper structure for managing pending transaction list elements (Indirect transmissions).
751 */
752 struct IndTxQueueElement : public SimpleRefCount<IndTxQueueElement>
753 {
754 uint8_t seqNum; //!< The sequence number of the queued packet
755 Mac16Address dstShortAddress; //!< The destination short Mac Address
756 Mac64Address dstExtAddress; //!< The destination extended Mac Address
757 Ptr<Packet> txQPkt; //!< Queued packet.
758 Time expireTime; //!< The expiration time of the packet in the indirect transmission queue.
759 };
760
761 /**
762 * Called to send a single beacon frame.
763 */
764 void SendOneBeacon();
765
766 /**
767 * Called to send an associate request command.
768 */
770
771 /**
772 * Used to send a data request command (i.e. Request the coordinator to send the association
773 * response)
774 */
776
777 /**
778 * Called to send an associate response command.
779 *
780 * \param rxDataReqPkt The received data request pkt that instigated the Association response
781 * command.
782 */
783 void SendAssocResponseCommand(Ptr<Packet> rxDataReqPkt);
784
785 /**
786 * Called after m_assocRespCmdWaitTime timeout while waiting for an association response
787 * command.
788 */
790
791 /**
792 * Called to send a beacon request command.
793 */
795
796 /**
797 * Called to send a orphan notification command. This is used by an associated device that
798 * has lost synchronization with its coordinator.
799 * As described in IEEE 802.15.4-2011 (Section 5.3.6)
800 */
802
803 /**
804 * Called to end a MLME-START.request after changing the page and channel number.
805 */
806 void EndStartRequest();
807
808 /**
809 * Called at the end of the current channel scan (Active or Passive) for a given duration.
810 */
811 void EndChannelScan();
812
813 /**
814 * Called at the end of one ED channel scan.
815 */
817
818 /**
819 * Called to end an MLME-ASSOCIATE.request after changing the page and channel number.
820 */
821 void EndAssociateRequest();
822
823 /**
824 * Called to begin the Contention Free Period (CFP) in a
825 * beacon-enabled mode.
826 *
827 * \param superframeType The incoming or outgoing superframe reference
828 */
829 void StartCFP(SuperframeType superframeType);
830
831 /**
832 * Called to begin the Contention Access Period (CAP) in a
833 * beacon-enabled mode.
834 *
835 * \param superframeType The incoming or outgoing superframe reference
836 */
837 void StartCAP(SuperframeType superframeType);
838
839 /**
840 * Start the Inactive Period in a beacon-enabled mode.
841 *
842 * \param superframeType The incoming or outgoing superframe reference
843 *
844 */
845 void StartInactivePeriod(SuperframeType superframeType);
846
847 /**
848 * Called after the end of an INCOMING superframe to start the moment a
849 * device waits for a new incoming beacon.
850 */
851 void AwaitBeacon();
852
853 /**
854 * Called if the device is unable to locate a beacon in the time set by MLME-SYNC.request.
855 */
856 void BeaconSearchTimeout();
857
858 /**
859 * Used to process the reception of a beacon packet.
860 *
861 * \param lqi The value of the link quality indicator (LQI) of the received packet
862 * \param p The packet containing the MAC header and the beacon payload information
863 */
864 void ReceiveBeacon(uint8_t lqi, Ptr<Packet> p);
865
866 /**
867 * Send an acknowledgment packet for the given sequence number.
868 *
869 * \param seqno the sequence number for the ACK
870 */
871 void SendAck(uint8_t seqno);
872
873 /**
874 * Add an element to the transmission queue.
875 *
876 * \param txQElement The element added to the Tx Queue.
877 */
878 void EnqueueTxQElement(Ptr<TxQueueElement> txQElement);
879
880 /**
881 * Remove the tip of the transmission queue, including clean up related to the
882 * last packet transmission.
883 */
885
886 /**
887 * Change the current MAC state to the given new state.
888 *
889 * \param newState the new state
890 */
891 void ChangeMacState(MacState newState);
892
893 /**
894 * Handle an ACK timeout with a packet retransmission, if there are
895 * retransmission left, or a packet drop.
896 */
897 void AckWaitTimeout();
898
899 /**
900 * After a successful transmission of a frame (beacon, data) or an ack frame reception,
901 * the mac layer wait an Interframe Space (IFS) time and triggers this function
902 * to continue with the MAC flow.
903 *
904 * \param ifsTime IFS time
905 */
906 void IfsWaitTimeout(Time ifsTime);
907
908 /**
909 * Check for remaining retransmissions for the packet currently being sent.
910 * Drop the packet, if there are no retransmissions left.
911 *
912 * \return true, if the packet should be retransmitted, false otherwise.
913 */
915
916 /**
917 * Adds a packet to the pending transactions list (Indirect transmissions).
918 *
919 * \param p The packet added to pending transaction list.
920 */
921 void EnqueueInd(Ptr<Packet> p);
922
923 /**
924 * Extracts a packet from pending transactions list (Indirect transmissions).
925 * \param dst The extended address used an index to obtain an element from the pending
926 * transaction list.
927 * \param entry The dequeued element from the pending transaction list.
928 * \return The status of the dequeue
929 */
931
932 /**
933 * Purge expired transactions from the pending transactions list.
934 */
935 void PurgeInd();
936
937 /**
938 * Remove an element from the pending transaction list.
939 *
940 * \param p The packet to be removed from the pending transaction list.
941 */
943
944 /**
945 * Check the transmission queue. If there are packets in the transmission
946 * queue and the MAC is idle, pick the first one and initiate a packet
947 * transmission.
948 */
949 void CheckQueue();
950
951 /**
952 * Constructs a Superframe specification field from the local information,
953 * the superframe Specification field is necessary to create a beacon frame.
954 *
955 * \returns the Superframe specification field (bitmap)
956 */
957 uint16_t GetSuperframeField();
958
959 /**
960 * Constructs the Guaranteed Time Slots (GTS) Fields from local information.
961 * The GTS Fields are part of the beacon frame.
962 *
963 * \returns the Guaranteed Time Slots (GTS) Fields
964 */
966
967 /**
968 * Constructs Pending Address Fields from the local information,
969 * the Pending Address Fields are part of the beacon frame.
970 *
971 * \returns the Pending Address Fields
972 */
974
975 /**
976 * The trace source is fired at the end of any Interframe Space (IFS).
977 */
979
980 /**
981 * The trace source fired when packets are considered as successfully sent
982 * or the transmission has been given up.
983 * Only non-broadcast packets are traced.
984 *
985 * The data should represent:
986 * packet, number of retries, total number of csma backoffs
987 *
988 * \see class CallBackTraceSource
989 */
991
992 /**
993 * The trace source fired when packets come into the "top" of the device
994 * at the L3/L2 transition, when being queued for transmission.
995 *
996 * \see class CallBackTraceSource
997 */
999
1000 /**
1001 * The trace source fired when packets are dequeued from the
1002 * L3/l2 transmission queue.
1003 *
1004 * \see class CallBackTraceSource
1005 */
1007
1008 /**
1009 * The trace source fired when packets come into the "top" of the device
1010 * at the L3/L2 transition, when being queued for indirect transmission
1011 * (pending transaction list).
1012 * \see class CallBackTraceSource
1013 */
1015
1016 /**
1017 * The trace source fired when packets are dequeued from the
1018 * L3/l2 indirect transmission queue (Pending transaction list).
1019 *
1020 * \see class CallBackTraceSource
1021 */
1023
1024 /**
1025 * The trace source fired when packets are being sent down to L1.
1026 *
1027 * \see class CallBackTraceSource
1028 */
1030
1031 /**
1032 * The trace source fired when packets where successfully transmitted, that is
1033 * an acknowledgment was received, if requested, or the packet was
1034 * successfully sent by L1, if no ACK was requested.
1035 *
1036 * \see class CallBackTraceSource
1037 */
1039
1040 /**
1041 * The trace source fired when packets are dropped due to missing ACKs or
1042 * because of transmission failures in L1.
1043 *
1044 * \see class CallBackTraceSource
1045 */
1047
1048 /**
1049 * The trace source fired when packets are dropped due to indirect Tx queue
1050 * overflows or expiration.
1051 *
1052 * \see class CallBackTraceSource
1053 */
1055
1056 /**
1057 * The trace source fired for packets successfully received by the device
1058 * immediately before being forwarded up to higher layers (at the L2/L3
1059 * transition). This is a promiscuous trace.
1060 *
1061 * \see class CallBackTraceSource
1062 */
1064
1065 /**
1066 * The trace source fired for packets successfully received by the device
1067 * immediately before being forwarded up to higher layers (at the L2/L3
1068 * transition). This is a non-promiscuous trace.
1069 *
1070 * \see class CallBackTraceSource
1071 */
1073
1074 /**
1075 * The trace source fired for packets successfully received by the device
1076 * but dropped before being forwarded up to higher layers (at the L2/L3
1077 * transition).
1078 *
1079 * \see class CallBackTraceSource
1080 */
1082
1083 /**
1084 * A trace source that emulates a non-promiscuous protocol sniffer connected
1085 * to the device. Unlike your average everyday sniffer, this trace source
1086 * will not fire on PACKET_OTHERHOST events.
1087 *
1088 * On the transmit size, this trace hook will fire after a packet is dequeued
1089 * from the device queue for transmission. In Linux, for example, this would
1090 * correspond to the point just before a device hard_start_xmit where
1091 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
1092 * ETH_P_ALL handlers.
1093 *
1094 * On the receive side, this trace hook will fire when a packet is received,
1095 * just before the receive callback is executed. In Linux, for example,
1096 * this would correspond to the point at which the packet is dispatched to
1097 * packet sniffers in netif_receive_skb.
1098 *
1099 * \see class CallBackTraceSource
1100 */
1102
1103 /**
1104 * A trace source that emulates a promiscuous mode protocol sniffer connected
1105 * to the device. This trace source fire on packets destined for any host
1106 * just like your average everyday packet sniffer.
1107 *
1108 * On the transmit size, this trace hook will fire after a packet is dequeued
1109 * from the device queue for transmission. In Linux, for example, this would
1110 * correspond to the point just before a device hard_start_xmit where
1111 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
1112 * ETH_P_ALL handlers.
1113 *
1114 * On the receive side, this trace hook will fire when a packet is received,
1115 * just before the receive callback is executed. In Linux, for example,
1116 * this would correspond to the point at which the packet is dispatched to
1117 * packet sniffers in netif_receive_skb.
1118 *
1119 * \see class CallBackTraceSource
1120 */
1122
1123 /**
1124 * A trace source that fires when the MAC changes states.
1125 * Parameters are the old mac state and the new mac state.
1126 *
1127 * \deprecated This TracedCallback is deprecated and will be
1128 * removed in a future release, Instead, use the \c MacStateValue
1129 * TracedValue.
1130 */
1131 // NS_DEPRECATED() - tag for future removal
1133
1134 /**
1135 * The PHY associated with this MAC.
1136 */
1138
1139 /**
1140 * The CSMA/CA implementation used by this MAC.
1141 */
1143
1144 /**
1145 * The current state of the MAC layer.
1146 */
1148
1149 /**
1150 * The current period of the incoming superframe.
1151 */
1153
1154 /**
1155 * The current period of the outgoing superframe.
1156 */
1158
1159 /**
1160 * The packet which is currently being sent by the MAC layer.
1161 */
1163
1164 /**
1165 * The command request packet received. Briefly stored to proceed with operations
1166 * that take place after ACK messages.
1167 */
1169
1170 /**
1171 * The short address (16 bit address) used by this MAC. If supported,
1172 * the short address must be assigned to the device by the coordinator
1173 * during the association process.
1174 */
1176
1177 /**
1178 * The extended 64 address (IEEE EUI-64) used by this MAC.
1179 */
1181
1182 /**
1183 * The transmit queue used by the MAC.
1184 */
1185 std::deque<Ptr<TxQueueElement>> m_txQueue;
1186
1187 /**
1188 * The indirect transmit queue used by the MAC pending messages (The pending transaction
1189 * list).
1190 */
1191 std::deque<Ptr<IndTxQueueElement>> m_indTxQueue;
1192
1193 /**
1194 * The maximum size of the transmit queue.
1195 */
1197
1198 /**
1199 * The maximum size of the indirect transmit queue (The pending transaction list).
1200 */
1202
1203 /**
1204 * The list of PAN descriptors accumulated during channel scans, used to select a PAN to
1205 * associate.
1206 */
1207 std::vector<PanDescriptor> m_panDescriptorList;
1208
1209 /**
1210 * The list of energy measurements, one for each channel searched during an ED scan.
1211 */
1212 std::vector<uint8_t> m_energyDetectList;
1213
1214 /**
1215 * The list of unscanned channels during a scan operation.
1216 */
1217 std::vector<uint8_t> m_unscannedChannels;
1218
1219 /**
1220 * The parameters used during a MLME-SCAN.request. These parameters are stored here while
1221 * PLME-SET (set channel page, set channel number) and other operations take place.
1222 */
1224
1225 /**
1226 * The parameters used during a MLME-START.request. These parameters are stored here while
1227 * PLME-SET operations (set channel page, set channel number) take place.
1228 */
1230
1231 /**
1232 * The parameters used during a MLME-ASSOCIATE.request. These parameters are stored here while
1233 * PLME-SET operations (set channel page, set channel number) take place.
1234 */
1236
1237 /**
1238 * The channel list index used to obtain the current scanned channel.
1239 */
1241
1242 /**
1243 * Indicates the pending primitive when PLME.SET operation (page or channel switch) is called
1244 * from within another MLME primitive (e.g. Association, Scan, Sync, Start).
1245 */
1247
1248 /**
1249 * The number of already used retransmission for the currently transmitted
1250 * packet.
1251 */
1253
1254 /**
1255 * The number of CSMA/CA retries used for sending the current packet.
1256 */
1258
1259 /**
1260 * Keep track of the last received frame Link Quality Indicator
1261 */
1263
1264 /**
1265 * Scheduler event for the ACK timeout of the currently transmitted data
1266 * packet.
1267 */
1269
1270 /**
1271 * Scheduler event for a response to a request command frame.
1272 */
1274
1275 /**
1276 * Scheduler event for the lost of a association response command frame.
1277 */
1279
1280 /**
1281 * Scheduler event for a deferred MAC state change.
1282 */
1284
1285 /**
1286 * Scheduler event for Interframe spacing wait time.
1287 */
1289
1290 /**
1291 * Scheduler event for generation of one beacon.
1292 */
1294
1295 /**
1296 * Scheduler event for the end of the outgoing superframe CAP.
1297 **/
1299
1300 /**
1301 * Scheduler event for the end of the outgoing superframe CFP.
1302 */
1304
1305 /**
1306 * Scheduler event for the end of the incoming superframe CAP.
1307 **/
1309
1310 /**
1311 * Scheduler event for the end of the incoming superframe CFP.
1312 */
1314
1315 /**
1316 * Scheduler event to track the incoming beacons.
1317 */
1319
1320 /**
1321 * Scheduler event for the end of an ACTIVE or PASSIVE channel scan.
1322 */
1324
1325 /**
1326 * Scheduler event for the end of an ORPHAN channel scan.
1327 */
1329
1330 /**
1331 * Scheduler event for the end of a ED channel scan.
1332 */
1334
1335 /**
1336 * The uniform random variable used in this mac layer
1337 */
1339};
1340} // namespace lrwpan
1341} // namespace ns3
1342
1343#endif /* LR_WPAN_MAC_H */
An identifier for simulation events.
Definition event-id.h:45
This class can contain 16 bit addresses.
an EUI-64 address
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:48
Represent the GTS information fields.
Lr-wpan MAC layer abstraction.
Class that implements the LR-WPAN MAC state machine.
Ptr< Packet > m_rxPkt
The command request packet received.
TracedCallback< Ptr< const Packet > > m_macTxDequeueTrace
The trace source fired when packets are dequeued from the L3/l2 transmission queue.
void RemovePendTxQElement(Ptr< Packet > p)
Remove an element from the pending transaction list.
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but dropped before being forwa...
uint8_t m_deviceCapability
Indication of current device capability (FFD or RFD)
std::vector< uint8_t > m_macBeaconPayload
The set with the contents of the beacon payload.
void SetExtendedAddress(Mac64Address address)
Set the extended address of this MAC.
TracedCallback< Ptr< const Packet > > m_macIndTxDequeueTrace
The trace source fired when packets are dequeued from the L3/l2 indirect transmission queue (Pending ...
Ptr< LrWpanPhy > GetPhy()
Get the underlying PHY of the MAC.
uint32_t m_superframeDuration
Indication of the superframe duration in symbols.
void AwaitBeacon()
Called after the end of an INCOMING superframe to start the moment a device waits for a new incoming ...
void EndStartRequest()
Called to end a MLME-START.request after changing the page and channel number.
void MlmeAssociateResponse(MlmeAssociateResponseParams params) override
IEEE 802.15.4-2011, section 6.2.2.3 MLME-ASSOCIATE.response Primitive used to initiate a response to ...
bool m_macPromiscuousMode
Indicates if MAC sublayer is in receive all mode.
Ptr< LrWpanCsmaCa > m_csmaCa
The CSMA/CA implementation used by this MAC.
void SendAck(uint8_t seqno)
Send an acknowledgment packet for the given sequence number.
uint8_t m_numCsmacaRetry
The number of CSMA/CA retries used for sending the current packet.
Ptr< Packet > m_txPkt
The packet which is currently being sent by the MAC layer.
MlmeStartRequestParams m_startParams
The parameters used during a MLME-START.request.
void PurgeInd()
Purge expired transactions from the pending transactions list.
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaCa)
Set the CSMA/CA implementation to be used by the MAC.
EventId m_scanEvent
Scheduler event for the end of an ACTIVE or PASSIVE channel scan.
void PdDataConfirm(PhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.1.2 Confirm the end of transmission of an MPDU to MAC.
void SendOrphanNotificationCommand()
Called to send a orphan notification command.
Mac64Address m_macExtendedAddress
The extended 64 address (IEEE EUI-64) used by this MAC.
EventId m_scanEnergyEvent
Scheduler event for the end of a ED channel scan.
uint16_t m_macPanIdScan
Temporally stores the value of the current m_macPanId when a MLME-SCAN.request is performed.
EventId m_setMacState
Scheduler event for a deferred MAC state change.
uint32_t m_macBeaconPayloadLength
The length, in octets, of the beacon payload.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
TracedCallback< Ptr< const Packet >, uint8_t, uint8_t > m_sentPktTrace
The trace source fired when packets are considered as successfully sent or the transmission has been ...
uint64_t m_assocRespCmdWaitTime
The maximum wait time for an association response command after the reception of data request command...
GtsFields GetGtsFields()
Constructs the Guaranteed Time Slots (GTS) Fields from local information.
void SetIndTxQMaxSize(uint32_t queueSize)
Set the max size of the indirect transmit queue (Pending Transaction list)
std::deque< Ptr< IndTxQueueElement > > m_indTxQueue
The indirect transmit queue used by the MAC pending messages (The pending transaction list).
uint8_t m_incomingSuperframeOrder
Used by all devices that have a parent.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
uint32_t m_macLIFSPeriod
The minimum time forming a Long InterFrame Spacing (LIFS) period.
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
std::vector< uint8_t > m_unscannedChannels
The list of unscanned channels during a scan operation.
bool m_macRxOnWhenIdle
Indication of whether the MAC sublayer is to enable its receiver during idle periods.
uint64_t m_macSyncSymbolOffset
Symbol boundary is same as m_macBeaconTxTime.
void PrintTransmitQueueSize()
Print the number of elements in the packet transmit queue.
uint16_t m_channelScanIndex
The channel list index used to obtain the current scanned channel.
void SendAssocRequestCommand()
Called to send an associate request command.
EventId m_beaconEvent
Scheduler event for generation of one beacon.
void BeaconSearchTimeout()
Called if the device is unable to locate a beacon in the time set by MLME-SYNC.request.
uint32_t m_macSIFSPeriod
The minimum time forming a Short InterFrame Spacing (SIFS) period.
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets are being sent down to L1.
void MlmeSyncRequest(MlmeSyncRequestParams params) override
IEEE 802.15.4-2011, section 6.2.13.1 MLME-SYNC.request Request to synchronize with the coordinator by...
SequenceNumber8 m_macDsn
Sequence number added to transmitted data or MAC command frame, 00-ff.
void ChangeMacState(MacState newState)
Change the current MAC state to the given new state.
Mac16Address m_macCoordShortAddress
The short address of the coordinator through which the device is associated.
Mac64Address GetCoordExtAddress() const
Get the coordinator extended address currently associated to this device.
void MlmeGetRequest(MacPibAttributeIdentifier id) override
IEEE 802.15.4-2006, section 7.1.6.1 MLME-GET.request Request information about a given PIB attribute.
std::deque< Ptr< TxQueueElement > > m_txQueue
The transmit queue used by the MAC.
uint8_t m_macSuperframeOrder
Used by a PAN coordinator or coordinator.
TracedValue< SuperframeStatus > m_incSuperframeStatus
The current period of the incoming superframe.
void SetPanId(uint16_t panId)
Set the PAN id used by this MAC.
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...
MlmeScanRequestParams m_scanParams
The parameters used during a MLME-SCAN.request.
void SetLrWpanMacState(MacState macState)
CSMA-CA algorithm calls back the MAC after executing channel assessment.
void SetShortAddress(Mac16Address address)
Set the short address of this MAC.
uint8_t m_incomingBeaconOrder
The beaconOrder value of the INCOMING frame.
void PrintTxQueue(std::ostream &os) const
Print the Transmit Queue.
void CheckQueue()
Check the transmission queue.
uint32_t m_incomingSuperframeDuration
Indication of the superframe duration in symbols (e.g.
TracedCallback< Ptr< const Packet > > m_macIndTxEnqueueTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
The trace source fired when packets are dropped due to missing ACKs or because of transmission failur...
void SetMacMaxFrameRetries(uint8_t retries)
Set the macMaxFrameRetries attribute value.
uint16_t m_macTransactionPersistenceTime
The maximum time (in UNIT periods) that a transaction is stored by a coordinator and indicated in its...
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...
void AckWaitTimeout()
Handle an ACK timeout with a packet retransmission, if there are retransmission left,...
uint32_t m_maxTxQueueSize
The maximum size of the transmit queue.
TracedCallback< Ptr< const Packet > > m_macIndTxDropTrace
The trace source fired when packets are dropped due to indirect Tx queue overflows or expiration.
uint8_t m_retransmission
The number of already used retransmission for the currently transmitted packet.
LrWpanMac()
Default constructor.
EventId m_incCfpEvent
Scheduler event for the end of the incoming superframe CFP.
std::vector< uint8_t > m_energyDetectList
The list of energy measurements, one for each channel searched during an ED scan.
SequenceNumber8 m_macBsn
Sequence number added to transmitted beacon frame, 00-ff.
TracedCallback< MacState, MacState > m_macStateLogger
A trace source that fires when the MAC changes states.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
Mac64Address GetExtendedAddress() const
Get the extended address of this MAC.
void DoDispose() override
Destructor implementation.
uint8_t m_fnlCapSlot
Indication of the Slot where the CAP portion of the OUTGOING Superframe ends.
MlmeAssociateRequestParams m_associateParams
The parameters used during a MLME-ASSOCIATE.request.
uint32_t m_incomingBeaconInterval
Indication of the interval a node should receive a superframe expressed in symbols.
bool m_macAssociationPermit
Indication of whether a coordinator is currently allowing association.
static TypeId GetTypeId()
Get the type ID.
uint64_t GetMacAckWaitDuration() const
Get the macAckWaitDuration attribute value.
void SetTxQMaxSize(uint32_t queueSize)
Set the max size of the transmit queue.
TracedCallback< Time > m_macIfsEndTrace
The trace source is fired at the end of any Interframe Space (IFS).
void MlmeAssociateRequest(MlmeAssociateRequestParams params) override
IEEE 802.15.4-2011, section 6.2.2.1 MLME-ASSOCIATE.request Request primitive used by a device to requ...
bool GetRxOnWhenIdle() const
Check if the receiver will be enabled when the MAC is idle.
void ReceiveBeacon(uint8_t lqi, Ptr< Packet > p)
Used to process the reception of a beacon packet.
void EnqueueInd(Ptr< Packet > p)
Adds a packet to the pending transactions list (Indirect transmissions).
Time m_macBeaconTxTime
The time that the device transmitted its last beacon frame.
std::vector< PanDescriptor > m_panDescriptorList
The list of PAN descriptors accumulated during channel scans, used to select a PAN to associate.
uint8_t m_maxEnergyLevel
The maximum energy level detected during ED scan on the current channel.
Mac16Address GetShortAddress() const
Get the short address of this MAC.
bool m_macAutoRequest
Indication of whether a device automatically sends data request command if its address is listed in t...
PendingAddrFields GetPendingAddrFields()
Constructs Pending Address Fields from the local information, the Pending Address Fields are part of ...
uint64_t m_rxBeaconSymbols
The total size of the received beacon in symbols.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< LrWpanPhy > m_phy
The PHY associated with this MAC.
EventId m_cfpEvent
Scheduler event for the end of the outgoing superframe CFP.
uint16_t GetPanId() const
Get the PAN id used by this MAC.
TracedCallback< Ptr< const Packet > > m_macTxOkTrace
The trace source fired when packets where successfully transmitted, that is an acknowledgment was rec...
bool m_panCoor
Indication of whether the current device is the PAN coordinator.
void SendAssocResponseCommand(Ptr< Packet > rxDataReqPkt)
Called to send an associate response command.
Time m_macBeaconRxTime
The time that the device received its last bit of the beacon frame.
void SetAssociatedCoor(Mac16Address mac)
Check if the packet destination is its coordinator.
void StartCFP(SuperframeType superframeType)
Called to begin the Contention Free Period (CFP) in a beacon-enabled mode.
uint16_t m_macPanId
16 bits id of PAN on which this device is operating.
bool PrepareRetransmission()
Check for remaining retransmissions for the packet currently being sent.
void PrintPendingTxQueue(std::ostream &os) const
Print the Pending transaction list.
uint32_t m_ifs
The value of the necessary InterFrame Space after the transmission of a packet.
void MlmeSetRequest(MacPibAttributeIdentifier id, Ptr< MacPibAttributes > attribute) override
IEEE 802.15.4-2011, section 6.2.11.1 MLME-SET.request Attempts to write the given value to the indica...
bool m_beaconTrackingOn
Indication of whether the current device is tracking incoming beacons.
void SendBeaconRequestCommand()
Called to send a beacon request command.
uint32_t m_maxIndTxQueueSize
The maximum size of the indirect transmit queue (The pending transaction list).
void IfsWaitTimeout(Time ifsTime)
After a successful transmission of a frame (beacon, data) or an ack frame reception,...
EventId m_ifsEvent
Scheduler event for Interframe spacing wait time.
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...
Ptr< UniformRandomVariable > m_uniformVar
The uniform random variable used in this mac layer.
void PdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
IEEE 802.15.4-2006 section 6.2.1.3 PD-DATA.indication Indicates the transfer of an MPDU from PHY to M...
uint8_t m_macMaxFrameRetries
The maximum number of retries allowed after a transmission failure.
PendingPrimitiveStatus m_pendPrimitive
Indicates the pending primitive when PLME.SET operation (page or channel switch) is called from withi...
EventId m_respWaitTimeout
Scheduler event for a response to a request command frame.
uint16_t GetSuperframeField()
Constructs a Superframe specification field from the local information, the superframe Specification ...
bool IsCoordDest()
Check if the packet destination is its coordinator.
EventId m_ackWaitTimeout
Scheduler event for the ACK timeout of the currently transmitted data packet.
void StartCAP(SuperframeType superframeType)
Called to begin the Contention Access Period (CAP) in a beacon-enabled mode.
Mac64Address m_macCoordExtendedAddress
The extended address of the coordinator through which the device is associated.
void(* StateTracedCallback)(MacState oldState, MacState newState)
TracedCallback signature for MacState change events.
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.
void(* SentTracedCallback)(Ptr< const Packet > packet, uint8_t retries, uint8_t backoffs)
TracedCallback signature for sent packets.
EventId m_incCapEvent
Scheduler event for the end of the incoming superframe CAP.
Mac16Address GetCoordShortAddress() const
Get the coordinator short address currently associated to this device.
void SendDataRequestCommand()
Used to send a data request command (i.e.
bool DequeueInd(Mac64Address dst, Ptr< IndTxQueueElement > entry)
Extracts a packet from pending transactions list (Indirect transmissions).
EventId m_trackingEvent
Scheduler event to track the incoming beacons.
uint64_t GetTxPacketSymbols()
Obtain the number of symbols in the packet which is currently being sent by the MAC layer.
uint32_t m_beaconInterval
Indication of the Interval used by the coordinator to transmit beacon frames expressed in symbols.
Mac16Address m_shortAddress
The short address (16 bit address) used by this MAC.
EventId m_assocResCmdWaitTimeout
Scheduler event for the lost of a association response command frame.
void PlmeGetAttributeConfirm(PhyEnumeration status, PhyPibAttributeIdentifier id, Ptr< PhyPibAttributes > attribute)
IEEE 802.15.4-2006 section 6.2.2.6 PLME-GET.confirm Get attributes per definition from Table 23 in se...
uint8_t m_macBeaconOrder
Used by a PAN coordinator or coordinator.
void SetPhy(Ptr< LrWpanPhy > phy)
Set the underlying PHY for the MAC.
void MlmePollRequest(MlmePollRequestParams params) override
IEEE 802.15.4-2011, section 6.2.14.2 MLME-POLL.request Prompts the device to request data from the co...
void RemoveFirstTxQElement()
Remove the tip of the transmission queue, including clean up related to the last packet transmission.
TracedValue< SuperframeStatus > m_outSuperframeStatus
The current period of the outgoing superframe.
void SetRxOnWhenIdle(bool rxOnWhenIdle)
Set if the receiver should be enabled when the MAC is idle.
void PlmeCcaConfirm(PhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
void PlmeSetAttributeConfirm(PhyEnumeration status, PhyPibAttributeIdentifier id)
IEEE 802.15.4-2006 section 6.2.2.10 PLME-SET.confirm Set attributes per definition from Table 23 in s...
EventId m_scanOrphanEvent
Scheduler event for the end of an ORPHAN channel scan.
void StartInactivePeriod(SuperframeType superframeType)
Start the Inactive Period in a beacon-enabled mode.
uint32_t GetIfsSize()
Get the size of the Interframe Space according to MPDU size (m_txPkt).
EventId m_capEvent
Scheduler event for the end of the outgoing superframe CAP.
void PlmeSetTRXStateConfirm(PhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.8 PLME-SET-TRX-STATE.confirm Set PHY state.
TracedValue< MacState > m_macState
The current state of the MAC layer.
void EndChannelEnergyScan()
Called at the end of one ED channel scan.
uint8_t m_incomingFnlCapSlot
Indication of the Slot where the CAP portion of the INCOMING Superframe ends.
TracedCallback< Ptr< const Packet > > m_macTxEnqueueTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
uint8_t m_numLostBeacons
The number of consecutive loss beacons in a beacon tracking operation.
uint8_t GetMacMaxFrameRetries() const
Get the macMaxFrameRetries attribute value.
bool IsTxAckReq()
Check if the packet to transmit requires acknowledgment.
void SendOneBeacon()
Called to send a single beacon frame.
void EnqueueTxQElement(Ptr< TxQueueElement > txQElement)
Add an element to the transmission queue.
void LostAssocRespCommand()
Called after m_assocRespCmdWaitTime timeout while waiting for an association response command.
void PlmeEdConfirm(PhyEnumeration status, uint8_t energyLevel)
IEEE 802.15.4-2006 section 6.2.2.4 PLME-ED.confirm status and energy level.
bool m_coor
Indicates if the current device is a coordinator type.
uint8_t m_lastRxFrameLqi
Keep track of the last received frame Link Quality Indicator.
void EndChannelScan()
Called at the end of the current channel scan (Active or Passive) for a given duration.
void EndAssociateRequest()
Called to end an MLME-ASSOCIATE.request after changing the page and channel number.
uint64_t m_macResponseWaitTime
The maximum time, in multiples of aBaseSuperframeDuration, a device shall wait for a response command...
void DoInitialize() override
Initialize() implementation.
Represent the Pending Address Specification field.
MacPibAttributeIdentifier
IEEE 802.15.4-2006 PHY and MAC PIB Attribute Identifiers Table 23 and Table 86.
MacState
MAC states.
Definition lr-wpan-mac.h:64
SuperframeStatus
Superframe status.
Definition lr-wpan-mac.h:92
PendingPrimitiveStatus
Indicates a pending MAC primitive.
SuperframeType
Superframe type.
PhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
TxOption
Tx options.
Definition lr-wpan-mac.h:51
PhyPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
@ MAC_CSMA
MAC_CSMA.
Definition lr-wpan-mac.h:66
@ MAC_GTS
MAC_GTS.
Definition lr-wpan-mac.h:72
@ CHANNEL_ACCESS_FAILURE
CHANNEL_ACCESS_FAILURE.
Definition lr-wpan-mac.h:69
@ CHANNEL_IDLE
CHANNEL_IDLE.
Definition lr-wpan-mac.h:70
@ SET_PHY_TX_ON
SET_PHY_TX_ON.
Definition lr-wpan-mac.h:71
@ MAC_CSMA_DEFERRED
MAC_CSMA_DEFERRED.
Definition lr-wpan-mac.h:74
@ MAC_IDLE
MAC_IDLE.
Definition lr-wpan-mac.h:65
@ MAC_INACTIVE
MAC_INACTIVE.
Definition lr-wpan-mac.h:73
@ MAC_SENDING
MAC_SENDING.
Definition lr-wpan-mac.h:67
@ MAC_ACK_PENDING
MAC_ACK_PENDING.
Definition lr-wpan-mac.h:68
@ BEACON
The Beacon transmission or reception Period.
Definition lr-wpan-mac.h:93
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
Definition lr-wpan-mac.h:96
@ CAP
Contention Access Period.
Definition lr-wpan-mac.h:94
@ CFP
Contention Free Period.
Definition lr-wpan-mac.h:95
@ MLME_SCAN_REQ
Pending MLME-SCAN.request primitive.
@ MLME_NONE
No pending primitive.
@ MLME_START_REQ
Pending MLME-START.request primitive.
@ MLME_ASSOC_REQ
Pending MLME-ASSOCIATION.request primitive.
@ MLME_SYNC_REQ
Pending MLME-SYNC.request primitive.
@ INCOMING
Incoming Superframe.
@ OUTGOING
Outgoing Superframe.
@ TX_OPTION_NONE
TX_OPTION_NONE.
Definition lr-wpan-mac.h:52
@ TX_OPTION_GTS
TX_OPTION_GTS.
Definition lr-wpan-mac.h:54
@ TX_OPTION_ACK
TX_OPTION_ACK.
Definition lr-wpan-mac.h:53
@ TX_OPTION_INDIRECT
TX_OPTION_INDIRECT.
Definition lr-wpan-mac.h:55
std::ostream & operator<<(std::ostream &os, const SuperframeField &superframeField)
Stream insertion operator.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Helper structure for managing pending transaction list elements (Indirect transmissions).
uint8_t seqNum
The sequence number of the queued packet.
Mac64Address dstExtAddress
The destination extended Mac Address.
Mac16Address dstShortAddress
The destination short Mac Address.
Ptr< Packet > txQPkt
Queued packet.
Time expireTime
The expiration time of the packet in the indirect transmission queue.
Helper structure for managing transmission queue elements.
Ptr< Packet > txQPkt
Queued packet.
MLME-ASSOCIATE.request params.
MLME-ASSOCIATE.response params.
std::ofstream queueSize