diff --git a/CHANGES.md b/CHANGES.md index fddd2c207..e6f86063e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,7 @@ Changes from ns-3.40 to ns-3-dev * (lte) Struct member `fdbetsFlowPerf_t::lastTtiBytesTrasmitted` in file `fdbet-ff-mac-scheduler.h` was renamed `fdbetsFlowPerf_t::lastTtiBytesTransmitted`. * (lte) Struct member `tdbetsFlowPerf_t::lastTtiBytesTrasmitted` in file `tdbet-ff-mac-scheduler.h` was renamed `fdbetsFlowPerf_t::lastTtiBytesTransmitted`. * (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. ### Changes to build system diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4748254c7..0bea5e6e6 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -20,6 +20,8 @@ Release 3-dev ### New user-visible features +- (lr-wpan) !1686 Change CapabilityField to standard bitmap + ### Bugs fixed - (lr-wpan) !1673 - Fixes PHY BUSY_RX -> RX_ON operation diff --git a/src/lr-wpan/examples/lr-wpan-bootstrap.cc b/src/lr-wpan/examples/lr-wpan-bootstrap.cc index 787287219..964d51ec8 100644 --- a/src/lr-wpan/examples/lr-wpan-bootstrap.cc +++ b/src/lr-wpan/examples/lr-wpan-bootstrap.cc @@ -133,6 +133,7 @@ ScanConfirm(Ptr device, MlmeScanConfirmParams params) assocParams.m_chPage = params.m_panDescList[panDescIndex].m_logChPage; assocParams.m_coordPanId = params.m_panDescList[panDescIndex].m_coorPanId; assocParams.m_coordAddrMode = params.m_panDescList[panDescIndex].m_coorAddrMode; + CapabilityField capability; if (params.m_panDescList[panDescIndex].m_coorAddrMode == LrWpanAddressMode::SHORT_ADDR) @@ -140,7 +141,7 @@ ScanConfirm(Ptr device, MlmeScanConfirmParams params) assocParams.m_coordAddrMode = LrWpanAddressMode::SHORT_ADDR; assocParams.m_coordShortAddr = params.m_panDescList[panDescIndex].m_coorShortAddr; - assocParams.m_capabilityInfo.SetShortAddrAllocOn(true); + capability.SetShortAddrAllocOn(true); } else if (assocParams.m_coordAddrMode == LrWpanAddressMode::EXT_ADDR) { @@ -148,8 +149,9 @@ ScanConfirm(Ptr device, MlmeScanConfirmParams params) assocParams.m_coordExtAddr = params.m_panDescList[panDescIndex].m_coorExtAddr; assocParams.m_coordShortAddr = Mac16Address("ff:fe"); - assocParams.m_capabilityInfo.SetShortAddrAllocOn(false); + capability.SetShortAddrAllocOn(false); } + assocParams.m_capabilityInfo = capability.GetCapability(); Simulator::ScheduleNow(&LrWpanMac::MlmeAssociateRequest, device->GetMac(), @@ -207,7 +209,10 @@ AssociateIndication(Ptr device, MlmeAssociateIndicationParams p assocRespParams.m_extDevAddr = params.m_extDevAddr; assocRespParams.m_status = LrWpanAssociationStatus::ASSOCIATED; - if (params.capabilityInfo.IsShortAddrAllocOn()) + CapabilityField capability; + capability.SetCapability(params.capabilityInfo); + + if (capability.IsShortAddrAllocOn()) { // Truncate the extended address and make an assigned // short address based on this. This mechanism is not described by the standard. diff --git a/src/lr-wpan/model/lr-wpan-fields.cc b/src/lr-wpan/model/lr-wpan-fields.cc index 7898c5a0e..0fee27885 100644 --- a/src/lr-wpan/model/lr-wpan-fields.cc +++ b/src/lr-wpan/model/lr-wpan-fields.cc @@ -525,27 +525,6 @@ CapabilityField::SetCapability(uint8_t bitmap) m_allocAddr = (bitmap >> 7) & (0x01); //!< Bit 7 } -uint32_t -CapabilityField::GetSerializedSize() const -{ - return 1; -} - -Buffer::Iterator -CapabilityField::Serialize(Buffer::Iterator i) const -{ - i.WriteU8(GetCapability()); - return i; -} - -Buffer::Iterator -CapabilityField::Deserialize(Buffer::Iterator i) -{ - uint8_t capability = i.ReadU8(); - SetCapability(capability); - return i; -} - bool CapabilityField::IsDeviceTypeFfd() const { diff --git a/src/lr-wpan/model/lr-wpan-fields.h b/src/lr-wpan/model/lr-wpan-fields.h index 79f3079e5..3bc1a6673 100644 --- a/src/lr-wpan/model/lr-wpan-fields.h +++ b/src/lr-wpan/model/lr-wpan-fields.h @@ -377,30 +377,6 @@ class CapabilityField */ void SetCapability(uint8_t bitmap); - /** - * Get the size of the serialized Capability Information Field. - * - * \return the size of the serialized field. - */ - uint32_t GetSerializedSize() const; - - /** - * Serialize the entire Capability Information Field. - * - * \param i an iterator which points to where the Capability information field - * should be written. - * \return an iterator. - */ - Buffer::Iterator Serialize(Buffer::Iterator i) const; - - /** - * Deserialize the entire Capability Information Field. - * - * \param i an iterator which points to where the Capability information field should be read. - * \return an iterator. - */ - Buffer::Iterator Deserialize(Buffer::Iterator i); - /** * True if the device type is a Full Functional Device (FFD) false if is a Reduced Functional * Device (RFD). diff --git a/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc b/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc index bd19ae278..f842dd9ed 100644 --- a/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc +++ b/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc @@ -166,7 +166,7 @@ CommandPayloadHeader::GetSerializedSize() const switch (m_cmdFrameId) { case ASSOCIATION_REQ: - size += m_capabilityInfo.GetSerializedSize(); + size += 1; // (Capability field) break; case ASSOCIATION_RESP: size += 3; // (short address + Association Status) @@ -201,7 +201,7 @@ CommandPayloadHeader::Serialize(Buffer::Iterator start) const switch (m_cmdFrameId) { case ASSOCIATION_REQ: - i = m_capabilityInfo.Serialize(i); + i.WriteU8(m_capabilityInfo); break; case ASSOCIATION_RESP: WriteTo(i, m_shortAddr); @@ -240,7 +240,7 @@ CommandPayloadHeader::Deserialize(Buffer::Iterator start) switch (m_cmdFrameId) { case ASSOCIATION_REQ: - i = m_capabilityInfo.Deserialize(i); + m_capabilityInfo = i.ReadU8(); break; case ASSOCIATION_RESP: ReadFrom(i, m_shortAddr); @@ -278,13 +278,15 @@ CommandPayloadHeader::Print(std::ostream& os) const os << "| MAC Command Frame ID | = " << static_cast(m_cmdFrameId); switch (m_cmdFrameId) { - case ASSOCIATION_REQ: - os << "| Device Type FFD | = " << m_capabilityInfo.IsDeviceTypeFfd() - << "| Alternative Power Source available | = " << m_capabilityInfo.IsPowSrcAvailable() - << "| Receiver on when Idle | = " << m_capabilityInfo.IsReceiverOnWhenIdle() - << "| Security capable | = " << m_capabilityInfo.IsSecurityCapability() - << "| Allocate address on | = " << m_capabilityInfo.IsShortAddrAllocOn(); + case ASSOCIATION_REQ: { + CapabilityField capability(m_capabilityInfo); + os << "| Device Type FFD | = " << capability.IsDeviceTypeFfd() + << "| Alternative Power Source available | = " << capability.IsPowSrcAvailable() + << "| Receiver on when Idle | = " << capability.IsReceiverOnWhenIdle() + << "| Security capable | = " << capability.IsSecurityCapability() + << "| Allocate address on | = " << capability.IsShortAddrAllocOn(); break; + } case ASSOCIATION_RESP: os << "| Assigned Short Address | = " << m_shortAddr << "| Status Response | = " << m_assocStatus; @@ -310,6 +312,8 @@ CommandPayloadHeader::Print(std::ostream& os) const break; case CMD_RESERVED: break; + default: + break; } } @@ -320,7 +324,7 @@ CommandPayloadHeader::SetCommandFrameType(MacCommand macCommand) } void -CommandPayloadHeader::SetCapabilityField(CapabilityField cap) +CommandPayloadHeader::SetCapabilityField(uint8_t cap) { NS_ASSERT(m_cmdFrameId == ASSOCIATION_REQ); m_capabilityInfo = cap; @@ -409,7 +413,7 @@ CommandPayloadHeader::GetAssociationStatus() const return m_assocStatus; } -CapabilityField +uint8_t CommandPayloadHeader::GetCapabilityField() const { NS_ASSERT(m_cmdFrameId == ASSOCIATION_REQ); diff --git a/src/lr-wpan/model/lr-wpan-mac-pl-headers.h b/src/lr-wpan/model/lr-wpan-mac-pl-headers.h index fbb1df272..f740d5f03 100644 --- a/src/lr-wpan/model/lr-wpan-mac-pl-headers.h +++ b/src/lr-wpan/model/lr-wpan-mac-pl-headers.h @@ -161,7 +161,7 @@ class CommandPayloadHeader : public Header * Command). * \param cap The capability Information field */ - void SetCapabilityField(CapabilityField cap); + void SetCapabilityField(uint8_t cap); /** * Set the coordinator short address (16 bit address). * \param addr The coordinator short address. @@ -212,9 +212,9 @@ class CommandPayloadHeader : public Header /** * Get the Capability Information Field from the command payload header. * (Association Request Command) - * \return The Capability Information Field + * \return The Capability Information Field (8 bit bitmap) */ - CapabilityField GetCapabilityField() const; + uint8_t GetCapabilityField() const; /** * Get the coordinator short address. * \return The coordinator short address (16 bit address) @@ -237,11 +237,11 @@ class CommandPayloadHeader : public Header uint16_t GetPanId() const; private: - MacCommand m_cmdFrameId; //!< The command Frame Identifier (Used by all commands) - CapabilityField m_capabilityInfo; //!< Capability Information Field - //!< (Association Request Command) - Mac16Address m_shortAddr; //!< Contains the short address assigned by the coordinator - //!< (Association Response and Coordinator Realiagment Command) + MacCommand m_cmdFrameId; //!< The command Frame Identifier (Used by all commands) + uint8_t m_capabilityInfo; //!< Capability Information Field + //!< (Association Request Command) + Mac16Address m_shortAddr; //!< Contains the short address assigned by the coordinator + //!< (Association Response and Coordinator Realiagment Command) Mac16Address m_coordShortAddr; //!< The coordinator short address //!< (Coordinator realigment command) uint16_t m_panid; //!< The PAN identifier (Coordinator realigment command) diff --git a/src/lr-wpan/model/lr-wpan-mac.h b/src/lr-wpan/model/lr-wpan-mac.h index a90cfac34..d506e017c 100644 --- a/src/lr-wpan/model/lr-wpan-mac.h +++ b/src/lr-wpan/model/lr-wpan-mac.h @@ -448,9 +448,9 @@ struct McpsDataIndicationParams */ struct MlmeAssociateIndicationParams { - Mac64Address m_extDevAddr; //!< The extended address of the device requesting association - CapabilityField capabilityInfo; //!< The operational capabilities of - //!< the device requesting association. + 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) }; @@ -512,8 +512,8 @@ struct MlmeSyncRequestParams */ struct MlmePollRequestParams { - LrWpanAddressMode m_coorAddrMode{ - SHORT_ADDR}; //!< The addressing mode of the coordinator to which the pool is intended. + 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. @@ -567,17 +567,17 @@ struct MlmeScanConfirmParams */ 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. - CapabilityField - m_capabilityInfo; //!< Specifies the operational capabilities of the associating device. + 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). }; /** @@ -589,7 +589,8 @@ 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 + MLMEASSOC_INVALID_PARAMETER}; //!< The status of + //!< a MLME-associate.request }; /** @@ -599,8 +600,8 @@ struct MlmeAssociateConfirmParams */ struct MlmeStartConfirmParams { - LrWpanMlmeStartConfirmStatus m_status{ - MLMESTART_INVALID_PARAMETER}; //!< The status of a MLME-start.request + LrWpanMlmeStartConfirmStatus m_status{MLMESTART_INVALID_PARAMETER}; //!< The status of + //!< a MLME-start.request }; /** @@ -624,7 +625,8 @@ struct MlmeBeaconNotifyIndicationParams struct MlmeSyncLossIndicationParams { LrWpanSyncLossReason m_lossReason{ - MLMESYNCLOSS_PAN_ID_CONFLICT}; //!< The reason for the lost of synchronization. + 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