author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 12 Jun 2008 12:28:36 -0700 | |
changeset 3902 | 9e048e073cf0 |
parent 3900 | 1687492ff059 |
child 3905 | 99c9346b5d71 |
permissions | -rw-r--r-- |
1889 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2005,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 |
||
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
21 |
#include "yans-wifi-phy.h" |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
22 |
#include "yans-wifi-channel.h" |
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
23 |
#include "wifi-mode.h" |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
24 |
#include "wifi-preamble.h" |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
25 |
#include "wifi-phy-state-helper.h" |
3902
9e048e073cf0
split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3900
diff
changeset
|
26 |
#include "error-rate-model.h" |
1889 | 27 |
#include "ns3/simulator.h" |
28 |
#include "ns3/packet.h" |
|
29 |
#include "ns3/random-variable.h" |
|
1974
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
30 |
#include "ns3/assert.h" |
1979
d535a38b7fc4
convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1978
diff
changeset
|
31 |
#include "ns3/log.h" |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
32 |
#include "ns3/double.h" |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
33 |
#include "ns3/uinteger.h" |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
34 |
#include "ns3/enum.h" |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
35 |
#include "ns3/pointer.h" |
1889 | 36 |
#include <math.h> |
37 |
||
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
38 |
NS_LOG_COMPONENT_DEFINE ("YansWifiPhy"); |
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
39 |
|
1889 | 40 |
namespace ns3 { |
41 |
||
42 |
/**************************************************************** |
|
43 |
* Phy event class |
|
44 |
****************************************************************/ |
|
45 |
||
2630
17b545238ab3
do not use ObjectBase as a base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
46 |
class RxEvent |
2370
5f7ad186b798
introduce ObjectBase
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2173
diff
changeset
|
47 |
{ |
1889 | 48 |
public: |
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
49 |
RxEvent (uint32_t size, WifiMode payloadMode, |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
50 |
enum WifiPreamble preamble, |
1889 | 51 |
Time duration, double rxPower) |
52 |
: m_size (size), |
|
53 |
m_payloadMode (payloadMode), |
|
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
54 |
m_preamble (preamble), |
1889 | 55 |
m_startTime (Simulator::Now ()), |
56 |
m_endTime (m_startTime + duration), |
|
57 |
m_rxPowerW (rxPower), |
|
58 |
m_refCount (1) |
|
59 |
{} |
|
60 |
~RxEvent () |
|
1992
5ff1101cb843
do not call Unref directly anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1988
diff
changeset
|
61 |
{ |
5ff1101cb843
do not call Unref directly anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1988
diff
changeset
|
62 |
NS_ASSERT (m_refCount == 0); |
5ff1101cb843
do not call Unref directly anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1988
diff
changeset
|
63 |
} |
1889 | 64 |
|
65 |
void Ref (void) const { |
|
66 |
m_refCount++; |
|
67 |
} |
|
68 |
void Unref (void) const { |
|
69 |
m_refCount--; |
|
70 |
if (m_refCount == 0) { |
|
71 |
delete this; |
|
72 |
} |
|
73 |
} |
|
74 |
Time GetDuration (void) const { |
|
75 |
return m_endTime - m_startTime; |
|
76 |
} |
|
77 |
Time GetStartTime (void) const { |
|
78 |
return m_startTime; |
|
79 |
} |
|
80 |
Time GetEndTime (void) const { |
|
81 |
return m_endTime; |
|
82 |
} |
|
83 |
bool Overlaps (Time time) const { |
|
84 |
if (m_startTime <= time && |
|
85 |
m_endTime >= time) { |
|
86 |
return true; |
|
87 |
} else { |
|
88 |
return false; |
|
89 |
} |
|
90 |
} |
|
91 |
double GetRxPowerW (void) const { |
|
92 |
return m_rxPowerW; |
|
93 |
} |
|
94 |
uint32_t GetSize (void) const { |
|
95 |
return m_size; |
|
96 |
} |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
97 |
WifiMode GetPayloadMode (void) const { |
1889 | 98 |
return m_payloadMode; |
99 |
} |
|
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
100 |
enum WifiPreamble GetPreambleType (void) const { |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
101 |
return m_preamble; |
1889 | 102 |
} |
103 |
||
104 |
private: |
|
105 |
uint32_t m_size; |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
106 |
WifiMode m_payloadMode; |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
107 |
enum WifiPreamble m_preamble; |
1889 | 108 |
Time m_startTime; |
109 |
Time m_endTime; |
|
110 |
double m_rxPowerW; |
|
111 |
mutable int m_refCount; |
|
112 |
}; |
|
113 |
||
114 |
||
115 |
/**************************************************************** |
|
116 |
* Class which records SNIR change events for a |
|
117 |
* short period of time. |
|
118 |
****************************************************************/ |
|
119 |
||
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
120 |
YansWifiPhy::NiChange::NiChange (Time time, double delta) |
1889 | 121 |
: m_time (time), m_delta (delta) |
122 |
{} |
|
123 |
Time |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
124 |
YansWifiPhy::NiChange::GetTime (void) const |
1889 | 125 |
{ |
126 |
return m_time; |
|
127 |
} |
|
128 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
129 |
YansWifiPhy::NiChange::GetDelta (void) const |
1889 | 130 |
{ |
131 |
return m_delta; |
|
132 |
} |
|
133 |
bool |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
134 |
YansWifiPhy::NiChange::operator < (YansWifiPhy::NiChange const &o) const |
1889 | 135 |
{ |
136 |
return (m_time < o.m_time)?true:false; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
||
141 |
/**************************************************************** |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
142 |
* The actual YansWifiPhy class |
1889 | 143 |
****************************************************************/ |
144 |
||
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
145 |
NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
146 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
147 |
TypeId |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
148 |
YansWifiPhy::GetTypeId (void) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
149 |
{ |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
150 |
static TypeId tid = TypeId ("ns3::YansWifiPhy") |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
151 |
.SetParent<WifiPhy> () |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
152 |
.AddConstructor<YansWifiPhy> () |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
153 |
.AddAttribute ("EnergyDetectionThreshold", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
154 |
"The energy of a received signal should be higher than " |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
155 |
"this threshold (dbm) to allow the PHY layer to detect the signal.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
156 |
DoubleValue (-140.0), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
157 |
MakeDoubleAccessor (&YansWifiPhy::SetEdThreshold, |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
158 |
&YansWifiPhy::GetEdThreshold), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
159 |
MakeDoubleChecker<double> ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
160 |
.AddAttribute ("TxGain", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
161 |
"Transmission gain (dB).", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
162 |
DoubleValue (1.0), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
163 |
MakeDoubleAccessor (&YansWifiPhy::SetTxGain, |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
164 |
&YansWifiPhy::GetTxGain), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
165 |
MakeDoubleChecker<double> ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
166 |
.AddAttribute ("RxGain", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
167 |
"Reception gain (dB).", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
168 |
DoubleValue (1.0), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
169 |
MakeDoubleAccessor (&YansWifiPhy::SetRxGain, |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
170 |
&YansWifiPhy::GetRxGain), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
171 |
MakeDoubleChecker<double> ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
172 |
.AddAttribute ("TxPowerLevels", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
173 |
"Number of transmission power levels available between " |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
174 |
"TxPowerBase and TxPowerEnd included.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
175 |
UintegerValue (1), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
176 |
MakeUintegerAccessor (&YansWifiPhy::m_nTxPower), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
177 |
MakeUintegerChecker<uint32_t> ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
178 |
.AddAttribute ("TxPowerEnd", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
179 |
"Maximum available transmission level (dbm).", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
180 |
DoubleValue (16.0206), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
181 |
MakeDoubleAccessor (&YansWifiPhy::SetTxPowerEnd, |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
182 |
&YansWifiPhy::GetTxPowerEnd), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
183 |
MakeDoubleChecker<double> ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
184 |
.AddAttribute ("TxPowerStart", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
185 |
"Minimum available transmission level (dbm).", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
186 |
DoubleValue (16.0206), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
187 |
MakeDoubleAccessor (&YansWifiPhy::SetTxPowerStart, |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
188 |
&YansWifiPhy::GetTxPowerStart), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
189 |
MakeDoubleChecker<double> ()) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
190 |
.AddAttribute ("RxNoise", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
191 |
"Ratio of energy lost by receiver (dB).", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
192 |
DoubleValue (7), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
193 |
MakeDoubleAccessor (&YansWifiPhy::SetRxNoise, |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
194 |
&YansWifiPhy::GetRxNoise), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
195 |
MakeDoubleChecker<double> ()) |
3212
0c00342d6a73
improve attribute documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
196 |
.AddAttribute ("Standard", "The standard chosen configures a set of transmission modes" |
0c00342d6a73
improve attribute documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2989
diff
changeset
|
197 |
" and some PHY-specific constants.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
198 |
EnumValue (WIFI_PHY_STANDARD_80211a), |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
199 |
MakeEnumAccessor (&YansWifiPhy::SetStandard), |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
200 |
MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a", |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
201 |
WIFI_PHY_STANDARD_holland, "holland")) |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
202 |
.AddAttribute ("State", "The state of the PHY layer", |
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
203 |
PointerValue (), |
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
204 |
MakePointerAccessor (&YansWifiPhy::m_state), |
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
205 |
MakePointerChecker<WifiPhyStateHelper> ()) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
206 |
; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
207 |
return tid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
208 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
209 |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
210 |
YansWifiPhy::YansWifiPhy () |
3897
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
211 |
: m_endSyncEvent (), |
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
212 |
m_random (0.0, 1.0) |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
213 |
{ |
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
214 |
NS_LOG_FUNCTION (this); |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
215 |
m_state = CreateObject<WifiPhyStateHelper> (); |
3902
9e048e073cf0
split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3900
diff
changeset
|
216 |
m_errorRateModel = Create<ErrorRateModel> (); |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
217 |
} |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
218 |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
219 |
YansWifiPhy::~YansWifiPhy () |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
220 |
{ |
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
221 |
NS_LOG_FUNCTION (this); |
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
222 |
} |
2530
05f9cec44621
avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
223 |
|
05f9cec44621
avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
224 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
225 |
YansWifiPhy::DoDispose (void) |
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1920
diff
changeset
|
226 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
227 |
NS_LOG_FUNCTION (this); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
228 |
m_channel = 0; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
229 |
m_events.clear (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
230 |
m_modes.clear (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
231 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
232 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
233 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
234 |
YansWifiPhy::SetStandard (enum WifiPhyStandard standard) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
235 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
236 |
NS_LOG_FUNCTION (this << standard); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
237 |
m_standard = standard; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
238 |
switch (standard) { |
2166
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
239 |
case WIFI_PHY_STANDARD_80211a: |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
240 |
Configure80211a (); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
241 |
break; |
2166
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
242 |
case WIFI_PHY_STANDARD_holland: |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
243 |
ConfigureHolland (); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
244 |
break; |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
245 |
default: |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
246 |
NS_ASSERT (false); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
247 |
break; |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
248 |
} |
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1920
diff
changeset
|
249 |
} |
1889 | 250 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
251 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
252 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
253 |
YansWifiPhy::SetRxNoise (double db) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
254 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
255 |
NS_LOG_FUNCTION (this << db); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
256 |
m_rxNoiseRatio = DbToRatio (db); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
257 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
258 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
259 |
YansWifiPhy::SetTxPowerStart (double start) |
1889 | 260 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
261 |
NS_LOG_FUNCTION (this << start); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
262 |
m_txPowerBaseDbm = start; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
263 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
264 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
265 |
YansWifiPhy::SetTxPowerEnd (double end) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
266 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
267 |
NS_LOG_FUNCTION (this << end); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
268 |
m_txPowerEndDbm = end; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
269 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
270 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
271 |
YansWifiPhy::SetNTxPower (uint32_t n) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
272 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
273 |
NS_LOG_FUNCTION (this << n); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
274 |
m_nTxPower = n; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
275 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
276 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
277 |
YansWifiPhy::SetTxGain (double gain) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
278 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
279 |
NS_LOG_FUNCTION (this << gain); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
280 |
m_txGainDb = gain; |
1889 | 281 |
} |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
282 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
283 |
YansWifiPhy::SetRxGain (double gain) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
284 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
285 |
NS_LOG_FUNCTION (this << gain); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
286 |
m_rxGainDb = gain; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
287 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
288 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
289 |
YansWifiPhy::SetEdThreshold (double threshold) |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
290 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
291 |
NS_LOG_FUNCTION (this << threshold); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
292 |
m_edThresholdW = DbmToW (threshold); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
293 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
294 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
295 |
YansWifiPhy::GetRxNoise (void) const |
2155
194dd8bdcf56
add WifiPhy::GetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2150
diff
changeset
|
296 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
297 |
return RatioToDb (m_rxNoiseRatio); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
298 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
299 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
300 |
YansWifiPhy::GetTxPowerStart (void) const |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
301 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
302 |
return m_txPowerBaseDbm; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
303 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
304 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
305 |
YansWifiPhy::GetTxPowerEnd (void) const |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
306 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
307 |
return m_txPowerEndDbm; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
308 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
309 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
310 |
YansWifiPhy::GetTxGain (void) const |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
311 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
312 |
return m_txGainDb; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
313 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
314 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
315 |
YansWifiPhy::GetRxGain (void) const |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
316 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
317 |
return m_rxGainDb; |
2155
194dd8bdcf56
add WifiPhy::GetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2150
diff
changeset
|
318 |
} |
194dd8bdcf56
add WifiPhy::GetDevice
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2150
diff
changeset
|
319 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
320 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
321 |
YansWifiPhy::GetEdThreshold (void) const |
2055
8899d6ef5d52
phy state logger
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1999
diff
changeset
|
322 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
323 |
return WToDbm (m_edThresholdW); |
2055
8899d6ef5d52
phy state logger
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1999
diff
changeset
|
324 |
} |
1889 | 325 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
326 |
Ptr<WifiChannel> |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
327 |
YansWifiPhy::GetChannel (void) const |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
328 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
329 |
return m_channel; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
330 |
} |
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
331 |
|
1889 | 332 |
void |
3893
94f771c1373a
split WifiChannel in WifiChannel + YansWifiChannel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3888
diff
changeset
|
333 |
YansWifiPhy::SetChannel (Ptr<YansWifiChannel> channel) |
1889 | 334 |
{ |
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
335 |
m_channel = channel; |
1889 | 336 |
} |
337 |
||
338 |
void |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
339 |
YansWifiPhy::SetReceiveOkCallback (SyncOkCallback callback) |
1889 | 340 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
341 |
m_state->SetReceiveOkCallback (callback); |
1889 | 342 |
} |
343 |
void |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
344 |
YansWifiPhy::SetReceiveErrorCallback (SyncErrorCallback callback) |
1889 | 345 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
346 |
m_state->SetReceiveErrorCallback (callback); |
1889 | 347 |
} |
348 |
void |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
349 |
YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
350 |
double rxPowerDbm, |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
351 |
WifiMode txMode, |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
352 |
enum WifiPreamble preamble) |
1889 | 353 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
354 |
NS_LOG_FUNCTION (this << packet << rxPowerDbm << txMode << preamble); |
2071
122c95ffccdd
use dB instead of dbm where appropriate
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2056
diff
changeset
|
355 |
rxPowerDbm += m_rxGainDb; |
1988
210701141b08
convert to and from dbms when needed
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1979
diff
changeset
|
356 |
double rxPowerW = DbmToW (rxPowerDbm); |
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2155
diff
changeset
|
357 |
Time rxDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); |
1889 | 358 |
Time endRx = Simulator::Now () + rxDuration; |
359 |
||
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2155
diff
changeset
|
360 |
Ptr<RxEvent> event = Create<RxEvent> (packet->GetSize (), |
1889 | 361 |
txMode, |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
362 |
preamble, |
1889 | 363 |
rxDuration, |
364 |
rxPowerW); |
|
365 |
AppendEvent (event); |
|
366 |
||
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
367 |
switch (m_state->GetState ()) { |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
368 |
case YansWifiPhy::SYNC: |
1979
d535a38b7fc4
convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1978
diff
changeset
|
369 |
NS_LOG_DEBUG ("drop packet because already in Sync (power="<< |
d535a38b7fc4
convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1978
diff
changeset
|
370 |
rxPowerW<<"W)"); |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
371 |
if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
1889 | 372 |
{ |
3897
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
373 |
// that packet will be noise _after_ the reception of the |
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
374 |
// currently-received packet. |
1889 | 375 |
goto maybeCcaBusy; |
376 |
} |
|
377 |
break; |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
378 |
case YansWifiPhy::TX: |
1979
d535a38b7fc4
convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1978
diff
changeset
|
379 |
NS_LOG_DEBUG ("drop packet because already in Tx (power="<< |
d535a38b7fc4
convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1978
diff
changeset
|
380 |
rxPowerW<<"W)"); |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
381 |
if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ()) |
1889 | 382 |
{ |
3897
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
383 |
// that packet will be noise _after_ the transmission of the |
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
384 |
// currently-transmitted packet. |
1889 | 385 |
goto maybeCcaBusy; |
386 |
} |
|
387 |
break; |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
388 |
case YansWifiPhy::CCA_BUSY: |
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
389 |
case YansWifiPhy::IDLE: |
1889 | 390 |
if (rxPowerW > m_edThresholdW) |
391 |
{ |
|
2150
e4aff46fe6c5
add some info logs, improve snr vs ber curve output, linearize the ber calculations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2139
diff
changeset
|
392 |
NS_LOG_DEBUG ("sync (power="<<rxPowerW<<"W)"); |
1889 | 393 |
// sync to signal |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
394 |
m_state->SwitchToSync (rxDuration); |
1974
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
395 |
NS_ASSERT (m_endSyncEvent.IsExpired ()); |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
396 |
m_endSyncEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndSync, this, |
1889 | 397 |
packet, |
1919
46ed9ed9dac0
remove extra WifiPhy::SendPacket argument. Add header mode support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1909
diff
changeset
|
398 |
event); |
2071
122c95ffccdd
use dB instead of dbm where appropriate
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2056
diff
changeset
|
399 |
} |
1889 | 400 |
else |
401 |
{ |
|
1979
d535a38b7fc4
convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1978
diff
changeset
|
402 |
NS_LOG_DEBUG ("drop packet because signal power too Small ("<< |
d535a38b7fc4
convert TRACE to NS_LOG
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1978
diff
changeset
|
403 |
rxPowerW<<"<"<<m_edThresholdW<<")"); |
1889 | 404 |
goto maybeCcaBusy; |
405 |
} |
|
406 |
break; |
|
407 |
} |
|
408 |
||
409 |
return; |
|
410 |
||
411 |
maybeCcaBusy: |
|
412 |
||
413 |
if (rxPowerW > m_edThresholdW) |
|
414 |
{ |
|
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
415 |
m_state->SwitchMaybeToCcaBusy (rxDuration); |
1889 | 416 |
} |
417 |
else |
|
418 |
{ |
|
419 |
double threshold = m_edThresholdW - rxPowerW; |
|
420 |
NiChanges ni; |
|
421 |
CalculateNoiseInterferenceW (event, &ni); |
|
422 |
double noiseInterferenceW = 0.0; |
|
423 |
Time end = Simulator::Now (); |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
424 |
for (NiChanges::const_iterator i = ni.begin (); i != ni.end (); i++) |
1889 | 425 |
{ |
426 |
noiseInterferenceW += i->GetDelta (); |
|
427 |
if (noiseInterferenceW < threshold) |
|
428 |
{ |
|
429 |
break; |
|
430 |
} |
|
431 |
end = i->GetTime (); |
|
432 |
} |
|
433 |
if (end > Simulator::Now ()) |
|
434 |
{ |
|
435 |
Time delta = end - Simulator::Now (); |
|
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
436 |
m_state->SwitchMaybeToCcaBusy (delta); |
1889 | 437 |
} |
438 |
} |
|
439 |
||
440 |
} |
|
441 |
void |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
442 |
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower) |
1889 | 443 |
{ |
3882
05de3d432860
print the tx power, not a random character
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3880
diff
changeset
|
444 |
NS_LOG_FUNCTION (this << packet << txMode << preamble << (uint32_t)txPower); |
1889 | 445 |
/* Transmission can happen if: |
446 |
* - we are syncing on a packet. It is the responsability of the |
|
447 |
* MAC layer to avoid doing this but the PHY does nothing to |
|
448 |
* prevent it. |
|
449 |
* - we are idle |
|
450 |
*/ |
|
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
451 |
NS_ASSERT (!m_state->IsStateTx ()); |
1889 | 452 |
|
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2155
diff
changeset
|
453 |
Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
454 |
if (m_state->IsStateSync ()) |
3897
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
455 |
{ |
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
456 |
m_endSyncEvent.Cancel (); |
44645cec42f2
split state management in a helper class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3893
diff
changeset
|
457 |
} |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
458 |
m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
459 |
m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble); |
1889 | 460 |
} |
461 |
||
462 |
uint32_t |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
463 |
YansWifiPhy::GetNModes (void) const |
1889 | 464 |
{ |
465 |
return m_modes.size (); |
|
466 |
} |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
467 |
WifiMode |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
468 |
YansWifiPhy::GetMode (uint32_t mode) const |
1889 | 469 |
{ |
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
470 |
return m_modes[mode]; |
1889 | 471 |
} |
472 |
uint32_t |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
473 |
YansWifiPhy::GetNTxPower (void) const |
1889 | 474 |
{ |
475 |
return m_nTxPower; |
|
476 |
} |
|
477 |
||
478 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
479 |
YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const |
1889 | 480 |
{ |
481 |
double low, high, precision; |
|
482 |
low = 1e-25; |
|
483 |
high = 1e25; |
|
484 |
precision = 1e-12; |
|
485 |
while (high - low > precision) |
|
486 |
{ |
|
1974
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
487 |
NS_ASSERT (high >= low); |
1889 | 488 |
double middle = low + (high - low) / 2; |
3902
9e048e073cf0
split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3900
diff
changeset
|
489 |
if ((1 - m_errorRateModel->GetChunkSuccessRate (txMode, middle, 1)) > ber) |
1889 | 490 |
{ |
491 |
low = middle; |
|
492 |
} |
|
493 |
else |
|
494 |
{ |
|
495 |
high = middle; |
|
496 |
} |
|
497 |
} |
|
498 |
return low; |
|
499 |
} |
|
500 |
||
501 |
void |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
502 |
YansWifiPhy::Configure80211aParameters (void) |
1889 | 503 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
504 |
NS_LOG_FUNCTION (this); |
2166
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
505 |
m_plcpLongPreambleDelayUs = 16; |
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
506 |
m_plcpShortPreambleDelayUs = 16; |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
507 |
m_longPlcpHeaderMode = g_6mba; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
508 |
m_shortPlcpHeaderMode = g_6mba; |
2166
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
509 |
m_plcpHeaderLength = 4 + 1 + 12 + 1 + 6; |
1889 | 510 |
/* 4095 bytes at a 6Mb/s rate with a 1/2 coding rate. */ |
2167
3b0f18764163
re-use the CaculateTxDuration method where it is needed.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2166
diff
changeset
|
511 |
m_maxPacketDuration = CalculateTxDuration (4095, g_6mba, WIFI_PREAMBLE_LONG); |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
512 |
} |
1889 | 513 |
|
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
514 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
515 |
YansWifiPhy::PrintModes (void) const |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
516 |
{ |
2150
e4aff46fe6c5
add some info logs, improve snr vs ber curve output, linearize the ber calculations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2139
diff
changeset
|
517 |
#if 0 |
e4aff46fe6c5
add some info logs, improve snr vs ber curve output, linearize the ber calculations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2139
diff
changeset
|
518 |
for (double db = -10; db < 30; db+= 0.5) { |
e4aff46fe6c5
add some info logs, improve snr vs ber curve output, linearize the ber calculations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2139
diff
changeset
|
519 |
double snr = DbToRatio (db); |
e4aff46fe6c5
add some info logs, improve snr vs ber curve output, linearize the ber calculations.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2139
diff
changeset
|
520 |
std::cout <<snr<<" "; |
1889 | 521 |
for (uint8_t i = 0; i < GetNModes (); i++) { |
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
522 |
WifiMode mode = GetMode (i); |
3902
9e048e073cf0
split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3900
diff
changeset
|
523 |
double ber = 1-m_errorRateModel->GetChunkSuccessRate (mode,snr, 2000*8); |
1889 | 524 |
std::cout <<ber<< " "; |
525 |
} |
|
526 |
std::cout << std::endl; |
|
527 |
} |
|
528 |
#endif |
|
529 |
} |
|
530 |
||
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
531 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
532 |
YansWifiPhy::Configure80211a (void) |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
533 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
534 |
NS_LOG_FUNCTION (this); |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
535 |
Configure80211aParameters (); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
536 |
m_modes.push_back (g_6mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
537 |
m_modes.push_back (g_9mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
538 |
m_modes.push_back (g_12mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
539 |
m_modes.push_back (g_18mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
540 |
m_modes.push_back (g_24mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
541 |
m_modes.push_back (g_36mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
542 |
m_modes.push_back (g_48mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
543 |
m_modes.push_back (g_54mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
544 |
|
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
545 |
PrintModes (); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
546 |
} |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
547 |
|
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
548 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
549 |
YansWifiPhy::ConfigureHolland (void) |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
550 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
551 |
NS_LOG_FUNCTION (this); |
2083
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
552 |
Configure80211aParameters (); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
553 |
m_modes.push_back (g_6mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
554 |
m_modes.push_back (g_12mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
555 |
m_modes.push_back (g_18mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
556 |
m_modes.push_back (g_36mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
557 |
m_modes.push_back (g_54mba); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
558 |
|
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
559 |
PrintModes (); |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
560 |
} |
c7541b84285e
add the holland 802.11a set of modes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2077
diff
changeset
|
561 |
|
1889 | 562 |
void |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
563 |
YansWifiPhy::RegisterListener (WifiPhyListener *listener) |
1889 | 564 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
565 |
m_state->RegisterListener (listener); |
1889 | 566 |
} |
567 |
||
568 |
bool |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
569 |
YansWifiPhy::IsStateCcaBusy (void) |
1889 | 570 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
571 |
return m_state->IsStateCcaBusy (); |
1889 | 572 |
} |
573 |
||
574 |
bool |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
575 |
YansWifiPhy::IsStateIdle (void) |
1889 | 576 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
577 |
return m_state->IsStateIdle (); |
1889 | 578 |
} |
579 |
bool |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
580 |
YansWifiPhy::IsStateBusy (void) |
1889 | 581 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
582 |
return m_state->IsStateBusy (); |
1889 | 583 |
} |
584 |
bool |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
585 |
YansWifiPhy::IsStateSync (void) |
1889 | 586 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
587 |
return m_state->IsStateSync (); |
1889 | 588 |
} |
589 |
bool |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
590 |
YansWifiPhy::IsStateTx (void) |
1889 | 591 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
592 |
return m_state->IsStateTx (); |
1889 | 593 |
} |
594 |
||
595 |
Time |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
596 |
YansWifiPhy::GetStateDuration (void) |
1889 | 597 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
598 |
return m_state->GetStateDuration (); |
1889 | 599 |
} |
600 |
Time |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
601 |
YansWifiPhy::GetDelayUntilIdle (void) |
1889 | 602 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
603 |
return m_state->GetDelayUntilIdle (); |
1889 | 604 |
} |
605 |
||
2139
a2cf93c741c3
add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2083
diff
changeset
|
606 |
Time |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
607 |
YansWifiPhy::GetLastRxStartTime (void) const |
2139
a2cf93c741c3
add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2083
diff
changeset
|
608 |
{ |
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
609 |
return m_state->GetLastRxStartTime (); |
2139
a2cf93c741c3
add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2083
diff
changeset
|
610 |
} |
a2cf93c741c3
add WifiPhy::GetLastRxStart
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2083
diff
changeset
|
611 |
|
1889 | 612 |
|
613 |
Time |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
614 |
YansWifiPhy::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble) const |
1889 | 615 |
{ |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
616 |
uint64_t delay = 0; |
2166
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
617 |
switch (m_standard) { |
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
618 |
case WIFI_PHY_STANDARD_80211a: |
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
619 |
case WIFI_PHY_STANDARD_holland: { |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
620 |
delay += m_plcpLongPreambleDelayUs; |
2166
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
621 |
// symbol duration is 4us |
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
622 |
delay += 4; |
2173
7437d8a72987
Avoid integer division
Federico Maguolo <maguolof@dei.unipd.it>
parents:
2167
diff
changeset
|
623 |
delay += lrint (ceil ((size * 8.0 + 16.0 + 6.0) / payloadMode.GetDataRate () / 4e-6) * 4); |
2166
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
624 |
} break; |
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
625 |
default: |
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
626 |
// quiet compiler. |
00b5eb43dba2
Improve the accuracy of 802.11a tx duration calculations.
Federico Maguolo <federico.maguolo@dei.unipd.it>
parents:
2164
diff
changeset
|
627 |
NS_ASSERT (false); |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
628 |
break; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
629 |
} |
1889 | 630 |
return MicroSeconds (delay); |
631 |
} |
|
632 |
||
633 |
||
634 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
635 |
YansWifiPhy::DbToRatio (double dB) const |
1889 | 636 |
{ |
637 |
double ratio = pow(10.0,dB/10.0); |
|
638 |
return ratio; |
|
639 |
} |
|
640 |
||
641 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
642 |
YansWifiPhy::DbmToW (double dBm) const |
1889 | 643 |
{ |
644 |
double mW = pow(10.0,dBm/10.0); |
|
645 |
return mW / 1000.0; |
|
646 |
} |
|
647 |
||
648 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
649 |
YansWifiPhy::WToDbm (double w) const |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
650 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
651 |
return 10.0 * log10(w * 1000.0); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
652 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
653 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
654 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
655 |
YansWifiPhy::RatioToDb (double ratio) const |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
656 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
657 |
return 10.0 * log10(ratio); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
658 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
659 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
660 |
double |
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
661 |
YansWifiPhy::GetEdThresholdW (void) const |
1889 | 662 |
{ |
663 |
return m_edThresholdW; |
|
664 |
} |
|
665 |
||
666 |
Time |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
667 |
YansWifiPhy::GetMaxPacketDuration (void) const |
1889 | 668 |
{ |
669 |
return m_maxPacketDuration; |
|
670 |
} |
|
671 |
||
672 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
673 |
YansWifiPhy::GetPowerDbm (uint8_t power) const |
1889 | 674 |
{ |
1974
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
675 |
NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm); |
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
676 |
NS_ASSERT (m_nTxPower > 0); |
2782
4c813b3ea1c3
tx power shoudl reflect the user-selected power level, not be always the power level zero.
Providence SALUMU MUNGA <Providence.Salumu_Munga@it-sudparis.eu>
parents:
2659
diff
changeset
|
677 |
double dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / m_nTxPower; |
1889 | 678 |
return dbm; |
679 |
} |
|
680 |
||
681 |
||
682 |
void |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
683 |
YansWifiPhy::AppendEvent (Ptr<RxEvent> event) |
1889 | 684 |
{ |
685 |
/* attempt to remove the events which are |
|
686 |
* not useful anymore. |
|
687 |
* i.e.: all events which end _before_ |
|
688 |
* now - m_maxPacketDuration |
|
689 |
*/ |
|
690 |
||
691 |
if (Simulator::Now () > GetMaxPacketDuration ()) |
|
692 |
{ |
|
693 |
Time end = Simulator::Now () - GetMaxPacketDuration (); |
|
694 |
Events::iterator i = m_events.begin (); |
|
695 |
while (i != m_events.end () && |
|
696 |
(*i)->GetEndTime () <= end) |
|
697 |
{ |
|
698 |
i++; |
|
699 |
} |
|
700 |
m_events.erase (m_events.begin (), i); |
|
701 |
} |
|
702 |
m_events.push_back (event); |
|
703 |
} |
|
704 |
||
705 |
||
706 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
707 |
YansWifiPhy::CalculateSnr (double signal, double noiseInterference, WifiMode mode) const |
1889 | 708 |
{ |
709 |
// thermal noise at 290K in J/s = W |
|
710 |
static const double BOLTZMANN = 1.3803e-23; |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
711 |
double Nt = BOLTZMANN * 290.0 * mode.GetBandwidth (); |
1889 | 712 |
// receiver noise Floor (W) |
713 |
double noiseFloor = m_rxNoiseRatio * Nt; |
|
714 |
double noise = noiseFloor + noiseInterference; |
|
715 |
double snr = signal / noise; |
|
716 |
return snr; |
|
717 |
} |
|
718 |
||
719 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
720 |
YansWifiPhy::CalculateNoiseInterferenceW (Ptr<RxEvent> event, NiChanges *ni) const |
1889 | 721 |
{ |
722 |
Events::const_iterator i = m_events.begin (); |
|
723 |
double noiseInterference = 0.0; |
|
724 |
while (i != m_events.end ()) |
|
725 |
{ |
|
726 |
if (event == (*i)) |
|
727 |
{ |
|
728 |
i++; |
|
729 |
continue; |
|
730 |
} |
|
731 |
if (event->Overlaps ((*i)->GetStartTime ())) |
|
732 |
{ |
|
733 |
ni->push_back (NiChange ((*i)->GetStartTime (), (*i)->GetRxPowerW ())); |
|
734 |
} |
|
735 |
if (event->Overlaps ((*i)->GetEndTime ())) |
|
736 |
{ |
|
737 |
ni->push_back (NiChange ((*i)->GetEndTime (), -(*i)->GetRxPowerW ())); |
|
738 |
} |
|
739 |
if ((*i)->Overlaps (event->GetStartTime ())) |
|
740 |
{ |
|
741 |
noiseInterference += (*i)->GetRxPowerW (); |
|
742 |
} |
|
743 |
i++; |
|
744 |
} |
|
745 |
ni->push_back (NiChange (event->GetStartTime (), noiseInterference)); |
|
746 |
ni->push_back (NiChange (event->GetEndTime (), 0)); |
|
747 |
||
748 |
/* quicksort vector of NI changes by time. */ |
|
749 |
std::sort (ni->begin (), ni->end (), std::less<NiChange> ()); |
|
750 |
||
751 |
return noiseInterference; |
|
752 |
} |
|
753 |
||
754 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
755 |
YansWifiPhy::CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode) const |
1889 | 756 |
{ |
757 |
if (duration == NanoSeconds (0)) { |
|
758 |
return 1.0; |
|
759 |
} |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
760 |
uint32_t rate = mode.GetPhyRate (); |
1889 | 761 |
uint64_t nbits = (uint64_t)(rate * duration.GetSeconds ()); |
3902
9e048e073cf0
split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3900
diff
changeset
|
762 |
double csr = m_errorRateModel->GetChunkSuccessRate (mode, snir, (uint32_t)nbits); |
1889 | 763 |
return csr; |
764 |
} |
|
765 |
||
766 |
double |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
767 |
YansWifiPhy::CalculatePer (Ptr<const RxEvent> event, NiChanges *ni) const |
1889 | 768 |
{ |
769 |
double psr = 1.0; /* Packet Success Rate */ |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
770 |
NiChanges::iterator j = ni->begin (); |
1889 | 771 |
Time previous = (*j).GetTime (); |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
772 |
uint64_t plcpPreambleDelayUs; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
773 |
WifiMode payloadMode = event->GetPayloadMode (); |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
774 |
WifiMode headerMode; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
775 |
switch (event->GetPreambleType ()) { |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
776 |
case WIFI_PREAMBLE_LONG: |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
777 |
plcpPreambleDelayUs = m_plcpLongPreambleDelayUs; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
778 |
headerMode = m_longPlcpHeaderMode; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
779 |
break; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
780 |
case WIFI_PREAMBLE_SHORT: |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
781 |
plcpPreambleDelayUs = m_plcpShortPreambleDelayUs; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
782 |
headerMode = m_shortPlcpHeaderMode; |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
783 |
break; |
2077
8ff95ff1ed2e
fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2071
diff
changeset
|
784 |
default: |
8ff95ff1ed2e
fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2071
diff
changeset
|
785 |
NS_ASSERT (false); |
8ff95ff1ed2e
fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2071
diff
changeset
|
786 |
// only to quiet compiler. Really stupid. |
8ff95ff1ed2e
fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2071
diff
changeset
|
787 |
plcpPreambleDelayUs = 0; |
8ff95ff1ed2e
fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2071
diff
changeset
|
788 |
headerMode = m_shortPlcpHeaderMode; |
8ff95ff1ed2e
fix optimized builds
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2071
diff
changeset
|
789 |
break; |
1920
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
790 |
} |
1d4864775cf8
replace header mode with preamble mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1919
diff
changeset
|
791 |
Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (plcpPreambleDelayUs); |
1889 | 792 |
Time plcpPayloadStart = plcpHeaderStart + |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
793 |
Seconds ((m_plcpHeaderLength + 0.0) / headerMode.GetDataRate ()); |
1889 | 794 |
double noiseInterferenceW = (*j).GetDelta (); |
795 |
double powerW = event->GetRxPowerW (); |
|
796 |
||
797 |
j++; |
|
798 |
while (ni->end () != j) |
|
799 |
{ |
|
800 |
Time current = (*j).GetTime (); |
|
1974
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
801 |
NS_ASSERT (current >= previous); |
1889 | 802 |
|
803 |
if (previous >= plcpPayloadStart) |
|
804 |
{ |
|
805 |
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
806 |
noiseInterferenceW, |
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
807 |
payloadMode), |
1889 | 808 |
current - previous, |
809 |
payloadMode); |
|
810 |
} |
|
811 |
else if (previous >= plcpHeaderStart) |
|
812 |
{ |
|
813 |
if (current >= plcpPayloadStart) |
|
814 |
{ |
|
815 |
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
816 |
noiseInterferenceW, |
|
817 |
headerMode), |
|
818 |
plcpPayloadStart - previous, |
|
819 |
headerMode); |
|
820 |
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
821 |
noiseInterferenceW, |
|
822 |
payloadMode), |
|
823 |
current - plcpPayloadStart, |
|
824 |
payloadMode); |
|
825 |
} |
|
826 |
else |
|
827 |
{ |
|
1974
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
828 |
NS_ASSERT (current >= plcpHeaderStart); |
1889 | 829 |
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
830 |
noiseInterferenceW, |
|
831 |
headerMode), |
|
832 |
current - previous, |
|
833 |
headerMode); |
|
834 |
} |
|
835 |
} |
|
836 |
else |
|
837 |
{ |
|
838 |
if (current >= plcpPayloadStart) |
|
839 |
{ |
|
840 |
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
841 |
noiseInterferenceW, |
|
842 |
headerMode), |
|
843 |
plcpPayloadStart - plcpHeaderStart, |
|
844 |
headerMode); |
|
845 |
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
846 |
noiseInterferenceW, |
|
847 |
payloadMode), |
|
848 |
current - plcpPayloadStart, |
|
849 |
payloadMode); |
|
850 |
} |
|
851 |
else if (current >= plcpHeaderStart) |
|
852 |
{ |
|
853 |
psr *= CalculateChunkSuccessRate (CalculateSnr (powerW, |
|
854 |
noiseInterferenceW, |
|
855 |
headerMode), |
|
856 |
current - plcpHeaderStart, |
|
857 |
headerMode); |
|
858 |
} |
|
859 |
} |
|
860 |
||
861 |
noiseInterferenceW += (*j).GetDelta (); |
|
862 |
previous = (*j).GetTime (); |
|
863 |
j++; |
|
864 |
} |
|
865 |
||
866 |
double per = 1 - psr; |
|
867 |
return per; |
|
868 |
} |
|
869 |
||
870 |
||
871 |
void |
|
3888
a15618dcd0eb
rename WifiPhy to YansWifiPhy and add WifiPhy abstract base class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3882
diff
changeset
|
872 |
YansWifiPhy::EndSync (Ptr<Packet> packet, Ptr<RxEvent> event) |
1889 | 873 |
{ |
2985
fa0747c4ad5e
use function logging macros
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2782
diff
changeset
|
874 |
NS_LOG_FUNCTION (this << packet << event); |
1974
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
875 |
NS_ASSERT (IsStateSync ()); |
0d6b3bead74a
replace cassert by ns3/assert.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
876 |
NS_ASSERT (event->GetEndTime () == Simulator::Now ()); |
1889 | 877 |
|
878 |
NiChanges ni; |
|
879 |
double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni); |
|
880 |
double snr = CalculateSnr (event->GetRxPowerW (), |
|
881 |
noiseInterferenceW, |
|
1891
add6fb8761f3
use WifiMode rather than TransmissionMode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1890
diff
changeset
|
882 |
event->GetPayloadMode ()); |
1889 | 883 |
|
884 |
/* calculate the SNIR at the start of the packet and accumulate |
|
885 |
* all SNIR changes in the snir vector. |
|
886 |
*/ |
|
887 |
double per = CalculatePer (event, &ni); |
|
2164
6e347fdbfa4a
avoid confusion between code and uncoded rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2159
diff
changeset
|
888 |
NS_LOG_DEBUG ("mode="<<(event->GetPayloadMode ().GetDataRate ())<< |
3902
9e048e073cf0
split the error rate model from the yans phy
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3900
diff
changeset
|
889 |
", ber="<<(1-m_errorRateModel->GetChunkSuccessRate (event->GetPayloadMode (), snr, 1))<< |
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2155
diff
changeset
|
890 |
", snr="<<snr<<", per="<<per<<", size="<<packet->GetSize ()); |
1889 | 891 |
|
892 |
if (m_random.GetValue () > per) |
|
893 |
{ |
|
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
894 |
m_state->SwitchFromSyncEndOk (packet, snr, event->GetPayloadMode (), event->GetPreambleType ()); |
1889 | 895 |
} |
896 |
else |
|
897 |
{ |
|
898 |
/* failure. */ |
|
3900
1687492ff059
re-enable tracing of wifi phy state.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3897
diff
changeset
|
899 |
m_state->SwitchFromSyncEndError (packet, snr); |
1889 | 900 |
} |
901 |
} |
|
902 |
||
903 |
||
904 |
||
905 |
||
1977
4303409f3d8e
remove uneeded trailing ';'
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1974
diff
changeset
|
906 |
} // namespace ns3 |