diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 45f819854..6a2db0532 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -960,10 +960,17 @@ StaWifiMac::GetSetupLinkIds() const Mac48Address StaWifiMac::DoGetLocalAddress(const Mac48Address& remoteAddr) const { - auto linkIds = GetSetupLinkIds(); - NS_ASSERT_MSG(!linkIds.empty(), "Not associated"); - uint8_t linkId = *linkIds.begin(); - return GetFrameExchangeManager(linkId)->GetAddress(); + for (const auto& [id, link] : GetLinks()) + { + if (GetStaLink(link).bssid == remoteAddr) + { + // the remote address is the address of the (single link) AP we are associated with; + return link->feManager->GetAddress(); + } + } + + // the remote address is unknown + return GetAddress(); } bool diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index df291846b..724acfd15 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -1780,7 +1780,7 @@ WifiMac::GetLocalAddress(const Mac48Address& remoteAddr) const // this is a single link device return m_address; } - // this is an MLD (hence the remote device is single link) + // this is an MLD (hence the remote device is single link or unknown) return DoGetLocalAddress(remoteAddr); }