Review issue 88093: Minor changes in wifi module needed by 802.11s
authorPavel Boyko <boyko@iitp.ru>
Thu, 16 Jul 2009 16:55:20 +0400
changeset 4692 f4cd995f1718
parent 4691 43e7ee285fdc
child 4693 ca8cbdd42786
child 5133 1e44b8fa74cd
Review issue 88093: Minor changes in wifi module needed by 802.11s
src/devices/wifi/mgt-headers.cc
src/devices/wifi/mgt-headers.h
src/devices/wifi/qos-tag.cc
src/devices/wifi/qos-tag.h
src/devices/wifi/wifi-mac-header.cc
src/devices/wifi/wifi-mac-header.h
src/devices/wifi/wifi-remote-station-manager.cc
src/devices/wifi/wifi-remote-station-manager.h
src/devices/wifi/wscript
--- a/src/devices/wifi/mgt-headers.cc	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/mgt-headers.cc	Thu Jul 16 16:55:20 2009 +0400
@@ -108,7 +108,11 @@
 {}
 MgtProbeResponseHeader::~MgtProbeResponseHeader ()
 {}
-
+uint64_t
+MgtProbeResponseHeader::GetTimestamp()
+{
+  return m_timestamp;
+}
 Ssid 
 MgtProbeResponseHeader::GetSsid (void) const
 {
@@ -198,7 +202,7 @@
 MgtProbeResponseHeader::Deserialize (Buffer::Iterator start)
 {
   Buffer::Iterator i = start;
-  i.Next (8); // timestamp
+  m_timestamp = i.ReadNtohU64();
   m_beaconInterval = i.ReadNtohU16 ();
   m_beaconInterval *= 1024;
   i = m_capability.Deserialize (i);
--- a/src/devices/wifi/mgt-headers.h	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/mgt-headers.h	Thu Jul 16 16:55:20 2009 +0400
@@ -116,7 +116,7 @@
   void SetSsid (Ssid ssid);
   void SetBeaconIntervalUs (uint64_t us);
   void SetSupportedRates (SupportedRates rates);
-
+  uint64_t GetTimestamp();
   static TypeId GetTypeId (void);
   virtual TypeId GetInstanceTypeId (void) const;
   virtual void Print (std::ostream &os) const;
@@ -125,6 +125,7 @@
   virtual uint32_t Deserialize (Buffer::Iterator start);
 
 private:
+  uint64_t m_timestamp;
   Ssid m_ssid;
   uint64_t m_beaconInterval;
   SupportedRates m_rates;
--- a/src/devices/wifi/qos-tag.cc	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/qos-tag.cc	Thu Jul 16 16:55:20 2009 +0400
@@ -43,7 +43,11 @@
   return GetTypeId ();
 }
 
-QosTag::QosTag()
+QosTag::QosTag ():
+  m_tid (0)
+{}
+QosTag::QosTag (uint8_t tid):
+  m_tid (tid)
 {}
 
 uint32_t 
--- a/src/devices/wifi/qos-tag.h	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/qos-tag.h	Thu Jul 16 16:55:20 2009 +0400
@@ -33,6 +33,7 @@
   virtual TypeId GetInstanceTypeId (void) const;
   
   QosTag ();
+  QosTag (uint8_t tid);
   virtual void Serialize (TagBuffer i) const;
   virtual void Deserialize (TagBuffer i);
   virtual uint32_t GetSerializedSize () const;
--- a/src/devices/wifi/wifi-mac-header.cc	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/wifi-mac-header.cc	Thu Jul 16 16:55:20 2009 +0400
@@ -128,6 +128,18 @@
   m_ctrlType = TYPE_DATA;
   m_ctrlSubtype = 0;
 }
+void
+WifiMacHeader::SetAction (void)
+{
+ m_ctrlType = TYPE_MGT;
+ m_ctrlSubtype = 0x0D;
+}
+void
+WifiMacHeader::SetMultihopAction (void)
+{
+ m_ctrlType = TYPE_MGT;
+ m_ctrlSubtype = 0x0F;
+}
 void 
 WifiMacHeader::SetType (enum WifiMacType type)
 {
@@ -191,6 +203,15 @@
   case WIFI_MAC_MGT_DEAUTHENTICATION:
     m_ctrlType = TYPE_MGT;
     m_ctrlSubtype = 12;
+  case WIFI_MAC_MGT_ACTION:
+    m_ctrlType = TYPE_MGT;
+    m_ctrlSubtype = 13;
+  case WIFI_MAC_MGT_ACTION_NO_ACK:
+    m_ctrlType = TYPE_MGT;
+    m_ctrlSubtype = 14;
+  case WIFI_MAC_MGT_MULTIHOP_ACTION:
+    m_ctrlType = TYPE_MGT;
+    m_ctrlSubtype = 15;
     break;
 
   case WIFI_MAC_DATA:
@@ -397,6 +418,15 @@
     case 12:
       return WIFI_MAC_MGT_DEAUTHENTICATION;
       break;
+    case 13:
+      return WIFI_MAC_MGT_ACTION;
+      break;
+    case 14:
+      return WIFI_MAC_MGT_ACTION_NO_ACK;
+      break;
+    case 15:
+      return WIFI_MAC_MGT_MULTIHOP_ACTION;
+      break;
 
     }
     break;
@@ -590,6 +620,16 @@
 {
   return (GetType () == WIFI_MAC_MGT_DEAUTHENTICATION)?true:false;
 }
+bool
+WifiMacHeader::IsAction (void) const
+{
+  return (GetType () == WIFI_MAC_MGT_ACTION)?true:false;
+}
+bool
+WifiMacHeader::IsMultihopAction (void) const
+{
+  return (GetType () == WIFI_MAC_MGT_MULTIHOP_ACTION)?true:false;
+}
 
 
 uint16_t 
@@ -810,6 +850,9 @@
     FOO (MGT_PROBE_RESPONSE);
     FOO (MGT_AUTHENTICATION);
     FOO (MGT_DEAUTHENTICATION);
+    FOO (MGT_ACTION);
+    FOO (MGT_ACTION_NO_ACK);
+    FOO (MGT_MULTIHOP_ACTION);
     
     FOO (DATA);
     FOO (DATA_CFACK);
@@ -895,6 +938,16 @@
          << ", BSSID=" << m_addr3 << ", FragNumber=" << m_seqFrag
          << ", SeqNumber=" << m_seqSeq;
       break;
+    case WIFI_MAC_MGT_ACTION:
+    case WIFI_MAC_MGT_ACTION_NO_ACK:
+      PrintFrameControl (os);
+      os << " Duration/ID=" << m_duration << "us"
+         << "DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3
+         << ", FragNumber=" << m_seqFrag << ", SeqNumber=" << m_seqSeq;
+    case WIFI_MAC_MGT_MULTIHOP_ACTION:
+      os << " Duration/ID=" << m_duration << "us"
+         << "RA=" << m_addr1 << ", TA=" << m_addr2 << ", DA=" << m_addr3
+         << ", FragNumber=" << m_seqFrag << ", SeqNumber=" << m_seqSeq;
     case WIFI_MAC_DATA:
       PrintFrameControl (os);
       os << " Duration/ID=" << m_duration << "us";
@@ -916,7 +969,7 @@
         }
       else
         {
-          NS_ASSERT (false);
+          NS_FATAL_ERROR ("Impossible ToDs and FromDs flags combination");
         }
       os << ", FragNumber=" << m_seqFrag
          << ", SeqNumber=" << m_seqSeq;
--- a/src/devices/wifi/wifi-mac-header.h	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/wifi-mac-header.h	Thu Jul 16 16:55:20 2009 +0400
@@ -46,6 +46,9 @@
   WIFI_MAC_MGT_PROBE_RESPONSE,
   WIFI_MAC_MGT_AUTHENTICATION,
   WIFI_MAC_MGT_DEAUTHENTICATION,
+  WIFI_MAC_MGT_ACTION,
+  WIFI_MAC_MGT_ACTION_NO_ACK,
+  WIFI_MAC_MGT_MULTIHOP_ACTION,
 
   WIFI_MAC_DATA,
   WIFI_MAC_DATA_CFACK,
@@ -98,6 +101,8 @@
   void SetProbeResp (void);
   void SetBeacon (void);
   void SetTypeData (void);
+  void SetAction ();
+  void SetMultihopAction();
   void SetDsFrom (void);
   void SetDsNotFrom (void);
   void SetDsTo (void);
@@ -150,6 +155,8 @@
   bool IsDisassociation (void) const;
   bool IsAuthentication (void) const;
   bool IsDeauthentication (void) const;
+  bool IsAction () const;
+  bool IsMultihopAction () const;
   uint16_t GetRawDuration (void) const;
   Time GetDuration (void) const;
   uint16_t GetSequenceControl (void) const;
--- a/src/devices/wifi/wifi-remote-station-manager.cc	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/wifi-remote-station-manager.cc	Thu Jul 16 16:55:20 2009 +0400
@@ -433,7 +433,9 @@
 WifiRemoteStation::WifiRemoteStation ()
   : m_state (BRAND_NEW),
     m_ssrc (0),
-    m_slrc (0)
+    m_slrc (0),
+    m_avgSlrcCoefficient(0.9),
+    m_avgSlrc (0)
 {}
 WifiRemoteStation::~WifiRemoteStation ()
 {}
@@ -557,7 +559,11 @@
 {
   return GetControlAnswerMode (dataMode);
 }
-
+double
+WifiRemoteStation::GetAvgSlrc () const
+{
+  return m_avgSlrc;
+}
 uint32_t 
 WifiRemoteStation::GetNSupportedModes (void) const
 {
@@ -712,6 +718,7 @@
 void 
 WifiRemoteStation::ReportDataOk (double ackSnr, WifiMode ackMode, double dataSnr)
 {
+  m_avgSlrc = m_avgSlrc * m_avgSlrcCoefficient + (double) m_slrc * (1 - m_avgSlrcCoefficient);
   m_slrc = 0;
   DoReportDataOk (ackSnr, ackMode, dataSnr);
 }
--- a/src/devices/wifi/wifi-remote-station-manager.h	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/wifi-remote-station-manager.h	Thu Jul 16 16:55:20 2009 +0400
@@ -260,7 +260,10 @@
    *          handshake.
    */
   WifiMode GetAckMode (WifiMode dataMode);
-
+  /**
+   * \return exponentially weighted average SLRC, this is used by Airtime link metric of 802.11s
+   */
+  double GetAvgSlrc () const;
 private:
   virtual Ptr<WifiRemoteStationManager> GetManager (void) const = 0;
   virtual WifiMode DoGetDataMode (uint32_t size) = 0;
@@ -289,6 +292,8 @@
   SupportedModes m_modes;
   TracedValue<uint32_t> m_ssrc;
   TracedValue<uint32_t> m_slrc;
+  double m_avgSlrcCoefficient;
+  double m_avgSlrc;
 };
 
 } // namespace ns3 
--- a/src/devices/wifi/wscript	Thu Jul 16 15:57:19 2009 +0400
+++ b/src/devices/wifi/wscript	Thu Jul 16 16:55:20 2009 +0400
@@ -106,6 +106,13 @@
         'msdu-aggregator.h',
         'amsdu-subframe-header.h',
         'qos-tag.h',
+# Need this for module devices/mesh
+        'mgt-headers.h',
+        'status-code.h',
+        'capability-information.h',
+        'dcf-manager.h',
+        'mac-rx-middle.h', 
+        'mac-low.h',
         ]
 
     if bld.env['ENABLE_GSL']: