|
Lines 178-195
WifiPhy::GetTypeId (void)
|
Link Here
|
|---|
|
| 178 |
MakeUintegerAccessor (&WifiPhy::SetChannelNumber, |
178 |
MakeUintegerAccessor (&WifiPhy::SetChannelNumber, |
| 179 |
&WifiPhy::GetChannelNumber), |
179 |
&WifiPhy::GetChannelNumber), |
| 180 |
MakeUintegerChecker<uint8_t> (0, 196)) |
180 |
MakeUintegerChecker<uint8_t> (0, 196)) |
| 181 |
.AddAttribute ("EnergyDetectionThreshold", |
181 |
.AddAttribute ("RxSensitivity", |
| 182 |
"The energy of a received signal should be higher than " |
182 |
"The energy of a received signal should be higher than " |
| 183 |
"this threshold (dbm) to allow the PHY layer to detect the signal.", |
183 |
"this threshold (dBm) for the PHY to detect the signal.", |
| 184 |
DoubleValue (-96.0), |
184 |
DoubleValue (-101.0), |
| 185 |
MakeDoubleAccessor (&WifiPhy::SetEdThreshold), |
185 |
MakeDoubleAccessor (&WifiPhy::SetRxSensitivity, |
|
|
186 |
&WifiPhy::GetRxSensitivity), |
| 186 |
MakeDoubleChecker<double> ()) |
187 |
MakeDoubleChecker<double> ()) |
| 187 |
.AddAttribute ("CcaMode1Threshold", |
188 |
.AddAttribute ("CcaEdThreshold", |
| 188 |
"The energy of a received signal should be higher than " |
189 |
"The energy of a received signal should be higher than " |
| 189 |
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.", |
190 |
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.", |
| 190 |
DoubleValue (-99.0), |
191 |
DoubleValue (-62.0), |
| 191 |
MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold, |
192 |
MakeDoubleAccessor (&WifiPhy::SetCcaEdThreshold, |
| 192 |
&WifiPhy::GetCcaMode1Threshold), |
193 |
&WifiPhy::GetCcaEdThreshold), |
| 193 |
MakeDoubleChecker<double> ()) |
194 |
MakeDoubleChecker<double> ()) |
| 194 |
.AddAttribute ("TxGain", |
195 |
.AddAttribute ("TxGain", |
| 195 |
"Transmission gain (dB).", |
196 |
"Transmission gain (dB).", |
|
Lines 463-491
WifiPhy::InitializeFrequencyChannelNumber (void)
|
Link Here
|
|---|
|
| 463 |
} |
464 |
} |
| 464 |
|
465 |
|
| 465 |
void |
466 |
void |
| 466 |
WifiPhy::SetEdThreshold (double threshold) |
467 |
WifiPhy::SetRxSensitivity (double threshold) |
| 467 |
{ |
468 |
{ |
| 468 |
NS_LOG_FUNCTION (this << threshold); |
469 |
NS_LOG_FUNCTION (this << threshold); |
| 469 |
m_edThresholdW = DbmToW (threshold); |
470 |
m_rxSensitivityW = DbmToW (threshold); |
| 470 |
} |
471 |
} |
| 471 |
|
472 |
|
| 472 |
double |
473 |
double |
| 473 |
WifiPhy::GetEdThreshold (void) const |
474 |
WifiPhy::GetRxSensitivity (void) const |
| 474 |
{ |
475 |
{ |
| 475 |
return WToDbm (m_edThresholdW); |
476 |
return WToDbm (m_rxSensitivityW); |
| 476 |
} |
477 |
} |
| 477 |
|
478 |
|
| 478 |
void |
479 |
void |
| 479 |
WifiPhy::SetCcaMode1Threshold (double threshold) |
480 |
WifiPhy::SetCcaEdThreshold (double threshold) |
| 480 |
{ |
481 |
{ |
| 481 |
NS_LOG_FUNCTION (this << threshold); |
482 |
NS_LOG_FUNCTION (this << threshold); |
| 482 |
m_ccaMode1ThresholdW = DbmToW (threshold); |
483 |
m_ccaEdThresholdW = DbmToW (threshold); |
| 483 |
} |
484 |
} |
| 484 |
|
485 |
|
| 485 |
double |
486 |
double |
| 486 |
WifiPhy::GetCcaMode1Threshold (void) const |
487 |
WifiPhy::GetCcaEdThreshold (void) const |
| 487 |
{ |
488 |
{ |
| 488 |
return WToDbm (m_ccaMode1ThresholdW); |
489 |
return WToDbm (m_ccaEdThresholdW); |
| 489 |
} |
490 |
} |
| 490 |
|
491 |
|
| 491 |
void |
492 |
void |
|
Lines 1627-1633
WifiPhy::ResumeFromSleep (void)
|
Link Here
|
|---|
|
| 1627 |
case WifiPhyState::SLEEP: |
1628 |
case WifiPhyState::SLEEP: |
| 1628 |
{ |
1629 |
{ |
| 1629 |
NS_LOG_DEBUG ("resuming from sleep mode"); |
1630 |
NS_LOG_DEBUG ("resuming from sleep mode"); |
| 1630 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaMode1ThresholdW); |
1631 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaEdThresholdW); |
| 1631 |
m_state->SwitchFromSleep (delayUntilCcaEnd); |
1632 |
m_state->SwitchFromSleep (delayUntilCcaEnd); |
| 1632 |
break; |
1633 |
break; |
| 1633 |
} |
1634 |
} |
|
Lines 1658-1664
WifiPhy::ResumeFromOff (void)
|
Link Here
|
|---|
|
| 1658 |
case WifiPhyState::OFF: |
1659 |
case WifiPhyState::OFF: |
| 1659 |
{ |
1660 |
{ |
| 1660 |
NS_LOG_DEBUG ("resuming from off mode"); |
1661 |
NS_LOG_DEBUG ("resuming from off mode"); |
| 1661 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1Threshold ())); |
1662 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaEdThreshold ())); |
| 1662 |
m_state->SwitchFromOff (delayUntilCcaEnd); |
1663 |
m_state->SwitchFromOff (delayUntilCcaEnd); |
| 1663 |
break; |
1664 |
break; |
| 1664 |
} |
1665 |
} |
|
Lines 2526-2532
WifiPhy::MaybeCcaBusyDuration ()
|
Link Here
|
|---|
|
| 2526 |
//In this model, CCA becomes busy when the aggregation of all signals as |
2527 |
//In this model, CCA becomes busy when the aggregation of all signals as |
| 2527 |
//tracked by the InterferenceHelper class is higher than the CcaBusyThreshold |
2528 |
//tracked by the InterferenceHelper class is higher than the CcaBusyThreshold |
| 2528 |
|
2529 |
|
| 2529 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1Threshold ())); |
2530 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaEdThreshold ())); |
| 2530 |
if (!delayUntilCcaEnd.IsZero ()) |
2531 |
if (!delayUntilCcaEnd.IsZero ()) |
| 2531 |
{ |
2532 |
{ |
| 2532 |
m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); |
2533 |
m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd); |
|
Lines 3622-3628
WifiPhy::SwitchMaybeToCcaBusy (void)
|
Link Here
|
|---|
|
| 3622 |
//In this model, CCA becomes busy when the aggregation of all signals as |
3623 |
//In this model, CCA becomes busy when the aggregation of all signals as |
| 3623 |
//tracked by the InterferenceHelper class is higher than the CcaBusyThreshold |
3624 |
//tracked by the InterferenceHelper class is higher than the CcaBusyThreshold |
| 3624 |
|
3625 |
|
| 3625 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaMode1Threshold ())); |
3626 |
Time delayUntilCcaEnd = m_interference.GetEnergyDuration (DbmToW (GetCcaEdThreshold ())); |
| 3626 |
if (!delayUntilCcaEnd.IsZero ()) |
3627 |
if (!delayUntilCcaEnd.IsZero ()) |
| 3627 |
{ |
3628 |
{ |
| 3628 |
NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S)); |
3629 |
NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S)); |
|
|
| 3652 |
WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event) |
3653 |
WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event) |
| 3653 |
{ |
3654 |
{ |
| 3654 |
NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration); |
3655 |
NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration); |
| 3655 |
if (rxPowerW > m_edThresholdW) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration) |
3656 |
|
|
|
3657 |
AmpduTag ampduTag; |
| 3658 |
WifiPreamble preamble = txVector.GetPreambleType (); |
| 3659 |
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) |
| 3656 |
{ |
3660 |
{ |
| 3657 |
AmpduTag ampduTag; |
3661 |
m_plcpSuccess = false; |
| 3658 |
WifiPreamble preamble = txVector.GetPreambleType (); |
3662 |
m_mpdusNum = 0; |
| 3659 |
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) |
3663 |
NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received"); |
| 3660 |
{ |
3664 |
NotifyRxDrop (packet); |
| 3661 |
m_plcpSuccess = false; |
3665 |
MaybeCcaBusyDuration (); |
| 3662 |
m_mpdusNum = 0; |
3666 |
return; |
| 3663 |
NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received"); |
3667 |
} |
| 3664 |
NotifyRxDrop (packet); |
3668 |
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0) |
| 3665 |
MaybeCcaBusyDuration (); |
3669 |
{ |
| 3666 |
return; |
3670 |
//received the first MPDU in an MPDU |
| 3667 |
} |
3671 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
| 3668 |
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0) |
3672 |
m_rxMpduReferenceNumber++; |
| 3669 |
{ |
3673 |
} |
| 3670 |
//received the first MPDU in an MPDU |
3674 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 3671 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
3675 |
{ |
| 3672 |
m_rxMpduReferenceNumber++; |
3676 |
//received the other MPDUs that are part of the A-MPDU |
| 3673 |
} |
3677 |
if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1)) |
| 3674 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
|
|
| 3675 |
{ |
| 3676 |
//received the other MPDUs that are part of the A-MPDU |
| 3677 |
if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1)) |
| 3678 |
{ |
| 3679 |
NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ()); |
| 3680 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
| 3681 |
} |
| 3682 |
else |
| 3683 |
{ |
| 3684 |
m_mpdusNum--; |
| 3685 |
} |
| 3686 |
} |
| 3687 |
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 3688 |
{ |
3678 |
{ |
| 3689 |
NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost"); |
3679 |
NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ()); |
| 3690 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
3680 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
| 3691 |
} |
3681 |
} |
| 3692 |
else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 ) |
3682 |
else |
| 3693 |
{ |
3683 |
{ |
| 3694 |
NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum); |
3684 |
m_mpdusNum--; |
| 3695 |
m_mpdusNum = 0; |
|
|
| 3696 |
} |
3685 |
} |
|
|
3686 |
} |
| 3687 |
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 3688 |
{ |
| 3689 |
NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost"); |
| 3690 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
| 3691 |
} |
| 3692 |
else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 ) |
| 3693 |
{ |
| 3694 |
NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum); |
| 3695 |
m_mpdusNum = 0; |
| 3696 |
} |
| 3697 |
|
3697 |
|
| 3698 |
NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)"); |
3698 |
NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)"); |
| 3699 |
m_currentEvent = event; |
3699 |
m_currentEvent = event; |
| 3700 |
m_state->SwitchToRx (rxDuration); |
3700 |
m_state->SwitchToRx (rxDuration); |
| 3701 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
3701 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 3702 |
NotifyRxBegin (packet); |
3702 |
NotifyRxBegin (packet); |
| 3703 |
m_interference.NotifyRxStart (); |
3703 |
m_interference.NotifyRxStart (); |
| 3704 |
|
|
|
| 3705 |
if (preamble != WIFI_PREAMBLE_NONE) |
| 3706 |
{ |
| 3707 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 3708 |
Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector); |
| 3709 |
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this, |
| 3710 |
packet, txVector, mpdutype, event); |
| 3711 |
} |
| 3712 |
|
3704 |
|
| 3713 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
3705 |
if (preamble != WIFI_PREAMBLE_NONE) |
| 3714 |
m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this, |
|
|
| 3715 |
packet, preamble, mpdutype, event); |
| 3716 |
} |
| 3717 |
else |
| 3718 |
{ |
3706 |
{ |
| 3719 |
NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
3707 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 3720 |
rxPowerW << "<" << m_edThresholdW << ")"); |
3708 |
Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector); |
| 3721 |
NotifyRxDrop (packet); |
3709 |
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this, |
| 3722 |
m_plcpSuccess = false; |
3710 |
packet, txVector, mpdutype, event); |
| 3723 |
MaybeCcaBusyDuration (); |
|
|
| 3724 |
} |
3711 |
} |
|
|
3712 |
|
| 3713 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
| 3714 |
m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this, |
| 3715 |
packet, preamble, mpdutype, event); |
| 3725 |
} |
3716 |
} |
| 3726 |
|
3717 |
|
| 3727 |
int64_t |
3718 |
int64_t |