diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.cc b/src/wifi/model/eht/eht-frame-exchange-manager.cc index 7fb088945..38da580f4 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.cc +++ b/src/wifi/model/eht/eht-frame-exchange-manager.cc @@ -121,4 +121,37 @@ EhtFrameExchangeManager::ForwardPsduDown(Ptr psdu, WifiTxVector& HeFrameExchangeManager::ForwardPsduDown(psdu, txVector); } +std::optional +EhtFrameExchangeManager::GetMostRecentRssi(const Mac48Address& address) const +{ + auto optRssi = HeFrameExchangeManager::GetMostRecentRssi(address); + + if (optRssi) + { + return optRssi; + } + + auto mldAddress = GetWifiRemoteStationManager()->GetMldAddress(address); + + if (!mldAddress) + { + // not an MLD, nothing else can be done + return std::nullopt; + } + + for (uint8_t linkId = 0; linkId < m_mac->GetNLinks(); linkId++) + { + std::optional linkAddress; + if (linkId != m_linkId && + (linkAddress = m_mac->GetWifiRemoteStationManager(linkId)->GetAffiliatedStaAddress( + *mldAddress)) && + (optRssi = m_mac->GetWifiRemoteStationManager(linkId)->GetMostRecentRssi(*linkAddress))) + { + return optRssi; + } + } + + return std::nullopt; +} + } // namespace ns3 diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.h b/src/wifi/model/eht/eht-frame-exchange-manager.h index ed7c360a9..84069b2f7 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.h +++ b/src/wifi/model/eht/eht-frame-exchange-manager.h @@ -45,6 +45,17 @@ class EhtFrameExchangeManager : public HeFrameExchangeManager void SetLinkId(uint8_t linkId) override; Ptr CreateAliasIfNeeded(Ptr mpdu) const override; + /** + * Get the RSSI (in dBm) of the most recent packet received from the station having + * the given address. If there is no such information for the given station and the + * station is affiliated with an MLD, return the RSSI (in dBm) of the most recent + * packet received from another station of the same MLD. + * + * \param address of the remote station + * \return the RSSI (in dBm) of the most recent packet received from the remote station + */ + std::optional GetMostRecentRssi(const Mac48Address& address) const override; + protected: void ForwardPsduDown(Ptr psdu, WifiTxVector& txVector) override; }; diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index 7ebe62fed..628fa6e85 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -1195,10 +1195,12 @@ HeFrameExchangeManager::GetHeTbTxVector(CtrlTriggerHeader trigger, Mac48Address * * Refer to section 27.3.14.2 (Power pre-correction) of 802.11ax Draft 4.0 for more details. */ + auto optRssi = GetMostRecentRssi(triggerSender); + NS_ASSERT(optRssi); int8_t pathLossDb = trigger.GetApTxPower() - - static_cast(GetWifiRemoteStationManager()->GetMostRecentRssi( - triggerSender)); // cast RSSI to be on equal footing with AP Tx power information + static_cast( + *optRssi); // cast RSSI to be on equal footing with AP Tx power information double reqTxPowerDbm = static_cast(userInfoIt->GetUlTargetRssi() + pathLossDb); // Convert the transmit power to a power level @@ -1231,6 +1233,12 @@ HeFrameExchangeManager::GetHeTbTxVector(CtrlTriggerHeader trigger, Mac48Address return v; } +std::optional +HeFrameExchangeManager::GetMostRecentRssi(const Mac48Address& address) const +{ + return GetWifiRemoteStationManager()->GetMostRecentRssi(address); +} + void HeFrameExchangeManager::SetTargetRssi(CtrlTriggerHeader& trigger) const { @@ -1244,8 +1252,9 @@ HeFrameExchangeManager::SetTargetRssi(CtrlTriggerHeader& trigger) const const auto staList = m_apMac->GetStaList(m_linkId); auto itAidAddr = staList.find(userInfo.GetAid12()); NS_ASSERT(itAidAddr != staList.end()); - int8_t rssi = static_cast( - GetWifiRemoteStationManager()->GetMostRecentRssi(itAidAddr->second)); + auto optRssi = GetMostRecentRssi(itAidAddr->second); + NS_ASSERT(optRssi); + int8_t rssi = static_cast(*optRssi); rssi = (rssi >= -20) ? -20 : ((rssi <= -110) ? -110 : rssi); // cap so as to keep within [-110; -20] dBm diff --git a/src/wifi/model/he/he-frame-exchange-manager.h b/src/wifi/model/he/he-frame-exchange-manager.h index ff3a1f0e4..634449b99 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.h +++ b/src/wifi/model/he/he-frame-exchange-manager.h @@ -93,6 +93,15 @@ class HeFrameExchangeManager : public VhtFrameExchangeManager */ virtual void SetTargetRssi(CtrlTriggerHeader& trigger) const; + /** + * Get the RSSI (in dBm) of the most recent packet received from the station having + * the given address. + * + * \param address of the remote station + * \return the RSSI (in dBm) of the most recent packet received from the remote station + */ + virtual std::optional GetMostRecentRssi(const Mac48Address& address) const; + protected: void DoDispose() override; diff --git a/src/wifi/model/wifi-remote-station-manager.cc b/src/wifi/model/wifi-remote-station-manager.cc index 5b87e4859..3c680c69e 100644 --- a/src/wifi/model/wifi-remote-station-manager.cc +++ b/src/wifi/model/wifi-remote-station-manager.cc @@ -1338,7 +1338,7 @@ WifiRemoteStationManager::GetInfo(Mac48Address address) return LookupState(address)->m_info; } -double +std::optional WifiRemoteStationManager::GetMostRecentRssi(Mac48Address address) const { auto stationIt = m_stations.find(address); @@ -1346,8 +1346,11 @@ WifiRemoteStationManager::GetMostRecentRssi(Mac48Address address) const auto station = stationIt->second; auto rssi = station->m_rssiAndUpdateTimePair.first; auto ts = station->m_rssiAndUpdateTimePair.second; - NS_ASSERT_MSG(ts.IsStrictlyPositive(), "address: " << address << " ts:" << ts); - return rssi; + if (ts.IsStrictlyPositive()) + { + return rssi; + } + return std::nullopt; } std::shared_ptr diff --git a/src/wifi/model/wifi-remote-station-manager.h b/src/wifi/model/wifi-remote-station-manager.h index e63a5dffe..f5c611367 100644 --- a/src/wifi/model/wifi-remote-station-manager.h +++ b/src/wifi/model/wifi-remote-station-manager.h @@ -973,7 +973,7 @@ class WifiRemoteStationManager : public Object * to estimate the target UL RSSI info to put in the * Trigger frame to send to the remote station. */ - double GetMostRecentRssi(Mac48Address address) const; + std::optional GetMostRecentRssi(Mac48Address address) const; /** * Set the default transmission power level *