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