|
|
| 190 |
m_endPlcpRxEvent (), |
190 |
m_endPlcpRxEvent (), |
| 191 |
m_channelStartingFrequency (0), |
191 |
m_channelStartingFrequency (0), |
| 192 |
m_mpdusNum (0), |
192 |
m_mpdusNum (0), |
| 193 |
m_plcpSuccess (false) |
193 |
m_plcpSuccess (false), |
|
|
194 |
m_mpduReferenceNumber (0xffffffff) |
| 194 |
{ |
195 |
{ |
| 195 |
NS_LOG_FUNCTION (this); |
196 |
NS_LOG_FUNCTION (this); |
| 196 |
m_random = CreateObject<UniformRandomVariable> (); |
197 |
m_random = CreateObject<UniformRandomVariable> (); |
|
|
| 572 |
double rxPowerDbm, |
573 |
double rxPowerDbm, |
| 573 |
WifiTxVector txVector, |
574 |
WifiTxVector txVector, |
| 574 |
enum WifiPreamble preamble, |
575 |
enum WifiPreamble preamble, |
| 575 |
struct mpduInfo aMpdu, Time rxDuration) |
576 |
uint8_t packetType, |
|
|
577 |
Time rxDuration) |
| 576 |
{ |
578 |
{ |
| 577 |
//This function should be later split to check separately whether plcp preamble and plcp header can be successfully received. |
579 |
//This function should be later split to check separately whether plcp preamble and plcp header can be successfully received. |
| 578 |
//Note: plcp preamble reception is not yet modeled. |
580 |
//Note: plcp preamble reception is not yet modeled. |
| 579 |
NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType); |
581 |
NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)packetType); |
| 580 |
AmpduTag ampduTag; |
582 |
AmpduTag ampduTag; |
| 581 |
rxPowerDbm += m_rxGainDb; |
583 |
rxPowerDbm += m_rxGainDb; |
| 582 |
double rxPowerW = DbmToW (rxPowerDbm); |
584 |
double rxPowerW = DbmToW (rxPowerDbm); |
|
|
| 653 |
{ |
655 |
{ |
| 654 |
//received the first MPDU in an MPDU |
656 |
//received the first MPDU in an MPDU |
| 655 |
m_mpdusNum = ampduTag.GetNoOfMpdus () - 1; |
657 |
m_mpdusNum = ampduTag.GetNoOfMpdus () - 1; |
|
|
658 |
m_mpduReferenceNumber++; |
| 656 |
} |
659 |
} |
| 657 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
660 |
else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0) |
| 658 |
{ |
661 |
{ |
|
|
| 684 |
{ |
687 |
{ |
| 685 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
688 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 686 |
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this, |
689 |
m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this, |
| 687 |
packet, txVector, preamble, aMpdu, event); |
690 |
packet, txVector, preamble, packetType, event); |
| 688 |
} |
691 |
} |
| 689 |
|
692 |
|
| 690 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
693 |
NS_ASSERT (m_endRxEvent.IsExpired ()); |
| 691 |
m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
694 |
m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, |
| 692 |
packet, preamble, aMpdu, event); |
695 |
packet, preamble, packetType, event); |
| 693 |
} |
696 |
} |
| 694 |
else |
697 |
else |
| 695 |
{ |
698 |
{ |
|
|
| 726 |
YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, |
729 |
YansWifiPhy::StartReceivePacket (Ptr<Packet> packet, |
| 727 |
WifiTxVector txVector, |
730 |
WifiTxVector txVector, |
| 728 |
enum WifiPreamble preamble, |
731 |
enum WifiPreamble preamble, |
| 729 |
struct mpduInfo aMpdu, |
732 |
uint8_t packetType, |
| 730 |
Ptr<InterferenceHelper::Event> event) |
733 |
Ptr<InterferenceHelper::Event> event) |
| 731 |
{ |
734 |
{ |
| 732 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType); |
735 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)packetType); |
| 733 |
NS_ASSERT (IsStateRx ()); |
736 |
NS_ASSERT (IsStateRx ()); |
| 734 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
737 |
NS_ASSERT (m_endPlcpRxEvent.IsExpired ()); |
| 735 |
AmpduTag ampduTag; |
738 |
AmpduTag ampduTag; |
|
|
| 763 |
} |
766 |
} |
| 764 |
|
767 |
|
| 765 |
void |
768 |
void |
| 766 |
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, uint32_t mpduReferenceNumber) |
769 |
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType) |
| 767 |
{ |
770 |
{ |
| 768 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)packetType); |
771 |
NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)packetType); |
| 769 |
/* Transmission can happen if: |
772 |
/* Transmission can happen if: |
|
|
| 800 |
{ |
803 |
{ |
| 801 |
dataRate500KbpsUnits = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () / 500000; |
804 |
dataRate500KbpsUnits = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () / 500000; |
| 802 |
} |
805 |
} |
| 803 |
struct mpduInfo aMpdu; |
806 |
NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector); |
| 804 |
aMpdu.packetType = packetType; |
|
|
| 805 |
aMpdu.referenceNumber = mpduReferenceNumber; |
| 806 |
NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector, aMpdu); |
| 807 |
m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble); |
807 |
m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble); |
| 808 |
m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, aMpdu, txDuration); |
808 |
m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, packetType, txDuration); |
| 809 |
} |
809 |
} |
| 810 |
|
810 |
|
| 811 |
uint32_t |
811 |
uint32_t |
|
|
| 1141 |
} |
1141 |
} |
| 1142 |
|
1142 |
|
| 1143 |
void |
1143 |
void |
| 1144 |
YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, struct mpduInfo aMpdu, Ptr<InterferenceHelper::Event> event) |
1144 |
YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, uint8_t packetType, Ptr<InterferenceHelper::Event> event) |
| 1145 |
{ |
1145 |
{ |
| 1146 |
NS_LOG_FUNCTION (this << packet << event); |
1146 |
NS_LOG_FUNCTION (this << packet << event); |
| 1147 |
NS_ASSERT (IsStateRx ()); |
1147 |
NS_ASSERT (IsStateRx ()); |
|
|
| 1171 |
struct signalNoiseDbm signalNoise; |
1171 |
struct signalNoiseDbm signalNoise; |
| 1172 |
signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30; |
1172 |
signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30; |
| 1173 |
signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; |
1173 |
signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; |
|
|
1174 |
struct mpduInfo aMpdu; |
| 1175 |
aMpdu.packetType = packetType; |
| 1176 |
aMpdu.mpduRefNumber = m_mpduReferenceNumber; |
| 1174 |
NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, signalNoise); |
1177 |
NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, signalNoise); |
| 1175 |
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ()); |
1178 |
m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ()); |
| 1176 |
} |
1179 |
} |
|
|
| 1186 |
m_state->SwitchFromRxEndError (packet, snrPer.snr); |
1189 |
m_state->SwitchFromRxEndError (packet, snrPer.snr); |
| 1187 |
} |
1190 |
} |
| 1188 |
|
1191 |
|
| 1189 |
if (preamble == WIFI_PREAMBLE_NONE && aMpdu.packetType == 2) |
1192 |
if (preamble == WIFI_PREAMBLE_NONE && packetType == 2) |
| 1190 |
{ |
1193 |
{ |
| 1191 |
m_plcpSuccess = false; |
1194 |
m_plcpSuccess = false; |
| 1192 |
} |
1195 |
} |