A Discrete-Event Network Simulator
API
sta-wifi-mac.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #ifndef STA_WIFI_MAC_H
24 #define STA_WIFI_MAC_H
25 
26 #include "regular-wifi-mac.h"
27 #include "mgt-headers.h"
28 
31 class HeAggregationTest;
32 
33 namespace ns3 {
34 
35 class SupportedRates;
36 class CapabilityInformation;
37 
44 struct ApInfo
45 {
48  double m_snr;
52 };
53 
107 {
108 public:
110  friend class ::TwoLevelAggregationTest;
112  friend class ::AmpduAggregationTest;
114  friend class ::HeAggregationTest;
119  static TypeId GetTypeId (void);
120 
121  StaWifiMac ();
122  virtual ~StaWifiMac ();
123 
132  void Enqueue (Ptr<Packet> packet, Mac48Address to) override;
133 
137  void SetWifiPhy (const Ptr<WifiPhy> phy) override;
138 
144  bool IsAssociated (void) const;
145 
151  uint16_t GetAssociationId (void) const;
152 
153 private:
157  enum MacState
158  {
164  REFUSED
165  };
166 
172  void SetActiveProbing (bool enable);
178  bool GetActiveProbing (void) const;
179 
185  void Receive (Ptr<WifiMacQueueItem> mpdu) override;
217  void UpdateCandidateApList (ApInfo newApInfo);
218 
223  void SendProbeRequest (void);
232  void SendAssociationRequest (bool isReassoc);
237  void TryToEnsureAssociated (void);
242  void AssocRequestTimeout (void);
247  void StartScanning (void);
253  void ScanningTimeout (void);
259  bool IsWaitAssocResp (void) const;
263  void MissedBeacons (void);
269  void RestartBeaconWatchdog (Time delay);
276  SupportedRates GetSupportedRates (void) const;
282  void SetState (MacState value);
292  void SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit);
299 
303  void PhyCapabilitiesChanged (void);
304 
305  void DoInitialize (void) override;
306 
308  uint16_t m_aid;
319  std::vector<ApInfo> m_candidateAps;
320  // Note: std::multiset<ApInfo> might be a candidate container to implement
321  // this sorted list, but we are using a std::vector because we want to sort
322  // based on SNR but find duplicates based on BSSID, and in practice this
323  // candidate vector should not be too large.
324 
328 };
329 
330 } //namespace ns3
331 
332 #endif /* STA_WIFI_MAC_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::StaWifiMac::m_waitBeaconTimeout
Time m_waitBeaconTimeout
wait beacon timeout
Definition: sta-wifi-mac.h:309
ns3::StaWifiMac::UNASSOCIATED
@ UNASSOCIATED
Definition: sta-wifi-mac.h:163
ns3::StaWifiMac::m_probeRequestTimeout
Time m_probeRequestTimeout
probe request timeout
Definition: sta-wifi-mac.h:310
ns3::StaWifiMac::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: sta-wifi-mac.cc:41
ns3::StaWifiMac::MissedBeacons
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
Definition: sta-wifi-mac.cc:374
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
regular-wifi-mac.h
ns3::ApInfo::m_snr
double m_snr
SNR in linear scale.
Definition: sta-wifi-mac.h:48
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::StaWifiMac::m_assocRequestTimeout
Time m_assocRequestTimeout
association request timeout
Definition: sta-wifi-mac.h:311
ns3::ApInfo::m_activeProbing
bool m_activeProbing
Flag whether active probing is used or not.
Definition: sta-wifi-mac.h:49
AmpduAggregationTest
Ampdu Aggregation Test.
Definition: wifi-aggregation-test.cc:57
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::StaWifiMac::m_deAssocLogger
TracedCallback< Mac48Address > m_deAssocLogger
disassociation logger
Definition: sta-wifi-mac.h:326
ns3::StaWifiMac::GetSupportedRates
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates.
Definition: sta-wifi-mac.cc:1040
ns3::RegularWifiMac
base class for all MAC-level wifi objects.
Definition: regular-wifi-mac.h:51
ns3::StaWifiMac::ScanningTimeout
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred.
Definition: sta-wifi-mac.cc:333
ns3::StaWifiMac::SendAssociationRequest
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
Definition: sta-wifi-mac.cc:186
ns3::StaWifiMac::m_aid
uint16_t m_aid
Association AID.
Definition: sta-wifi-mac.h:308
ns3::ApInfo::m_apAddr
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:47
ns3::StaWifiMac::m_state
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:307
ns3::StaWifiMac::m_probeRequestEvent
EventId m_probeRequestEvent
probe request event
Definition: sta-wifi-mac.h:313
ns3::StaWifiMac::Enqueue
void Enqueue(Ptr< Packet > packet, Mac48Address to) override
Definition: sta-wifi-mac.cc:426
ns3::StaWifiMac::UpdateApInfoFromBeacon
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP's information from beacon.
Definition: sta-wifi-mac.cc:723
ns3::StaWifiMac::m_candidateAps
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate to
Definition: sta-wifi-mac.h:319
ns3::StaWifiMac::AssocRequestTimeout
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
Definition: sta-wifi-mac.cc:366
ns3::ApInfo::m_bssid
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:46
mgt-headers.h
ns3::StaWifiMac::UpdateCandidateApList
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
Definition: sta-wifi-mac.cc:697
ns3::SupportedRates
The Supported Rates Information Element.
Definition: supported-rates.h:96
ns3::Ptr< Packet >
ns3::StaWifiMac::MacState
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:158
ns3::StaWifiMac::m_maxMissedBeacons
uint32_t m_maxMissedBeacons
maximum missed beacons
Definition: sta-wifi-mac.h:317
ns3::StaWifiMac::WAIT_PROBE_RESP
@ WAIT_PROBE_RESP
Definition: sta-wifi-mac.h:161
ns3::StaWifiMac::m_beaconWatchdog
EventId m_beaconWatchdog
beacon watchdog
Definition: sta-wifi-mac.h:315
ns3::StaWifiMac::m_waitBeaconEvent
EventId m_waitBeaconEvent
wait beacon event
Definition: sta-wifi-mac.h:312
ns3::StaWifiMac::UpdateApInfoFromAssocResp
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP's information from association response.
Definition: sta-wifi-mac.cc:896
ns3::ApInfo::m_beacon
MgtBeaconHeader m_beacon
Beacon header.
Definition: sta-wifi-mac.h:50
ns3::ApInfo
Struct to hold information regarding observed AP through active/passive scanning.
Definition: sta-wifi-mac.h:45
ns3::StaWifiMac::SetWifiPhy
void SetWifiPhy(const Ptr< WifiPhy > phy) override
Definition: sta-wifi-mac.cc:141
HeAggregationTest
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
Definition: wifi-aggregation-test.cc:549
ns3::StaWifiMac::SendProbeRequest
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
Definition: sta-wifi-mac.cc:149
ns3::StaWifiMac::m_activeProbing
bool m_activeProbing
active probing
Definition: sta-wifi-mac.h:318
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::StaWifiMac::m_assocRequestEvent
EventId m_assocRequestEvent
association request event
Definition: sta-wifi-mac.h:314
ns3::StaWifiMac::UpdateApInfoFromProbeResp
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP's information from probe response.
Definition: sta-wifi-mac.cc:830
ns3::StaWifiMac::Receive
void Receive(Ptr< WifiMacQueueItem > mpdu) override
Handle a received packet.
Definition: sta-wifi-mac.cc:496
ns3::MgtBeaconHeader
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:835
ns3::ApInfo::m_probeResp
MgtProbeResponseHeader m_probeResp
Probe Response header.
Definition: sta-wifi-mac.h:51
ns3::StaWifiMac::ASSOCIATED
@ ASSOCIATED
Definition: sta-wifi-mac.h:159
ns3::CapabilityInformation
Capability information.
Definition: capability-information.h:34
ns3::StaWifiMac::WAIT_BEACON
@ WAIT_BEACON
Definition: sta-wifi-mac.h:160
TwoLevelAggregationTest
Two Level Aggregation Test.
Definition: wifi-aggregation-test.cc:324
ns3::StaWifiMac::SetEdcaParameters
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
Definition: sta-wifi-mac.cc:1085
ns3::StaWifiMac::SetState
void SetState(MacState value)
Set the current MAC state.
Definition: sta-wifi-mac.cc:1069
ns3::StaWifiMac::~StaWifiMac
virtual ~StaWifiMac()
Definition: sta-wifi-mac.cc:110
ns3::StaWifiMac::PhyCapabilitiesChanged
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
Definition: sta-wifi-mac.cc:1095
ns3::MgtProbeResponseHeader
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:619
ns3::StaWifiMac::StaWifiMac
StaWifiMac()
Definition: sta-wifi-mac.cc:88
ns3::StaWifiMac::DoInitialize
void DoInitialize(void) override
Initialize() implementation.
Definition: sta-wifi-mac.cc:104
ns3::StaWifiMac::IsAssociated
bool IsAssociated(void) const
Return whether we are associated with an AP.
Definition: sta-wifi-mac.cc:414
ns3::StaWifiMac::SetActiveProbing
void SetActiveProbing(bool enable)
Enable or disable active probing.
Definition: sta-wifi-mac.cc:123
ns3::AcIndex
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
ns3::StaWifiMac::WAIT_ASSOC_RESP
@ WAIT_ASSOC_RESP
Definition: sta-wifi-mac.h:162
ns3::StaWifiMac
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:107
ns3::StaWifiMac::StartScanning
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag.
Definition: sta-wifi-mac.cc:303
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::StaWifiMac::RestartBeaconWatchdog
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
Definition: sta-wifi-mac.cc:401
ns3::StaWifiMac::m_beaconArrival
TracedCallback< Time > m_beaconArrival
beacon arrival logger
Definition: sta-wifi-mac.h:327
ns3::StaWifiMac::m_assocLogger
TracedCallback< Mac48Address > m_assocLogger
association logger
Definition: sta-wifi-mac.h:325
ns3::StaWifiMac::IsWaitAssocResp
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
Definition: sta-wifi-mac.cc:420
ns3::StaWifiMac::m_beaconWatchdogEnd
Time m_beaconWatchdogEnd
beacon watchdog end
Definition: sta-wifi-mac.h:316
ns3::StaWifiMac::REFUSED
@ REFUSED
Definition: sta-wifi-mac.h:164
ns3::StaWifiMac::GetActiveProbing
bool GetActiveProbing(void) const
Return whether active probing is enabled.
Definition: sta-wifi-mac.cc:135
ns3::StaWifiMac::GetAssociationId
uint16_t GetAssociationId(void) const
Return the association ID.
Definition: sta-wifi-mac.cc:116
ns3::StaWifiMac::TryToEnsureAssociated
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
Definition: sta-wifi-mac.cc:258
third.phy
phy
Definition: third.py:93
ns3::StaWifiMac::GetCapabilities
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
Definition: sta-wifi-mac.cc:1060
ns3::MgtAssocResponseHeader
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:319