A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wifi-remote-station-manager.h
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
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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  */
20 #ifndef WIFI_REMOTE_STATION_MANAGER_H
21 #define WIFI_REMOTE_STATION_MANAGER_H
22 
23 #include <vector>
24 #include <utility>
25 #include "ns3/mac48-address.h"
26 #include "ns3/traced-callback.h"
27 #include "ns3/packet.h"
28 #include "ns3/object.h"
29 #include "ns3/nstime.h"
30 #include "wifi-mode.h"
31 #include "wifi-tx-vector.h"
32 #include "ht-capabilities.h"
33 
34 namespace ns3 {
35 
36 struct WifiRemoteStation;
37 struct WifiRemoteStationState;
38 class WifiPhy;
39 class WifiMacHeader;
40 
48 {
49 public:
57  void NotifyTxSuccess (uint32_t retryCounter);
59  void NotifyTxFailed ();
61  double GetFrameErrorRate () const;
62 private:
74  double m_failAvg;
75 };
76 
84 {
85 public:
86  static TypeId GetTypeId (void);
87 
89  virtual ~WifiRemoteStationManager ();
90 
91  virtual void SetupPhy (Ptr<WifiPhy> phy);
92 
93  uint32_t GetMaxSsrc (void) const;
94  uint32_t GetMaxSlrc (void) const;
95  uint32_t GetRtsCtsThreshold (void) const;
96  uint32_t GetFragmentationThreshold (void) const;
97  void SetMaxSsrc (uint32_t maxSsrc);
98  void SetMaxSlrc (uint32_t maxSlrc);
99  void SetRtsCtsThreshold (uint32_t threshold);
100  void SetFragmentationThreshold (uint32_t threshold);
101  void AddStationHtCapabilities (Mac48Address from,HtCapabilities htcapabilities);
102  void SetHtSupported (bool enable);
103  bool HasHtSupported (void) const;
104 
105  // Invoked in a STA upon dis-association
106  // or in an AP upon reboot
107  void Reset (void);
108  // Invoked in a STA upon association to store
109  // the set of rates which belong to the
110  // BSSBasicRateSet of the associated AP
111  // and which are supported locally.
112  // Invoked in an AP to configure the BSSBasicRateSet
113  void AddBasicMode (WifiMode mode);
114 
115  WifiMode GetDefaultMode (void) const;
116  uint32_t GetNBasicModes (void) const;
117  WifiMode GetBasicMode (uint32_t i) const;
119  void AddBasicMcs (uint8_t mcs);
120 
121  uint8_t GetDefaultMcs (void) const;
122  uint32_t GetNBasicMcs (void) const;
123  uint8_t GetBasicMcs (uint32_t i) const;
124  void AddSupportedMcs (Mac48Address address, uint8_t mcs);
125 
126  WifiMode GetNonUnicastMode (void) const;
127 
128 
133  void Reset (Mac48Address address);
141  void AddSupportedMode (Mac48Address address, WifiMode mode);
142  //void AddBssMembershipParameters(Mac48Address address, uint32_t selector);
143 
144  bool IsBrandNew (Mac48Address address) const;
145  bool IsAssociated (Mac48Address address) const;
146  bool IsWaitAssocTxOk (Mac48Address address) const;
147  void RecordWaitAssocTxOk (Mac48Address address);
148  void RecordGotAssocTxOk (Mac48Address address);
149  void RecordGotAssocTxFailed (Mac48Address address);
150  void RecordDisassociated (Mac48Address address);
151 
163  void PrepareForQueue (Mac48Address address, const WifiMacHeader *header,
164  Ptr<const Packet> packet, uint32_t fullPacketSize);
165 
173  WifiTxVector GetDataTxVector (Mac48Address address, const WifiMacHeader *header,
174  Ptr<const Packet> packet, uint32_t fullPacketSize);
182  WifiTxVector GetRtsTxVector (Mac48Address address, const WifiMacHeader *header,
183  Ptr<const Packet> packet);
184 
186  Ptr<const Packet> packet);
187 
188  //Since CTS to Self parameters don't depened on the station it is implemented in wifiremote station manager
190 
191 
196  void ReportRtsFailed (Mac48Address address, const WifiMacHeader *header);
201  void ReportDataFailed (Mac48Address address, const WifiMacHeader *header);
206  void ReportRtsOk (Mac48Address address, const WifiMacHeader *header,
207  double ctsSnr, WifiMode ctsMode, double rtsSnr);
212  void ReportDataOk (Mac48Address address, const WifiMacHeader *header,
213  double ackSnr, WifiMode ackMode, double dataSnr);
218  void ReportFinalRtsFailed (Mac48Address address, const WifiMacHeader *header);
223  void ReportFinalDataFailed (Mac48Address address, const WifiMacHeader *header);
224 
233  void ReportRxOk (Mac48Address address, const WifiMacHeader *header,
234  double rxSnr, WifiMode txMode);
235 
243  bool NeedRts (Mac48Address address, const WifiMacHeader *header,
244  Ptr<const Packet> packet);
245  bool NeedCtsToSelf (WifiTxVector txVector);
246 
254  bool NeedRtsRetransmission (Mac48Address address, const WifiMacHeader *header,
255  Ptr<const Packet> packet);
263  bool NeedDataRetransmission (Mac48Address address, const WifiMacHeader *header,
264  Ptr<const Packet> packet);
265 
272  bool NeedFragmentation (Mac48Address address, const WifiMacHeader *header,
273  Ptr<const Packet> packet);
281  uint32_t GetFragmentSize (Mac48Address address, const WifiMacHeader *header,
282  Ptr<const Packet> packet, uint32_t fragmentNumber);
290  uint32_t GetFragmentOffset (Mac48Address address, const WifiMacHeader *header,
291  Ptr<const Packet> packet, uint32_t fragmentNumber);
299  bool IsLastFragment (Mac48Address address, const WifiMacHeader *header,
300  Ptr<const Packet> packet, uint32_t fragmentNumber);
301 
315  WifiTxVector GetAckTxVector (Mac48Address address, WifiMode dataMode);
326  uint8_t GetDefaultTxPowerLevel (void) const;
335  void SetDefaultTxPowerLevel (uint8_t txPower);
339  uint32_t GetNumberOfTransmitAntennas (void);
340 
341  protected:
342  virtual void DoDispose (void);
343  // for convenience
344  WifiMode GetSupported (const WifiRemoteStation *station, uint32_t i) const;
345  uint32_t GetNSupported (const WifiRemoteStation *station) const;
346  uint8_t GetMcsSupported (const WifiRemoteStation *station, uint32_t i) const;
347  uint32_t GetNMcsSupported (const WifiRemoteStation *station) const;
348 
349  bool GetShortGuardInterval (const WifiRemoteStation *station) const;
350  bool GetStbc (const WifiRemoteStation *station) const;
351  bool GetGreenfield (const WifiRemoteStation *station) const;
352  uint32_t GetNumberOfReceiveAntennas (const WifiRemoteStation *station) const;
353  uint32_t GetNumberOfTransmitAntennas (const WifiRemoteStation *station) const;
354  uint32_t GetLongRetryCount (const WifiRemoteStation *station) const;
355  uint32_t GetShortRetryCount (const WifiRemoteStation *station) const;
356 private:
367  virtual bool DoNeedRts (WifiRemoteStation *station,
368  Ptr<const Packet> packet, bool normally);
380  virtual bool DoNeedRtsRetransmission (WifiRemoteStation *station,
381  Ptr<const Packet> packet, bool normally);
393  virtual bool DoNeedDataRetransmission (WifiRemoteStation *station,
394  Ptr<const Packet> packet, bool normally);
395 
405  virtual bool DoNeedFragmentation (WifiRemoteStation *station,
406  Ptr<const Packet> packet, bool normally);
414  virtual bool IsLowLatency (void) const = 0;
418  virtual WifiRemoteStation* DoCreateStation (void) const = 0;
428  uint32_t size) = 0;
436  virtual WifiTxVector DoGetRtsTxVector (WifiRemoteStation *station) = 0;
437 
438 
445  virtual uint8_t DoGetCtsTxPowerLevel (Mac48Address address, WifiMode ctsMode);
446 
453  virtual uint8_t DoGetAckTxPowerLevel (Mac48Address address, WifiMode ackMode);
454 
461  virtual uint8_t DoGetBlockAckTxPowerLevel (Mac48Address address, WifiMode blockAckMode);
462 
463  virtual bool DoGetCtsTxGuardInterval (Mac48Address address, WifiMode ctsMode);
464 
465  virtual uint8_t DoGetCtsTxNss(Mac48Address address, WifiMode ctsMode);
466  virtual uint8_t DoGetCtsTxNess(Mac48Address address, WifiMode ctsMode);
467  virtual bool DoGetCtsTxStbc(Mac48Address address, WifiMode ctsMode);
468  virtual bool DoGetAckTxGuardInterval(Mac48Address address, WifiMode ackMode);
469  virtual uint8_t DoGetAckTxNss(Mac48Address address, WifiMode ackMode);
470  virtual uint8_t DoGetAckTxNess(Mac48Address address, WifiMode ackMode);
471  virtual bool DoGetAckTxStbc(Mac48Address address, WifiMode ackMode);
472  virtual bool DoGetBlockAckTxGuardInterval(Mac48Address address, WifiMode blockAckMode);
473  virtual uint8_t DoGetBlockAckTxNss(Mac48Address address, WifiMode blockAckMode);
474  virtual uint8_t DoGetBlockAckTxNess(Mac48Address address, WifiMode blockAckMode);
475  virtual bool DoGetBlockAckTxStbc(Mac48Address address, WifiMode blockAckMode);
476 
477  virtual void DoReportRtsFailed (WifiRemoteStation *station) = 0;
478  virtual void DoReportDataFailed (WifiRemoteStation *station) = 0;
479  virtual void DoReportRtsOk (WifiRemoteStation *station,
480  double ctsSnr, WifiMode ctsMode, double rtsSnr) = 0;
481  virtual void DoReportDataOk (WifiRemoteStation *station,
482  double ackSnr, WifiMode ackMode, double dataSnr) = 0;
483  virtual void DoReportFinalRtsFailed (WifiRemoteStation *station) = 0;
484  virtual void DoReportFinalDataFailed (WifiRemoteStation *station) = 0;
485  virtual void DoReportRxOk (WifiRemoteStation *station,
486  double rxSnr, WifiMode txMode) = 0;
487 
489  WifiRemoteStation* Lookup (Mac48Address address, uint8_t tid) const;
491  WifiRemoteStation* Lookup (Mac48Address address, const WifiMacHeader *header) const;
493 
494  void DoSetFragmentationThreshold (uint32_t threshold);
495  uint32_t DoGetFragmentationThreshold (void) const;
496  uint32_t GetNFragments (const WifiMacHeader *header, Ptr<const Packet> packet);
497 
498  typedef std::vector <WifiRemoteStation *> Stations;
499  typedef std::vector <WifiRemoteStationState *> StationStates;
500 
513  uint8_t m_defaultTxMcs;
514 
525 
527  uint32_t m_maxSsrc;
528  uint32_t m_maxSlrc;
533 
552 
553 };
554 
556 {
557  enum
558  {
563  } m_state;
564 
579  uint32_t m_rx;
580  uint32_t m_tx;
581  bool m_stbc;
583 
584 };
585 
595 {
597  uint32_t m_ssrc;
598  uint32_t m_slrc;
599  uint8_t m_tid;
600 };
601 
602 
603 } // namespace ns3
604 
605 #endif /* WIFI_REMOTE_STATION_MANAGER_H */
virtual uint8_t DoGetAckTxNss(Mac48Address address, WifiMode ackMode)
uint32_t GetNSupported(const WifiRemoteStation *station) const
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
virtual uint8_t DoGetAckTxNess(Mac48Address address, WifiMode ackMode)
uint32_t GetNFragments(const WifiMacHeader *header, Ptr< const Packet > packet)
std::vector< WifiRemoteStationState * > StationStates
bool GetGreenfieldSupported(Mac48Address address) const
bool NeedDataRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
void RecordWaitAssocTxOk(Mac48Address address)
virtual void DoReportRtsFailed(WifiRemoteStation *station)=0
void ReportDataFailed(Mac48Address address, const WifiMacHeader *header)
virtual uint8_t DoGetBlockAckTxNss(Mac48Address address, WifiMode blockAckMode)
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual bool DoGetAckTxGuardInterval(Mac48Address address, WifiMode ackMode)
WifiTxVector GetCtsTxVector(Mac48Address address, WifiMode rtsMode)
virtual uint8_t DoGetBlockAckTxNess(Mac48Address address, WifiMode blockAckMode)
enum ns3::WifiRemoteStationState::@90 m_state
The Ht Capabilities Information ElementThis class knows how to serialise and deserialise the Ht Capab...
uint8_t GetMcsSupported(const WifiRemoteStation *station, uint32_t i) const
bool GetGreenfield(const WifiRemoteStation *station) const
Time m_memoryTime
averaging coefficient depends on the memory time
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
TracedCallback< Mac48Address > m_macTxFinalRtsFailed
bool IsBrandNew(Mac48Address address) const
virtual void SetupPhy(Ptr< WifiPhy > phy)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
virtual bool DoNeedRts(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
Tid independent remote station statistics.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
WifiRemoteStationState * LookupState(Mac48Address address) const
WifiRemoteStationState * m_state
double m_failAvg
moving percentage of failed frames
WifiTxVector GetCtsToSelfTxVector(const WifiMacHeader *header, Ptr< const Packet > packet)
void RecordDisassociated(Mac48Address address)
TracedCallback< Mac48Address > m_macTxFinalDataFailed
bool GetStbc(const WifiRemoteStation *station) const
virtual bool DoNeedDataRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
virtual bool DoGetAckTxStbc(Mac48Address address, WifiMode ackMode)
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)=0
Time m_lastUpdate
when last update has occured
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header)
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)=0
WifiRemoteStation * Lookup(Mac48Address address, uint8_t tid) const
double CalculateAveragingCoefficient()
Calculate averaging coefficient for frame error rate. Depends on time of the last update...
virtual bool DoGetCtsTxGuardInterval(Mac48Address address, WifiMode ctsMode)
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)=0
void ReportRtsFailed(Mac48Address address, const WifiMacHeader *header)
virtual bool DoNeedRtsRetransmission(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
virtual void DoReportDataFailed(WifiRemoteStation *station)=0
void RecordGotAssocTxFailed(Mac48Address address)
WifiMode GetBasicMode(uint32_t i) const
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
WifiRemoteStationInfo GetInfo(Mac48Address address)
void NotifyTxSuccess(uint32_t retryCounter)
Updates average frame error rate when data or RTS was transmitted successfully.
std::vector< uint8_t > WifiMcsList
Definition: wifi-mode.h:180
hold a list of per-remote-station state.
WifiMode GetControlAnswerMode(Mac48Address address, WifiMode reqMode)
virtual uint8_t DoGetCtsTxNss(Mac48Address address, WifiMode ctsMode)
void ReportDataOk(Mac48Address address, const WifiMacHeader *header, double ackSnr, WifiMode ackMode, double dataSnr)
virtual uint8_t DoGetAckTxPowerLevel(Mac48Address address, WifiMode ackMode)
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool IsWaitAssocTxOk(Mac48Address address) const
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
void AddSupportedMode(Mac48Address address, WifiMode mode)
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
void DoSetFragmentationThreshold(uint32_t threshold)
an EUI-48 address
Definition: mac48-address.h:41
TracedCallback< Mac48Address > m_macTxRtsFailed
bool IsAssociated(Mac48Address address) const
virtual bool IsLowLatency(void) const =0
std::vector< WifiMode > WifiModeList
Definition: wifi-mode.h:177
bool GetShortGuardInterval(const WifiRemoteStation *station) const
void ReportRtsOk(Mac48Address address, const WifiMacHeader *header, double ctsSnr, WifiMode ctsMode, double rtsSnr)
TracedCallback< Mac48Address > m_macTxDataFailed
double GetFrameErrorRate() const
Returns frame error rate (probability that frame is corrupted due to transmission error)...
virtual bool DoNeedFragmentation(WifiRemoteStation *station, Ptr< const Packet > packet, bool normally)
void NotifyTxFailed()
Updates average frame error rate when final data or RTS has failed.
bool NeedCtsToSelf(WifiTxVector txVector)
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
void AddSupportedMcs(Mac48Address address, uint8_t mcs)
virtual bool DoGetCtsTxStbc(Mac48Address address, WifiMode ctsMode)
uint32_t GetNMcsSupported(const WifiRemoteStation *station) const
void SetFragmentationThreshold(uint32_t threshold)
virtual bool DoGetBlockAckTxGuardInterval(Mac48Address address, WifiMode blockAckMode)
WifiTxVector GetDataTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
void ReportRxOk(Mac48Address address, const WifiMacHeader *header, double rxSnr, WifiMode txMode)
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
virtual bool DoGetBlockAckTxStbc(Mac48Address address, WifiMode blockAckMode)
bool NeedRtsRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
virtual uint8_t DoGetCtsTxNess(Mac48Address address, WifiMode ctsMode)
WifiTxVector GetRtsTxVector(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
a base class which provides memory management and object aggregation
Definition: object.h:63
tuple address
Definition: first.py:37
bool NeedRts(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
WifiTxVector GetBlockAckTxVector(Mac48Address address, WifiMode dataMode)
virtual uint8_t DoGetCtsTxPowerLevel(Mac48Address address, WifiMode ctsMode)
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)=0
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)=0
a unique identifier for an interface.
Definition: type-id.h:49
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
WifiTxVector GetAckTxVector(Mac48Address address, WifiMode dataMode)
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)=0
hold per-remote-station state.
virtual WifiRemoteStation * DoCreateStation(void) const =0
void RecordGotAssocTxOk(Mac48Address address)
virtual uint8_t DoGetBlockAckTxPowerLevel(Mac48Address address, WifiMode blockAckMode)
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)=0
std::vector< WifiRemoteStation * > Stations