|
|
| 184 |
m_endPlcpRxEvent (), |
184 |
m_endPlcpRxEvent (), |
| 185 |
m_channelStartingFrequency (0), |
185 |
m_channelStartingFrequency (0), |
| 186 |
m_mpdusNum (0), |
186 |
m_mpdusNum (0), |
| 187 |
m_plcpSuccess (false) |
187 |
m_plcpSuccess (false), |
|
|
188 |
m_mpduReferenceNumber (0xffffffff) |
| 188 |
{ |
189 |
{ |
| 189 |
NS_LOG_FUNCTION (this); |
190 |
NS_LOG_FUNCTION (this); |
| 190 |
m_random = CreateObject<UniformRandomVariable> (); |
191 |
m_random = CreateObject<UniformRandomVariable> (); |
|
|
| 566 |
double rxPowerDbm, |
567 |
double rxPowerDbm, |
| 567 |
WifiTxVector txVector, |
568 |
WifiTxVector txVector, |
| 568 |
enum WifiPreamble preamble, |
569 |
enum WifiPreamble preamble, |
| 569 |
struct mpduInfo aMpdu, Time rxDuration) |
570 |
uint8_t packetType, |
|
|
571 |
Time rxDuration) |
| 570 |
{ |
572 |
{ |
| 571 |
//This function should be later split to check separately whether plcp preamble and plcp header can be successfully received. |
573 |
//This function should be later split to check separately whether plcp preamble and plcp header can be successfully received. |
| 572 |
//Note: plcp preamble reception is not yet modeled. |
574 |
//Note: plcp preamble reception is not yet modeled. |
| 573 |
NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType); |
575 |
NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)packetType); |
| 574 |
AmpduTag ampduTag; |
576 |
AmpduTag ampduTag; |
| 575 |
rxPowerDbm += m_rxGainDb; |
577 |
rxPowerDbm += m_rxGainDb; |
| 576 |
double rxPowerW = DbmToW (rxPowerDbm); |
578 |
double rxPowerW = DbmToW (rxPowerDbm); |
|
|
| 647 |
{ |
649 |
{ |
| 648 |
//received the first MPDU in an MPDU |
650 |
//received the first MPDU in an MPDU |
| 649 |
m_mpdusNum = ampduTag.GetNoOfMpdus () - 1; |
651 |
m_mpdusNum = ampduTag.GetNoOfMpdus () - 1; |
|
|
652 |
m_mpduReferenceNumber++; |
| 650 |
} |
653 |
} |
| 651 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
654 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 652 |
{ |
655 |
{ |
|
|
| 678 |
{ |
681 |
{ |
| 679 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
682 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 680 |
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this, |
683 |
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this, |
| 681 |
packet, txVector, preamble, aMpdu, event); |
684 |
packet, txVector, preamble, packetType, event); |
| 682 |
} |
685 |
} |
| 683 |
|
686 |
|
| 684 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
687 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
| 685 |
m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
688 |
m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
| 686 |
packet, preamble, aMpdu, event); |
689 |
packet, preamble, packetType, event); |
| 687 |
} |
690 |
} |
| 688 |
else |
691 |
else |
| 689 |
{ |
692 |
{ |
|
|
| 720 |
YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, |
723 |
YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, |
| 721 |
WifiTxVector txVector, |
724 |
WifiTxVector txVector, |
| 722 |
enum WifiPreamble preamble, |
725 |
enum WifiPreamble preamble, |
| 723 |
struct mpduInfo aMpdu, |
726 |
uint8_t packetType, |
| 724 |
Ptr<InterferenceHelper::Event> event) |
727 |
Ptr<InterferenceHelper::Event> event) |
| 725 |
{ |
728 |
{ |
| 726 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType); |
729 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)packetType); |
| 727 |
NS_ASSERT (IsStateRx ()); |
730 |
NS_ASSERT (IsStateRx ()); |
| 728 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
731 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 729 |
AmpduTag ampduTag; |
732 |
AmpduTag ampduTag; |
|
|
| 757 |
} |
760 |
} |
| 758 |
|
761 |
|
| 759 |
void |
762 |
void |
| 760 |
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, uint32_t mpduReferenceNumber) |
763 |
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType) |
| 761 |
{ |
764 |
{ |
| 762 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)packetType); |
765 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)packetType); |
| 763 |
/* Transmission can happen if: |
766 |
/* Transmission can happen if: |
|
|
| 794 |
{ |
797 |
{ |
| 795 |
dataRate500KbpsUnits = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () / 500000; |
798 |
dataRate500KbpsUnits = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () / 500000; |
| 796 |
} |
799 |
} |
| 797 |
struct mpduInfo aMpdu; |
800 |
NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector); |
| 798 |
aMpdu.packetType = packetType; |
|
|
| 799 |
aMpdu.referenceNumber = mpduReferenceNumber; |
| 800 |
NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector, aMpdu); |
| 801 |
m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble); |
801 |
m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble); |
| 802 |
m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, aMpdu, txDuration); |
802 |
m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, packetType, txDuration); |
| 803 |
} |
803 |
} |
| 804 |
|
804 |
|
| 805 |
uint32_t |
805 |
uint32_t |
|
|
| 1135 |
} |
1135 |
} |
| 1136 |
|
1136 |
|
| 1137 |
void |
1137 |
void |
| 1138 |
YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, struct mpduInfo aMpdu, Ptr<InterferenceHelper::Event> event) |
1138 |
YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, uint8_t packetType, Ptr<InterferenceHelper::Event> event) |
| 1139 |
{ |
1139 |
{ |
| 1140 |
NS_LOG_FUNCTION (this << packet << event); |
1140 |
NS_LOG_FUNCTION (this << packet << event); |
| 1141 |
NS_ASSERT (IsStateRx ()); |
1141 |
NS_ASSERT (IsStateRx ()); |
|
|
| 1165 |
struct signalNoiseDbm signalNoise; |
1165 |
struct signalNoiseDbm signalNoise; |
| 1166 |
signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30; |
1166 |
signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30; |
| 1167 |
signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; |
1167 |
signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; |
|
|
1168 |
struct mpduInfo aMpdu; |
| 1169 |
aMpdu.packetType = packetType; |
| 1170 |
aMpdu.mpduRefNumber = m_mpduReferenceNumber; |
| 1168 |
NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, signalNoise); |
1171 |
NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, signalNoise); |
| 1169 |
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ()); |
1172 |
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ()); |
| 1170 |
} |
1173 |
} |
|
|
| 1180 |
m_state->SwitchFromRxEndError (packet, snrPer.snr); |
1183 |
m_state->SwitchFromRxEndError (packet, snrPer.snr); |
| 1181 |
} |
1184 |
} |
| 1182 |
|
1185 |
|
| 1183 |
if (preamble == WIFI_PREAMBLE_NONE && aMpdu.packetType == 2) |
1186 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 1184 |
{ |
1187 |
{ |
| 1185 |
m_plcpSuccess = false; |
1188 |
m_plcpSuccess = false; |
| 1186 |
} |
1189 |
} |