Index: src/wifi/model/wifi-phy.cc |
=================================================================== |
--- a/src/wifi/model/wifi-phy.cc |
+++ b/src/wifi/model/wifi-phy.cc |
@@ -83,6 +83,9 @@ |
return tid; |
} |
+uint32_t WifiPhy::m_totalAmpduSize=0; |
+uint32_t WifiPhy::m_totalApmduNumSymbols=0; |
+ |
WifiPhy::WifiPhy () |
{ |
NS_LOG_FUNCTION (this); |
@@ -93,7 +96,6 @@ |
NS_LOG_FUNCTION (this); |
} |
-//Added by Ghada to support 11n |
//return the L-SIG |
WifiMode |
@@ -142,7 +144,6 @@ |
} |
} |
-//end added by Ghada |
WifiMode |
WifiPhy::GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble) |
@@ -165,7 +166,6 @@ |
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 |
@@ -251,6 +251,7 @@ |
case WIFI_PREAMBLE_HT_MF: |
// L-SIG |
return 4; |
+ case WIFI_PREAMBLE_NONE: |
case WIFI_PREAMBLE_HT_GF: |
//L-SIG |
return 0; |
@@ -305,8 +306,16 @@ |
} |
} |
case WIFI_MOD_CLASS_HT: |
- { //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG |
- return 16; |
+ { |
+ switch (preamble) |
+ { |
+ case WIFI_PREAMBLE_NONE: |
+ //A-MPDU support since MPDUs inside an A-MPDU are sent without a preamble |
+ return 0; |
+ default: |
+ //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG |
+ return 16; |
+ } |
} |
case WIFI_MOD_CLASS_ERP_OFDM: |
return 4; |
@@ -329,7 +338,7 @@ |
} |
double |
-WifiPhy::GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector) |
+WifiPhy::GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector,WifiPreamble preamble,uint8_t packetType,uint8_t incFlag) |
{ |
WifiMode payloadMode=txvector.GetMode(); |
@@ -417,7 +426,39 @@ |
//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 = lrint (m_Stbc*ceil ((16 + size * 8.0 + 6.0*Nes) / (m_Stbc* numDataBitsPerSymbol))); |
+ double numSymbols ; |
+ if (packetType == 1 && preamble != WIFI_PREAMBLE_NONE) |
+ { |
+ //First packet in an A-MPDU add service bits |
+ numSymbols= m_Stbc* ((16 + size * 8.0 ) / (m_Stbc* numDataBitsPerSymbol)); |
+ if (incFlag == 1){ |
+ m_totalAmpduSize+=size; |
+ m_totalApmduNumSymbols+=numSymbols;} |
+ } |
+ else if (packetType == 1 && preamble == WIFI_PREAMBLE_NONE) |
+ { |
+ //consecutive packets in an A-MPDU |
+ numSymbols= m_Stbc* ((size * 8.0 ) / (m_Stbc* numDataBitsPerSymbol)); |
+ if (incFlag == 1){ |
+ m_totalAmpduSize+=size; |
+ m_totalApmduNumSymbols+=numSymbols;} |
+ } |
+ else if (packetType == 2 && preamble == WIFI_PREAMBLE_NONE) |
+ { |
+ //last packet in an A-MPDU add pad bits |
+ |
+ uint32_t totalAmpduSize=m_totalAmpduSize+size; |
+ numSymbols = lrint (m_Stbc* ceil((16 + totalAmpduSize * 8.0 +6*Nes) / (m_Stbc* numDataBitsPerSymbol))); |
+ numSymbols -= m_totalApmduNumSymbols; |
+ if (incFlag == 1){ |
+ m_totalAmpduSize=0; |
+ m_totalApmduNumSymbols=0;} |
+ } |
+ 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))); |
+ else |
+ NS_FATAL_ERROR ("Wrong combination of preamble and packet type"); |
return numSymbols * symbolDurationUs; |
@@ -436,14 +477,14 @@ |
} |
Time |
-WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble) |
+WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble, uint8_t packetType,uint8_t incFlag) |
{ |
WifiMode payloadMode=txvector.GetMode(); |
double duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble) |
+ GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble) |
+ GetPlcpHtSigHeaderDurationMicroSeconds (payloadMode, preamble) |
+ GetPlcpHtTrainingSymbolDurationMicroSeconds (payloadMode, preamble,txvector) |
- + GetPayloadDurationMicroSeconds (size, txvector); |
+ + GetPayloadDurationMicroSeconds (size, txvector,preamble,packetType,incFlag); |
return MicroSeconds (duration); |
} |