25 #include "ns3/simulator.h"
26 #include "ns3/string.h"
27 #include "ns3/pointer.h"
42 .SetGroupName (
"Wifi")
44 .AddAttribute (
"BeaconInterval",
45 "Delay between two beacons",
50 .AddAttribute (
"BeaconJitter",
51 "A uniform random variable to cause the initial beacon starting time (after simulation time 0) "
52 "to be distributed between 0 and the BeaconInterval.",
55 MakePointerChecker<UniformRandomVariable> ())
56 .AddAttribute (
"EnableBeaconJitter",
57 "If beacons are enabled, whether to jitter the initial send event.",
61 .AddAttribute (
"BeaconGeneration",
62 "Whether or not beacons are generated.",
67 .AddAttribute (
"EnableNonErpProtection",
"Whether or not protection mechanism should be used when non-ERP STAs are present within the BSS."
68 "This parameter is only used when ERP is supported by the AP.",
72 .AddAttribute (
"RifsMode",
"If non-HT STAs are detected, whether to force RIFS to be disabled within the BSS."
73 "This parameter is only used when HT is supported by the AP.",
82 : m_enableBeaconGeneration (false)
159 m_beaconDca->SetWifiRemoteStationManager (stationManager);
181 NS_LOG_WARN (
"beacon interval should be multiple of 1024us (802.11 time unit), see IEEE Std. 802.11-2012");
210 for (std::list<Mac48Address>::const_iterator i =
m_staList.begin (); i !=
m_staList.end (); i++)
242 bool isNonGfHtStasPresent =
false;
243 for (std::list<Mac48Address>::const_iterator i =
m_staList.begin (); i !=
m_staList.end (); i++)
247 isNonGfHtStasPresent =
true;
252 return isNonGfHtStasPresent;
259 for (std::list<Mac48Address>::const_iterator i =
m_staList.begin (); i !=
m_staList.end (); i++)
302 NS_LOG_FUNCTION (
this << packet << from << to << static_cast<uint32_t> (tid));
344 m_dca->Queue (packet, hdr);
402 NS_LOG_DEBUG (
"Adding supported rate of " << modeDataRate);
435 return dsssParameters;
513 return edcaParameters;
547 if (channelWidth == 160)
551 else if (channelWidth == 80)
559 for (uint8_t nss = 1; nss <= 8; nss++)
562 if (nss <= m_phy->GetMaxSupportedRxSpatialStreams ())
629 m_dca->Queue (packet, hdr);
657 assoc.SetStatusCode (code);
687 m_dca->Queue (packet, hdr);
828 NS_LOG_DEBUG (
"forwarding frame from=" << from <<
", to=" << to);
864 else if (hdr->
IsMgt ())
883 bool problem =
false;
884 bool isHtStation =
false;
885 bool isOfdmStation =
false;
886 bool isErpStation =
false;
887 bool isDsssStation =
false;
895 isDsssStation =
false;
899 isErpStation =
false;
903 isOfdmStation =
false;
905 if (isDsssStation ==
false && isErpStation ==
false && isOfdmStation ==
false)
915 isDsssStation =
true;
923 isOfdmStation =
true;
1053 if (!isErpStation && isDsssStation)
1065 for (std::list<Mac48Address>::const_iterator i =
m_staList.begin (); i !=
m_staList.end (); i++)
1109 i != packets.end (); ++i)
1111 if ((*i).second.GetDestinationAddr () ==
GetAddress ())
1113 ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
1114 (*i).second.GetDestinationAddr ());
1120 NS_LOG_DEBUG (
"forwarding QoS frame from=" << from <<
", to=" << to);
1137 NS_LOG_DEBUG (
"Scheduling initial beacon for access point " <<
GetAddress () <<
" at time " << jitter <<
" microseconds");
1154 return useProtection;
1160 bool rifsMode =
false;
void DoInitialize(void)
Initialize() implementation.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Ptr< DcfManager > m_dcfManager
DCF manager (access to channel)
EdcaParameterSet GetEdcaParameterSet(void) const
Return the EDCA Parameter Set of the current AP.
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilties Info field in the VHT Capabilities information element.
bool GetVhtSupported(Mac48Address address) const
Return whether the station supports VHT or not.
uint8_t GetChannelNumber(void) const
Return current channel number.
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
void SetBeaconInterval(Time interval)
void AddSupportedRate(uint32_t bs)
Add the given rate to the supported rates.
uint32_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Simulation virtual time values and global simulation resolution.
bool IsSupportedTxMcs(uint8_t mcs) const
Get the is transmit MCS supported.
void AddSupportedMcs(Mac48Address address, WifiMode mcs)
Record the MCS index supported by the station.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetQosSupported(uint8_t qosSupported)
Set QOS supported function.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
bool GetGreenfieldSupported(Mac48Address address) const
Return whether the station supports Greenfield or not.
AttributeValue implementation for Boolean.
void SetMaxVhtMcsPerNss(uint8_t nss, uint8_t maxVhtMcs)
Set the Basic VHT-MCS and NSS field in the VHT Operation information element by specifying the tuple ...
void SetBkCWmin(uint8_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
bool m_disableRifs
Flag whether to force RIFS to be disabled within the BSS If non-HT STAs are detected.
Hold variables of type string.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void RecordWaitAssocTxOk(Mac48Address address)
Records that we are waiting for an ACK for the association response we sent.
DsssParameterSet GetDsssParameterSet(void) const
Return the DSSS Parameter Set that we support.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
EdcaQueues m_edca
This is a map from Access Category index to the corresponding channel access function.
The VHT Operation Information ElementThis class knows how to serialise and deserialise the VHT Operat...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
void SetVoAifsn(uint8_t aifsn)
Set the AC_VO AIFSN field in the EdcaParameterSet information element.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > >::const_iterator DeaggregatedMsdusCI
DeaggregatedMsdusCI typedef.
bool IsBroadcast(void) const
void SetSlot(Time slotTime)
static DeaggregatedMsdus Deaggregate(Ptr< Packet > aggregatedPacket)
void NotifyRxDrop(Ptr< const Packet > packet)
void SetVoTXOPLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
The HT Operation Information ElementThis class knows how to serialise and deserialise the HT Operatio...
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
uint8_t GetNMcs(void) const
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
void SendAssocResp(Mac48Address to, bool success)
Forward an association response packet to the DCF.
uint8_t GetVhtOperationalChannelWidth(void) const
Determine the VHT operational channel width (in MHz).
bool SupportsSendFrom(void) const
Ptr< WifiPhy > m_phy
Wifi PHY.
Ptr< DcaTxop > m_beaconDca
Dedicated DcaTxop for beacons.
void SetHtProtection(uint8_t htprotection)
Set the HT protection.
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
bool IsMandatory(void) const
VhtCapabilities GetVhtCapabilities(void) const
Return the VHT capability of the device.
uint32_t GetBssMembershipSelector(uint32_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
virtual void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
HeCapabilities GetHeCapabilities(void) const
Return the HE capability of the device.
uint8_t QosUtilsGetTidForPacket(Ptr< const Packet > packet)
If a qos tag is attached to the packet, returns a value < 8.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
bool GetUseNonErpProtection(void) const
Return whether protection for non-ERP stations is used in the BSS.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
bool m_enableBeaconGeneration
Flag whether beacons are being generated.
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void Enqueue(Ptr< const Packet > packet, Mac48Address to)
void SetShortSlotTimeEnabled(bool enable)
Enable or disable short slot time.
void SetVhtSupported(uint8_t vhtsupported)
Set the VHT supported information element.
void SetBssid(Mac48Address bssid)
void SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
Time GetTxopLimit(void) const
Return the TXOP limit.
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
base class for all MAC-level wifi objects.
void SetSuccess(void)
Set success bit to 0 (success).
bool m_qosSupported
This Boolean is set true iff this WifiMac is to model 802.11e/WMM style Quality of Service...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
void SetBeTXOPLimit(uint16_t txop)
Set the AC_BE TXOP Limit field in the EdcaParameterSet information element.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
Ptr< DcaTxop > m_dca
This holds a pointer to the DCF instance for this WifiMac - used for transmission of frames to non-Qo...
The IEEE 802.11ac VHT Capabilities.
static TypeId GetTypeId(void)
Get the type ID.
void NotifyTxDrop(Ptr< const Packet > packet)
void ForwardDown(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet down to DCF/EDCAF (enqueue the packet).
void SetViAci(uint8_t aci)
Set the AC_VI ACI field in the EdcaParameterSet information element.
void RecordGotAssocTxFailed(Mac48Address address)
Records that we missed an ACK for the association response we sent.
bool GetRifsMode(void) const
Return whether RIFS is allowed in the BSS.
uint64_t GetDataRate(uint8_t channelWidth, uint16_t guardInterval, uint8_t nss) const
WifiMode GetBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes.
bool GetShortPreambleEnabled(void) const
Determine whether short preamble should be enabled or not in the BSS.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
bool m_vhtSupported
This Boolean is set true iff this WifiMac is to model 802.11ac.
bool m_enableNonErpProtection
Flag whether protection mechanism is used or not when non-ERP STAs are present within the BSS...
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
void SetAddress(Mac48Address address)
void SetBeCWmax(uint8_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
uint8_t GetMcsValue(void) const
std::string GetUniqueName(void) const
static Mac48Address GetBroadcast(void)
void SetBeCWmin(uint8_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
EventId m_beaconEvent
Event to generate one beacon.
uint8_t GetChannelWidthSupported(Mac48Address address) const
Return the channel width supported by the station.
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
void SetViCWmin(uint8_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
bool m_heSupported
This Boolean is set true iff this WifiMac is to model 802.11ax.
uint16_t GetSupportedMcsAndNss() const
Return the MCS and NSS field in the HE Capabilities information element.
void SetCurrentChannel(uint8_t currentChannel)
Set the Current Channel field in the DsssParameterSet information element.
HtOperation GetHtOperation(void) const
Return the HT operation of the current AP.
Ptr< MacLow > m_low
MacLow (RTS, CTS, DATA, ACK etc.)
uint32_t GetNBasicMcs(void) const
Return the number of basic MCS index.
HtCapabilities GetHtCapabilities(void) const
Return the HT capability of the device.
void SetBasicRate(uint32_t bs)
Set the given rate to basic rates.
void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
This method acts as the MacRxMiddle receive callback and is invoked to notify us that a frame has bee...
void DeaggregateAmsduAndForward(Ptr< Packet > aggregatedPacket, const WifiMacHeader *hdr)
This method is called to de-aggregate an A-MSDU and forward the constituent packets up the stack...
std::list< Mac48Address > m_staList
List of all stations currently associated to the AP.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Status code for association response.
WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
bool IsWaitAssocTxOk(Mac48Address address) const
Return whether we are waiting for an ACK for the association response we sent.
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
void SetLinkUpCallback(Callback< void > linkUp)
void AddBssMembershipSelectorRate(uint32_t bs)
Add a special value to the supported rate set, corresponding to a BSS membership selector.
void SetLinkUpCallback(Callback< void > linkUp)
virtual void DoDispose()
Destructor implementation.
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
DeaggregatedMsdus typedef.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
The EDCA Parameter SetThis class knows how to serialise and deserialise the EDCA Parameter Set...
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
bool IsSupportedMcs(uint8_t mcs) const
Return the is MCS supported flag.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
void SetUseNonErpProtection(bool enable)
Enable or disable protection for non-ERP stations.
WifiMode GetBasicMcs(uint32_t i) const
Return the MCS at the given list index.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
bool IsAssociated(Mac48Address address) const
Return whether the station associated.
void SetDsssSupported(uint8_t DsssSupported)
Set DSSS supported.
static EventId ScheduleNow(MEM mem_ptr, OBJ obj)
Schedule an event to expire Now.
void SetBkTXOPLimit(uint16_t txop)
Set the AC_BK TXOP Limit field in the EdcaParameterSet information element.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
bool IsNonGfHtStasPresent(void) const
Determine whether non-Greenfield HT stations are present or not.
bool GetBeaconGeneration(void) const
Return whether the AP is generating beacons.
Wi-Fi AP state machineHandle association, dis-association and authentication, of STAs within an infra...
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
void AddSupportedPlcpPreamble(Mac48Address address, bool isShortPreambleSupported)
Record whether the short PLCP preamble is supported by the station.
bool m_htSupported
This Boolean is set true iff this WifiMac is to model 802.11n.
void SendProbeResp(Mac48Address to)
Forward a probe response packet to the DCF.
uint8_t GetChannelWidth(void) const
The DSSS Parameter SetThis class knows how to serialise and deserialise the DSSS Parameter Set...
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
uint32_t GetNBasicModes(void) const
Return the number of basic modes we support.
bool GetShortSlotTimeSupported(Mac48Address address) const
Return whether the station supports short ERP slot time or not.
void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
void SetNonGfHtStasPresent(uint8_t nongfhtstaspresent)
Set the non GF HT STAs present.
void SendOneBeacon(void)
Forward a beacon packet to the beacon special DCF.
void AddSupportedErpSlotTime(Mac48Address address, bool isShortSlotTimeSupported)
Record whether the short ERP slot time is supported by the station.
void SetViTXOPLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
void DoDispose(void)
Destructor implementation.
void SetAddress(Mac48Address address)
ErpInformation GetErpInformation(void) const
Return the ERP information of the current AP.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Mac48Address GetAddress(void) const
Ptr< UniformRandomVariable > m_beaconJitter
UniformRandomVariable used to randomize the time of the first beacon.
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current AP.
Time m_beaconInterval
Interval between beacons.
bool IsSupportedTxMcs(uint8_t mcs) const
Is transmit MCS supported.
void SetVoCWmin(uint8_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
void SetUseGreenfieldProtection(bool enable)
Enable or disable protection for stations that do not support HT greenfield format.
std::list< Mac48Address > m_nonErpStations
List of all non-ERP stations currently associated to the AP.
virtual void DoInitialize()
Initialize() implementation.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsSupportedRate(uint32_t bs) const
Check if the given rate is supported.
void SetRifsMode(uint8_t rifsmode)
Set the RIFS mode.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
bool m_enableBeaconJitter
Flag whether the first beacon should be generated at random time.
Time GetBeaconInterval(void) const
void SetVoCWmax(uint8_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
bool GetShortSlotTimeSupported(void) const
virtual void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
bool m_erpSupported
This Boolean is set true iff this WifiMac is to model 802.11g.
void TxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
bool GetRifsSupported(void) const
WifiModulationClass GetModulationClass() const
void SetShortPreambleEnabled(bool enable)
Enable or disable short PLCP preambles.
void SetHtSupported(uint8_t htsupported)
Set the HT Supported.
void SetBkCWmax(uint8_t cwMax)
Set the AC_BK CWmax field in the EdcaParameterSet information element.
Ptr< WifiRemoteStationManager > m_stationManager
Remote station manager (rate control, RTS/CTS/fragmentation thresholds etc.)
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
void SetFailure(void)
Set success bit to 1 (failure).
std::list< Mac48Address > m_nonHtStations
List of all non-HT stations currently associated to the AP.
bool GetShortSlotTimeEnabled(void) const
Determine whether short slot time should be enabled or not in the BSS.
The IEEE 802.11ax HE Capabilities.
VhtOperation GetVhtOperation(void) const
Return the VHT operation of the current AP.
uint32_t GetMinCw(void) const
Return the minimum contention window size.
a unique identifier for an interface.
bool m_dsssSupported
This Boolean is set true iff this WifiMac is to model 802.11b.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void StartBeaconing(void)
Start beacon transmission immediately.
void SetViCWmax(uint8_t cwMax)
Set the AC_VI CWmax field in the EdcaParameterSet information element.
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
void SetRifsPermitted(bool allow)
Permit or prohibit RIFS.
void RecordGotAssocTxOk(Mac48Address address)
Records that we got an ACK for the association response we sent.
void AddHeader(const Header &header)
Add header to this packet.
void AddStationVhtCapabilities(Mac48Address from, VhtCapabilities vhtcapabilities)
Records VHT capabilities of the remote station.
void SetBeaconGeneration(bool enable)
Enable or disable beacon generation of the AP.
void SetChannelWidth(uint8_t channelWidth)
Set the Channel Width field in the VHT Operation information element.
WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
virtual void TxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver (i.e.
bool GetShortPreambleSupported(Mac48Address address) const
Return whether the station supports short PLCP preamble or not.