wifi: Add check on length value set in L-SIG
This commit is contained in:
committed by
Sébastien Deronne
parent
0afae8ef34
commit
48ae785d16
@@ -293,6 +293,7 @@ LSigHeader::GetRate (uint16_t channelWidth) const
|
||||
void
|
||||
LSigHeader::SetLength (uint16_t length)
|
||||
{
|
||||
NS_ASSERT_MSG (length < 4096, "Invalid length");
|
||||
m_length = length;
|
||||
}
|
||||
|
||||
|
||||
@@ -2624,25 +2624,29 @@ WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector)
|
||||
LSigHeader sig;
|
||||
if ((txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_OFDM) || (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM))
|
||||
{
|
||||
sig.SetRate (txVector.GetMode ().GetDataRate (GetChannelWidth ()), GetChannelWidth ());
|
||||
sig.SetRate (txVector.GetMode ().GetDataRate (txVector), GetChannelWidth ());
|
||||
sig.SetLength (packet->GetSize ());
|
||||
}
|
||||
uint8_t sigExtention = 0;
|
||||
if (Is2_4Ghz (GetFrequency ()))
|
||||
{
|
||||
sigExtention = 6;
|
||||
}
|
||||
uint8_t m = 0;
|
||||
if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_SU)
|
||||
{
|
||||
m = 2;
|
||||
}
|
||||
else if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU)
|
||||
{
|
||||
m = 1;
|
||||
}
|
||||
//Equation 27-11 of IEEE P802.11/D4.0
|
||||
uint16_t length = ((ceil ((static_cast<double> (txDuration.GetNanoSeconds () - (20 * 1000) - (sigExtention * 1000)) / 1000) / 4.0) * 3) - 3 - m);
|
||||
sig.SetLength (length);
|
||||
else //HT, VHT or HE
|
||||
{
|
||||
uint8_t sigExtention = 0;
|
||||
if (Is2_4Ghz (GetFrequency ()))
|
||||
{
|
||||
sigExtention = 6;
|
||||
}
|
||||
uint8_t m = 0;
|
||||
if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_SU)
|
||||
{
|
||||
m = 2;
|
||||
}
|
||||
else if (txVector.GetPreambleType () == WIFI_PREAMBLE_HE_MU)
|
||||
{
|
||||
m = 1;
|
||||
}
|
||||
//Equation 27-11 of IEEE P802.11/D4.0
|
||||
uint16_t length = ((ceil ((static_cast<double> (txDuration.GetNanoSeconds () - (20 * 1000) - (sigExtention * 1000)) / 1000) / 4.0) * 3) - 3 - m);
|
||||
sig.SetLength (length);
|
||||
}
|
||||
newPacket->AddHeader (sig);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ InterferenceHelperSequenceTest::InterferenceHelperSequenceTest ()
|
||||
void
|
||||
InterferenceHelperSequenceTest::SendOnePacket (Ptr<WifiNetDevice> dev)
|
||||
{
|
||||
Ptr<Packet> p = Create<Packet> (9999);
|
||||
Ptr<Packet> p = Create<Packet> (1000);
|
||||
dev->Send (p, dev->GetBroadcast (), 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user