Mesh:Dot11s: fixed airtime metric
authorKirill Andreev <andreev@iitp.ru>
Wed, 02 Dec 2009 19:58:59 +0300
changeset 5828 9959ba75ba25
parent 5827 ed0b2d9301a1
child 5830 e03be90a225c
Mesh:Dot11s: fixed airtime metric
src/devices/mesh/dot11s/airtime-metric.cc
src/devices/mesh/dot11s/airtime-metric.h
src/devices/mesh/dot11s/hwmp-protocol.cc
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-2-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-3-1.pcap
src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-4-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-2-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-3-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-4-1.pcap
src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-5-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-0-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-1-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-2-1.pcap
src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-3-1.pcap
src/devices/mesh/mesh-wifi-interface-mac.cc
src/devices/mesh/mesh-wifi-interface-mac.h
--- a/src/devices/mesh/dot11s/airtime-metric.cc	Tue Dec 01 18:34:11 2009 +0300
+++ b/src/devices/mesh/dot11s/airtime-metric.cc	Wed Dec 02 19:58:59 2009 +0300
@@ -30,12 +30,6 @@
   static TypeId tid = TypeId ("ns3::dot11s::AirtimeLinkMetricCalculator")
     .SetParent<Object> ()
     .AddConstructor<AirtimeLinkMetricCalculator> ()
-    .AddAttribute ( "OverheadNanosec",
-                    "Overhead expressed in nanoseconds:DIFS+ SIFS + 2 * PREAMBLE + ACK",
-                    UintegerValue (108000),
-                    MakeUintegerAccessor (&AirtimeLinkMetricCalculator::m_overheadNanosec),
-                    MakeUintegerChecker<uint32_t> (1)
-                  )
     .AddAttribute ( "TestLength",
                     "Rate should be estimated using test length.",
                      UintegerValue (1024),
@@ -60,7 +54,32 @@
                   ;
   return tid;
 }
-
+AirtimeLinkMetricCalculator::AirtimeLinkMetricCalculator () :
+  m_overheadNanosec (0)
+{}
+void
+AirtimeLinkMetricCalculator::SetPhyStandard (WifiPhyStandard standard)
+{
+  switch (standard) {
+  case WIFI_PHY_STANDARD_80211a:
+  case WIFI_PHY_STANDARD_holland:
+    // 2 * PREAMBLE + DIFS + SIFS + ACK
+    m_overheadNanosec = (2 * 16 + 34 + 16 + 44) * 1000;
+    break;
+  case WIFI_PHY_STANDARD_80211b:
+    m_overheadNanosec = (2 * 144 + 50 + 16 + 304) * 1000;
+    break;
+  case WIFI_PHY_STANDARD_80211_10Mhz: 
+    m_overheadNanosec = (2 * 32 + 58 + 32 + 88) * 1000;
+    break;
+  case WIFI_PHY_STANDARD_80211_5Mhz:
+    m_overheadNanosec = (2 * 64 + 106 + 64 + 176) * 1000;
+    break;
+  default:
+    NS_ASSERT (false);
+    break;
+  }
+}
 uint32_t
 AirtimeLinkMetricCalculator::CalculateMetric (Mac48Address peerAddress, Ptr<MeshWifiInterfaceMac> mac)
 {
@@ -80,6 +99,7 @@
 
   WifiRemoteStation * station = mac->GetStationManager ()->Lookup (peerAddress);
   NS_ASSERT (station != 0);
+  NS_ASSERT (m_overheadNanosec != 0);
   Ptr<Packet> test_frame = Create<Packet> (m_testLength + m_meshHeaderLength);
   uint32_t rate =
       station->GetDataMode (test_frame, m_testLength + m_meshHeaderLength).GetDataRate ();
--- a/src/devices/mesh/dot11s/airtime-metric.h	Tue Dec 01 18:34:11 2009 +0300
+++ b/src/devices/mesh/dot11s/airtime-metric.h	Wed Dec 02 19:58:59 2009 +0300
@@ -42,7 +42,9 @@
 class AirtimeLinkMetricCalculator : public Object
 {
 public:
+  AirtimeLinkMetricCalculator ();
   static TypeId GetTypeId ();
+  void SetPhyStandard (WifiPhyStandard standard);
   uint32_t CalculateMetric (Mac48Address peerAddress, Ptr<MeshWifiInterfaceMac> mac);
 private:
   /// Overhead expressed in nanoseconds:DIFS + SIFS + 2 * PREAMBLE + ACK
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Tue Dec 01 18:34:11 2009 +0300
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed Dec 02 19:58:59 2009 +0300
@@ -710,6 +710,7 @@
       //Installing airtime link metric:
       Ptr<AirtimeLinkMetricCalculator> metric = CreateObject <AirtimeLinkMetricCalculator> ();
       mac->SetLinkMetricCallback (MakeCallback (&AirtimeLinkMetricCalculator::CalculateMetric, metric));
+      metric->SetPhyStandard (mac->GetPhyStandard ());
     }
   mp->SetRoutingProtocol (this);
   // Mesh point aggregates all installed protocols
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-1-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-2-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-3-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-proactive-regression-test-4-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-1-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-2-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-3-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-4-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-reactive-regression-test-5-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-0-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-1-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-2-1.pcap has changed
Binary file src/devices/mesh/dot11s/test/hwmp-target-flags-regression-test-3-1.pcap has changed
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc	Tue Dec 01 18:34:11 2009 +0300
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc	Wed Dec 02 19:58:59 2009 +0300
@@ -81,7 +81,8 @@
                   ;
   return tid;
 }
-MeshWifiInterfaceMac::MeshWifiInterfaceMac ()
+MeshWifiInterfaceMac::MeshWifiInterfaceMac () :
+  m_standard (WIFI_PHY_STANDARD_80211a)
 {
   NS_LOG_FUNCTION (this);
 
@@ -747,7 +748,12 @@
       NS_ASSERT (false);
       break;
     }
+  m_standard = standard;
 }
-
+WifiPhyStandard
+MeshWifiInterfaceMac::GetPhyStandard () const
+{
+  return m_standard;
+}
 } // namespace ns3
 
--- a/src/devices/mesh/mesh-wifi-interface-mac.h	Tue Dec 01 18:34:11 2009 +0300
+++ b/src/devices/mesh/mesh-wifi-interface-mac.h	Wed Dec 02 19:58:59 2009 +0300
@@ -159,6 +159,7 @@
   /// Enable/disable beacons
   void SetBeaconGeneration (bool enable);
   void SetQueue (AccessClass ac);
+  WifiPhyStandard GetPhyStandard () const;
   virtual void FinishConfigureStandard (enum WifiPhyStandard standard);
 private:
   /// Frame receive handler
@@ -246,7 +247,8 @@
   ///\}
   TracedCallback<WifiMacHeader const &> m_txOkCallback;
   TracedCallback<WifiMacHeader const &> m_txErrCallback;
-
+  /// Current PHY standard: needed to configure metric
+  WifiPhyStandard m_standard;
 };
 
 } // namespace ns3