From e574f80fca2993b7b5ed9d5de149631111a86d10 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 18 Jan 2023 10:12:29 +0100 Subject: [PATCH] wifi: Add a WifiPsdu method to check if a PSDU is setting the NAV --- src/wifi/model/frame-exchange-manager.cc | 7 +------ src/wifi/model/wifi-psdu.cc | 10 ++++++++++ src/wifi/model/wifi-psdu.h | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index d5f2228ec..5a39d3d5f 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -1110,13 +1110,8 @@ FrameExchangeManager::UpdateNav(Ptr psdu, const WifiTxVector& tx { NS_LOG_FUNCTION(this << psdu << txVector); - if (psdu->GetHeader(0).GetRawDuration() > 32767) + if (!psdu->HasNav()) { - // When the contents of a received Duration/ID field, treated as an unsigned - // integer, are greater than 32 768, the contents are interpreted as appropriate - // for the frame type and subtype or ignored if the receiving MAC entity does - // not have a defined interpretation for that type and subtype (IEEE 802.11-2016 - // sec. 10.27.3) return; } diff --git a/src/wifi/model/wifi-psdu.cc b/src/wifi/model/wifi-psdu.cc index 5e4c2d9b3..473034d44 100644 --- a/src/wifi/model/wifi-psdu.cc +++ b/src/wifi/model/wifi-psdu.cc @@ -139,6 +139,16 @@ WifiPsdu::GetAddr2() const return ta; } +bool +WifiPsdu::HasNav() const +{ + // When the contents of a received Duration/ID field, treated as an unsigned integer, + // are greater than 32 768, the contents are interpreted as appropriate for the frame + // type and subtype or ignored if the receiving MAC entity does not have a defined + // interpretation for that type and subtype (IEEE 802.11-2016 sec. 10.27.3) + return (m_mpduList.at(0)->GetHeader().GetRawDuration() & 0x8000) == 0; +} + Time WifiPsdu::GetDuration() const { diff --git a/src/wifi/model/wifi-psdu.h b/src/wifi/model/wifi-psdu.h index da169919e..1f7328c90 100644 --- a/src/wifi/model/wifi-psdu.h +++ b/src/wifi/model/wifi-psdu.h @@ -144,6 +144,11 @@ class WifiPsdu : public SimpleRefCount */ Mac48Address GetAddr2() const; + /** + * \return true if the Duration/ID field contains a value for setting the NAV + */ + bool HasNav() const; + /** * Get the duration from the Duration/ID field, which is common to all the MPDUs * \return the duration from the Duration/ID field.