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-mac-header.h"
20#include "lr-wpan-phy.h"
21
22#include "ns3/event-id.h"
23#include "ns3/sequence-number.h"
24#include "ns3/traced-callback.h"
25#include "ns3/traced-value.h"
26
27#include <deque>
28#include <memory>
29
30namespace ns3
31{
32class Packet;
33
34namespace lrwpan
35{
36
37class LrWpanCsmaCa;
38
39/**
40 * @defgroup lr-wpan LR-WPAN models
41 *
42 * This section documents the API of the IEEE 802.15.4-related models. For a generic functional
43 * description, please refer to the ns-3 manual.
44 */
45
46/**
47 * @ingroup lr-wpan
48 *
49 * Tx options
50 */
52{
53 TX_OPTION_NONE = 0, //!< TX_OPTION_NONE
54 TX_OPTION_ACK = 1, //!< TX_OPTION_ACK
55 TX_OPTION_GTS = 2, //!< TX_OPTION_GTS
56 TX_OPTION_INDIRECT = 4 //!< TX_OPTION_INDIRECT
57};
58
59/**
60 * @ingroup lr-wpan
61 *
62 * MAC states
63 */
65{
66 MAC_IDLE, //!< MAC_IDLE
67 MAC_CSMA, //!< MAC_CSMA
68 MAC_SENDING, //!< MAC_SENDING
69 MAC_ACK_PENDING, //!< MAC_ACK_PENDING
70 CHANNEL_ACCESS_FAILURE, //!< CHANNEL_ACCESS_FAILURE
71 CHANNEL_IDLE, //!< CHANNEL_IDLE
72 SET_PHY_TX_ON, //!< SET_PHY_TX_ON
73 MAC_GTS, //!< MAC_GTS
74 MAC_INACTIVE, //!< MAC_INACTIVE
75 MAC_CSMA_DEFERRED //!< MAC_CSMA_DEFERRED
76};
77
78/**
79 * Overloaded operator to print the value of a MacState.
80 *
81 * @param os The output stream
82 * @param state The text value of the PHY state
83 * @return The output stream with text value of the MAC state
84 */
85std::ostream& operator<<(std::ostream& os, const MacState& state);
86
87/**
88 * @ingroup lr-wpan
89 *
90 * Superframe status
91 */
93{
94 BEACON, //!< The Beacon transmission or reception Period
95 CAP, //!< Contention Access Period
96 CFP, //!< Contention Free Period
97 INACTIVE //!< Inactive Period or unslotted CSMA-CA
98};
99
100/**
101 * @ingroup lr-wpan
102 *
103 * Superframe type
104 */
106{
107 OUTGOING = 0, //!< Outgoing Superframe
108 INCOMING = 1 //!< Incoming Superframe
110
111/**
112 * @ingroup lr-wpan
113 *
114 * Indicates a pending MAC primitive
115 */
117{
118 MLME_NONE = 0, //!< No pending primitive
119 MLME_START_REQ = 1, //!< Pending MLME-START.request primitive
120 MLME_SCAN_REQ = 2, //!< Pending MLME-SCAN.request primitive
121 MLME_ASSOC_REQ = 3, //!< Pending MLME-ASSOCIATION.request primitive
122 MLME_SYNC_REQ = 4 //!< Pending MLME-SYNC.request primitive
124
125namespace TracedValueCallback
126{
127
128/**
129 * @ingroup lr-wpan
130 * TracedValue callback signature for MacState.
131 *
132 * @param [in] oldValue original value of the traced variable
133 * @param [in] newValue new value of the traced variable
134 */
135typedef void (*MacState)(MacState oldValue, MacState newValue);
136
137/**
138 * @ingroup lr-wpan
139 * TracedValue callback signature for SuperframeStatus.
140 *
141 * @param [in] oldValue original value of the traced variable
142 * @param [in] newValue new value of the traced variable
143 */
144typedef void (*SuperframeStatus)(SuperframeStatus oldValue, SuperframeStatus newValue);
145
146} // namespace TracedValueCallback
147
148/**
149 * @ingroup lr-wpan
150 *
151 * Class that implements the LR-WPAN MAC state machine
152 */
154{
155 public:
156 /**
157 * Get the type ID.
158 *
159 * @return the object TypeId
160 */
161 static TypeId GetTypeId();
162
163 /**
164 * Default constructor.
165 */
166 LrWpanMac();
167 ~LrWpanMac() override;
168
169 /**
170 * Check if the receiver will be enabled when the MAC is idle.
171 *
172 * @return true, if the receiver is enabled during idle periods, false otherwise
173 */
174 bool GetRxOnWhenIdle() const;
175
176 /**
177 * Set if the receiver should be enabled when the MAC is idle.
178 *
179 * @param rxOnWhenIdle set to true to enable the receiver during idle periods
180 */
181 void SetRxOnWhenIdle(bool rxOnWhenIdle);
182
183 // XXX these setters will become obsolete if we use the attribute system
184 /**
185 * Set the short address of this MAC.
186 *
187 * @param address the new address
188 */
189 void SetShortAddress(Mac16Address address);
190
191 /**
192 * Get the short address of this MAC.
193 *
194 * @return the short address
195 */
197
198 /**
199 * Set the extended address of this MAC.
200 *
201 * @param address the new address
202 */
203 void SetExtendedAddress(Mac64Address address);
204
205 /**
206 * Get the extended address of this MAC.
207 *
208 * @return the extended address
209 */
211
212 /**
213 * Set the PAN id used by this MAC.
214 *
215 * @param panId the new PAN id.
216 */
217 void SetPanId(uint16_t panId);
218
219 /**
220 * Get the PAN id used by this MAC.
221 *
222 * @return the PAN id.
223 */
224 uint16_t GetPanId() const;
225
226 /**
227 * Get the coordinator short address currently associated to this device.
228 *
229 * @return The coordinator short address
230 */
232
233 /**
234 * Get the coordinator extended address currently associated to this device.
235 *
236 * @return The coordinator extended address
237 */
239
240 void McpsDataRequest(McpsDataRequestParams params, Ptr<Packet> p) override;
241
242 void MlmeStartRequest(MlmeStartRequestParams params) override;
243
244 void MlmeScanRequest(MlmeScanRequestParams params) override;
245
247
249
250 void MlmeOrphanResponse(MlmeOrphanResponseParams params) override;
251
252 void MlmeSyncRequest(MlmeSyncRequestParams params) override;
253
254 void MlmePollRequest(MlmePollRequestParams params) override;
255
257
259
260 /**
261 * Set the CSMA/CA implementation to be used by the MAC.
262 *
263 * @param csmaCa the CSMA/CA implementation
264 */
265 void SetCsmaCa(Ptr<LrWpanCsmaCa> csmaCa);
266
267 /**
268 * Set the underlying PHY for the MAC.
269 *
270 * @param phy the PHY
271 */
272 void SetPhy(Ptr<LrWpanPhy> phy);
273
274 /**
275 * Get the underlying PHY of the MAC.
276 *
277 * @return the PHY
278 */
280
281 ////////////////////////////////////
282 // Interfaces between MAC and PHY //
283 ////////////////////////////////////
284
285 /**
286 * IEEE 802.15.4-2006 section 6.2.1.3
287 * PD-DATA.indication
288 * Indicates the transfer of an MPDU from PHY to MAC (receiving)
289 * @param psduLength number of bytes in the PSDU
290 * @param p the packet to be transmitted
291 * @param lqi Link quality (LQI) value measured during reception of the PPDU
292 */
293 void PdDataIndication(uint32_t psduLength, Ptr<Packet> p, uint8_t lqi);
294
295 /**
296 * IEEE 802.15.4-2006 section 6.2.1.2
297 * Confirm the end of transmission of an MPDU to MAC
298 * @param status to report to MAC
299 * PHY PD-DATA.confirm status
300 */
301 void PdDataConfirm(PhyEnumeration status);
302
303 /**
304 * IEEE 802.15.4-2006 section 6.2.2.2
305 * PLME-CCA.confirm status
306 * @param status TRX_OFF, BUSY or IDLE
307 */
308 void PlmeCcaConfirm(PhyEnumeration status);
309
310 /**
311 * IEEE 802.15.4-2006 section 6.2.2.4
312 * PLME-ED.confirm status and energy level
313 * @param status SUCCESS, TRX_OFF or TX_ON
314 * @param energyLevel 0x00-0xff ED level for the channel
315 */
316 void PlmeEdConfirm(PhyEnumeration status, uint8_t energyLevel);
317
318 /**
319 * IEEE 802.15.4-2006 section 6.2.2.6
320 * PLME-GET.confirm
321 * Get attributes per definition from Table 23 in section 6.4.2
322 * @param status SUCCESS or UNSUPPORTED_ATTRIBUTE
323 * @param id the attributed identifier
324 * @param attribute the attribute value
325 */
328 Ptr<PhyPibAttributes> attribute);
329
330 /**
331 * IEEE 802.15.4-2006 section 6.2.2.8
332 * PLME-SET-TRX-STATE.confirm
333 * Set PHY state
334 * @param status in RX_ON,TRX_OFF,FORCE_TRX_OFF,TX_ON
335 */
337
338 /**
339 * IEEE 802.15.4-2006 section 6.2.2.10
340 * PLME-SET.confirm
341 * Set attributes per definition from Table 23 in section 6.4.2
342 * @param status SUCCESS, UNSUPPORTED_ATTRIBUTE, INVALID_PARAMETER, or READ_ONLY
343 * @param id the attributed identifier
344 */
346
347 /**
348 * CSMA-CA algorithm calls back the MAC after executing channel assessment.
349 *
350 * @param macState indicate BUSY or IDLE channel condition
351 */
352 void SetLrWpanMacState(MacState macState);
353
354 /**
355 * Set the max size of the transmit queue.
356 *
357 * @param queueSize The transmit queue size.
358 */
360
361 /**
362 * Set the max size of the indirect transmit queue (Pending Transaction list)
363 *
364 * @param queueSize The indirect transmit queue size.
365 */
367
368 // MAC PIB attributes
369
370 /**
371 * The time that the device transmitted its last beacon frame.
372 * It also indicates the start of the Active Period in the Outgoing superframe.
373 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
374 */
376
377 /**
378 * The time that the device received its last bit of the beacon frame.
379 * It does not indicate the start of the Active Period in the Incoming superframe.
380 * Not explicitly listed by the standard but its use is implied.
381 * Its purpose is somehow similar to m_macBeaconTxTime
382 */
384
385 /**
386 * The maximum time, in multiples of aBaseSuperframeDuration, a device
387 * shall wait for a response command frame to be available following a
388 * request command frame.
389 */
391
392 /**
393 * The maximum wait time for an association response command after the reception
394 * of data request command ACK during the association process. Not explicitly
395 * listed by the standard but its use is required for a device to react to the lost
396 * of the association response (failure of the association: NO_DATA)
397 */
399
400 /**
401 * The short address of the coordinator through which the device is
402 * associated.
403 * 0xFFFF indicates this value is unknown.
404 * 0xFFFE indicates the coordinator is only using its extended address.
405 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
406 */
408
409 /**
410 * The extended address of the coordinator through which the device
411 * is associated.
412 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
413 */
415
416 /**
417 * Symbol boundary is same as m_macBeaconTxTime.
418 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
419 */
421
422 /**
423 * Used by a PAN coordinator or coordinator.
424 * Defines how often the coordinator transmits its beacon
425 * (outgoing superframe). Range 0 - 15 with 15 meaning no beacons are being sent.
426 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
427 */
429
430 /**
431 * Used by a PAN coordinator or coordinator. The length of the active portion
432 * of the outgoing superframe, including the beacon frame.
433 * 0 - 15 with 15 means the superframe will not be active after the beacon.
434 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
435 */
437
438 /**
439 * The maximum time (in UNIT periods) that a transaction is stored by a
440 * coordinator and indicated in its beacon. This value establish the expiration
441 * time of the packets stored in the pending transaction list (indirect transmissions).
442 * 1 Unit Period:
443 * Beacon-enabled = aBaseSuperframeDuration * 2^BO
444 * Non-beacon enabled = aBaseSuperframeDuration
445 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
446 */
448
449 /**
450 * The total size of the received beacon in symbols.
451 * Its value is used to calculate the end CAP time of the incoming superframe.
452 */
454
455 /**
456 * Indication of the Slot where the CAP portion of the OUTGOING Superframe ends.
457 */
459
460 /**
461 * The beaconOrder value of the INCOMING frame. Used by all devices that have a parent.
462 * Specification of how often the parent coordinator transmits its beacon.
463 * 0 - 15 with 15 means the parent is not currently transmitting beacons.
464 */
466
467 /**
468 * Used by all devices that have a parent.
469 * The length of the active portion of the INCOMING superframe, including the
470 * beacon frame.
471 * 0 - 15 with 15 meaning the superframe will not be active after the beacon.
472 */
474
475 /**
476 * Indication of the Slot where the CAP portion of the INCOMING Superframe ends.
477 */
479
480 /**
481 * Indicates if MAC sublayer is in receive all mode. True mean accept all
482 * frames from PHY.
483 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
484 */
486
487 /**
488 * 16 bits id of PAN on which this device is operating. 0xffff means not
489 * associated.
490 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
491 */
492 uint16_t m_macPanId;
493
494 /**
495 * Temporarily stores the value of the current m_macPanId when a MLME-SCAN.request is performed.
496 * See IEEE 802.15.4-2011, section 5.1.2.1.2.
497 */
499
500 /**
501 * Sequence number added to transmitted data or MAC command frame, 00-ff.
502 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
503 */
505
506 /**
507 * Sequence number added to transmitted beacon frame, 00-ff.
508 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
509 */
511
512 /**
513 * The set with the contents of the beacon payload.
514 * This value is set directly by the MLME-SET primitive.
515 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
516 */
517 std::vector<uint8_t> m_macBeaconPayload;
518
519 /**
520 * The length, in octets, of the beacon payload.
521 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
522 */
524
525 /**
526 * The maximum number of retries allowed after a transmission failure.
527 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
528 */
530
531 /**
532 * Indication of whether the MAC sublayer is to enable its receiver during
533 * idle periods.
534 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
535 */
537
538 /**
539 * The minimum time forming a Long InterFrame Spacing (LIFS) period.
540 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
541 */
543
544 /**
545 * The minimum time forming a Short InterFrame Spacing (SIFS) period.
546 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
547 */
549
550 /**
551 * Indication of whether a coordinator is currently allowing association.
552 * A value of TRUE indicates that the association is permitted.
553 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
554 */
556
557 /**
558 * Indication of whether a device automatically sends data request command
559 * if its address is listed in the beacon frame.
560 * TRUE = request command automatically is sent. This command also affects
561 * the generation of MLME-BEACON-NOTIFY.indication (6.2.4.1)
562 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
563 */
565
566 /**
567 * The maximum energy level detected during ED scan on the current channel.
568 */
570
571 /**
572 * The value of the necessary InterFrame Space after the transmission of a packet.
573 */
575
576 /**
577 * Indication of whether the current device is the PAN coordinator
578 */
580
581 /**
582 * Indicates if the current device is a coordinator type
583 */
584 bool m_coor;
585
586 /**
587 * Indication of the Interval used by the coordinator to transmit beacon frames
588 * expressed in symbols.
589 */
591
592 /**
593 * Indication of the superframe duration in symbols.
594 * (e.g. 1 symbol = 4 bits in a 250kbps O-QPSK PHY)
595 */
597
598 /**
599 * Indication of the interval a node should receive a superframe
600 * expressed in symbols.
601 */
603
604 /**
605 * Indication of the superframe duration in symbols
606 * (e.g. 1 symbol = 4 bits in a 250kbps O-QPSK PHY)
607 */
609
610 /**
611 * Indication of current device capability (FFD or RFD)
612 */
614
615 /**
616 * Indication of whether the current device is tracking incoming beacons.
617 */
619
620 /**
621 * The number of consecutive loss beacons in a beacon tracking operation.
622 */
624
625 /**
626 * Get the macAckWaitDuration attribute value.
627 *
628 * @return the maximum number symbols to wait for an acknowledgment frame
629 */
630 uint64_t GetMacAckWaitDuration() const;
631
632 /**
633 * Get the macMaxFrameRetries attribute value.
634 *
635 * @return the maximum number of retries
636 */
637 uint8_t GetMacMaxFrameRetries() const;
638
639 /**
640 * Print the number of elements in the packet transmit queue.
641 */
643
644 /**
645 * Set the macMaxFrameRetries attribute value.
646 *
647 * @param retries the maximum number of retries
648 */
649 void SetMacMaxFrameRetries(uint8_t retries);
650
651 /**
652 * Check if the packet destination is its coordinator
653 *
654 * @return True if m_txPkt (packet awaiting to be sent) destination is its coordinator
655 */
656 bool IsCoordDest();
657
658 /**
659 * Check if the packet destination is its coordinator
660 *
661 * @param mac The coordinator short MAC Address
662 */
664
665 /**
666 * Check if the packet destination is its coordinator
667 *
668 * @param mac The coordinator extended MAC Address
669 */
671
672 /**
673 * Get the size of the Interframe Space according to MPDU size (m_txPkt).
674 *
675 * @return the IFS size in symbols
676 */
678
679 /**
680 * Obtain the number of symbols in the packet which is currently being sent by the MAC layer.
681 *
682 * @return packet number of symbols
683 */
684 uint64_t GetTxPacketSymbols();
685
686 /**
687 * Check if the packet to transmit requires acknowledgment
688 *
689 * @return True if the Tx packet requires acknowledgment
690 */
691 bool IsTxAckReq();
692
693 /**
694 * Print the Pending transaction list.
695 * @param os The reference to the output stream used by this print function.
696 */
697 void PrintPendingTxQueue(std::ostream& os) const;
698
699 /**
700 * Print the Transmit Queue.
701 * @param os The reference to the output stream used by this print function.
702 */
703 void PrintTxQueue(std::ostream& os) const;
704
705 /**
706 * Assign a fixed random variable stream number to the random variables
707 * used by this model. Return the number of streams that have been assigned.
708 *
709 * @param stream first stream index to use
710 * @return the number of stream indices assigned by this model
711 */
712 int64_t AssignStreams(int64_t stream);
713
714 /**
715 * TracedCallback signature for sent packets.
716 *
717 * @param [in] packet The packet.
718 * @param [in] retries The number of retries.
719 * @param [in] backoffs The number of CSMA backoffs.
720 */
721 typedef void (*SentTracedCallback)(Ptr<const Packet> packet, uint8_t retries, uint8_t backoffs);
722
723 /**
724 * TracedCallback signature for MacState change events.
725 *
726 * @param [in] oldValue The original state value.
727 * @param [in] newValue The new state value.
728 * @deprecated The MacState is now accessible as the
729 * TracedValue \c MacStateValue. The \c MacState TracedCallback will
730 * be removed in a future release.
731 */
732 // NS_DEPRECATED() - tag for future removal
733 typedef void (*StateTracedCallback)(MacState oldState, MacState newState);
734
735 protected:
736 // Inherited from Object.
737 void DoInitialize() override;
738 void DoDispose() override;
739
740 private:
741 /**
742 * Helper structure for managing transmission queue elements.
743 */
744 struct TxQueueElement : public SimpleRefCount<TxQueueElement>
745 {
746 uint8_t txQMsduHandle; //!< MSDU Handle
747 Ptr<Packet> txQPkt; //!< Queued packet
748 };
749
750 /**
751 * Helper structure for managing pending transaction list elements (Indirect transmissions).
752 */
753 struct IndTxQueueElement : public SimpleRefCount<IndTxQueueElement>
754 {
755 uint8_t seqNum; //!< The sequence number of the queued packet
756 Mac16Address dstShortAddress; //!< The destination short Mac Address
757 Mac64Address dstExtAddress; //!< The destination extended Mac Address
758 Ptr<Packet> txQPkt; //!< Queued packet.
759 Time expireTime; //!< The expiration time of the packet in the indirect transmission queue.
760 };
761
762 /**
763 * Process a frame when promiscuous mode is active.
764 *
765 * @param lqi The LQI value of the received packet
766 * @param receivedMacHdr The reference to the received MAC header
767 * @param p The packet containing the MAC payload
768 */
769 void ReceiveInPromiscuousMode(uint8_t lqi,
770 const LrWpanMacHeader& receivedMacHdr,
771 Ptr<Packet> p);
772
773 /**
774 * Called to send a single beacon frame.
775 */
776 void SendOneBeacon();
777
778 /**
779 * Called to send an associate request command.
780 */
782
783 /**
784 * Used to send a data request command (i.e. Request the coordinator to send the association
785 * response)
786 */
788
789 /**
790 * Called to send an associate response command.
791 *
792 * @param rxDataReqPkt The received data request pkt that instigated the Association response
793 * command.
794 */
795 void SendAssocResponseCommand(Ptr<Packet> rxDataReqPkt);
796
797 /**
798 * Called after m_assocRespCmdWaitTime timeout while waiting for an association response
799 * command.
800 */
802
803 /**
804 * Called to send a beacon request command.
805 */
807
808 /**
809 * Called to send a orphan notification command. This is used by an associated device that
810 * has lost synchronization with its coordinator.
811 * As described in IEEE 802.15.4-2011 (Section 5.3.6)
812 */
814
815 /**
816 * Called to end a MLME-START.request after changing the page and channel number.
817 */
818 void EndStartRequest();
819
820 /**
821 * Called at the end of the current channel scan (Active or Passive) for a given duration.
822 */
823 void EndChannelScan();
824
825 /**
826 * Called at the end of one ED channel scan.
827 */
829
830 /**
831 * Called to end an MLME-ASSOCIATE.request after changing the page and channel number.
832 */
833 void EndAssociateRequest();
834
835 /**
836 * Called to begin the Contention Free Period (CFP) in a
837 * beacon-enabled mode.
838 *
839 * @param superframeType The incoming or outgoing superframe reference
840 */
841 void StartCFP(SuperframeType superframeType);
842
843 /**
844 * Called to begin the Contention Access Period (CAP) in a
845 * beacon-enabled mode.
846 *
847 * @param superframeType The incoming or outgoing superframe reference
848 */
849 void StartCAP(SuperframeType superframeType);
850
851 /**
852 * Start the Inactive Period in a beacon-enabled mode.
853 *
854 * @param superframeType The incoming or outgoing superframe reference
855 *
856 */
857 void StartInactivePeriod(SuperframeType superframeType);
858
859 /**
860 * Called after the end of an INCOMING superframe to start the moment a
861 * device waits for a new incoming beacon.
862 */
863 void AwaitBeacon();
864
865 /**
866 * Called if the device is unable to locate a beacon in the time set by MLME-SYNC.request.
867 */
868 void BeaconSearchTimeout();
869
870 /**
871 * Used to process the reception of a beacon packet.
872 *
873 * @param lqi The value of the link quality indicator (LQI) of the received packet.
874 * @param receivedMacHdr The reference to the received MAC header.
875 * @param p The packet containing the beacon payload information.
876 */
877 void ReceiveBeacon(uint8_t lqi, const LrWpanMacHeader& receivedMacHdr, Ptr<Packet> p);
878
879 /**
880 * Used to process the reception of a command packet.
881 *
882 * @param lqi The value of the link quality indicator (LQI) of the received packet.
883 * @param receivedMacHdr The reference to the received MAC header.
884 * @param p The packet containing the command payload information.
885 */
886 void ReceiveCommand(uint8_t lqi, const LrWpanMacHeader& receivedMacHdr, Ptr<Packet> p);
887
888 /**
889 * Used to process the reception of data.
890 *
891 * @param lqi The value of the link quality indicator (LQI) of the received packet.
892 * @param receivedMacHdr The reference to the received MAC header.
893 * @param p The packet containing the data payload.
894 */
895 void ReceiveData(uint8_t lqi, const LrWpanMacHeader& receivedMacHdr, Ptr<Packet> p);
896
897 /**
898 * Used to process an acknowledgment packet.
899 *
900 * @param receivedMacHdr The reference to the received MAC header.
901 * @param p The packet containing the MAC header and the data payload.
902 */
903 void ReceiveAcknowledgment(const LrWpanMacHeader& receivedMacHdr, Ptr<Packet> p);
904
905 /**
906 * Display the MAC header contents of a successfully received packet when
907 * logs are active.
908 *
909 * @param receivedMacHdr The reference of the received MAC header
910 */
911 void PrintReceivedPacket(const LrWpanMacHeader& receivedMacHdr);
912
913 /**
914 * Send an acknowledgment packet for the given sequence number.
915 *
916 * @param seqno the sequence number for the ACK
917 */
918 void SendAck(uint8_t seqno);
919
920 /**
921 * Add an element to the transmission queue.
922 *
923 * @param txQElement The element added to the Tx Queue.
924 */
925 void EnqueueTxQElement(Ptr<TxQueueElement> txQElement);
926
927 /**
928 * Remove the tip of the transmission queue, including clean up related to the
929 * last packet transmission.
930 */
932
933 /**
934 * Change the current MAC state to the given new state.
935 *
936 * @param newState the new state
937 */
938 void ChangeMacState(MacState newState);
939
940 /**
941 * Handle an ACK timeout with a packet retransmission, if there are
942 * retransmission left, or a packet drop.
943 */
944 void AckWaitTimeout();
945
946 /**
947 * After a successful transmission of a frame (beacon, data) or an ack frame reception,
948 * the mac layer wait an Interframe Space (IFS) time and triggers this function
949 * to continue with the MAC flow.
950 *
951 * @param ifsTime IFS time
952 */
953 void IfsWaitTimeout(Time ifsTime);
954
955 /**
956 * Check for remaining retransmissions for the packet currently being sent.
957 * Drop the packet, if there are no retransmissions left.
958 *
959 * @return true, if the packet should be retransmitted, false otherwise.
960 */
962
963 /**
964 * Adds a packet to the pending transactions list (Indirect transmissions).
965 *
966 * @param p The packet added to pending transaction list.
967 */
968 void EnqueueInd(Ptr<Packet> p);
969
970 /**
971 * Extracts a packet from pending transactions list (Indirect transmissions).
972 * @param dst The extended address used an index to obtain an element from the pending
973 * transaction list.
974 * @param entry The dequeued element from the pending transaction list.
975 * @return The status of the dequeue
976 */
978
979 /**
980 * Purge expired transactions from the pending transactions list.
981 */
982 void PurgeInd();
983
984 /**
985 * Remove an element from the pending transaction list.
986 *
987 * @param p The packet to be removed from the pending transaction list.
988 */
990
991 /**
992 * Check the transmission queue. If there are packets in the transmission
993 * queue and the MAC is idle, pick the first one and initiate a packet
994 * transmission.
995 */
996 void CheckQueue();
997
998 /**
999 * Constructs a Superframe specification field from the local information,
1000 * the superframe Specification field is necessary to create a beacon frame.
1001 *
1002 * @returns the Superframe specification field (bitmap)
1003 */
1004 uint16_t GetSuperframeField();
1005
1006 /**
1007 * Constructs the Guaranteed Time Slots (GTS) Fields from local information.
1008 * The GTS Fields are part of the beacon frame.
1009 *
1010 * @returns the Guaranteed Time Slots (GTS) Fields
1011 */
1013
1014 /**
1015 * Constructs Pending Address Fields from the local information,
1016 * the Pending Address Fields are part of the beacon frame.
1017 *
1018 * @returns the Pending Address Fields
1019 */
1021
1022 /**
1023 * The trace source is fired at the end of any Interframe Space (IFS).
1024 */
1026
1027 /**
1028 * The trace source fired when packets are considered as successfully sent
1029 * or the transmission has been given up.
1030 * Only non-broadcast packets are traced.
1031 *
1032 * The data should represent:
1033 * packet, number of retries, total number of csma backoffs
1034 *
1035 * @see class CallBackTraceSource
1036 */
1038
1039 /**
1040 * The trace source fired when packets come into the "top" of the device
1041 * at the L3/L2 transition, when being queued for transmission.
1042 *
1043 * @see class CallBackTraceSource
1044 */
1046
1047 /**
1048 * The trace source fired when packets are dequeued from the
1049 * L3/l2 transmission queue.
1050 *
1051 * @see class CallBackTraceSource
1052 */
1054
1055 /**
1056 * The trace source fired when packets come into the "top" of the device
1057 * at the L3/L2 transition, when being queued for indirect transmission
1058 * (pending transaction list).
1059 * @see class CallBackTraceSource
1060 */
1062
1063 /**
1064 * The trace source fired when packets are dequeued from the
1065 * L3/l2 indirect transmission queue (Pending transaction list).
1066 *
1067 * @see class CallBackTraceSource
1068 */
1070
1071 /**
1072 * The trace source fired when packets are being sent down to L1.
1073 *
1074 * @see class CallBackTraceSource
1075 */
1077
1078 /**
1079 * The trace source fired when packets where successfully transmitted, that is
1080 * an acknowledgment was received, if requested, or the packet was
1081 * successfully sent by L1, if no ACK was requested.
1082 *
1083 * @see class CallBackTraceSource
1084 */
1086
1087 /**
1088 * The trace source fired when packets are dropped due to missing ACKs or
1089 * because of transmission failures in L1.
1090 *
1091 * @see class CallBackTraceSource
1092 */
1094
1095 /**
1096 * The trace source fired when packets are dropped due to indirect Tx queue
1097 * overflows or expiration.
1098 *
1099 * @see class CallBackTraceSource
1100 */
1102
1103 /**
1104 * The trace source fired for packets successfully received by the device
1105 * immediately before being forwarded up to higher layers (at the L2/L3
1106 * transition). This is a promiscuous trace.
1107 *
1108 * @see class CallBackTraceSource
1109 */
1111
1112 /**
1113 * The trace source fired for packets successfully received by the device
1114 * immediately before being forwarded up to higher layers (at the L2/L3
1115 * transition). This is a non-promiscuous trace.
1116 *
1117 * @see class CallBackTraceSource
1118 */
1120
1121 /**
1122 * The trace source fired for packets successfully received by the device
1123 * but dropped before being forwarded up to higher layers (at the L2/L3
1124 * transition).
1125 *
1126 * @see class CallBackTraceSource
1127 */
1129
1130 /**
1131 * A trace source that emulates a non-promiscuous protocol sniffer connected
1132 * to the device. Unlike your average everyday sniffer, this trace source
1133 * will not fire on PACKET_OTHERHOST events.
1134 *
1135 * On the transmit size, this trace hook will fire after a packet is dequeued
1136 * from the device queue for transmission. In Linux, for example, this would
1137 * correspond to the point just before a device hard_start_xmit where
1138 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
1139 * ETH_P_ALL handlers.
1140 *
1141 * On the receive side, this trace hook will fire when a packet is received,
1142 * just before the receive callback is executed. In Linux, for example,
1143 * this would correspond to the point at which the packet is dispatched to
1144 * packet sniffers in netif_receive_skb.
1145 *
1146 * @see class CallBackTraceSource
1147 */
1149
1150 /**
1151 * A trace source that emulates a promiscuous mode protocol sniffer connected
1152 * to the device. This trace source fire on packets destined for any host
1153 * just like your average everyday packet sniffer.
1154 *
1155 * On the transmit size, this trace hook will fire after a packet is dequeued
1156 * from the device queue for transmission. In Linux, for example, this would
1157 * correspond to the point just before a device hard_start_xmit where
1158 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
1159 * ETH_P_ALL handlers.
1160 *
1161 * On the receive side, this trace hook will fire when a packet is received,
1162 * just before the receive callback is executed. In Linux, for example,
1163 * this would correspond to the point at which the packet is dispatched to
1164 * packet sniffers in netif_receive_skb.
1165 *
1166 * @see class CallBackTraceSource
1167 */
1169
1170 /**
1171 * A trace source that fires when the MAC changes states.
1172 * Parameters are the old mac state and the new mac state.
1173 *
1174 * @deprecated This TracedCallback is deprecated and will be
1175 * removed in a future release, Instead, use the \c MacStateValue
1176 * TracedValue.
1177 */
1178 // NS_DEPRECATED() - tag for future removal
1180
1181 /**
1182 * The PHY associated with this MAC.
1183 */
1185
1186 /**
1187 * The CSMA/CA implementation used by this MAC.
1188 */
1190
1191 /**
1192 * The current state of the MAC layer.
1193 */
1195
1196 /**
1197 * The current period of the incoming superframe.
1198 */
1200
1201 /**
1202 * The current period of the outgoing superframe.
1203 */
1205
1206 /**
1207 * The packet which is currently being sent by the MAC layer.
1208 */
1210
1211 /**
1212 * The command request packet received. Briefly stored to proceed with operations
1213 * that take place after ACK messages.
1214 */
1216
1217 /**
1218 * The short address (16 bit address) used by this MAC. If supported,
1219 * the short address must be assigned to the device by the coordinator
1220 * during the association process.
1221 */
1223
1224 /**
1225 * The extended 64 address (IEEE EUI-64) used by this MAC.
1226 */
1228
1229 /**
1230 * The transmit queue used by the MAC.
1231 */
1232 std::deque<Ptr<TxQueueElement>> m_txQueue;
1233
1234 /**
1235 * The indirect transmit queue used by the MAC pending messages (The pending transaction
1236 * list).
1237 */
1238 std::deque<Ptr<IndTxQueueElement>> m_indTxQueue;
1239
1240 /**
1241 * The maximum size of the transmit queue.
1242 */
1244
1245 /**
1246 * The maximum size of the indirect transmit queue (The pending transaction list).
1247 */
1249
1250 /**
1251 * The list of PAN descriptors accumulated during channel scans, used to select a PAN to
1252 * associate.
1253 */
1254 std::vector<PanDescriptor> m_panDescriptorList;
1255
1256 /**
1257 * The list of energy measurements, one for each channel searched during an ED scan.
1258 */
1259 std::vector<uint8_t> m_energyDetectList;
1260
1261 /**
1262 * The list of unscanned channels during a scan operation.
1263 */
1264 std::vector<uint8_t> m_unscannedChannels;
1265
1266 /**
1267 * The parameters used during a MLME-SCAN.request. These parameters are stored here while
1268 * PLME-SET (set channel page, set channel number) and other operations take place.
1269 */
1271
1272 /**
1273 * The parameters used during a MLME-START.request. These parameters are stored here while
1274 * PLME-SET operations (set channel page, set channel number) take place.
1275 */
1277
1278 /**
1279 * The parameters used during a MLME-ASSOCIATE.request. These parameters are stored here while
1280 * PLME-SET operations (set channel page, set channel number) take place.
1281 */
1283
1284 /**
1285 * The channel list index used to obtain the current scanned channel.
1286 */
1288
1289 /**
1290 * Indicates the pending primitive when PLME.SET operation (page or channel switch) is called
1291 * from within another MLME primitive (e.g. Association, Scan, Sync, Start).
1292 */
1294
1295 /**
1296 * The number of already used retransmission for the currently transmitted
1297 * packet.
1298 */
1300
1301 /**
1302 * The number of CSMA/CA retries used for sending the current packet.
1303 */
1305
1306 /**
1307 * Keep track of the last received frame Link Quality Indicator
1308 */
1310
1311 /**
1312 * This flag informs the MAC that an association response command was received
1313 * before the acknowledgment (ACK) for the data request command that
1314 * should precede it. This situation typically occurs due to network saturation.
1315 */
1316
1318
1319 /**
1320 * Scheduler event for the ACK timeout of the currently transmitted data
1321 * packet.
1322 */
1324
1325 /**
1326 * Scheduler event for a response to a request command frame.
1327 */
1329
1330 /**
1331 * Scheduler event for the lost of a association response command frame.
1332 */
1334
1335 /**
1336 * Scheduler event for a deferred MAC state change.
1337 */
1339
1340 /**
1341 * Scheduler event for Interframe spacing wait time.
1342 */
1344
1345 /**
1346 * Scheduler event for generation of one beacon.
1347 */
1349
1350 /**
1351 * Scheduler event for the end of the outgoing superframe CAP.
1352 **/
1354
1355 /**
1356 * Scheduler event for the end of the outgoing superframe CFP.
1357 */
1359
1360 /**
1361 * Scheduler event for the end of the incoming superframe CAP.
1362 **/
1364
1365 /**
1366 * Scheduler event for the end of the incoming superframe CFP.
1367 */
1369
1370 /**
1371 * Scheduler event to track the incoming beacons.
1372 */
1374
1375 /**
1376 * Scheduler event for the end of an ACTIVE or PASSIVE channel scan.
1377 */
1379
1380 /**
1381 * Scheduler event for the end of an ORPHAN channel scan.
1382 */
1384
1385 /**
1386 * Scheduler event for the end of a ED channel scan.
1387 */
1389
1390 /**
1391 * The uniform random variable used in this mac layer
1392 */
1394};
1395} // namespace lrwpan
1396} // namespace ns3
1397
1398#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:49
Represent the GTS information fields.
Lr-wpan MAC layer abstraction.
Represent the Mac Header with the Frame Control and Sequence Number fields.
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
Temporarily 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.
void ReceiveData(uint8_t lqi, const LrWpanMacHeader &receivedMacHdr, Ptr< Packet > p)
Used to process the reception of data.
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.
void PrintReceivedPacket(const LrWpanMacHeader &receivedMacHdr)
Display the MAC header contents of a successfully received packet when logs are active.
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.
void ReceiveBeacon(uint8_t lqi, const LrWpanMacHeader &receivedMacHdr, Ptr< Packet > p)
Used to process the reception of a beacon packet.
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.
void ReceiveAcknowledgment(const LrWpanMacHeader &receivedMacHdr, Ptr< Packet > p)
Used to process an acknowledgment packet.
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 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.
void ReceiveInPromiscuousMode(uint8_t lqi, const LrWpanMacHeader &receivedMacHdr, Ptr< Packet > p)
Process a frame when promiscuous mode is active.
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 ReceiveCommand(uint8_t lqi, const LrWpanMacHeader &receivedMacHdr, Ptr< Packet > p)
Used to process the reception of a command packet.
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.
bool m_ignoreDataCmdAck
This flag informs the MAC that an association response command was received before the acknowledgment...
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:65
SuperframeStatus
Superframe status.
Definition lr-wpan-mac.h:93
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:52
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:67
@ MAC_GTS
MAC_GTS.
Definition lr-wpan-mac.h:73
@ CHANNEL_ACCESS_FAILURE
CHANNEL_ACCESS_FAILURE.
Definition lr-wpan-mac.h:70
@ CHANNEL_IDLE
CHANNEL_IDLE.
Definition lr-wpan-mac.h:71
@ SET_PHY_TX_ON
SET_PHY_TX_ON.
Definition lr-wpan-mac.h:72
@ MAC_CSMA_DEFERRED
MAC_CSMA_DEFERRED.
Definition lr-wpan-mac.h:75
@ MAC_IDLE
MAC_IDLE.
Definition lr-wpan-mac.h:66
@ MAC_INACTIVE
MAC_INACTIVE.
Definition lr-wpan-mac.h:74
@ MAC_SENDING
MAC_SENDING.
Definition lr-wpan-mac.h:68
@ MAC_ACK_PENDING
MAC_ACK_PENDING.
Definition lr-wpan-mac.h:69
@ BEACON
The Beacon transmission or reception Period.
Definition lr-wpan-mac.h:94
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
Definition lr-wpan-mac.h:97
@ CAP
Contention Access Period.
Definition lr-wpan-mac.h:95
@ CFP
Contention Free Period.
Definition lr-wpan-mac.h:96
@ 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:53
@ TX_OPTION_GTS
TX_OPTION_GTS.
Definition lr-wpan-mac.h:55
@ TX_OPTION_ACK
TX_OPTION_ACK.
Definition lr-wpan-mac.h:54
@ TX_OPTION_INDIRECT
TX_OPTION_INDIRECT.
Definition lr-wpan-mac.h:56
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