Merge with ns-3-dev
authorKirill Andreev <andreev@iitp.ru>
Thu, 16 Jul 2009 11:51:24 +0400
changeset 5121 872e554039c3
parent 5117 591e912d459a (current diff)
parent 4684 44b325571ab4 (diff)
child 5122 0326727af888
Merge with ns-3-dev
src/core/test.h
src/devices/wifi/mac-low.cc
src/devices/wifi/wscript
src/devices/wifi/yans-wifi-phy.cc
src/devices/wifi/yans-wifi-phy.h
src/internet-stack/ipv4-checksum.cc
src/internet-stack/ipv4-checksum.h
src/internet-stack/ipv4-l3-protocol.cc
--- a/CHANGES.html	Fri Jul 10 18:43:24 2009 +0400
+++ b/CHANGES.html	Thu Jul 16 11:51:24 2009 +0400
@@ -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>
--- a/doc/modules	Fri Jul 10 18:43:24 2009 +0400
+++ b/doc/modules	Thu Jul 16 11:51:24 2009 +0400
@@ -49,14 +49,14 @@
  *    - an ARP module
  *    - a UDP and a TCP implementation
  *    
+ * @defgroup routing Routing
+ *
  * @defgroup helper Helpers
  * 
  * @defgroup applications Applications
  *
  * @defgroup mobility Mobility
  *
- * @defgroup routing Routing
- *
  * @defgroup constants Constants
  * @brief Constants you can change
  *
--- a/src/core/ptr.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/core/ptr.h	Thu Jul 16 11:51:24 2009 +0400
@@ -373,6 +373,13 @@
   return Ptr<T1> (dynamic_cast<T1 *> (PeekPointer (p)));
 }
 
+template <typename T1, typename T2>
+Ptr<T1>
+StaticCast (Ptr<T2> const&p)
+{
+  return Ptr<T1> (static_cast<T1 *> (PeekPointer (p)));
+}
+
 
 /****************************************************
  *      Member method implementations.
--- a/src/devices/csma/csma-channel.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/csma/csma-channel.h	Thu Jul 16 11:51:24 2009 +0400
@@ -259,14 +259,14 @@
    * \return Returns the DataRate to be used by device transmitters.
    * with deviceId i.
    */
-  virtual DataRate GetDataRate (void);
+  DataRate GetDataRate (void);
 
   /**
    * Get the assigned speed-of-light delay of the channel
    *
    * \return Returns the delay used by the channel.
    */
-  virtual Time GetDelay (void);
+  Time GetDelay (void);
 
 private:
 
--- a/src/devices/emu/emu-net-device.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/emu/emu-net-device.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -612,6 +612,19 @@
   Ptr<Packet> originalPacket = packet->Copy ();
 
   EthernetHeader header (false);
+
+  //
+  // This device could be running in an environment where completely unexpected
+  // kinds of packets are flying around, so we need to harden things a bit and
+  // filter out packets we think are completely bogus, so we always check to see
+  // that the packet is long enough to contain the header we want to remove.
+  //
+  if (packet->GetSize() < header.GetSerializedSize())
+    {
+      m_phyRxDropTrace (originalPacket);
+      return;
+    }
+
   packet->RemoveHeader (header);
 
   NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
@@ -628,6 +641,16 @@
   if (header.GetLengthType () <= 1500)
     {
       LlcSnapHeader llc;
+      //
+      // Check to see that the packet is long enough to possibly contain the
+      // header we want to remove before just naively calling.
+      //
+      if (packet->GetSize() < llc.GetSerializedSize())
+        {
+          m_phyRxDropTrace (originalPacket);
+          return;
+        }
+
       packet->RemoveHeader (llc);
       protocol = llc.GetType ();
     }
@@ -787,10 +810,6 @@
   header.SetLengthType (packet->GetSize ());
   packet->AddHeader (header);
 
-  EthernetTrailer trailer;
-  trailer.CalcFcs (packet);
-  packet->AddTrailer (trailer);
-
   //
   // there's not much meaning associated with the different layers in this
   // device, so don't be surprised when they're all stacked together in 
--- a/src/devices/virtual-net-device/virtual-net-device.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/virtual-net-device/virtual-net-device.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -115,6 +115,7 @@
 void VirtualNetDevice::DoDispose()
 {
   NS_LOG_FUNCTION_NOARGS ();
+  m_node = 0;
   NetDevice::DoDispose ();
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/interference-helper-tx-duration-test.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -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	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/interference-helper.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -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,57 +225,186 @@
   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) 
-  {
-    case WIFI_PHY_STANDARD_80211a:
+  switch (payloadMode.GetStandard ())
+    {
     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;
+    case WIFI_PHY_STANDARD_80211a:
+      // 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;
+      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;
+          case WIFI_PHY_STANDARD_80211b:
+            NS_FATAL_ERROR("can't happen here");
+            symbolDurationUs = 0; // quiet compiler
+          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;
+    }
+}
+
+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 
@@ -367,29 +497,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	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/interference-helper.h	Thu Jul 16 11:51:24 2009 +0400
@@ -69,8 +69,6 @@
   InterferenceHelper ();
   ~InterferenceHelper ();
 
-  void Configure80211aParameters (void);
-  void Configure80211bParameters (void);
   void SetNoiseFigure (double value);
   void SetErrorRateModel (Ptr<ErrorRateModel> rate);
 
@@ -85,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);
@@ -114,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/jakes-propagation-loss-model.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/jakes-propagation-loss-model.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -138,13 +138,15 @@
     .AddAttribute ("NumberOfRaysPerPath",
                    "The number of rays to use by default for compute the fading coeficent for a given path (default is 1)",
                    UintegerValue (1),
-		   MakeUintegerAccessor (&JakesPropagationLossModel::m_nRays),
+		   MakeUintegerAccessor (&JakesPropagationLossModel::SetNRays,
+                                         &JakesPropagationLossModel::GetNRays),
 		   MakeUintegerChecker<uint8_t> ())
     .AddAttribute ("NumberOfOscillatorsPerRay",
                    "The number of oscillators to use by default for compute the coeficent for a given ray of a given "
                    "path (default is 4)",
                    UintegerValue (4),
-		   MakeUintegerAccessor (&JakesPropagationLossModel::m_nOscillators),
+		   MakeUintegerAccessor (&JakesPropagationLossModel::SetNOscillators,
+                                         &JakesPropagationLossModel::GetNOscillators),
 		   MakeUintegerChecker<uint8_t> ())
     .AddAttribute ("DopplerFreq",
                    "The doppler frequency in Hz (f_d = v / lambda = v * f / c), the default is 0)",
@@ -161,9 +163,10 @@
 }
 
 JakesPropagationLossModel::JakesPropagationLossModel ()
-{
-  DoConstruct ();
-}
+  : m_amp (0),
+    m_nRays (0),
+    m_nOscillators (0)
+{}
 
 JakesPropagationLossModel::~JakesPropagationLossModel ()
 {
@@ -181,8 +184,16 @@
 }
 
 void
-JakesPropagationLossModel::DoConstruct ()
+JakesPropagationLossModel::SetNRays (uint8_t nRays)
 {
+  m_nRays = nRays;
+}
+
+void
+JakesPropagationLossModel::SetNOscillators (uint8_t nOscillators)
+{
+  m_nOscillators = nOscillators;
+  delete [] m_amp;
   uint16_t N = 4 * m_nOscillators + 2;
   m_amp = new ComplexNumber[m_nOscillators + 1];
   m_amp[0].real = 2.0 * sqrt(2.0 / N) * cos (PI / 4.0);
@@ -195,17 +206,17 @@
     }
 }
 
-void
-JakesPropagationLossModel::SetNRays (uint8_t nRays)
+uint8_t 
+JakesPropagationLossModel::GetNRays (void) const
 {
-  m_nRays = nRays;
+  return m_nRays;
+}
+uint8_t 
+JakesPropagationLossModel::GetNOscillators (void) const
+{
+  return m_nOscillators;
 }
 
-void
-JakesPropagationLossModel::SetNOscillators (uint8_t nOscillators)
-{
-  m_nOscillators = nOscillators;
-}
 
 double 
 JakesPropagationLossModel::DoCalcRxPower (double txPowerDbm,
--- a/src/devices/wifi/jakes-propagation-loss-model.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/jakes-propagation-loss-model.h	Thu Jul 16 11:51:24 2009 +0400
@@ -96,6 +96,9 @@
    */
   void SetNOscillators (uint8_t nOscillators);
 
+  uint8_t GetNRays (void) const;
+  uint8_t GetNOscillators (void) const;
+
 private:
   JakesPropagationLossModel (const JakesPropagationLossModel &o);
   JakesPropagationLossModel & operator = (const JakesPropagationLossModel &o);
--- a/src/devices/wifi/mac-low.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/mac-low.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -585,11 +585,11 @@
         {
           m_listener->GotAck (rxSnr, txMode);
         }
-    if (m_txParams.HasNextPacket ()) 
-      {
-        m_waitSifsEvent = Simulator::Schedule (GetSifs (), 
-                                               &MacLow::WaitSifsAfterEndTx, this);
-      }
+      if (m_txParams.HasNextPacket ()) 
+        {
+          m_waitSifsEvent = Simulator::Schedule (GetSifs (), 
+                                                 &MacLow::WaitSifsAfterEndTx, this);
+        }
     } 
   else if (hdr.IsCtl ()) 
     {
--- a/src/devices/wifi/wifi-mac.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wifi-mac.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -117,6 +117,14 @@
 		   MakeSsidAccessor (&WifiMac::GetSsid,
 				     &WifiMac::SetSsid),
 		   MakeSsidChecker ())
+    .AddAttribute ("Standard", "The standard chosen configures some MAC-specific constants",
+                   EnumValue (WIFI_PHY_STANDARD_80211a),
+                   MakeEnumAccessor (&WifiMac::SetStandard),
+                   MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a",
+                                    WIFI_PHY_STANDARD_80211b, "802.11b",
+                                    WIFI_PHY_STANDARD_80211_10Mhz,"802.11_10Mhz",
+                                    WIFI_PHY_STANDARD_80211_5Mhz,"802-11_5Mhz",
+                                    WIFI_PHY_STANDARD_holland, "holland"))
     .AddTraceSource ("MacTx", 
                      "A packet has been received from higher layers and is being processed in preparation for "
                      "queueing for transmission.",
@@ -200,4 +208,74 @@
   m_macRxDropTrace (packet);
 }
 
+void
+WifiMac::SetStandard (enum WifiPhyStandard standard)
+{
+  m_standard = standard;
+  switch (standard) {
+  case WIFI_PHY_STANDARD_80211a:
+    Configure80211a ();
+    break;
+  case WIFI_PHY_STANDARD_80211b:
+    Configure80211b ();
+    break;
+  case WIFI_PHY_STANDARD_80211_10Mhz: 
+    Configure80211_10Mhz ();
+    break;
+  case WIFI_PHY_STANDARD_80211_5Mhz:
+    Configure80211_5Mhz ();
+    break;
+  case WIFI_PHY_STANDARD_holland:
+    Configure80211a ();
+    break;
+  default:
+    NS_ASSERT (false);
+    break;
+  }
+}
+
+void
+WifiMac::Configure80211a (void)
+{
+  SetSifs(MicroSeconds(16));
+  SetSlot(MicroSeconds(9)); 
+  SetEifsNoDifs(MicroSeconds(16+44));
+  SetPifs(MicroSeconds(16+9));
+  SetCtsTimeout(MicroSeconds(16+44+9+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2));
+  SetAckTimeout(MicroSeconds(16+44+9+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2)); 
+}
+
+void
+WifiMac::Configure80211b (void)
+{
+  SetSifs(MicroSeconds(10));
+  SetSlot(MicroSeconds(20));
+  SetEifsNoDifs(MicroSeconds(10+304));
+  SetPifs(MicroSeconds(10+20));
+  SetCtsTimeout(MicroSeconds(10+304+20+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2));
+  SetAckTimeout(MicroSeconds(10+304+20+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2)); 
+}
+
+void
+WifiMac::Configure80211_10Mhz (void)
+{
+  SetSifs(MicroSeconds(32));
+  SetSlot(MicroSeconds(13)); 
+  SetEifsNoDifs(MicroSeconds(32+88));
+  SetPifs(MicroSeconds(32+13));
+  SetCtsTimeout(MicroSeconds(32+88+13+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2));
+  SetAckTimeout(MicroSeconds(32+88+13+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2)); 
+}
+
+void
+WifiMac::Configure80211_5Mhz (void)
+{
+  SetSifs(MicroSeconds(64));
+  SetSlot(MicroSeconds(21));
+  SetEifsNoDifs(MicroSeconds(64+176));
+  SetPifs(MicroSeconds(64+21));
+  SetCtsTimeout(MicroSeconds(64+176+21+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2));
+  SetAckTimeout(MicroSeconds(64+176+21+GetDefaultMaxPropagationDelay().GetMicroSeconds ()*2)); 
+}
+
 } // namespace ns3
--- a/src/devices/wifi/wifi-mac.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wifi-mac.h	Thu Jul 16 11:51:24 2009 +0400
@@ -206,6 +206,10 @@
    * purposes.
    */
   void NotifyRxDrop (Ptr<const Packet> packet);
+  /**
+   * \param standard the wifi standard to be configured
+   */
+  void SetStandard (enum WifiPhyStandard standard);
 
 private:
   static Time GetDefaultMaxPropagationDelay (void);
@@ -217,6 +221,12 @@
 
   Time m_maxPropagationDelay;
   uint32_t m_maxMsduSize;
+  WifiPhyStandard m_standard;
+
+  void Configure80211a (void);
+  void Configure80211b (void);
+  void Configure80211_10Mhz (void);
+  void Configure80211_5Mhz ();
 
   /**
    * The trace source fired when packets come into the "top" of the device
--- a/src/devices/wifi/wifi-mode.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wifi-mode.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -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	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wifi-mode.h	Thu Jul 16 11:51:24 2009 +0400
@@ -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-standard.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wifi-phy-standard.h	Thu Jul 16 11:51:24 2009 +0400
@@ -25,6 +25,8 @@
 enum WifiPhyStandard {
   WIFI_PHY_STANDARD_80211a,
   WIFI_PHY_STANDARD_80211b,
+  WIFI_PHY_STANDARD_80211_10Mhz,
+  WIFI_PHY_STANDARD_80211_5Mhz,
   WIFI_PHY_STANDARD_holland
 };
 
--- a/src/devices/wifi/wifi-phy.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wifi-phy.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -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,168 @@
 {
   static WifiMode mode = WifiModeFactory::CreateDqpsk ("wifib-11mbs",
                                                       true,
-                                                      22000000, 11000000, 11000000);
+                                                      22000000, 11000000, 11000000,
+                                                      WIFI_PHY_STANDARD_80211b);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get3mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-3mbs-10Mhz",
+                                                      true,
+                                                      10000000, 3000000, 6000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get4_5mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-4.5mbs-10Mhz",
+                                                      false,
+                                                      10000000, 4500000, 6000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get6mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-6mbs-10Mhz",
+                                                      true,
+                                                      10000000, 6000000, 12000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get9mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-9mbs-10Mhz",
+                                                      false,
+                                                      10000000, 9000000, 12000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get12mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-12mbs-10Mhz",
+                                                      true,
+                                                      10000000, 12000000, 24000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get18mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-18mbs-10Mhz",
+                                                      false,
+                                                      10000000, 18000000, 24000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get24mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-24mbs-10Mhz",
+                                                      false,
+                                                      10000000, 24000000, 36000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get27mb10Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-27mbs-10Mhz",
+                                                      false,
+                                                      10000000, 27000000, 36000000,
+                                                      WIFI_PHY_STANDARD_80211_10Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get1_5mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-1_5mbs-5Mhz",
+                                                      true,
+                                                      5000000, 1500000, 3000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get2_25mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-2.25mbs-5Mhz",
+                                                      false,
+                                                      5000000, 2250000, 3000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get3mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-3mbs-5Mhz",
+                                                      true,
+                                                      5000000, 3000000, 6000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get4_5mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-4.5mbs-5Mhz",
+                                                      false,
+                                                      5000000, 4500000, 6000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get6mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-6mbs-5Mhz",
+                                                      true,
+                                                      5000000, 6000000, 12000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get9mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-9mbs-5Mhz",
+                                                      false,
+                                                      10000000, 9000000, 12000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get12mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-12mbs-5Mhz",
+                                                      false,
+                                                      10000000, 12000000, 18000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
+  return mode;
+}
+
+WifiMode 
+WifiPhy::Get13_5mb5Mhz (void)
+{
+  static WifiMode mode = WifiModeFactory::CreateBpsk ("wifi-13.5mbs-5Mhz",
+                                                      false,
+                                                      10000000, 13500000, 18000000,
+                                                      WIFI_PHY_STANDARD_80211_5Mhz);
   return mode;
 }
 
@@ -265,6 +437,22 @@
     ns3::WifiPhy::Get2mbb ();
     ns3::WifiPhy::Get5_5mbb ();
     ns3::WifiPhy::Get11mbb ();
+    ns3::WifiPhy::Get3mb10Mhz ();
+    ns3::WifiPhy::Get4_5mb10Mhz ();
+    ns3::WifiPhy::Get6mb10Mhz ();
+    ns3::WifiPhy::Get9mb10Mhz ();
+    ns3::WifiPhy::Get12mb10Mhz ();
+    ns3::WifiPhy::Get18mb10Mhz ();
+    ns3::WifiPhy::Get24mb10Mhz ();
+    ns3::WifiPhy::Get27mb10Mhz ();
+    ns3::WifiPhy::Get1_5mb5Mhz ();
+    ns3::WifiPhy::Get2_25mb5Mhz ();
+    ns3::WifiPhy::Get3mb5Mhz ();
+    ns3::WifiPhy::Get4_5mb5Mhz ();
+    ns3::WifiPhy::Get6mb5Mhz ();
+    ns3::WifiPhy::Get9mb5Mhz ();
+    ns3::WifiPhy::Get12mb5Mhz ();
+    ns3::WifiPhy::Get13_5mb5Mhz ();
   }
 } g_constructor;
 }
--- a/src/devices/wifi/wifi-phy.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wifi-phy.h	Thu Jul 16 11:51:24 2009 +0400
@@ -256,6 +256,22 @@
   static WifiMode Get2mbb (void);
   static WifiMode Get5_5mbb (void);
   static WifiMode Get11mbb (void);
+  static WifiMode Get3mb10Mhz (void);
+  static WifiMode Get4_5mb10Mhz (void);
+  static WifiMode Get6mb10Mhz (void);
+  static WifiMode Get9mb10Mhz (void);
+  static WifiMode Get12mb10Mhz (void);
+  static WifiMode Get18mb10Mhz (void);
+  static WifiMode Get24mb10Mhz (void);
+  static WifiMode Get27mb10Mhz (void);
+  static WifiMode Get1_5mb5Mhz (void);
+  static WifiMode Get2_25mb5Mhz (void);
+  static WifiMode Get3mb5Mhz (void);
+  static WifiMode Get4_5mb5Mhz (void);
+  static WifiMode Get6mb5Mhz (void);
+  static WifiMode Get9mb5Mhz (void);
+  static WifiMode Get12mb5Mhz (void);
+  static WifiMode Get13_5mb5Mhz (void);
 
 
   /**
--- a/src/devices/wifi/wscript	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/wscript	Thu Jul 16 11:51:24 2009 +0400
@@ -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-error-rate-model.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/yans-error-rate-model.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -176,7 +176,7 @@
 double 
 YansErrorRateModel::GetChunkSuccessRate (WifiMode mode, double snr, uint32_t nbits) const
 {
-  if (mode == WifiPhy::Get6mba ())
+  if (mode == WifiPhy::Get6mba () || mode == WifiPhy::Get3mb10Mhz () || mode == WifiPhy::Get1_5mb5Mhz ())
     {
       return GetFecBpskBer (snr, 
                             nbits,
@@ -186,7 +186,7 @@
                             11 // adFree
                             );      
     }
-  else if (mode == WifiPhy::Get9mba ())
+  else if (mode == WifiPhy::Get9mba () || mode == WifiPhy::Get4_5mb10Mhz () || mode == WifiPhy::Get2_25mb5Mhz ())
     {
       return GetFecBpskBer (snr, 
                             nbits,
@@ -196,7 +196,7 @@
                             8 // adFree
                             );
     }
-  else if (mode == WifiPhy::Get12mba ())
+  else if (mode == WifiPhy::Get12mba () || mode == WifiPhy::Get6mb10Mhz () || mode == WifiPhy::Get3mb5Mhz ())
     {
       return GetFecQamBer (snr, 
                            nbits,
@@ -208,7 +208,7 @@
                            0   // adFreePlusOne
                            );
     }
-  else if (mode == WifiPhy::Get18mba ())
+  else if (mode == WifiPhy::Get18mba () || mode == WifiPhy::Get9mb10Mhz () || mode == WifiPhy::Get4_5mb5Mhz ())
     {
       return GetFecQamBer (snr, 
                            nbits,
@@ -220,7 +220,7 @@
                            31 // adFreePlusOne
                            );
     }
-  else if (mode == WifiPhy::Get24mba ())
+  else if (mode == WifiPhy::Get24mba () || mode == WifiPhy::Get12mb10Mhz () || mode == WifiPhy::Get6mb5Mhz ())
     {
       return GetFecQamBer (snr, 
                            nbits,
@@ -232,7 +232,7 @@
                            0   // adFreePlusOne
                            );
     }
-  else if (mode == WifiPhy::Get36mba ())
+  else if (mode == WifiPhy::Get36mba () || mode == WifiPhy::Get18mb10Mhz () || mode == WifiPhy::Get9mb5Mhz ())
     {
       return GetFecQamBer (snr, 
                            nbits,
@@ -244,7 +244,7 @@
                            31  // adFreePlusOne
                            );
     }
-  else if (mode == WifiPhy::Get48mba ())
+  else if (mode == WifiPhy::Get48mba () || mode == WifiPhy::Get24mb10Mhz () || mode == WifiPhy::Get12mb5Mhz ())
     {
       return GetFecQamBer (snr, 
                            nbits,
@@ -256,7 +256,7 @@
                            16  // adFreePlusOne
                            );
     }
-  else if (mode == WifiPhy::Get54mba ())
+  else if (mode == WifiPhy::Get54mba () || mode == WifiPhy::Get27mb10Mhz () || mode == WifiPhy::Get13_5mb5Mhz ())
     {
       return GetFecQamBer (snr, 
                            nbits,
--- a/src/devices/wifi/yans-wifi-phy.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/yans-wifi-phy.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -111,6 +111,8 @@
                    MakeEnumAccessor (&YansWifiPhy::SetStandard),
                    MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a",
                                     WIFI_PHY_STANDARD_80211b, "802.11b",
+                                    WIFI_PHY_STANDARD_80211_10Mhz,"802.11_10Mhz",
+                                    WIFI_PHY_STANDARD_80211_5Mhz,"802-11_5Mhz",
                                     WIFI_PHY_STANDARD_holland, "holland"))
     .AddAttribute ("State", "The state of the PHY layer",
                    PointerValue (),
@@ -160,6 +162,12 @@
   case WIFI_PHY_STANDARD_80211b:
     Configure80211b ();
     break;
+  case WIFI_PHY_STANDARD_80211_10Mhz: 
+    Configure80211_10Mhz ();
+    break;
+  case WIFI_PHY_STANDARD_80211_5Mhz:
+    Configure80211_5Mhz ();
+    break;
   case WIFI_PHY_STANDARD_holland:
     ConfigureHolland ();
     break;
@@ -468,8 +476,6 @@
 YansWifiPhy::Configure80211a (void)
 {
   NS_LOG_FUNCTION (this);
-  m_interference.Configure80211aParameters ();
-  m_channelStartingFrequency = 5e3; // 5.000 GHz 
   m_modes.push_back (WifiPhy::Get6mba ());
   m_modes.push_back (WifiPhy::Get9mba ());
   m_modes.push_back (WifiPhy::Get12mba ());
@@ -485,8 +491,6 @@
 YansWifiPhy::Configure80211b (void)
 {
   NS_LOG_FUNCTION (this);
-  m_interference.Configure80211bParameters ();
-  m_channelStartingFrequency = 2412; // 2.412 GHz 
   m_modes.push_back (WifiPhy::Get1mbb ());
   m_modes.push_back (WifiPhy::Get2mbb ());
   m_modes.push_back (WifiPhy::Get5_5mbb ());
@@ -494,11 +498,37 @@
 }
 
 void
+YansWifiPhy::Configure80211_10Mhz (void)
+{
+  NS_LOG_FUNCTION (this);
+  m_modes.push_back (WifiPhy::Get3mb10Mhz ());
+  m_modes.push_back (WifiPhy::Get4_5mb10Mhz ());
+  m_modes.push_back (WifiPhy::Get6mb10Mhz ());
+  m_modes.push_back (WifiPhy::Get9mb10Mhz ());
+  m_modes.push_back (WifiPhy::Get12mb10Mhz ());
+  m_modes.push_back (WifiPhy::Get18mb10Mhz ());
+  m_modes.push_back (WifiPhy::Get24mb10Mhz ());
+  m_modes.push_back (WifiPhy::Get27mb10Mhz  ());
+}
+
+void
+YansWifiPhy::Configure80211_5Mhz (void)
+{
+  NS_LOG_FUNCTION (this); 
+  m_modes.push_back (WifiPhy::Get1_5mb5Mhz ());
+  m_modes.push_back (WifiPhy::Get2_25mb5Mhz ());
+  m_modes.push_back (WifiPhy::Get3mb5Mhz ());
+  m_modes.push_back (WifiPhy::Get4_5mb5Mhz ());
+  m_modes.push_back (WifiPhy::Get6mb5Mhz ());
+  m_modes.push_back (WifiPhy::Get9mb5Mhz ());
+  m_modes.push_back (WifiPhy::Get12mb5Mhz ());
+  m_modes.push_back (WifiPhy::Get13_5mb5Mhz  ());
+}
+
+void
 YansWifiPhy::ConfigureHolland (void)
 {
   NS_LOG_FUNCTION (this);
-  m_interference.Configure80211aParameters ();
-  m_channelStartingFrequency = 5e3; // 5.000 GHz 
   m_modes.push_back (WifiPhy::Get6mba ());
   m_modes.push_back (WifiPhy::Get12mba ());
   m_modes.push_back (WifiPhy::Get18mba ());
--- a/src/devices/wifi/yans-wifi-phy.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/devices/wifi/yans-wifi-phy.h	Thu Jul 16 11:51:24 2009 +0400
@@ -142,6 +142,8 @@
   virtual void DoDispose (void);
   void Configure80211a (void);
   void Configure80211b (void);
+  void Configure80211_10Mhz (void);
+  void Configure80211_5Mhz ();
   void ConfigureHolland (void);
   double GetEdThresholdW (void) const;
   double DbmToW (double dbm) const;
--- a/src/helper/nqos-wifi-mac-helper.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/helper/nqos-wifi-mac-helper.h	Thu Jul 16 11:51:24 2009 +0400
@@ -70,7 +70,6 @@
                 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
                 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
   /**
-   * \param type the type of ns3::WifiMac to create.
    * \param n0 the name of the attribute to set
    * \param v0 the value of the attribute to set
    * \param n1 the name of the attribute to set
@@ -78,6 +77,7 @@
    * \param n2 the name of the attribute to set
    * \param v2 the value of the attribute to set
    * \param n3 the name of the attribute to set
+   * \param v3 the value of the attribute to set
    */
   void SetDcaParameters (std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
                          std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
--- a/src/helper/qos-wifi-mac-helper.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/helper/qos-wifi-mac-helper.h	Thu Jul 16 11:51:24 2009 +0400
@@ -74,7 +74,7 @@
   /**
    * \param accessClass access class for which we are setting aggregator. Possibilities
    *  are: AC_BK, AC_BE, AC_VI, AC_VO.
-   * \param aggregatorType type of aggregator.
+   * \param type the type of ns3::WifiMac to create.
    * \param n0 the name of the attribute to set
    * \param v0 the value of the attribute to set
    * \param n1 the name of the attribute to set
--- a/src/internet-stack/arp-l3-protocol.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/arp-l3-protocol.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -81,12 +81,15 @@
 void
 ArpL3Protocol::NotifyNewAggregate ()
 {
-  Ptr<Node>node = this->GetObject<Node> ();
-  //verify that it's a valid node and that
-  //the node was not set before
-  if (node!= 0 && m_node == 0)
+  if (m_node == 0)
     {
-      this->SetNode (node);
+      Ptr<Node>node = this->GetObject<Node> ();
+      //verify that it's a valid node and that
+      //the node was not set before
+      if (node != 0)
+        {
+          this->SetNode (node);
+        }
     }
   Object::NotifyNewAggregate ();
 }
--- a/src/internet-stack/icmpv4-l4-protocol.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/icmpv4-l4-protocol.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -50,15 +50,20 @@
 void
 Icmpv4L4Protocol::NotifyNewAggregate ()
 {
-  bool is_not_initialized = (m_node == 0);
-  Ptr<Node>node = this->GetObject<Node> ();
-  Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
-  if (is_not_initialized && node!= 0 && ipv4 != 0)
+  if (m_node == 0)
     {
-      this->SetNode (node);
-      ipv4->Insert (this);
-      Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
-      ipv4->AggregateObject (rawFactory);
+      Ptr<Node> node = this->GetObject<Node> ();
+      if (node != 0)
+	{
+	  Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
+	  if (ipv4 != 0)
+	    {
+	      this->SetNode (node);
+	      ipv4->Insert (this);
+	      Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
+	      ipv4->AggregateObject (rawFactory);
+	    }
+	}
     }
   Object::NotifyNewAggregate ();
 }
--- a/src/internet-stack/ipv4-checksum.cc	Fri Jul 10 18:43:24 2009 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006,2007 INRIA
- *
- * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "ipv4-checksum.h"
-
-namespace ns3 {
-
-uint16_t 
-Ipv4ChecksumCalculate (uint16_t checksum, uint8_t *buffer, uint16_t size)
-{
-  /* see RFC 1071 to understand this code. */
-  uint32_t sum = checksum;
-  uint16_t *data = (uint16_t *) buffer;
-  for (uint16_t i = 0; i < (size/2); i++) {
-    sum += data[i];
-  }
-  if ((size % 2) != 0) {
-    uint8_t tmpBuf[2];
-    tmpBuf[0] = buffer[size-1];
-    tmpBuf[1] = 0;
-    data = (uint16_t *)tmpBuf;
-    sum += *data;
-  }
-  while (sum >> 16) {
-    sum = (sum & 0xffff) + (sum >> 16);
-  }
-  return sum;
-}
-
-uint16_t 
-Ipv4ChecksumComplete (uint16_t checksum)
-{
-  return ~checksum;
-}
-
-}; //namespace ns3
--- a/src/internet-stack/ipv4-checksum.h	Fri Jul 10 18:43:24 2009 +0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2005,2006,2007 INRIA
- *
- * 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef IPV4_CHECKSUM_H
-#define IPV4_CHECKSUM_H
-
-#include <stdint.h>
-
-namespace ns3 {
-
-uint16_t Ipv4ChecksumCalculate (uint16_t checksum, uint8_t *buffer, uint16_t size);
-
-uint16_t Ipv4ChecksumComplete (uint16_t checksum);
-
-}; //namespace ns3
-
-#endif /* IPV4_CHECKSUM_H */
--- a/src/internet-stack/ipv4-interface.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/ipv4-interface.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -199,7 +199,7 @@
         {
           Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
         
-          ipv4->Receive (0, p, Ipv4L3Protocol::PROT_NUMBER, 
+          ipv4->Receive (m_device, p, Ipv4L3Protocol::PROT_NUMBER, 
                          m_device->GetBroadcast (),
                          m_device->GetBroadcast (),
                          NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here
--- a/src/internet-stack/ipv4-l3-protocol.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/ipv4-l3-protocol.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -146,12 +146,15 @@
 void
 Ipv4L3Protocol::NotifyNewAggregate ()
 {
-  Ptr<Node>node = this->GetObject<Node>();
-  // verify that it's a valid node and that
-  // the node has not been set before
-  if (node!= 0 && m_node == 0)
+  if (m_node == 0)
     {
-      this->SetNode (node);
+      Ptr<Node>node = this->GetObject<Node>();
+      // verify that it's a valid node and that
+      // the node has not been set before
+      if (node != 0)
+        {
+          this->SetNode (node);
+        }
     }
   Object::NotifyNewAggregate ();
 }
--- a/src/internet-stack/nsc-tcp-l4-protocol.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/nsc-tcp-l4-protocol.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -164,16 +164,21 @@
 void
 NscTcpL4Protocol::NotifyNewAggregate ()
 { 
-  bool is_not_initialized = (m_node == 0);
-  Ptr<Node>node = this->GetObject<Node> ();
-  Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
-  if (is_not_initialized && node!= 0 && ipv4 != 0)
+  if (m_node == 0)
     {
-      this->SetNode (node);
-      ipv4->Insert (this);
-      Ptr<NscTcpSocketFactoryImpl> tcpFactory = CreateObject<NscTcpSocketFactoryImpl> ();
-      tcpFactory->SetTcp (this);
-      node->AggregateObject (tcpFactory);
+      Ptr<Node>node = this->GetObject<Node> ();
+      if (node != 0)
+        {
+          Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
+          if (ipv4 != 0)
+            {
+              this->SetNode (node);
+              ipv4->Insert (this);
+              Ptr<NscTcpSocketFactoryImpl> tcpFactory = CreateObject<NscTcpSocketFactoryImpl> ();
+              tcpFactory->SetTcp (this);
+              node->AggregateObject (tcpFactory);
+            }
+        }
     }
   Object::NotifyNewAggregate ();
 }
--- a/src/internet-stack/tcp-l4-protocol.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/tcp-l4-protocol.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -366,16 +366,21 @@
 void
 TcpL4Protocol::NotifyNewAggregate ()
 {
-  bool is_not_initialized = (m_node == 0);
-  Ptr<Node>node = this->GetObject<Node> ();
-  Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
-  if (is_not_initialized && node!= 0 && ipv4 != 0)
+  if (m_node == 0)
     {
-      this->SetNode (node);
-      ipv4->Insert (this);
-      Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
-      tcpFactory->SetTcp (this);
-      node->AggregateObject (tcpFactory);
+      Ptr<Node> node = this->GetObject<Node> ();
+      if (node != 0)
+        {
+          Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
+          if (ipv4 != 0)
+            {
+              this->SetNode (node);
+              ipv4->Insert (this);
+              Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
+              tcpFactory->SetTcp (this);
+              node->AggregateObject (tcpFactory);
+            }
+        }
     }
   Object::NotifyNewAggregate ();
 }
--- a/src/internet-stack/udp-l4-protocol.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/udp-l4-protocol.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -77,16 +77,21 @@
 void
 UdpL4Protocol::NotifyNewAggregate ()
 {  
-  bool is_not_initialized = (m_node == 0);
-  Ptr<Node>node = this->GetObject<Node> ();
-  Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
-  if (is_not_initialized && node!= 0 && ipv4 != 0)
+  if (m_node == 0)
     {
-      this->SetNode (node);
-      ipv4->Insert (this);
-      Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
-      udpFactory->SetUdp (this);
-      node->AggregateObject (udpFactory);
+      Ptr<Node> node = this->GetObject<Node> ();
+      if (node != 0)
+        {
+          Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
+          if (ipv4 != 0)
+            {
+              this->SetNode (node);
+              ipv4->Insert (this);
+              Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
+              udpFactory->SetUdp (this);
+              node->AggregateObject (udpFactory);
+            }
+        }
     }
   Object::NotifyNewAggregate ();
 }
--- a/src/internet-stack/wscript	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/internet-stack/wscript	Thu Jul 16 11:51:24 2009 +0400
@@ -78,7 +78,6 @@
         'ipv4-l4-protocol.cc',
         'udp-header.cc',
         'tcp-header.cc',
-        'ipv4-checksum.cc',
         'ipv4-interface.cc',
         'ipv4-l3-protocol.cc',
         'ipv4-end-point.cc',
--- a/src/node/ipv4-routing-protocol.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/node/ipv4-routing-protocol.h	Thu Jul 16 11:51:24 2009 +0400
@@ -34,10 +34,13 @@
 
 /**
  * \ingroup node 
- * \defgroup ipv4Routing Ipv4 Routing
- *
- * Abstract base class for Ipv4 routing protocols.  Defines two
- * virtual functions for packet routing and forwarding.  The first, 
+ * \defgroup ipv4Routing Ipv4RoutingProtocol 
+ */
+/**
+ * \ingroup ipv4Routing
+ * \brief Abstract base class for IPv4 routing protocols. 
+ * 
+ * Defines two virtual functions for packet routing and forwarding.  The first, 
  * RouteOutput(), is used for locally originated packets, and the second,
  * RouteInput(), is used for forwarding and/or delivering received packets. 
  * Also defines the signatures of four callbacks used in RouteInput().
--- a/src/routing/list-routing/ipv4-list-routing.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/routing/list-routing/ipv4-list-routing.h	Thu Jul 16 11:51:24 2009 +0400
@@ -25,7 +25,11 @@
 namespace ns3 {
 
 /**
- * \ingroup ipv4Routing 
+ * \ingroup routing 
+ * \defgroup ipv4ListRouting Ipv4 List Routing
+ */
+/**
+ * \ingroup ipv4ListRouting
  *
  * This class is a specialization of Ipv4RoutingProtocol that allows 
  * other instances of Ipv4RoutingProtocol to be inserted in a 
--- a/src/routing/static-routing/ipv4-routing-table-entry.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/routing/static-routing/ipv4-routing-table-entry.h	Thu Jul 16 11:51:24 2009 +0400
@@ -29,7 +29,7 @@
 namespace ns3 {
 
 /**
- * \ingroup ipv4Routing
+ * \ingroup routing
  *
  * A record of an IPv4 routing table entry for Ipv4GlobalRouting and 
  * Ipv4StaticRouting.  This is not a reference counted object.
@@ -155,7 +155,7 @@
 std::ostream& operator<< (std::ostream& os, Ipv4RoutingTableEntry const& route);
 
 /**
- * \ingroup ipv4Routing
+ * \ingroup routing
  *
  * \brief A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting
  */
--- a/src/routing/static-routing/ipv4-static-routing.h	Fri Jul 10 18:43:24 2009 +0400
+++ b/src/routing/static-routing/ipv4-static-routing.h	Thu Jul 16 11:51:24 2009 +0400
@@ -43,7 +43,11 @@
 class Node;
 
 /**
- * \ingroup ipv4Routing
+ * \ingroup routing
+ * \defgroup ipv4StaticRouting Ipv4StaticRouting
+ */
+/**
+ * \ingroup ipv4StaticRouting
  * 
  * \brief Static routing protocol for IP version 4 stacks.
  *
--- a/utils/bench-simulator.cc	Fri Jul 10 18:43:24 2009 +0400
+++ b/utils/bench-simulator.cc	Thu Jul 16 11:51:24 2009 +0400
@@ -33,6 +33,7 @@
 class Bench 
 {
 public:
+  Bench ();
   void ReadDistribution (std::istream &istream);
   void SetTotal (uint32_t total);
   void RunBench (void);
@@ -44,6 +45,11 @@
   uint32_t m_total;
 };
 
+Bench::Bench ()
+  : m_n (0),
+    m_total (0)
+{}
+
 void 
 Bench::SetTotal (uint32_t total)
 {