diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index fe2d306a1..902672cd9 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -2562,9 +2562,9 @@ WifiPhy::SendPacket (Ptr packet, WifiTxVector txVector) } void -WifiPhy::StartReceiveHeader (Ptr packet, WifiTxVector txVector, Ptr event, Time rxDuration) +WifiPhy::StartReceiveHeader (Ptr event, Time rxDuration) { - NS_LOG_FUNCTION (this << packet << txVector << event << rxDuration); + NS_LOG_FUNCTION (this << event->GetPacket () << event->GetTxVector () << event << rxDuration); NS_ASSERT (!IsStateRx ()); NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); @@ -2575,40 +2575,39 @@ WifiPhy::StartReceiveHeader (Ptr packet, WifiTxVector txVector, PtrIsPreambleDetected (snr, m_channelWidth))) { m_state->SwitchToRx (rxDuration); - NotifyRxBegin (packet); + NotifyRxBegin (event->GetPacket ()); + WifiTxVector txVector = event->GetTxVector (); m_timeLastPreambleDetected = Simulator::Now (); Time remainingPreambleHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector) - GetPreambleDetectionDuration (); if ((txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT) && (txVector.GetPreambleType () == WIFI_PREAMBLE_HT_GF)) { //No legacy PHY header for HT GF - m_endPlcpRxEvent = Simulator::Schedule (remainingPreambleHeaderDuration, &WifiPhy::StartReceivePayload, this, - packet, txVector, event); + m_endPlcpRxEvent = Simulator::Schedule (remainingPreambleHeaderDuration, &WifiPhy::StartReceivePayload, this, event); } else { //Schedule end of legacy PHY header Time remainingPreambleAndLegacyHeaderDuration = GetPlcpPreambleDuration (txVector) + GetPlcpHeaderDuration (txVector) - GetPreambleDetectionDuration (); - m_endPlcpRxEvent = Simulator::Schedule (remainingPreambleAndLegacyHeaderDuration, &WifiPhy::ContinueReceiveHeader, this, - packet, txVector, event); + m_endPlcpRxEvent = Simulator::Schedule (remainingPreambleAndLegacyHeaderDuration, &WifiPhy::ContinueReceiveHeader, this, event); } NS_ASSERT (m_endRxEvent.IsExpired ()); m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this, - packet, txVector, rxDuration - remainingPreambleHeaderDuration, event); + event, rxDuration - remainingPreambleHeaderDuration); } else { NS_LOG_DEBUG ("Drop packet because PHY preamble detection failed"); - NotifyRxDrop (packet); + NotifyRxDrop (event->GetPacket ()); m_plcpSuccess = false; } } void -WifiPhy::ContinueReceiveHeader (Ptr packet, WifiTxVector txVector, Ptr event) +WifiPhy::ContinueReceiveHeader (Ptr event) { - NS_LOG_FUNCTION (this << packet << txVector << event); + NS_LOG_FUNCTION (this << event->GetPacket () << event->GetTxVector () << event); NS_ASSERT (IsStateRx ()); NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); @@ -2619,14 +2618,14 @@ WifiPhy::ContinueReceiveHeader (Ptr packet, WifiTxVector txVector, PtrGetTxVector (); Time remainingPreambleHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector) - GetPlcpPreambleDuration (txVector) - GetPlcpHeaderDuration (txVector); - m_endPlcpRxEvent = Simulator::Schedule (remainingPreambleHeaderDuration, &WifiPhy::StartReceivePayload, this, - packet, txVector, event); + m_endPlcpRxEvent = Simulator::Schedule (remainingPreambleHeaderDuration, &WifiPhy::StartReceivePayload, this, event); } else //legacy PHY header reception failed { NS_LOG_DEBUG ("Drop packet because legacy PHY header reception failed"); - NotifyRxDrop (packet); + NotifyRxDrop (event->GetPacket ()); m_plcpSuccess = false; } } @@ -2715,7 +2714,7 @@ WifiPhy::StartReceivePreamble (Ptr packet, double rxPowerW, Time rxDurat { AbortCurrentReception (); NS_LOG_DEBUG ("Switch to new packet"); - StartRx (packet, txVector, rxPowerW, rxDuration, event); + StartRx (event, rxPowerW, rxDuration); } else { @@ -2745,7 +2744,7 @@ WifiPhy::StartReceivePreamble (Ptr packet, double rxPowerW, Time rxDurat break; case WifiPhyState::CCA_BUSY: case WifiPhyState::IDLE: - StartRx (packet, txVector, rxPowerW, rxDuration, event); + StartRx (event, rxPowerW, rxDuration); break; case WifiPhyState::SLEEP: NS_LOG_DEBUG ("Drop packet because in sleep mode"); @@ -2774,12 +2773,12 @@ WifiPhy::MaybeCcaBusyDuration () } void -WifiPhy::StartReceivePayload (Ptr packet, WifiTxVector txVector, Ptr event) +WifiPhy::StartReceivePayload (Ptr event) { - NS_LOG_FUNCTION (this << packet << txVector << event); + NS_LOG_FUNCTION (this << event->GetPacket () << event->GetTxVector () << event); NS_ASSERT (IsStateRx ()); NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); - WifiMode txMode = txVector.GetMode (); + WifiMode txMode = event->GetTxVector ().GetMode (); bool canReceivePayload; if ((txMode.GetModulationClass () == WIFI_MOD_CLASS_HT) || (txMode.GetModulationClass () == WIFI_MOD_CLASS_VHT) || (txMode.GetModulationClass () == WIFI_MOD_CLASS_HE)) { @@ -2802,27 +2801,27 @@ WifiPhy::StartReceivePayload (Ptr packet, WifiTxVector txVector, PtrGetRxPowerW (); - params.bssColor = txVector.GetBssColor (); + params.bssColor = event->GetTxVector ().GetBssColor (); NotifyEndOfHePreamble (params); } } else //mode is not allowed { NS_LOG_DEBUG ("Drop packet because it was sent using an unsupported mode (" << txMode << ")"); - NotifyRxDrop (packet); + NotifyRxDrop (event->GetPacket ()); } } else //plcp reception failed { NS_LOG_DEBUG ("Drop packet because non-legacy PHY header reception failed"); - NotifyRxDrop (packet); + NotifyRxDrop (event->GetPacket ()); } } void -WifiPhy::EndReceive (Ptr packet, WifiTxVector txVector, Time psduDuration, Ptr event) +WifiPhy::EndReceive (Ptr event, Time psduDuration) { - NS_LOG_FUNCTION (this << packet << txVector << psduDuration << event); + NS_LOG_FUNCTION (this << event->GetPacket () << event->GetTxVector () << event << psduDuration); NS_ASSERT (IsStateRx ()); NS_ASSERT (event->GetEndTime () == Simulator::Now ()); @@ -2830,11 +2829,13 @@ WifiPhy::EndReceive (Ptr packet, WifiTxVector txVector, Time psduDuratio std::vector statusPerMpdu; SignalNoiseDbm signalNoise; + Ptr packet = event->GetPacket (); Time relativeStart = NanoSeconds (0); if (m_plcpSuccess == true) { bool receptionOkAtLeastForOneMpdu = true; std::pair rxInfo; + WifiTxVector txVector = event->GetTxVector (); if (txVector.IsAggregation ()) { //Extract all MPDUs of the A-MPDU to compute per-MPDU PER stats @@ -2853,7 +2854,7 @@ WifiPhy::EndReceive (Ptr packet, WifiTxVector txVector, Time psduDuratio { mpduDuration += remainingAmpduDuration; //apply a correction just in case rounding had induced slight shift } - rxInfo = GetReceptionStatus (MpduAggregator::PeekMpduInAmpduSubframe (subframe), txVector, relativeStart, mpduDuration, event); + rxInfo = GetReceptionStatus (MpduAggregator::PeekMpduInAmpduSubframe (subframe), event, relativeStart, mpduDuration); NS_LOG_DEBUG ("Extracted MPDU #" << ampduSubframes.size () - nbOfRemainingMpdus - 1 << ": duration: " << mpduDuration.GetNanoSeconds () << "ns" << ", correct reception: " << rxInfo.first << ", Signal/Noise: " << rxInfo.second.signal << "/" << rxInfo.second.noise << "dBm"); @@ -2868,7 +2869,7 @@ WifiPhy::EndReceive (Ptr packet, WifiTxVector txVector, Time psduDuratio else { //Simple MPDU - rxInfo = GetReceptionStatus (packet, txVector, relativeStart, psduDuration, event); + rxInfo = GetReceptionStatus (packet, event, relativeStart, psduDuration); signalNoise = rxInfo.second; //same information for all MPDUs statusPerMpdu.push_back (rxInfo.first); receptionOkAtLeastForOneMpdu = rxInfo.first; @@ -2877,17 +2878,17 @@ WifiPhy::EndReceive (Ptr packet, WifiTxVector txVector, Time psduDuratio if (receptionOkAtLeastForOneMpdu) { NotifyMonitorSniffRx (packet, GetFrequency (), txVector, signalNoise, statusPerMpdu); - m_state->SwitchFromRxEndOk (packet, snr, txVector, statusPerMpdu); + m_state->SwitchFromRxEndOk (packet->Copy (), snr, txVector, statusPerMpdu); } else { - m_state->SwitchFromRxEndError (packet, snr); + m_state->SwitchFromRxEndError (packet->Copy (), snr); } } else { /* failure of whole PSDU because of PLCP preamble/header error */ - m_state->SwitchFromRxEndError (packet, snr); + m_state->SwitchFromRxEndError (packet->Copy (), snr); } m_interference.NotifyRxEnd (); @@ -2897,13 +2898,13 @@ WifiPhy::EndReceive (Ptr packet, WifiTxVector txVector, Time psduDuratio } std::pair -WifiPhy::GetReceptionStatus (Ptr mpdu, WifiTxVector txVector, Time relativeMpduStart, Time mpduDuration, Ptr event) +WifiPhy::GetReceptionStatus (Ptr mpdu, Ptr event, Time relativeMpduStart, Time mpduDuration) { - NS_LOG_FUNCTION (this << mpdu << txVector << relativeMpduStart << mpduDuration << event); + NS_LOG_FUNCTION (this << mpdu << event->GetTxVector () << event << relativeMpduStart << mpduDuration); InterferenceHelper::SnrPer snrPer; snrPer = m_interference.CalculatePayloadSnrPer (event, std::make_pair (relativeMpduStart, relativeMpduStart + mpduDuration)); - NS_LOG_DEBUG ("mode=" << (txVector.GetMode ().GetDataRate (txVector)) << + NS_LOG_DEBUG ("mode=" << (event->GetTxVector ().GetMode ().GetDataRate (event->GetTxVector ())) << ", snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per << ", size=" << mpdu->GetSize () << ", relativeStart = " << relativeMpduStart.GetNanoSeconds () << "ns, duration = " << mpduDuration.GetNanoSeconds () << "ns"); @@ -3966,9 +3967,9 @@ WifiPhy::AbortCurrentReception () } void -WifiPhy::StartRx (Ptr packet, WifiTxVector txVector, double rxPowerW, Time rxDuration, Ptr event) +WifiPhy::StartRx (Ptr event, double rxPowerW, Time rxDuration) { - NS_LOG_FUNCTION (this << packet << txVector << rxPowerW << rxDuration); + NS_LOG_FUNCTION (this << event->GetPacket () << event->GetTxVector () << event << rxPowerW << rxDuration); NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)"); m_interference.NotifyRxStart (); //We need to notify it now so that it starts recording events @@ -3978,7 +3979,7 @@ WifiPhy::StartRx (Ptr packet, WifiTxVector txVector, double rxPowerW, Ti Time startOfPreambleDuration = GetPreambleDetectionDuration (); Time remainingRxDuration = rxDuration - startOfPreambleDuration; m_endPreambleDetectionEvent = Simulator::Schedule (startOfPreambleDuration, &WifiPhy::StartReceiveHeader, this, - packet, txVector, event, remainingRxDuration); + event, remainingRxDuration); } else if ((m_frameCaptureModel != 0) && (rxPowerW > m_currentEvent->GetRxPowerW ())) { @@ -3991,12 +3992,12 @@ WifiPhy::StartRx (Ptr packet, WifiTxVector txVector, double rxPowerW, Ti Time startOfPreambleDuration = GetPreambleDetectionDuration (); Time remainingRxDuration = rxDuration - startOfPreambleDuration; m_endPreambleDetectionEvent = Simulator::Schedule (startOfPreambleDuration, &WifiPhy::StartReceiveHeader, this, - packet, txVector, event, remainingRxDuration); + event, remainingRxDuration); } else { NS_LOG_DEBUG ("Drop packet because RX is already decoding preamble"); - NotifyRxDrop (packet); + NotifyRxDrop (event->GetPacket ()); } m_currentEvent = event; } diff --git a/src/wifi/model/wifi-phy.h b/src/wifi/model/wifi-phy.h index 1558b3906..4ffc27fbb 100644 --- a/src/wifi/model/wifi-phy.h +++ b/src/wifi/model/wifi-phy.h @@ -128,56 +128,37 @@ public: * \param rxPowerW the receive power in W * \param rxDuration the duration needed for the reception of the packet */ - void StartReceivePreamble (Ptr packet, - double rxPowerW, - Time rxDuration); + void StartReceivePreamble (Ptr packet, double rxPowerW, Time rxDuration); /** * Start receiving the PHY header of a packet (i.e. after the end of receiving the preamble). * - * \param packet the arriving packet - * \param txVector the TXVECTOR of the arriving packet - * \param event the corresponding event of the first time the packet arrives + * \param event the corresponding event of the first time the packet arrives (also storing packet and TxVector information) + * \param rxDuration the duration needed for the reception of the header and payload of the packet */ - void StartReceiveHeader (Ptr packet, - WifiTxVector txVector, - Ptr event, - Time rxDuration); + void StartReceiveHeader (Ptr event, Time rxDuration); /** * Continue receiving the PHY header of a packet (i.e. after the end of receiving the legacy header part). * - * \param packet the arriving packet - * \param txVector the TXVECTOR of the arriving packet - * \param event the corresponding event of the first time the packet arrives + * \param event the corresponding event of the first time the packet arrives (also storing packet and TxVector information) */ - void ContinueReceiveHeader (Ptr packet, - WifiTxVector txVector, - Ptr event); + void ContinueReceiveHeader (Ptr event); /** * Start receiving the payload of a packet (i.e. the first bit of the packet has arrived). * - * \param packet the arriving packet - * \param txVector the TXVECTOR of the arriving packet - * \param event the corresponding event of the first time the packet arrives + * \param event the corresponding event of the first time the packet arrives (also storing packet and TxVector information) */ - void StartReceivePayload (Ptr packet, - WifiTxVector txVector, - Ptr event); + void StartReceivePayload (Ptr event); /** * The last bit of the packet has arrived. * - * \param packet the packet that the last bit has arrived - * \param txVector the TXVECTOR of the arriving packet + * \param event the corresponding event of the first time the packet arrives (also storing packet and TxVector information) * \param psduDuration the duration of the PSDU - * \param event the corresponding event of the first time the packet arrives */ - void EndReceive (Ptr packet, - WifiTxVector txVector, - Time psduDuration, - Ptr event); + void EndReceive (Ptr event, Time psduDuration); /** * \param packet the packet to send @@ -1698,33 +1679,25 @@ private: /** * Starting receiving the packet after having detected the medium is idle or after a reception switch. * - * \param packet the arriving packet - * \param txVector the TXVECTOR of the arriving packet + * \param event the corresponding event of the first time the packet arrives (also storing packet and TxVector information) * \param rxPowerW the receive power in W * \param rxDuration the duration needed for the reception of the packet - * \param event the corresponding event of the first time the packet arrives */ - void StartRx (Ptr packet, - WifiTxVector txVector, - double rxPowerW, - Time rxDuration, - Ptr event); + void StartRx (Ptr event, double rxPowerW, Time rxDuration); /** * Get the reception status for the provided MPDU and notify. * * \param mpdu the arriving MPDU - * \param txVector the TXVECTOR of the arriving packet + * \param event the corresponding event of the first time the packet arrives (also storing packet and TxVector information) * \param relativeMpduStart the relative start time of the MPDU within the A-MPDU. 0 for normal MPDUs * \param mpduDuration the duration of the MPDU - * \param event the corresponding event of the first time the packet arrives * * \return information on MPDU reception: status, signal power (dBm), and noise power (in dBm) */ std::pair GetReceptionStatus (Ptr mpdu, - WifiTxVector txVector, + Ptr event, Time relativeMpduStart, - Time mpduDuration, - Ptr event); + Time mpduDuration); /** * The trace source fired when a packet begins the transmission process on