diff --git a/CHANGES.md b/CHANGES.md index 57e80d188..dbc3dc0bc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,7 @@ Changes from ns-3.40 to ns-3-dev * (lte) Struct member `pfsFlowPerf_t::lastTtiBytesTrasmitted` in file `pf-ff-mac-scheduler.h` was renamed `fdbetsFlowPerf_t::lastTtiBytesTransmitted`. * (lr-wpan) Change the CapabilityField parameter in `LrWpanMac::MlmeAssociateRequest` and `LrWpanMac::MlmeAssociateIndication` to a standard bitmap. * (lr-wpan) Change the MAC SuperframeField usage to a standard bitmap, this change impact parameters in the `BeaconPayloadHeader`. +* (lr-wpan) Create a new abstract class that defines the form of any Lr-wpan MAC layers (`LrWpanMacBase`). ### Changes to build system diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 80806c022..997ccd4ca 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -20,8 +20,9 @@ Release 3-dev ### New user-visible features -- (lr-wpan) !1686 Change CapabilityField to standard bitmap -- (lr-wpan) !1698 Change SuperframeField to standard bitmap +- (lr-wpan) !1686 - Change CapabilityField to standard bitmap +- (lr-wpan) !1698 - Change SuperframeField to standard bitmap +- (lr-wpan) !1706 - Create MAC layer abstraction (decoupling, alternative MACs) ### Bugs fixed diff --git a/src/lr-wpan/CMakeLists.txt b/src/lr-wpan/CMakeLists.txt index 55b267e60..2fd307806 100644 --- a/src/lr-wpan/CMakeLists.txt +++ b/src/lr-wpan/CMakeLists.txt @@ -10,6 +10,7 @@ build_lib( model/lr-wpan-mac-header.cc model/lr-wpan-mac-pl-headers.cc model/lr-wpan-mac-trailer.cc + model/lr-wpan-mac-base.cc model/lr-wpan-mac.cc model/lr-wpan-net-device.cc model/lr-wpan-phy.cc @@ -26,6 +27,7 @@ build_lib( model/lr-wpan-mac-header.h model/lr-wpan-mac-pl-headers.h model/lr-wpan-mac-trailer.h + model/lr-wpan-mac-base.h model/lr-wpan-mac.h model/lr-wpan-net-device.h model/lr-wpan-phy.h diff --git a/src/lr-wpan/model/lr-wpan-mac-base.cc b/src/lr-wpan/model/lr-wpan-mac-base.cc new file mode 100644 index 000000000..f6e8833bc --- /dev/null +++ b/src/lr-wpan/model/lr-wpan-mac-base.cc @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2023 Tokushima University, Japan. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Alberto Gallegos Ramonet + */ + +#include "lr-wpan-mac-base.h" + +#include +#include + +namespace ns3 +{ + +NS_LOG_COMPONENT_DEFINE("LrWpanMacBase"); +NS_OBJECT_ENSURE_REGISTERED(LrWpanMacBase); + +TypeId +LrWpanMacBase::GetTypeId() +{ + static TypeId tid = TypeId("ns3::LrWpanMacBase").SetParent().SetGroupName("LrWpan"); + return tid; +} + +LrWpanMacBase::~LrWpanMacBase() +{ +} + +void +LrWpanMacBase::SetMcpsDataConfirmCallback(McpsDataConfirmCallback c) +{ + m_mcpsDataConfirmCallback = c; +} + +void +LrWpanMacBase::SetMcpsDataIndicationCallback(McpsDataIndicationCallback c) +{ + m_mcpsDataIndicationCallback = c; +} + +void +LrWpanMacBase::SetMlmeAssociateIndicationCallback(MlmeAssociateIndicationCallback c) +{ + m_mlmeAssociateIndicationCallback = c; +} + +void +LrWpanMacBase::SetMlmeCommStatusIndicationCallback(MlmeCommStatusIndicationCallback c) +{ + m_mlmeCommStatusIndicationCallback = c; +} + +void +LrWpanMacBase::SetMlmeOrphanIndicationCallback(MlmeOrphanIndicationCallback c) +{ + m_mlmeOrphanIndicationCallback = c; +} + +void +LrWpanMacBase::SetMlmeStartConfirmCallback(MlmeStartConfirmCallback c) +{ + m_mlmeStartConfirmCallback = c; +} + +void +LrWpanMacBase::SetMlmeScanConfirmCallback(MlmeScanConfirmCallback c) +{ + m_mlmeScanConfirmCallback = c; +} + +void +LrWpanMacBase::SetMlmeAssociateConfirmCallback(MlmeAssociateConfirmCallback c) +{ + m_mlmeAssociateConfirmCallback = c; +} + +void +LrWpanMacBase::SetMlmeBeaconNotifyIndicationCallback(MlmeBeaconNotifyIndicationCallback c) +{ + m_mlmeBeaconNotifyIndicationCallback = c; +} + +void +LrWpanMacBase::SetMlmeSyncLossIndicationCallback(MlmeSyncLossIndicationCallback c) +{ + m_mlmeSyncLossIndicationCallback = c; +} + +void +LrWpanMacBase::SetMlmeSetConfirmCallback(MlmeSetConfirmCallback c) +{ + m_mlmeSetConfirmCallback = c; +} + +void +LrWpanMacBase::SetMlmeGetConfirmCallback(MlmeGetConfirmCallback c) +{ + m_mlmeGetConfirmCallback = c; +} + +void +LrWpanMacBase::SetMlmePollConfirmCallback(MlmePollConfirmCallback c) +{ + m_mlmePollConfirmCallback = c; +} + +} // namespace ns3 diff --git a/src/lr-wpan/model/lr-wpan-mac-base.h b/src/lr-wpan/model/lr-wpan-mac-base.h new file mode 100644 index 000000000..7e1bfd571 --- /dev/null +++ b/src/lr-wpan/model/lr-wpan-mac-base.h @@ -0,0 +1,1049 @@ +/* + * Copyright (c) 2023 Tokushima University, Japan. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Alberto Gallegos Ramonet + */ + +#ifndef LR_WPAN_MAC_BASE_H +#define LR_WPAN_MAC_BASE_H + +#include +#include +#include +#include +#include +#include +#include + +namespace ns3 +{ + +/** + * \ingroup lr-wpan + * + * table 80 of 802.15.4 + */ +enum LrWpanAddressMode +{ + NO_PANID_ADDR = 0, + ADDR_MODE_RESERVED = 1, + SHORT_ADDR = 2, + EXT_ADDR = 3 +}; + +/** + * \ingroup lr-wpan + * + * table 83 of 802.15.4 + */ +enum LrWpanAssociationStatus +{ + ASSOCIATED = 0, + PAN_AT_CAPACITY = 1, + PAN_ACCESS_DENIED = 2, + ASSOCIATED_WITHOUT_ADDRESS = 0xfe, + DISASSOCIATED = 0xff +}; + +/** + * \ingroup lr-wpan + * + * Table 30 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeScanType +{ + MLMESCAN_ED = 0x00, + MLMESCAN_ACTIVE = 0x01, + MLMESCAN_PASSIVE = 0x02, + MLMESCAN_ORPHAN = 0x03 +}; + +/** + * \ingroup lr-wpan + * + * MCPS-DATA.request params. See 7.1.1.1 + */ +struct McpsDataRequestParams +{ + LrWpanAddressMode m_srcAddrMode{SHORT_ADDR}; //!< Source address mode + LrWpanAddressMode m_dstAddrMode{SHORT_ADDR}; //!< Destination address mode + uint16_t m_dstPanId{0}; //!< Destination PAN identifier + Mac16Address m_dstAddr; //!< Destination address + Mac64Address m_dstExtAddr; //!< Destination extended address + uint8_t m_msduHandle{0}; //!< MSDU handle + uint8_t m_txOptions{0}; //!< Tx Options (bitfield) +}; + +/** + * \ingroup lr-wpan + * + * MLME-START.request params. See 802.15.4-2011 Section 6.2.12.1 + */ +struct MlmeStartRequestParams +{ + uint16_t m_PanId{0}; //!< Pan Identifier used by the device. + uint8_t m_logCh{11}; //!< Logical channel on which to start using the + //!< new superframe configuration. + uint32_t m_logChPage{0}; //!< Logical channel page on which to start using the + //!< new superframe configuration. + uint32_t m_startTime{0}; //!< Time at which to begin transmitting beacons (Used by Coordinator + //!< not PAN Coordinators). The time is specified in symbols. + uint8_t m_bcnOrd{15}; //!< Beacon Order, Used to calculate the beacon interval, a value of 15 + //!< indicates no periodic beacons will be transmitted. + uint8_t m_sfrmOrd{15}; //!< Superframe Order, indicates the length of the CAP in time slots. + bool m_panCoor{false}; //!< On true this device will become coordinator. + bool m_battLifeExt{false}; //!< Flag indicating whether or not the Battery life extension (BLE) + //!< features are used. + bool m_coorRealgn{false}; //!< True if a realignment request command is to be transmitted prior + //!< changing the superframe. +}; + +/** + * \ingroup lr-wpan + * + * MLME-SCAN.request params. See IEEE 802.15.4-2011 Section 6.2.10.1 Table 30 + */ +struct MlmeScanRequestParams +{ + LrWpanMlmeScanType m_scanType{MLMESCAN_PASSIVE}; //!< Indicates the type of scan performed as + //!< described in IEEE 802.15.4-2011 (5.1.2.1). + uint32_t m_scanChannels{0x7FFF800}; //!< The channel numbers to be scanned. + //!< Default: (0x7FFF800 = Ch11-Ch26) + //!< 27 LSB (b0,b1,...,b26) = channels + uint8_t m_scanDuration{14}; //!< The factor (0-14) used to calculate the length of time + //!< to spend scanning. + //!< scanDurationSymbols = + //!< [aBaseSuperframeDuration * (2^m_scanDuration + 1)]. + uint32_t m_chPage{0}; //!< The channel page on which to perform scan. +}; + +/** + * \ingroup lr-wpan + * + * MLME-ASSOCIATE.request params. See 802.15.4-2011 Section 6.2.2.1 + */ +struct MlmeAssociateRequestParams +{ + uint8_t m_chNum{11}; //!< The channel number on which to attempt association. + uint32_t m_chPage{0}; //!< The channel page on which to attempt association. + uint8_t m_coordAddrMode{SHORT_ADDR}; //!< The coordinator addressing mode for this + //!< primitive and subsequent MPDU. + uint16_t m_coordPanId{0}; //!< The identifier of the PAN with which to associate. + Mac16Address m_coordShortAddr; //!< The short address of the coordinator + //!< with which to associate. + Mac64Address m_coordExtAddr; //!< The extended address of the coordinator + //!< with which to associate. + uint8_t m_capabilityInfo{0}; //!< Specifies the operational capabilities + //!< of the associating device (bitmap). +}; + +/** + * \ingroup lr-wpan + * + * MLME-ASSOCIATE.response params. See 802.15.4-2011 6.2.2.3. + */ +struct MlmeAssociateResponseParams +{ + Mac64Address m_extDevAddr; //!< The extended address of the device requesting association + Mac16Address m_assocShortAddr; //!< The short address allocated by the coordinator on successful + //!< assoc. FF:FF = Unsuccessful + LrWpanAssociationStatus m_status{DISASSOCIATED}; //!< The status of the association attempt (As + //!< defined on Table 83 IEEE 802.15.4-2006) +}; + +/** + * \ingroup lr-wpan + * + * MLME-ORPHAN.response params. See 802.15.4-2011 Section 6.2.7.2 + */ +struct MlmeOrphanResponseParams +{ + Mac64Address m_orphanAddr; //!< The address of the orphaned device. + Mac16Address m_shortAddr; //!< The short address allocated. + bool m_assocMember{false}; //!< T = allocated with this coord | F = otherwise +}; + +/** + * \ingroup lr-wpan + * + * MLME-SYNC.request params. See 802.15.4-2011 Section 6.2.13.1 + */ +struct MlmeSyncRequestParams +{ + uint8_t m_logCh{11}; //!< The channel number on which to attempt coordinator synchronization. + bool m_trackBcn{false}; //!< True if the mlme sync with the next beacon and attempts to track + //!< future beacons. False if mlme sync only the next beacon. +}; + +/** + * \ingroup lr-wpan + * + * MLME-POLL.request params. See 802.15.4-2011 Section 6.2.14.1 + */ +struct MlmePollRequestParams +{ + LrWpanAddressMode m_coorAddrMode{SHORT_ADDR}; //!< The addressing mode of the coordinator + //!< to which the pool is intended. + uint16_t m_coorPanId{0}; //!< The PAN id of the coordinator to which the poll is intended. + Mac16Address m_coorShortAddr; //!< Coordinator short address. + Mac64Address m_coorExtAddr; //!< Coordinator extended address. +}; + +/** + * \ingroup lr-wpan + * + * IEEE802.15.4-2011 MAC PIB Attribute Identifiers Table 52 in section 6.4.2 + * + */ +enum LrWpanMacPibAttributeIdentifier +{ + macBeaconPayload = 0, + macBeaconPayloadLength = 1, + macShortAddress = 2, + macExtendedAddress = 3, + macPanId = 4, + pCurrentChannel = 100, + pCurrentPage = 101, + unsupported = 255 + // TODO: complete other MAC pib attributes +}; + +/** + * \ingroup lr-wpan + * + * IEEE802.15.4-2011 PHY PIB Attributes Table 52 in section 6.4.2 + */ +struct LrWpanMacPibAttributes : public SimpleRefCount +{ + Ptr macBeaconPayload; //!< The contents of the beacon payload. + uint8_t macBeaconPayloadLength{0}; //!< The length in octets of the beacon payload. + Mac16Address macShortAddress; //!< The 16 bit mac short address + Mac64Address macExtendedAddress; //!< The EUI-64 bit address + uint16_t macPanId{0xffff}; //!< The identifier of the PAN + uint8_t pCurrentChannel{11}; //!< The current logical channel in used in the PHY + uint8_t pCurrentPage{0}; //!< The current logical page in use in the PHY + // TODO: complete other MAC pib attributes +}; + +/** + * \ingroup lr-wpan + * + * Table 42 of 802.15.4-2006 + */ +enum LrWpanMcpsDataConfirmStatus +{ + IEEE_802_15_4_SUCCESS = 0, + IEEE_802_15_4_TRANSACTION_OVERFLOW = 1, + IEEE_802_15_4_TRANSACTION_EXPIRED = 2, + IEEE_802_15_4_CHANNEL_ACCESS_FAILURE = 3, + IEEE_802_15_4_INVALID_ADDRESS = 4, + IEEE_802_15_4_INVALID_GTS = 5, + IEEE_802_15_4_NO_ACK = 6, + IEEE_802_15_4_COUNTER_ERROR = 7, + IEEE_802_15_4_FRAME_TOO_LONG = 8, + IEEE_802_15_4_UNAVAILABLE_KEY = 9, + IEEE_802_15_4_UNSUPPORTED_SECURITY = 10, + IEEE_802_15_4_INVALID_PARAMETER = 11 +}; + +/** + * \ingroup lr-wpan + * + * MCPS-DATA.confirm params. See 7.1.1.2 + */ +struct McpsDataConfirmParams +{ + uint8_t m_msduHandle{0}; //!< MSDU handle + LrWpanMcpsDataConfirmStatus m_status{ + IEEE_802_15_4_INVALID_PARAMETER}; //!< The status + //!< of the last MSDU transmission +}; + +/** + * \ingroup lr-wpan + * + * MCPS-DATA.indication params. See 7.1.1.3 + */ +struct McpsDataIndicationParams +{ + uint8_t m_srcAddrMode{SHORT_ADDR}; //!< Source address mode + uint16_t m_srcPanId{0}; //!< Source PAN identifier + Mac16Address m_srcAddr; //!< Source address + Mac64Address m_srcExtAddr; //!< Source extended address + uint8_t m_dstAddrMode{SHORT_ADDR}; //!< Destination address mode + uint16_t m_dstPanId{0}; //!< Destination PAN identifier + Mac16Address m_dstAddr; //!< Destination address + Mac64Address m_dstExtAddr; //!< Destination extended address + uint8_t m_mpduLinkQuality{0}; //!< LQI value measured during reception of the MPDU + uint8_t m_dsn{0}; //!< The DSN of the received data frame +}; + +/** + * \ingroup lr-wpan + * + * MLME-ASSOCIATE.indication params. See 802.15.4-2011 6.2.2.2. + */ +struct MlmeAssociateIndicationParams +{ + Mac64Address m_extDevAddr; //!< The extended address of the device requesting association + uint8_t capabilityInfo{0}; //!< The operational capabilities of + //!< the device requesting association. + uint8_t lqi{0}; //!< The link quality indicator of the received associate request command + //!< (Not officially supported in the standard but found in implementations) +}; + +/** + * \ingroup lr-wpan + * + * Table 18 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeCommStatus +{ + MLMECOMMSTATUS_SUCCESS = 0, + MLMECOMMSTATUS_TRANSACTION_OVERFLOW = 1, + MLMECOMMSTATUS_TRANSACTION_EXPIRED = 2, + MLMECOMMSTATUS_CHANNEL_ACCESS_FAILURE = 3, + MLMECOMMSTATUS_NO_ACK = 4, + MLMECOMMSTATUS_COUNTER_ERROR = 5, + MLMECOMMSTATUS_FRAME_TOO_LONG = 6, + MLMECOMMSTATUS_INVALID_PARAMETER = 7 +}; + +/** + * \ingroup lr-wpan + * + * MLME-COMM-STATUS.indication params. See 802.15.4-2011 Section 6.2.4.2 Table 18 + */ +struct MlmeCommStatusIndicationParams +{ + uint16_t m_panId{0}; //!< The PAN identifier of the device from which the frame was received or + //!< to which the frame was being sent. + uint8_t m_srcAddrMode{SHORT_ADDR}; //!< The source addressing mode for this primitive + Mac16Address m_srcShortAddr; //!< The short address of the entity from which the frame causing + //!< the error originated. + Mac64Address m_srcExtAddr; //!< The extended address of the entity from which the frame causing + //!< the error originated. + uint8_t m_dstAddrMode{SHORT_ADDR}; //!< The destination addressing mode for this primitive. + Mac16Address m_dstShortAddr; //!< The short address of the device for + //!< which the frame was intended. + Mac64Address m_dstExtAddr; //!< The extended address of the device for + //!< which the frame was intended. + LrWpanMlmeCommStatus m_status{MLMECOMMSTATUS_INVALID_PARAMETER}; //!< The communication status +}; + +/** + * \ingroup lr-wpan + * + * MLME-ORPHAN.indication params. See 802.15.4-2011 Section 6.2.7.1 + */ +struct MlmeOrphanIndicationParams +{ + Mac64Address m_orphanAddr; //!< The address of the orphaned device. +}; + +/** + * \ingroup lr-wpan + * + * Table 35 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeStartConfirmStatus +{ + MLMESTART_SUCCESS = 0, + MLMESTART_NO_SHORT_ADDRESS = 1, + MLMESTART_SUPERFRAME_OVERLAP = 2, + MLMESTART_TRACKING_OFF = 3, + MLMESTART_INVALID_PARAMETER = 4, + MLMESTART_COUNTER_ERROR = 5, + MLMESTART_FRAME_TOO_LONG = 6, + MLMESTART_UNAVAILABLE_KEY = 7, + MLMESTART_UNSUPPORTED_SECURITY = 8, + MLMESTART_CHANNEL_ACCESS_FAILURE = 9 +}; + +/** + * \ingroup lr-wpan + * + * MLME-START.confirm params. See 802.15.4-2011 Section 6.2.12.2 + */ +struct MlmeStartConfirmParams +{ + LrWpanMlmeStartConfirmStatus m_status{MLMESTART_INVALID_PARAMETER}; //!< The status of + //!< a MLME-start.request +}; + +/** + * \ingroup lr-wpan + * + * Table 31 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeScanConfirmStatus +{ + MLMESCAN_SUCCESS = 0, + MLMESCAN_LIMIT_REACHED = 1, + MLMESCAN_NO_BEACON = 2, + MLMESCAN_SCAN_IN_PROGRESS = 3, + MLMESCAN_COUNTER_ERROR = 4, + MLMESCAN_FRAME_TOO_LONG = 5, + MLMESCAN_UNAVAILABLE_KEY = 6, + MLMESCAN_UNSUPPORTED_SECURITY = 7, + MLMESCAN_INVALID_PARAMETER = 8 +}; + +/** + * \ingroup lr-wpan + * + * PAN Descriptor, Table 17 IEEE 802.15.4-2011 + */ +struct PanDescriptor +{ + LrWpanAddressMode m_coorAddrMode{SHORT_ADDR}; //!< The coordinator addressing mode corresponding + //!< to the received beacon frame. + uint16_t m_coorPanId{0xffff}; //!< The PAN ID of the coordinator as specified in + //!< the received beacon frame. + Mac16Address m_coorShortAddr; //!< The coordinator short address as specified in the coordinator + //!< address mode. + Mac64Address m_coorExtAddr; //!< The coordinator extended address as specified in the + //!< coordinator address mode. + uint8_t m_logCh{11}; //!< The current channel number occupied by the network. + uint8_t m_logChPage{0}; //!< The current channel page occupied by the network. + uint16_t m_superframeSpec{0}; //!< The superframe specification as specified in the received + //!< beacon frame. + bool m_gtsPermit{false}; //!< TRUE if the beacon is from the PAN coordinator + //!< that is accepting GTS requests. + uint8_t m_linkQuality{0}; //!< The LQI at which the network beacon was received. + //!< Lower values represent lower LQI. + Time m_timeStamp; //!< Beacon frame reception time. Used as Time data type in ns-3 to avoid + //!< precision problems. +}; + +/** + * \ingroup lr-wpan + * + * MLME-SCAN.confirm params. See IEEE 802.15.4-2011 Section 6.2.10.2 + */ +struct MlmeScanConfirmParams +{ + LrWpanMlmeScanConfirmStatus m_status{MLMESCAN_INVALID_PARAMETER}; //!< The status the request. + LrWpanMlmeScanType m_scanType{MLMESCAN_PASSIVE}; //!< Indicates the type of scan + //!< performed (ED,ACTIVE,PASSIVE,ORPHAN). + uint32_t m_chPage{0}; //!< The channel page on which the scan was performed. + std::vector m_unscannedCh; //!< A list of channels given in the request which + //!< were not scanned (Not valid for ED scans). + uint8_t m_resultListSize{0}; //!< The number of elements returned in the appropriate + //!< result list. (Not valid for Orphan scan). + std::vector m_energyDetList; //!< A list of energy measurements, one for each + //!< channel searched during ED scan + //!< (Not valid for Active, Passive or Orphan Scans) + std::vector m_panDescList; //!< A list of PAN descriptor, one for each beacon + //!< found (Not valid for ED and Orphan scans). +}; + +/** + * \ingroup lr-wpan + * + * Table 12 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeAssociateConfirmStatus +{ + MLMEASSOC_SUCCESS = 0, + MLMEASSOC_FULL_CAPACITY = 1, + MLMEASSOC_ACCESS_DENIED = 2, + MLMEASSOC_CHANNEL_ACCESS_FAILURE = 3, + MLMEASSOC_NO_ACK = 4, + MLMEASSOC_NO_DATA = 5, + MLMEASSOC_COUNTER_ERROR = 6, + MLMEASSOC_FRAME_TOO_LONG = 7, + MLMEASSOC_UNSUPPORTED_LEGACY = 8, + MLMEASSOC_INVALID_PARAMETER = 9 +}; + +/** + * \ingroup lr-wpan + * + * MLME-ASSOCIATE.confirm params. See 802.15.4-2011 Section 6.2.2.4 + */ +struct MlmeAssociateConfirmParams +{ + Mac16Address m_assocShortAddr; //!< The short address used in the association request + LrWpanMlmeAssociateConfirmStatus m_status{MLMEASSOC_INVALID_PARAMETER}; + //!< The status of a MLME-associate.request +}; + +/** + * \ingroup lr-wpan + * + * MLME-BEACON-NOTIFY.indication params. See 802.15.4-2011 Section 6.2.4.1, Table 16 + */ +struct MlmeBeaconNotifyIndicationParams +{ + uint8_t m_bsn{0}; //!< The beacon sequence number. + PanDescriptor m_panDescriptor; //!< The PAN descriptor for the received beacon. + uint32_t m_sduLength{0}; //!< The number of octets contained in the beacon payload. + Ptr m_sdu; //!< The set of octets comprising the beacon payload. +}; + +/** + * \ingroup lr-wpan + * + * Table 37 of IEEE 802.15.4-2011 + */ +enum LrWpanSyncLossReason +{ + MLMESYNCLOSS_PAN_ID_CONFLICT = 0, + MLMESYNCLOSS_REALIGMENT = 1, + MLMESYNCLOSS_BEACON_LOST = 2, + MLMESYNCLOSS_SUPERFRAME_OVERLAP = 3 +}; + +/** + * \ingroup lr-wpan + * + * MLME-SYNC-LOSS.indication params. See 802.15.4-2011 Section 6.2.13.2, Table 37 + */ +struct MlmeSyncLossIndicationParams +{ + LrWpanSyncLossReason m_lossReason{MLMESYNCLOSS_PAN_ID_CONFLICT}; //!< The reason for the lost + //!< of synchronization. + uint16_t m_panId{0}; //!< The PAN identifier with which the device lost synchronization or to + //!< which it was realigned. + uint8_t m_logCh{11}; //!< The channel number on which the device lost synchronization or to + //!< which it was realigned. +}; + +/** + * \ingroup lr-wpan + * + * Table 33 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeSetConfirmStatus +{ + MLMESET_SUCCESS = 0, + MLMESET_READ_ONLY = 1, + MLMESET_UNSUPPORTED_ATTRIBUTE = 2, + MLMESET_INVALID_INDEX = 3, + MLMESET_INVALID_PARAMETER = 4 +}; + +/** + * \ingroup lr-wpan + * + * Table 20 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmeGetConfirmStatus +{ + MLMEGET_SUCCESS = 0, + MLMEGET_UNSUPPORTED_ATTRIBUTE = 1 +}; + +/** + * \ingroup lr-wpan + * + * MLME-SET.confirm params. See 802.15.4-2011 Section 6.2.11.2 + */ +struct MlmeSetConfirmParams +{ + LrWpanMlmeSetConfirmStatus m_status{MLMESET_UNSUPPORTED_ATTRIBUTE}; //!< The result of + //!< the request to write + //!< the PIB attribute. + LrWpanMacPibAttributeIdentifier id; //!< The id of the PIB attribute that was written. +}; + +/** + * \ingroup lr-wpan + * + * Table 39 of IEEE 802.15.4-2011 + */ +enum LrWpanMlmePollConfirmStatus +{ + MLMEPOLL_SUCCESS = 0, + MLMEPOLL_CHANNEL_ACCESS_FAILURE = 2, + MLMEPOLL_NO_ACK = 3, + MLMEPOLL_NO_DATA = 4, + MLMEPOLL_COUNTER_ERROR = 5, + MLMEPOLL_FRAME_TOO_LONG = 6, + MLMEPOLL_UNAVAILABLE_KEY = 7, + MLMEPOLL_UNSUPPORTED_SECURITY = 8, + MLMEPOLL_INVALID_PARAMETER = 9 +}; + +/** + * \ingroup lr-wpan + * + * MLME-START.confirm params. See 802.15.4-2011 Section 6.2.14.2 + */ +struct MlmePollConfirmParams +{ + LrWpanMlmePollConfirmStatus m_status{MLMEPOLL_INVALID_PARAMETER}; //!< The confirmation + //!< status resulting from a + //!< MLME-poll.request. +}; + +/** + * \ingroup lr-wpan + * + * This callback is called after a McpsDataRequest has been called from + * the higher layer. It returns a status of the outcome of the + * transmission request + */ +using McpsDataConfirmCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called after a Mcps has successfully received a + * frame and wants to deliver it to the higher layer. + * + * \todo for now, we do not deliver all of the parameters in section + * 802.15.4-2006 7.1.1.3.1 but just send up the packet. + */ +using McpsDataIndicationCallback = Callback>; + +/** + * \ingroup lr-wpan + * + * This callback is called after a Mlme has successfully received a command + * frame and wants to deliver it to the higher layer. + * + * Security related parameters and not handle. + * See 802.15.4-2011 6.2.2.2. + */ +using MlmeAssociateIndicationCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called by the MLME and issued to its next higher layer following + * a transmission instigated through a response primitive. + * + * Security related parameters and not handle. + * See 802.15.4-2011 6.2.4.2 + */ +using MlmeCommStatusIndicationCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called by the MLME and issued to its next higher layer following + * the reception of a orphan notification. + * + * Security related parameters and not handle. + * See 802.15.4-2011 6.2.7.1 + */ +using MlmeOrphanIndicationCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called after a MlmeStartRequest has been called from + * the higher layer. It returns a status of the outcome of the + * transmission request + */ +using MlmeStartConfirmCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called after a MlmeScanRequest has been called from + * the higher layer. It returns a status of the outcome of the scan. + */ +using MlmeScanConfirmCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called after a MlmeAssociateRequest has been called from + * the higher layer. It returns a status of the outcome of the + * association request + */ +using MlmeAssociateConfirmCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called after a Mlme has successfully received a + * beacon frame and wants to deliver it to the higher layer. + * + * \todo for now, we do not deliver all of the parameters in section + * 802.15.4-2006 6.2.4.1 but just send up the packet. + */ +using MlmeBeaconNotifyIndicationCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called to indicate the loss of synchronization with + * a coordinator. + * + * \todo for now, we do not deliver all of the parameters in section + * See IEEE 802.15.4-2011 6.2.13.2. + */ +using MlmeSyncLossIndicationCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called after a MlmeSetRequest has been called from + * the higher layer to set a PIB. It returns a status of the outcome of the + * write attempt. + */ +using MlmeSetConfirmCallback = Callback; + +/** + * \ingroup lr-wpan + * + * This callback is called after a MlmeGetRequest has been called from + * the higher layer to get a PIB. It returns a status of the outcome of the + * write attempt. + */ +using MlmeGetConfirmCallback = Callback>; + +/** + * \ingroup lr-wpan + * + * This callback is called after a Mlme-Poll.Request has been called from + * the higher layer. It returns a status of the outcome of the + * transmission request + */ +using MlmePollConfirmCallback = Callback; + +/** + * \ingroup netdevice + * + * \brief Lr-wpan MAC layer abstraction + * + * This class defines the interface functions (primitives) used by a IEEE 802.15.4-2011 compliant + * MAC layer. Any lr-wpan MAC should extend from this class and implement the + * behavior of the basic MAC interfaces (primitives). + * + */ +class LrWpanMacBase : public Object +{ + public: + /** + * \brief Get the type ID. + * \return the object TypeId + */ + static TypeId GetTypeId(); + ~LrWpanMacBase() override; + + /** + * IEEE 802.15.4-2006, section 7.1.1.1 + * MCPS-DATA.request + * Request to transfer a MSDU. + * + * \param params the request parameters + * \param p the packet to be transmitted + */ + virtual void McpsDataRequest(McpsDataRequestParams params, Ptr p) = 0; + + /** + * IEEE 802.15.4-2006, section 7.1.14.1 + * MLME-START.request + * Request to allow a PAN coordinator to initiate + * a new PAN or beginning a new superframe configuration. + * + * \param params the request parameters + */ + virtual void MlmeStartRequest(MlmeStartRequestParams params) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.10.1 + * MLME-SCAN.request + * Request primitive used to initiate a channel scan over a given list of channels. + * + * \param params the scan request parameters + */ + virtual void MlmeScanRequest(MlmeScanRequestParams params) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.2.1 + * MLME-ASSOCIATE.request + * Request primitive used by a device to request an association with + * a coordinator. + * + * \param params the request parameters + */ + virtual void MlmeAssociateRequest(MlmeAssociateRequestParams params) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.2.3 + * MLME-ASSOCIATE.response + * Primitive used to initiate a response to an MLME-ASSOCIATE.indication + * primitive. + * + * \param params the associate response parameters + */ + virtual void MlmeAssociateResponse(MlmeAssociateResponseParams params) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.13.1 + * MLME-SYNC.request + * Request to synchronize with the coordinator by acquiring and, + * if specified, tracking beacons. + * + * \param params the request parameters + */ + virtual void MlmeSyncRequest(MlmeSyncRequestParams params) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.14.2 + * MLME-POLL.request + * Prompts the device to request data from the coordinator. + * + * \param params the request parameters + */ + virtual void MlmePollRequest(MlmePollRequestParams params) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.7.2 + * MLME-ORPHAN.response + * Primitive used to initiatte a response to an MLME-ORPHAN.indication + * primitive. + * + * \param params the orphan response parameters + */ + virtual void MlmeOrphanResponse(MlmeOrphanResponseParams params) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.11.1 + * MLME-SET.request + * Attempts to write the given value to the indicated PIB attribute. + * + * \param id the attributed identifier + * \param attribute the attribute value + */ + virtual void MlmeSetRequest(LrWpanMacPibAttributeIdentifier id, + Ptr attribute) = 0; + + /** + * IEEE 802.15.4-2011, section 6.2.5.1 + * MLME-GET.request + * Request information about a given PIB attribute. + * + * \param id the attribute identifier + */ + virtual void MlmeGetRequest(LrWpanMacPibAttributeIdentifier id) = 0; + + /** + * Set the callback for the confirmation of a data transmission request. + * The callback implements MCPS-DATA.confirm SAP of IEEE 802.15.4-2006, + * section 7.1.1.2. + * + * \param c the callback + */ + void SetMcpsDataConfirmCallback(McpsDataConfirmCallback c); + + /** + * Set the callback for the indication of an incoming data packet. + * The callback implements MCPS-DATA.indication SAP of IEEE 802.15.4-2006, + * section 7.1.1.3. + * + * \param c the callback + */ + void SetMcpsDataIndicationCallback(McpsDataIndicationCallback c); + + /** + * Set the callback for the indication of an incoming associate request command. + * The callback implements MLME-ASSOCIATE.indication SAP of IEEE 802.15.4-2011, + * section 6.2.2.2. + * + * \param c the callback + */ + void SetMlmeAssociateIndicationCallback(MlmeAssociateIndicationCallback c); + + /** + * Set the callback for the indication to a response primitive. + * The callback implements MLME-COMM-STATUS.indication SAP of IEEE 802.15.4-2011, + * section 6.2.4.2. + * + * \param c the callback + */ + void SetMlmeCommStatusIndicationCallback(MlmeCommStatusIndicationCallback c); + + /** + * Set the callback for the indication to the reception of an orphan notification. + * The callback implements MLME-ORPHAN.indication SAP of IEEE 802.15.4-2011, + * section 6.2.7.1. + * + * \param c the callback + */ + void SetMlmeOrphanIndicationCallback(MlmeOrphanIndicationCallback c); + + /** + * Set the callback for the confirmation of a data transmission request. + * The callback implements MLME-START.confirm SAP of IEEE 802.15.4-2006, + * section 7.1.14.2. + * + * \param c the callback + */ + void SetMlmeStartConfirmCallback(MlmeStartConfirmCallback c); + + /** + * Set the callback for the confirmation of a data transmission request. + * The callback implements MLME-SCAN.confirm SAP of IEEE 802.15.4-2011, + * section 6.2.10.2. + * + * \param c the callback + */ + void SetMlmeScanConfirmCallback(MlmeScanConfirmCallback c); + + /** + * Set the callback for the confirmation of a data transmission request. + * The callback implements MLME-ASSOCIATE.confirm SAP of IEEE 802.15.4-2011, + * section 6.2.2.4. + * + * \param c the callback + */ + void SetMlmeAssociateConfirmCallback(MlmeAssociateConfirmCallback c); + + /** + * Set the callback for the indication of an incoming beacon packet. + * The callback implements MLME-BEACON-NOTIFY.indication SAP of IEEE 802.15.4-2011, + * section 6.2.4.1. + * + * \param c the callback + */ + void SetMlmeBeaconNotifyIndicationCallback(MlmeBeaconNotifyIndicationCallback c); + + /** + * Set the callback for the loss of synchronization with a coordinator. + * The callback implements MLME-SYNC-LOSS.indication SAP of IEEE 802.15.4-2011, + * section 6.2.13.2. + * + * \param c the callback + */ + void SetMlmeSyncLossIndicationCallback(MlmeSyncLossIndicationCallback c); + + /** + * Set the callback for the confirmation of an attempt to write an attribute. + * The callback implements MLME-SET.confirm SAP of IEEE 802.15.4-2011, + * section 6.2.11.2 + * + * \param c the callback + */ + void SetMlmeSetConfirmCallback(MlmeSetConfirmCallback c); + + /** + * Set the callback for the confirmation of an attempt to read an attribute. + * The callback implements MLME-GET.confirm SAP of IEEE 802.15.4-2011, + * section 6.2.5.2 + * + *\param c the callback + */ + void SetMlmeGetConfirmCallback(MlmeGetConfirmCallback c); + + /** + * Set the callback for the confirmation of a data transmission request. + * The callback implements MLME-POLL.confirm SAP of IEEE 802.15.4-2011, + * section 6.2.14.2 + * + * \param c the callback + */ + void SetMlmePollConfirmCallback(MlmePollConfirmCallback c); + + protected: + /** + * This callback is used to report data transmission request status to the + * upper layers. + * See IEEE 802.15.4-2006, section 7.1.1.2. + */ + McpsDataConfirmCallback m_mcpsDataConfirmCallback; + + /** + * This callback is used to notify incoming packets to the upper layers. + * See IEEE 802.15.4-2006, section 7.1.1.3. + */ + McpsDataIndicationCallback m_mcpsDataIndicationCallback; + + /** + * This callback is used to indicate the reception of an association request command. + * See IEEE 802.15.4-2011, section 6.2.2.2 + */ + MlmeAssociateIndicationCallback m_mlmeAssociateIndicationCallback; + + /** + * This callback is instigated through a response primitive. + * See IEEE 802.15.4-2011, section 6.2.4.2 + */ + MlmeCommStatusIndicationCallback m_mlmeCommStatusIndicationCallback; + + /** + * This callback is used to indicate the reception of a orphan notification command. + * See IEEE 802.15.4-2011, section 6.2.7.1 + */ + MlmeOrphanIndicationCallback m_mlmeOrphanIndicationCallback; + + /** + * This callback is used to report the start of a new PAN or + * the begin of a new superframe configuration. + * See IEEE 802.15.4-2006, section 7.1.14.2. + */ + MlmeStartConfirmCallback m_mlmeStartConfirmCallback; + + /** + * This callback is used to report the result of a scan on a group of channels for the + * selected channel page. + * See IEEE 802.15.4-2011, section 6.2.10.2. + */ + MlmeScanConfirmCallback m_mlmeScanConfirmCallback; + + /** + * This callback is used to report the status after a device request an association with + * a coordinator. + * See IEEE 802.15.4-2011, section 6.2.2.4. + */ + MlmeAssociateConfirmCallback m_mlmeAssociateConfirmCallback; + + /** + * This callback is used to notify incoming beacon packets to the upper layers. + * See IEEE 802.15.4-2011, section 6.2.4.1. + */ + MlmeBeaconNotifyIndicationCallback m_mlmeBeaconNotifyIndicationCallback; + + /** + * This callback is used to indicate the loss of synchronization with a coordinator. + * See IEEE 802.15.4-2011, section 6.2.13.2. + */ + MlmeSyncLossIndicationCallback m_mlmeSyncLossIndicationCallback; + + /** + * This callback is used to report the result of an attribute writing request + * to the upper layers. + * See IEEE 802.15.4-2011, section 6.2.11.2. + */ + MlmeSetConfirmCallback m_mlmeSetConfirmCallback; + + /** + * This callback is used to report the result of an attribute read request + * to the upper layers. + * See IEEE 802.15.4-2011, section 6.2.5.2 + */ + MlmeGetConfirmCallback m_mlmeGetConfirmCallback; + + /** + * This callback is used to report the status after a device send data command request to + * the coordinator to transmit data. + * See IEEE 802.15.4-2011, section 6.2.14.2. + */ + MlmePollConfirmCallback m_mlmePollConfirmCallback; +}; + +} // namespace ns3 + +#endif /* LR_WPAN_MAC_BASE_H*/ diff --git a/src/lr-wpan/model/lr-wpan-mac.cc b/src/lr-wpan/model/lr-wpan-mac.cc index 24a4a1863..18fa11b95 100644 --- a/src/lr-wpan/model/lr-wpan-mac.cc +++ b/src/lr-wpan/model/lr-wpan-mac.cc @@ -53,7 +53,7 @@ LrWpanMac::GetTypeId() { static TypeId tid = TypeId("ns3::LrWpanMac") - .SetParent() + .SetParent() .SetGroupName("LrWpan") .AddConstructor() .AddAttribute("PanId", @@ -1782,84 +1782,6 @@ LrWpanMac::GetPhy() return m_phy; } -void -LrWpanMac::SetMcpsDataIndicationCallback(McpsDataIndicationCallback c) -{ - m_mcpsDataIndicationCallback = c; -} - -void -LrWpanMac::SetMlmeAssociateIndicationCallback(MlmeAssociateIndicationCallback c) -{ - m_mlmeAssociateIndicationCallback = c; -} - -void -LrWpanMac::SetMlmeCommStatusIndicationCallback(MlmeCommStatusIndicationCallback c) -{ - m_mlmeCommStatusIndicationCallback = c; -} - -void -LrWpanMac::SetMlmeOrphanIndicationCallback(MlmeOrphanIndicationCallback c) -{ - m_mlmeOrphanIndicationCallback = c; -} - -void -LrWpanMac::SetMcpsDataConfirmCallback(McpsDataConfirmCallback c) -{ - m_mcpsDataConfirmCallback = c; -} - -void -LrWpanMac::SetMlmeStartConfirmCallback(MlmeStartConfirmCallback c) -{ - m_mlmeStartConfirmCallback = c; -} - -void -LrWpanMac::SetMlmeScanConfirmCallback(MlmeScanConfirmCallback c) -{ - m_mlmeScanConfirmCallback = c; -} - -void -LrWpanMac::SetMlmeAssociateConfirmCallback(MlmeAssociateConfirmCallback c) -{ - m_mlmeAssociateConfirmCallback = c; -} - -void -LrWpanMac::SetMlmeBeaconNotifyIndicationCallback(MlmeBeaconNotifyIndicationCallback c) -{ - m_mlmeBeaconNotifyIndicationCallback = c; -} - -void -LrWpanMac::SetMlmeSyncLossIndicationCallback(MlmeSyncLossIndicationCallback c) -{ - m_mlmeSyncLossIndicationCallback = c; -} - -void -LrWpanMac::SetMlmePollConfirmCallback(MlmePollConfirmCallback c) -{ - m_mlmePollConfirmCallback = c; -} - -void -LrWpanMac::SetMlmeSetConfirmCallback(MlmeSetConfirmCallback c) -{ - m_mlmeSetConfirmCallback = c; -} - -void -LrWpanMac::SetMlmeGetConfirmCallback(MlmeGetConfirmCallback c) -{ - m_mlmeGetConfirmCallback = c; -} - void LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) { diff --git a/src/lr-wpan/model/lr-wpan-mac.h b/src/lr-wpan/model/lr-wpan-mac.h index f0b4bab26..8e5ad15c8 100644 --- a/src/lr-wpan/model/lr-wpan-mac.h +++ b/src/lr-wpan/model/lr-wpan-mac.h @@ -26,12 +26,10 @@ #define LR_WPAN_MAC_H #include "lr-wpan-fields.h" +#include "lr-wpan-mac-base.h" #include "lr-wpan-phy.h" #include -#include -#include -#include #include #include #include @@ -145,705 +143,12 @@ typedef void (*SuperframeStatus)(SuperframeStatus oldValue, SuperframeStatus new } // namespace TracedValueCallback -/** - * \ingroup lr-wpan - * - * table 80 of 802.15.4 - */ -enum LrWpanAddressMode -{ - NO_PANID_ADDR = 0, - ADDR_MODE_RESERVED = 1, - SHORT_ADDR = 2, - EXT_ADDR = 3 -}; - -/** - * \ingroup lr-wpan - * - * table 83 of 802.15.4 - */ -enum LrWpanAssociationStatus -{ - ASSOCIATED = 0, - PAN_AT_CAPACITY = 1, - PAN_ACCESS_DENIED = 2, - ASSOCIATED_WITHOUT_ADDRESS = 0xfe, - DISASSOCIATED = 0xff -}; - -/** - * \ingroup lr-wpan - * - * Table 30 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmeScanType -{ - MLMESCAN_ED = 0x00, - MLMESCAN_ACTIVE = 0x01, - MLMESCAN_PASSIVE = 0x02, - MLMESCAN_ORPHAN = 0x03 -}; - -/** - * \ingroup lr-wpan - * - * Table 42 of 802.15.4-2006 - */ -enum LrWpanMcpsDataConfirmStatus -{ - IEEE_802_15_4_SUCCESS = 0, - IEEE_802_15_4_TRANSACTION_OVERFLOW = 1, - IEEE_802_15_4_TRANSACTION_EXPIRED = 2, - IEEE_802_15_4_CHANNEL_ACCESS_FAILURE = 3, - IEEE_802_15_4_INVALID_ADDRESS = 4, - IEEE_802_15_4_INVALID_GTS = 5, - IEEE_802_15_4_NO_ACK = 6, - IEEE_802_15_4_COUNTER_ERROR = 7, - IEEE_802_15_4_FRAME_TOO_LONG = 8, - IEEE_802_15_4_UNAVAILABLE_KEY = 9, - IEEE_802_15_4_UNSUPPORTED_SECURITY = 10, - IEEE_802_15_4_INVALID_PARAMETER = 11 -}; - -/** - * \ingroup lr-wpan - * - * Table 35 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmeStartConfirmStatus -{ - MLMESTART_SUCCESS = 0, - MLMESTART_NO_SHORT_ADDRESS = 1, - MLMESTART_SUPERFRAME_OVERLAP = 2, - MLMESTART_TRACKING_OFF = 3, - MLMESTART_INVALID_PARAMETER = 4, - MLMESTART_COUNTER_ERROR = 5, - MLMESTART_FRAME_TOO_LONG = 6, - MLMESTART_UNAVAILABLE_KEY = 7, - MLMESTART_UNSUPPORTED_SECURITY = 8, - MLMESTART_CHANNEL_ACCESS_FAILURE = 9 -}; - -/** - * \ingroup lr-wpan - * - * Table 31 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmeScanConfirmStatus -{ - MLMESCAN_SUCCESS = 0, - MLMESCAN_LIMIT_REACHED = 1, - MLMESCAN_NO_BEACON = 2, - MLMESCAN_SCAN_IN_PROGRESS = 3, - MLMESCAN_COUNTER_ERROR = 4, - MLMESCAN_FRAME_TOO_LONG = 5, - MLMESCAN_UNAVAILABLE_KEY = 6, - MLMESCAN_UNSUPPORTED_SECURITY = 7, - MLMESCAN_INVALID_PARAMETER = 8 -}; - -/** - * \ingroup lr-wpan - * - * Table 12 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmeAssociateConfirmStatus -{ - MLMEASSOC_SUCCESS = 0, - MLMEASSOC_FULL_CAPACITY = 1, - MLMEASSOC_ACCESS_DENIED = 2, - MLMEASSOC_CHANNEL_ACCESS_FAILURE = 3, - MLMEASSOC_NO_ACK = 4, - MLMEASSOC_NO_DATA = 5, - MLMEASSOC_COUNTER_ERROR = 6, - MLMEASSOC_FRAME_TOO_LONG = 7, - MLMEASSOC_UNSUPPORTED_LEGACY = 8, - MLMEASSOC_INVALID_PARAMETER = 9 -}; - -/** - * \ingroup lr-wpan - * - * Table 37 of IEEE 802.15.4-2011 - */ -enum LrWpanSyncLossReason -{ - MLMESYNCLOSS_PAN_ID_CONFLICT = 0, - MLMESYNCLOSS_REALIGMENT = 1, - MLMESYNCLOSS_BEACON_LOST = 2, - MLMESYNCLOSS_SUPERFRAME_OVERLAP = 3 -}; - -/** - * \ingroup lr-wpan - * - * Table 18 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmeCommStatus -{ - MLMECOMMSTATUS_SUCCESS = 0, - MLMECOMMSTATUS_TRANSACTION_OVERFLOW = 1, - MLMECOMMSTATUS_TRANSACTION_EXPIRED = 2, - MLMECOMMSTATUS_CHANNEL_ACCESS_FAILURE = 3, - MLMECOMMSTATUS_NO_ACK = 4, - MLMECOMMSTATUS_COUNTER_ERROR = 5, - MLMECOMMSTATUS_FRAME_TOO_LONG = 6, - MLMECOMMSTATUS_INVALID_PARAMETER = 7 -}; - -/** - * \ingroup lr-wpan - * - * Table 39 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmePollConfirmStatus -{ - MLMEPOLL_SUCCESS = 0, - MLMEPOLL_CHANNEL_ACCESS_FAILURE = 2, - MLMEPOLL_NO_ACK = 3, - MLMEPOLL_NO_DATA = 4, - MLMEPOLL_COUNTER_ERROR = 5, - MLMEPOLL_FRAME_TOO_LONG = 6, - MLMEPOLL_UNAVAILABLE_KEY = 7, - MLMEPOLL_UNSUPPORTED_SECURITY = 8, - MLMEPOLL_INVALID_PARAMETER = 9 -}; - -/** - * \ingroup lr-wpan - * - * Table 33 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmeSetConfirmStatus -{ - MLMESET_SUCCESS = 0, - MLMESET_READ_ONLY = 1, - MLMESET_UNSUPPORTED_ATTRIBUTE = 2, - MLMESET_INVALID_INDEX = 3, - MLMESET_INVALID_PARAMETER = 4 -}; - -/** - * \ingroup lr-wpan - * - * Table 20 of IEEE 802.15.4-2011 - */ -enum LrWpanMlmeGetConfirmStatus -{ - MLMEGET_SUCCESS = 0, - MLMEGET_UNSUPPORTED_ATTRIBUTE = 1 -}; - -/** - * \ingroup lr-wpan - * - * IEEE802.15.4-2011 MAC PIB Attribute Identifiers Table 52 in section 6.4.2 - * - */ -enum LrWpanMacPibAttributeIdentifier -{ - macBeaconPayload = 0, - macBeaconPayloadLength = 1, - macShortAddress = 2, - macExtendedAddress = 3, - macPanId = 4, - pCurrentChannel = 100, - pCurrentPage = 101, - unsupported = 255 - // TODO: complete other MAC pib attributes -}; - -/** - * \ingroup lr-wpan - * - * IEEE802.15.4-2011 PHY PIB Attributes Table 52 in section 6.4.2 - */ -struct LrWpanMacPibAttributes : public SimpleRefCount -{ - Ptr macBeaconPayload; //!< The contents of the beacon payload. - uint8_t macBeaconPayloadLength{0}; //!< The length in octets of the beacon payload. - Mac16Address macShortAddress; //!< The 16 bit mac short address - Mac64Address macExtendedAddress; //!< The EUI-64 bit address - uint16_t macPanId{0xffff}; //!< The identifier of the PAN - uint8_t pCurrentChannel{11}; //!< The current logical channel in used in the PHY - uint8_t pCurrentPage{0}; //!< The current logical page in use in the PHY - // TODO: complete other MAC pib attributes -}; - -/** - * \ingroup lr-wpan - * - * PAN Descriptor, Table 17 IEEE 802.15.4-2011 - */ -struct PanDescriptor -{ - LrWpanAddressMode m_coorAddrMode{SHORT_ADDR}; //!< The coordinator addressing mode corresponding - //!< to the received beacon frame. - uint16_t m_coorPanId{0xffff}; //!< The PAN ID of the coordinator as specified in - //!< the received beacon frame. - Mac16Address m_coorShortAddr; //!< The coordinator short address as specified in the coordinator - //!< address mode. - Mac64Address m_coorExtAddr; //!< The coordinator extended address as specified in the - //!< coordinator address mode. - uint8_t m_logCh{11}; //!< The current channel number occupied by the network. - uint8_t m_logChPage{0}; //!< The current channel page occupied by the network. - uint16_t m_superframeSpec{0}; //!< The superframe specification as specified in the received - //!< beacon frame. - bool m_gtsPermit{false}; //!< TRUE if the beacon is from the PAN coordinator - //!< that is accepting GTS requests. - uint8_t m_linkQuality{0}; //!< The LQI at which the network beacon was received. - //!< Lower values represent lower LQI. - Time m_timeStamp; //!< Beacon frame reception time. Used as Time data type in ns-3 to avoid - //!< precision problems. -}; - -/** - * \ingroup lr-wpan - * - * MCPS-DATA.request params. See 7.1.1.1 - */ -struct McpsDataRequestParams -{ - LrWpanAddressMode m_srcAddrMode{SHORT_ADDR}; //!< Source address mode - LrWpanAddressMode m_dstAddrMode{SHORT_ADDR}; //!< Destination address mode - uint16_t m_dstPanId{0}; //!< Destination PAN identifier - Mac16Address m_dstAddr; //!< Destination address - Mac64Address m_dstExtAddr; //!< Destination extended address - uint8_t m_msduHandle{0}; //!< MSDU handle - uint8_t m_txOptions{0}; //!< Tx Options (bitfield) -}; - -/** - * \ingroup lr-wpan - * - * MCPS-DATA.confirm params. See 7.1.1.2 - */ -struct McpsDataConfirmParams -{ - uint8_t m_msduHandle{0}; //!< MSDU handle - LrWpanMcpsDataConfirmStatus m_status{ - IEEE_802_15_4_INVALID_PARAMETER}; //!< The status of the last MSDU transmission -}; - -/** - * \ingroup lr-wpan - * - * MCPS-DATA.indication params. See 7.1.1.3 - */ -struct McpsDataIndicationParams -{ - uint8_t m_srcAddrMode{SHORT_ADDR}; //!< Source address mode - uint16_t m_srcPanId{0}; //!< Source PAN identifier - Mac16Address m_srcAddr; //!< Source address - Mac64Address m_srcExtAddr; //!< Source extended address - uint8_t m_dstAddrMode{SHORT_ADDR}; //!< Destination address mode - uint16_t m_dstPanId{0}; //!< Destination PAN identifier - Mac16Address m_dstAddr; //!< Destination address - Mac64Address m_dstExtAddr; //!< Destination extended address - uint8_t m_mpduLinkQuality{0}; //!< LQI value measured during reception of the MPDU - uint8_t m_dsn{0}; //!< The DSN of the received data frame -}; - -/** - * \ingroup lr-wpan - * - * MLME-ASSOCIATE.indication params. See 802.15.4-2011 6.2.2.2. - */ -struct MlmeAssociateIndicationParams -{ - Mac64Address m_extDevAddr; //!< The extended address of the device requesting association - uint8_t capabilityInfo; //!< The operational capabilities of - //!< the device requesting association. - uint8_t lqi{0}; //!< The link quality indicator of the received associate request command - //!< (Not officially supported in the standard but found in implementations) -}; - -/** - * \ingroup lr-wpan - * - * MLME-ASSOCIATE.response params. See 802.15.4-2011 6.2.2.3. - */ -struct MlmeAssociateResponseParams -{ - Mac64Address m_extDevAddr; //!< The extended address of the device requesting association - Mac16Address m_assocShortAddr; //!< The short address allocated by the coordinator on successful - //!< assoc. FF:FF = Unsuccessful - LrWpanAssociationStatus m_status{DISASSOCIATED}; //!< The status of the association attempt (As - //!< defined on Table 83 IEEE 802.15.4-2006) -}; - -/** - * \ingroup lr-wpan - * - * MLME-START.request params. See 802.15.4-2011 Section 6.2.12.1 - */ -struct MlmeStartRequestParams -{ - uint16_t m_PanId{0}; //!< Pan Identifier used by the device. - uint8_t m_logCh{11}; //!< Logical channel on which to start using the - //!< new superframe configuration. - uint32_t m_logChPage{0}; //!< Logical channel page on which to start using the - //!< new superframe configuration. - uint32_t m_startTime{0}; //!< Time at which to begin transmitting beacons (Used by Coordinator - //!< not PAN Coordinators). The time is specified in symbols. - uint8_t m_bcnOrd{15}; //!< Beacon Order, Used to calculate the beacon interval, a value of 15 - //!< indicates no periodic beacons will be transmitted. - uint8_t m_sfrmOrd{15}; //!< Superframe Order, indicates the length of the CAP in time slots. - bool m_panCoor{false}; //!< On true this device will become coordinator. - bool m_battLifeExt{false}; //!< Flag indicating whether or not the Battery life extension (BLE) - //!< features are used. - bool m_coorRealgn{false}; //!< True if a realignment request command is to be transmitted prior - //!< changing the superframe. -}; - -/** - * \ingroup lr-wpan - * - * MLME-SYNC.request params. See 802.15.4-2011 Section 6.2.13.1 - */ -struct MlmeSyncRequestParams -{ - uint8_t m_logCh{11}; //!< The channel number on which to attempt coordinator synchronization. - bool m_trackBcn{false}; //!< True if the mlme sync with the next beacon and attempts to track - //!< future beacons. False if mlme sync only the next beacon. -}; - -/** - * \ingroup lr-wpan - * - * MLME-POLL.request params. See 802.15.4-2011 Section 6.2.14.1 - */ -struct MlmePollRequestParams -{ - LrWpanAddressMode m_coorAddrMode{SHORT_ADDR}; //!< The addressing mode of the coordinator - //!< to which the pool is intended. - uint16_t m_coorPanId{0}; //!< The PAN id of the coordinator to which the poll is intended. - Mac16Address m_coorShortAddr; //!< Coordinator short address. - Mac64Address m_coorExtAddr; //!< Coordinator extended address. -}; - -/** - * \ingroup lr-wpan - * - * MLME-SCAN.request params. See IEEE 802.15.4-2011 Section 6.2.10.1 Table 30 - */ -struct MlmeScanRequestParams -{ - LrWpanMlmeScanType m_scanType{MLMESCAN_PASSIVE}; //!< Indicates the type of scan performed as - //!< described in IEEE 802.15.4-2011 (5.1.2.1). - uint32_t m_scanChannels{0x7FFF800}; //!< The channel numbers to be scanned. - //!< Default: (0x7FFF800 = Ch11-Ch26) - //!< 27 LSB (b0,b1,...,b26) = channels - uint8_t m_scanDuration{14}; //!< The factor (0-14) used to calculate the length of time - //!< to spend scanning. - //!< scanDurationSymbols = - //!< [aBaseSuperframeDuration * (2^m_scanDuration + 1)]. - uint32_t m_chPage{0}; //!< The channel page on which to perform scan. -}; - -/** - * \ingroup lr-wpan - * - * MLME-SCAN.confirm params. See IEEE 802.15.4-2011 Section 6.2.10.2 - */ -struct MlmeScanConfirmParams -{ - LrWpanMlmeScanConfirmStatus m_status{MLMESCAN_INVALID_PARAMETER}; //!< The status the request. - LrWpanMlmeScanType m_scanType{MLMESCAN_PASSIVE}; //!< Indicates the type of scan - //!< performed (ED,ACTIVE,PASSIVE,ORPHAN). - uint32_t m_chPage{0}; //!< The channel page on which the scan was performed. - std::vector m_unscannedCh; //!< A list of channels given in the request which - //!< were not scanned (Not valid for ED scans). - uint8_t m_resultListSize{0}; //!< The number of elements returned in the appropriate - //!< result list. (Not valid for Orphan scan). - std::vector m_energyDetList; //!< A list of energy measurements, one for each - //!< channel searched during ED scan - //!< (Not valid for Active, Passive or Orphan Scans) - std::vector m_panDescList; //!< A list of PAN descriptor, one for each beacon - //!< found (Not valid for ED and Orphan scans). -}; - -/** - * \ingroup lr-wpan - * - * MLME-ASSOCIATE.request params. See 802.15.4-2011 Section 6.2.2.1 - */ -struct MlmeAssociateRequestParams -{ - uint8_t m_chNum{11}; //!< The channel number on which to attempt association. - uint32_t m_chPage{0}; //!< The channel page on which to attempt association. - uint8_t m_coordAddrMode{SHORT_ADDR}; //!< The coordinator addressing mode for this - //!< primitive and subsequent MPDU. - uint16_t m_coordPanId{0}; //!< The identifier of the PAN with which to associate. - Mac16Address m_coordShortAddr; //!< The short address of the coordinator - //!< with which to associate. - Mac64Address m_coordExtAddr; //!< The extended address of the coordinator - //!< with which to associate. - uint8_t m_capabilityInfo; //!< Specifies the operational capabilities - //!< of the associating device (bitmap). -}; - -/** - * \ingroup lr-wpan - * - * MLME-ASSOCIATE.confirm params. See 802.15.4-2011 Section 6.2.2.4 - */ -struct MlmeAssociateConfirmParams -{ - Mac16Address m_assocShortAddr; //!< The short address used in the association request - LrWpanMlmeAssociateConfirmStatus m_status{ - MLMEASSOC_INVALID_PARAMETER}; //!< The status of - //!< a MLME-associate.request -}; - -/** - * \ingroup lr-wpan - * - * MLME-START.confirm params. See 802.15.4-2011 Section 6.2.12.2 - */ -struct MlmeStartConfirmParams -{ - LrWpanMlmeStartConfirmStatus m_status{MLMESTART_INVALID_PARAMETER}; //!< The status of - //!< a MLME-start.request -}; - -/** - * \ingroup lr-wpan - * - * MLME-BEACON-NOTIFY.indication params. See 802.15.4-2011 Section 6.2.4.1, Table 16 - */ -struct MlmeBeaconNotifyIndicationParams -{ - uint8_t m_bsn{0}; //!< The beacon sequence number. - PanDescriptor m_panDescriptor; //!< The PAN descriptor for the received beacon. - uint32_t m_sduLength{0}; //!< The number of octets contained in the beacon payload. - Ptr m_sdu; //!< The set of octets comprising the beacon payload. -}; - -/** - * \ingroup lr-wpan - * - * MLME-SYNC-LOSS.indication params. See 802.15.4-2011 Section 6.2.13.2, Table 37 - */ -struct MlmeSyncLossIndicationParams -{ - LrWpanSyncLossReason m_lossReason{ - MLMESYNCLOSS_PAN_ID_CONFLICT}; //!< The reason for - //!< the lost of synchronization. - uint16_t m_panId{0}; //!< The PAN identifier with which the device lost synchronization or to - //!< which it was realigned. - uint8_t m_logCh{11}; //!< The channel number on which the device lost synchronization or to - //!< which it was realigned. -}; - -/** - * \ingroup lr-wpan - * - * MLME-COMM-STATUS.indication params. See 802.15.4-2011 Section 6.2.4.2 Table 18 - */ -struct MlmeCommStatusIndicationParams -{ - uint16_t m_panId{0}; //!< The PAN identifier of the device from which the frame was received or - //!< to which the frame was being sent. - uint8_t m_srcAddrMode{SHORT_ADDR}; //!< The source addressing mode for this primitive - Mac16Address m_srcShortAddr; //!< The short address of the entity from which the frame causing - //!< the error originated. - Mac64Address m_srcExtAddr; //!< The extended address of the entity from which the frame causing - //!< the error originated. - uint8_t m_dstAddrMode{SHORT_ADDR}; //!< The destination addressing mode for this primitive. - Mac16Address m_dstShortAddr; //!< The short address of the device for - //!< which the frame was intended. - Mac64Address m_dstExtAddr; //!< The extended address of the device for - //!< which the frame was intended. - LrWpanMlmeCommStatus m_status{MLMECOMMSTATUS_INVALID_PARAMETER}; //!< The communication status -}; - -/** - * \ingroup lr-wpan - * - * MLME-ORPHAN.indication params. See 802.15.4-2011 Section 6.2.7.1 - */ -struct MlmeOrphanIndicationParams -{ - Mac64Address m_orphanAddr; //!< The address of the orphaned device. -}; - -/** - * \ingroup lr-wpan - * - * MLME-ORPHAN.response params. See 802.15.4-2011 Section 6.2.7.2 - */ -struct MlmeOrphanResponseParams -{ - Mac64Address m_orphanAddr; //!< The address of the orphaned device. - Mac16Address m_shortAddr; //!< The short address allocated. - bool m_assocMember{false}; //!< T = allocated with this coord | F = otherwise -}; - -/** - * \ingroup lr-wpan - * - * MLME-START.confirm params. See 802.15.4-2011 Section 6.2.14.2 - */ -struct MlmePollConfirmParams -{ - LrWpanMlmePollConfirmStatus m_status{ - MLMEPOLL_INVALID_PARAMETER}; //!< The confirmation status resulting from a - //!< MLME-poll.request. -}; - -/** - * \ingroup lr-wpan - * - * MLME-SET.confirm params. See 802.15.4-2011 Section 6.2.11.2 - */ -struct MlmeSetConfirmParams -{ - LrWpanMlmeSetConfirmStatus m_status{MLMESET_UNSUPPORTED_ATTRIBUTE}; //!< The result of - //!< the request to write - //!< the PIB attribute. - LrWpanMacPibAttributeIdentifier id; //!< The id of the PIB attribute that was written. -}; - -/** - * \ingroup lr-wpan - * - * This callback is called after a McpsDataRequest has been called from - * the higher layer. It returns a status of the outcome of the - * transmission request - */ -typedef Callback McpsDataConfirmCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a Mcps has successfully received a - * frame and wants to deliver it to the higher layer. - * - * \todo for now, we do not deliver all of the parameters in section - * 802.15.4-2006 7.1.1.3.1 but just send up the packet. - */ -typedef Callback> McpsDataIndicationCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a MlmeStartRequest has been called from - * the higher layer. It returns a status of the outcome of the - * transmission request - */ -typedef Callback MlmeStartConfirmCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a Mlme has successfully received a - * beacon frame and wants to deliver it to the higher layer. - * - * \todo for now, we do not deliver all of the parameters in section - * 802.15.4-2006 6.2.4.1 but just send up the packet. - */ -typedef Callback MlmeBeaconNotifyIndicationCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called to indicate the loss of synchronization with - * a coordinator. - * - * \todo for now, we do not deliver all of the parameters in section - * See IEEE 802.15.4-2011 6.2.13.2. - */ -typedef Callback MlmeSyncLossIndicationCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a Mlme-Poll.Request has been called from - * the higher layer. It returns a status of the outcome of the - * transmission request - */ -typedef Callback MlmePollConfirmCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a MlmeScanRequest has been called from - * the higher layer. It returns a status of the outcome of the scan. - */ -typedef Callback MlmeScanConfirmCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a MlmeAssociateRequest has been called from - * the higher layer. It returns a status of the outcome of the - * association request - */ -typedef Callback MlmeAssociateConfirmCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a Mlme has successfully received a command - * frame and wants to deliver it to the higher layer. - * - * Security related parameters and not handle. - * See 802.15.4-2011 6.2.2.2. - */ -typedef Callback MlmeAssociateIndicationCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called by the MLME and issued to its next higher layer following - * a transmission instigated through a response primitive. - * - * Security related parameters and not handle. - * See 802.15.4-2011 6.2.4.2 - */ -typedef Callback MlmeCommStatusIndicationCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called by the MLME and issued to its next higher layer following - * the reception of a orphan notification. - * - * Security related parameters and not handle. - * See 802.15.4-2011 6.2.7.1 - */ -typedef Callback MlmeOrphanIndicationCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a MlmeSetRequest has been called from - * the higher layer to set a PIB. It returns a status of the outcome of the - * write attempt. - */ -typedef Callback MlmeSetConfirmCallback; - -/** - * \ingroup lr-wpan - * - * This callback is called after a MlmeGetRequest has been called from - * the higher layer to get a PIB. It returns a status of the outcome of the - * write attempt. - */ -typedef Callback> - MlmeGetConfirmCallback; - /** * \ingroup lr-wpan * * Class that implements the LR-WPAN MAC state machine */ -class LrWpanMac : public Object +class LrWpanMac : public LrWpanMacBase { public: /** @@ -930,102 +235,26 @@ class LrWpanMac : public Object */ Mac64Address GetCoordExtAddress() const; - /** - * IEEE 802.15.4-2006, section 7.1.1.1 - * MCPS-DATA.request - * Request to transfer a MSDU. - * - * \param params the request parameters - * \param p the packet to be transmitted - */ - void McpsDataRequest(McpsDataRequestParams params, Ptr p); + void McpsDataRequest(McpsDataRequestParams params, Ptr p) override; - /** - * IEEE 802.15.4-2006, section 7.1.14.1 - * MLME-START.request - * Request to allow a PAN coordinator to initiate - * a new PAN or beginning a new superframe configuration. - * - * \param params the request parameters - */ - void MlmeStartRequest(MlmeStartRequestParams params); + void MlmeStartRequest(MlmeStartRequestParams params) override; - /** - * IEEE 802.15.4-2011, section 6.2.10.1 - * MLME-SCAN.request - * Request primitive used to initiate a channel scan over a given list of channels. - * - * \param params the scan request parameters - */ - void MlmeScanRequest(MlmeScanRequestParams params); + void MlmeScanRequest(MlmeScanRequestParams params) override; - /** - * IEEE 802.15.4-2011, section 6.2.2.1 - * MLME-ASSOCIATE.request - * Request primitive used by a device to request an association with - * a coordinator. - * - * \param params the request parameters - */ - void MlmeAssociateRequest(MlmeAssociateRequestParams params); + void MlmeAssociateRequest(MlmeAssociateRequestParams params) override; - /** - * IEEE 802.15.4-2011, section 6.2.2.3 - * MLME-ASSOCIATE.response - * Primitive used to initiate a response to an MLME-ASSOCIATE.indication - * primitive. - * - * \param params the associate response parameters - */ - void MlmeAssociateResponse(MlmeAssociateResponseParams params); + void MlmeAssociateResponse(MlmeAssociateResponseParams params) override; - /** - * IEEE 802.15.4-2011, section 6.2.7.2 - * MLME-ORPHAN.response - * Primitive used to initiatte a response to an MLME-ORPHAN.indication - * primitive. - * - * \param params the orphan response parameters - */ - void MlmeOrphanResponse(MlmeOrphanResponseParams params); + void MlmeOrphanResponse(MlmeOrphanResponseParams params) override; - /** - * IEEE 802.15.4-2011, section 6.2.13.1 - * MLME-SYNC.request - * Request to synchronize with the coordinator by acquiring and, - * if specified, tracking beacons. - * - * \param params the request parameters - */ - void MlmeSyncRequest(MlmeSyncRequestParams params); + void MlmeSyncRequest(MlmeSyncRequestParams params) override; - /** - * IEEE 802.15.4-2011, section 6.2.14.2 - * MLME-POLL.request - * Prompts the device to request data from the coordinator. - * - * \param params the request parameters - */ - void MlmePollRequest(MlmePollRequestParams params); + void MlmePollRequest(MlmePollRequestParams params) override; - /** - * IEEE 802.15.4-2011, section 6.2.11.1 - * MLME-SET.request - * Attempts to write the given value to the indicated PIB attribute. - * - * \param id the attributed identifier - * \param attribute the attribute value - */ - void MlmeSetRequest(LrWpanMacPibAttributeIdentifier id, Ptr attribute); + void MlmeSetRequest(LrWpanMacPibAttributeIdentifier id, + Ptr attribute) override; - /** - * IEEE 802.15.4-2011, section 6.2.5.1 - * MLME-GET.request - * Request information about a given PIB attribute. - * - * \param id the attribute identifier - */ - void MlmeGetRequest(LrWpanMacPibAttributeIdentifier id); + void MlmeGetRequest(LrWpanMacPibAttributeIdentifier id) override; /** * Set the CSMA/CA implementation to be used by the MAC. @@ -1048,124 +277,9 @@ class LrWpanMac : public Object */ Ptr GetPhy(); - /** - * Set the callback for the indication of an incoming data packet. - * The callback implements MCPS-DATA.indication SAP of IEEE 802.15.4-2006, - * section 7.1.1.3. - * - * \param c the callback - */ - void SetMcpsDataIndicationCallback(McpsDataIndicationCallback c); - - /** - * Set the callback for the indication of an incoming associate request command. - * The callback implements MLME-ASSOCIATE.indication SAP of IEEE 802.15.4-2011, - * section 6.2.2.2. - * - * \param c the callback - */ - void SetMlmeAssociateIndicationCallback(MlmeAssociateIndicationCallback c); - - /** - * Set the callback for the indication to a response primitive. - * The callback implements MLME-COMM-STATUS.indication SAP of IEEE 802.15.4-2011, - * section 6.2.4.2. - * - * \param c the callback - */ - void SetMlmeCommStatusIndicationCallback(MlmeCommStatusIndicationCallback c); - - /** - * Set the callback for the indication to the reception of an orphan notification. - * The callback implements MLME-ORPHAN.indication SAP of IEEE 802.15.4-2011, - * section 6.2.7.1. - * - * \param c the callback - */ - void SetMlmeOrphanIndicationCallback(MlmeOrphanIndicationCallback c); - - /** - * Set the callback for the confirmation of a data transmission request. - * The callback implements MCPS-DATA.confirm SAP of IEEE 802.15.4-2006, - * section 7.1.1.2. - * - * \param c the callback - */ - void SetMcpsDataConfirmCallback(McpsDataConfirmCallback c); - - /** - * Set the callback for the confirmation of a data transmission request. - * The callback implements MLME-START.confirm SAP of IEEE 802.15.4-2006, - * section 7.1.14.2. - * - * \param c the callback - */ - void SetMlmeStartConfirmCallback(MlmeStartConfirmCallback c); - - /** - * Set the callback for the confirmation of a data transmission request. - * The callback implements MLME-SCAN.confirm SAP of IEEE 802.15.4-2011, - * section 6.2.10.2. - * - * \param c the callback - */ - void SetMlmeScanConfirmCallback(MlmeScanConfirmCallback c); - - /** - * Set the callback for the confirmation of a data transmission request. - * The callback implements MLME-ASSOCIATE.confirm SAP of IEEE 802.15.4-2011, - * section 6.2.2.4. - * - * \param c the callback - */ - void SetMlmeAssociateConfirmCallback(MlmeAssociateConfirmCallback c); - - /** - * Set the callback for the indication of an incoming beacon packet. - * The callback implements MLME-BEACON-NOTIFY.indication SAP of IEEE 802.15.4-2011, - * section 6.2.4.1. - * - * \param c the callback - */ - void SetMlmeBeaconNotifyIndicationCallback(MlmeBeaconNotifyIndicationCallback c); - - /** - * Set the callback for the loss of synchronization with a coordinator. - * The callback implements MLME-BEACON-NOTIFY.indication SAP of IEEE 802.15.4-2011, - * section 6.2.13.2. - * - * \param c the callback - */ - void SetMlmeSyncLossIndicationCallback(MlmeSyncLossIndicationCallback c); - - /** - * Set the callback for the confirmation of a data transmission request. - * The callback implements MLME-POLL.confirm SAP of IEEE 802.15.4-2011, - * section 6.2.14.2 - * - * \param c the callback - */ - void SetMlmePollConfirmCallback(MlmePollConfirmCallback c); - - /** - * Set the callback for the confirmation of an attempt to write an attribute. - * The callback implements MLME-SET.confirm SAP of IEEE 802.15.4-2011, - * section 6.2.11.2 - * - * \param c the callback - */ - void SetMlmeSetConfirmCallback(MlmeSetConfirmCallback c); - - /** - * Set the callback for the confirmation of an attempt to read an attribute. - * The callback implements MLME-GET.confirm SAP of IEEE 802.15.4-2011, - * section 6.2.5.2 - * - *\param c the callback - */ - void SetMlmeGetConfirmCallback(MlmeGetConfirmCallback c); - - // interfaces between MAC and PHY + //////////////////////////////////// + // Interfaces between MAC and PHY // + //////////////////////////////////// /** * IEEE 802.15.4-2006 section 6.2.1.3 @@ -2022,91 +1136,6 @@ class LrWpanMac : public Object */ Ptr m_csmaCa; - /** - * This callback is used to report the result of an attribute writing request - * to the upper layers. - * See IEEE 802.15.4-2011, section 6.2.11.2. - */ - MlmeSetConfirmCallback m_mlmeSetConfirmCallback; - - /** - * This callback is used to report the result of an attribute read request - * to the upper layers. - * See IEEE 802.15.4-2011, section 6.2.5.2 - */ - MlmeGetConfirmCallback m_mlmeGetConfirmCallback; - - /** - * This callback is used to notify incoming beacon packets to the upper layers. - * See IEEE 802.15.4-2011, section 6.2.4.1. - */ - MlmeBeaconNotifyIndicationCallback m_mlmeBeaconNotifyIndicationCallback; - - /** - * This callback is used to indicate the loss of synchronization with a coordinator. - * See IEEE 802.15.4-2011, section 6.2.13.2. - */ - MlmeSyncLossIndicationCallback m_mlmeSyncLossIndicationCallback; - - /** - * This callback is used to report the result of a scan on a group of channels for the - * selected channel page. - * See IEEE 802.15.4-2011, section 6.2.10.2. - */ - MlmeScanConfirmCallback m_mlmeScanConfirmCallback; - - /** - * This callback is used to report the status after a device request an association with - * a coordinator. - * See IEEE 802.15.4-2011, section 6.2.2.4. - */ - MlmeAssociateConfirmCallback m_mlmeAssociateConfirmCallback; - - /** - * This callback is used to report the status after a device send data command request to - * the coordinator to transmit data. - * See IEEE 802.15.4-2011, section 6.2.14.2. - */ - MlmePollConfirmCallback m_mlmePollConfirmCallback; - - /** - * This callback is used to report the start of a new PAN or - * the begin of a new superframe configuration. - * See IEEE 802.15.4-2006, section 7.1.14.2. - */ - MlmeStartConfirmCallback m_mlmeStartConfirmCallback; - - /** - * This callback is used to notify incoming packets to the upper layers. - * See IEEE 802.15.4-2006, section 7.1.1.3. - */ - McpsDataIndicationCallback m_mcpsDataIndicationCallback; - - /** - * This callback is used to indicate the reception of an association request command. - * See IEEE 802.15.4-2011, section 6.2.2.2 - */ - MlmeAssociateIndicationCallback m_mlmeAssociateIndicationCallback; - - /** - * This callback is instigated through a response primitive. - * See IEEE 802.15.4-2011, section 6.2.4.2 - */ - MlmeCommStatusIndicationCallback m_mlmeCommStatusIndicationCallback; - - /** - * This callback is used to indicate the reception of a orphan notification command. - * See IEEE 802.15.4-2011, section 6.2.7.1 - */ - MlmeOrphanIndicationCallback m_mlmeOrphanIndicationCallback; - - /** - * This callback is used to report data transmission request status to the - * upper layers. - * See IEEE 802.15.4-2006, section 7.1.1.2. - */ - McpsDataConfirmCallback m_mcpsDataConfirmCallback; - /** * The current state of the MAC layer. */