--- a/src/wifi/model/interference-helper.cc Sun Jan 04 09:43:20 2015 -0800
+++ b/src/wifi/model/interference-helper.cc Sun Jan 04 10:13:34 2015 -0800
@@ -281,10 +281,10 @@
}
WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (payloadMode, preamble);
- Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (WifiPhy::GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)); //packet start time+ preamble
- Time plcpHsigHeaderStart=plcpHeaderStart+ MicroSeconds (WifiPhy::GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble));//packet start time+ preamble+L SIG
- Time plcpHtTrainingSymbolsStart = plcpHsigHeaderStart + MicroSeconds (WifiPhy::GetPlcpHtSigHeaderDurationMicroSeconds (payloadMode, preamble));//packet start time+ preamble+L SIG+HT SIG
- Time plcpPayloadStart =plcpHtTrainingSymbolsStart + MicroSeconds (WifiPhy::GetPlcpHtTrainingSymbolDurationMicroSeconds (preamble,event->GetTxVector())); //packet start time+ preamble+L SIG+HT SIG+Training
+ Time plcpHeaderStart = (*j).GetTime () + WifiPhy::GetPlcpPreambleDuration (payloadMode, preamble); //packet start time+ preamble
+ Time plcpHsigHeaderStart = plcpHeaderStart + WifiPhy::GetPlcpHeaderDuration (payloadMode, preamble);//packet start time+ preamble+L SIG
+ Time plcpHtTrainingSymbolsStart = plcpHsigHeaderStart + WifiPhy::GetPlcpHtSigHeaderDuration (payloadMode, preamble);//packet start time+ preamble+L SIG+HT SIG
+ Time plcpPayloadStart =plcpHtTrainingSymbolsStart + WifiPhy::GetPlcpHtTrainingSymbolDuration (preamble,event->GetTxVector()); //packet start time+ preamble+L SIG+HT SIG+Training
double noiseInterferenceW = (*j).GetDelta ();
double powerW = event->GetRxPowerW ();
j++;
--- a/src/wifi/model/wifi-mac-header.cc Sun Jan 04 09:43:20 2015 -0800
+++ b/src/wifi/model/wifi-mac-header.cc Sun Jan 04 10:13:34 2015 -0800
@@ -313,7 +313,7 @@
void
WifiMacHeader::SetDuration (Time duration)
{
- int64_t duration_us = duration.GetMicroSeconds ();
+ int64_t duration_us = ceil((double)duration.GetNanoSeconds ()/1000);
NS_ASSERT (duration_us >= 0 && duration_us <= 0x7fff);
m_duration = static_cast<uint16_t> (duration_us);
}
--- a/src/wifi/model/wifi-phy.cc Sun Jan 04 09:43:20 2015 -0800
+++ b/src/wifi/model/wifi-phy.cc Sun Jan 04 10:13:34 2015 -0800
@@ -131,8 +131,8 @@
}
}
-uint32_t
-WifiPhy::GetPlcpHtTrainingSymbolDurationMicroSeconds (WifiPreamble preamble, WifiTxVector txvector)
+Time
+WifiPhy::GetPlcpHtTrainingSymbolDuration (WifiPreamble preamble, WifiTxVector txvector)
{
uint8_t Ndltf, Neltf;
@@ -158,30 +158,30 @@
switch (preamble)
{
case WIFI_PREAMBLE_HT_MF:
- return 4 + (4 * Ndltf) + (4 * Neltf);
+ return MicroSeconds(4 + (4 * Ndltf) + (4 * Neltf));
case WIFI_PREAMBLE_HT_GF:
- return (4 * Ndltf) + (4 * Neltf);
+ return MicroSeconds((4 * Ndltf) + (4 * Neltf));
default:
// no training for non HT
- return 0;
+ return MicroSeconds(0);
}
}
//return L-SIG
-uint32_t
-WifiPhy::GetPlcpHtSigHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
+Time
+WifiPhy::GetPlcpHtSigHeaderDuration (WifiMode payloadMode, WifiPreamble preamble)
{
switch (preamble)
{
case WIFI_PREAMBLE_HT_MF:
// HT-SIG
- return 8;
+ return MicroSeconds(8);
case WIFI_PREAMBLE_HT_GF:
//HT-SIG
- return 8;
+ return MicroSeconds(8);
default:
// no HT-SIG for non HT
- return 0;
+ return MicroSeconds(0);
}
}
@@ -260,8 +260,8 @@
}
-uint32_t
-WifiPhy::GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
+Time
+WifiPhy::GetPlcpHeaderDuration (WifiMode payloadMode, WifiPreamble preamble)
{
switch (payloadMode.GetModulationClass ())
{
@@ -277,13 +277,13 @@
// 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 4;
+ 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 8;
+ 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 16;
+ return MicroSeconds(16);
}
}
//Added by Ghada to support 11n
@@ -293,38 +293,38 @@
{
case WIFI_PREAMBLE_HT_MF:
// L-SIG
- return 4;
+ return MicroSeconds(4);
case WIFI_PREAMBLE_HT_GF:
//L-SIG
- return 0;
+ return MicroSeconds(0);
default:
// L-SIG
- return 4;
+ return MicroSeconds(4);
}
}
case WIFI_MOD_CLASS_ERP_OFDM:
- return 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 24;
+ return MicroSeconds(24);
}
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 48;
+ return MicroSeconds(48);
}
default:
NS_FATAL_ERROR ("unsupported modulation class");
- return 0;
+ return MicroSeconds(0);
}
}
-uint32_t
-WifiPhy::GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
+Time
+WifiPhy::GetPlcpPreambleDuration (WifiMode payloadMode, WifiPreamble preamble)
{
switch (payloadMode.GetModulationClass ())
{
@@ -336,43 +336,43 @@
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 16;
+ 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 32;
+ 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 64;
+ return MicroSeconds(64);
}
}
case WIFI_MOD_CLASS_HT:
{ //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
- return 16;
+ return MicroSeconds(16);
}
case WIFI_MOD_CLASS_ERP_OFDM:
- return 16;
+ 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 72;
+ 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 144;
+ return MicroSeconds(144);
}
default:
NS_FATAL_ERROR ("unsupported modulation class");
- return 0;
+ return MicroSeconds(0);
}
}
-double
-WifiPhy::GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector, double frequency)
+Time
+WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txvector, double frequency)
{
WifiMode payloadMode=txvector.GetMode();
@@ -385,25 +385,25 @@
{
// (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)
- uint32_t symbolDurationUs;
+ Time symbolDuration;
switch (payloadMode.GetBandwidth ())
{
case 20000000:
default:
- symbolDurationUs = 4;
+ symbolDuration = MicroSeconds(4);
break;
case 10000000:
- symbolDurationUs = 8;
+ symbolDuration = MicroSeconds(8);
break;
case 5000000:
- symbolDurationUs = 16;
+ 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 () * symbolDurationUs / 1e6;
+ double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDuration.GetNanoSeconds() / 1e9;
// (Section 18.3.5.4 "Pad bits (PAD)" Equation 18-11; IEEE Std 802.11-2012)
uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
@@ -411,22 +411,22 @@
// Add signal extension for ERP PHY
if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
{
- return numSymbols * symbolDurationUs + 6;
+ return Time (numSymbols * symbolDuration) + MicroSeconds(6);
}
else
{
- return numSymbols * symbolDurationUs;
+ return Time (numSymbols * symbolDuration);
}
}
case WIFI_MOD_CLASS_HT:
{
- double symbolDurationUs;
+ 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" )
{
- symbolDurationUs=3.6;
+ symbolDuration = NanoSeconds(3600);
}
else
{
@@ -446,17 +446,17 @@
case 90000000:
case 120000000:
case 150000000:
- symbolDurationUs=3.6;
+ symbolDuration = NanoSeconds(3600);
break;
default:
- symbolDurationUs=4;
+ symbolDuration = MicroSeconds(4);
}
}
if (txvector.IsStbc())
m_Stbc=2;
else
m_Stbc=1;
- double numDataBitsPerSymbol = payloadMode.GetDataRate () *txvector.GetNss() * symbolDurationUs / 1e6;
+ 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)
@@ -464,11 +464,11 @@
if (frequency >= 2400 && frequency <= 2500) //at 2.4 GHz
{
- return (numSymbols * symbolDurationUs) + 6;
+ return Time (numSymbols * symbolDuration) + MicroSeconds(6);
}
else //at 5 GHz
{
- return (numSymbols * symbolDurationUs);
+ return Time (numSymbols * symbolDuration);
}
}
case WIFI_MOD_CLASS_DSSS:
@@ -476,24 +476,24 @@
NS_LOG_LOGIC (" size=" << size
<< " mode=" << payloadMode
<< " rate=" << payloadMode.GetDataRate () );
- return lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
+ return MicroSeconds (lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6))));
default:
NS_FATAL_ERROR ("unsupported modulation class");
- return 0;
+ return MicroSeconds (0);
}
}
Time
WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txvector, WifiPreamble preamble, double frequency)
{
- WifiMode payloadMode=txvector.GetMode();
- double duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)
- + GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)
- + GetPlcpHtSigHeaderDurationMicroSeconds (payloadMode, preamble)
- + GetPlcpHtTrainingSymbolDurationMicroSeconds (preamble, txvector)
- + GetPayloadDurationMicroSeconds (size, txvector, frequency);
- return NanoSeconds (duration*1000);
+ WifiMode payloadMode = txvector.GetMode ();
+ Time duration = GetPlcpPreambleDuration (payloadMode, preamble)
+ + GetPlcpHeaderDuration (payloadMode, preamble)
+ + GetPlcpHtSigHeaderDuration (payloadMode, preamble)
+ + GetPlcpHtTrainingSymbolDuration (preamble, txvector)
+ + GetPayloadDuration (size, txvector, frequency);
+ return duration;
}
--- a/src/wifi/model/wifi-phy.h Sun Jan 04 09:43:20 2015 -0800
+++ b/src/wifi/model/wifi-phy.h Sun Jan 04 10:13:34 2015 -0800
@@ -292,7 +292,7 @@
* \return the training symbol duration
*/
- static uint32_t GetPlcpHtTrainingSymbolDurationMicroSeconds (WifiPreamble preamble, WifiTxVector txvector);
+ static Time GetPlcpHtTrainingSymbolDuration (WifiPreamble preamble, WifiTxVector txvector);
/**
* \param payloadMode the WifiMode use for the transmission of the payload
* \param preamble the type of preamble
@@ -306,7 +306,7 @@
*
* \return the duration of the HT-SIG in Mixed Format and greenfield format PLCP header
*/
- static uint32_t GetPlcpHtSigHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
+ static Time GetPlcpHtSigHeaderDuration (WifiMode payloadMode, WifiPreamble preamble);
/**
* \param payloadMode the WifiMode use for the transmission of the payload
@@ -320,26 +320,26 @@
* \param payloadMode the WifiMode use for the transmission of the payload
* \param preamble the type of preamble
*
- * \return the duration of the PLCP header in microseconds
+ * \return the duration of the PLCP header
*/
- static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
+ static Time GetPlcpHeaderDuration (WifiMode payloadMode, WifiPreamble preamble);
/**
* \param payloadMode the WifiMode use for the transmission of the payload
* \param preamble the type of preamble
*
- * \return the duration of the PLCP preamble in microseconds
+ * \return the duration of the PLCP preamble
*/
- static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble 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 frequency the channel center frequency (MHz)
*
- * \return the duration of the payload in microseconds
+ * \return the duration of the payload
*/
- static double GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector, double frequency);
+ static Time GetPayloadDuration (uint32_t size, WifiTxVector txvector, double frequency);
/**
* The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
--- a/src/wifi/test/tx-duration-test.cc Sun Jan 04 09:43:20 2015 -0800
+++ b/src/wifi/test/tx-duration-test.cc Sun Jan 04 10:13:34 2015 -0800
@@ -89,7 +89,7 @@
{
testedFrequency = CHANNEL_36_MHZ;
}
- double calculatedDurationMicroSeconds = WifiPhy::GetPayloadDurationMicroSeconds (size, txVector, testedFrequency);
+ double calculatedDurationMicroSeconds = WifiPhy::GetPayloadDuration (size, txVector, testedFrequency).GetMicroSeconds();
if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
{
std::cerr << " size=" << size
@@ -103,7 +103,7 @@
{
// Durations vary depending on frequency; test also 2.4 GHz (bug 1971)
testedFrequency = CHANNEL_1_MHZ;
- calculatedDurationMicroSeconds = WifiPhy::GetPayloadDurationMicroSeconds (size, txVector, testedFrequency);
+ calculatedDurationMicroSeconds = WifiPhy::GetPayloadDuration (size, txVector, testedFrequency).GetMicroSeconds();
if (calculatedDurationMicroSeconds != knownDurationMicroSeconds + 6)
{
std::cerr << " size=" << size
@@ -244,10 +244,34 @@
retval = retval
&& CheckTxDuration (1536,WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,228)
&& CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,48)
- && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,40 )
+ && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,40)
+ && CheckTxDuration (1536,WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,220)
+ && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,40)
+ && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,32)
+ && CheckTxDuration (1536,WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,1746)
+ && CheckTxDuration (76, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,126)
+ && CheckTxDuration (14, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_MF,57.6)
+ && CheckTxDuration (1536,WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,1738)
+ && CheckTxDuration (76, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,118)
+ && CheckTxDuration (14, WifiPhy::GetOfdmRate7_2MbpsBW20MHz (), WIFI_PREAMBLE_HT_GF,49.6)
+ && CheckTxDuration (1536, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_MF,226.8)
+ && CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_MF,46.8)
+ && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_MF,39.6)
&& CheckTxDuration (1536, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,218.8)
&& CheckTxDuration (76, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,38.8)
- && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,31.6);
+ && CheckTxDuration (14, WifiPhy::GetOfdmRate65MbpsBW20MHzShGi (), WIFI_PREAMBLE_HT_GF,31.6)
+ && CheckTxDuration (1536,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,128)
+ && CheckTxDuration (76,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,44)
+ && CheckTxDuration (14,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,40)
+ && CheckTxDuration (1536,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,120)
+ && CheckTxDuration (76,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,36)
+ && CheckTxDuration (14,WifiPhy::GetOfdmRate135MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,32)
+ && CheckTxDuration (1536,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,118.8)
+ && CheckTxDuration (76,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,43.2)
+ && CheckTxDuration (14,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_MF,39.6)
+ && CheckTxDuration (1536,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,110.8)
+ && CheckTxDuration (76,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,35.2)
+ && CheckTxDuration (14,WifiPhy::GetOfdmRate150MbpsBW40MHz (), WIFI_PREAMBLE_HT_GF,31.6);
NS_TEST_EXPECT_MSG_EQ (retval, true, "an 802.11n duration failed");
}