560 void |
560 void |
561 YansWifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, |
561 YansWifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, |
562 double rxPowerDbm, |
562 double rxPowerDbm, |
563 WifiTxVector txVector, |
563 WifiTxVector txVector, |
564 enum WifiPreamble preamble, |
564 enum WifiPreamble preamble, |
565 uint8_t packetType, Time rxDuration) |
565 struct mpduInfo aMpdu, Time rxDuration) |
566 { |
566 { |
567 //This function should be later split to check separately wether plcp preamble and plcp header can be successfully received. |
567 //This function should be later split to check separately wether plcp preamble and plcp header can be successfully received. |
568 //Note: plcp preamble reception is not yet modeled. |
568 //Note: plcp preamble reception is not yet modeled. |
569 NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)packetType); |
569 NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType); |
570 AmpduTag ampduTag; |
570 AmpduTag ampduTag; |
571 rxPowerDbm += m_rxGainDb; |
571 rxPowerDbm += m_rxGainDb; |
572 double rxPowerW = DbmToW (rxPowerDbm); |
572 double rxPowerW = DbmToW (rxPowerDbm); |
573 Time endRx = Simulator::Now () + rxDuration; |
573 Time endRx = Simulator::Now () + rxDuration; |
574 Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector, preamble); |
574 Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector, preamble); |
672 |
672 |
673 if (preamble != WIFI_PREAMBLE_NONE) |
673 if (preamble != WIFI_PREAMBLE_NONE) |
674 { |
674 { |
675 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
675 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
676 m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this, |
676 m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this, |
677 packet, txVector, preamble, packetType, event); |
677 packet, txVector, preamble, aMpdu, event); |
678 } |
678 } |
679 |
679 |
680 NS_ASSERT (m_endRxEvent.IsExpired ()); |
680 NS_ASSERT (m_endRxEvent.IsExpired ()); |
681 m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
681 m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
682 packet, preamble, packetType, event); |
682 packet, preamble, aMpdu, event); |
683 } |
683 } |
684 else |
684 else |
685 { |
685 { |
686 NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
686 NS_LOG_DEBUG ("drop packet because signal power too Small (" << |
687 rxPowerW << "<" << m_edThresholdW << ")"); |
687 rxPowerW << "<" << m_edThresholdW << ")"); |
714 |
714 |
715 void |
715 void |
716 YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, |
716 YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, |
717 WifiTxVector txVector, |
717 WifiTxVector txVector, |
718 enum WifiPreamble preamble, |
718 enum WifiPreamble preamble, |
719 uint8_t packetType, |
719 struct mpduInfo aMpdu, |
720 Ptr<InterferenceHelper::Event> event) |
720 Ptr<InterferenceHelper::Event> event) |
721 { |
721 { |
722 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)packetType); |
722 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType); |
723 NS_ASSERT (IsStateRx ()); |
723 NS_ASSERT (IsStateRx ()); |
724 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
724 NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
725 AmpduTag ampduTag; |
725 AmpduTag ampduTag; |
726 WifiMode txMode = txVector.GetMode (); |
726 WifiMode txMode = txVector.GetMode (); |
727 |
727 |
751 m_plcpSuccess = false; |
751 m_plcpSuccess = false; |
752 } |
752 } |
753 } |
753 } |
754 |
754 |
755 void |
755 void |
756 YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType) |
756 YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, uint32_t mpduReferenceNumber) |
757 { |
757 { |
758 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)packetType); |
758 NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)packetType); |
759 /* Transmission can happen if: |
759 /* Transmission can happen if: |
760 * - we are syncing on a packet. It is the responsability of the |
760 * - we are syncing on a packet. It is the responsability of the |
761 * MAC layer to avoid doing this but the PHY does nothing to |
761 * MAC layer to avoid doing this but the PHY does nothing to |
786 } |
786 } |
787 else |
787 else |
788 { |
788 { |
789 dataRate500KbpsUnits = txVector.GetMode ().GetDataRate () * txVector.GetNss () / 500000; |
789 dataRate500KbpsUnits = txVector.GetMode ().GetDataRate () * txVector.GetNss () / 500000; |
790 } |
790 } |
791 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble); |
791 struct mpduInfo aMpdu; |
792 NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector); |
792 aMpdu.packetType = packetType; |
|
793 aMpdu.referenceNumber = mpduReferenceNumber; |
|
794 NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector, aMpdu); |
793 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble); |
795 m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble); |
794 m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, packetType, txDuration); |
796 m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, aMpdu, txDuration); |
795 } |
797 } |
796 |
798 |
797 uint32_t |
799 uint32_t |
798 YansWifiPhy::GetNModes (void) const |
800 YansWifiPhy::GetNModes (void) const |
799 { |
801 { |
1077 } |
1079 } |
1078 return dbm; |
1080 return dbm; |
1079 } |
1081 } |
1080 |
1082 |
1081 void |
1083 void |
1082 YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, uint8_t packetType, Ptr<InterferenceHelper::Event> event) |
1084 YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, struct mpduInfo aMpdu, Ptr<InterferenceHelper::Event> event) |
1083 { |
1085 { |
1084 NS_LOG_FUNCTION (this << packet << event); |
1086 NS_LOG_FUNCTION (this << packet << event); |
1085 NS_ASSERT (IsStateRx ()); |
1087 NS_ASSERT (IsStateRx ()); |
1086 NS_ASSERT (event->GetEndTime () == Simulator::Now ()); |
1088 NS_ASSERT (event->GetEndTime () == Simulator::Now ()); |
1087 |
1089 |
1104 } |
1106 } |
1105 else |
1107 else |
1106 { |
1108 { |
1107 dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector ().GetNss () / 500000; |
1109 dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector ().GetNss () / 500000; |
1108 } |
1110 } |
1109 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ()); |
1111 struct snrDbm snr; |
1110 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; |
1112 snr.signal = RatioToDb (event->GetRxPowerW ()) + 30; |
1111 double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; |
1113 snr.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; |
1112 NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, event->GetTxVector (), signalDbm, noiseDbm); |
1114 NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, snr); |
1113 m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ()); |
1115 m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ()); |
1114 } |
1116 } |
1115 else |
1117 else |
1116 { |
1118 { |
1117 /* failure. */ |
1119 /* failure. */ |