Skip to content

Commit

Permalink
wifi: A non-AP MLD associated with a single link AP advertises the li…
Browse files Browse the repository at this point in the history
…nk MAC address
  • Loading branch information
stavallo authored and Stefano Avallone committed Dec 31, 2022
1 parent e6d6216 commit c0e535c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/wifi/model/wifi-net-device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

#include "wifi-net-device.h"

#include "wifi-mac.h"
#include "frame-exchange-manager.h"
#include "sta-wifi-mac.h"
#include "wifi-phy.h"

#include "ns3/channel.h"
Expand Down Expand Up @@ -374,6 +375,30 @@ WifiNetDevice::SetAddress(Address address)
Address
WifiNetDevice::GetAddress() const
{
Ptr<StaWifiMac> staMac;
std::set<uint8_t> linkIds;

/**
* Normally, the MAC address that the network device has to advertise to upper layers is
* the MLD address, if this device is an MLD, or the unique MAC address, otherwise.
* Advertising the MAC address returned by WifiMac::GetAddress() is therefore the right
* thing to do in both cases. However, there is an exception: if this device is a non-AP MLD
* associated with a single link AP (hence, no ML setup was done), we need to advertise the
* MAC address of the link used to communicate with the AP. In fact, if we advertised the
* MLD address, the AP could not forward a frame to us because it would not recognize our
* MLD address as the MAC address of an associated station.
*/

// Handle the exception first
if (m_mac->GetTypeOfStation() == STA &&
(staMac = StaticCast<StaWifiMac>(m_mac))->IsAssociated() && m_mac->GetNLinks() > 1 &&
(linkIds = staMac->GetSetupLinkIds()).size() == 1 &&
!GetRemoteStationManager(*linkIds.begin())
->GetMldAddress(m_mac->GetBssid(*linkIds.begin())))
{
return m_mac->GetFrameExchangeManager(*linkIds.begin())->GetAddress();
}

return m_mac->GetAddress();
}

Expand Down Expand Up @@ -504,7 +529,7 @@ WifiNetDevice::ForwardUp(Ptr<const Packet> packet, Mac48Address from, Mac48Addre
{
type = NetDevice::PACKET_MULTICAST;
}
else if (to == m_mac->GetAddress())
else if (to == GetAddress())
{
type = NetDevice::PACKET_HOST;
}
Expand Down

0 comments on commit c0e535c

Please sign in to comment.