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
109};
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
123};
124
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 * @param rssi The received signal strength indicator measured during the reception of the
293 * packet. Supported by IEEE 802.15.4-2015 onwards.
294 */
295 void PdDataIndication(uint32_t psduLength, Ptr<Packet> p, uint8_t lqi, int8_t rssi);
296
297 /**
298 * IEEE 802.15.4-2006 section 6.2.1.2
299 * Confirm the end of transmission of an MPDU to MAC
300 * @param status to report to MAC
301 * PHY PD-DATA.confirm status
302 */
303 void PdDataConfirm(PhyEnumeration status);
304
305 /**
306 * IEEE 802.15.4-2006 section 6.2.2.2
307 * PLME-CCA.confirm status
308 * @param status TRX_OFF, BUSY or IDLE
309 */
310 void PlmeCcaConfirm(PhyEnumeration status);
311
312 /**
313 * IEEE 802.15.4-2006 section 6.2.2.4
314 * PLME-ED.confirm status and energy level
315 * @param status SUCCESS, TRX_OFF or TX_ON
316 * @param energyLevel 0x00-0xff ED level for the channel
317 */
318 void PlmeEdConfirm(PhyEnumeration status, uint8_t energyLevel);
319
320 /**
321 * IEEE 802.15.4-2006 section 6.2.2.6
322 * PLME-GET.confirm
323 * Get attributes per definition from Table 23 in section 6.4.2
324 * @param status SUCCESS or UNSUPPORTED_ATTRIBUTE
325 * @param id the attributed identifier
326 * @param attribute the attribute value
327 */
330 Ptr<PhyPibAttributes> attribute);
331
332 /**
333 * IEEE 802.15.4-2006 section 6.2.2.8
334 * PLME-SET-TRX-STATE.confirm
335 * Set PHY state
336 * @param status in RX_ON,TRX_OFF,FORCE_TRX_OFF,TX_ON
337 */
339
340 /**
341 * IEEE 802.15.4-2006 section 6.2.2.10
342 * PLME-SET.confirm
343 * Set attributes per definition from Table 23 in section 6.4.2
344 * @param status SUCCESS, UNSUPPORTED_ATTRIBUTE, INVALID_PARAMETER, or READ_ONLY
345 * @param id the attributed identifier
346 */
348
349 /**
350 * CSMA-CA algorithm calls back the MAC after executing channel assessment.
351 *
352 * @param macState indicate BUSY or IDLE channel condition
353 */
354 void SetLrWpanMacState(MacState macState);
355
356 /**
357 * Set the max size of the transmit queue.
358 *
359 * @param queueSize The transmit queue size.
360 */
362
363 /**
364 * Set the max size of the indirect transmit queue (Pending Transaction list)
365 *
366 * @param queueSize The indirect transmit queue size.
367 */
369
370 // MAC PIB attributes
371
372 /**
373 * The time that the device transmitted its last beacon frame.
374 * It also indicates the start of the Active Period in the Outgoing superframe.
375 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
376 */
378
379 /**
380 * The time that the device received its last bit of the beacon frame.
381 * It does not indicate the start of the Active Period in the Incoming superframe.
382 * Not explicitly listed by the standard but its use is implied.
383 * Its purpose is somehow similar to m_macBeaconTxTime
384 */
386
387 /**
388 * The maximum time, in multiples of aBaseSuperframeDuration, a device
389 * shall wait for a response command frame to be available following a
390 * request command frame.
391 */
393
394 /**
395 * The maximum wait time for an association response command after the reception
396 * of data request command ACK during the association process. Not explicitly
397 * listed by the standard but its use is required for a device to react to the lost
398 * of the association response (failure of the association: NO_DATA)
399 */
401
402 /**
403 * The short address of the coordinator through which the device is
404 * associated.
405 * 0xFFFF indicates this value is unknown.
406 * 0xFFFE indicates the coordinator is only using its extended address.
407 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
408 */
410
411 /**
412 * The extended address of the coordinator through which the device
413 * is associated.
414 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
415 */
417
418 /**
419 * Symbol boundary is same as m_macBeaconTxTime.
420 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
421 */
423
424 /**
425 * Used by a PAN coordinator or coordinator.
426 * Defines how often the coordinator transmits its beacon
427 * (outgoing superframe). Range 0 - 15 with 15 meaning no beacons are being sent.
428 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
429 */
431
432 /**
433 * Used by a PAN coordinator or coordinator. The length of the active portion
434 * of the outgoing superframe, including the beacon frame.
435 * 0 - 15 with 15 means the superframe will not be active after the beacon.
436 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
437 */
439
440 /**
441 * The maximum time (in UNIT periods) that a transaction is stored by a
442 * coordinator and indicated in its beacon. This value establish the expiration
443 * time of the packets stored in the pending transaction list (indirect transmissions).
444 * 1 Unit Period:
445 * Beacon-enabled = aBaseSuperframeDuration * 2^BO
446 * Non-beacon enabled = aBaseSuperframeDuration
447 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
448 */
450
451 /**
452 * The total size of the received beacon in symbols.
453 * Its value is used to calculate the end CAP time of the incoming superframe.
454 */
456
457 /**
458 * Indication of the Slot where the CAP portion of the OUTGOING Superframe ends.
459 */
461
462 /**
463 * The beaconOrder value of the INCOMING frame. Used by all devices that have a parent.
464 * Specification of how often the parent coordinator transmits its beacon.
465 * 0 - 15 with 15 means the parent is not currently transmitting beacons.
466 */
468
469 /**
470 * Used by all devices that have a parent.
471 * The length of the active portion of the INCOMING superframe, including the
472 * beacon frame.
473 * 0 - 15 with 15 meaning the superframe will not be active after the beacon.
474 */
476
477 /**
478 * Indication of the Slot where the CAP portion of the INCOMING Superframe ends.
479 */
481
482 /**
483 * Indicates if MAC sublayer is in receive all mode. True mean accept all
484 * frames from PHY.
485 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
486 */
488
489 /**
490 * 16 bits id of PAN on which this device is operating. 0xffff means not
491 * associated.
492 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
493 */
494 uint16_t m_macPanId;
495
496 /**
497 * Temporarily stores the value of the current m_macPanId when a MLME-SCAN.request is performed.
498 * See IEEE 802.15.4-2011, section 5.1.2.1.2.
499 */
501
502 /**
503 * Sequence number added to transmitted data or MAC command frame, 00-ff.
504 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
505 */
507
508 /**
509 * Sequence number added to transmitted beacon frame, 00-ff.
510 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
511 */
513
514 /**
515 * The set with the contents of the beacon payload.
516 * This value is set directly by the MLME-SET primitive.
517 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
518 */
519 std::vector<uint8_t> m_macBeaconPayload;
520
521 /**
522 * The length, in octets, of the beacon payload.
523 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
524 */
526
527 /**
528 * The maximum number of retries allowed after a transmission failure.
529 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
530 */
532
533 /**
534 * Indication of whether the MAC sublayer is to enable its receiver during
535 * idle periods.
536 * See IEEE 802.15.4-2006, section 7.4.2, Table 86.
537 */
539
540 /**
541 * The minimum time forming a Long InterFrame Spacing (LIFS) period.
542 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
543 */
545
546 /**
547 * The minimum time forming a Short InterFrame Spacing (SIFS) period.
548 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
549 */
551
552 /**
553 * Indication of whether a coordinator is currently allowing association.
554 * A value of TRUE indicates that the association is permitted.
555 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
556 */
558
559 /**
560 * Indication of whether a device automatically sends data request command
561 * if its address is listed in the beacon frame.
562 * TRUE = request command automatically is sent. This command also affects
563 * the generation of MLME-BEACON-NOTIFY.indication (6.2.4.1)
564 * See IEEE 802.15.4-2011, section 6.4.2, Table 52.
565 */
567
568 /**
569 * The maximum energy level detected during ED scan on the current channel.
570 */
572
573 /**
574 * The value of the necessary InterFrame Space after the transmission of a packet.
575 */
577
578 /**
579 * Indication of whether the current device is the PAN coordinator
580 */
582
583 /**
584 * Indicates if the current device is a coordinator type
585 */
586 bool m_coor;
587
588 /**
589 * Indication of the Interval used by the coordinator to transmit beacon frames
590 * expressed in symbols.
591 */
593
594 /**
595 * Indication of the superframe duration in symbols.
596 * (e.g. 1 symbol = 4 bits in a 250kbps O-QPSK PHY)
597 */
599
600 /**
601 * Indication of the interval a node should receive a superframe
602 * expressed in symbols.
603 */
605
606 /**
607 * Indication of the superframe duration in symbols
608 * (e.g. 1 symbol = 4 bits in a 250kbps O-QPSK PHY)
609 */
611
612 /**
613 * Indication of current device capability (FFD or RFD)
614 */
616
617 /**
618 * Indication of whether the current device is tracking incoming beacons.
619 */
621
622 /**
623 * The number of consecutive loss beacons in a beacon tracking operation.
624 */
626
627 /**
628 * Get the macAckWaitDuration attribute value.
629 *
630 * @return the maximum number symbols to wait for an acknowledgment frame
631 */
632 uint64_t GetMacAckWaitDuration() const;
633
634 /**
635 * Get the macMaxFrameRetries attribute value.
636 *
637 * @return the maximum number of retries
638 */
639 uint8_t GetMacMaxFrameRetries() const;
640
641 /**
642 * Print the number of elements in the packet transmit queue.
643 */
645
646 /**
647 * Set the macMaxFrameRetries attribute value.
648 *
649 * @param retries the maximum number of retries
650 */
651 void SetMacMaxFrameRetries(uint8_t retries);
652
653 /**
654 * Check if the packet destination is its coordinator
655 *
656 * @return True if m_txPkt (packet awaiting to be sent) destination is its coordinator
657 */
658 bool IsCoordDest();
659
660 /**
661 * Check if the packet destination is its coordinator
662 *
663 * @param mac The coordinator short MAC Address
664 */
666
667 /**
668 * Check if the packet destination is its coordinator
669 *
670 * @param mac The coordinator extended MAC Address
671 */
673
674 /**
675 * Get the size of the Interframe Space according to MPDU size (m_txPkt).
676 *
677 * @return the IFS size in symbols
678 */
680
681 /**
682 * Obtain the number of symbols in the packet which is currently being sent by the MAC layer.
683 *
684 * @return packet number of symbols
685 */
686 uint64_t GetTxPacketSymbols();
687
688 /**
689 * Check if the packet to transmit requires acknowledgment
690 *
691 * @return True if the Tx packet requires acknowledgment
692 */
693 bool IsTxAckReq();
694
695 /**
696 * Print the Pending transaction list.
697 * @param os The reference to the output stream used by this print function.
698 */
699 void PrintPendingTxQueue(std::ostream& os) const;
700
701 /**
702 * Print the Transmit Queue.
703 * @param os The reference to the output stream used by this print function.
704 */
705 void PrintTxQueue(std::ostream& os) const;
706
707 /**
708 * Assign a fixed random variable stream number to the random variables
709 * used by this model. Return the number of streams that have been assigned.
710 *
711 * @param stream first stream index to use
712 * @return the number of stream indices assigned by this model
713 */
714 int64_t AssignStreams(int64_t stream);
715
716 /**
717 * TracedCallback signature for sent packets.
718 *
719 * @param [in] packet The packet.
720 * @param [in] retries The number of retries.
721 * @param [in] backoffs The number of CSMA backoffs.
722 */
723 typedef void (*SentTracedCallback)(Ptr<const Packet> packet, uint8_t retries, uint8_t backoffs);
724
725 /**
726 * TracedCallback signature for MacState change events.
727 *
728 * @param [in] oldValue The original state value.
729 * @param [in] newValue The new state value.
730 * @deprecated The MacState is now accessible as the
731 * TracedValue \c MacStateValue. The \c MacState TracedCallback will
732 * be removed in a future release.
733 */
734 // NS_DEPRECATED() - tag for future removal
735 typedef void (*StateTracedCallback)(MacState oldState, MacState newState);
736
737 protected:
738 // Inherited from Object.
739 void DoInitialize() override;
740 void DoDispose() override;
741
742 private:
743 /**
744 * Helper structure for managing transmission queue elements.
745 */
747 {
748 uint8_t txQMsduHandle; //!< MSDU Handle
749 Ptr<Packet> txQPkt; //!< Queued packet
750 };
751
752 /**
753 * Helper structure for managing pending transaction list elements (Indirect transmissions).
754 */
756 {
757 uint8_t seqNum; //!< The sequence number of the queued packet
758 Mac16Address dstShortAddress; //!< The destination short Mac Address
759 Mac64Address dstExtAddress; //!< The destination extended Mac Address
760 Ptr<Packet> txQPkt; //!< Queued packet.
761 Time expireTime; //!< The expiration time of the packet in the indirect transmission queue.
762 };
763
764 /**
765 * Process a frame when promiscuous mode is active.
766 *
767 * @param lqi The LQI value of the received packet
768 * @param rssi The receive signal strength indicator in dBm.
769 * @param receivedMacHdr The reference to the received MAC header
770 * @param p The packet containing the MAC payload
771 */
772 void ReceiveInPromiscuousMode(uint8_t lqi,
773 int8_t rssi,
774 const LrWpanMacHeader& receivedMacHdr,
775 Ptr<Packet> p);
776
777 /**
778 * Called to send a single beacon frame.
779 */
780 void SendOneBeacon();
781
782 /**
783 * Called to send an associate request command.
784 */
786
787 /**
788 * Used to send a data request command (i.e. Request the coordinator to send the association
789 * response)
790 */
792
793 /**
794 * Called to send an associate response command.
795 *
796 * @param rxDataReqPkt The received data request pkt that instigated the Association response
797 * command.
798 */
799 void SendAssocResponseCommand(Ptr<Packet> rxDataReqPkt);
800
801 /**
802 * Called after m_assocRespCmdWaitTime timeout while waiting for an association response
803 * command.
804 */
806
807 /**
808 * Called to send a beacon request command.
809 */
811
812 /**
813 * Called to send a orphan notification command. This is used by an associated device that
814 * has lost synchronization with its coordinator.
815 * As described in IEEE 802.15.4-2011 (Section 5.3.6)
816 */
818
819 /**
820 * Called to end a MLME-START.request after changing the page and channel number.
821 */
822 void EndStartRequest();
823
824 /**
825 * Called at the end of the current channel scan (Active or Passive) for a given duration.
826 */
827 void EndChannelScan();
828
829 /**
830 * Called at the end of one ED channel scan.
831 */
833
834 /**
835 * Called to end an MLME-ASSOCIATE.request after changing the page and channel number.
836 */
837 void EndAssociateRequest();
838
839 /**
840 * Called to begin the Contention Free Period (CFP) in a
841 * beacon-enabled mode.
842 *
843 * @param superframeType The incoming or outgoing superframe reference
844 */
845 void StartCFP(SuperframeType superframeType);
846
847 /**
848 * Called to begin the Contention Access Period (CAP) in a
849 * beacon-enabled mode.
850 *
851 * @param superframeType The incoming or outgoing superframe reference
852 */
853 void StartCAP(SuperframeType superframeType);
854
855 /**
856 * Start the Inactive Period in a beacon-enabled mode.
857 *
858 * @param superframeType The incoming or outgoing superframe reference
859 *
860 */
861 void StartInactivePeriod(SuperframeType superframeType);
862
863 /**
864 * Called after the end of an INCOMING superframe to start the moment a
865 * device waits for a new incoming beacon.
866 */
867 void AwaitBeacon();
868
869 /**
870 * Called if the device is unable to locate a beacon in the time set by MLME-SYNC.request.
871 */
872 void BeaconSearchTimeout();
873
874 /**
875 * Used to process the reception of a beacon packet.
876 *
877 * @param lqi The value of the link quality indicator (LQI) of the received packet.
878 * @param receivedMacHdr The reference to the received MAC header.
879 * @param p The packet containing the beacon payload information.
880 */
881 void ReceiveBeacon(uint8_t lqi, const LrWpanMacHeader& receivedMacHdr, Ptr<Packet> p);
882
883 /**
884 * Used to process the reception of a command packet.
885 *
886 * @param lqi The value of the link quality indicator (LQI) of the received packet.
887 * @param receivedMacHdr The reference to the received MAC header.
888 * @param p The packet containing the command payload information.
889 */
890 void ReceiveCommand(uint8_t lqi, const LrWpanMacHeader& receivedMacHdr, Ptr<Packet> p);
891
892 /**
893 * Used to process the reception of data.
894 *
895 * @param lqi The value of the link quality indicator (LQI) of the received packet.
896 * @param rssi The received signal strength indicator in dBm.
897 * @param receivedMacHdr The reference to the received MAC header.
898 * @param p The packet containing the data payload.
899 */
900 void ReceiveData(uint8_t lqi,
901 int8_t rssi,
902 const LrWpanMacHeader& receivedMacHdr,
903 Ptr<Packet> p);
904
905 /**
906 * Used to process an acknowledgment packet.
907 *
908 * @param receivedMacHdr The reference to the received MAC header.
909 * @param p The packet containing the MAC header and the data payload.
910 */
911 void ReceiveAcknowledgment(const LrWpanMacHeader& receivedMacHdr, Ptr<Packet> p);
912
913 /**
914 * Display the MAC header contents of a successfully received packet when
915 * logs are active.
916 *
917 * @param receivedMacHdr The reference of the received MAC header
918 */
919 void PrintReceivedPacket(const LrWpanMacHeader& receivedMacHdr);
920
921 /**
922 * Send an acknowledgment packet for the given sequence number.
923 *
924 * @param seqno the sequence number for the ACK
925 */
926 void SendAck(uint8_t seqno);
927
928 /**
929 * Add an element to the transmission queue.
930 *
931 * @param txQElement The element added to the Tx Queue.
932 */
933 void EnqueueTxQElement(std::shared_ptr<TxQueueElement> txQElement);
934
935 /**
936 * Remove the tip of the transmission queue, including clean up related to the
937 * last packet transmission.
938 */
940
941 /**
942 * Change the current MAC state to the given new state.
943 *
944 * @param newState the new state
945 */
946 void ChangeMacState(MacState newState);
947
948 /**
949 * Handle an ACK timeout with a packet retransmission, if there are
950 * retransmission left, or a packet drop.
951 */
952 void AckWaitTimeout();
953
954 /**
955 * After a successful transmission of a frame (beacon, data) or an ack frame reception,
956 * the mac layer wait an Interframe Space (IFS) time and triggers this function
957 * to continue with the MAC flow.
958 *
959 * @param ifsTime IFS time
960 */
961 void IfsWaitTimeout(Time ifsTime);
962
963 /**
964 * Check for remaining retransmissions for the packet currently being sent.
965 * Drop the packet, if there are no retransmissions left.
966 *
967 * @return true, if the packet should be retransmitted, false otherwise.
968 */
970
971 /**
972 * Adds a packet to the pending transactions list (Indirect transmissions).
973 *
974 * @param p The packet added to pending transaction list.
975 */
976 void EnqueueInd(Ptr<Packet> p);
977
978 /**
979 * Extracts a packet from pending transactions list (Indirect transmissions).
980 * @param dst The extended address used an index to obtain an element from the pending
981 * transaction list.
982 * @param entry The dequeued element from the pending transaction list.
983 * @return The status of the dequeue
984 */
985 bool DequeueInd(Mac64Address dst, std::shared_ptr<IndTxQueueElement> entry);
986
987 /**
988 * Purge expired transactions from the pending transactions list.
989 */
990 void PurgeInd();
991
992 /**
993 * Remove an element from the pending transaction list.
994 *
995 * @param p The packet to be removed from the pending transaction list.
996 */
998
999 /**
1000 * Check the transmission queue. If there are packets in the transmission
1001 * queue and the MAC is idle, pick the first one and initiate a packet
1002 * transmission.
1003 */
1004 void CheckQueue();
1005
1006 /**
1007 * Constructs a Superframe specification field from the local information,
1008 * the superframe Specification field is necessary to create a beacon frame.
1009 *
1010 * @returns the Superframe specification field (bitmap)
1011 */
1012 uint16_t GetSuperframeField();
1013
1014 /**
1015 * Constructs the Guaranteed Time Slots (GTS) Fields from local information.
1016 * The GTS Fields are part of the beacon frame.
1017 *
1018 * @returns the Guaranteed Time Slots (GTS) Fields
1019 */
1021
1022 /**
1023 * Constructs Pending Address Fields from the local information,
1024 * the Pending Address Fields are part of the beacon frame.
1025 *
1026 * @returns the Pending Address Fields
1027 */
1029
1030 /**
1031 * The trace source is fired at the end of any Interframe Space (IFS).
1032 */
1034
1035 /**
1036 * The trace source fired when packets are considered as successfully sent
1037 * or the transmission has been given up.
1038 * Only non-broadcast packets are traced.
1039 *
1040 * The data should represent:
1041 * packet, number of retries, total number of csma backoffs
1042 *
1043 * @see class CallBackTraceSource
1044 */
1046
1047 /**
1048 * The trace source fired when packets come into the "top" of the device
1049 * at the L3/L2 transition, when being queued for transmission.
1050 *
1051 * @see class CallBackTraceSource
1052 */
1054
1055 /**
1056 * The trace source fired when packets are dequeued from the
1057 * L3/l2 transmission queue.
1058 *
1059 * @see class CallBackTraceSource
1060 */
1062
1063 /**
1064 * The trace source fired when packets come into the "top" of the device
1065 * at the L3/L2 transition, when being queued for indirect transmission
1066 * (pending transaction list).
1067 * @see class CallBackTraceSource
1068 */
1070
1071 /**
1072 * The trace source fired when packets are dequeued from the
1073 * L3/l2 indirect transmission queue (Pending transaction list).
1074 *
1075 * @see class CallBackTraceSource
1076 */
1078
1079 /**
1080 * The trace source fired when packets are being sent down to L1.
1081 *
1082 * @see class CallBackTraceSource
1083 */
1085
1086 /**
1087 * The trace source fired when packets where successfully transmitted, that is
1088 * an acknowledgment was received, if requested, or the packet was
1089 * successfully sent by L1, if no ACK was requested.
1090 *
1091 * @see class CallBackTraceSource
1092 */
1094
1095 /**
1096 * The trace source fired when packets are dropped due to missing ACKs or
1097 * because of transmission failures in L1.
1098 *
1099 * @see class CallBackTraceSource
1100 */
1102
1103 /**
1104 * The trace source fired when packets are dropped due to indirect Tx queue
1105 * overflows or expiration.
1106 *
1107 * @see class CallBackTraceSource
1108 */
1110
1111 /**
1112 * The trace source fired for packets successfully received by the device
1113 * immediately before being forwarded up to higher layers (at the L2/L3
1114 * transition). This is a promiscuous trace.
1115 *
1116 * @see class CallBackTraceSource
1117 */
1119
1120 /**
1121 * The trace source fired for packets successfully received by the device
1122 * immediately before being forwarded up to higher layers (at the L2/L3
1123 * transition). This is a non-promiscuous trace.
1124 *
1125 * @see class CallBackTraceSource
1126 */
1128
1129 /**
1130 * The trace source fired for packets successfully received by the device
1131 * but dropped before being forwarded up to higher layers (at the L2/L3
1132 * transition).
1133 *
1134 * @see class CallBackTraceSource
1135 */
1137
1138 /**
1139 * A trace source that emulates a non-promiscuous protocol sniffer connected
1140 * to the device. Unlike your average everyday sniffer, this trace source
1141 * will not fire on PACKET_OTHERHOST events.
1142 *
1143 * On the transmit size, this trace hook will fire after a packet is dequeued
1144 * from the device queue for transmission. In Linux, for example, this would
1145 * correspond to the point just before a device hard_start_xmit where
1146 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
1147 * ETH_P_ALL handlers.
1148 *
1149 * On the receive side, this trace hook will fire when a packet is received,
1150 * just before the receive callback is executed. In Linux, for example,
1151 * this would correspond to the point at which the packet is dispatched to
1152 * packet sniffers in netif_receive_skb.
1153 *
1154 * @see class CallBackTraceSource
1155 */
1157
1158 /**
1159 * A trace source that emulates a promiscuous mode protocol sniffer connected
1160 * to the device. This trace source fire on packets destined for any host
1161 * just like your average everyday packet sniffer.
1162 *
1163 * On the transmit size, this trace hook will fire after a packet is dequeued
1164 * from the device queue for transmission. In Linux, for example, this would
1165 * correspond to the point just before a device hard_start_xmit where
1166 * dev_queue_xmit_nit is called to dispatch the packet to the PF_PACKET
1167 * ETH_P_ALL handlers.
1168 *
1169 * On the receive side, this trace hook will fire when a packet is received,
1170 * just before the receive callback is executed. In Linux, for example,
1171 * this would correspond to the point at which the packet is dispatched to
1172 * packet sniffers in netif_receive_skb.
1173 *
1174 * @see class CallBackTraceSource
1175 */
1177
1178 /**
1179 * A trace source that fires when the MAC changes states.
1180 * Parameters are the old mac state and the new mac state.
1181 *
1182 * @deprecated This TracedCallback is deprecated and will be
1183 * removed in a future release, Instead, use the \c MacStateValue
1184 * TracedValue.
1185 */
1186 // NS_DEPRECATED() - tag for future removal
1188
1189 /**
1190 * The PHY associated with this MAC.
1191 */
1193
1194 /**
1195 * The CSMA/CA implementation used by this MAC.
1196 */
1198
1199 /**
1200 * The current state of the MAC layer.
1201 */
1203
1204 /**
1205 * The current period of the incoming superframe.
1206 */
1208
1209 /**
1210 * The current period of the outgoing superframe.
1211 */
1213
1214 /**
1215 * The packet which is currently being sent by the MAC layer.
1216 */
1218
1219 /**
1220 * The command request packet received. Briefly stored to proceed with operations
1221 * that take place after ACK messages.
1222 */
1224
1225 /**
1226 * The short address (16 bit address) used by this MAC. If supported,
1227 * the short address must be assigned to the device by the coordinator
1228 * during the association process.
1229 */
1231
1232 /**
1233 * The extended 64 address (IEEE EUI-64) used by this MAC.
1234 */
1236
1237 /**
1238 * The transmit queue used by the MAC.
1239 */
1240 std::deque<std::shared_ptr<TxQueueElement>> m_txQueue;
1241
1242 /**
1243 * The indirect transmit queue used by the MAC pending messages (The pending transaction
1244 * list).
1245 */
1246 std::deque<std::shared_ptr<IndTxQueueElement>> m_indTxQueue;
1247
1248 /**
1249 * The maximum size of the transmit queue.
1250 */
1252
1253 /**
1254 * The maximum size of the indirect transmit queue (The pending transaction list).
1255 */
1257
1258 /**
1259 * The list of PAN descriptors accumulated during channel scans, used to select a PAN to
1260 * associate.
1261 */
1262 std::vector<PanDescriptor> m_panDescriptorList;
1263
1264 /**
1265 * The list of energy measurements, one for each channel searched during an ED scan.
1266 */
1267 std::vector<uint8_t> m_energyDetectList;
1268
1269 /**
1270 * The list of unscanned channels during a scan operation.
1271 */
1272 std::vector<uint8_t> m_unscannedChannels;
1273
1274 /**
1275 * The parameters used during a MLME-SCAN.request. These parameters are stored here while
1276 * PLME-SET (set channel page, set channel number) and other operations take place.
1277 */
1279
1280 /**
1281 * The parameters used during a MLME-START.request. These parameters are stored here while
1282 * PLME-SET operations (set channel page, set channel number) take place.
1283 */
1285
1286 /**
1287 * The parameters used during a MLME-ASSOCIATE.request. These parameters are stored here while
1288 * PLME-SET operations (set channel page, set channel number) take place.
1289 */
1291
1292 /**
1293 * The channel list index used to obtain the current scanned channel.
1294 */
1296
1297 /**
1298 * Indicates the pending primitive when PLME.SET operation (page or channel switch) is called
1299 * from within another MLME primitive (e.g. Association, Scan, Sync, Start).
1300 */
1302
1303 /**
1304 * The number of already used retransmission for the currently transmitted
1305 * packet.
1306 */
1308
1309 /**
1310 * The number of CSMA/CA retries used for sending the current packet.
1311 */
1313
1314 /**
1315 * Keep track of the last received frame Link Quality Indicator
1316 */
1318
1319 /**
1320 * This flag informs the MAC that an association response command was received
1321 * before the acknowledgment (ACK) for the data request command that
1322 * should precede it. This situation typically occurs due to network saturation.
1323 */
1324
1326
1327 /**
1328 * Scheduler event for the ACK timeout of the currently transmitted data
1329 * packet.
1330 */
1332
1333 /**
1334 * Scheduler event for a response to a request command frame.
1335 */
1337
1338 /**
1339 * Scheduler event for the lost of a association response command frame.
1340 */
1342
1343 /**
1344 * Scheduler event for a deferred MAC state change.
1345 */
1347
1348 /**
1349 * Scheduler event for Interframe spacing wait time.
1350 */
1352
1353 /**
1354 * Scheduler event for generation of one beacon.
1355 */
1357
1358 /**
1359 * Scheduler event for the end of the outgoing superframe CAP.
1360 **/
1362
1363 /**
1364 * Scheduler event for the end of the outgoing superframe CFP.
1365 */
1367
1368 /**
1369 * Scheduler event for the end of the incoming superframe CAP.
1370 **/
1372
1373 /**
1374 * Scheduler event for the end of the incoming superframe CFP.
1375 */
1377
1378 /**
1379 * Scheduler event to track the incoming beacons.
1380 */
1382
1383 /**
1384 * Scheduler event for the end of an ACTIVE or PASSIVE channel scan.
1385 */
1387
1388 /**
1389 * Scheduler event for the end of an ORPHAN channel scan.
1390 */
1392
1393 /**
1394 * Scheduler event for the end of a ED channel scan.
1395 */
1397
1398 /**
1399 * The uniform random variable used in this mac layer
1400 */
1402};
1403} // namespace lrwpan
1404} // namespace ns3
1405
1406#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
network packets
Definition packet.h:228
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Forward calls to a chain of Callback.
Trace classes with value semantics.
a unique identifier for an interface.
Definition type-id.h:50
Represent the GTS information fields.
This class is a helper for the LrWpanMac to manage the Csma/CA state machine according to IEEE 802....
Lr-wpan MAC layer abstraction.
Represent the Mac Header with the Frame Control and Sequence Number fields.
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.
void ReceiveData(uint8_t lqi, int8_t rssi, const LrWpanMacHeader &receivedMacHdr, Ptr< Packet > p)
Used to process the reception of data.
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 ...
void ReceiveInPromiscuousMode(uint8_t lqi, int8_t rssi, const LrWpanMacHeader &receivedMacHdr, Ptr< Packet > p)
Process a frame when promiscuous mode is active.
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).
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.
bool DequeueInd(Mac64Address dst, std::shared_ptr< IndTxQueueElement > entry)
Extracts a packet from pending transactions list (Indirect transmissions).
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.
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.
std::deque< std::shared_ptr< IndTxQueueElement > > m_indTxQueue
The indirect transmit queue used by the MAC pending messages (The pending transaction list).
void SendAssocResponseCommand(Ptr< Packet > rxDataReqPkt)
Called to send an associate response command.
Time m_macBeaconRxTime
The time that the device received its last bit of the beacon frame.
void PdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi, int8_t rssi)
IEEE 802.15.4-2006 section 6.2.1.3 PD-DATA.indication Indicates the transfer of an MPDU from PHY to M...
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.
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.
void EnqueueTxQElement(std::shared_ptr< TxQueueElement > txQElement)
Add an element to the transmission queue.
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.
std::deque< std::shared_ptr< TxQueueElement > > m_txQueue
The transmit queue used by the MAC.
void SendDataRequestCommand()
Used to send a data request command (i.e.
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 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.
void(* SuperframeStatus)(SuperframeStatus oldValue, SuperframeStatus newValue)
TracedValue callback signature for SuperframeStatus.
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
void(* MacState)(MacState oldValue, MacState newValue)
TracedValue callback signature for MacState.
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
SequenceNumber< uint8_t, int8_t > SequenceNumber8
8 bit Sequence number.
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