27 #include "ns3/wifi-phy.h"
28 #include "ns3/wifi-psdu.h"
29 #include "ns3/wifi-utils.h"
42 return (os <<
"PSD_NON_HE_PORTION");
44 return (os <<
"PSD_HE_PORTION");
47 return (os <<
"INVALID");
53 uint16_t txCenterFreq,
65 NS_LOG_FUNCTION(
this << psdus << txVector << txCenterFreq << ppduDuration << band << uid
69 m_psdus.begin()->second =
nullptr;
77 NS_ABORT_MSG_IF(!ret,
"STA-ID " << heMuUserInfo.first <<
" already present");
88 uint16_t txCenterFreq,
99 NS_LOG_FUNCTION(
this << psdu << txVector << txCenterFreq << ppduDuration << band << uid);
110 #ifdef NS3_BUILD_PROFILE_DEBUG
128 uint8_t sigExtension = 0;
134 uint16_t length = ((ceil((
static_cast<double>(ppduDuration.
GetNanoSeconds() - (20 * 1000) -
135 (sigExtension * 1000)) /
170 #ifdef NS3_BUILD_PROFILE_DEBUG
174 if (phyHeaders->RemoveHeader(lSig) == 0)
180 if (phyHeaders->PeekHeader(heSig) == 0)
232 #ifdef NS3_BUILD_PROFILE_DEBUG
237 length = m_lSig.GetLength();
242 uint8_t sigExtension = 0;
249 Time calculatedDuration =
250 MicroSeconds(((ceil(
static_cast<double>(length + 3 +
m) / 3)) * 4) + 20 + sigExtension);
251 NS_ASSERT(calculatedDuration > preambleDuration);
253 floor(
static_cast<double>((calculatedDuration - preambleDuration).GetNanoSeconds() -
254 (sigExtension * 1000)) /
256 ppduDuration = preambleDuration + (nSymbols * tSymbol) +
MicroSeconds(sigExtension);
307 uint8_t ppduBssColor = 0;
308 #ifdef NS3_BUILD_PROFILE_DEBUG
311 phyHeaders->RemoveHeader(lSig);
313 phyHeaders->RemoveHeader(heSig);
316 ppduBssColor = m_heSig.GetBssColor();
322 if (bssColor == 0 || ppduBssColor == 0 || (bssColor == ppduBssColor))
324 return m_psdus.cbegin()->second;
329 if (bssColor == 0 || ppduBssColor == 0 || (bssColor == ppduBssColor))
331 const auto it =
m_psdus.find(staId);
383 if (trigVector.has_value())
399 if (trigVector.has_value() && trigVector->IsUlMu() &&
400 (trigVector->GetHeMuUserInfoMap().count(staId) > 0))
404 m_txVector->SetGuardInterval(trigVector->GetGuardInterval());
405 m_txVector->SetHeMuUserInfo(staId, trigVector->GetHeMuUserInfo(staId));
426 "Invalid content channel ID " << channelId);
428 return (std::find(channelAlloc.cbegin(), channelAlloc.cend(), staId) != channelAlloc.cend());
434 std::ostringstream ss;
465 .SetGroupName(
"Wifi")
479 os <<
"MCS=" << +m_mcs <<
" CHANNEL_WIDTH=" << GetChannelWidth() <<
" GI=" << GetGuardInterval()
480 <<
" NSTS=" << +m_nsts <<
" BSSColor=" << +m_bssColor <<
" MU=" << +m_mu;
519 m_bssColor = bssColor;
531 if (channelWidth == 160)
535 else if (channelWidth == 80)
539 else if (channelWidth == 40)
552 if (m_bandwidth == 3)
556 else if (m_bandwidth == 2)
560 else if (m_bandwidth == 1)
573 if (gi == 800 && ltf == 1)
577 else if (gi == 800 && ltf == 2)
581 else if (gi == 1600 && ltf == 2)
594 if (m_gi_ltf_size == 3)
599 else if (m_gi_ltf_size == 2)
613 m_nsts = (nStreams - 1);
626 uint8_t
byte = m_format & 0x01;
627 byte |= ((m_ul_dl & 0x01) << 2);
628 byte |= ((m_mcs & 0x0f) << 3);
630 uint16_t bytes = (m_bssColor & 0x3f);
631 bytes |= (0x01 << 6);
632 bytes |= ((m_spatialReuse & 0x0f) << 7);
633 bytes |= ((m_bandwidth & 0x03) << 11);
634 bytes |= ((m_gi_ltf_size & 0x03) << 13);
635 bytes |= ((m_nsts & 0x01) << 15);
636 start.WriteU16(bytes);
637 start.WriteU8((m_nsts >> 1) & 0x03);
641 sigA2 |= (0x01 << 14);
642 start.WriteU32(sigA2);
657 uint8_t
byte = i.
ReadU8();
658 m_format = (
byte & 0x01);
659 m_ul_dl = ((
byte >> 2) & 0x01);
660 m_mcs = ((
byte >> 3) & 0x0f);
662 m_bssColor = (bytes & 0x3f);
663 m_spatialReuse = ((bytes >> 7) & 0x0f);
664 m_bandwidth = ((bytes >> 11) & 0x03);
665 m_gi_ltf_size = ((bytes >> 13) & 0x03);
666 m_nsts = ((bytes >> 15) & 0x01);
668 m_nsts |= (
byte & 0x03) << 1;
iterator in a Buffer instance
uint32_t GetDistanceFrom(const Iterator &o) const
static WifiMode GetHeMcs(uint8_t index)
Return the HE MCS corresponding to the provided index.
void SetTxPsdFlag(TxPsdFlag flag) const
WifiTxVector DoGetTxVector() const override
Get the TXVECTOR used to send the PPDU.
void UpdateTxVectorForUlMu(const std::optional< WifiTxVector > &trigVector) const
Update the TXVECTOR for HE TB PPDUs, since the information to decode HE TB PPDUs is not available fro...
Ptr< WifiPpdu > Copy() const override
Copy this instance.
virtual void SetTxVectorFromPhyHeaders(WifiTxVector &txVector, const LSigHeader &lSig, const HeSigHeader &heSig) const
Fill in the TXVECTOR from PHY headers.
TxPsdFlag
The transmit power spectral density flag, namely used to correctly build PSDs for pre-HE and HE porti...
@ PSD_HE_PORTION
HE portion of an HE PPDU.
@ PSD_NON_HE_PORTION
Non-HE portion of an HE PPDU.
virtual bool IsDlMu() const
Return true if the PPDU is a DL MU PPDU.
Time GetTxDuration() const override
Get the total transmission duration of the PPDU.
virtual bool IsUlMu() const
Return true if the PPDU is an UL MU PPDU.
ContentChannelAllocation m_contentChannelAlloc
HE SIG-B Content Channel allocation (to be removed once HE-SIG-B headers are implemented)
WifiTxVector::HeMuUserInfoMap m_muUserInfos
HE MU specific per-user information (to be removed once HE-SIG-B headers are implemented)
virtual void SetPhyHeaders(const WifiTxVector &txVector, Time ppduDuration)
Fill in the PHY headers.
bool IsAllocated(uint16_t staId) const
Check if STA ID is allocated.
std::string PrintPayload() const override
Print the payload of the PPDU.
uint16_t GetStaId() const override
Get the ID of the STA that transmitted the PPDU for UL MU, SU_STA_ID otherwise.
WifiPpduType GetType() const override
Return the PPDU type (.
TxPsdFlag GetTxPsdFlag() const
HePpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, uint16_t txCenterFreq, Time ppduDuration, WifiPhyBand band, uint64_t uid)
Create an SU HE PPDU, storing a PSDU.
virtual bool IsMu() const
Return true if the PPDU is a MU PPDU.
RuAllocation m_ruAllocation
RU_ALLOCATION in SIG-B common field (to be removed once HE-SIG-B headers are implemented)
virtual void SetLSigHeader(LSigHeader &lSig, Time ppduDuration) const
Fill in the L-SIG header.
bool IsStaInContentChannel(uint16_t staId, size_t channelId) const
Check if STA ID is in HE SIG-B Content Channel ID.
TxPsdFlag m_txPsdFlag
the transmit power spectral density flag
void SetHeSigHeader(HeSigHeader &heSig, const WifiTxVector &txVector) const
Fill in the HE-SIG header.
uint16_t GetTransmissionChannelWidth() const override
Get the channel width over which the PPDU will effectively be transmitted.
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
static RuType GetRuType(uint16_t bandwidth)
Get the RU corresponding to the approximate bandwidth.
WifiPhyBand m_band
the WifiPhyBand used to transmit that PPDU
void AddHeader(const Header &header)
Add header to this packet.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static WifiMode GetVhtMcs(uint8_t index)
Return the VHT MCS corresponding to the provided index.
uint8_t GetMcsValue() const
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
std::optional< WifiTxVector > m_txVector
the TXVECTOR at TX PHY or the reconstructed TXVECTOR at RX PHY (or std::nullopt if TXVECTOR has not b...
WifiPreamble m_preamble
the PHY preamble
Ptr< const WifiPsdu > GetPsdu() const
Get the payload of the PPDU.
const WifiTxVector & GetTxVector() const
Get the TXVECTOR used to send the PPDU.
WifiModulationClass GetModulation() const
Get the modulation used for the PPDU.
virtual uint16_t GetTransmissionChannelWidth() const
Get the channel width over which the PPDU will effectively be transmitted.
WifiConstPsduMap m_psdus
the PSDUs contained in this PPDU
Ptr< Packet > m_phyHeaders
the PHY headers contained in this PPDU
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
const RuAllocation & GetRuAllocation() const
Get RU Allocation of SIG-B.
uint16_t GetGuardInterval() const
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
uint8_t GetBssColor() const
Get the BSS color.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
void SetHeMuUserInfo(uint16_t staId, HeMuUserInfo userInfo)
Set the HE MU user-specific transmission information for the given STA-ID.
void SetAggregation(bool aggregation)
Sets if PSDU contains A-MPDU.
HeRu::RuSpec GetRu(uint16_t staId) const
Get the RU specification for the STA-ID.
void SetRuAllocation(const RuAllocation &ruAlloc)
Set RU Allocation of SIG-B common field.
const HeMuUserInfoMap & GetHeMuUserInfoMap() const
Get a const reference to the map HE MU user-specific transmission information indexed by STA-ID.
ContentChannelAllocation GetContentChannelAllocation() const
Get the HE SIG-B content channel STA ID allocation IEEE 802.11ax-2021 27.3.11.8.2 HE-SIG-B content ch...
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
void SetLength(uint16_t length)
Set the LENGTH field of the L-SIG.
void SetSigBMode(const WifiMode &mode)
Set the MCS used for SIG-B.
void SetBssColor(uint8_t color)
Set the BSS color.
uint16_t GetChannelWidth() const
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
WifiMode GetSigBMode() const
Get MCS used for SIG-B.
void SetNss(uint8_t nss)
Sets the number of Nss.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiPhyBand
Identifies the PHY band.
WifiPpduType
The type of PPDU (SU, DL MU, or UL MU)
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
Declaration of ns3::HePhy class and ns3::HeSigAParameters struct.
Declaration of ns3::HePpdu class.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
bool IsDlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a downlink multi-user transmission.
std::ostream & operator<<(std::ostream &os, const Angles &a)
bool IsUlMu(WifiPreamble preamble)
Return true if a preamble corresponds to a uplink multi-user transmission.