fixed bug 668
authorNicola Baldo <nbaldo@cttc.es>
Tue, 24 Nov 2009 13:59:14 +0100
changeset 5774 0fad665ff307
parent 5770 bb1eea10412f
child 5775 86ff2e00d4ea
fixed bug 668
src/devices/mesh/mesh-wifi-interface-mac.cc
src/devices/wifi/qos-tag.cc
src/devices/wifi/qos-tag.h
src/devices/wifi/qos-utils.cc
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc	Tue Nov 24 10:45:08 2009 +0100
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc	Tue Nov 24 13:59:14 2009 +0100
@@ -401,11 +401,11 @@
   if (packet->RemovePacketTag (tag))
     {
       hdr.SetType (WIFI_MAC_QOSDATA);
-      hdr.SetQosTid (tag.Get ());
+      hdr.SetQosTid (tag.GetTid ());
       //Aftre setting type DsFrom and DsTo fields are reset.
       hdr.SetDsFrom ();
       hdr.SetDsTo ();
-      ac = QosUtilsMapTidToAc (tag.Get ());
+      ac = QosUtilsMapTidToAc (tag.GetTid ());
     }
   m_stats.sentFrames++;
   m_stats.sentBytes += packet->GetSize ();
--- a/src/devices/wifi/qos-tag.cc	Tue Nov 24 10:45:08 2009 +0100
+++ b/src/devices/wifi/qos-tag.cc	Tue Nov 24 13:59:14 2009 +0100
@@ -31,7 +31,7 @@
     .AddConstructor<QosTag> ()
     .AddAttribute ("tid", "The tid that indicates AC which packet belongs",
                    UintegerValue (0),
-                   MakeUintegerAccessor (&QosTag::Get),
+                   MakeUintegerAccessor (&QosTag::GetTid),
                    MakeUintegerChecker<uint8_t> ())
     ;
   return tid;
@@ -49,6 +49,18 @@
 QosTag::QosTag (uint8_t tid):
   m_tid (tid)
 {}
+  
+void
+QosTag::SetTid (uint8_t tid)
+{
+  m_tid = tid;
+}
+
+void
+QosTag::SetUserPriority (UserPriority up)
+{
+  m_tid = up;
+}
 
 uint32_t 
 QosTag::GetSerializedSize (void) const
@@ -65,17 +77,11 @@
 void
 QosTag::Deserialize (TagBuffer i)
 {
-  m_tid = i.ReadU8 ();
-}
-
-void
-QosTag::Set (uint8_t tid)
-{
-  m_tid = tid;
+  m_tid = (UserPriority) i.ReadU8 ();
 }
 
 uint8_t
-QosTag::Get () const
+QosTag::GetTid () const
 {
   return m_tid;
 }
--- a/src/devices/wifi/qos-tag.h	Tue Nov 24 10:45:08 2009 +0100
+++ b/src/devices/wifi/qos-tag.h	Tue Nov 24 13:59:14 2009 +0100
@@ -26,21 +26,79 @@
 
 class Tag;
 
+
+/**
+ * As per IEEE Std. 802.11-2007, Section 6.1.1.1.1, when EDCA is used the
+ * the Traffic ID (TID) value corresponds to one of the User Priority (UP)
+ * values defined by the IEEE Std. 802.1D-2004, Annex G, table G-2.
+ *
+ * Note that this correspondence does not hold for HCCA, since in that
+ * case the mapping between UPs and TIDs should be determined by a
+ * TSPEC element as per IEEE Std. 802.11-2007, Section 7.3.2.30
+ */
+enum UserPriority {
+  UP_BK = 1, /**< background  */
+  UP_BE = 0, /**< best effort (default) */
+  UP_EE = 3, /**< excellent effort  */
+  UP_CL = 4, /**< controlled load */
+  UP_VI = 5, /**< video, < 100ms latency and jitter */
+  UP_VO = 6, /**< voice, < 10ms latency and jitter */
+  UP_NC = 7  /**< network control */
+};
+  
+
+  
+  /**
+   * The aim of the QosTag is to provide means for an Application to
+   * specify the TID which will be used by a QoS-aware WifiMac for a
+   * given traffic flow. Note that the current QosTag class was
+   * designed to be completely mac/wifi specific without any attempt
+   * at being generic. 
+   */
 class QosTag : public Tag
 {
 public:
   static TypeId GetTypeId (void);
   virtual TypeId GetInstanceTypeId (void) const;
-  
+
+  /** 
+   * Create a QosTag with the default TID = 0 (best effort traffic) 
+   */  
   QosTag ();
+
+  /** 
+   * Create a QosTag with the given TID 
+   */  
   QosTag (uint8_t tid);
+
+  /** 
+   * Set the TID to the given value. This assumes that the
+   * application is aware of the QoS support provided by the MAC
+   * layer, and is therefore able to set the correct TID. 
+   * 
+   * @param tid the value of the TID to set
+   */
+  void SetTid (uint8_t tid);
+
+  /** 
+   * Set the TID to the value that corresponds to the requested
+   * UserPriority. Note that, since the mapping of UserPriority to TID
+   * is defined for EDCA only, you should call this method only when
+   * EDCA is used. When using HDCA, QosTag(uint8_t tid) should be used
+   * instead.
+   * 
+   * @param up the requested UserPriority
+   * 
+   */
+  void SetUserPriority (UserPriority up);
+
   virtual void Serialize (TagBuffer i) const;
   virtual void Deserialize (TagBuffer i);
   virtual uint32_t GetSerializedSize () const;
   virtual void Print (std::ostream &os) const;
 
-  uint8_t Get (void) const;
-  void Set (uint8_t tid);
+  uint8_t GetTid (void) const;
+
 private:
   uint8_t m_tid;
 };
--- a/src/devices/wifi/qos-utils.cc	Tue Nov 24 10:45:08 2009 +0100
+++ b/src/devices/wifi/qos-utils.cc	Tue Nov 24 13:59:14 2009 +0100
@@ -61,9 +61,9 @@
   uint8_t tid = 8;
   if (packet->PeekPacketTag (qos))
     {
-      if (qos.Get () < 8)
+      if (qos.GetTid () < 8)
         {
-          tid = qos.Get ();
+          tid = qos.GetTid ();
         }
     }
   return tid;