diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index 2188b4dca..1f629bf6c 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -870,7 +870,6 @@ FrameExchangeManager::Receive (Ptr psdu, RxSignalInfo rxSignalInfo, return; } - double rxSnr = rxSignalInfo.snr; if (psdu->GetNMpdus () == 1) { // if perMpduStatus is not empty (i.e., this MPDU is not included in an A-MPDU) @@ -881,13 +880,13 @@ FrameExchangeManager::Receive (Ptr psdu, RxSignalInfo rxSignalInfo, if (!psdu->GetHeader (0).IsAck () && !psdu->GetHeader (0).IsCts ()) { m_mac->GetWifiRemoteStationManager ()->ReportRxOk (psdu->GetHeader (0).GetAddr2 (), - rxSnr, txVector.GetMode ()); + rxSignalInfo, txVector.GetMode ()); } - ReceiveMpdu (*(psdu->begin ()), rxSnr, txVector, perMpduStatus.empty ()); + ReceiveMpdu (*(psdu->begin ()), rxSignalInfo, txVector, perMpduStatus.empty ()); } else { - EndReceiveAmpdu (psdu, rxSnr, txVector, perMpduStatus); + EndReceiveAmpdu (psdu, rxSignalInfo.snr, txVector, perMpduStatus); } } @@ -963,15 +962,16 @@ FrameExchangeManager::NavResetTimeout (void) } void -FrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, +FrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, bool inAmpdu) { - NS_LOG_FUNCTION (this << *mpdu << rxSnr << txVector << inAmpdu); + NS_LOG_FUNCTION (this << *mpdu << rxSignalInfo << txVector << inAmpdu); // The received MPDU is either broadcast or addressed to this station NS_ASSERT (mpdu->GetHeader ().GetAddr1 ().IsGroup () || mpdu->GetHeader ().GetAddr1 () == m_self); const WifiMacHeader& hdr = mpdu->GetHeader (); + double rxSnr = rxSignalInfo.snr; if (hdr.IsCtl ()) { @@ -1005,7 +1005,7 @@ FrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, SnrTag tag; mpdu->GetPacket ()->PeekPacketTag (tag); - m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxSnr, txVector.GetMode ()); + m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxSignalInfo, txVector.GetMode ()); m_mac->GetWifiRemoteStationManager ()->ReportRtsOk (m_mpdu->GetHeader (), rxSnr, txVector.GetMode (), tag.Get ()); @@ -1019,7 +1019,7 @@ FrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, NS_ASSERT (hdr.GetAddr1 () == m_self); SnrTag tag; mpdu->GetPacket ()->PeekPacketTag (tag); - ReceivedNormalAck (m_mpdu, m_txParams.m_txVector, txVector, rxSnr, tag.Get ()); + ReceivedNormalAck (m_mpdu, m_txParams.m_txVector, txVector, rxSignalInfo, tag.Get ()); m_mpdu = 0; } } @@ -1061,7 +1061,7 @@ FrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, void FrameExchangeManager::ReceivedNormalAck (Ptr mpdu, const WifiTxVector& txVector, - const WifiTxVector& ackTxVector, double rxSnr, + const WifiTxVector& ackTxVector, RxSignalInfo rxSignalInfo, double snr) { Mac48Address sender = mpdu->GetHeader ().GetAddr1 (); @@ -1072,9 +1072,8 @@ FrameExchangeManager::ReceivedNormalAck (Ptr mpdu, const WifiT // When fragmentation is used, only update manager when the last fragment is acknowledged if (!mpdu->GetHeader ().IsMoreFragments ()) { - m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxSnr, ackTxVector.GetMode ()); - m_mac->GetWifiRemoteStationManager ()->ReportDataOk (mpdu, rxSnr, ackTxVector.GetMode (), - snr, txVector); + m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxSignalInfo, ackTxVector.GetMode ()); + m_mac->GetWifiRemoteStationManager ()->ReportDataOk (mpdu, rxSignalInfo.snr, ackTxVector.GetMode (), snr, txVector); } // cancel the timer m_txTimer.Cancel (); diff --git a/src/wifi/model/frame-exchange-manager.h b/src/wifi/model/frame-exchange-manager.h index 95e2fa223..9d66bd1d9 100644 --- a/src/wifi/model/frame-exchange-manager.h +++ b/src/wifi/model/frame-exchange-manager.h @@ -246,11 +246,11 @@ protected: * This method handles the reception of an MPDU (possibly included in an A-MPDU) * * \param mpdu the received MPDU - * \param rxSnr snr of MPDU received in linear scale + * \param rxSignalInfo the info on the received signal (\see RxSignalInfo) * \param txVector TxVector of the received PSDU * \param inAmpdu true if the MPDU is part of an A-MPDU */ - virtual void ReceiveMpdu (Ptr mpdu, double rxSnr, + virtual void ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, bool inAmpdu); /** @@ -271,11 +271,11 @@ protected: * \param mpdu the MPDU that was acknowledged * \param txVector the TXVECTOR used to transmit the MPDU that was acknowledged * \param ackTxVector the TXVECTOR used to transmit the Normal Ack frame - * \param rxSnr snr of MPDU received in linear scale + * \param rxSignalInfo the info on the received signal (\see RxSignalInfo) * \param snr the SNR at the receiver for the MPDU that was acknowledged */ virtual void ReceivedNormalAck (Ptr mpdu, const WifiTxVector& txVector, - const WifiTxVector& ackTxVector, double rxSnr, double snr); + const WifiTxVector& ackTxVector, RxSignalInfo rxSignalInfo, double snr); /** * Notify other components that an MPDU was acknowledged. diff --git a/src/wifi/model/ht-frame-exchange-manager.cc b/src/wifi/model/ht-frame-exchange-manager.cc index 469300efd..509986f98 100644 --- a/src/wifi/model/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht-frame-exchange-manager.cc @@ -1237,7 +1237,7 @@ HtFrameExchangeManager::GetBlockAckType (Mac48Address originator, uint8_t tid) c } void -HtFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, +HtFrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, bool inAmpdu) { // The received MPDU is either broadcast or addressed to this station @@ -1245,6 +1245,7 @@ HtFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, || mpdu->GetHeader ().GetAddr1 () == m_self); const WifiMacHeader& hdr = mpdu->GetHeader (); + double rxSnr = rxSignalInfo.snr; if (hdr.IsCtl ()) { @@ -1259,7 +1260,7 @@ HtFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, SnrTag tag; mpdu->GetPacket ()->PeekPacketTag (tag); - m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxSnr, txVector.GetMode ()); + m_mac->GetWifiRemoteStationManager ()->ReportRxOk (sender, rxSignalInfo, txVector.GetMode ()); m_mac->GetWifiRemoteStationManager ()->ReportRtsOk (m_psdu->GetHeader (0), rxSnr, txVector.GetMode (), tag.Get ()); @@ -1326,7 +1327,7 @@ HtFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, else { // the received control frame cannot be handled here - QosFrameExchangeManager::ReceiveMpdu (mpdu, rxSnr, txVector, inAmpdu); + QosFrameExchangeManager::ReceiveMpdu (mpdu, rxSignalInfo, txVector, inAmpdu); } return; } @@ -1356,7 +1357,7 @@ HtFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, // to a Block Ack agreement } - QosFrameExchangeManager::ReceiveMpdu (mpdu, rxSnr, txVector, inAmpdu); + QosFrameExchangeManager::ReceiveMpdu (mpdu, rxSignalInfo, txVector, inAmpdu); } void diff --git a/src/wifi/model/ht-frame-exchange-manager.h b/src/wifi/model/ht-frame-exchange-manager.h index aed402605..92f5a7388 100644 --- a/src/wifi/model/ht-frame-exchange-manager.h +++ b/src/wifi/model/ht-frame-exchange-manager.h @@ -186,7 +186,7 @@ protected: virtual void DoDispose () override; // Overridden from QosFrameExchangeManager - virtual void ReceiveMpdu (Ptr mpdu, double rxSnr, + virtual void ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, bool inAmpdu) override; virtual void EndReceiveAmpdu (Ptr psdu, double rxSnr, const WifiTxVector& txVector, const std::vector& perMpduStatus) override; diff --git a/src/wifi/model/qos-frame-exchange-manager.cc b/src/wifi/model/qos-frame-exchange-manager.cc index c370ecbf4..44b85a268 100644 --- a/src/wifi/model/qos-frame-exchange-manager.cc +++ b/src/wifi/model/qos-frame-exchange-manager.cc @@ -628,7 +628,7 @@ QosFrameExchangeManager::SetTxopHolder (Ptr psdu, const WifiTxVe } void -QosFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, +QosFrameExchangeManager::ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, bool inAmpdu) { // The received MPDU is either broadcast or addressed to this station @@ -644,6 +644,7 @@ QosFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, return; } + double rxSnr = rxSignalInfo.snr; if (hdr.IsRts ()) { NS_ABORT_MSG_IF (inAmpdu, "Received RTS as part of an A-MPDU"); @@ -685,7 +686,7 @@ QosFrameExchangeManager::ReceiveMpdu (Ptr mpdu, double rxSnr, return; } - return FrameExchangeManager::ReceiveMpdu (mpdu, rxSnr, txVector, inAmpdu); + return FrameExchangeManager::ReceiveMpdu (mpdu, rxSignalInfo, txVector, inAmpdu); } } //namespace ns3 diff --git a/src/wifi/model/qos-frame-exchange-manager.h b/src/wifi/model/qos-frame-exchange-manager.h index dccf69f29..a0f96d39c 100644 --- a/src/wifi/model/qos-frame-exchange-manager.h +++ b/src/wifi/model/qos-frame-exchange-manager.h @@ -94,7 +94,7 @@ protected: virtual void DoDispose () override; // Overridden from FrameExchangeManager - virtual void ReceiveMpdu (Ptr mpdu, double rxSnr, + virtual void ReceiveMpdu (Ptr mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector& txVector, bool inAmpdu) override; virtual void PreProcessFrame (Ptr psdu, const WifiTxVector& txVector) override; virtual Time GetFrameDurationId (const WifiMacHeader& header, uint32_t size, diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc index f28ebb38e..4ebdb8f63 100644 --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -900,14 +900,16 @@ WifiRemoteStationManager::ReportFinalDataFailed (Ptr mpd } void -WifiRemoteStationManager::ReportRxOk (Mac48Address address, double rxSnr, WifiMode txMode) +WifiRemoteStationManager::ReportRxOk (Mac48Address address, RxSignalInfo rxSignalInfo, WifiMode txMode) { - NS_LOG_FUNCTION (this << address << rxSnr << txMode); + NS_LOG_FUNCTION (this << address << rxSignalInfo << txMode); if (address.IsGroup ()) { return; } - DoReportRxOk (Lookup (address), rxSnr, txMode); + WifiRemoteStation *station = Lookup (address); + DoReportRxOk (station, rxSignalInfo.snr, txMode); + station->m_rssiAndUpdateTimePair = std::make_pair (rxSignalInfo.rssi, Simulator::Now ()); } void @@ -1199,6 +1201,26 @@ WifiRemoteStationManager::GetInfo (Mac48Address address) return state->m_info; } +double +WifiRemoteStationManager::GetMostRecentRssi (Mac48Address address) const +{ + double rssi = 0.0; + Time mostRecentUpdateTime = NanoSeconds (0); + for (const auto & station : m_stations) + { + if (station->m_state->m_address == address) //get most recent RSSI irrespective of TID + { + if (station->m_rssiAndUpdateTimePair.second >= mostRecentUpdateTime) + { + rssi = station->m_rssiAndUpdateTimePair.first; + mostRecentUpdateTime = station->m_rssiAndUpdateTimePair.second; + } + } + } + NS_ASSERT (mostRecentUpdateTime.IsStrictlyPositive ()); + return rssi; +} + WifiRemoteStationState * WifiRemoteStationManager::LookupState (Mac48Address address) const { @@ -1244,6 +1266,7 @@ WifiRemoteStationManager::Lookup (Mac48Address address) const WifiRemoteStation *station = DoCreateStation (); station->m_state = state; + station->m_rssiAndUpdateTimePair = std::make_pair (0, Seconds (0)); const_cast (this)->m_stations.push_back (station); return station; } diff --git a/src/wifi/model/wifi-remote-station-manager.h b/src/wifi/model/wifi-remote-station-manager.h index 423276ebd..4485d72b3 100644 --- a/src/wifi/model/wifi-remote-station-manager.h +++ b/src/wifi/model/wifi-remote-station-manager.h @@ -44,6 +44,7 @@ class WifiMacQueueItem; class WifiTxVector; struct WifiRemoteStationState; +struct RxSignalInfo; /** * \brief hold per-remote-station state. @@ -59,7 +60,8 @@ struct WifiRemoteStationState; struct WifiRemoteStation { virtual ~WifiRemoteStation () {}; - WifiRemoteStationState *m_state; //!< Remote station state + WifiRemoteStationState *m_state; //!< Remote station state + std::pair m_rssiAndUpdateTimePair; //!< RSSI (in dBm) of the most recent packet received from the remote station along with update time }; /** @@ -776,12 +778,12 @@ public: /** * \param address remote address - * \param rxSnr the SNR of the packet received + * \param rxSignalInfo the info on the received signal (\see RxSignalInfo) * \param txMode the transmission mode used for the packet received * * Should be invoked whenever a packet is successfully received. */ - void ReportRxOk (Mac48Address address, double rxSnr, WifiMode txMode); + void ReportRxOk (Mac48Address address, RxSignalInfo rxSignalInfo, WifiMode txMode); /** * \param header MAC header @@ -847,6 +849,16 @@ public: * \return information regarding the remote station associated with the given address */ WifiRemoteStationInfo GetInfo (Mac48Address address); + /** + * \param address of the remote station + * + * \return the RSSI (in dBm) of the most recent packet received from the remote station (irrespective of TID) + * + * This method is typically used when the device needs + * to estimate the target UL RSSI info to put in the + * Trigger frame to send to the remote station. + */ + double GetMostRecentRssi (Mac48Address address) const; /** * Set the default transmission power level *