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 
32 namespace ns3 {
33 
34 struct WifiRemoteStation;
35 struct WifiRemoteStationState;
36 class WifiPhy;
37 class WifiMacHeader;
38 
46 {
47 public:
55  void NotifyTxSuccess (uint32_t retryCounter);
57  void NotifyTxFailed ();
59  double GetFrameErrorRate () const;
60 private:
72  double m_failAvg;
73 };
74 
82 {
83 public:
84  static TypeId GetTypeId (void);
85 
87  virtual ~WifiRemoteStationManager ();
88 
89  virtual void SetupPhy (Ptr<WifiPhy> phy);
90 
91  uint32_t GetMaxSsrc (void) const;
92  uint32_t GetMaxSlrc (void) const;
93  uint32_t GetRtsCtsThreshold (void) const;
94  uint32_t GetFragmentationThreshold (void) const;
95  void SetMaxSsrc (uint32_t maxSsrc);
96  void SetMaxSlrc (uint32_t maxSlrc);
97  void SetRtsCtsThreshold (uint32_t threshold);
98  void SetFragmentationThreshold (uint32_t threshold);
99 
100  // Invoked in a STA upon dis-association
101  // or in an AP upon reboot
102  void Reset (void);
103  // Invoked in a STA upon association to store
104  // the set of rates which belong to the
105  // BSSBasicRateSet of the associated AP
106  // and which are supported locally.
107  // Invoked in an AP to configure the BSSBasicRateSet
108  void AddBasicMode (WifiMode mode);
109 
110  WifiMode GetDefaultMode (void) const;
111  uint32_t GetNBasicModes (void) const;
112  WifiMode GetBasicMode (uint32_t i) const;
113 
114  WifiMode GetNonUnicastMode (void) const;
115 
116 
121  void Reset (Mac48Address address);
129  void AddSupportedMode (Mac48Address address, WifiMode mode);
130 
131  bool IsBrandNew (Mac48Address address) const;
132  bool IsAssociated (Mac48Address address) const;
133  bool IsWaitAssocTxOk (Mac48Address address) const;
134  void RecordWaitAssocTxOk (Mac48Address address);
135  void RecordGotAssocTxOk (Mac48Address address);
136  void RecordGotAssocTxFailed (Mac48Address address);
137  void RecordDisassociated (Mac48Address address);
138 
150  void PrepareForQueue (Mac48Address address, const WifiMacHeader *header,
151  Ptr<const Packet> packet, uint32_t fullPacketSize);
159  WifiMode GetDataMode (Mac48Address address, const WifiMacHeader *header,
160  Ptr<const Packet> packet, uint32_t fullPacketSize);
168  WifiMode GetRtsMode (Mac48Address address, const WifiMacHeader *header,
169  Ptr<const Packet> packet);
174  void ReportRtsFailed (Mac48Address address, const WifiMacHeader *header);
179  void ReportDataFailed (Mac48Address address, const WifiMacHeader *header);
184  void ReportRtsOk (Mac48Address address, const WifiMacHeader *header,
185  double ctsSnr, WifiMode ctsMode, double rtsSnr);
190  void ReportDataOk (Mac48Address address, const WifiMacHeader *header,
191  double ackSnr, WifiMode ackMode, double dataSnr);
196  void ReportFinalRtsFailed (Mac48Address address, const WifiMacHeader *header);
201  void ReportFinalDataFailed (Mac48Address address, const WifiMacHeader *header);
202 
211  void ReportRxOk (Mac48Address address, const WifiMacHeader *header,
212  double rxSnr, WifiMode txMode);
213 
221  bool NeedRts (Mac48Address address, const WifiMacHeader *header,
222  Ptr<const Packet> packet);
230  bool NeedRtsRetransmission (Mac48Address address, const WifiMacHeader *header,
231  Ptr<const Packet> packet);
239  bool NeedDataRetransmission (Mac48Address address, const WifiMacHeader *header,
240  Ptr<const Packet> packet);
241 
248  bool NeedFragmentation (Mac48Address address, const WifiMacHeader *header,
249  Ptr<const Packet> packet);
257  uint32_t GetFragmentSize (Mac48Address address, const WifiMacHeader *header,
258  Ptr<const Packet> packet, uint32_t fragmentNumber);
266  uint32_t GetFragmentOffset (Mac48Address address, const WifiMacHeader *header,
267  Ptr<const Packet> packet, uint32_t fragmentNumber);
275  bool IsLastFragment (Mac48Address address, const WifiMacHeader *header,
276  Ptr<const Packet> packet, uint32_t fragmentNumber);
277 
284  WifiMode GetCtsMode (Mac48Address address, WifiMode rtsMode);
291  WifiMode GetAckMode (Mac48Address address, WifiMode dataMode);
292 
294 protected:
295  virtual void DoDispose (void);
296  // for convenience
297  WifiMode GetSupported (const WifiRemoteStation *station, uint32_t i) const;
298  uint32_t GetNSupported (const WifiRemoteStation *station) const;
299 private:
310  virtual bool DoNeedRts (WifiRemoteStation *station,
311  Ptr<const Packet> packet, bool normally);
323  virtual bool DoNeedRtsRetransmission (WifiRemoteStation *station,
324  Ptr<const Packet> packet, bool normally);
336  virtual bool DoNeedDataRetransmission (WifiRemoteStation *station,
337  Ptr<const Packet> packet, bool normally);
338 
348  virtual bool DoNeedFragmentation (WifiRemoteStation *station,
349  Ptr<const Packet> packet, bool normally);
357  virtual bool IsLowLatency (void) const = 0;
361  virtual WifiRemoteStation* DoCreateStation (void) const = 0;
370  virtual WifiMode DoGetDataMode (WifiRemoteStation *station,
371  uint32_t size) = 0;
379  virtual WifiMode DoGetRtsMode (WifiRemoteStation *station) = 0;
380  virtual void DoReportRtsFailed (WifiRemoteStation *station) = 0;
381  virtual void DoReportDataFailed (WifiRemoteStation *station) = 0;
382  virtual void DoReportRtsOk (WifiRemoteStation *station,
383  double ctsSnr, WifiMode ctsMode, double rtsSnr) = 0;
384  virtual void DoReportDataOk (WifiRemoteStation *station,
385  double ackSnr, WifiMode ackMode, double dataSnr) = 0;
386  virtual void DoReportFinalRtsFailed (WifiRemoteStation *station) = 0;
387  virtual void DoReportFinalDataFailed (WifiRemoteStation *station) = 0;
388  virtual void DoReportRxOk (WifiRemoteStation *station,
389  double rxSnr, WifiMode txMode) = 0;
390 
392  WifiRemoteStation* Lookup (Mac48Address address, uint8_t tid) const;
394  WifiRemoteStation* Lookup (Mac48Address address, const WifiMacHeader *header) const;
396 
397  void DoSetFragmentationThreshold (uint32_t threshold);
398  uint32_t DoGetFragmentationThreshold (void) const;
399  uint32_t GetNFragments (const WifiMacHeader *header, Ptr<const Packet> packet);
400 
401  typedef std::vector <WifiRemoteStation *> Stations;
402  typedef std::vector <WifiRemoteStationState *> StationStates;
403 
416 
426 
428  uint32_t m_maxSsrc;
429  uint32_t m_maxSlrc;
452 
453 };
454 
456 {
457  enum
458  {
463  } m_state;
464 
475 
478 };
479 
489 {
491  uint32_t m_ssrc;
492  uint32_t m_slrc;
493  uint8_t m_tid;
494 };
495 
496 
497 } // namespace ns3
498 
499 #endif /* WIFI_REMOTE_STATION_MANAGER_H */