22 #include "wifi-phy.h" |
22 #include "wifi-phy.h" |
23 #include "wifi-mode.h" |
23 #include "wifi-mode.h" |
24 #include "wifi-channel.h" |
24 #include "wifi-channel.h" |
25 #include "wifi-net-device.h" |
25 #include "wifi-net-device.h" |
26 #include "wifi-preamble.h" |
26 #include "wifi-preamble.h" |
|
27 #include "wifi-default-parameters.h" |
27 #include "ns3/simulator.h" |
28 #include "ns3/simulator.h" |
28 #include "ns3/packet.h" |
29 #include "ns3/packet.h" |
29 #include "ns3/random-variable.h" |
30 #include "ns3/random-variable.h" |
30 |
31 |
31 #include <cassert> |
32 #include <cassert> |
196 /**************************************************************** |
197 /**************************************************************** |
197 * The actual WifiPhy class |
198 * The actual WifiPhy class |
198 ****************************************************************/ |
199 ****************************************************************/ |
199 |
200 |
200 WifiPhy::WifiPhy (Ptr<WifiNetDevice> device) |
201 WifiPhy::WifiPhy (Ptr<WifiNetDevice> device) |
201 : m_edThresholdW (DbmToW (-140)), |
202 : m_edThresholdW (DbmToW (WifiDefaultParameters::GetPhyEnergyDetectionThresholdDbm ())), |
202 m_txGainDbm (1.0), |
203 m_txGainDbm (WifiDefaultParameters::GetPhyTxGainDbm ()), |
203 m_rxGainDbm (1.0), |
204 m_rxGainDbm (WifiDefaultParameters::GetPhyRxGainDbm ()), |
204 m_rxNoiseRatio (DbToRatio (7)), |
205 m_rxNoiseRatio (DbToRatio (WifiDefaultParameters::GetPhyRxNoiseDb ())), |
205 m_txPowerBaseDbm (16.0206), |
206 m_txPowerBaseDbm (WifiDefaultParameters::GetPhyTxPowerBaseDbm ()), |
206 m_txPowerEndDbm (16.0206), |
207 m_txPowerEndDbm (WifiDefaultParameters::GetPhyTxPowerEndDbm ()), |
207 m_nTxPower (1), |
208 m_nTxPower (WifiDefaultParameters::GetPhyTxPowerLevels ()), |
208 m_syncing (false), |
209 m_syncing (false), |
209 m_endTx (Seconds (0)), |
210 m_endTx (Seconds (0)), |
210 m_endSync (Seconds (0)), |
211 m_endSync (Seconds (0)), |
211 m_endCcaBusy (Seconds (0)), |
212 m_endCcaBusy (Seconds (0)), |
212 m_startTx (Seconds (0)), |
213 m_startTx (Seconds (0)), |
355 NotifyTxStart (txDuration); |
359 NotifyTxStart (txDuration); |
356 SwitchToTx (txDuration); |
360 SwitchToTx (txDuration); |
357 m_channel->Send (m_device, packet, GetPowerDbm (txPower) + m_txGainDbm, txMode, preamble); |
361 m_channel->Send (m_device, packet, GetPowerDbm (txPower) + m_txGainDbm, txMode, preamble); |
358 } |
362 } |
359 |
363 |
360 void |
|
361 WifiPhy::SetEdThresholdDbm (double edThreshold) |
|
362 { |
|
363 m_edThresholdW = DbmToW (edThreshold); |
|
364 } |
|
365 void |
|
366 WifiPhy::SetRxNoiseDb (double rxNoise) |
|
367 { |
|
368 m_rxNoiseRatio = DbToRatio (rxNoise); |
|
369 } |
|
370 void |
|
371 WifiPhy::SetTxPowerIncrementsDbm (double txPowerBase, |
|
372 double txPowerEnd, |
|
373 int nTxPower) |
|
374 { |
|
375 m_txPowerBaseDbm = txPowerBase; |
|
376 m_txPowerEndDbm = txPowerEnd; |
|
377 m_nTxPower = nTxPower; |
|
378 } |
|
379 void |
|
380 WifiPhy::SetRxTxGainDbm (double rxGainDbm, double txGainDbm) |
|
381 { |
|
382 m_rxGainDbm = rxGainDbm; |
|
383 m_txGainDbm = txGainDbm; |
|
384 } |
|
385 uint32_t |
364 uint32_t |
386 WifiPhy::GetNModes (void) const |
365 WifiPhy::GetNModes (void) const |
387 { |
366 { |
388 return m_modes.size (); |
367 return m_modes.size (); |
389 } |
368 } |