--- a/CHANGES.html Sat May 07 22:05:29 2011 +0200
+++ b/CHANGES.html Mon May 09 22:03:43 2011 +0200
@@ -83,6 +83,16 @@
<h2>Changes to existing API:</h2>
<ul>
+<li><b>Wifi TX duration calculation moved from InterferenceHelper to WifiPhy</b>
+<p>The following static methods have been moved from the InterferenceHelper class to the WifiPhy class:
+ <pre>
+static Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble);
+static WifiMode GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
+static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
+static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
+static uint32_t GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode);
+</pre>
+</p></li>
<li><b>Test cases no longer return a boolean value</b>
<p>Unit test case DoRun() functions no longer return a bool value. Now, they don't return a value at all. The motivation for this change was to disallow users from merely returning "true" from a test case to force an error to be recorded. Instead, test case macros should be used.
</p></li>
--- a/src/wifi/model/interference-helper.cc Sat May 07 22:05:29 2011 +0200
+++ b/src/wifi/model/interference-helper.cc Mon May 09 22:03:43 2011 +0200
@@ -189,211 +189,6 @@
return end > now ? end - now : MicroSeconds (0);
}
-WifiMode
-InterferenceHelper::GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble)
-{
- switch (payloadMode.GetModulationClass ())
- {
- case WIFI_MOD_CLASS_OFDM:
- {
- switch (payloadMode.GetBandwidth ())
- {
- case 5000000:
- return WifiPhy::GetOfdmRate1_5MbpsBW5MHz ();
- case 10000000:
- return WifiPhy::GetOfdmRate3MbpsBW10MHz ();
- default:
- // IEEE Std 802.11-2007, 17.3.2
- // 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_ERP_OFDM:
- return WifiPhy::GetErpOfdmRate6Mbps ();
-
- case WIFI_MOD_CLASS_DSSS:
- if (preamble == WIFI_PREAMBLE_LONG)
- {
- // IEEE Std 802.11-2007, sections 15.2.3 and 18.2.2.1
- return WifiPhy::GetDsssRate1Mbps ();
- }
- else // WIFI_PREAMBLE_SHORT
- {
- // IEEE Std 802.11-2007, section 18.2.2.2
- return WifiPhy::GetDsssRate2Mbps ();
- }
-
- default:
- NS_FATAL_ERROR ("unsupported modulation class");
- return WifiMode ();
- }
-}
-
-uint32_t
-InterferenceHelper::GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
-{
- switch (payloadMode.GetModulationClass ())
- {
- case WIFI_MOD_CLASS_OFDM:
- {
- switch (payloadMode.GetBandwidth ())
- {
- case 20000000:
- default:
- // IEEE Std 802.11-2007, section 17.3.3 and figure 17-4
- // also section 17.3.2.3, table 17-4
- // We return the duration of the SIGNAL field only, since the
- // SERVICE field (which strictly speaking belongs to the PLCP
- // header, see section 17.3.2 and figure 17-1) is sent using the
- // payload mode.
- return 4;
- case 10000000:
- // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
- return 8;
- case 5000000:
- // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
- return 16;
- }
- }
-
- case WIFI_MOD_CLASS_ERP_OFDM:
- return 16;
-
- case WIFI_MOD_CLASS_DSSS:
- if (preamble == WIFI_PREAMBLE_SHORT)
- {
- // IEEE Std 802.11-2007, section 18.2.2.2 and figure 18-2
- return 24;
- }
- else // WIFI_PREAMBLE_LONG
- {
- // IEEE Std 802.11-2007, sections 18.2.2.1 and figure 18-1
- return 48;
- }
-
- default:
- NS_FATAL_ERROR ("unsupported modulation class");
- return 0;
- }
-}
-
-uint32_t
-InterferenceHelper::GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
-{
- switch (payloadMode.GetModulationClass ())
- {
- case WIFI_MOD_CLASS_OFDM:
- {
- switch (payloadMode.GetBandwidth ())
- {
- case 20000000:
- default:
- // IEEE Std 802.11-2007, section 17.3.3, figure 17-4
- // also section 17.3.2.3, table 17-4
- return 16;
- case 10000000:
- // IEEE Std 802.11-2007, section 17.3.3, table 17-4
- // also section 17.3.2.3, table 17-4
- return 32;
- case 5000000:
- // IEEE Std 802.11-2007, section 17.3.3
- // also section 17.3.2.3, table 17-4
- return 64;
- }
- }
-
- case WIFI_MOD_CLASS_ERP_OFDM:
- return 4;
-
- case WIFI_MOD_CLASS_DSSS:
- if (preamble == WIFI_PREAMBLE_SHORT)
- {
- // IEEE Std 802.11-2007, section 18.2.2.2 and figure 18-2
- return 72;
- }
- else // WIFI_PREAMBLE_LONG
- {
- // IEEE Std 802.11-2007, sections 18.2.2.1 and figure 18-1
- return 144;
- }
-
- default:
- NS_FATAL_ERROR ("unsupported modulation class");
- return 0;
- }
-}
-
-uint32_t
-InterferenceHelper::GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode)
-{
- NS_LOG_FUNCTION (size << payloadMode);
-
- switch (payloadMode.GetModulationClass ())
- {
- case WIFI_MOD_CLASS_OFDM:
- case WIFI_MOD_CLASS_ERP_OFDM:
- {
- // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
- // corresponds to T_{SYM} in the table
- uint32_t symbolDurationUs;
-
- switch (payloadMode.GetBandwidth ())
- {
- case 20000000:
- default:
- symbolDurationUs = 4;
- break;
- case 10000000:
- symbolDurationUs = 8;
- break;
- case 5000000:
- symbolDurationUs = 16;
- break;
- }
-
- // IEEE Std 802.11-2007, section 17.3.2.2, table 17-3
- // corresponds to N_{DBPS} in the table
- double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDurationUs / 1e6;
-
- // IEEE Std 802.11-2007, section 17.3.5.3, equation (17-11)
- uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
-
- // Add signal extension for ERP PHY
- if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
- {
- return numSymbols * symbolDurationUs + 6;
- }
- else
- {
- return numSymbols * symbolDurationUs;
- }
- }
-
- case WIFI_MOD_CLASS_DSSS:
- // IEEE Std 802.11-2007, section 18.2.3.5
- NS_LOG_LOGIC (" size=" << size
- << " mode=" << payloadMode
- << " rate=" << payloadMode.GetDataRate () );
- return lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
-
- default:
- NS_FATAL_ERROR ("unsupported modulation class");
- return 0;
- }
-}
-
-Time
-InterferenceHelper::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble)
-{
- uint32_t duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)
- + GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)
- + GetPayloadDurationMicroSeconds (size, payloadMode);
- return MicroSeconds (duration);
-}
-
void
InterferenceHelper::AppendEvent (Ptr<InterferenceHelper::Event> event)
{
@@ -470,9 +265,9 @@
Time previous = (*j).GetTime ();
WifiMode payloadMode = event->GetPayloadMode ();
WifiPreamble preamble = event->GetPreambleType ();
- WifiMode headerMode = GetPlcpHeaderMode (payloadMode, preamble);
- Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble));
- Time plcpPayloadStart = plcpHeaderStart + MicroSeconds (GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble));
+ WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (payloadMode, preamble);
+ Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (WifiPhy::GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble));
+ Time plcpPayloadStart = plcpHeaderStart + MicroSeconds (WifiPhy::GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble));
double noiseInterferenceW = (*j).GetDelta ();
double powerW = event->GetRxPowerW ();
--- a/src/wifi/model/interference-helper.h Sat May 07 22:05:29 2011 +0200
+++ b/src/wifi/model/interference-helper.h Mon May 09 22:03:43 2011 +0200
@@ -88,11 +88,6 @@
Time GetEnergyDuration (double energyW);
- static WifiMode GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
- static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
- static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode mode, WifiPreamble preamble);
- static uint32_t GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode);
- static Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble);
Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode,
enum WifiPreamble preamble,
Time duration, double rxPower);
--- a/src/wifi/model/wifi-phy.cc Sat May 07 22:05:29 2011 +0200
+++ b/src/wifi/model/wifi-phy.cc Mon May 09 22:03:43 2011 +0200
@@ -94,6 +94,213 @@
NS_LOG_FUNCTION (this);
}
+
+WifiMode
+WifiPhy::GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble)
+{
+ switch (payloadMode.GetModulationClass ())
+ {
+ case WIFI_MOD_CLASS_OFDM:
+ {
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 5000000:
+ return WifiPhy::GetOfdmRate1_5MbpsBW5MHz ();
+ case 10000000:
+ return WifiPhy::GetOfdmRate3MbpsBW10MHz ();
+ default:
+ // IEEE Std 802.11-2007, 17.3.2
+ // 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_ERP_OFDM:
+ return WifiPhy::GetErpOfdmRate6Mbps ();
+
+ case WIFI_MOD_CLASS_DSSS:
+ if (preamble == WIFI_PREAMBLE_LONG)
+ {
+ // IEEE Std 802.11-2007, sections 15.2.3 and 18.2.2.1
+ return WifiPhy::GetDsssRate1Mbps ();
+ }
+ else // WIFI_PREAMBLE_SHORT
+ {
+ // IEEE Std 802.11-2007, section 18.2.2.2
+ return WifiPhy::GetDsssRate2Mbps ();
+ }
+
+ default:
+ NS_FATAL_ERROR ("unsupported modulation class");
+ return WifiMode ();
+ }
+}
+
+uint32_t
+WifiPhy::GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
+{
+ switch (payloadMode.GetModulationClass ())
+ {
+ case WIFI_MOD_CLASS_OFDM:
+ {
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 20000000:
+ default:
+ // IEEE Std 802.11-2007, section 17.3.3 and figure 17-4
+ // also section 17.3.2.3, table 17-4
+ // We return the duration of the SIGNAL field only, since the
+ // SERVICE field (which strictly speaking belongs to the PLCP
+ // header, see section 17.3.2 and figure 17-1) is sent using the
+ // payload mode.
+ return 4;
+ case 10000000:
+ // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
+ return 8;
+ case 5000000:
+ // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
+ return 16;
+ }
+ }
+
+ case WIFI_MOD_CLASS_ERP_OFDM:
+ return 16;
+
+ case WIFI_MOD_CLASS_DSSS:
+ if (preamble == WIFI_PREAMBLE_SHORT)
+ {
+ // IEEE Std 802.11-2007, section 18.2.2.2 and figure 18-2
+ return 24;
+ }
+ else // WIFI_PREAMBLE_LONG
+ {
+ // IEEE Std 802.11-2007, sections 18.2.2.1 and figure 18-1
+ return 48;
+ }
+
+ default:
+ NS_FATAL_ERROR ("unsupported modulation class");
+ return 0;
+ }
+}
+
+uint32_t
+WifiPhy::GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
+{
+ switch (payloadMode.GetModulationClass ())
+ {
+ case WIFI_MOD_CLASS_OFDM:
+ {
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 20000000:
+ default:
+ // IEEE Std 802.11-2007, section 17.3.3, figure 17-4
+ // also section 17.3.2.3, table 17-4
+ return 16;
+ case 10000000:
+ // IEEE Std 802.11-2007, section 17.3.3, table 17-4
+ // also section 17.3.2.3, table 17-4
+ return 32;
+ case 5000000:
+ // IEEE Std 802.11-2007, section 17.3.3
+ // also section 17.3.2.3, table 17-4
+ return 64;
+ }
+ }
+
+ case WIFI_MOD_CLASS_ERP_OFDM:
+ return 4;
+
+ case WIFI_MOD_CLASS_DSSS:
+ if (preamble == WIFI_PREAMBLE_SHORT)
+ {
+ // IEEE Std 802.11-2007, section 18.2.2.2 and figure 18-2
+ return 72;
+ }
+ else // WIFI_PREAMBLE_LONG
+ {
+ // IEEE Std 802.11-2007, sections 18.2.2.1 and figure 18-1
+ return 144;
+ }
+
+ default:
+ NS_FATAL_ERROR ("unsupported modulation class");
+ return 0;
+ }
+}
+
+uint32_t
+WifiPhy::GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode)
+{
+ NS_LOG_FUNCTION (size << payloadMode);
+
+ switch (payloadMode.GetModulationClass ())
+ {
+ case WIFI_MOD_CLASS_OFDM:
+ case WIFI_MOD_CLASS_ERP_OFDM:
+ {
+ // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
+ // corresponds to T_{SYM} in the table
+ uint32_t symbolDurationUs;
+
+ switch (payloadMode.GetBandwidth ())
+ {
+ case 20000000:
+ default:
+ symbolDurationUs = 4;
+ break;
+ case 10000000:
+ symbolDurationUs = 8;
+ break;
+ case 5000000:
+ symbolDurationUs = 16;
+ break;
+ }
+
+ // IEEE Std 802.11-2007, section 17.3.2.2, table 17-3
+ // corresponds to N_{DBPS} in the table
+ double numDataBitsPerSymbol = payloadMode.GetDataRate () * symbolDurationUs / 1e6;
+
+ // IEEE Std 802.11-2007, section 17.3.5.3, equation (17-11)
+ uint32_t numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
+
+ // Add signal extension for ERP PHY
+ if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
+ {
+ return numSymbols * symbolDurationUs + 6;
+ }
+ else
+ {
+ return numSymbols * symbolDurationUs;
+ }
+ }
+
+ case WIFI_MOD_CLASS_DSSS:
+ // IEEE Std 802.11-2007, section 18.2.3.5
+ NS_LOG_LOGIC (" size=" << size
+ << " mode=" << payloadMode
+ << " rate=" << payloadMode.GetDataRate () );
+ return lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6)));
+
+ default:
+ NS_FATAL_ERROR ("unsupported modulation class");
+ return 0;
+ }
+}
+
+Time
+WifiPhy::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble)
+{
+ uint32_t duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)
+ + GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)
+ + GetPayloadDurationMicroSeconds (size, payloadMode);
+ return MicroSeconds (duration);
+}
+
+
void
WifiPhy::NotifyTxBegin (Ptr<const Packet> packet)
{
--- a/src/wifi/model/wifi-phy.h Sat May 07 22:05:29 2011 +0200
+++ b/src/wifi/model/wifi-phy.h Mon May 09 22:03:43 2011 +0200
@@ -239,10 +239,44 @@
* \param size the number of bytes in the packet to send
* \param payloadMode the transmission mode to use for this packet
* \param preamble the type of preamble to use for this packet.
- * \returns the total amount of time this PHY will stay busy for
+ * \return the total amount of time this PHY will stay busy for
* the transmission of these bytes.
*/
- virtual Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble) const = 0;
+ static Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble);
+
+ /**
+ * \param payloadMode the WifiMode use for the transmission of the payload
+ * \param preamble the type of preamble
+ *
+ * \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
+ *
+ * \return the duration of the PLCP header in microseconds
+ */
+ static uint32_t GetPlcpHeaderDurationMicroSeconds (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
+ */
+ static uint32_t GetPlcpPreambleDurationMicroSeconds (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 payload in microseconds
+ */
+ static uint32_t GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode);
/**
* The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
--- a/src/wifi/model/yans-wifi-phy.cc Sat May 07 22:05:29 2011 +0200
+++ b/src/wifi/model/yans-wifi-phy.cc Mon May 09 22:03:43 2011 +0200
@@ -717,12 +717,6 @@
return m_state->GetLastRxStartTime ();
}
-Time
-YansWifiPhy::CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble) const
-{
- return m_interference.CalculateTxDuration (size, payloadMode, preamble);
-}
-
double
YansWifiPhy::DbToRatio (double dB) const
{
--- a/src/wifi/model/yans-wifi-phy.h Sat May 07 22:05:29 2011 +0200
+++ b/src/wifi/model/yans-wifi-phy.h Mon May 09 22:03:43 2011 +0200
@@ -135,7 +135,6 @@
virtual Time GetStateDuration (void);
virtual Time GetDelayUntilIdle (void);
virtual Time GetLastRxStartTime (void) const;
- virtual Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble) const;
virtual uint32_t GetNModes (void) const;
virtual WifiMode GetMode (uint32_t mode) const;
virtual double CalculateSnr (WifiMode txMode, double ber) const;
--- a/src/wifi/test/interference-helper-tx-duration-test.cc Sat May 07 22:05:29 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2009 CTTC
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Nicola Baldo <nbaldo@cttc.es>
- */
-
-#include <ns3/object.h>
-#include <ns3/log.h>
-#include <ns3/test.h>
-#include <iostream>
-#include "ns3/interference-helper.h"
-#include "ns3/wifi-phy.h"
-
-NS_LOG_COMPONENT_DEFINE ("InterferenceHelperTxDurationTest");
-
-namespace ns3 {
-
-class InterferenceHelperTxDurationTest : public TestCase
-{
-public:
- InterferenceHelperTxDurationTest ();
- virtual ~InterferenceHelperTxDurationTest ();
- virtual void DoRun (void);
-
-private:
- /**
- * Check if the payload tx duration returned by InterferenceHelper
- * corresponds to a known value of the pay
- *
- * @param size size of payload in octets (includes everything after the PLCP header)
- * @param payloadMode the WifiMode used
- * @param knownPlcpLengthFieldValue the known value of the Length field in the PLCP header
- *
- * @return true if values correspond, false otherwise
- */
- bool CheckPayloadDuration (uint32_t size, WifiMode payloadMode, uint32_t knownDurationMicroSeconds);
-
- /**
- * Check if the overall tx duration returned by InterferenceHelper
- * corresponds to a known value of the pay
- *
- * @param size size of payload in octets (includes everything after the PLCP header)
- * @param payloadMode the WifiMode used
- * @param preamble the WifiPreamble used
- * @param knownPlcpLengthFieldValue the known value of the Length field in the PLCP header
- *
- * @return true if values correspond, false otherwise
- */
- bool CheckTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble, uint32_t knownDurationMicroSeconds);
-
-};
-
-
-InterferenceHelperTxDurationTest::InterferenceHelperTxDurationTest ()
- : TestCase ("InterferenceHelper TX Duration")
-{
-}
-
-
-InterferenceHelperTxDurationTest::~InterferenceHelperTxDurationTest ()
-{
-}
-
-bool
-InterferenceHelperTxDurationTest::CheckPayloadDuration (uint32_t size, WifiMode payloadMode, uint32_t knownDurationMicroSeconds)
-{
- uint32_t calculatedDurationMicroSeconds = InterferenceHelper::GetPayloadDurationMicroSeconds (size, payloadMode);
- if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
- {
- std::cerr << " size=" << size
- << " mode=" << payloadMode
- << " known=" << knownDurationMicroSeconds
- << " calculated=" << calculatedDurationMicroSeconds
- << std::endl;
- return false;
- }
- return true;
-}
-
-bool
-InterferenceHelperTxDurationTest::CheckTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble, uint32_t knownDurationMicroSeconds)
-{
- uint32_t calculatedDurationMicroSeconds = InterferenceHelper::CalculateTxDuration (size, payloadMode, preamble).GetMicroSeconds ();
- if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
- {
- std::cerr << " size=" << size
- << " mode=" << payloadMode
- << " preamble=" << preamble
- << " known=" << knownDurationMicroSeconds
- << " calculated=" << calculatedDurationMicroSeconds
- << std::endl;
- return false;
- }
- return true;
-}
-
-void
-InterferenceHelperTxDurationTest::DoRun (void)
-{
- bool retval = true;
-
- // IEEE Std 802.11-2007 Table 18-2 "Example of LENGTH calculations for CCK"
- retval = retval
- && CheckPayloadDuration (1023, WifiPhy::GetDsssRate11Mbps (), 744)
- && CheckPayloadDuration (1024, WifiPhy::GetDsssRate11Mbps (), 745)
- && CheckPayloadDuration (1025, WifiPhy::GetDsssRate11Mbps (), 746)
- && CheckPayloadDuration (1026, WifiPhy::GetDsssRate11Mbps (), 747);
-
-
- // Similar, but we add PLCP preamble and header durations
- // and we test different rates.
- // The payload durations for modes other than 11mbb have been
- // calculated by hand according to IEEE Std 802.11-2007 18.2.3.5
- retval = retval
- && CheckTxDuration (1023, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 744 + 96)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 745 + 96)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 746 + 96)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 747 + 96)
- && CheckTxDuration (1023, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 744 + 192)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 745 + 192)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 746 + 192)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 747 + 192)
- && CheckTxDuration (1023, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1488 + 96)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1490 + 96)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1491 + 96)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1493 + 96)
- && CheckTxDuration (1023, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1488 + 192)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1490 + 192)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1491 + 192)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1493 + 192)
- && CheckTxDuration (1023, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4092 + 96)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4096 + 96)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4100 + 96)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4104 + 96)
- && CheckTxDuration (1023, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4092 + 192)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4096 + 192)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4100 + 192)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4104 + 192)
- && CheckTxDuration (1023, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8184 + 96)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8192 + 96)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8200 + 96)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8208 + 96)
- && CheckTxDuration (1023, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8184 + 192)
- && CheckTxDuration (1024, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8192 + 192)
- && CheckTxDuration (1025, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8200 + 192)
- && CheckTxDuration (1026, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8208 + 192);
-
- // values from http://mailman.isi.edu/pipermail/ns-developers/2009-July/006226.html
- retval = retval && CheckTxDuration (14, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 304);
-
- // values from
- // http://www.oreillynet.com/pub/a/wireless/2003/08/08/wireless_throughput.html
- retval = retval
- && CheckTxDuration (1536, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 1310)
- && CheckTxDuration (76, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 248)
- && CheckTxDuration (14, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 203)
- && CheckTxDuration (1536, WifiPhy::GetOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 248)
- && CheckTxDuration (76, WifiPhy::GetOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 32)
- && CheckTxDuration (14, WifiPhy::GetOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 24);
-
- // 802.11g durations are same as 802.11a durations but with 6 us signal extension
- retval = retval
- && CheckTxDuration (1536, WifiPhy::GetErpOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 254)
- && CheckTxDuration (76, WifiPhy::GetErpOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 38)
- && CheckTxDuration (14, WifiPhy::GetErpOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 30);
-}
-
-class TxDurationTestSuite : public TestSuite
-{
-public:
- TxDurationTestSuite ();
-};
-
-TxDurationTestSuite::TxDurationTestSuite ()
- : TestSuite ("devices-wifi-tx-duration", UNIT)
-{
- AddTestCase (new InterferenceHelperTxDurationTest);
-}
-
-static TxDurationTestSuite g_txDurationTestSuite;
-} //namespace ns3
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/wifi/test/tx-duration-test.cc Mon May 09 22:03:43 2011 +0200
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 CTTC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Nicola Baldo <nbaldo@cttc.es>
+ */
+
+#include <ns3/object.h>
+#include <ns3/log.h>
+#include <ns3/test.h>
+#include <iostream>
+#include "ns3/interference-helper.h"
+#include "ns3/wifi-phy.h"
+
+NS_LOG_COMPONENT_DEFINE ("InterferenceHelperTxDurationTest");
+
+namespace ns3 {
+
+class TxDurationTest : public TestCase
+{
+public:
+ TxDurationTest ();
+ virtual ~TxDurationTest ();
+ virtual void DoRun (void);
+
+private:
+ /**
+ * Check if the payload tx duration returned by InterferenceHelper
+ * corresponds to a known value of the pay
+ *
+ * @param size size of payload in octets (includes everything after the PLCP header)
+ * @param payloadMode the WifiMode used
+ * @param knownPlcpLengthFieldValue the known value of the Length field in the PLCP header
+ *
+ * @return true if values correspond, false otherwise
+ */
+ bool CheckPayloadDuration (uint32_t size, WifiMode payloadMode, uint32_t knownDurationMicroSeconds);
+
+ /**
+ * Check if the overall tx duration returned by InterferenceHelper
+ * corresponds to a known value of the pay
+ *
+ * @param size size of payload in octets (includes everything after the PLCP header)
+ * @param payloadMode the WifiMode used
+ * @param preamble the WifiPreamble used
+ * @param knownPlcpLengthFieldValue the known value of the Length field in the PLCP header
+ *
+ * @return true if values correspond, false otherwise
+ */
+ bool CheckTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble, uint32_t knownDurationMicroSeconds);
+
+};
+
+
+TxDurationTest::TxDurationTest ()
+ : TestCase ("Wifi TX Duration")
+{
+}
+
+
+TxDurationTest::~TxDurationTest ()
+{
+}
+
+bool
+TxDurationTest::CheckPayloadDuration (uint32_t size, WifiMode payloadMode, uint32_t knownDurationMicroSeconds)
+{
+ uint32_t calculatedDurationMicroSeconds = WifiPhy::GetPayloadDurationMicroSeconds (size, payloadMode);
+ if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
+ {
+ std::cerr << " size=" << size
+ << " mode=" << payloadMode
+ << " known=" << knownDurationMicroSeconds
+ << " calculated=" << calculatedDurationMicroSeconds
+ << std::endl;
+ return false;
+ }
+ return true;
+}
+
+bool
+TxDurationTest::CheckTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble, uint32_t knownDurationMicroSeconds)
+{
+ uint32_t calculatedDurationMicroSeconds = WifiPhy::CalculateTxDuration (size, payloadMode, preamble).GetMicroSeconds ();
+ if (calculatedDurationMicroSeconds != knownDurationMicroSeconds)
+ {
+ std::cerr << " size=" << size
+ << " mode=" << payloadMode
+ << " preamble=" << preamble
+ << " known=" << knownDurationMicroSeconds
+ << " calculated=" << calculatedDurationMicroSeconds
+ << std::endl;
+ return false;
+ }
+ return true;
+}
+
+void
+TxDurationTest::DoRun (void)
+{
+ bool retval = true;
+
+ // IEEE Std 802.11-2007 Table 18-2 "Example of LENGTH calculations for CCK"
+ retval = retval
+ && CheckPayloadDuration (1023, WifiPhy::GetDsssRate11Mbps (), 744)
+ && CheckPayloadDuration (1024, WifiPhy::GetDsssRate11Mbps (), 745)
+ && CheckPayloadDuration (1025, WifiPhy::GetDsssRate11Mbps (), 746)
+ && CheckPayloadDuration (1026, WifiPhy::GetDsssRate11Mbps (), 747);
+
+
+ // Similar, but we add PLCP preamble and header durations
+ // and we test different rates.
+ // The payload durations for modes other than 11mbb have been
+ // calculated by hand according to IEEE Std 802.11-2007 18.2.3.5
+ retval = retval
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 744 + 96)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 745 + 96)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 746 + 96)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_SHORT, 747 + 96)
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 744 + 192)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 745 + 192)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 746 + 192)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 747 + 192)
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1488 + 96)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1490 + 96)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1491 + 96)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_SHORT, 1493 + 96)
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1488 + 192)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1490 + 192)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1491 + 192)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate5_5Mbps (), WIFI_PREAMBLE_LONG, 1493 + 192)
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4092 + 96)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4096 + 96)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4100 + 96)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_SHORT, 4104 + 96)
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4092 + 192)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4096 + 192)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4100 + 192)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate2Mbps (), WIFI_PREAMBLE_LONG, 4104 + 192)
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8184 + 96)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8192 + 96)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8200 + 96)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_SHORT, 8208 + 96)
+ && CheckTxDuration (1023, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8184 + 192)
+ && CheckTxDuration (1024, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8192 + 192)
+ && CheckTxDuration (1025, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8200 + 192)
+ && CheckTxDuration (1026, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 8208 + 192);
+
+ // values from http://mailman.isi.edu/pipermail/ns-developers/2009-July/006226.html
+ retval = retval && CheckTxDuration (14, WifiPhy::GetDsssRate1Mbps (), WIFI_PREAMBLE_LONG, 304);
+
+ // values from
+ // http://www.oreillynet.com/pub/a/wireless/2003/08/08/wireless_throughput.html
+ retval = retval
+ && CheckTxDuration (1536, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 1310)
+ && CheckTxDuration (76, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 248)
+ && CheckTxDuration (14, WifiPhy::GetDsssRate11Mbps (), WIFI_PREAMBLE_LONG, 203)
+ && CheckTxDuration (1536, WifiPhy::GetOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 248)
+ && CheckTxDuration (76, WifiPhy::GetOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 32)
+ && CheckTxDuration (14, WifiPhy::GetOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 24);
+
+ // 802.11g durations are same as 802.11a durations but with 6 us signal extension
+ retval = retval
+ && CheckTxDuration (1536, WifiPhy::GetErpOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 254)
+ && CheckTxDuration (76, WifiPhy::GetErpOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 38)
+ && CheckTxDuration (14, WifiPhy::GetErpOfdmRate54Mbps (), WIFI_PREAMBLE_LONG, 30);
+}
+
+class TxDurationTestSuite : public TestSuite
+{
+public:
+ TxDurationTestSuite ();
+};
+
+TxDurationTestSuite::TxDurationTestSuite ()
+ : TestSuite ("devices-wifi-tx-duration", UNIT)
+{
+ AddTestCase (new TxDurationTest);
+}
+
+static TxDurationTestSuite g_txDurationTestSuite;
+} //namespace ns3
+
--- a/src/wifi/wscript Sat May 07 22:05:29 2011 +0200
+++ b/src/wifi/wscript Mon May 09 22:03:43 2011 +0200
@@ -71,7 +71,7 @@
obj_test.source = [
'test/block-ack-test-suite.cc',
'test/dcf-manager-test.cc',
- 'test/interference-helper-tx-duration-test.cc',
+ 'test/tx-duration-test.cc',
'test/wifi-test.cc',
]