diff --git a/src/wave/model/ocb-wifi-mac.cc b/src/wave/model/ocb-wifi-mac.cc index e9054c2f7..5dfd6f538 100644 --- a/src/wave/model/ocb-wifi-mac.cc +++ b/src/wave/model/ocb-wifi-mac.cc @@ -58,8 +58,6 @@ OcbWifiMac::OcbWifiMac (void) NS_LOG_FUNCTION (this); // Let the lower layers know that we are acting as an OCB node SetTypeOfStation (OCB); - // BSSID is still needed in the low part of MAC - WifiMac::SetBssid (WILDCARD_BSSID); } OcbWifiMac::~OcbWifiMac (void) @@ -130,7 +128,7 @@ OcbWifiMac::SetBssid (Mac48Address bssid) } Mac48Address -OcbWifiMac::GetBssid (void) const +OcbWifiMac::GetBssid (uint8_t /* linkId */) const { NS_LOG_WARN ("in OCB mode we should not call GetBssid"); return WILDCARD_BSSID; diff --git a/src/wave/model/ocb-wifi-mac.h b/src/wave/model/ocb-wifi-mac.h index c297c4cb5..bf4477f23 100644 --- a/src/wave/model/ocb-wifi-mac.h +++ b/src/wave/model/ocb-wifi-mac.h @@ -103,7 +103,7 @@ public: * here it will overloaded to log warn message * \return An invalid BSSID. */ - virtual Mac48Address GetBssid (void) const; + virtual Mac48Address GetBssid (uint8_t /* linkId */) const; /** * SetLinkUpCallback and SetLinkDownCallback will be overloaded * In OCB mode, stations can send packets directly whenever they want diff --git a/src/wifi/model/adhoc-wifi-mac.cc b/src/wifi/model/adhoc-wifi-mac.cc index ff021ce09..2fdaeb031 100644 --- a/src/wifi/model/adhoc-wifi-mac.cc +++ b/src/wifi/model/adhoc-wifi-mac.cc @@ -58,20 +58,6 @@ AdhocWifiMac::~AdhocWifiMac () NS_LOG_FUNCTION (this); } -void -AdhocWifiMac::SetAddress (Mac48Address address) -{ - NS_LOG_FUNCTION (this << address); - //In an IBSS, the BSSID is supposed to be generated per Section - //11.1.3 of IEEE 802.11. We don't currently do this - instead we - //make an IBSS STA a bit like an AP, with the BSSID for frames - //transmitted by each STA set to that STA's address. - // - //This is why we're overriding this method. - WifiMac::SetAddress (address); - WifiMac::SetBssid (address); -} - bool AdhocWifiMac::CanForwardPacketsTo (Mac48Address to) const { @@ -150,7 +136,7 @@ AdhocWifiMac::Enqueue (Ptr packet, Mac48Address to) } hdr.SetAddr1 (to); hdr.SetAddr2 (GetAddress ()); - hdr.SetAddr3 (GetBssid ()); + hdr.SetAddr3 (GetBssid (0)); hdr.SetDsNotFrom (); hdr.SetDsNotTo (); diff --git a/src/wifi/model/adhoc-wifi-mac.h b/src/wifi/model/adhoc-wifi-mac.h index 076094606..65d4cf346 100644 --- a/src/wifi/model/adhoc-wifi-mac.h +++ b/src/wifi/model/adhoc-wifi-mac.h @@ -44,7 +44,6 @@ public: AdhocWifiMac (); virtual ~AdhocWifiMac (); - void SetAddress (Mac48Address address) override; void SetLinkUpCallback (Callback linkUp) override; void Enqueue (Ptr packet, Mac48Address to) override; bool CanForwardPacketsTo (Mac48Address to) const override; diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 95d76e2db..f7e4c8eea 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -148,16 +148,6 @@ ApWifiMac::GetLink (uint8_t linkId) const return static_cast (WifiMac::GetLink (linkId)); } -void -ApWifiMac::SetAddress (Mac48Address address) -{ - NS_LOG_FUNCTION (this << address); - //As an AP, our MAC address is also the BSSID. Hence we are - //overriding this function and setting both in our parent class. - WifiMac::SetAddress (address); - WifiMac::SetBssid (address); -} - void ApWifiMac::ConfigureStandard (WifiStandard standard) { diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 6de02aaf8..0aa1ee080 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -65,7 +65,6 @@ public: void Enqueue (Ptr packet, Mac48Address to) override; void Enqueue (Ptr packet, Mac48Address to, Mac48Address from) override; bool SupportsSendFrom (void) const override; - void SetAddress (Mac48Address address) override; Ptr GetTxopQueue (AcIndex ac) const override; void ConfigureStandard (WifiStandard standard) override; diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index e9f4b80d7..492b766f9 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -190,6 +190,9 @@ void FrameExchangeManager::SetAddress (Mac48Address address) { NS_LOG_FUNCTION (this << address); + // For APs, the BSSID is the MAC address. For STAs, the BSSID will be overwritten + // when receiving Beacon frames or Probe Response frames + SetBssid (address); m_self = address; } @@ -206,6 +209,12 @@ FrameExchangeManager::SetBssid (Mac48Address bssid) m_bssid = bssid; } +Mac48Address +FrameExchangeManager::GetBssid (void) const +{ + return m_bssid; +} + void FrameExchangeManager::SetDroppedMpduCallback (DroppedMpdu callback) { diff --git a/src/wifi/model/frame-exchange-manager.h b/src/wifi/model/frame-exchange-manager.h index eb789186c..17bc3fb8e 100644 --- a/src/wifi/model/frame-exchange-manager.h +++ b/src/wifi/model/frame-exchange-manager.h @@ -162,6 +162,12 @@ public: * \param bssid the BSSID */ virtual void SetBssid (Mac48Address bssid); + /** + * Get the Basic Service Set Identification. + * + * \return the BSSID + */ + Mac48Address GetBssid (void) const; /** * Set the callback to invoke when an MPDU is dropped. * diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 61a68b9d8..c1b7122aa 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -204,12 +204,12 @@ StaWifiMac::SendProbeRequest (void) void StaWifiMac::SendAssociationRequest (bool isReassoc) { - NS_LOG_FUNCTION (this << GetBssid () << isReassoc); + NS_LOG_FUNCTION (this << GetBssid (0) << isReassoc); // TODO use appropriate linkId WifiMacHeader hdr; hdr.SetType (isReassoc ? WIFI_MAC_MGT_REASSOCIATION_REQUEST : WIFI_MAC_MGT_ASSOCIATION_REQUEST); - hdr.SetAddr1 (GetBssid ()); + hdr.SetAddr1 (GetBssid (0)); // TODO use appropriate linkId hdr.SetAddr2 (GetAddress ()); - hdr.SetAddr3 (GetBssid ()); + hdr.SetAddr3 (GetBssid (0)); // TODO use appropriate linkId hdr.SetDsNotFrom (); hdr.SetDsNotTo (); Ptr packet = Create (); @@ -242,7 +242,7 @@ StaWifiMac::SendAssociationRequest (bool isReassoc) else { MgtReassocRequestHeader reassoc; - reassoc.SetCurrentApAddress (GetBssid ()); + reassoc.SetCurrentApAddress (GetBssid (0)); // TODO use appropriate linkId reassoc.SetSsid (GetSsid ()); reassoc.SetSupportedRates (GetSupportedRates ()); reassoc.SetCapabilities (GetCapabilities ()); @@ -278,7 +278,7 @@ StaWifiMac::SendAssociationRequest (bool isReassoc) // AC_BE should be selected. // — If category AC_BE was not selected by the previous step, category AC_VO // shall be selected." (Sec. 10.2.3.2 of 802.11-2020) - else if (!GetWifiRemoteStationManager ()->GetQosSupported (GetBssid ())) + else if (!GetWifiRemoteStationManager ()->GetQosSupported (GetBssid (0))) // TODO use appropriate linkId { GetBEQueue ()->Queue (packet, hdr); } @@ -531,7 +531,7 @@ StaWifiMac::Enqueue (Ptr packet, Mac48Address to) hdr.SetNoOrder (); // explicitly set to 0 for the time being since HT control field is not yet implemented (set it to 1 when implemented) } - hdr.SetAddr1 (GetBssid ()); + hdr.SetAddr1 (GetBssid (0)); // TODO use appropriate linkId hdr.SetAddr2 (GetAddress ()); hdr.SetAddr3 (to); hdr.SetDsNotFrom (); @@ -582,7 +582,7 @@ StaWifiMac::Receive (Ptr mpdu, uint8_t linkId) NotifyRxDrop (packet); return; } - if (hdr->GetAddr2 () != GetBssid ()) + if (hdr->GetAddr2 () != GetBssid (0)) // TODO use appropriate linkId { NS_LOG_LOGIC ("Received data frame not from the BSS we are associated with: ignore"); NotifyRxDrop (packet); @@ -592,7 +592,7 @@ StaWifiMac::Receive (Ptr mpdu, uint8_t linkId) { if (hdr->IsQosAmsdu ()) { - NS_ASSERT (hdr->GetAddr3 () == GetBssid ()); + NS_ASSERT (hdr->GetAddr3 () == GetBssid (0)); // TODO use appropriate linkId DeaggregateAmsduAndForward (mpdu); packet = 0; } @@ -646,7 +646,7 @@ StaWifiMac::Receive (Ptr mpdu, uint8_t linkId) NS_LOG_LOGIC ("No match for BSS membership selector"); goodBeacon = false; } - if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid ()) + if ((IsWaitAssocResp () || IsAssociated ()) && hdr->GetAddr3 () != GetBssid (linkId)) { NS_LOG_LOGIC ("Beacon is not for us"); goodBeacon = false; @@ -783,7 +783,7 @@ StaWifiMac::UpdateApInfoFromBeacon (MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid, uint8_t linkId) { NS_LOG_FUNCTION (this << beacon << apAddr << bssid << +linkId); - SetBssid (bssid); + SetBssid (bssid, linkId); const CapabilityInformation& capabilities = beacon.GetCapabilities (); const SupportedRates& rates = beacon.GetSupportedRates (); for (const auto & mode : GetWifiPhy (linkId)->GetModeList ()) @@ -967,7 +967,7 @@ StaWifiMac::UpdateApInfoFromProbeResp (MgtProbeResponseHeader probeResp, Mac48Ad } GetWifiRemoteStationManager (linkId)->SetShortPreambleEnabled (isShortPreambleEnabled); GetWifiRemoteStationManager (linkId)->SetShortSlotTimeEnabled (capabilities.IsShortSlotTime ()); - SetBssid (bssid); + SetBssid (bssid, linkId); } void @@ -1173,12 +1173,12 @@ StaWifiMac::SetState (MacState value) if (value == ASSOCIATED && m_state != ASSOCIATED) { - m_assocLogger (GetBssid ()); + m_assocLogger (GetBssid (0)); // TODO use appropriate linkId } else if (value != ASSOCIATED && m_state == ASSOCIATED) { - m_deAssocLogger (GetBssid ()); + m_deAssocLogger (GetBssid (0)); // TODO use appropriate linkId } m_state = value; } diff --git a/src/wifi/model/wifi-mac.cc b/src/wifi/model/wifi-mac.cc index 8d5f899f6..e91987b5e 100644 --- a/src/wifi/model/wifi-mac.cc +++ b/src/wifi/model/wifi-mac.cc @@ -422,20 +422,16 @@ WifiMac::GetSsid (void) const } void -WifiMac::SetBssid (Mac48Address bssid) +WifiMac::SetBssid (Mac48Address bssid, uint8_t linkId) { - NS_LOG_FUNCTION (this << bssid); - m_bssid = bssid; - for (auto& link : m_links) - { - link->feManager->SetBssid (bssid); - } + NS_LOG_FUNCTION (this << bssid << +linkId); + GetLink (linkId).feManager->SetBssid (bssid); } Mac48Address -WifiMac::GetBssid (void) const +WifiMac::GetBssid (uint8_t linkId) const { - return m_bssid; + return GetLink (linkId).feManager->GetBssid (); } void @@ -763,7 +759,6 @@ WifiMac::SetupFrameExchangeManager (WifiStandard standard) feManager->SetMacTxMiddle (m_txMiddle); feManager->SetMacRxMiddle (m_rxMiddle); feManager->SetAddress (GetAddress ()); - feManager->SetBssid (GetBssid ()); feManager->GetWifiTxTimer ().SetMpduResponseTimeoutCallback (MakeCallback (&MpduResponseTimeoutTracedCallback::operator(), &m_mpduResponseTimeoutCallback)); feManager->GetWifiTxTimer ().SetPsduResponseTimeoutCallback (MakeCallback (&PsduResponseTimeoutTracedCallback::operator(), diff --git a/src/wifi/model/wifi-mac.h b/src/wifi/model/wifi-mac.h index b8d01b03c..934409ba2 100644 --- a/src/wifi/model/wifi-mac.h +++ b/src/wifi/model/wifi-mac.h @@ -223,13 +223,15 @@ public: */ virtual void SetAddress (Mac48Address address); /** - * \return the BSSID of the network this device belongs to. + * \return the BSSID of the network the given link belongs to. + * \param linkId the ID of the given link */ - Mac48Address GetBssid (void) const; + Mac48Address GetBssid (uint8_t linkId) const; /** - * \param bssid the BSSID of the network that this device belongs to. + * \param bssid the BSSID of the network that the given link belongs to. + * \param linkId the ID of the given link */ - void SetBssid (Mac48Address bssid); + void SetBssid (Mac48Address bssid, uint8_t linkId); /** * Return true if packets can be forwarded to the given destination, @@ -752,7 +754,6 @@ private: Mac48Address m_address; //!< MAC address of this station Ssid m_ssid; //!< Service Set ID (SSID) - Mac48Address m_bssid; //!< the BSSID /** This type defines a mapping between an Access Category index, and a pointer to the corresponding channel access function. diff --git a/src/wifi/test/wifi-primary-channels-test.cc b/src/wifi/test/wifi-primary-channels-test.cc index 9961a05db..d8925d7da 100644 --- a/src/wifi/test/wifi-primary-channels-test.cc +++ b/src/wifi/test/wifi-primary-channels-test.cc @@ -682,7 +682,7 @@ WifiPrimaryChannelsTest::SendDlSuPpdu (uint8_t bss, uint16_t txChannelWidth) hdr.SetQosTid (0); hdr.SetAddr1 (staDev->GetMac ()->GetAddress ()); hdr.SetAddr2 (apDev->GetMac ()->GetAddress ()); - hdr.SetAddr3 (apDev->GetMac ()->GetBssid ()); + hdr.SetAddr3 (apDev->GetMac ()->GetBssid (0)); hdr.SetSequenceNumber (1); Ptr psdu = Create (Create (1000), hdr); apDev->GetPhy ()->Send (WifiConstPsduMap ({std::make_pair (SU_STA_ID, psdu)}), txVector); @@ -703,7 +703,7 @@ WifiPrimaryChannelsTest::SendDlMuPpdu (uint8_t bss, uint16_t txChannelWidth, HeR hdr.SetType (WIFI_MAC_QOSDATA); hdr.SetQosTid (0); hdr.SetAddr2 (apDev->GetMac ()->GetAddress ()); - hdr.SetAddr3 (apDev->GetMac ()->GetBssid ()); + hdr.SetAddr3 (apDev->GetMac ()->GetBssid (0)); hdr.SetSequenceNumber (1); WifiConstPsduMap psduMap; @@ -749,7 +749,7 @@ WifiPrimaryChannelsTest::DoSendHeTbPpdu (uint8_t bss, uint16_t txChannelWidth, H hdr.SetType (WIFI_MAC_QOSDATA); hdr.SetQosTid (0); hdr.SetAddr1 (apDev->GetMac ()->GetAddress ()); - hdr.SetAddr3 (apDev->GetMac ()->GetBssid ()); + hdr.SetAddr3 (apDev->GetMac ()->GetBssid (0)); hdr.SetSequenceNumber (1); Time duration = Seconds (0);