|
|
| 174 |
MakeUintegerAccessor (&WifiPhy::SetChannelNumber, |
174 |
MakeUintegerAccessor (&WifiPhy::SetChannelNumber, |
| 175 |
&WifiPhy::GetChannelNumber), |
175 |
&WifiPhy::GetChannelNumber), |
| 176 |
MakeUintegerChecker<uint8_t> (0, 196)) |
176 |
MakeUintegerChecker<uint8_t> (0, 196)) |
| 177 |
.AddAttribute ("EnergyDetectionThreshold", |
177 |
.AddAttribute ("SignalDetectionThreshold", |
| 178 |
"The energy of a received signal should be higher than " |
178 |
"The energy of a received signal should be higher than " |
| 179 |
"this threshold (dbm) to allow the PHY layer to detect the signal.", |
179 |
"this threshold (dbm) to allow the PHY layer to detect the signal.", |
| 180 |
DoubleValue (-96.0), |
180 |
DoubleValue (-91.0), |
| 181 |
MakeDoubleAccessor (&WifiPhy::SetEdThreshold, |
181 |
MakeDoubleAccessor (&WifiPhy::SetSignalDetectionThreshold, |
| 182 |
&WifiPhy::GetEdThreshold), |
182 |
&WifiPhy::GetSignalDetectionThreshold), |
| 183 |
MakeDoubleChecker<double> ()) |
183 |
MakeDoubleChecker<double> ()) |
| 184 |
.AddAttribute ("CcaMode1Threshold", |
184 |
.AddAttribute ("CcaMode1Threshold", |
| 185 |
"The energy of a received signal should be higher than " |
185 |
"The energy of a received signal should be higher than " |
| 186 |
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.", |
186 |
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.", |
| 187 |
DoubleValue (-99.0), |
187 |
DoubleValue (-62.0), |
| 188 |
MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold, |
188 |
MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold, |
| 189 |
&WifiPhy::GetCcaMode1Threshold), |
189 |
&WifiPhy::GetCcaMode1Threshold), |
| 190 |
MakeDoubleChecker<double> ()) |
190 |
MakeDoubleChecker<double> ()) |
|
|
191 |
.AddAttribute ("SensitivityThreshold", |
| 192 |
"The energy of a received signal should be higher than " |
| 193 |
"this threshold (dbm) to allow the PHY layer to accept this signal.", |
| 194 |
DoubleValue (-101.0), |
| 195 |
MakeDoubleAccessor (&WifiPhy::SetSensitivityThreshold, |
| 196 |
&WifiPhy::GetSensitivityThreshold), |
| 197 |
MakeDoubleChecker<double> ()) |
| 191 |
.AddAttribute ("TxGain", |
198 |
.AddAttribute ("TxGain", |
| 192 |
"Transmission gain (dB).", |
199 |
"Transmission gain (dB).", |
| 193 |
DoubleValue (0.0), |
200 |
DoubleValue (0.0), |
|
|
| 469 |
} |
476 |
} |
| 470 |
|
477 |
|
| 471 |
void |
478 |
void |
| 472 |
WifiPhy::SetEdThreshold (double threshold) |
479 |
WifiPhy::SetSignalDetectionThreshold (double threshold) |
| 473 |
{ |
480 |
{ |
| 474 |
NS_LOG_FUNCTION (this << threshold); |
481 |
NS_LOG_FUNCTION (this << threshold); |
| 475 |
m_edThresholdW = DbmToW (threshold); |
482 |
m_signalDetectionThresholdW = DbmToW (threshold); |
| 476 |
} |
483 |
} |
| 477 |
|
484 |
|
| 478 |
double |
485 |
double |
| 479 |
WifiPhy::GetEdThresholdW (void) const |
486 |
WifiPhy::GetSignalDetectionThresholdW (void) const |
| 480 |
{ |
487 |
{ |
| 481 |
return m_edThresholdW; |
488 |
return m_signalDetectionThresholdW; |
| 482 |
} |
489 |
} |
| 483 |
|
490 |
|
| 484 |
double |
491 |
double |
| 485 |
WifiPhy::GetEdThreshold (void) const |
492 |
WifiPhy::GetSignalDetectionThreshold (void) const |
| 486 |
{ |
493 |
{ |
| 487 |
return WToDbm (m_edThresholdW); |
494 |
return WToDbm (m_signalDetectionThresholdW); |
| 488 |
} |
495 |
} |
| 489 |
|
496 |
|
| 490 |
void |
497 |
void |
|
|
| 501 |
} |
508 |
} |
| 502 |
|
509 |
|
| 503 |
void |
510 |
void |
|
|
511 |
WifiPhy::SetSensitivityThreshold (double threshold) |
| 512 |
{ |
| 513 |
NS_LOG_FUNCTION (this << threshold); |
| 514 |
m_sensitivityThresholdW = DbmToW (threshold); |
| 515 |
} |
| 516 |
|
| 517 |
double |
| 518 |
WifiPhy::GetSensitivityThreshold (void) const |
| 519 |
{ |
| 520 |
return WToDbm (m_sensitivityThresholdW); |
| 521 |
} |
| 522 |
|
| 523 |
void |
| 504 |
WifiPhy::SetRxNoiseFigure (double noiseFigureDb) |
524 |
WifiPhy::SetRxNoiseFigure (double noiseFigureDb) |
| 505 |
{ |
525 |
{ |
| 506 |
NS_LOG_FUNCTION (this << noiseFigureDb); |
526 |
NS_LOG_FUNCTION (this << noiseFigureDb); |
|
|
| 1278 |
NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value"); |
1298 |
NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value"); |
| 1279 |
m_channelWidth = channelwidth; |
1299 |
m_channelWidth = channelwidth; |
| 1280 |
AddSupportedChannelWidth (channelwidth); |
1300 |
AddSupportedChannelWidth (channelwidth); |
|
|
1301 |
if (GetCcaMode1Threshold () == 0) |
| 1302 |
{ |
| 1303 |
//todo: what if channel width has changed but we already set CCAMode1 threshold value? |
| 1304 |
switch (channelwidth) |
| 1305 |
{ |
| 1306 |
case 5: |
| 1307 |
SetCcaMode1Threshold (-68); |
| 1308 |
break; |
| 1309 |
case 10: |
| 1310 |
SetCcaMode1Threshold (-65); |
| 1311 |
break; |
| 1312 |
case 20: |
| 1313 |
default: |
| 1314 |
SetCcaMode1Threshold (-62); |
| 1315 |
break; |
| 1316 |
//todo: other cases (DSSS, channel bonding, ...) |
| 1317 |
} |
| 1318 |
} |
| 1281 |
} |
1319 |
} |
| 1282 |
|
1320 |
|
| 1283 |
uint8_t |
1321 |
uint8_t |
|
|
| 2452 |
//This function should be later split to check separately whether plcp preamble and plcp header can be successfully received. |
2490 |
//This function should be later split to check separately whether plcp preamble and plcp header can be successfully received. |
| 2453 |
//Note: plcp preamble reception is not yet modeled. |
2491 |
//Note: plcp preamble reception is not yet modeled. |
| 2454 |
NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); |
2492 |
NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration); |
|
|
2493 |
|
| 2494 |
if (WToDbm (rxPowerW) < GetSensitivityThreshold ()) |
| 2495 |
{ |
| 2496 |
//ignore this signal |
| 2497 |
NS_LOG_DEBUG ("Signal power received is below the sensitivity threshold: ignore this signal!"); |
| 2498 |
return; |
| 2499 |
} |
| 2500 |
|
| 2455 |
AmpduTag ampduTag; |
2501 |
AmpduTag ampduTag; |
| 2456 |
Time endRx = Simulator::Now () + rxDuration; |
2502 |
Time endRx = Simulator::Now () + rxDuration; |
| 2457 |
|
2503 |
|
|
|
| 2531 |
break; |
2577 |
break; |
| 2532 |
case WifiPhy::CCA_BUSY: |
2578 |
case WifiPhy::CCA_BUSY: |
| 2533 |
case WifiPhy::IDLE: |
2579 |
case WifiPhy::IDLE: |
| 2534 |
if (rxPowerW > GetEdThresholdW ()) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration) |
2580 |
if (rxPowerW > GetSignalDetectionThresholdW ()) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration) |
| 2535 |
{ |
2581 |
{ |
| 2536 |
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) |
2582 |
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) |
| 2537 |
{ |
2583 |
{ |
|
|
| 2592 |
else |
2638 |
else |
| 2593 |
{ |
2639 |
{ |
| 2594 |
NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
2640 |
NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
| 2595 |
rxPowerW << "<" << GetEdThresholdW () << ")"); |
2641 |
rxPowerW << "<" << GetSignalDetectionThresholdW () << ")"); |
| 2596 |
NotifyRxDrop (packet); |
2642 |
NotifyRxDrop (packet); |
| 2597 |
m_plcpSuccess = false; |
2643 |
m_plcpSuccess = false; |
| 2598 |
goto maybeCcaBusy; |
2644 |
goto maybeCcaBusy; |