A Discrete-Event Network Simulator
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
24 #include "ns3/traced-callback.h"
25 #include "ns3/object.h"
26 #include "ns3/nstime.h"
27 #include "ns3/data-rate.h"
28 #include "ns3/mac48-address.h"
29 #include "wifi-mode.h"
30 #include "wifi-preamble.h"
32 namespace ns3 {
34 struct WifiRemoteStation;
35 struct WifiRemoteStationState;
37 class WifiPhy;
38 class WifiMac;
39 class WifiMacHeader;
40 class Packet;
41 class HtCapabilities;
42 class VhtCapabilities;
43 class HeCapabilities;
44 class WifiTxVector;
53 {
54 public:
61  void NotifyTxSuccess (uint32_t retryCounter);
63  void NotifyTxFailed ();
68  double GetFrameErrorRate () const;
69 private:
84  double m_failAvg;
85 };
94 {
95 public:
100  static TypeId GetTypeId (void);
103  virtual ~WifiRemoteStationManager ();
107  {
110  };
118  virtual void SetupPhy (const Ptr<WifiPhy> phy);
125  virtual void SetupMac (const Ptr<WifiMac> mac);
132  void SetMaxSsrc (uint32_t maxSsrc);
138  void SetMaxSlrc (uint32_t maxSlrc);
144  void SetRtsCtsThreshold (uint32_t threshold);
151  uint32_t GetFragmentationThreshold (void) const;
158  void SetFragmentationThreshold (uint32_t threshold);
163  void UpdateFragmentationThreshold (void);
171  void SetQosSupport (Mac48Address from, bool qosSupported);
178  void AddStationHtCapabilities (Mac48Address from, HtCapabilities htcapabilities);
185  void AddStationVhtCapabilities (Mac48Address from, VhtCapabilities vhtcapabilities);
192  void AddStationHeCapabilities (Mac48Address from, HeCapabilities hecapabilities);
198  virtual void SetHtSupported (bool enable);
204  bool HasHtSupported (void) const;
210  virtual void SetVhtSupported (bool enable);
216  bool HasVhtSupported (void) const;
222  virtual void SetHeSupported (bool enable);
228  bool HasHeSupported (void) const;
234  virtual void SetPcfSupported (bool enable);
240  bool HasPcfSupported (void) const;
246  void SetUseNonErpProtection (bool enable);
253  bool GetUseNonErpProtection (void) const;
259  void SetUseNonHtProtection (bool enable);
266  bool GetUseNonHtProtection (void) const;
272  void SetUseGreenfieldProtection (bool enable);
279  bool GetUseGreenfieldProtection (void) const;
285  void SetShortPreambleEnabled (bool enable);
292  bool GetShortPreambleEnabled (void) const;
298  void SetShortSlotTimeEnabled (bool enable);
305  bool GetShortSlotTimeEnabled (void) const;
311  void SetRifsPermitted (bool allow);
318  bool GetRifsPermitted (void) const;
323  void Reset (void);
332  void AddBasicMode (WifiMode mode);
338  WifiMode GetDefaultMode (void) const;
344  uint8_t GetNBasicModes (void) const;
352  WifiMode GetBasicMode (uint8_t i) const;
358  uint32_t GetNNonErpBasicModes (void) const;
366  WifiMode GetNonErpBasicMode (uint8_t i) const;
375  bool GetGreenfieldSupported (Mac48Address address) const;
384  bool GetShortPreambleSupported (Mac48Address address) const;
393  bool GetShortSlotTimeSupported (Mac48Address address) const;
402  bool GetQosSupported (Mac48Address address) const;
409  void AddBasicMcs (WifiMode mcs);
415  WifiMode GetDefaultMcs (void) const;
421  uint8_t GetNBasicMcs (void) const;
429  WifiMode GetBasicMcs (uint8_t i) const;
436  void AddSupportedMcs (Mac48Address address, WifiMode mcs);
444  uint16_t GetChannelWidthSupported (Mac48Address address) const;
453  bool GetShortGuardInterval (Mac48Address address) const;
461  uint8_t GetNumberOfSupportedStreams (Mac48Address address) const;
469  uint8_t GetNMcsSupported (Mac48Address address) const;
478  bool GetHtSupported (Mac48Address address) const;
487  bool GetVhtSupported (Mac48Address address) const;
494  WifiMode GetNonUnicastMode (void) const;
506  void AddSupportedMode (Mac48Address address, WifiMode mode);
514  void AddAllSupportedModes (Mac48Address address);
521  void AddAllSupportedMcs (Mac48Address address);
527  void RemoveAllSupportedMcs (Mac48Address address);
534  void AddSupportedPlcpPreamble (Mac48Address address, bool isShortPreambleSupported);
541  void AddSupportedErpSlotTime (Mac48Address address, bool isShortSlotTimeSupported);
550  bool IsBrandNew (Mac48Address address) const;
559  bool IsAssociated (Mac48Address address) const;
569  bool IsWaitAssocTxOk (Mac48Address address) const;
576  void RecordWaitAssocTxOk (Mac48Address address);
583  void RecordGotAssocTxOk (Mac48Address address);
590  void RecordGotAssocTxFailed (Mac48Address address);
596  void RecordDisassociated (Mac48Address address);
608  void PrepareForQueue (Mac48Address address, const WifiMacHeader *header,
609  Ptr<const Packet> packet);
618  WifiTxVector GetDataTxVector (Mac48Address address, const WifiMacHeader *header,
619  Ptr<const Packet> packet);
628  WifiTxVector GetRtsTxVector (Mac48Address address, const WifiMacHeader *header,
629  Ptr<const Packet> packet);
637  WifiTxVector GetCtsToSelfTxVector (const WifiMacHeader *header,
638  Ptr<const Packet> packet);
646  WifiTxVector DoGetCtsToSelfTxVector (void);
655  void ReportRtsFailed (Mac48Address address, const WifiMacHeader *header);
663  void ReportDataFailed (Mac48Address address, const WifiMacHeader *header);
675  void ReportRtsOk (Mac48Address address, const WifiMacHeader *header,
676  double ctsSnr, WifiMode ctsMode, double rtsSnr);
687  void ReportDataOk (Mac48Address address, const WifiMacHeader *header,
688  double ackSnr, WifiMode ackMode, double dataSnr);
696  void ReportFinalRtsFailed (Mac48Address address, const WifiMacHeader *header);
704  void ReportFinalDataFailed (Mac48Address address, const WifiMacHeader *header);
717  void ReportAmpduTxStatus (Mac48Address address, uint8_t tid, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr);
727  void ReportRxOk (Mac48Address address, const WifiMacHeader *header,
728  double rxSnr, WifiMode txMode);
739  bool NeedRts (Mac48Address address, const WifiMacHeader *header,
740  Ptr<const Packet> packet, WifiTxVector txVector);
749  bool NeedCtsToSelf (WifiTxVector txVector);
759  bool NeedRetransmission (Mac48Address address, const WifiMacHeader *header,
760  Ptr<const Packet> packet);
769  bool NeedFragmentation (Mac48Address address, const WifiMacHeader *header,
770  Ptr<const Packet> packet);
779  uint32_t GetFragmentSize (Mac48Address address, const WifiMacHeader *header,
780  Ptr<const Packet> packet, uint32_t fragmentNumber);
789  uint32_t GetFragmentOffset (Mac48Address address, const WifiMacHeader *header,
790  Ptr<const Packet> packet, uint32_t fragmentNumber);
799  bool IsLastFragment (Mac48Address address, const WifiMacHeader *header,
800  Ptr<const Packet> packet, uint32_t fragmentNumber);
808  WifiTxVector GetCtsTxVector (Mac48Address address, WifiMode rtsMode);
815  WifiTxVector GetAckTxVector (Mac48Address address, WifiMode dataMode);
822  WifiTxVector GetBlockAckTxVector (Mac48Address address, WifiMode dataMode);
826  uint8_t GetDefaultTxPowerLevel (void) const;
838  void SetDefaultTxPowerLevel (uint8_t txPower);
842  uint8_t GetNumberOfAntennas (void);
846  uint8_t GetMaxNumberOfTransmitStreams (void);
855  typedef void (*PowerChangeTracedCallback)(double oldPower, double newPower, Mac48Address remoteAddress);
864  typedef void (*RateChangeTracedCallback)(DataRate oldRate, DataRate newRate, Mac48Address remoteAddress);
867 protected:
868  virtual void DoDispose (void);
877  WifiMode GetSupported (const WifiRemoteStation *station, uint8_t i) const;
885  uint8_t GetNSupported (const WifiRemoteStation *station) const;
894  bool GetQosSupported (const WifiRemoteStation *station) const;
903  bool GetHtSupported (const WifiRemoteStation *station) const;
912  bool GetVhtSupported (const WifiRemoteStation *station) const;
921  bool GetHeSupported (const WifiRemoteStation *station) const;
931  WifiMode GetMcsSupported (const WifiRemoteStation *station, uint8_t i) const;
939  uint8_t GetNMcsSupported (const WifiRemoteStation *station) const;
948  WifiMode GetNonErpSupported (const WifiRemoteStation *station, uint8_t i) const;
956  uint32_t GetNNonErpSupported (const WifiRemoteStation *station) const;
964  Mac48Address GetAddress (const WifiRemoteStation *station) const;
972  uint16_t GetChannelWidth (const WifiRemoteStation *station) const;
981  bool GetShortGuardInterval (const WifiRemoteStation *station) const;
989  uint16_t GetGuardInterval (const WifiRemoteStation *station) const;
998  bool GetAggregation (const WifiRemoteStation *station) const;
1007  bool GetGreenfield (const WifiRemoteStation *station) const;
1016  uint8_t GetNumberOfSupportedStreams (const WifiRemoteStation *station) const;
1024  uint8_t GetNess (const WifiRemoteStation *station) const;
1033  WifiPreamble GetPreambleForTransmission (WifiMode mode, Mac48Address dest);
1043  static uint16_t GetChannelWidthForTransmission (WifiMode mode, uint16_t maxSupportedChannelWidth);
1050  Ptr<WifiPhy> GetPhy (void) const;
1056  Ptr<WifiMac> GetMac (void) const;
1059 private:
1071  virtual bool DoNeedRts (WifiRemoteStation *station,
1072  Ptr<const Packet> packet, bool normally);
1084  virtual bool DoNeedRetransmission (WifiRemoteStation *station,
1085  Ptr<const Packet> packet, bool normally);
1097  virtual bool DoNeedFragmentation (WifiRemoteStation *station,
1098  Ptr<const Packet> packet, bool normally);
1105  virtual bool IsLowLatency (void) const = 0;
1109  virtual WifiRemoteStation* DoCreateStation (void) const = 0;
1118  virtual WifiTxVector DoGetDataTxVector (WifiRemoteStation *station) = 0;
1127  virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station) = 0;
1134  virtual uint8_t DoGetCtsTxPowerLevel (Mac48Address address, WifiMode ctsMode);
1141  virtual uint8_t DoGetAckTxPowerLevel (Mac48Address address, WifiMode ackMode);
1148  virtual uint8_t DoGetBlockAckTxPowerLevel (Mac48Address address, WifiMode blockAckMode);
1156  virtual uint16_t DoGetCtsTxChannelWidth (Mac48Address address, WifiMode ctsMode);
1163  virtual uint16_t DoGetCtsTxGuardInterval (Mac48Address address, WifiMode ctsMode);
1170  virtual uint8_t DoGetCtsTxNss (Mac48Address address, WifiMode ctsMode);
1177  virtual uint8_t DoGetCtsTxNess (Mac48Address address, WifiMode ctsMode);
1184  virtual uint16_t DoGetAckTxChannelWidth (Mac48Address address, WifiMode ctsMode);
1191  virtual uint16_t DoGetAckTxGuardInterval (Mac48Address address, WifiMode ackMode);
1198  virtual uint8_t DoGetAckTxNss (Mac48Address address, WifiMode ackMode);
1205  virtual uint8_t DoGetAckTxNess (Mac48Address address, WifiMode ackMode);
1212  virtual uint16_t DoGetBlockAckTxChannelWidth (Mac48Address address, WifiMode ctsMode);
1219  virtual uint16_t DoGetBlockAckTxGuardInterval (Mac48Address address, WifiMode blockAckMode);
1226  virtual uint8_t DoGetBlockAckTxNss (Mac48Address address, WifiMode blockAckMode);
1233  virtual uint8_t DoGetBlockAckTxNess (Mac48Address address, WifiMode blockAckMode);
1241  virtual void DoReportRtsFailed (WifiRemoteStation *station) = 0;
1248  virtual void DoReportDataFailed (WifiRemoteStation *station) = 0;
1258  virtual void DoReportRtsOk (WifiRemoteStation *station,
1259  double ctsSnr, WifiMode ctsMode, double rtsSnr) = 0;
1269  virtual void DoReportDataOk (WifiRemoteStation *station,
1270  double ackSnr, WifiMode ackMode, double dataSnr) = 0;
1277  virtual void DoReportFinalRtsFailed (WifiRemoteStation *station) = 0;
1284  virtual void DoReportFinalDataFailed (WifiRemoteStation *station) = 0;
1293  virtual void DoReportRxOk (WifiRemoteStation *station,
1294  double rxSnr, WifiMode txMode) = 0;
1308  virtual void DoReportAmpduTxStatus (WifiRemoteStation *station, uint8_t nSuccessfulMpdus, uint8_t nFailedMpdus, double rxSnr, double dataSnr);
1316  WifiRemoteStationState* LookupState (Mac48Address address) const;
1325  WifiRemoteStation* Lookup (Mac48Address address, uint8_t tid) const;
1336  WifiRemoteStation* Lookup (Mac48Address address, const WifiMacHeader *header) const;
1348  bool IsAllowedControlAnswerModulationClass (WifiModulationClass modClassReq, WifiModulationClass modClassAnswer) const;
1358  WifiMode GetControlAnswerMode (Mac48Address address, WifiMode reqMode);
1366  void DoSetFragmentationThreshold (uint32_t threshold);
1372  uint32_t DoGetFragmentationThreshold (void) const;
1381  uint32_t GetNFragments (const WifiMacHeader *header, Ptr<const Packet> packet);
1386  typedef std::vector <WifiRemoteStation *> Stations;
1390  typedef std::vector <WifiRemoteStationState *> StationStates;
1421  StationStates m_states;
1422  Stations m_stations;
1431  uint32_t m_maxSsrc;
1432  uint32_t m_maxSlrc;
1465 };
1471 {
1475  enum
1476  {
1481  } m_state;
1497  uint16_t m_channelWidth;
1499  uint16_t m_guardInterval;
1500  uint8_t m_streams;
1501  uint8_t m_ness;
1502  bool m_stbc;
1503  bool m_ldpc;
1512 };
1526 {
1527  virtual ~WifiRemoteStation ();
1529  uint32_t m_ssrc;
1530  uint32_t m_slrc;
1531  uint8_t m_tid;
1532 };
1534 } //namespace ns3
bool m_useNonHtProtection
flag if protection for non-HT stations against HT transmissions is enabled
uint32_t m_ssrc
STA short retry count.
bool m_shortPreamble
Flag if short PLCP preamble is supported by the remote station.
bool m_vhtSupported
Flag if VHT capability is supported.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
std::vector< WifiRemoteStationState * > StationStates
A vector of WifiRemoteStationStates.
bool m_shortGuardInterval
Flag if HT/VHT short guard interval is supported by the remote station.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint32_t m_rtsCtsThreshold
Threshold for RTS/CTS.
bool m_shortSlotTimeEnabled
flag if short slot time is enabled
bool m_vhtSupported
Flag if VHT is supported by the station.
WifiMode m_nonUnicastMode
Transmission mode for non-unicast DATA frames.
uint32_t m_nextFragmentationThreshold
Threshold for fragmentation that will be used for the next transmission.
Forward calls to a chain of Callback.
uint8_t m_streams
Number of supported streams by the remote station.
uint32_t m_fragmentationThreshold
Current threshold for fragmentation.
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
uint8_t m_defaultTxPowerLevel
Default tranmission power level.
Mac48Address m_address
Mac48Address of the remote station.
Time m_memoryTime
averaging coefficient depends on the memory time
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
The trace source fired when the transmission of a RTS has exceeded the maximum number of attempts...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
bool m_shortPreambleEnabled
flag if short PLCP preamble is enabled
Tid independent remote station statistics.
WifiRemoteStationState * m_state
Remote station state.
double m_failAvg
moving percentage of failed frames
Definition: third.py:86
TracedCallback< Mac48Address > m_macTxFinalDataFailed
The trace source fired when the transmission of a data packet has exceeded the maximum number of atte...
Class for representing data rates.
Definition: data-rate.h:88
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
ProtectionMode enumeration.
ProtectionMode m_htProtectionMode
Protection mode for HT stations when non-HT stations are detected.
Time m_lastUpdate
when last update has occurred
bool m_qosSupported
Flag if HT is supported by the station.
WifiMode m_defaultTxMcs
The default transmission modulation-coding scheme (MCS)
Ptr< WifiPhy > m_wifiPhy
This is a pointer to the WifiPhy associated with this WifiRemoteStationManager that is set on call to...
double CalculateAveragingCoefficient()
Calculate averaging coefficient for frame error rate.
The IEEE 802.11ac VHT Capabilities.
bool m_useNonErpProtection
flag if protection for non-ERP stations against ERP transmissions is enabled
bool m_stbc
Flag if STBC is supported by the remote station.
Definition: third.py:92
uint32_t m_maxSlrc
Maximum STA long retry count (SLRC)
bool m_pcfSupported
Flag if PCF capability is supported.
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
Ptr< WifiMac > m_wifiMac
This is a pointer to the WifiMac associated with this WifiRemoteStationManager that is set on call to...
hold a list of per-remote-station state.
WifiMode m_defaultTxMode
The default transmission mode.
bool m_ldpc
Flag if LDPC is supported by the remote station.
WifiModeList m_bssBasicRateSet
This member is the list of WifiMode objects that comprise the BSSBasicRateSet parameter.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: first.py:37
WifiModeList m_operationalRateSet
This member is the list of WifiMode objects that comprise the OperationalRateSet parameter for this r...
bool m_htSupported
Flag if HT capability is supported.
bool m_useGreenfieldProtection
flag if protection for stations that do not support HT greenfield format is enabled ...
bool m_aggregation
Flag if MPDU aggregation is used by the remote station.
an EUI-48 address
Definition: mac48-address.h:43
TracedCallback< Mac48Address > m_macTxRtsFailed
The trace source fired when the transmission of a single RTS has failed.
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
Definition: wifi-mode.h:252
Stations m_stations
Information for each known stations.
bool m_heSupported
Flag if HE capability is supported.
TracedCallback< Mac48Address > m_macTxDataFailed
The trace source fired when the transmission of a single data packet has failed.
uint16_t m_channelWidth
Channel width (in MHz) supported by the remote station.
double GetFrameErrorRate() const
Return frame error rate (probability that frame is corrupted due to transmission error).
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
Definition: config.cc:757
void NotifyTxFailed()
Updates average frame error rate when final data or RTS has failed.
bool m_htSupported
Flag if HT is supported by the station.
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
Definition: wifi-mode.h:36
A struct that holds information about each remote station.
WifiModeList m_operationalMcsSet
operational MCS set
uint32_t m_maxSsrc
Maximum STA short retry count (SSRC)
uint8_t m_ness
Number of streams in beamforming of the remote station.
bool m_shortSlotTime
Flag if short ERP slot time is supported by the remote station.
A base class which provides memory management and object aggregation.
Definition: object.h:87
StationStates m_states
States of known stations.
ProtectionMode m_erpProtectionMode
Protection mode for ERP stations when non-ERP stations are detected.
uint32_t m_slrc
STA long retry count.
The IEEE 802.11ax HE Capabilities.
a unique identifier for an interface.
Definition: type-id.h:58
bool m_rifsPermitted
flag if RIFS is enabled
bool m_greenfield
Flag if greenfield is supported by the remote station.
WifiRemoteStationInfo m_info
remote station info
WifiModeList m_bssBasicMcsSet
basic MCS set
bool m_heSupported
Flag if HE is supported by the station.
hold per-remote-station state.
Implements the IEEE 802.11 MAC header.
uint16_t m_guardInterval
HE Guard interval duration (in nanoseconds) supported by the remote station.
std::vector< WifiRemoteStation * > Stations
A vector of WifiRemoteStations.