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 
27 #include "mgt-headers.h"
28 
29 namespace ns3 {
30 
31 class SupportedRates;
32 class CapabilityInformation;
33 
40 struct ApInfo
41 {
44  double m_snr;
48 };
49 
103 {
104 public:
109  static TypeId GetTypeId (void);
110 
111  StaWifiMac ();
112  virtual ~StaWifiMac ();
113 
120 
129  void Enqueue (Ptr<const Packet> packet, Mac48Address to);
130 
134  void SetWifiPhy (const Ptr<WifiPhy> phy);
135 
136 
137 private:
141  enum MacState
142  {
149  };
150 
156  void SetActiveProbing (bool enable);
162  bool GetActiveProbing (void) const;
163 
170  void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr);
202  void UpdateCandidateApList (ApInfo newApInfo);
203 
208  void SendProbeRequest (void);
217  void SendAssociationRequest (bool isReassoc);
221  void SendCfPollResponse (void);
226  void TryToEnsureAssociated (void);
231  void AssocRequestTimeout (void);
236  void StartScanning (void);
242  void ScanningTimeout (void);
248  bool IsAssociated (void) const;
254  bool IsWaitAssocResp (void) const;
258  void MissedBeacons (void);
264  void RestartBeaconWatchdog (Time delay);
271  SupportedRates GetSupportedRates (void) const;
277  void SetState (MacState value);
287  void SetEdcaParameters (AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit);
294 
298  void PhyCapabilitiesChanged (void);
299 
300  void DoInitialize (void);
301 
313  std::vector<ApInfo> m_candidateAps;
314  // Note: std::multiset<ApInfo> might be a candidate container to implement
315  // this sorted list, but we are using a std::vector because we want to sort
316  // based on SNR but find duplicates based on BSSID, and in practice this
317  // candidate vector should not be too large.
318 
322 };
323 
324 } //namespace ns3
325 
326 #endif /* STA_WIFI_MAC_H */
void SetWifiPhy(const Ptr< WifiPhy > phy)
bool m_activeProbing
Flag whether active probing is used or not.
Definition: sta-wifi-mac.h:45
TracedCallback< Mac48Address > m_deAssocLogger
deassoc logger
Definition: sta-wifi-mac.h:320
double m_snr
SNR.
Definition: sta-wifi-mac.h:44
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Time m_assocRequestTimeout
assoc request timeout
Definition: sta-wifi-mac.h:305
void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
Handle a received packet.
bool GetActiveProbing(void) const
Return whether active probing is enabled.
void DoInitialize(void)
Initialize() implementation.
void SetEdcaParameters(AcIndex ac, uint32_t cwMin, uint32_t cwMax, uint8_t aifsn, Time txopLimit)
Set the EDCA parameters.
void SetState(MacState value)
Set the current MAC state.
std::vector< ApInfo > m_candidateAps
list of candidate APs to associate
Definition: sta-wifi-mac.h:313
void AssocRequestTimeout(void)
This method is called after the association timeout occurred.
Time m_probeRequestTimeout
probe request timeout
Definition: sta-wifi-mac.h:304
Forward calls to a chain of Callback.
void StartScanning(void)
Start the scanning process which trigger active or passive scanning based on the active probing flag...
Struct to hold information regarding observed AP through active/passive scanning. ...
Definition: sta-wifi-mac.h:40
void UpdateCandidateApList(ApInfo newApInfo)
Update list of candidate AP to associate.
Mac48Address m_bssid
BSSID.
Definition: sta-wifi-mac.h:42
TracedCallback< Mac48Address > m_assocLogger
assoc logger
Definition: sta-wifi-mac.h:319
EventId m_assocRequestEvent
assoc request event
Definition: sta-wifi-mac.h:308
Time m_waitBeaconTimeout
wait beacon timeout
Definition: sta-wifi-mac.h:303
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
Capability information.
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Set up WifiRemoteStationManager associated with this StaWifiMac.
phy
Definition: third.py:86
The Wifi MAC high model for a STA or AP in a BSS.
MacState
The current MAC state of the STA.
Definition: sta-wifi-mac.h:141
void SendProbeRequest(void)
Forward a probe request packet to the DCF.
CapabilityInformation GetCapabilities(void) const
Return the Capability information of the current STA.
void UpdateApInfoFromBeacon(MgtBeaconHeader beacon, Mac48Address apAddr, Mac48Address bssid)
Update associated AP&#39;s information from beacon.
SupportedRates GetSupportedRates(void) const
Return an instance of SupportedRates that contains all rates that we support including HT rates...
Mac48Address m_apAddr
AP MAC address.
Definition: sta-wifi-mac.h:43
MacState m_state
MAC state.
Definition: sta-wifi-mac.h:302
void MissedBeacons(void)
This method is called after we have not received a beacon from the AP.
MgtProbeResponseHeader m_probeResp
Probe Response header.
Definition: sta-wifi-mac.h:47
void ScanningTimeout(void)
This method is called after wait beacon timeout or wait probe request timeout has occurred...
void SendCfPollResponse(void)
Forward a CF-Poll response packet to the CFP queue.
uint32_t m_maxMissedBeacons
maximum missed beacons
Definition: sta-wifi-mac.h:311
EventId m_beaconWatchdog
beacon watchdog
Definition: sta-wifi-mac.h:309
void UpdateApInfoFromProbeResp(MgtProbeResponseHeader probeResp, Mac48Address apAddr, Mac48Address bssid)
Update AP&#39;s information from probe response.
virtual ~StaWifiMac()
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void PhyCapabilitiesChanged(void)
Indicate that PHY capabilities have changed.
static TypeId GetTypeId(void)
Get the type ID.
Definition: sta-wifi-mac.cc:39
an EUI-48 address
Definition: mac48-address.h:43
void RestartBeaconWatchdog(Time delay)
Restarts the beacon timer.
void TryToEnsureAssociated(void)
Try to ensure that we are associated with an AP by taking an appropriate action depending on the curr...
MgtBeaconHeader m_beacon
Beacon header.
Definition: sta-wifi-mac.h:46
EventId m_waitBeaconEvent
wait beacon event
Definition: sta-wifi-mac.h:306
void SetActiveProbing(bool enable)
Enable or disable active probing.
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:318
void UpdateApInfoFromAssocResp(MgtAssocResponseHeader assocResp, Mac48Address apAddr)
Update AP&#39;s information from association response.
An identifier for simulation events.
Definition: event-id.h:53
void Enqueue(Ptr< const Packet > packet, Mac48Address to)
bool IsWaitAssocResp(void) const
Return whether we are waiting for an association response from an AP.
Time m_beaconWatchdogEnd
beacon watchdog end
Definition: sta-wifi-mac.h:310
bool m_activeProbing
active probing
Definition: sta-wifi-mac.h:312
EventId m_probeRequestEvent
probe request event
Definition: sta-wifi-mac.h:307
Implement the header for management frames of type probe response.
Definition: mgt-headers.h:612
a unique identifier for an interface.
Definition: type-id.h:58
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:37
Implement the header for management frames of type beacon.
Definition: mgt-headers.h:841
Implements the IEEE 802.11 MAC header.
void SendAssociationRequest(bool isReassoc)
Forward an association or reassociation request packet to the DCF.
bool IsAssociated(void) const
Return whether we are associated with an AP.
TracedCallback< Time > m_beaconArrival
beacon arrival logger
Definition: sta-wifi-mac.h:321
The Wifi MAC high model for a non-AP STA in a BSS.
Definition: sta-wifi-mac.h:102