diff --git a/CHANGES.md b/CHANGES.md index 7013e997dee..d0e62f3e737 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -35,6 +35,7 @@ Changes from ns-3.40 to ns-3-dev * (antenna) `GetNumberOfElements` is renamed to `GetNumElems` for the sake of simplifying the long lines of code that use complex mathematical expressions. * (spectrum) `PhasedArraySpectrumPropagationLossModel::CalcRxPowerSpectralDensity` return type is changed from `Ptr` to `Ptr` to support MIMO, because when multiple transmit and receive antenna ports are present, it is not enough to have a single PSD (represented by `Ptr`) but also the 3D channel matrix is needed per receive and transmit antenna port. Notice that `CalcRxPowerSpectralDensity` is typically called from within `MultiModelSpectrumChannel`, but if some external ns-3 module is calling directly this function, it can still access to its original return value through `Ptr` which contains `Ptr`. * (wifi) The default value for `WifiRemoteStationManager::RtsCtsThreshold` has been increased from 65535 to 4692480. +* (lr-wpan) Add the capability to see the enum values of the MAC transition states in log prints for easier debugging. ### Changes to build system diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 75edeeb527b..312f03eb899 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -33,6 +33,7 @@ Release 3-dev - (lr-wpan) !1673 - Fixes PHY BUSY_RX -> RX_ON operation - (wifi) - Fix agreement not always properly torn down when Block Ack inactivity timeout is elapsed - (wifi) - Stop A-MSDU aggregation when an A-MSDU is found in the queue +- (lr-wpan) !1769 - `DoDispose` SIGSEGV and beacon fixes Release 3.40 ------------ diff --git a/src/lr-wpan/model/lr-wpan-mac.cc b/src/lr-wpan/model/lr-wpan-mac.cc index 18fa11b95d0..c2234ec2955 100644 --- a/src/lr-wpan/model/lr-wpan-mac.cc +++ b/src/lr-wpan/model/lr-wpan-mac.cc @@ -48,6 +48,45 @@ namespace ns3 NS_LOG_COMPONENT_DEFINE("LrWpanMac"); NS_OBJECT_ENSURE_REGISTERED(LrWpanMac); +std::ostream& +operator<<(std::ostream& os, const LrWpanMacState& state) +{ + switch (state) + { + case LrWpanMacState::MAC_IDLE: + os << "MAC IDLE"; + break; + case LrWpanMacState::MAC_CSMA: + os << "CSMA"; + break; + case LrWpanMacState::MAC_SENDING: + os << "SENDING"; + break; + case LrWpanMacState::MAC_ACK_PENDING: + os << "ACK PENDING"; + break; + case LrWpanMacState::CHANNEL_ACCESS_FAILURE: + os << "CHANNEL_ACCESS_FAILURE"; + break; + case LrWpanMacState::CHANNEL_IDLE: + os << "CHANNEL IDLE"; + break; + case LrWpanMacState::SET_PHY_TX_ON: + os << "SET PHY to TX ON"; + break; + case LrWpanMacState::MAC_GTS: + os << "MAC GTS PERIOD"; + break; + case LrWpanMacState::MAC_INACTIVE: + os << "SUPERFRAME INACTIVE PERIOD"; + break; + case LrWpanMacState::MAC_CSMA_DEFERRED: + os << "CSMA DEFERRED TO NEXT PERIOD"; + break; + } + return os; +}; + TypeId LrWpanMac::GetTypeId() { @@ -254,16 +293,12 @@ LrWpanMac::DoDispose() for (uint32_t i = 0; i < m_txQueue.size(); i++) { m_txQueue[i]->txQPkt = nullptr; - m_txQueue[i]->txQMsduHandle = 0; } m_txQueue.clear(); for (uint32_t i = 0; i < m_indTxQueue.size(); i++) { m_indTxQueue[i]->txQPkt = nullptr; - m_indTxQueue[i]->seqNum = 0; - m_indTxQueue[i]->dstExtAddress = nullptr; - m_indTxQueue[i]->dstShortAddress = nullptr; } m_indTxQueue.clear(); @@ -2119,35 +2154,44 @@ LrWpanMac::PdDataIndication(uint32_t psduLength, Ptr p, uint8_t lqi) m_incomingSuperframeOrder = incomingSuperframe.GetFrameOrder(); m_incomingFnlCapSlot = incomingSuperframe.GetFinalCapSlot(); - m_incomingBeaconInterval = - (static_cast(1 << m_incomingBeaconOrder)) * - lrwpan::aBaseSuperframeDuration; - m_incomingSuperframeDuration = - lrwpan::aBaseSuperframeDuration * - (static_cast(1 << m_incomingSuperframeOrder)); - - if (incomingSuperframe.IsBattLifeExt()) + if (m_incomingBeaconOrder < 15) { - m_csmaCa->SetBatteryLifeExtension(true); + // Start Beacon-enabled mode + m_csmaCa->SetSlottedCsmaCa(); + m_incomingBeaconInterval = + (static_cast(1 << m_incomingBeaconOrder)) * + lrwpan::aBaseSuperframeDuration; + m_incomingSuperframeDuration = + lrwpan::aBaseSuperframeDuration * + (static_cast(1 << m_incomingSuperframeOrder)); + + if (incomingSuperframe.IsBattLifeExt()) + { + m_csmaCa->SetBatteryLifeExtension(true); + } + else + { + m_csmaCa->SetBatteryLifeExtension(false); + } + + // TODO: get Incoming frame GTS Fields here + + // Begin CAP on the current device using info from + // the Incoming superframe + NS_LOG_DEBUG("Incoming superframe Active Portion " + << "(Beacon + CAP + CFP): " << m_incomingSuperframeDuration + << " symbols"); + + m_incCapEvent = Simulator::ScheduleNow(&LrWpanMac::StartCAP, + this, + SuperframeType::INCOMING); } else { - m_csmaCa->SetBatteryLifeExtension(false); + // Start non-beacon enabled mode + m_csmaCa->SetUnSlottedCsmaCa(); } - if (m_incomingBeaconOrder < 15 && !m_csmaCa->IsSlottedCsmaCa()) - { - m_csmaCa->SetSlottedCsmaCa(); - } - - // TODO: get Incoming frame GTS Fields here - - // Begin CAP on the current device using info from the Incoming superframe - NS_LOG_DEBUG("Incoming superframe Active Portion (Beacon + CAP + CFP): " - << m_incomingSuperframeDuration << " symbols"); - m_incCapEvent = Simulator::ScheduleNow(&LrWpanMac::StartCAP, - this, - SuperframeType::INCOMING); m_setMacState = Simulator::ScheduleNow(&LrWpanMac::SetLrWpanMacState, this, MAC_IDLE); } diff --git a/src/lr-wpan/model/lr-wpan-mac.h b/src/lr-wpan/model/lr-wpan-mac.h index 8e5ad15c840..bd2f0b30772 100644 --- a/src/lr-wpan/model/lr-wpan-mac.h +++ b/src/lr-wpan/model/lr-wpan-mac.h @@ -82,6 +82,15 @@ enum LrWpanMacState MAC_CSMA_DEFERRED //!< MAC_CSMA_DEFERRED }; +/** + * Overloaded operator to print the value of a LrWpanMacState. + * + * \param os The output stream + * \param state The text value of the PHY state + * \return The output stream with text value of the MAC state + */ +std::ostream& operator<<(std::ostream& os, const LrWpanMacState& state); + /** * \ingroup lr-wpan *