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