A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ideal-wifi-manager.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 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 #include "ideal-wifi-manager.h"
21 #include "wifi-phy.h"
22 #include "ns3/assert.h"
23 #include "ns3/double.h"
24 #include <cmath>
25 
26 #define Min(a,b) ((a < b) ? a : b)
27 
28 namespace ns3 {
29 
37 {
38  double m_lastSnr;
39 };
40 
42  ;
43 
44 TypeId
46 {
47  static TypeId tid = TypeId ("ns3::IdealWifiManager")
49  .AddConstructor<IdealWifiManager> ()
50  .AddAttribute ("BerThreshold",
51  "The maximum Bit Error Rate acceptable at any transmission mode",
52  DoubleValue (10e-6),
53  MakeDoubleAccessor (&IdealWifiManager::m_ber),
54  MakeDoubleChecker<double> ())
55  ;
56  return tid;
57 }
58 
60 {
61 }
63 {
64 }
65 
66 void
68 {
69  uint32_t nModes = phy->GetNModes ();
70  for (uint32_t i = 0; i < nModes; i++)
71  {
72  WifiMode mode = phy->GetMode (i);
73  AddModeSnrThreshold (mode, phy->CalculateSnr (mode, m_ber));
74  }
75 
77 }
78 
79 double
81 {
82  for (Thresholds::const_iterator i = m_thresholds.begin (); i != m_thresholds.end (); i++)
83  {
84  if (mode == i->second)
85  {
86  return i->first;
87  }
88  }
89  NS_ASSERT (false);
90  return 0.0;
91 }
92 
93 void
95 {
96  m_thresholds.push_back (std::make_pair (snr,mode));
97 }
98 
101 {
103  station->m_lastSnr = 0.0;
104  return station;
105 }
106 
107 
108 void
110  double rxSnr, WifiMode txMode)
111 {
112 }
113 void
115 {
116 }
117 void
119 {
120 }
121 void
123  double ctsSnr, WifiMode ctsMode, double rtsSnr)
124 {
126  station->m_lastSnr = rtsSnr;
127 }
128 void
130  double ackSnr, WifiMode ackMode, double dataSnr)
131 {
133  station->m_lastSnr = dataSnr;
134 }
135 void
137 {
138 }
139 void
141 {
142 }
143 
146 {
148  // We search within the Supported rate set the mode with the
149  // highest snr threshold possible which is smaller than m_lastSnr
150  // to ensure correct packet delivery.
151  double maxThreshold = 0.0;
152  WifiMode maxMode = GetDefaultMode ();
153  for (uint32_t i = 0; i < GetNSupported (station); i++)
154  {
155  WifiMode mode = GetSupported (station, i);
156  double threshold = GetSnrThreshold (mode);
157  if (threshold > maxThreshold
158  && threshold < station->m_lastSnr)
159  {
160  maxThreshold = threshold;
161  maxMode = mode;
162  }
163  }
165 }
168 {
170  // We search within the Basic rate set the mode with the highest
171  // snr threshold possible which is smaller than m_lastSnr to
172  // ensure correct packet delivery.
173  double maxThreshold = 0.0;
174  WifiMode maxMode = GetDefaultMode ();
175  for (uint32_t i = 0; i < GetNBasicModes (); i++)
176  {
177  WifiMode mode = GetBasicMode (i);
178  double threshold = GetSnrThreshold (mode);
179  if (threshold > maxThreshold
180  && threshold < station->m_lastSnr)
181  {
182  maxThreshold = threshold;
183  maxMode = mode;
184  }
185  }
187 }
188 
189 bool
191 {
192  return true;
193 }
194 
195 } // namespace ns3
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
uint32_t GetNSupported(const WifiRemoteStation *station) const
Return the number of modes supported by the given station.
virtual bool IsLowLatency(void) const
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
double GetSnrThreshold(WifiMode mode) const
Return the minimum SNR needed to successfully transmit data with this mode at the specified BER...
virtual uint32_t GetNModes(void) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
virtual void SetupPhy(Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
#define NS_ASSERT(condition)
Definition: assert.h:64
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual double CalculateSnr(WifiMode txMode, double ber) const =0
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
This method is a pure virtual method that must be implemented by the sub-class.
hold per-remote-station state for Ideal Wifi manager.
virtual void SetupPhy(Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
Return the number of receive antenna the station has.
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
Return whether mode associated with the specified station at the specified index. ...
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
This method is a pure virtual method that must be implemented by the sub-class.
bool GetStbc(const WifiRemoteStation *station) const
Return whether the given station supports space-time block coding (STBC).
static TypeId GetTypeId(void)
double m_ber
The maximum Bit Error Rate acceptable at any transmission mode.
WifiMode GetBasicMode(uint32_t i) const
Return a basic mode from the set of basic modes.
Thresholds m_thresholds
List of WifiMode and the minimum SNR pair.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Definition: int64x64.h:90
hold a list of per-remote-station state.
virtual void DoReportDataOk(WifiRemoteStation *station, double ackSnr, WifiMode ackMode, double dataSnr)
This method is a pure virtual method that must be implemented by the sub-class.
virtual WifiRemoteStation * DoCreateStation(void) const
virtual WifiMode GetMode(uint32_t mode) const =0
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
bool GetShortGuardInterval(const WifiRemoteStation *station) const
Return whether the given station supports short guard interval.
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
uint32_t GetNBasicModes(void) const
Return the number of basic modes we support.
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Return the long retry limit of the given station.
WifiMode GetDefaultMode(void) const
Return the default transmission mode.
Ideal rate control algorithmThis class implements an 'ideal' rate control algorithm similar to RBAR i...
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
Return the short retry limit of the given station.
virtual void DoReportDataFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
double m_lastSnr
SNR of last packet sent to the remote station.
Hold a floating point type.
Definition: double.h:41
void AddModeSnrThreshold(WifiMode mode, double snr)
Adds a pair of WifiMode and the minimum SNR for that given mode to the list.
a unique identifier for an interface.
Definition: type-id.h:49
virtual void DoReportRtsFailed(WifiRemoteStation *station)
This method is a pure virtual method that must be implemented by the sub-class.
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
hold per-remote-station state.