256 m_startSync (Seconds (0)), |
256 m_startSync (Seconds (0)), |
257 m_startCcaBusy (Seconds (0)), |
257 m_startCcaBusy (Seconds (0)), |
258 m_previousStateChangeTime (Seconds (0)), |
258 m_previousStateChangeTime (Seconds (0)), |
259 m_endSyncEvent (), |
259 m_endSyncEvent (), |
260 m_random (0.0, 1.0) |
260 m_random (0.0, 1.0) |
261 {} |
261 { |
|
262 NS_LOG_FUNCTION (this); |
|
263 } |
262 |
264 |
263 WifiPhy::~WifiPhy () |
265 WifiPhy::~WifiPhy () |
264 {} |
266 { |
|
267 NS_LOG_FUNCTION (this); |
|
268 } |
265 |
269 |
266 void |
270 void |
267 WifiPhy::DoDispose (void) |
271 WifiPhy::DoDispose (void) |
268 { |
272 { |
|
273 NS_LOG_FUNCTION (this); |
269 m_channel = 0; |
274 m_channel = 0; |
270 m_events.clear (); |
275 m_events.clear (); |
271 m_modes.clear (); |
276 m_modes.clear (); |
272 } |
277 } |
273 |
278 |
274 void |
279 void |
275 WifiPhy::SetStandard (enum WifiPhyStandard standard) |
280 WifiPhy::SetStandard (enum WifiPhyStandard standard) |
276 { |
281 { |
|
282 NS_LOG_FUNCTION (this << standard); |
277 m_standard = standard; |
283 m_standard = standard; |
278 switch (standard) { |
284 switch (standard) { |
279 case WIFI_PHY_STANDARD_80211a: |
285 case WIFI_PHY_STANDARD_80211a: |
280 Configure80211a (); |
286 Configure80211a (); |
281 break; |
287 break; |
290 |
296 |
291 |
297 |
292 void |
298 void |
293 WifiPhy::SetRxNoise (double db) |
299 WifiPhy::SetRxNoise (double db) |
294 { |
300 { |
|
301 NS_LOG_FUNCTION (this << db); |
295 m_rxNoiseRatio = DbToRatio (db); |
302 m_rxNoiseRatio = DbToRatio (db); |
296 } |
303 } |
297 void |
304 void |
298 WifiPhy::SetTxPowerStart (double start) |
305 WifiPhy::SetTxPowerStart (double start) |
299 { |
306 { |
|
307 NS_LOG_FUNCTION (this << start); |
300 m_txPowerBaseDbm = start; |
308 m_txPowerBaseDbm = start; |
301 } |
309 } |
302 void |
310 void |
303 WifiPhy::SetTxPowerEnd (double end) |
311 WifiPhy::SetTxPowerEnd (double end) |
304 { |
312 { |
|
313 NS_LOG_FUNCTION (this << end); |
305 m_txPowerEndDbm = end; |
314 m_txPowerEndDbm = end; |
306 } |
315 } |
307 void |
316 void |
308 WifiPhy::SetNTxPower (uint32_t n) |
317 WifiPhy::SetNTxPower (uint32_t n) |
309 { |
318 { |
|
319 NS_LOG_FUNCTION (this << n); |
310 m_nTxPower = n; |
320 m_nTxPower = n; |
311 } |
321 } |
312 void |
322 void |
313 WifiPhy::SetTxGain (double gain) |
323 WifiPhy::SetTxGain (double gain) |
314 { |
324 { |
|
325 NS_LOG_FUNCTION (this << gain); |
315 m_txGainDb = gain; |
326 m_txGainDb = gain; |
316 } |
327 } |
317 void |
328 void |
318 WifiPhy::SetRxGain (double gain) |
329 WifiPhy::SetRxGain (double gain) |
319 { |
330 { |
|
331 NS_LOG_FUNCTION (this << gain); |
320 m_rxGainDb = gain; |
332 m_rxGainDb = gain; |
321 } |
333 } |
322 void |
334 void |
323 WifiPhy::SetEdThreshold (double threshold) |
335 WifiPhy::SetEdThreshold (double threshold) |
324 { |
336 { |
|
337 NS_LOG_FUNCTION (this << threshold); |
325 m_edThresholdW = DbmToW (threshold); |
338 m_edThresholdW = DbmToW (threshold); |
326 } |
339 } |
327 double |
340 double |
328 WifiPhy::GetRxNoise (void) const |
341 WifiPhy::GetRxNoise (void) const |
329 { |
342 { |
382 WifiPhy::StartReceivePacket (Ptr<Packet> packet, |
395 WifiPhy::StartReceivePacket (Ptr<Packet> packet, |
383 double rxPowerDbm, |
396 double rxPowerDbm, |
384 WifiMode txMode, |
397 WifiMode txMode, |
385 enum WifiPreamble preamble) |
398 enum WifiPreamble preamble) |
386 { |
399 { |
|
400 NS_LOG_FUNCTION (this << packet << rxPowerDbm << txMode << preamble); |
387 rxPowerDbm += m_rxGainDb; |
401 rxPowerDbm += m_rxGainDb; |
388 double rxPowerW = DbmToW (rxPowerDbm); |
402 double rxPowerW = DbmToW (rxPowerDbm); |
389 Time rxDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); |
403 Time rxDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); |
390 Time endRx = Simulator::Now () + rxDuration; |
404 Time endRx = Simulator::Now () + rxDuration; |
391 |
405 |
470 |
484 |
471 } |
485 } |
472 void |
486 void |
473 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower) |
487 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower) |
474 { |
488 { |
|
489 NS_LOG_FUNCTION (this << packet << txMode << preamble << txPower); |
475 /* Transmission can happen if: |
490 /* Transmission can happen if: |
476 * - we are syncing on a packet. It is the responsability of the |
491 * - we are syncing on a packet. It is the responsability of the |
477 * MAC layer to avoid doing this but the PHY does nothing to |
492 * MAC layer to avoid doing this but the PHY does nothing to |
478 * prevent it. |
493 * prevent it. |
479 * - we are idle |
494 * - we are idle |
527 } |
542 } |
528 |
543 |
529 void |
544 void |
530 WifiPhy::Configure80211aParameters (void) |
545 WifiPhy::Configure80211aParameters (void) |
531 { |
546 { |
|
547 NS_LOG_FUNCTION (this); |
532 m_plcpLongPreambleDelayUs = 16; |
548 m_plcpLongPreambleDelayUs = 16; |
533 m_plcpShortPreambleDelayUs = 16; |
549 m_plcpShortPreambleDelayUs = 16; |
534 m_longPlcpHeaderMode = g_6mba; |
550 m_longPlcpHeaderMode = g_6mba; |
535 m_shortPlcpHeaderMode = g_6mba; |
551 m_shortPlcpHeaderMode = g_6mba; |
536 m_plcpHeaderLength = 4 + 1 + 12 + 1 + 6; |
552 m_plcpHeaderLength = 4 + 1 + 12 + 1 + 6; |
556 } |
572 } |
557 |
573 |
558 void |
574 void |
559 WifiPhy::Configure80211a (void) |
575 WifiPhy::Configure80211a (void) |
560 { |
576 { |
|
577 NS_LOG_FUNCTION (this); |
561 Configure80211aParameters (); |
578 Configure80211aParameters (); |
562 m_modes.push_back (g_6mba); |
579 m_modes.push_back (g_6mba); |
563 m_modes.push_back (g_9mba); |
580 m_modes.push_back (g_9mba); |
564 m_modes.push_back (g_12mba); |
581 m_modes.push_back (g_12mba); |
565 m_modes.push_back (g_18mba); |
582 m_modes.push_back (g_18mba); |
572 } |
589 } |
573 |
590 |
574 void |
591 void |
575 WifiPhy::ConfigureHolland (void) |
592 WifiPhy::ConfigureHolland (void) |
576 { |
593 { |
|
594 NS_LOG_FUNCTION (this); |
577 Configure80211aParameters (); |
595 Configure80211aParameters (); |
578 m_modes.push_back (g_6mba); |
596 m_modes.push_back (g_6mba); |
579 m_modes.push_back (g_12mba); |
597 m_modes.push_back (g_12mba); |
580 m_modes.push_back (g_18mba); |
598 m_modes.push_back (g_18mba); |
581 m_modes.push_back (g_36mba); |
599 m_modes.push_back (g_36mba); |
1327 |
1345 |
1328 |
1346 |
1329 void |
1347 void |
1330 WifiPhy::EndSync (Ptr<Packet> packet, Ptr<RxEvent> event) |
1348 WifiPhy::EndSync (Ptr<Packet> packet, Ptr<RxEvent> event) |
1331 { |
1349 { |
|
1350 NS_LOG_FUNCTION (this << packet << event); |
1332 NS_ASSERT (IsStateSync ()); |
1351 NS_ASSERT (IsStateSync ()); |
1333 NS_ASSERT (event->GetEndTime () == Simulator::Now ()); |
1352 NS_ASSERT (event->GetEndTime () == Simulator::Now ()); |
1334 |
1353 |
1335 NiChanges ni; |
1354 NiChanges ni; |
1336 double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni); |
1355 double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni); |