|
Lines 183-193
WifiPhy::GetTypeId (void)
|
Link Here
|
|---|
|
| 183 |
"this threshold (dbm) to allow the PHY layer to detect the signal.", |
183 |
"this threshold (dbm) to allow the PHY layer to detect the signal.", |
| 184 |
DoubleValue (-96.0), |
184 |
DoubleValue (-96.0), |
| 185 |
MakeDoubleAccessor (&WifiPhy::SetEdThreshold), |
185 |
MakeDoubleAccessor (&WifiPhy::SetEdThreshold), |
|
|
186 |
MakeDoubleChecker<double> (), |
| 187 |
TypeId::DEPRECATED, "Replaced by RxSensitivity") |
| 188 |
.AddAttribute ("RxSensitivity", |
| 189 |
"The energy of a received signal should be higher than " |
| 190 |
"this threshold (dBm) for the PHY to detect the signal.", |
| 191 |
DoubleValue (-101.0), |
| 192 |
MakeDoubleAccessor (&WifiPhy::SetRxSensitivity, |
| 193 |
&WifiPhy::GetRxSensitivity), |
| 186 |
MakeDoubleChecker<double> ()) |
194 |
MakeDoubleChecker<double> ()) |
| 187 |
.AddAttribute ("CcaMode1Threshold", |
195 |
.AddAttribute ("CcaMode1Threshold", |
| 188 |
"The energy of a received signal should be higher than " |
196 |
"The energy of a received signal should be higher than " |
| 189 |
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.", |
197 |
"this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.", |
| 190 |
DoubleValue (-99.0), |
198 |
DoubleValue (-62.0), |
| 191 |
MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold, |
199 |
MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold, |
| 192 |
&WifiPhy::GetCcaMode1Threshold), |
200 |
&WifiPhy::GetCcaMode1Threshold), |
| 193 |
MakeDoubleChecker<double> ()) |
201 |
MakeDoubleChecker<double> ()) |
|
Lines 476-481
WifiPhy::GetEdThreshold (void) const
|
Link Here
|
|---|
|
| 476 |
} |
484 |
} |
| 477 |
|
485 |
|
| 478 |
void |
486 |
void |
|
|
487 |
WifiPhy::SetRxSensitivity (double threshold) |
| 488 |
{ |
| 489 |
NS_LOG_FUNCTION (this << threshold); |
| 490 |
m_rxSensitivityW = DbmToW (threshold); |
| 491 |
} |
| 492 |
|
| 493 |
double |
| 494 |
WifiPhy::GetRxSensitivity (void) const |
| 495 |
{ |
| 496 |
return WToDbm (m_rxSensitivityW); |
| 497 |
} |
| 498 |
|
| 499 |
void |
| 479 |
WifiPhy::SetCcaMode1Threshold (double threshold) |
500 |
WifiPhy::SetCcaMode1Threshold (double threshold) |
| 480 |
{ |
501 |
{ |
| 481 |
NS_LOG_FUNCTION (this << threshold); |
502 |
NS_LOG_FUNCTION (this << threshold); |
|
|
| 3652 |
WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event) |
3673 |
WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event) |
| 3653 |
{ |
3674 |
{ |
| 3654 |
NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration); |
3675 |
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) |
3676 |
|
|
|
3677 |
AmpduTag ampduTag; |
| 3678 |
WifiPreamble preamble = txVector.GetPreambleType (); |
| 3679 |
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) |
| 3656 |
{ |
3680 |
{ |
| 3657 |
AmpduTag ampduTag; |
3681 |
m_plcpSuccess = false; |
| 3658 |
WifiPreamble preamble = txVector.GetPreambleType (); |
3682 |
m_mpdusNum = 0; |
| 3659 |
if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false)) |
3683 |
NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received"); |
| 3660 |
{ |
3684 |
NotifyRxDrop (packet); |
| 3661 |
m_plcpSuccess = false; |
3685 |
MaybeCcaBusyDuration (); |
| 3662 |
m_mpdusNum = 0; |
3686 |
return; |
| 3663 |
NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received"); |
3687 |
} |
| 3664 |
NotifyRxDrop (packet); |
3688 |
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0) |
| 3665 |
MaybeCcaBusyDuration (); |
3689 |
{ |
| 3666 |
return; |
3690 |
//received the first MPDU in an MPDU |
| 3667 |
} |
3691 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
| 3668 |
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0) |
3692 |
m_rxMpduReferenceNumber++; |
| 3669 |
{ |
3693 |
} |
| 3670 |
//received the first MPDU in an MPDU |
3694 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 3671 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
3695 |
{ |
| 3672 |
m_rxMpduReferenceNumber++; |
3696 |
//received the other MPDUs that are part of the A-MPDU |
| 3673 |
} |
3697 |
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 |
{ |
3698 |
{ |
| 3689 |
NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost"); |
3699 |
NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ()); |
| 3690 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
3700 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
| 3691 |
} |
3701 |
} |
| 3692 |
else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 ) |
3702 |
else |
| 3693 |
{ |
3703 |
{ |
| 3694 |
NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum); |
3704 |
m_mpdusNum--; |
| 3695 |
m_mpdusNum = 0; |
|
|
| 3696 |
} |
3705 |
} |
|
|
3706 |
} |
| 3707 |
else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 3708 |
{ |
| 3709 |
NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost"); |
| 3710 |
m_mpdusNum = ampduTag.GetRemainingNbOfMpdus (); |
| 3711 |
} |
| 3712 |
else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 ) |
| 3713 |
{ |
| 3714 |
NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum); |
| 3715 |
m_mpdusNum = 0; |
| 3716 |
} |
| 3697 |
|
3717 |
|
| 3698 |
NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)"); |
3718 |
NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)"); |
| 3699 |
m_currentEvent = event; |
3719 |
m_currentEvent = event; |
| 3700 |
m_state->SwitchToRx (rxDuration); |
3720 |
m_state->SwitchToRx (rxDuration); |
| 3701 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
3721 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 3702 |
NotifyRxBegin (packet); |
3722 |
NotifyRxBegin (packet); |
| 3703 |
m_interference.NotifyRxStart (); |
3723 |
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 |
|
3724 |
|
| 3713 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
3725 |
if (preamble != WIFI_PREAMBLE_NONE) |
| 3714 |
m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this, |
|
|
| 3715 |
packet, preamble, mpdutype, event); |
| 3716 |
} |
| 3717 |
else |
| 3718 |
{ |
3726 |
{ |
| 3719 |
NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
3727 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 3720 |
rxPowerW << "<" << m_edThresholdW << ")"); |
3728 |
Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector); |
| 3721 |
NotifyRxDrop (packet); |
3729 |
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this, |
| 3722 |
m_plcpSuccess = false; |
3730 |
packet, txVector, mpdutype, event); |
| 3723 |
MaybeCcaBusyDuration (); |
|
|
| 3724 |
} |
3731 |
} |
|
|
3732 |
|
| 3733 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
| 3734 |
m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this, |
| 3735 |
packet, preamble, mpdutype, event); |
| 3725 |
} |
3736 |
} |
| 3726 |
|
3737 |
|
| 3727 |
int64_t |
3738 |
int64_t |