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 
31 {
32  double m_lastSnr;
33 };
34 
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::IdealWifiManager")
42  .AddConstructor<IdealWifiManager> ()
43  .AddAttribute ("BerThreshold",
44  "The maximum Bit Error Rate acceptable at any transmission mode",
45  DoubleValue (10e-6),
46  MakeDoubleAccessor (&IdealWifiManager::m_ber),
47  MakeDoubleChecker<double> ())
48  ;
49  return tid;
50 }
51 
53 {
54 }
56 {
57 }
58 
59 void
61 {
62  uint32_t nModes = phy->GetNModes ();
63  for (uint32_t i = 0; i < nModes; i++)
64  {
65  WifiMode mode = phy->GetMode (i);
66  AddModeSnrThreshold (mode, phy->CalculateSnr (mode, m_ber));
67  }
68 
70 }
71 
72 double
74 {
75  for (Thresholds::const_iterator i = m_thresholds.begin (); i != m_thresholds.end (); i++)
76  {
77  if (mode == i->second)
78  {
79  return i->first;
80  }
81  }
82  NS_ASSERT (false);
83  return 0.0;
84 }
85 
86 void
88 {
89  m_thresholds.push_back (std::make_pair (snr,mode));
90 }
91 
94 {
96  station->m_lastSnr = 0.0;
97  return station;
98 }
99 
100 
101 void
103  double rxSnr, WifiMode txMode)
104 {
105 }
106 void
108 {
109 }
110 void
112 {
113 }
114 void
116  double ctsSnr, WifiMode ctsMode, double rtsSnr)
117 {
119  station->m_lastSnr = rtsSnr;
120 }
121 void
123  double ackSnr, WifiMode ackMode, double dataSnr)
124 {
126  station->m_lastSnr = dataSnr;
127 }
128 void
130 {
131 }
132 void
134 {
135 }
136 
139 {
141  // We search within the Supported rate set the mode with the
142  // highest snr threshold possible which is smaller than m_lastSnr
143  // to ensure correct packet delivery.
144  double maxThreshold = 0.0;
145  WifiMode maxMode = GetDefaultMode ();
146  for (uint32_t i = 0; i < GetNSupported (station); i++)
147  {
148  WifiMode mode = GetSupported (station, i);
149  double threshold = GetSnrThreshold (mode);
150  if (threshold > maxThreshold
151  && threshold < station->m_lastSnr)
152  {
153  maxThreshold = threshold;
154  maxMode = mode;
155  }
156  }
158 }
161 {
163  // We search within the Basic rate set the mode with the highest
164  // snr threshold possible which is smaller than m_lastSnr to
165  // ensure correct packet delivery.
166  double maxThreshold = 0.0;
167  WifiMode maxMode = GetDefaultMode ();
168  for (uint32_t i = 0; i < GetNBasicModes (); i++)
169  {
170  WifiMode mode = GetBasicMode (i);
171  double threshold = GetSnrThreshold (mode);
172  if (threshold > maxThreshold
173  && threshold < station->m_lastSnr)
174  {
175  maxThreshold = threshold;
176  maxMode = mode;
177  }
178  }
180 }
181 
182 bool
184 {
185  return true;
186 }
187 
188 } // namespace ns3
virtual void DoReportFinalDataFailed(WifiRemoteStation *station)
uint32_t GetNSupported(const WifiRemoteStation *station) const
virtual bool IsLowLatency(void) const
void AddModeSnrThreshold(WifiMode mode, double ber)
virtual void DoReportFinalRtsFailed(WifiRemoteStation *station)
double GetSnrThreshold(WifiMode mode) const
virtual uint32_t GetNModes(void) const =0
virtual void SetupPhy(Ptr< WifiPhy > phy)
#define NS_ASSERT(condition)
Definition: assert.h:64
virtual double CalculateSnr(WifiMode txMode, double ber) const =0
virtual void DoReportRtsOk(WifiRemoteStation *station, double ctsSnr, WifiMode ctsMode, double rtsSnr)
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
uint32_t GetNumberOfReceiveAntennas(const WifiRemoteStation *station) const
WifiMode GetSupported(const WifiRemoteStation *station, uint32_t i) const
virtual void DoReportRxOk(WifiRemoteStation *station, double rxSnr, WifiMode txMode)
bool GetStbc(const WifiRemoteStation *station) const
static TypeId GetTypeId(void)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
WifiMode GetBasicMode(uint32_t i) const
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)
virtual WifiRemoteStation * DoCreateStation(void) const
virtual WifiMode GetMode(uint32_t mode) const =0
bool GetShortGuardInterval(const WifiRemoteStation *station) const
virtual WifiTxVector DoGetDataTxVector(WifiRemoteStation *station, uint32_t size)
virtual WifiTxVector DoGetRtsTxVector(WifiRemoteStation *station)
uint32_t GetLongRetryCount(const WifiRemoteStation *station) const
Ideal rate control algorithmThis class implements an 'ideal' rate control algorithm similar to RBAR i...
uint32_t GetShortRetryCount(const WifiRemoteStation *station) const
virtual void DoReportDataFailed(WifiRemoteStation *station)
Hold an floating point type.
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:49
virtual void DoReportRtsFailed(WifiRemoteStation *station)
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
hold per-remote-station state.