--- a/CHANGES.html Mon Jul 13 14:30:12 2009 +0200
+++ b/CHANGES.html Wed Jul 15 13:06:11 2009 +0200
@@ -44,6 +44,39 @@
us a note on ns-developers mailing list. </p>
<hr>
+<h1>Changes from ns-3.5 to ns-3.6</h1>
+
+<h2>Changes to build system:</h2>
+<ul>
+</ul>
+
+<h2>New API:</h2>
+<ul>
+</ul>
+
+<h2>Changes to existing API:</h2>
+<ul>
+<li><b>InterferenceHelper</b>
+<p>The method InterferenceHelper::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble) has been made static, so that the frame duration depends only on the characteristics of the frame (i.e., the function parameters) and not on the particular standard which is used by the receiving PHY. This makes it now possible to correctly calculate the duration of incoming frames in scenarios in which devices using different PHY configurations coexist in the same channel (e.g., a BSS using short preamble and another BSS using long preamble). </p>
+<p> The following member methods have been added to InterferenceHelper:</p>
+<pre>
+ static WifiMode GetPlcpHeaderMode (WifiMode, WifiPreamble);
+ static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode, WifiPreamble);
+ static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode, WifiPreamble);
+ static uint32_t GetPayloadDurationMicroSeconds (size, WifiMode); </pre>
+<p> The following member methods have been removed from InterferenceHelper:</p>
+<pre>
+ void Configure80211aParameters (void);
+ void Configure80211bParameters (void);
+ void Configure80211_10MhzParameters (void);
+ void Configure80211_5MhzParameters (void);</pre>
+</li>
+<li><b>WifiMode</b>
+<p>WifiMode now has a WifiPhyStandard attribute which identifies the standard the WifiMode belongs to. To properly set this attribute when creating a new WifiMode, it is now required to explicitly pass a WifiPhyStandard parameter to all WifiModeFactory::CreateXXXX() methods. The WifiPhyStandard value of an existing WifiMode can be retrieved using the new method WifiMode::GetStandard().</p>
+</li>
+</ul>
+
+<hr>
<h1>Changes from ns-3.4 to ns-3.5</h1>
<h2>Changes to build system:</h2>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/interference-helper-tx-duration-test.cc Wed Jul 15 13:06:11 2009 +0200
@@ -0,0 +1,193 @@
+/* -*- 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"interference-helper.h"
+#include"wifi-phy.h"
+
+NS_LOG_COMPONENT_DEFINE ("InterferenceHelperTxDurationTest");
+
+
+#ifdef RUN_SELF_TESTS
+
+
+namespace ns3 {
+
+class InterferenceHelperTxDurationTest : public Test {
+public:
+ InterferenceHelperTxDurationTest ();
+ virtual ~InterferenceHelperTxDurationTest ();
+ virtual bool RunTests (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);
+
+};
+
+
+// we need to create one instance of InterferenceHelperTxDurationTest
+static InterferenceHelperTxDurationTest interferenceHelperTxDurationTestInstance;
+
+
+InterferenceHelperTxDurationTest::InterferenceHelperTxDurationTest ()
+ : Test ("InterferenceHelperTxDuration")
+{
+}
+
+
+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;
+}
+
+bool
+InterferenceHelperTxDurationTest::RunTests (void)
+{
+ bool retval = true;
+
+ // IEEE Std 802.11-2007 Table 18-2 "Example of LENGTH calculations for CCK"
+ retval = retval
+ && CheckPayloadDuration (1023, WifiPhy::Get11mbb (), 744)
+ && CheckPayloadDuration (1024, WifiPhy::Get11mbb (), 745)
+ && CheckPayloadDuration (1025, WifiPhy::Get11mbb (), 746)
+ && CheckPayloadDuration (1026, WifiPhy::Get11mbb (), 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::Get11mbb (), WIFI_PREAMBLE_SHORT, 744 + 96)
+ && CheckTxDuration (1024, WifiPhy::Get11mbb (), WIFI_PREAMBLE_SHORT, 745 + 96)
+ && CheckTxDuration (1025, WifiPhy::Get11mbb (), WIFI_PREAMBLE_SHORT, 746 + 96)
+ && CheckTxDuration (1026, WifiPhy::Get11mbb (), WIFI_PREAMBLE_SHORT, 747 + 96)
+ && CheckTxDuration (1023, WifiPhy::Get11mbb (), WIFI_PREAMBLE_LONG, 744 + 192)
+ && CheckTxDuration (1024, WifiPhy::Get11mbb (), WIFI_PREAMBLE_LONG, 745 + 192)
+ && CheckTxDuration (1025, WifiPhy::Get11mbb (), WIFI_PREAMBLE_LONG, 746 + 192)
+ && CheckTxDuration (1026, WifiPhy::Get11mbb (), WIFI_PREAMBLE_LONG, 747 + 192)
+ && CheckTxDuration (1023, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_SHORT, 1488 + 96)
+ && CheckTxDuration (1024, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_SHORT, 1490 + 96)
+ && CheckTxDuration (1025, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_SHORT, 1491 + 96)
+ && CheckTxDuration (1026, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_SHORT, 1493 + 96)
+ && CheckTxDuration (1023, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_LONG, 1488 + 192)
+ && CheckTxDuration (1024, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_LONG, 1490 + 192)
+ && CheckTxDuration (1025, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_LONG, 1491 + 192)
+ && CheckTxDuration (1026, WifiPhy::Get5_5mbb (), WIFI_PREAMBLE_LONG, 1493 + 192)
+ && CheckTxDuration (1023, WifiPhy::Get2mbb (), WIFI_PREAMBLE_SHORT, 4092 + 96)
+ && CheckTxDuration (1024, WifiPhy::Get2mbb (), WIFI_PREAMBLE_SHORT, 4096 + 96)
+ && CheckTxDuration (1025, WifiPhy::Get2mbb (), WIFI_PREAMBLE_SHORT, 4100 + 96)
+ && CheckTxDuration (1026, WifiPhy::Get2mbb (), WIFI_PREAMBLE_SHORT, 4104 + 96)
+ && CheckTxDuration (1023, WifiPhy::Get2mbb (), WIFI_PREAMBLE_LONG, 4092 + 192)
+ && CheckTxDuration (1024, WifiPhy::Get2mbb (), WIFI_PREAMBLE_LONG, 4096 + 192)
+ && CheckTxDuration (1025, WifiPhy::Get2mbb (), WIFI_PREAMBLE_LONG, 4100 + 192)
+ && CheckTxDuration (1026, WifiPhy::Get2mbb (), WIFI_PREAMBLE_LONG, 4104 + 192)
+ && CheckTxDuration (1023, WifiPhy::Get1mbb (), WIFI_PREAMBLE_SHORT, 8184 + 96)
+ && CheckTxDuration (1024, WifiPhy::Get1mbb (), WIFI_PREAMBLE_SHORT, 8192 + 96)
+ && CheckTxDuration (1025, WifiPhy::Get1mbb (), WIFI_PREAMBLE_SHORT, 8200 + 96)
+ && CheckTxDuration (1026, WifiPhy::Get1mbb (), WIFI_PREAMBLE_SHORT, 8208 + 96)
+ && CheckTxDuration (1023, WifiPhy::Get1mbb (), WIFI_PREAMBLE_LONG, 8184 + 192)
+ && CheckTxDuration (1024, WifiPhy::Get1mbb (), WIFI_PREAMBLE_LONG, 8192 + 192)
+ && CheckTxDuration (1025, WifiPhy::Get1mbb (), WIFI_PREAMBLE_LONG, 8200 + 192)
+ && CheckTxDuration (1026, WifiPhy::Get1mbb (), WIFI_PREAMBLE_LONG, 8208 + 192);
+
+ // values from http://mailman.isi.edu/pipermail/ns-developers/2009-July/006226.html
+ retval = retval && CheckTxDuration (14, WifiPhy::Get1mbb (), WIFI_PREAMBLE_LONG, 304);
+
+ // values from
+ // http://www.oreillynet.com/pub/a/wireless/2003/08/08/wireless_throughput.html
+ retval = retval
+ && CheckTxDuration (1536, WifiPhy::Get11mbb (), WIFI_PREAMBLE_LONG, 1310)
+ && CheckTxDuration (76, WifiPhy::Get11mbb (), WIFI_PREAMBLE_LONG, 248)
+ && CheckTxDuration (14, WifiPhy::Get11mbb (), WIFI_PREAMBLE_LONG, 203)
+ && CheckTxDuration (1536, WifiPhy::Get54mba (), WIFI_PREAMBLE_LONG, 248)
+ && CheckTxDuration (76, WifiPhy::Get54mba (), WIFI_PREAMBLE_LONG, 32)
+ && CheckTxDuration (14, WifiPhy::Get54mba (), WIFI_PREAMBLE_LONG, 24);
+
+
+ return retval;
+}
+
+
+} //namespace ns3
+
+
+#endif /* RUN_SELF_TESTS */
--- a/src/devices/wifi/interference-helper.cc Mon Jul 13 14:30:12 2009 +0200
+++ b/src/devices/wifi/interference-helper.cc Wed Jul 15 13:06:11 2009 +0200
@@ -123,8 +123,8 @@
****************************************************************/
InterferenceHelper::InterferenceHelper ()
- : m_80211_standard (WIFI_PHY_STANDARD_80211a),
- m_errorRateModel (0)
+ : m_maxPacketDuration (Seconds(0)),
+ m_errorRateModel (0)
{}
InterferenceHelper::~InterferenceHelper ()
{
@@ -145,6 +145,7 @@
duration,
rxPowerW);
+ m_maxPacketDuration = std::max(duration, m_maxPacketDuration);
AppendEvent (event);
return event;
}
@@ -224,97 +225,183 @@
return end - now;
}
-Time
-InterferenceHelper::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble) const
+WifiMode
+InterferenceHelper::GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble)
{
- uint64_t delay = 0;
- switch (m_80211_standard)
- {
+ switch (payloadMode.GetStandard ())
+ {
+ case WIFI_PHY_STANDARD_holland:
case WIFI_PHY_STANDARD_80211a:
- case WIFI_PHY_STANDARD_holland:
- delay += m_plcpLongPreambleDelayUs;
- // symbol duration is 4us
- delay += 4;
- delay += lrint (ceil ((size * 8.0 + 16.0 + 6.0) / payloadMode.GetDataRate () / 4e-6) * 4);
- break;
+ // 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::Get6mba ();
+
case WIFI_PHY_STANDARD_80211b:
- delay += m_plcpLongPreambleDelayUs;
- delay += lrint (ceil ((size * 8.0 + 48.0) / payloadMode.GetDataRate () / 4e-6) * 4);
- break;
- case WIFI_PHY_STANDARD_80211_10Mhz:
- delay += m_plcpLongPreambleDelayUs;
- // symbol duration is 8us
- delay += 8;
- delay += lrint (ceil ((size * 8.0 + 16.0 + 6.0) / payloadMode.GetDataRate () / 8e-6) * 8);
- break;
- case WIFI_PHY_STANDARD_80211_5Mhz:
- delay += m_plcpLongPreambleDelayUs;
- // symbol duration is 16us
- delay += 16;
- delay += lrint (ceil ((size * 8.0 + 16.0 + 6.0) / payloadMode.GetDataRate () / 1.6e-5) * 16);
- break;
+ if (preamble == WIFI_PREAMBLE_LONG)
+ {
+ // IEEE Std 802.11-2007, sections 15.2.3 and 18.2.2.1
+ return WifiPhy::Get1mbb ();
+ }
+ else // WIFI_PREAMBLE_SHORT
+ {
+ // IEEE Std 802.11-2007, section 18.2.2.2
+ return WifiPhy::Get2mbb ();
+ }
+
+ case WIFI_PHY_STANDARD_80211_10Mhz:
+ return WifiPhy::Get3mb10Mhz ();
+
+ case WIFI_PHY_STANDARD_80211_5Mhz:
+ return WifiPhy::Get1_5mb5Mhz ();
+
default:
- NS_ASSERT (false);
- break;
- }
+ NS_FATAL_ERROR("unknown standard");
+ return WifiMode ();
+ }
+}
- return MicroSeconds (delay);
+uint32_t
+InterferenceHelper::GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
+{
+ switch (payloadMode.GetStandard ())
+ {
+ case WIFI_PHY_STANDARD_holland:
+ case WIFI_PHY_STANDARD_80211a:
+ // 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 WIFI_PHY_STANDARD_80211_10Mhz:
+ // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
+ return 8;
+
+ case WIFI_PHY_STANDARD_80211_5Mhz:
+ // IEEE Std 802.11-2007, section 17.3.2.3, table 17-4
+ return 16;
+
+ case WIFI_PHY_STANDARD_80211b:
+ 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("unknown standard");
+ return 0;
+ }
+
}
-void
-InterferenceHelper::Configure80211aParameters (void)
+uint32_t
+InterferenceHelper::GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble)
{
- NS_LOG_FUNCTION (this);
- m_80211_standard = WIFI_PHY_STANDARD_80211a;
- m_plcpLongPreambleDelayUs = 16;
- m_plcpShortPreambleDelayUs = 16;
- m_longPlcpHeaderMode = WifiPhy::Get6mba ();
- m_shortPlcpHeaderMode = WifiPhy::Get6mba ();
- m_plcpHeaderLength = 4 + 1 + 12 + 1 + 6;
- /* 4095 bytes at a 6Mb/s rate with a 1/2 coding rate. */
- m_maxPacketDuration = CalculateTxDuration (4095, WifiPhy::Get6mba (), WIFI_PREAMBLE_LONG);
+ switch (payloadMode.GetStandard ())
+ {
+ case WIFI_PHY_STANDARD_holland:
+ case WIFI_PHY_STANDARD_80211a:
+ // IEEE Std 802.11-2007, section 17.3.3, figure 17-4
+ // also section 17.3.2.3, table 17-4
+ return 16;
+
+ case WIFI_PHY_STANDARD_80211_10Mhz:
+ // IEEE Std 802.11-2007, section 17.3.3, table 17-4
+ // also section 17.3.2.3, table 17-4
+ return 32;
+
+ case WIFI_PHY_STANDARD_80211_5Mhz:
+ // IEEE Std 802.11-2007, section 17.3.3
+ // also section 17.3.2.3, table 17-4
+ return 64;
+
+ case WIFI_PHY_STANDARD_80211b:
+ 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("unknown standard");
+ return 0;
+ }
}
-void
-InterferenceHelper::Configure80211bParameters (void)
-{
- NS_LOG_FUNCTION (this);
- m_80211_standard = WIFI_PHY_STANDARD_80211b;
- m_plcpLongPreambleDelayUs = 144;
- m_plcpShortPreambleDelayUs = 144; // fixed preamable for 802.11b
- m_longPlcpHeaderMode = WifiPhy::Get1mbb ();
- m_shortPlcpHeaderMode = WifiPhy::Get1mbb ();
- // PLCP Header: signal 8, service 8, length 16, CRC 16 bits
- m_plcpHeaderLength = 8 + 8 + 16 + 16;
- m_maxPacketDuration = CalculateTxDuration (4095, WifiPhy::Get1mbb (), WIFI_PREAMBLE_LONG);
+uint32_t
+InterferenceHelper::GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode)
+{
+ NS_LOG_FUNCTION(size << payloadMode);
+ switch (payloadMode.GetStandard ())
+ {
+ case WIFI_PHY_STANDARD_80211a:
+ case WIFI_PHY_STANDARD_holland:
+ case WIFI_PHY_STANDARD_80211_10Mhz:
+ case WIFI_PHY_STANDARD_80211_5Mhz:
+ {
+ // 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.GetStandard ())
+ {
+ case WIFI_PHY_STANDARD_holland:
+ case WIFI_PHY_STANDARD_80211a:
+ symbolDurationUs = 4;
+ break;
+ case WIFI_PHY_STANDARD_80211_10Mhz:
+ symbolDurationUs = 8;
+ break;
+ case WIFI_PHY_STANDARD_80211_5Mhz:
+ symbolDurationUs = 16;
+ break;
+ default:
+ NS_FATAL_ERROR("unknown standard");
+ }
+
+ // 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 = ceil ((16 + size * 8.0 + 6.0)/numDataBitsPerSymbol);
+
+ return numSymbols*symbolDurationUs;
+ }
+ case WIFI_PHY_STANDARD_80211b:
+ // IEEE Std 802.11-2007, section 18.2.3.5
+ NS_LOG_LOGIC(" size=" << size
+ << " mode=" << payloadMode
+ << " rate=" << payloadMode.GetDataRate () );
+ return ceil ((size * 8.0) / (payloadMode.GetDataRate () / 1.0e6));
+
+ default:
+ NS_FATAL_ERROR("unknown standard");
+ return 0;
+ }
}
-void
-InterferenceHelper::Configure80211_10MhzParameters (void)
+Time
+InterferenceHelper::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble)
{
- NS_LOG_FUNCTION (this);
- m_80211_standard = WIFI_PHY_STANDARD_80211_10Mhz;
- m_plcpLongPreambleDelayUs = 32;
- m_plcpShortPreambleDelayUs = 32;
- m_longPlcpHeaderMode = WifiPhy::Get3mb10Mhz ();
- m_shortPlcpHeaderMode = WifiPhy::Get3mb10Mhz ();
- m_plcpHeaderLength = 4 + 1 + 12 + 1 + 6;
- /* 4095 bytes at a 3Mb/s rate with a 1/2 coding rate. */
- m_maxPacketDuration = CalculateTxDuration (4095, WifiPhy::Get3mb10Mhz (), WIFI_PREAMBLE_LONG);
-}
-
-void
-InterferenceHelper::Configure80211_5MhzParameters (void)
-{
- NS_LOG_FUNCTION (this);
- m_80211_standard = WIFI_PHY_STANDARD_80211_5Mhz;
- m_plcpLongPreambleDelayUs = 64;
- m_plcpShortPreambleDelayUs = 64;
- m_longPlcpHeaderMode = WifiPhy::Get1_5mb5Mhz ();
- m_shortPlcpHeaderMode = WifiPhy::Get1_5mb5Mhz ();
- m_plcpHeaderLength = 4 + 1 + 12 + 1 + 6;
- /* 4095 bytes at a 1.5Mb/s rate with a 1/2 coding rate. */
- m_maxPacketDuration = CalculateTxDuration (4095, WifiPhy::Get1_5mb5Mhz (), WIFI_PREAMBLE_LONG);
+ uint32_t duration = GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble)
+ + GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble)
+ + GetPayloadDurationMicroSeconds (size, payloadMode);
+ return MicroSeconds (duration);
}
void
@@ -407,29 +494,12 @@
{
double psr = 1.0; /* Packet Success Rate */
NiChanges::iterator j = ni->begin ();
- Time previous = (*j).GetTime ();
- uint64_t plcpPreambleDelayUs;
+ Time previous = (*j).GetTime ();
WifiMode payloadMode = event->GetPayloadMode ();
- WifiMode headerMode;
- switch (event->GetPreambleType ()) {
- case WIFI_PREAMBLE_LONG:
- plcpPreambleDelayUs = m_plcpLongPreambleDelayUs;
- headerMode = m_longPlcpHeaderMode;
- break;
- case WIFI_PREAMBLE_SHORT:
- plcpPreambleDelayUs = m_plcpShortPreambleDelayUs;
- headerMode = m_shortPlcpHeaderMode;
- break;
- default:
- NS_ASSERT (false);
- // only to quiet compiler. Really stupid.
- plcpPreambleDelayUs = 0;
- headerMode = m_shortPlcpHeaderMode;
- break;
- }
- Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (plcpPreambleDelayUs);
- Time plcpPayloadStart = plcpHeaderStart +
- Seconds ((m_plcpHeaderLength + 0.0) / headerMode.GetDataRate ());
+ WifiPreamble preamble = event->GetPreambleType ();
+ WifiMode headerMode = GetPlcpHeaderMode (payloadMode, preamble);
+ Time plcpHeaderStart = (*j).GetTime () + MicroSeconds (GetPlcpPreambleDurationMicroSeconds (payloadMode, preamble));
+ Time plcpPayloadStart = plcpHeaderStart + MicroSeconds (GetPlcpHeaderDurationMicroSeconds (payloadMode, preamble));
double noiseInterferenceW = (*j).GetDelta ();
double powerW = event->GetRxPowerW ();
--- a/src/devices/wifi/interference-helper.h Mon Jul 13 14:30:12 2009 +0200
+++ b/src/devices/wifi/interference-helper.h Wed Jul 15 13:06:11 2009 +0200
@@ -69,10 +69,6 @@
InterferenceHelper ();
~InterferenceHelper ();
- void Configure80211aParameters (void);
- void Configure80211bParameters (void);
- void Configure80211_10MhzParameters (void);
- void Configure80211_5MhzParameters (void);
void SetNoiseFigure (double value);
void SetErrorRateModel (Ptr<ErrorRateModel> rate);
@@ -87,7 +83,13 @@
* the requested threshold.
*/
Time GetEnergyDuration (double energyW);
- Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble) const;
+
+
+ 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);
@@ -116,15 +118,9 @@
double CalculatePer (Ptr<const Event> event, NiChanges *ni) const;
Time GetMaxPacketDuration (void) const;
- uint64_t m_plcpLongPreambleDelayUs;
- uint64_t m_plcpShortPreambleDelayUs;
- WifiMode m_longPlcpHeaderMode;
- WifiMode m_shortPlcpHeaderMode;
- uint32_t m_plcpHeaderLength;
Time m_maxPacketDuration;
double m_noiseFigure; /**< noise figure (linear) */
Events m_events;
- enum WifiPhyStandard m_80211_standard;
Ptr<ErrorRateModel> m_errorRateModel;
};
--- a/src/devices/wifi/wifi-mode.cc Mon Jul 13 14:30:12 2009 +0200
+++ b/src/devices/wifi/wifi-mode.cc Wed Jul 15 13:06:11 2009 +0200
@@ -107,6 +107,12 @@
{
return m_uid;
}
+enum WifiPhyStandard
+WifiMode::GetStandard () const
+{
+ struct WifiModeFactory::WifiModeItem *item = WifiModeFactory::GetFactory ()->Get (m_uid);
+ return item->standard;
+}
WifiMode::WifiMode ()
: m_uid (0)
{}
@@ -131,7 +137,8 @@
bool isMandatory,
uint32_t bandwidth,
uint32_t dataRate,
- uint32_t phyRate)
+ uint32_t phyRate,
+ enum WifiPhyStandard standard)
{
WifiModeFactory *factory = GetFactory ();
uint32_t uid = factory->AllocateUid (uniqueName);
@@ -143,6 +150,7 @@
item->modulation = WifiMode::BPSK;
item->constellationSize = 2;
item->isMandatory = isMandatory;
+ item->standard = standard;
return WifiMode (uid);
}
WifiMode
@@ -151,7 +159,8 @@
uint32_t bandwidth,
uint32_t dataRate,
uint32_t phyRate,
- uint8_t constellationSize)
+ uint8_t constellationSize,
+ enum WifiPhyStandard standard)
{
WifiModeFactory *factory = GetFactory ();
uint32_t uid = factory->AllocateUid (uniqueName);
@@ -163,6 +172,7 @@
item->modulation = WifiMode::QAM;
item->constellationSize = constellationSize;
item->isMandatory = isMandatory;
+ item->standard = standard;
return WifiMode (uid);
}
WifiMode
@@ -170,7 +180,8 @@
bool isMandatory,
uint32_t bandwidth,
uint32_t dataRate,
- uint32_t phyRate)
+ uint32_t phyRate,
+ enum WifiPhyStandard standard)
{
WifiModeFactory *factory = GetFactory ();
uint32_t uid = factory->AllocateUid (uniqueName);
@@ -182,6 +193,7 @@
item->modulation = WifiMode::DBPSK;
item->constellationSize = 2;
item->isMandatory = isMandatory;
+ item->standard = standard;
return WifiMode (uid);
}
WifiMode
@@ -189,7 +201,8 @@
bool isMandatory,
uint32_t bandwidth,
uint32_t dataRate,
- uint32_t phyRate)
+ uint32_t phyRate,
+ enum WifiPhyStandard standard)
{
WifiModeFactory *factory = GetFactory ();
uint32_t uid = factory->AllocateUid (uniqueName);
@@ -201,6 +214,7 @@
item->modulation = WifiMode::DQPSK;
item->constellationSize = 4;
item->isMandatory = isMandatory;
+ item->standard = standard;
return WifiMode (uid);
}
bool
--- a/src/devices/wifi/wifi-mode.h Mon Jul 13 14:30:12 2009 +0200
+++ b/src/devices/wifi/wifi-mode.h Wed Jul 15 13:06:11 2009 +0200
@@ -25,6 +25,7 @@
#include <vector>
#include <ostream>
#include "ns3/attribute-helper.h"
+#include "ns3/wifi-phy-standard.h"
namespace ns3 {
@@ -101,6 +102,12 @@
*/
uint32_t GetUid (void) const;
+ /**
+ *
+ * @return the WifiPhyStandard to which the WifiMode belongs
+ */
+ enum WifiPhyStandard GetStandard () const;
+
/**
* Create an invalid WifiMode. Calling any method on the
* instance created will trigger an assert. This is useful
@@ -151,7 +158,8 @@
bool isMandatory,
uint32_t bandwidth,
uint32_t dataRate,
- uint32_t phyRate);
+ uint32_t phyRate,
+ enum WifiPhyStandard standard);
/**
* \param uniqueName the name of the associated WifiMode. This name
* must be unique accross _all_ instances.
@@ -170,7 +178,8 @@
uint32_t bandwidth,
uint32_t dataRate,
uint32_t phyRate,
- uint8_t constellationSize);
+ uint8_t constellationSize,
+ enum WifiPhyStandard standard);
/**
* \param uniqueName the name of the associated WifiMode. This name
@@ -188,7 +197,8 @@
bool isMandatory,
uint32_t bandwidth,
uint32_t dataRate,
- uint32_t phyRate);
+ uint32_t phyRate,
+ enum WifiPhyStandard standard);
/**
* \param uniqueName the name of the associated WifiMode. This name
* must be unique accross _all_ instances.
@@ -205,7 +215,8 @@
bool isMandatory,
uint32_t bandwidth,
uint32_t dataRate,
- uint32_t phyRate);
+ uint32_t phyRate,
+ enum WifiPhyStandard standard);
private:
friend class WifiMode;
friend std::istream & operator >> (std::istream &is, WifiMode &mode);
@@ -225,6 +236,7 @@
enum WifiMode::ModulationType modulation;
uint8_t constellationSize;
bool isMandatory;
+ enum WifiPhyStandard standard;
};
bool Search (std::string name, WifiMode *mode);
--- a/src/devices/wifi/wifi-phy.cc Mon Jul 13 14:30:12 2009 +0200
+++ b/src/devices/wifi/wifi-phy.cc Wed Jul 15 13:06:11 2009 +0200
@@ -98,7 +98,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-6mbs",
true,
- 20000000, 6000000, 12000000);
+ 20000000, 6000000, 12000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
WifiMode
@@ -106,7 +107,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-9mbs",
false,
- 20000000, 9000000, 12000000);
+ 20000000, 9000000, 12000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
WifiMode
@@ -114,7 +116,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-12mbs",
true,
- 20000000, 12000000, 24000000);
+ 20000000, 12000000, 24000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
WifiMode
@@ -122,7 +125,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-18mbs",
false,
- 20000000, 18000000, 24000000);
+ 20000000, 18000000, 24000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
WifiMode
@@ -130,7 +134,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-24mbs",
true,
- 20000000, 24000000, 48000000);
+ 20000000, 24000000, 48000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
WifiMode
@@ -138,7 +143,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-36mbs",
false,
- 20000000, 36000000, 48000000);
+ 20000000, 36000000, 48000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
@@ -147,7 +153,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-48mbs",
false,
- 20000000, 48000000, 72000000);
+ 20000000, 48000000, 72000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
@@ -156,7 +163,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifia-54mbs",
false,
- 20000000, 54000000, 72000000);
+ 20000000, 54000000, 72000000,
+ WIFI_PHY_STANDARD_80211a);
return mode;
}
@@ -213,7 +221,8 @@
{
static WifiMode mode = WifiModeFactory::CreateDbpsk ("wifib-1mbs",
true,
- 22000000, 1000000, 1000000);
+ 22000000, 1000000, 1000000,
+ WIFI_PHY_STANDARD_80211b);
return mode;
}
@@ -222,7 +231,8 @@
{
static WifiMode mode = WifiModeFactory::CreateDqpsk ("wifib-2mbs",
true,
- 22000000, 2000000, 2000000);
+ 22000000, 2000000, 2000000,
+ WIFI_PHY_STANDARD_80211b);
return mode;
}
@@ -231,7 +241,8 @@
{
static WifiMode mode = WifiModeFactory::CreateDqpsk ("wifib-5.5mbs",
true,
- 22000000, 5500000, 5500000);
+ 22000000, 5500000, 5500000,
+ WIFI_PHY_STANDARD_80211b);
return mode;
}
@@ -240,7 +251,8 @@
{
static WifiMode mode = WifiModeFactory::CreateDqpsk ("wifib-11mbs",
true,
- 22000000, 11000000, 11000000);
+ 22000000, 11000000, 11000000,
+ WIFI_PHY_STANDARD_80211b);
return mode;
}
@@ -249,7 +261,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-3mbs-10Mhz",
true,
- 10000000, 3000000, 6000000);
+ 10000000, 3000000, 6000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -258,7 +271,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-4.5mbs-10Mhz",
false,
- 10000000, 4500000, 6000000);
+ 10000000, 4500000, 6000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -267,7 +281,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-6mbs-10Mhz",
true,
- 10000000, 6000000, 12000000);
+ 10000000, 6000000, 12000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -276,7 +291,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-9mbs-10Mhz",
false,
- 10000000, 9000000, 12000000);
+ 10000000, 9000000, 12000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -285,7 +301,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-12mbs-10Mhz",
true,
- 10000000, 12000000, 24000000);
+ 10000000, 12000000, 24000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -294,7 +311,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-18mbs-10Mhz",
false,
- 10000000, 18000000, 24000000);
+ 10000000, 18000000, 24000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -303,7 +321,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-24mbs-10Mhz",
false,
- 10000000, 24000000, 36000000);
+ 10000000, 24000000, 36000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -312,7 +331,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-27mbs-10Mhz",
false,
- 10000000, 27000000, 36000000);
+ 10000000, 27000000, 36000000,
+ WIFI_PHY_STANDARD_80211_10Mhz);
return mode;
}
@@ -321,7 +341,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-1_5mbs-5Mhz",
true,
- 5000000, 1500000, 3000000);
+ 5000000, 1500000, 3000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
@@ -330,7 +351,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-2.25mbs-5Mhz",
false,
- 5000000, 2250000, 3000000);
+ 5000000, 2250000, 3000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
@@ -339,7 +361,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-3mbs-5Mhz",
true,
- 5000000, 3000000, 6000000);
+ 5000000, 3000000, 6000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
@@ -348,7 +371,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-4.5mbs-5Mhz",
false,
- 5000000, 4500000, 6000000);
+ 5000000, 4500000, 6000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
@@ -357,7 +381,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-6mbs-5Mhz",
true,
- 5000000, 6000000, 12000000);
+ 5000000, 6000000, 12000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
@@ -366,7 +391,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-9mbs-5Mhz",
false,
- 10000000, 9000000, 12000000);
+ 10000000, 9000000, 12000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
@@ -375,7 +401,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-12mbs-5Mhz",
false,
- 10000000, 12000000, 18000000);
+ 10000000, 12000000, 18000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
@@ -384,7 +411,8 @@
{
static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-13.5mbs-5Mhz",
false,
- 10000000, 13500000, 18000000);
+ 10000000, 13500000, 18000000,
+ WIFI_PHY_STANDARD_80211_5Mhz);
return mode;
}
--- a/src/devices/wifi/wscript Mon Jul 13 14:30:12 2009 +0200
+++ b/src/devices/wifi/wscript Wed Jul 15 13:06:11 2009 +0200
@@ -21,6 +21,7 @@
'error-rate-model.cc',
'yans-error-rate-model.cc',
'interference-helper.cc',
+ 'interference-helper-tx-duration-test.cc',
'yans-wifi-phy.cc',
'yans-wifi-channel.cc',
'wifi-mac-header.cc',
--- a/src/devices/wifi/yans-wifi-phy.cc Mon Jul 13 14:30:12 2009 +0200
+++ b/src/devices/wifi/yans-wifi-phy.cc Wed Jul 15 13:06:11 2009 +0200
@@ -445,7 +445,6 @@
YansWifiPhy::Configure80211a (void)
{
NS_LOG_FUNCTION (this);
- m_interference.Configure80211aParameters ();
m_modes.push_back (WifiPhy::Get6mba ());
m_modes.push_back (WifiPhy::Get9mba ());
m_modes.push_back (WifiPhy::Get12mba ());
@@ -461,7 +460,6 @@
YansWifiPhy::Configure80211b (void)
{
NS_LOG_FUNCTION (this);
- m_interference.Configure80211bParameters ();
m_modes.push_back (WifiPhy::Get1mbb ());
m_modes.push_back (WifiPhy::Get2mbb ());
m_modes.push_back (WifiPhy::Get5_5mbb ());
@@ -472,7 +470,6 @@
YansWifiPhy::Configure80211_10Mhz (void)
{
NS_LOG_FUNCTION (this);
- m_interference.Configure80211_10MhzParameters ();
m_modes.push_back (WifiPhy::Get3mb10Mhz ());
m_modes.push_back (WifiPhy::Get4_5mb10Mhz ());
m_modes.push_back (WifiPhy::Get6mb10Mhz ());
@@ -486,8 +483,7 @@
void
YansWifiPhy::Configure80211_5Mhz (void)
{
- NS_LOG_FUNCTION (this);
- m_interference.Configure80211_5MhzParameters ();
+ NS_LOG_FUNCTION (this);
m_modes.push_back (WifiPhy::Get1_5mb5Mhz ());
m_modes.push_back (WifiPhy::Get2_25mb5Mhz ());
m_modes.push_back (WifiPhy::Get3mb5Mhz ());
@@ -502,7 +498,6 @@
YansWifiPhy::ConfigureHolland (void)
{
NS_LOG_FUNCTION (this);
- m_interference.Configure80211aParameters ();
m_modes.push_back (WifiPhy::Get6mba ());
m_modes.push_back (WifiPhy::Get12mba ());
m_modes.push_back (WifiPhy::Get18mba ());