--- a/src/wifi/model/wifi-phy.cc Sun Jun 14 10:53:08 2015 +0200
+++ b/src/wifi/model/wifi-phy.cc Sun Jun 14 17:33:42 2015 +0200
@@ -117,31 +117,28 @@
NS_LOG_FUNCTION (this);
}
-//return the L-SIG
WifiMode
WifiPhy::GetMFPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble)
{
- switch (payloadMode.GetBandwidth ())
- {
- case 20000000:
- return WifiPhy::GetOfdmRate6_5MbpsBW20MHz ();
- case 40000000:
- return WifiPhy::GetOfdmRate13_5MbpsBW40MHz ();
- default:
- return WifiPhy::GetOfdmRate6_5MbpsBW20MHz ();
- }
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 20000000:
+ default:
+ return WifiPhy::GetOfdmRate6_5MbpsBW20MHz ();
+ case 40000000:
+ return WifiPhy::GetOfdmRate13_5MbpsBW40MHz ();
+ }
}
Time
WifiPhy::GetPlcpHtTrainingSymbolDuration (WifiPreamble preamble, WifiTxVector txvector)
{
uint8_t Ndltf, Neltf;
-
//We suppose here that STBC = 0.
//If STBC > 0, we need a different mapping between Nss and Nltf (IEEE 802.11n-2012 standard, page 1682).
if (txvector.GetNss () < 3)
{
- Ndltf = txvector.GetNss();
+ Ndltf = txvector.GetNss ();
}
else
{
@@ -149,7 +146,7 @@
}
if (txvector.GetNess () < 3)
{
- Neltf = txvector.GetNess();
+ Neltf = txvector.GetNess ();
}
else
{
@@ -158,32 +155,29 @@
switch (preamble)
{
- case WIFI_PREAMBLE_HT_MF:
- return MicroSeconds(4 + (4 * Ndltf) + (4 * Neltf));
- case WIFI_PREAMBLE_HT_GF:
- return MicroSeconds((4 * Ndltf) + (4 * Neltf));
- default:
- // no training for non HT
- return MicroSeconds(0);
+ case WIFI_PREAMBLE_HT_MF:
+ return MicroSeconds (4 + (4 * Ndltf) + (4 * Neltf));
+ case WIFI_PREAMBLE_HT_GF:
+ return MicroSeconds ((4 * Ndltf) + (4 * Neltf));
+ default:
+ //no training for non HT
+ return MicroSeconds (0);
}
}
-//return L-SIG
Time
WifiPhy::GetPlcpHtSigHeaderDuration (WifiPreamble preamble)
{
- switch (preamble)
- {
- case WIFI_PREAMBLE_HT_MF:
- // HT-SIG
- return MicroSeconds(8);
- case WIFI_PREAMBLE_HT_GF:
- //HT-SIG
- return MicroSeconds(8);
- default:
- // no HT-SIG for non HT
- return MicroSeconds(0);
- }
+ switch (preamble)
+ {
+ case WIFI_PREAMBLE_HT_MF:
+ case WIFI_PREAMBLE_HT_GF:
+ //HT-SIG
+ return MicroSeconds (8);
+ default:
+ //no HT-SIG for non HT
+ return MicroSeconds (0);
+ }
}
WifiMode
@@ -191,81 +185,78 @@
{
switch (payloadMode.GetModulationClass ())
{
- case WIFI_MOD_CLASS_OFDM:
- {
- switch (payloadMode.GetBandwidth ())
- {
- case 5000000:
- return WifiPhy::GetOfdmRate1_5MbpsBW5MHz ();
- case 10000000:
- return WifiPhy::GetOfdmRate3MbpsBW10MHz ();
- default:
- // (Section 18.3.2 "PLCP frame format"; IEEE Std 802.11-2012)
- // actually this is only the first part of the PlcpHeader,
- // because the last 16 bits of the PlcpHeader are using the
- // same mode of the payload
- return WifiPhy::GetOfdmRate6Mbps ();
- }
- }
- //Added by Ghada to support 11n
- case WIFI_MOD_CLASS_HT:
- { //return the HT-SIG
- // IEEE Std 802.11n, 20.3.23
- switch (preamble)
- {
- case WIFI_PREAMBLE_HT_MF:
+ case WIFI_MOD_CLASS_OFDM:
+ {
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 5000000:
+ return WifiPhy::GetOfdmRate1_5MbpsBW5MHz ();
+ case 10000000:
+ return WifiPhy::GetOfdmRate3MbpsBW10MHz ();
+ default:
+ //(Section 18.3.2 "PLCP frame format"; IEEE Std 802.11-2012)
+ //actually this is only the first part of the PlcpHeader,
+ //because the last 16 bits of the PlcpHeader are using the
+ //same mode of the payload
+ return WifiPhy::GetOfdmRate6Mbps ();
+ }
+ }
+ case WIFI_MOD_CLASS_HT:
+ {
+ //return the HT-SIG
+ //IEEE Std 802.11n, 20.3.23
+ switch (preamble)
+ {
+ case WIFI_PREAMBLE_HT_MF:
switch (payloadMode.GetBandwidth ())
{
- case 20000000:
+ case 20000000:
return WifiPhy::GetOfdmRate13MbpsBW20MHz ();
- case 40000000:
+ case 40000000:
return WifiPhy::GetOfdmRate27MbpsBW40MHz ();
- default:
+ default:
return WifiPhy::GetOfdmRate13MbpsBW20MHz ();
}
- case WIFI_PREAMBLE_HT_GF:
- switch (payloadMode.GetBandwidth ())
+ case WIFI_PREAMBLE_HT_GF:
+ switch (payloadMode.GetBandwidth ())
{
- case 20000000:
+ case 20000000:
return WifiPhy::GetOfdmRate13MbpsBW20MHz ();
- case 40000000:
+ case 40000000:
return WifiPhy::GetOfdmRate27MbpsBW40MHz ();
- default:
+ default:
return WifiPhy::GetOfdmRate13MbpsBW20MHz ();
}
- default:
+ default:
return WifiPhy::GetOfdmRate6Mbps ();
- }
- }
+ }
+ }
case WIFI_MOD_CLASS_ERP_OFDM:
return WifiPhy::GetErpOfdmRate6Mbps ();
-
case WIFI_MOD_CLASS_DSSS:
if (preamble == WIFI_PREAMBLE_LONG)
{
- // (Section 16.2.3 "PLCP field definitions" and Section 17.2.2.2 "Long PPDU format"; IEEE Std 802.11-2012)
+ //(Section 16.2.3 "PLCP field definitions" and Section 17.2.2.2 "Long PPDU format"; IEEE Std 802.11-2012)
return WifiPhy::GetDsssRate1Mbps ();
}
- else // WIFI_PREAMBLE_SHORT
+ else //WIFI_PREAMBLE_SHORT
{
- // (Section 17.2.2.3 "Short PPDU format"; IEEE Std 802.11-2012)
+ //(Section 17.2.2.3 "Short PPDU format"; IEEE Std 802.11-2012)
return WifiPhy::GetDsssRate2Mbps ();
}
-
default:
NS_FATAL_ERROR ("unsupported modulation class");
return WifiMode ();
}
}
-
Time
WifiPhy::GetPlcpHeaderDuration (WifiMode payloadMode, WifiPreamble preamble)
{
if (preamble == WIFI_PREAMBLE_NONE)
- {
+ {
return MicroSeconds(0);
- }
+ }
switch (payloadMode.GetModulationClass ())
{
case WIFI_MOD_CLASS_OFDM:
@@ -274,55 +265,50 @@
{
case 20000000:
default:
- // (Section 18.3.3 "PLCP preamble (SYNC))" and Figure 18-4 "OFDM training structure"; IEEE Std 802.11-2012)
- // also (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
- // We return the duration of the SIGNAL field only, since the
- // SERVICE field (which strictly speaking belongs to the PLCP
- // header, see Section 18.3.2 and Figure 18-1) is sent using the
- // payload mode.
- return MicroSeconds(4);
+ //(Section 18.3.3 "PLCP preamble (SYNC))" and Figure 18-4 "OFDM training structure"; IEEE Std 802.11-2012)
+ //also (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
+ //We return the duration of the SIGNAL field only, since the
+ //SERVICE field (which strictly speaking belongs to the PLCP
+ //header, see Section 18.3.2 and Figure 18-1) is sent using the
+ //payload mode.
+ return MicroSeconds (4);
case 10000000:
- // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
- return MicroSeconds(8);
+ //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
+ return MicroSeconds (8);
case 5000000:
- // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
- return MicroSeconds(16);
+ //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
+ return MicroSeconds (16);
}
}
- //Added by Ghada to support 11n
case WIFI_MOD_CLASS_HT:
- { //IEEE 802.11n Figure 20.1
- switch (preamble)
- {
- case WIFI_PREAMBLE_HT_MF:
- // L-SIG
- return MicroSeconds(4);
- case WIFI_PREAMBLE_HT_GF:
- //L-SIG
- return MicroSeconds(0);
- default:
- // L-SIG
- return MicroSeconds(4);
- }
+ {
+ //L-SIG
+ //IEEE 802.11n Figure 20.1
+ switch (preamble)
+ {
+ case WIFI_PREAMBLE_HT_MF:
+ default:
+ return MicroSeconds (4);
+ case WIFI_PREAMBLE_HT_GF:
+ return MicroSeconds (0);
+ }
}
case WIFI_MOD_CLASS_ERP_OFDM:
- return MicroSeconds(4);
-
+ return MicroSeconds (4);
case WIFI_MOD_CLASS_DSSS:
if (preamble == WIFI_PREAMBLE_SHORT)
{
- // (Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
- return MicroSeconds(24);
+ //(Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
+ return MicroSeconds (24);
}
- else // WIFI_PREAMBLE_LONG
+ else //WIFI_PREAMBLE_LONG
{
- // (Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
- return MicroSeconds(48);
+ //(Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
+ return MicroSeconds (48);
}
-
default:
NS_FATAL_ERROR ("unsupported modulation class");
- return MicroSeconds(0);
+ return MicroSeconds (0);
}
}
@@ -330,95 +316,91 @@
WifiPhy::GetPlcpPreambleDuration (WifiMode payloadMode, WifiPreamble preamble)
{
if (preamble == WIFI_PREAMBLE_NONE)
- {
- return MicroSeconds(0);
- }
+ {
+ return MicroSeconds (0);
+ }
switch (payloadMode.GetModulationClass ())
{
- case WIFI_MOD_CLASS_OFDM:
- {
- switch (payloadMode.GetBandwidth ())
+ case WIFI_MOD_CLASS_OFDM:
+ {
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 20000000:
+ default:
+ //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
+ //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
+ return MicroSeconds (16);
+ case 10000000:
+ //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
+ //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
+ return MicroSeconds (32);
+ case 5000000:
+ //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
+ //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
+ return MicroSeconds (64);
+ }
+ }
+ case WIFI_MOD_CLASS_HT:
+ //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
+ return MicroSeconds (16);
+ case WIFI_MOD_CLASS_ERP_OFDM:
+ return MicroSeconds (16);
+ case WIFI_MOD_CLASS_DSSS:
+ if (preamble == WIFI_PREAMBLE_SHORT)
{
- case 20000000:
- default:
- // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
- // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
- return MicroSeconds(16);
- case 10000000:
- // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
- // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
- return MicroSeconds(32);
- case 5000000:
- // (Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
- // also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
- return MicroSeconds(64);
+ //(Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
+ return MicroSeconds (72);
}
- }
- case WIFI_MOD_CLASS_HT:
- {
- //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
- return MicroSeconds(16);
- }
- case WIFI_MOD_CLASS_ERP_OFDM:
- return MicroSeconds(16);
-
- case WIFI_MOD_CLASS_DSSS:
- if (preamble == WIFI_PREAMBLE_SHORT)
- {
- // (Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
- return MicroSeconds(72);
- }
- else // WIFI_PREAMBLE_LONG
- {
- // (Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
- return MicroSeconds(144);
- }
- default:
- NS_FATAL_ERROR ("unsupported modulation class");
- return MicroSeconds(0);
+ else //WIFI_PREAMBLE_LONG
+ {
+ //(Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
+ return MicroSeconds (144);
+ }
+ default:
+ NS_FATAL_ERROR ("unsupported modulation class");
+ return MicroSeconds (0);
}
}
Time
WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble, double frequency, uint8_t packetType, uint8_t incFlag)
{
- WifiMode payloadMode = txvector.GetMode();
+ WifiMode payloadMode = txvector.GetMode ();
NS_LOG_FUNCTION (size << payloadMode);
switch (payloadMode.GetModulationClass ())
{
- case WIFI_MOD_CLASS_OFDM:
- case WIFI_MOD_CLASS_ERP_OFDM:
- {
- // (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
- // corresponds to T_{SYM} in the table)
- Time symbolDuration;
-
- switch (payloadMode.GetBandwidth ())
- {
- case 20000000:
- default:
- symbolDuration = MicroSeconds(4);
- break;
- case 10000000:
- symbolDuration = MicroSeconds(8);
- break;
- case 5000000:
- symbolDuration = MicroSeconds(16);
- break;
+ case WIFI_MOD_CLASS_OFDM:
+ case WIFI_MOD_CLASS_ERP_OFDM:
+ {
+ //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
+ //corresponds to T_{SYM} in the table)
+ Time symbolDuration;
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 20000000:
+ default:
+ symbolDuration = MicroSeconds (4);
+ break;
+ case 10000000:
+ symbolDuration = MicroSeconds (8);
+ break;
+ case 5000000:
+ symbolDuration = MicroSeconds (16);
+ break;
}
- // (Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
- // corresponds to N_{DBPS} in the table
- double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDuration.GetNanoSeconds() / 1e9;
+ //(Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
+ //corresponds to N_{DBPS} in the table
+ double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDuration.GetNanoSeconds () / 1e9;
- // (Section 18.3.5.4 "Pad bits (PAD)" Equation 18-11; IEEE Std 802.11-2012)
+ //(Section 18.3.5.4 "Pad bits (PAD)" Equation 18-11; IEEE Std 802.11-2012)
uint32_t numSymbols;
if (packetType == 1 && preamble != WIFI_PREAMBLE_NONE)
{
//First packet in an A-MPDU
- numSymbols= ceil((16 + size * 8.0 + 6) / (numDataBitsPerSymbol));
+ numSymbols = ceil ((16 + size * 8.0 + 6) / numDataBitsPerSymbol);
if (incFlag == 1)
{
m_totalAmpduSize += size;
@@ -428,7 +410,7 @@
else if (packetType == 1 && preamble == WIFI_PREAMBLE_NONE)
{
//consecutive packets in an A-MPDU
- numSymbols= ((size * 8.0) / (numDataBitsPerSymbol));
+ numSymbols = ((size * 8.0) / numDataBitsPerSymbol);
if (incFlag == 1)
{
m_totalAmpduSize += size;
@@ -439,7 +421,7 @@
{
//last packet in an A-MPDU
uint32_t totalAmpduSize = m_totalAmpduSize + size;
- numSymbols = lrint (ceil((16 + totalAmpduSize * 8.0 + 6) / (numDataBitsPerSymbol)));
+ numSymbols = lrint (ceil ((16 + totalAmpduSize * 8.0 + 6) / numDataBitsPerSymbol));
numSymbols -= m_totalAmpduNumSymbols;
if (incFlag == 1)
{
@@ -450,15 +432,15 @@
else if (packetType == 0 && preamble != WIFI_PREAMBLE_NONE)
{
//Not an A-MPDU
- numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / (numDataBitsPerSymbol)));
+ numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
}
else
NS_FATAL_ERROR ("Wrong combination of preamble and packet type");
- // Add signal extension for ERP PHY
+ //Add signal extension for ERP PHY
if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
{
- return Time (numSymbols * symbolDuration) + MicroSeconds(6);
+ return Time (numSymbols * symbolDuration) + MicroSeconds (6);
}
else
{
@@ -467,51 +449,56 @@
}
case WIFI_MOD_CLASS_HT:
{
- Time symbolDuration;
- double m_Stbc;
+ Time symbolDuration;
+ double m_Stbc;
//if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
//In the future has to create a stationmanager that only uses these data rates if sender and reciever support GI
- if (payloadMode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || payloadMode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
- {
- symbolDuration = NanoSeconds(3600);
- }
- else
- {
- switch (payloadMode.GetDataRate ()/ (txvector.GetNss()))
- { //shortGi
- case 7200000:
- case 14400000:
- case 21700000:
- case 28900000:
- case 43300000:
- case 57800000:
- case 72200000:
- case 15000000:
- case 30000000:
- case 45000000:
- case 60000000:
- case 90000000:
- case 120000000:
- case 150000000:
- symbolDuration = NanoSeconds(3600);
- break;
- default:
- symbolDuration = MicroSeconds(4);
+ if (payloadMode.GetUniqueName () == "OfdmRate135MbpsBW40MHzShGi" || payloadMode.GetUniqueName () == "OfdmRate65MbpsBW20MHzShGi" )
+ {
+ symbolDuration = NanoSeconds (3600);
+ }
+ else
+ {
+ switch (payloadMode.GetDataRate () / (txvector.GetNss ()))
+ {
+ //shortGi
+ case 7200000:
+ case 14400000:
+ case 21700000:
+ case 28900000:
+ case 43300000:
+ case 57800000:
+ case 72200000:
+ case 15000000:
+ case 30000000:
+ case 45000000:
+ case 60000000:
+ case 90000000:
+ case 120000000:
+ case 150000000:
+ symbolDuration = NanoSeconds (3600);
+ break;
+ default:
+ symbolDuration = MicroSeconds (4);
}
- }
- if (txvector.IsStbc())
- m_Stbc=2;
- else
- m_Stbc=1;
- double numDataBitsPerSymbol = payloadMode.GetDataRate () * txvector.GetNss() * symbolDuration.GetNanoSeconds() / 1e9;
- //check tables 20-35 and 20-36 in the standard to get cases when nes =2
- double Nes=1;
- // IEEE Std 802.11n, section 20.3.11, equation (20-32)
+ }
+
+ if (txvector.IsStbc ())
+ m_Stbc = 2;
+ else
+ m_Stbc = 1;
+
+ //check tables 20-35 and 20-36 in the standard to get cases when nes =2
+ double Nes = 1;
+
+ //IEEE Std 802.11n, section 20.3.11, equation (20-32)
uint32_t numSymbols;
+ double numDataBitsPerSymbol = payloadMode.GetDataRate () * txvector.GetNss () * symbolDuration.GetNanoSeconds () / 1e9;
+
if (packetType == 1 && preamble != WIFI_PREAMBLE_NONE)
{
//First packet in an A-MPDU
- numSymbols = ceil(m_Stbc*(16 + size * 8.0 + 6*Nes) / (m_Stbc* numDataBitsPerSymbol));
+ numSymbols = ceil (m_Stbc * (16 + size * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol));
if (incFlag == 1)
{
m_totalAmpduSize += size;
@@ -521,7 +508,7 @@
else if (packetType == 1 && preamble == WIFI_PREAMBLE_NONE)
{
//consecutive packets in an A-MPDU
- numSymbols = m_Stbc* ((size * 8.0 ) / (m_Stbc* numDataBitsPerSymbol));
+ numSymbols = m_Stbc * ((size * 8.0 ) / (m_Stbc * numDataBitsPerSymbol));
if (incFlag == 1)
{
m_totalAmpduSize += size;
@@ -531,8 +518,8 @@
else if (packetType == 2 && preamble == WIFI_PREAMBLE_NONE)
{
//last packet in an A-MPDU
- uint32_t totalAmpduSize = m_totalAmpduSize+size;
- numSymbols = lrint (m_Stbc* ceil((16 + totalAmpduSize * 8.0 + 6*Nes) / (m_Stbc* numDataBitsPerSymbol)));
+ uint32_t totalAmpduSize = m_totalAmpduSize + size;
+ numSymbols = lrint (m_Stbc * ceil ((16 + totalAmpduSize * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol)));
NS_ASSERT (m_totalAmpduNumSymbols <= numSymbols);
numSymbols -= m_totalAmpduNumSymbols;
if (incFlag == 1)
@@ -542,30 +529,28 @@
}
}
else if (packetType == 0 && preamble != WIFI_PREAMBLE_NONE)
- //Not an A-MPDU
{
- numSymbols = lrint (m_Stbc*ceil ((16 + size * 8.0 + 6.0*Nes) / (m_Stbc* numDataBitsPerSymbol)));
+ //Not an A-MPDU
+ numSymbols = lrint (m_Stbc * ceil ((16 + size * 8.0 + 6.0 * Nes) / (m_Stbc * numDataBitsPerSymbol)));
}
else
NS_FATAL_ERROR ("Wrong combination of preamble and packet type");
if (frequency >= 2400 && frequency <= 2500 && ((packetType == 0 && preamble != WIFI_PREAMBLE_NONE) || (packetType == 2 && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
{
- return Time (numSymbols * symbolDuration) + MicroSeconds(6);
+ return Time (numSymbols * symbolDuration) + MicroSeconds (6);
}
- else //at 5 GHz
+ else //at 5 GHz
{
return Time (numSymbols * symbolDuration);
}
-
}
case WIFI_MOD_CLASS_DSSS:
- // (Section 17.2.3.6 "Long PLCP LENGTH field"; IEEE Std 802.11-2012)
+ //(Section 17.2.3.6 "Long PLCP LENGTH field"; IEEE Std 802.11-2012)
NS_LOG_LOGIC (" size=" << size
<< " mode=" << payloadMode
- << " rate=" << payloadMode.GetDataRate () );
+ << " rate=" << payloadMode.GetDataRate ());
return MicroSeconds (lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6))));
-
default:
NS_FATAL_ERROR ("unsupported modulation class");
return MicroSeconds (0);
@@ -573,24 +558,21 @@
}
Time
+WifiPhy::CalculatePlcpPreambleAndHeaderDuration (WifiTxVector txvector, WifiPreamble preamble)
+{
+ WifiMode payloadMode = txvector.GetMode ();
+ Time duration = GetPlcpPreambleDuration (payloadMode, preamble)
+ + GetPlcpHeaderDuration (payloadMode, preamble)
+ + GetPlcpHtSigHeaderDuration (preamble)
+ + GetPlcpHtTrainingSymbolDuration (preamble, txvector);
+ return duration;
+}
+
+Time
WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble, double frequency, uint8_t packetType, uint8_t incFlag)
{
- WifiMode payloadMode=txvector.GetMode();
- Time duration = GetPlcpPreambleDuration (payloadMode, preamble)
- + GetPlcpHeaderDuration (payloadMode, preamble)
- + GetPlcpHtSigHeaderDuration (preamble)
- + GetPlcpHtTrainingSymbolDuration (preamble, txvector)
- + GetPayloadDuration (size, txvector, preamble, frequency, packetType, incFlag);
- return duration;
-}
-Time
-WifiPhy::CalculatePlcpDuration (WifiTxVector txvector, WifiPreamble preamble)
-{
- WifiMode payloadMode=txvector.GetMode();
- Time duration = GetPlcpPreambleDuration (payloadMode, preamble)
- + GetPlcpHeaderDuration (payloadMode, preamble)
- + GetPlcpHtSigHeaderDuration (preamble)
- + GetPlcpHtTrainingSymbolDuration (preamble, txvector);
+ Time duration = CalculatePlcpPreambleAndHeaderDuration (txvector, preamble)
+ + GetPayloadDuration (size, txvector, preamble, frequency, packetType, incFlag);
return duration;
}
@@ -914,6 +896,7 @@
return mode;
}
+
// 10 MHz channel rates
WifiMode
@@ -1020,6 +1003,7 @@
return mode;
}
+
// 5 MHz channel rates
WifiMode
@@ -1126,6 +1110,7 @@
return mode;
}
+
// Clause 20
WifiMode
@@ -1140,6 +1125,7 @@
2);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate7_2MbpsBW20MHz ()
{
@@ -1178,6 +1164,7 @@
4);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate19_5MbpsBW20MHz ()
{
@@ -1204,7 +1191,6 @@
return mode;
}
-
WifiMode
WifiPhy::GetOfdmRate26MbpsBW20MHz ()
{
@@ -1283,7 +1269,6 @@
return mode;
}
-
WifiMode
WifiPhy::GetOfdmRate58_5MbpsBW20MHz ()
{
@@ -1374,6 +1359,7 @@
4);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate30MbpsBW40MHz ()
{
@@ -1399,6 +1385,7 @@
4);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate45MbpsBW40MHz ()
{
@@ -1450,6 +1437,7 @@
16);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate90MbpsBW40MHz ()
{
@@ -1475,6 +1463,7 @@
64);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate120MbpsBW40MHz ()
{
@@ -1487,6 +1476,7 @@
64);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate121_5MbpsBW40MHz ()
{
@@ -1499,6 +1489,7 @@
64);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate135MbpsBW40MHzShGi ()
{
@@ -1511,6 +1502,7 @@
64);
return mode;
}
+
WifiMode
WifiPhy::GetOfdmRate135MbpsBW40MHz ()
{
@@ -1538,7 +1530,6 @@
}
-
std::ostream& operator<< (std::ostream& os, enum WifiPhy::State state)
{
switch (state)
@@ -1561,8 +1552,6 @@
}
}
-
-
} // namespace ns3
namespace {
@@ -1642,4 +1631,5 @@
ns3::WifiPhy::GetOfdmRate150MbpsBW40MHz ();
}
} g_constructor;
+
}
--- a/src/wifi/model/wifi-phy.h Sun Jun 14 10:53:08 2015 +0200
+++ b/src/wifi/model/wifi-phy.h Sun Jun 14 17:33:42 2015 +0200
@@ -82,7 +82,6 @@
* unless they have received a cca busy report.
*/
virtual void NotifyTxStart (Time duration, double txPowerDbm) = 0;
-
/**
* \param duration the expected busy duration.
*
@@ -163,12 +162,12 @@
* arg3: TXVECTOR of packet
* arg4: type of preamble used for packet.
*/
- typedef Callback<void,Ptr<Packet>, double, WifiTxVector, enum WifiPreamble> RxOkCallback;
+ typedef Callback<void, Ptr<Packet>, double, WifiTxVector, enum WifiPreamble> RxOkCallback;
/**
* arg1: packet received unsuccessfully
* arg2: snr of packet
*/
- typedef Callback<void,Ptr<const Packet>, double> RxErrorCallback;
+ typedef Callback<void, Ptr<const Packet>, double> RxErrorCallback;
static TypeId GetTypeId (void);
@@ -289,24 +288,25 @@
* \param txvector the transmission parameters used for this packet
* \param preamble the type of preamble to use for this packet.
* \param frequency the channel center frequency (MHz)
- * \param packetType the type of the packet 0 is not A-MPDU, 1 is a MPDU that is part of an A-MPDU and 2 is the last MPDU in an A-MPDU
+ * \param packetType the type of the packet 0 is not A-MPDU, 1 is a MPDU that is part of an A-MPDU and 2 is the last MPDU in an A-MPDU
* \param incFlag this flag is used to indicate that the static variables need to be update or not. This function is called a couple of times for the same packet so static variables should not be increased each time.
- * \return the total amount of time this PHY will stay busy for
- * the transmission of these bytes.
+ *
+ * \return the total amount of time this PHY will stay busy for the transmission of these bytes.
*/
Time CalculateTxDuration (uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble, double frequency, uint8_t packetType, uint8_t incFlag);
/**
* \param txvector the transmission parameters used for this packet
* \param preamble the type of preamble to use for this packet.
- * \return the total amount of time this PHY will stay busy for the transmission of the plcp.
+ *
+ * \return the total amount of time this PHY will stay busy for the transmission of the PLCP preamble and PLCP header.
*/
- Time CalculatePlcpDuration (WifiTxVector txvector, enum WifiPreamble preamble);
+ Time CalculatePlcpPreambleAndHeaderDuration (WifiTxVector txvector, enum WifiPreamble preamble);
/**
* \param preamble the type of preamble
* \param txvector the transmission parameters used for this packet
-
+ *
* \return the training symbol duration
*/
static Time GetPlcpHtTrainingSymbolDuration (WifiPreamble preamble, WifiTxVector txvector);
@@ -323,8 +323,6 @@
* \return the duration of the HT-SIG in Mixed Format and greenfield format PLCP header
*/
static Time GetPlcpHtSigHeaderDuration (WifiPreamble preamble);
-
-
/**
* \param payloadMode the WifiMode use for the transmission of the payload
* \param preamble the type of preamble
@@ -332,7 +330,6 @@
* \return the WifiMode used for the transmission of the PLCP header
*/
static WifiMode GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
-
/**
* \param payloadMode the WifiMode use for the transmission of the payload
* \param preamble the type of preamble
@@ -340,7 +337,6 @@
* \return the duration of the PLCP header
*/
static Time GetPlcpHeaderDuration (WifiMode payloadMode, WifiPreamble preamble);
-
/**
* \param payloadMode the WifiMode use for the transmission of the payload
* \param preamble the type of preamble
@@ -348,13 +344,12 @@
* \return the duration of the PLCP preamble
*/
static Time GetPlcpPreambleDuration (WifiMode payloadMode, WifiPreamble preamble);
-
/**
* \param size the number of bytes in the packet to send
* \param txvector the transmission parameters used for this packet
- * \param preamble the type of preamble to use for this packet.
+ * \param preamble the type of preamble to use for this packet
* \param frequency the channel center frequency (MHz)
- * \param packetType the type of the packet 0 is not A-MPDU, 1 is a MPDU that is part of an A-MPDU and 2 is the last MPDU in an A-MPDU
+ * \param packetType the type of the packet (0 is not A-MPDU, 1 is a MPDU that is part of an A-MPDU and 2 is the last MPDU in an A-MPDU)
* \param incFlag this flag is used to indicate that the static variables need to be update or not. This function is called a couple of times for the same packet so static variables should not be increased each time
*
* \return the duration of the payload
@@ -393,6 +388,7 @@
* necessarily proper) of the BSSBasicRateSet.
*
* \param mode index in array of supported modes
+ *
* \return the mode whose index is specified.
*
* \sa WifiPhy::GetNModes()
@@ -402,17 +398,21 @@
* Check if the given WifiMode is supported by the PHY.
*
* \param mode the wifi mode to check
+ *
* \return true if the given mode is supported,
* false otherwise
*/
virtual bool IsModeSupported (WifiMode mode) const = 0;
+
/**
* \param txMode the transmission mode
* \param ber the probability of bit error rate
+ *
* \return the minimum snr which is required to achieve
* the requested ber for the specified transmission mode. (W/W)
*/
virtual double CalculateSnr (WifiMode txMode, double ber) const = 0;
+
/**
* The WifiPhy::NBssMembershipSelectors() method is used
* (e.g., by a WifiRemoteStationManager) to determine the set of
@@ -420,12 +420,9 @@
* can support - a set of WifiMode objects which we call the
* BssMembershipSelectorSet, and which is stored as WifiPhy::m_bssMembershipSelectorSet.
*
- * This was introduced with 11n
- *
* \return the memebership selector whose index is specified.
*/
- virtual uint32_t GetNBssMembershipSelectors (void) const=0;
-
+ virtual uint32_t GetNBssMembershipSelectors (void) const = 0;
/**
* The WifiPhy::BssMembershipSelector() method is used
* (e.g., by a WifiRemoteStationManager) to determine the set of
@@ -433,12 +430,11 @@
* can support - a set of WifiMode objects which we call the
* BssMembershipSelectorSet, and which is stored as WifiPhy::m_bssMembershipSelectorSet.
*
- * This was introduced with 11n
+ * \param selector index in array of supported memberships
*
- * \param selector index in array of supported memberships
* \return the memebership selector whose index is specified.
*/
- virtual uint32_t GetBssMembershipSelector (uint32_t selector) const=0;
+ virtual uint32_t GetBssMembershipSelector (uint32_t selector) const = 0;
/**
* The WifiPhy::GetMembershipSelectorModes() method is used
* (e.g., by a WifiRemoteStationManager) to determine the set of
@@ -446,14 +442,13 @@
* can support - a set of WifiMode objects which we call the
* BssMembershipSelectorSet, and which is stored as WifiPhy::m_bssMembershipSelectorSet.
*
- * This was introduced with 11n
+ * \param selector index in array of supported memberships
*
- * \param selector index in array of supported memberships
* \return a WifiModeList that contains the WifiModes associrated with the selected index.
*
* \sa WifiPhy::GetMembershipSelectorModes()
*/
- virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)=0;
+ virtual WifiModeList GetMembershipSelectorModes(uint32_t selector) = 0;
/**
* The WifiPhy::GetNMcs() method is used
* (e.g., by a WifiRemoteStationManager) to determine the set of
@@ -461,8 +456,6 @@
* can support - a set of MCS indexes which we call the
* DeviceMcsSet, and which is stored as WifiPhy::m_deviceMcsSet.
*
- * This was introduced with 11n
- *
* \return the MCS index whose index is specified.
*/
virtual uint8_t GetNMcs (void) const=0;
@@ -473,31 +466,31 @@
* can support - a set of MCS indexes which we call the
* DeviceMcsSet, and which is stored as WifiPhy::m_deviceMcsSet.
*
- * This was introduced with 11n
+ * \param mcs index in array of supported MCS
*
- * \param mcs index in array of supported MCS
* \return the MCS index whose index is specified.
*/
- virtual uint8_t GetMcs (uint8_t mcs) const=0;
+ virtual uint8_t GetMcs (uint8_t mcs) const = 0;
/**
* For a given WifiMode finds the corresponding MCS value and returns it
* as defined in the IEEE 802.11n standard
*
* \param mode the WifiMode
+ *
* \return the MCS number that corresponds to the given WifiMode
*/
- virtual uint32_t WifiModeToMcs (WifiMode mode)=0;
+ virtual uint32_t WifiModeToMcs (WifiMode mode) = 0;
/**
* For a given MCS finds the corresponding WifiMode and returns it
* as defined in the IEEE 802.11n standard.
*
* \param mcs the MCS number
+ *
* \return the WifiMode that corresponds to the given MCS number
*/
- virtual WifiMode McsToWifiMode (uint8_t mcs)=0;
+ virtual WifiMode McsToWifiMode (uint8_t mcs) = 0;
-
/**
* \brief Set channel number.
*
@@ -846,7 +839,6 @@
* \return a WifiMode for OFDM at 135Mbps with 40MHz channel spacing
*/
static WifiMode GetOfdmRate135MbpsBW40MHz ();
- //Rates for clause 20 with short guard interval
/**
* Return a WifiMode for OFDM at 7.2Mbps with 20MHz channel spacing.
*
@@ -946,58 +938,52 @@
*/
static WifiMode GetOfdmRate150MbpsBW40MHz ();
-
/**
- * Public method used to fire a PhyTxBegin trace. Implemented for encapsulation
- * purposes.
+ * Public method used to fire a PhyTxBegin trace.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet being transmitted
*/
void NotifyTxBegin (Ptr<const Packet> packet);
-
/**
- * Public method used to fire a PhyTxEnd trace. Implemented for encapsulation
- * purposes.
+ * Public method used to fire a PhyTxEnd trace.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet that was transmitted
*/
void NotifyTxEnd (Ptr<const Packet> packet);
-
/**
- * Public method used to fire a PhyTxDrop trace. Implemented for encapsulation
- * purposes.
+ * Public method used to fire a PhyTxDrop trace.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet that was failed to transmitted
*/
void NotifyTxDrop (Ptr<const Packet> packet);
-
/**
- * Public method used to fire a PhyRxBegin trace. Implemented for encapsulation
- * purposes.
+ * Public method used to fire a PhyRxBegin trace.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet being received
*/
void NotifyRxBegin (Ptr<const Packet> packet);
-
/**
- * Public method used to fire a PhyRxEnd trace. Implemented for encapsulation
- * purposes.
+ * Public method used to fire a PhyRxEnd trace.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet received
*/
void NotifyRxEnd (Ptr<const Packet> packet);
-
/**
- * Public method used to fire a PhyRxDrop trace. Implemented for encapsulation
- * purposes.
+ * Public method used to fire a PhyRxDrop trace.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet that was not successfully received
*/
void NotifyRxDrop (Ptr<const Packet> packet);
/**
- * Public method used to fire a MonitorSniffer trace for a wifi packet
- * being received. Implemented for encapsulation purposes.
+ * Public method used to fire a MonitorSniffer trace for a wifi packet being received.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet being received
* \param channelFreqMhz the frequency in MHz at which the packet is
@@ -1038,7 +1024,7 @@
* \param isShortPreamble true if short preamble is used, false otherwise
* \param txVector the txvector that holds rx parameters
* \param signalDbm signal power in dBm
- * \param noiseDbm noise power in dBm
+ * \param noiseDbm noise power in dBm
*/
typedef void (* MonitorSnifferRxCallback)
(Ptr<const Packet> packet, uint16_t channelFreqMhz,
@@ -1047,8 +1033,8 @@
double signalDbm, double noiseDbm);
/**
- * Public method used to fire a MonitorSniffer trace for a wifi packet
- * being transmitted. Implemented for encapsulation purposes.
+ * Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
+ * Implemented for encapsulation purposes.
*
* \param packet the packet being transmitted
* \param channelFreqMhz the frequency in MHz at which the packet is
@@ -1080,10 +1066,9 @@
uint16_t channelNumber, uint32_t rate,
bool isShortPreamble, WifiTxVector txvector);
-
/**
* Assign a fixed random variable stream number to the random variables
- * used by this model. Return the number of streams (possibly zero) that
+ * used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
@@ -1094,69 +1079,68 @@
/**
* \param freq the operating frequency on this node.
*/
- virtual void SetFrequency (uint32_t freq)=0;
+ virtual void SetFrequency (uint32_t freq) = 0;
/**
* \return the operating frequency on this node
*/
- virtual uint32_t GetFrequency (void) const=0;
+ virtual uint32_t GetFrequency (void) const = 0;
/**
* \param tx the number of transmitters on this node.
*/
- virtual void SetNumberOfTransmitAntennas (uint32_t tx)=0;
-
+ virtual void SetNumberOfTransmitAntennas (uint32_t tx) = 0;
/**
* \return the number of transmit antenna on this device
*/
- virtual uint32_t GetNumberOfTransmitAntennas (void) const=0;
+ virtual uint32_t GetNumberOfTransmitAntennas (void) const = 0;
/**
* \param rx the number of receivers on this node.
*/
- virtual void SetNumberOfReceiveAntennas (uint32_t rx)=0 ;
+ virtual void SetNumberOfReceiveAntennas (uint32_t rx) = 0;
/**
* \return the number of receivers on this node.
*/
- virtual uint32_t GetNumberOfReceiveAntennas (void) const=0;
+ virtual uint32_t GetNumberOfReceiveAntennas (void) const = 0;
/**
* \param guardInterval Enable or disable short guard interval
*/
- virtual void SetGuardInterval (bool guardInterval)=0;
- /**
- * \return true if short guard interval is supported, false otherwise
+ virtual void SetGuardInterval (bool guardInterval) = 0;
+ /**
+ * \return true if short guard interval is supported, false otherwise
*/
virtual bool GetGuardInterval (void) const = 0;
/**
* \param ldpc Enable or disable LDPC
*/
- virtual void SetLdpc (bool ldpc)=0;
+ virtual void SetLdpc (bool ldpc) = 0;
/**
* \return true if LDPC is supported, false otherwise
*/
- virtual bool GetLdpc (void) const=0;
+ virtual bool GetLdpc (void) const = 0;
/**
* \param stbc Enable or disable STBC is supported
*/
- virtual void SetStbc (bool stbc)=0;
+ virtual void SetStbc (bool stbc) = 0;
/**
- * \return true if STBC is supported, false otherwise
+ * \return true if STBC is supported, false otherwise
*/
- virtual bool GetStbc (void) const=0;
-
+ virtual bool GetStbc (void) const = 0;
/**
* \param greenfield Enable or disable GreenField
*/
- virtual void SetGreenfield (bool greenfield)=0;
+ virtual void SetGreenfield (bool greenfield) = 0;
/**
* \return true if Greenfield is supported, false otherwise
*/
- virtual bool GetGreenfield (void) const=0;
+ virtual bool GetGreenfield (void) const = 0;
/**
* \return true if channel bonding 40 MHz is supported, false otherwise
*/
virtual bool GetChannelBonding (void) const = 0;
/**
- * \param channelbonding Enable or disable channel bonding
+ * \param channelbonding Enable or disable channel bonding
*/
- virtual void SetChannelBonding (bool channelbonding) = 0 ;
+ virtual void SetChannelBonding (bool channelbonding) = 0;
+
private:
/**
--- a/src/wifi/model/yans-wifi-phy.cc Sun Jun 14 10:53:08 2015 +0200
+++ b/src/wifi/model/yans-wifi-phy.cc Sun Jun 14 17:33:42 2015 +0200
@@ -533,7 +533,7 @@
rxPowerDbm += m_rxGainDb;
double rxPowerW = DbmToW (rxPowerDbm);
Time endRx = Simulator::Now () + rxDuration;
- Time plcpDuration = CalculatePlcpDuration (txVector, preamble);
+ Time plcpDuration = CalculatePlcpPreambleAndHeaderDuration (txVector, preamble);
Ptr<InterferenceHelper::Event> event;
event = m_interference.Add (packet->GetSize (),