wifi: Fill BSS color in TxVector and add trace source to be fired at the end of 802.11ax preamble
authorSébastien Deronne <sebastien.deronne@gmail.com>
Mon, 03 Dec 2018 21:48:44 +0100
changeset 13878 0cb5fc48c184
parent 13877 8ce4c7c7398c
child 13879 8ffe454e52c1
wifi: Fill BSS color in TxVector and add trace source to be fired at the end of 802.11ax preamble
CHANGES.html
src/wifi/model/wifi-phy.cc
src/wifi/model/wifi-phy.h
src/wifi/model/wifi-remote-station-manager.cc
src/wifi/model/wifi-tx-vector.cc
src/wifi/model/wifi-tx-vector.h
--- a/CHANGES.html	Mon Dec 03 21:18:05 2018 +0100
+++ b/CHANGES.html	Mon Dec 03 21:48:44 2018 +0100
@@ -62,6 +62,7 @@
 </li>
 <li>New attributes <b>QosTxop::AddBaResponseTimeout</b> and <b>QosTxop::FailedAddBaTimeout</b> have been added to set the timeout to wait for an ADDBA response after the ACK to the ADDBA request is received and to set the timeout after a failed BA agreement, respectively.
 </li>
+  <li> Added a new trace source <b>EndOfHePreamble</b> in WifiPhy for tracing end of preamble (after training fields) for received 802.11ax packets.</li>
 </ul>
 <h2>Changes to existing API:</h2>
 <ul>
--- a/src/wifi/model/wifi-phy.cc	Mon Dec 03 21:18:05 2018 +0100
+++ b/src/wifi/model/wifi-phy.cc	Mon Dec 03 21:48:44 2018 +0100
@@ -367,6 +367,10 @@
                      "in monitor mode to sniff all frames being transmitted",
                      MakeTraceSourceAccessor (&WifiPhy::m_phyMonitorSniffTxTrace),
                      "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
+    .AddTraceSource ("EndOfHePreamble",
+                     "Trace source indicating the end of the 802.11ax preamble (after training fields)",
+                     MakeTraceSourceAccessor (&WifiPhy::m_phyEndOfHePreambleTrace),
+                     "ns3::WifiPhy::EndOfHePreambleTracedCallback")
   ;
   return tid;
 }
@@ -2381,6 +2385,12 @@
 }
 
 void
+WifiPhy::NotifyEndOfHePreamble (HePreambleParameters params)
+{
+  m_phyEndOfHePreambleTrace (params);
+}
+
+void
 WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType mpdutype)
 {
   NS_LOG_FUNCTION (this << packet << txVector.GetMode ()
@@ -2654,6 +2664,13 @@
         {
           NS_LOG_DEBUG ("receiving plcp payload"); //endReceive is already scheduled
           m_plcpSuccess = true;
+          if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HE)
+            {
+              HePreambleParameters params;
+              params.rssiW = event->GetRxPowerW ();
+              params.bssColor = txVector.GetBssColor ();
+              NotifyEndOfHePreamble (params);
+            }
         }
       else //mode is not allowed
         {
--- a/src/wifi/model/wifi-phy.h	Mon Dec 03 21:18:05 2018 +0100
+++ b/src/wifi/model/wifi-phy.h	Mon Dec 03 21:48:44 2018 +0100
@@ -59,6 +59,13 @@
   uint32_t mpduRefNumber; ///< MPDU ref number
 };
 
+// Parameters for receive HE preamble
+struct HePreambleParameters
+{
+  double rssiW; ///< RSSI in W
+  uint8_t bssColor; ///< BSS color
+};
+
 /**
  * \brief 802.11 PHY layer model
  * \ingroup wifi
@@ -1204,6 +1211,21 @@
                                             MpduInfo aMpdu);
 
   /**
+   * Public method used to fire a EndOfHePreamble trace once both HE SIG fields have been received, as well as training fields.
+   *
+   * \param params the HE preamble parameters
+   */
+  void NotifyEndOfHePreamble (HePreambleParameters params);
+
+  /**
+   * TracedCallback signature for end of HE-SIG-A events.
+   *
+   *
+   * \param params the HE preamble parameters
+   */
+  typedef void (* EndOfHePreambleCallback)(HePreambleParameters params);
+
+  /**
    * Assign a fixed random variable stream number to the random variables
    * used by this model. Return the number of streams (possibly zero) that
    * have been assigned.
@@ -1754,6 +1776,13 @@
   TracedCallback<Ptr<const Packet>, uint16_t, WifiTxVector, MpduInfo> m_phyMonitorSniffTxTrace;
 
   /**
+   * A trace source that indiates the end of both HE SIG fields as well as training fields for received 802.11ax packets
+   *
+   * \see class CallBackTraceSource
+   */
+  TracedCallback<HePreambleParameters> m_phyEndOfHePreambleTrace;
+
+  /**
    * This vector holds the set of transmission modes that this
    * WifiPhy(-derived class) can support. In conversation we call this
    * the DeviceRateSet (not a term you'll find in the standard), and
--- a/src/wifi/model/wifi-remote-station-manager.cc	Mon Dec 03 21:18:05 2018 +0100
+++ b/src/wifi/model/wifi-remote-station-manager.cc	Mon Dec 03 21:48:44 2018 +0100
@@ -588,6 +588,14 @@
       txVector.SetChannelWidth (GetChannelWidthForTransmission (mgtMode, m_wifiPhy->GetChannelWidth ()));
       txVector.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mgtMode, DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ())));
     }
+  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_wifiPhy->GetDevice ());
+  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
+  if (heConfiguration)
+    {
+      UintegerValue bssColor;
+      heConfiguration->GetAttribute ("BssColor", bssColor);
+      txVector.SetBssColor (bssColor.Get ());
+    }
   return txVector;
 }
 
--- a/src/wifi/model/wifi-tx-vector.cc	Mon Dec 03 21:18:05 2018 +0100
+++ b/src/wifi/model/wifi-tx-vector.cc	Mon Dec 03 21:48:44 2018 +0100
@@ -32,6 +32,7 @@
     m_ness (0),
     m_aggregation (false),
     m_stbc (false),
+    m_bssColor (0),
     m_modeInitialized (false),
     m_txPowerLevelInitialized (false)
 {
@@ -46,7 +47,8 @@
                             uint8_t ness,
                             uint16_t channelWidth,
                             bool aggregation,
-                            bool stbc)
+                            bool stbc,
+                            uint8_t bssColor)
   : m_mode (mode),
     m_txPowerLevel (powerLevel),
     m_preamble (preamble),
@@ -57,6 +59,7 @@
     m_ness (ness),
     m_aggregation (aggregation),
     m_stbc (stbc),
+    m_bssColor (bssColor),
     m_modeInitialized (true),
     m_txPowerLevelInitialized (true)
 {
@@ -192,6 +195,18 @@
   m_stbc = stbc;
 }
 
+void
+WifiTxVector::SetBssColor (uint8_t color)
+{
+  m_bssColor = color;
+}
+
+uint8_t
+WifiTxVector::GetBssColor (void) const
+{
+  return m_bssColor;
+}
+
 bool
 WifiTxVector::IsValid (void) const
 {
--- a/src/wifi/model/wifi-tx-vector.h	Mon Dec 03 21:18:05 2018 +0100
+++ b/src/wifi/model/wifi-tx-vector.h	Mon Dec 03 21:48:44 2018 +0100
@@ -75,6 +75,7 @@
    * \param channelWidth the channel width in MHz
    * \param aggregation enable or disable MPDU aggregation
    * \param stbc enable or disable STBC
+   * \param bssColor the BSS color
    */
   WifiTxVector (WifiMode mode,
                 uint8_t powerLevel,
@@ -85,7 +86,8 @@
                 uint8_t ness,
                 uint16_t channelWidth,
                 bool aggregation,
-                bool stbc);
+                bool stbc,
+                uint8_t bssColor = 0);
   /**
    * \returns the selected payload transmission mode
    */
@@ -192,6 +194,16 @@
    */
   void SetStbc (bool stbc);
   /**
+   * Set the BSS color
+   * \param color the BSS color
+   */
+  void SetBssColor (uint8_t color);
+  /**
+   * Get the BSS color
+   * \return the BSS color
+   */
+  uint8_t GetBssColor (void) const;
+  /**
    * The standard disallows certain combinations of WifiMode, number of
    * spatial streams, and channel widths.  This method can be used to
    * check whether this WifiTxVector contains an invalid combination.
@@ -216,6 +228,7 @@
   uint8_t  m_ness;               /**< number of spatial streams in beamforming */
   bool     m_aggregation;        /**< Flag whether the PSDU contains A-MPDU. */
   bool     m_stbc;               /**< STBC used or not */
+  uint8_t  m_bssColor;           /**< BSS color */
 
   bool     m_modeInitialized;         /**< Internal initialization flag */
   bool     m_txPowerLevelInitialized; /**< Internal initialization flag */