From eb92e3c5a23f039efdcf6ff66be73c602a9cf298 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 12 Jun 2019 18:36:49 +0200 Subject: [PATCH] wifi: Handle HE TB PPDUs in TX vector --- src/wifi/model/wifi-mode.cc | 3 +-- src/wifi/model/wifi-phy.cc | 6 +++--- src/wifi/model/wifi-ppdu.cc | 2 +- src/wifi/model/wifi-tx-vector.cc | 28 +++++++++++++++++----------- src/wifi/model/wifi-tx-vector.h | 6 ++++++ 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/wifi/model/wifi-mode.cc b/src/wifi/model/wifi-mode.cc index 8cde7fcc5..0aea1eea3 100644 --- a/src/wifi/model/wifi-mode.cc +++ b/src/wifi/model/wifi-mode.cc @@ -115,8 +115,7 @@ WifiMode::GetDataRate (WifiTxVector txVector, uint16_t staId) const { uint16_t bw = txVector.GetChannelWidth (); uint8_t nss = txVector.GetNss (staId); - if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU - || txVector.GetPreambleType () == WIFI_PREAMBLE_HE_TB) + if (txVector.IsMu ()) { bw = HeRu::GetBandwidth (txVector.GetRu (staId).ruType); } diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index e9c7e7bd6..a51538d82 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -3243,7 +3243,7 @@ WifiPhy::EndReceive (Ptr event) WifiTxVector txVector = event->GetTxVector (); uint16_t channelWidth = std::min (GetChannelWidth (), txVector.GetChannelWidth ()); WifiSpectrumBand band; - if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU) + if (txVector.IsMu ()) { band = GetRuBand (txVector, staId); channelWidth = HeRu::GetBandwidth (txVector.GetRu (staId).ruType); @@ -3278,7 +3278,7 @@ WifiPhy::GetReceptionStatus (Ptr psdu, Ptr event, uint16_ uint16_t channelWidth = std::min (GetChannelWidth (), event->GetTxVector ().GetChannelWidth ()); WifiTxVector txVector = event->GetTxVector (); WifiSpectrumBand band; - if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU) + if (txVector.IsMu ()) { band = GetRuBand (txVector, staId); channelWidth = HeRu::GetBandwidth (txVector.GetRu (staId).ruType); @@ -3317,7 +3317,7 @@ WifiPhy::GetReceptionStatus (Ptr psdu, Ptr event, uint16_ WifiSpectrumBand WifiPhy::GetRuBand (WifiTxVector txVector, uint16_t staId) { - NS_ASSERT (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU); + NS_ASSERT (txVector.IsMu ()); WifiSpectrumBand band; HeRu::RuSpec ru = txVector.GetRu (staId); uint16_t channelWidth = txVector.GetChannelWidth (); diff --git a/src/wifi/model/wifi-ppdu.cc b/src/wifi/model/wifi-ppdu.cc index f3681213b..1202cc092 100644 --- a/src/wifi/model/wifi-ppdu.cc +++ b/src/wifi/model/wifi-ppdu.cc @@ -52,7 +52,7 @@ WifiPpdu::WifiPpdu (const WifiConstPsduMap & psdus, WifiTxVector txVector, Time m_txPowerLevel (txVector.GetTxPowerLevel ()) { NS_LOG_FUNCTION (this << psdus << txVector << ppduDuration << band); - if (m_preamble == WIFI_PREAMBLE_HE_MU) + if (txVector.IsMu ()) { m_muUserInfos = txVector.GetHeMuUserInfoMap (); } diff --git a/src/wifi/model/wifi-tx-vector.cc b/src/wifi/model/wifi-tx-vector.cc index 1c487867b..f17aa4a68 100644 --- a/src/wifi/model/wifi-tx-vector.cc +++ b/src/wifi/model/wifi-tx-vector.cc @@ -110,7 +110,7 @@ WifiTxVector::GetMode (uint16_t staId) const { NS_FATAL_ERROR ("WifiTxVector mode must be set before using"); } - if (m_preamble == WIFI_PREAMBLE_HE_MU || m_preamble == WIFI_PREAMBLE_HE_TB) + if (IsMu ()) { NS_ABORT_MSG_IF (staId > 2048, "STA-ID should be correctly set for HE MU (" << staId << ")"); NS_ASSERT (m_muUserInfos.find (staId) != m_muUserInfos.end ()); @@ -169,7 +169,7 @@ WifiTxVector::GetNTx (void) const uint8_t WifiTxVector::GetNss (uint16_t staId) const { - if (m_preamble == WIFI_PREAMBLE_HE_MU || m_preamble == WIFI_PREAMBLE_HE_TB) + if (IsMu ()) { NS_ABORT_MSG_IF (staId > 2048, "STA-ID should be correctly set for HE MU (" << staId << ")"); NS_ASSERT (m_muUserInfos.find (staId) != m_muUserInfos.end ()); @@ -182,7 +182,7 @@ uint8_t WifiTxVector::GetNssMax (void) const { uint8_t nss = 0; - if (m_preamble == WIFI_PREAMBLE_HE_MU || m_preamble == WIFI_PREAMBLE_HE_TB) + if (IsMu ()) { for (const auto & info : m_muUserInfos) { @@ -230,7 +230,7 @@ WifiTxVector::SetMode (WifiMode mode) void WifiTxVector::SetMode (WifiMode mode, uint16_t staId) { - NS_ABORT_MSG_IF (m_preamble != WIFI_PREAMBLE_HE_MU, "Not an HE MU transmission"); + NS_ABORT_MSG_IF (!IsMu (), "Not an HE MU transmission"); NS_ABORT_MSG_IF (staId > 2048, "STA-ID should be correctly set for HE MU"); m_muUserInfos[staId].mcs = mode; m_modeInitialized = true; @@ -275,7 +275,7 @@ WifiTxVector::SetNss (uint8_t nss) void WifiTxVector::SetNss (uint8_t nss, uint16_t staId) { - NS_ABORT_MSG_IF (m_preamble != WIFI_PREAMBLE_HE_MU, "Not an HE MU transmission"); + NS_ABORT_MSG_IF (!IsMu (), "Not an HE MU transmission"); NS_ABORT_MSG_IF (staId > 2048, "STA-ID should be correctly set for HE MU"); m_muUserInfos[staId].nss = nss; } @@ -352,10 +352,16 @@ WifiTxVector::IsValid (void) const return true; } +bool +WifiTxVector::IsMu (void) const +{ + return (m_preamble == WIFI_PREAMBLE_HE_MU || m_preamble == WIFI_PREAMBLE_HE_TB); +} + HeRu::RuSpec WifiTxVector::GetRu (uint16_t staId) const { - NS_ABORT_MSG_IF (m_preamble != WIFI_PREAMBLE_HE_MU, "RU only available for MU"); + NS_ABORT_MSG_IF (!IsMu (), "RU only available for MU"); NS_ABORT_MSG_IF (staId > 2048, "STA-ID should be correctly set for HE MU"); return m_muUserInfos.at (staId).ru; } @@ -363,7 +369,7 @@ WifiTxVector::GetRu (uint16_t staId) const void WifiTxVector::SetRu (HeRu::RuSpec ru, uint16_t staId) { - NS_ABORT_MSG_IF (m_preamble != WIFI_PREAMBLE_HE_MU, "RU only available for MU"); + NS_ABORT_MSG_IF (!IsMu (), "RU only available for MU"); NS_ABORT_MSG_IF (staId > 2048, "STA-ID should be correctly set for HE MU"); m_muUserInfos[staId].ru = ru; } @@ -371,14 +377,14 @@ WifiTxVector::SetRu (HeRu::RuSpec ru, uint16_t staId) HeMuUserInfo WifiTxVector::GetHeMuUserInfo (uint16_t staId) const { - NS_ABORT_MSG_IF (m_preamble != WIFI_PREAMBLE_HE_MU, "HE MU user info only available for MU"); + NS_ABORT_MSG_IF (!IsMu (), "HE MU user info only available for MU"); return m_muUserInfos.at (staId); } void WifiTxVector::SetHeMuUserInfo (uint16_t staId, HeMuUserInfo userInfo) { - NS_ABORT_MSG_IF (m_preamble != WIFI_PREAMBLE_HE_MU, "HE MU user info only available for MU"); + NS_ABORT_MSG_IF (!IsMu (), "HE MU user info only available for MU"); NS_ABORT_MSG_IF (staId > 2048, "STA-ID should be correctly set for HE MU"); NS_ABORT_MSG_IF (userInfo.mcs.GetModulationClass () != WIFI_MOD_CLASS_HE, "Only HE modes authorized for HE MU"); m_muUserInfos[staId] = userInfo; @@ -388,7 +394,7 @@ WifiTxVector::SetHeMuUserInfo (uint16_t staId, HeMuUserInfo userInfo) const WifiTxVector::HeMuUserInfoMap& WifiTxVector::GetHeMuUserInfoMap (void) const { - NS_ABORT_MSG_IF (m_preamble != WIFI_PREAMBLE_HE_MU, "HE MU user info map only available for MU"); + NS_ABORT_MSG_IF (!IsMu (), "HE MU user info map only available for MU"); return m_muUserInfos; } @@ -408,7 +414,7 @@ std::ostream & operator << ( std::ostream &os, const WifiTxVector &v) << " MPDU aggregation: " << v.IsAggregation () << " STBC: " << v.IsStbc () << " FEC coding: " << (v.IsLdpc () ? "LDPC" : "BCC"); - if (v.GetPreambleType () == WIFI_PREAMBLE_HE_MU) + if (v.IsMu ()) { WifiTxVector::HeMuUserInfoMap userInfoMap = v.GetHeMuUserInfoMap (); os << " num User Infos: " << userInfoMap.size (); diff --git a/src/wifi/model/wifi-tx-vector.h b/src/wifi/model/wifi-tx-vector.h index 65dc49c24..3fbf78182 100644 --- a/src/wifi/model/wifi-tx-vector.h +++ b/src/wifi/model/wifi-tx-vector.h @@ -288,6 +288,12 @@ public: */ bool IsValid (void) const; /** + * Return true if this TX vector is used for a multi-user transmission. + * + * \return true if this TX vector is used for a multi-user transmission + */ + bool IsMu (void) const; + /** * Get the RU specification for the STA-ID. * This is applicable only for HE MU. *