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