From 4bb239b8ce36e374efad64da9943dd728232a6a3 Mon Sep 17 00:00:00 2001 From: Alberto Gallegos Ramonet Date: Thu, 19 Oct 2023 15:54:13 +0900 Subject: [PATCH] lr-wpan: Change SuperframeField to standard bitmap --- CHANGES.md | 1 + RELEASE_NOTES.md | 1 + src/lr-wpan/examples/lr-wpan-bootstrap.cc | 3 ++- src/lr-wpan/model/lr-wpan-fields.cc | 27 ++++----------------- src/lr-wpan/model/lr-wpan-fields.h | 26 ++++++-------------- src/lr-wpan/model/lr-wpan-mac-pl-headers.cc | 10 ++++---- src/lr-wpan/model/lr-wpan-mac-pl-headers.h | 10 ++++---- src/lr-wpan/model/lr-wpan-mac.cc | 8 +++--- src/lr-wpan/model/lr-wpan-mac.h | 16 ++++++------ 9 files changed, 39 insertions(+), 63 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f2e45340a..57e80d188 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ Changes from ns-3.40 to ns-3-dev * (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. +* (lr-wpan) Change the MAC SuperframeField usage to a standard bitmap, this change impact parameters in the `BeaconPayloadHeader`. ### Changes to build system diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 0bea5e6e6..80806c022 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -21,6 +21,7 @@ Release 3-dev ### New user-visible features - (lr-wpan) !1686 Change CapabilityField to standard bitmap +- (lr-wpan) !1698 Change SuperframeField to standard bitmap ### Bugs fixed diff --git a/src/lr-wpan/examples/lr-wpan-bootstrap.cc b/src/lr-wpan/examples/lr-wpan-bootstrap.cc index 964d51ec8..0381a7d48 100644 --- a/src/lr-wpan/examples/lr-wpan-bootstrap.cc +++ b/src/lr-wpan/examples/lr-wpan-bootstrap.cc @@ -105,7 +105,8 @@ ScanConfirm(Ptr device, MlmeScanConfirmParams params) } // Only request association if the coordinator is permitting association at this moment. - if (params.m_panDescList[panDescIndex].m_superframeSpec.IsAssocPermit()) + SuperframeField superframe(params.m_panDescList[panDescIndex].m_superframeSpec); + if (superframe.IsAssocPermit()) { std::string addressing; if (params.m_panDescList[panDescIndex].m_coorAddrMode == SHORT_ADDR) diff --git a/src/lr-wpan/model/lr-wpan-fields.cc b/src/lr-wpan/model/lr-wpan-fields.cc index 0fee27885..3c8428f60 100644 --- a/src/lr-wpan/model/lr-wpan-fields.cc +++ b/src/lr-wpan/model/lr-wpan-fields.cc @@ -35,6 +35,11 @@ SuperframeField::SuperframeField() SetAssocPermit(false); } +SuperframeField::SuperframeField(uint16_t bitmap) +{ + SetSuperframe(bitmap); +} + void SuperframeField::SetSuperframe(uint16_t superFrmSpec) { @@ -156,28 +161,6 @@ SuperframeField::GetSuperframe() const return superframe; } -uint32_t -SuperframeField::GetSerializedSize() const -{ - return 2; // 2 Octets (superframeSpec) -} - -Buffer::Iterator -SuperframeField::Serialize(Buffer::Iterator i) const -{ - i.WriteHtolsbU16(GetSuperframe()); - return i; -} - -Buffer::Iterator -SuperframeField::Deserialize(Buffer::Iterator i) -{ - uint16_t superframe = i.ReadLsbtohU16(); - SetSuperframe(superframe); - - return i; -} - std::ostream& operator<<(std::ostream& os, const SuperframeField& superframeField) { diff --git a/src/lr-wpan/model/lr-wpan-fields.h b/src/lr-wpan/model/lr-wpan-fields.h index 3bc1a6673..bc18e09e1 100644 --- a/src/lr-wpan/model/lr-wpan-fields.h +++ b/src/lr-wpan/model/lr-wpan-fields.h @@ -54,6 +54,14 @@ class SuperframeField { public: SuperframeField(); + + /** + * Create a superframe Specification Information field with + * the information specified in the bitmap. + * + * \param bitmap The superframe in bitmap form + */ + SuperframeField(uint16_t bitmap); /** * Set the whole Superframe Specification Information field. * \param superFrm The Superframe Specification information field. @@ -127,24 +135,6 @@ class SuperframeField * \return the Superframe Specification Information field bits. */ uint16_t GetSuperframe() const; - /** - * Get the size of the serialized Superframe specification information field. - * \return the size of the serialized field. - */ - uint32_t GetSerializedSize() const; - /** - * Serialize the entire superframe specification field. - * \param i an iterator which points to where the superframe specification field should be - * written. - * \return an iterator. - */ - Buffer::Iterator Serialize(Buffer::Iterator i) const; - /** - * Deserialize the entire superframe specification field. - * \param i an iterator which points to where the superframe specification field should be read. - * \return an iterator. - */ - Buffer::Iterator Deserialize(Buffer::Iterator i); private: // Superframe Specification field 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 f842dd9ed..0743c1b1c 100644 --- a/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc +++ b/src/lr-wpan/model/lr-wpan-mac-pl-headers.cc @@ -55,7 +55,7 @@ uint32_t BeaconPayloadHeader::GetSerializedSize() const { uint32_t size = 0; - size += m_superframeField.GetSerializedSize(); + size += sizeof(m_superframeField); size += m_gtsFields.GetSerializedSize(); size += m_pndAddrFields.GetSerializedSize(); @@ -66,7 +66,7 @@ void BeaconPayloadHeader::Serialize(Buffer::Iterator start) const { Buffer::Iterator i = start; - i = m_superframeField.Serialize(i); + i.WriteU16(m_superframeField); i = m_gtsFields.Serialize(i); i = m_pndAddrFields.Serialize(i); } @@ -75,7 +75,7 @@ uint32_t BeaconPayloadHeader::Deserialize(Buffer::Iterator start) { Buffer::Iterator i = start; - i = m_superframeField.Deserialize(i); + m_superframeField = i.ReadU16(); i = m_gtsFields.Deserialize(i); i = m_pndAddrFields.Deserialize(i); @@ -91,7 +91,7 @@ BeaconPayloadHeader::Print(std::ostream& os) const } void -BeaconPayloadHeader::SetSuperframeSpecField(SuperframeField sf) +BeaconPayloadHeader::SetSuperframeSpecField(uint16_t sf) { m_superframeField = sf; } @@ -108,7 +108,7 @@ BeaconPayloadHeader::SetPndAddrFields(PendingAddrFields pndAddrFields) m_pndAddrFields = pndAddrFields; } -SuperframeField +uint16_t BeaconPayloadHeader::GetSuperframeSpecField() const { return m_superframeField; 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 f740d5f03..9a52fbdc1 100644 --- a/src/lr-wpan/model/lr-wpan-mac-pl-headers.h +++ b/src/lr-wpan/model/lr-wpan-mac-pl-headers.h @@ -50,9 +50,9 @@ class BeaconPayloadHeader : public Header void Print(std::ostream& os) const override; /** * Set the superframe specification field to the beacon payload header. - * \param sfrmField The superframe specification field + * \param sfrmField The superframe specification field (bitmap) */ - void SetSuperframeSpecField(SuperframeField sfrmField); + void SetSuperframeSpecField(uint16_t sfrmField); /** * Set the superframe Guaranteed Time Slot (GTS) fields to the beacon payload header. * \param gtsFields The GTS fields. @@ -65,9 +65,9 @@ class BeaconPayloadHeader : public Header void SetPndAddrFields(PendingAddrFields pndAddrFields); /** * Get the superframe specification field from the beacon payload header. - * \return The superframe specification field + * \return The superframe specification field (bitmap) */ - SuperframeField GetSuperframeSpecField() const; + uint16_t GetSuperframeSpecField() const; /** * Get the Guaranteed Time Slots (GTS) fields from the beacon payload header. * \return The GTS fields. @@ -83,7 +83,7 @@ class BeaconPayloadHeader : public Header /** * Superframe Specification Field */ - SuperframeField m_superframeField; + uint16_t m_superframeField; /** * GTS Fields */ diff --git a/src/lr-wpan/model/lr-wpan-mac.cc b/src/lr-wpan/model/lr-wpan-mac.cc index 4d6a43f1e..07ce69394 100644 --- a/src/lr-wpan/model/lr-wpan-mac.cc +++ b/src/lr-wpan/model/lr-wpan-mac.cc @@ -1711,7 +1711,7 @@ LrWpanMac::CheckQueue() } } -SuperframeField +uint16_t LrWpanMac::GetSuperframeField() { SuperframeField sfrmSpec; @@ -1736,7 +1736,7 @@ LrWpanMac::GetSuperframeField() sfrmSpec.SetAssocPermit(true); } - return sfrmSpec; + return sfrmSpec.GetSuperframe(); } GtsFields @@ -2184,8 +2184,8 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) // beginning of an Association). m_csmaCa->Cancel(); - SuperframeField incomingSuperframe; - incomingSuperframe = receivedMacPayload.GetSuperframeSpecField(); + SuperframeField incomingSuperframe( + receivedMacPayload.GetSuperframeSpecField()); m_incomingBeaconOrder = incomingSuperframe.GetBeaconOrder(); m_incomingSuperframeOrder = incomingSuperframe.GetFrameOrder(); diff --git a/src/lr-wpan/model/lr-wpan-mac.h b/src/lr-wpan/model/lr-wpan-mac.h index d506e017c..a44b33c5a 100644 --- a/src/lr-wpan/model/lr-wpan-mac.h +++ b/src/lr-wpan/model/lr-wpan-mac.h @@ -384,12 +384,12 @@ struct PanDescriptor //!< 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. - SuperframeField m_superframeSpec; //!< 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. + 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. }; @@ -1830,9 +1830,9 @@ class LrWpanMac : public Object * Constructs a Superframe specification field from the local information, * the superframe Specification field is necessary to create a beacon frame. * - * \returns the Superframe specification field + * \returns the Superframe specification field (bitmap) */ - SuperframeField GetSuperframeField(); + uint16_t GetSuperframeField(); /** * Constructs the Guaranteed Time Slots (GTS) Fields from local information.