src/wifi/model/ctrl-headers.h
changeset 10483 e3a02ed14587
parent 7386 2310ed220a61
child 11450 9f4ae69f12b7
equal deleted inserted replaced
10482:b470331449bc 10483:e3a02ed14587
    22 
    22 
    23 #include "ns3/header.h"
    23 #include "ns3/header.h"
    24 
    24 
    25 namespace ns3 {
    25 namespace ns3 {
    26 
    26 
       
    27 /**
       
    28  * Enumeration for different block ACK policies.
       
    29  */
    27 enum BlockAckType
    30 enum BlockAckType
    28 {
    31 {
    29   BASIC_BLOCK_ACK,
    32   BASIC_BLOCK_ACK,
    30   COMPRESSED_BLOCK_ACK,
    33   COMPRESSED_BLOCK_ACK,
    31   MULTI_TID_BLOCK_ACK
    34   MULTI_TID_BLOCK_ACK
    53   virtual void Print (std::ostream &os) const;
    56   virtual void Print (std::ostream &os) const;
    54   virtual uint32_t GetSerializedSize (void) const;
    57   virtual uint32_t GetSerializedSize (void) const;
    55   virtual void Serialize (Buffer::Iterator start) const;
    58   virtual void Serialize (Buffer::Iterator start) const;
    56   virtual uint32_t Deserialize (Buffer::Iterator start);
    59   virtual uint32_t Deserialize (Buffer::Iterator start);
    57 
    60 
       
    61   /**
       
    62    * Enable or disable HT immediate ACK.
       
    63    *
       
    64    * \param immediateAck enable or disable HT immediate ACK
       
    65    */
    58   void SetHtImmediateAck (bool immediateAck);
    66   void SetHtImmediateAck (bool immediateAck);
       
    67   /**
       
    68    * Set the block ACK type.
       
    69    *
       
    70    * \param type
       
    71    */
    59   void SetType (enum BlockAckType type);
    72   void SetType (enum BlockAckType type);
       
    73   /**
       
    74    * Set Traffic ID (TID).
       
    75    *
       
    76    * \param tid
       
    77    */
    60   void SetTidInfo (uint8_t tid);
    78   void SetTidInfo (uint8_t tid);
       
    79   /**
       
    80    * Set the starting sequence number from the given 
       
    81    * raw sequence control field.
       
    82    *
       
    83    * \param seq the raw sequence control 
       
    84    */
    61   void SetStartingSequence (uint16_t seq);
    85   void SetStartingSequence (uint16_t seq);
    62 
    86 
       
    87   /**
       
    88    * Check if the current ACK policy is immediate.
       
    89    *
       
    90    * \return true if the current ACK policy is immediate,
       
    91    *         false otherwise
       
    92    */
    63   bool MustSendHtImmediateAck (void) const;
    93   bool MustSendHtImmediateAck (void) const;
       
    94   /**
       
    95    * Return the Traffic ID (TID).
       
    96    *
       
    97    * \return TID
       
    98    */
    64   uint8_t GetTidInfo (void) const;
    99   uint8_t GetTidInfo (void) const;
       
   100   /**
       
   101    * Return the starting sequence number.
       
   102    *
       
   103    * \return the starting sequence number
       
   104    */
    65   uint16_t GetStartingSequence (void) const;
   105   uint16_t GetStartingSequence (void) const;
       
   106   /**
       
   107    * Check if the current ACK policy is basic
       
   108    * (i.e. not multiple TID and not compressed ACK).
       
   109    *
       
   110    * \return true if the current ACK policy is basic,
       
   111    *         false otherwise
       
   112    */
    66   bool IsBasic (void) const;
   113   bool IsBasic (void) const;
       
   114   /**
       
   115    * Check if the current ACK policy is compressed ACK
       
   116    * and not multiple TID.
       
   117    *
       
   118    * \return true if the current ACK policy is compressed ACK,
       
   119    *         false otherwise
       
   120    */
    67   bool IsCompressed (void) const;
   121   bool IsCompressed (void) const;
       
   122   /**
       
   123    * Check if the current ACK policy has multiple TID.
       
   124    *
       
   125    * \return true if the current ACK policy has multiple TID,
       
   126    *         false otherwise
       
   127    */
    68   bool IsMultiTid (void) const;
   128   bool IsMultiTid (void) const;
    69 
   129 
       
   130   /**
       
   131    * Return the starting sequence control.
       
   132    *
       
   133    * \return the starting sequence control
       
   134    */
    70   uint16_t GetStartingSequenceControl (void) const;
   135   uint16_t GetStartingSequenceControl (void) const;
    71 
   136 
    72 private:
   137 private:
       
   138   /**
       
   139    * Set the starting sequence control with the given
       
   140    * sequence control value
       
   141    *
       
   142    * \param seqControl
       
   143    */
    73   void SetStartingSequenceControl (uint16_t seqControl);
   144   void SetStartingSequenceControl (uint16_t seqControl);
       
   145   /**
       
   146    * Return the Block ACK control.
       
   147    *
       
   148    * \return the Block ACK control
       
   149    */
    74   uint16_t GetBarControl (void) const;
   150   uint16_t GetBarControl (void) const;
       
   151   /**
       
   152    * Set the Block ACK control.
       
   153    *
       
   154    * \param bar
       
   155    */
    75   void SetBarControl (uint16_t bar);
   156   void SetBarControl (uint16_t bar);
    76 
   157 
    77   /**
   158   /**
    78    * The lsb bit of the BAR control field is used only for the
   159    * The lsb bit of the BAR control field is used only for the
    79    * HT (High Throughput) delayed block ack configuration.
   160    * HT (High Throughput) delayed block ack configuration.
   109   virtual void Print (std::ostream &os) const;
   190   virtual void Print (std::ostream &os) const;
   110   virtual uint32_t GetSerializedSize (void) const;
   191   virtual uint32_t GetSerializedSize (void) const;
   111   virtual void Serialize (Buffer::Iterator start) const;
   192   virtual void Serialize (Buffer::Iterator start) const;
   112   virtual uint32_t Deserialize (Buffer::Iterator start);
   193   virtual uint32_t Deserialize (Buffer::Iterator start);
   113 
   194 
   114   void SetHtImmediateAck (bool immeadiateAck);
   195   /**
       
   196    * Enable or disable HT immediate ACK.
       
   197    *
       
   198    * \param immediateAck enable or disable HT immediate ACK
       
   199    */
       
   200   void SetHtImmediateAck (bool immediateAck);
       
   201   /**
       
   202    * Set the block ACK type.
       
   203    *
       
   204    * \param type
       
   205    */
   115   void SetType (enum BlockAckType type);
   206   void SetType (enum BlockAckType type);
       
   207   /**
       
   208    * Set Traffic ID (TID).
       
   209    *
       
   210    * \param tid
       
   211    */
   116   void SetTidInfo (uint8_t tid);
   212   void SetTidInfo (uint8_t tid);
       
   213   /**
       
   214    * Set the starting sequence number from the given 
       
   215    * raw sequence control field.
       
   216    *
       
   217    * \param seq the raw sequence control 
       
   218    */
   117   void SetStartingSequence (uint16_t seq);
   219   void SetStartingSequence (uint16_t seq);
   118 
   220 
       
   221   /**
       
   222    * Check if the current ACK policy is immediate.
       
   223    *
       
   224    * \return true if the current ACK policy is immediate,
       
   225    *         false otherwise
       
   226    */
   119   bool MustSendHtImmediateAck (void) const;
   227   bool MustSendHtImmediateAck (void) const;
       
   228   /**
       
   229    * Return the Traffic ID (TID).
       
   230    *
       
   231    * \return TID
       
   232    */
   120   uint8_t GetTidInfo (void) const;
   233   uint8_t GetTidInfo (void) const;
       
   234   /**
       
   235    * Return the starting sequence number.
       
   236    *
       
   237    * \return the starting sequence number
       
   238    */
   121   uint16_t GetStartingSequence (void) const;
   239   uint16_t GetStartingSequence (void) const;
       
   240   /**
       
   241    * Check if the current ACK policy is basic
       
   242    * (i.e. not multiple TID and not compressed ACK).
       
   243    *
       
   244    * \return true if the current ACK policy is basic,
       
   245    *         false otherwise
       
   246    */
   122   bool IsBasic (void) const;
   247   bool IsBasic (void) const;
       
   248   /**
       
   249    * Check if the current ACK policy is compressed ACK
       
   250    * and not multiple TID.
       
   251    *
       
   252    * \return true if the current ACK policy is compressed ACK,
       
   253    *         false otherwise
       
   254    */
   123   bool IsCompressed (void) const;
   255   bool IsCompressed (void) const;
       
   256   /**
       
   257    * Check if the current ACK policy has multiple TID.
       
   258    *
       
   259    * \return true if the current ACK policy has multiple TID,
       
   260    *         false otherwise
       
   261    */
   124   bool IsMultiTid (void) const;
   262   bool IsMultiTid (void) const;
   125 
   263 
       
   264   /**
       
   265    * Set the bitmap that the packet with the given sequence
       
   266    * number was received.
       
   267    *
       
   268    * \param seq
       
   269    */
   126   void SetReceivedPacket (uint16_t seq);
   270   void SetReceivedPacket (uint16_t seq);
       
   271   /**
       
   272    * Set the bitmap that the packet with the given sequence
       
   273    * number and fragment number was received.
       
   274    *
       
   275    * \param seq
       
   276    * \param frag
       
   277    */
   127   void SetReceivedFragment (uint16_t seq, uint8_t frag);
   278   void SetReceivedFragment (uint16_t seq, uint8_t frag);
       
   279   /**
       
   280    * Check if the packet with the given sequence number
       
   281    * was ACKed in this Block ACK response.
       
   282    *
       
   283    * \param seq
       
   284    * \return true if the packet with the given sequence number
       
   285    *         was ACKed in this Block ACK response, false otherwise
       
   286    */
   128   bool IsPacketReceived (uint16_t seq) const;
   287   bool IsPacketReceived (uint16_t seq) const;
       
   288   /**
       
   289    * Check if the packet with the given sequence number
       
   290    * and fragment number was ACKed in this Block ACK response.
       
   291    *
       
   292    * \param seq
       
   293    * \param frag
       
   294    * \return true if the packet with the given sequence number
       
   295    *         and sequence number was ACKed in this Block ACK response,
       
   296    *         false otherwise
       
   297    */
   129   bool IsFragmentReceived (uint16_t seq, uint8_t frag) const;
   298   bool IsFragmentReceived (uint16_t seq, uint8_t frag) const;
   130 
   299 
       
   300   /**
       
   301    * Return the starting sequence control.
       
   302    *
       
   303    * \return the starting sequence control
       
   304    */
   131   uint16_t GetStartingSequenceControl (void) const;
   305   uint16_t GetStartingSequenceControl (void) const;
       
   306   /**
       
   307    * Set the starting sequence control with the given
       
   308    * sequence control value
       
   309    *
       
   310    * \param seqControl
       
   311    */
   132   void SetStartingSequenceControl (uint16_t seqControl);
   312   void SetStartingSequenceControl (uint16_t seqControl);
       
   313   /**
       
   314    * Return the bitmap from the block ACK response header.
       
   315    *
       
   316    * \return the bitmap from the block ACK response header
       
   317    */
   133   const uint16_t* GetBitmap (void) const;
   318   const uint16_t* GetBitmap (void) const;
       
   319   /**
       
   320    * Return the compressed bitmap from the block ACK response header.
       
   321    *
       
   322    * \return the compressed bitmap from the block ACK response header
       
   323    */
   134   uint64_t GetCompressedBitmap (void) const;
   324   uint64_t GetCompressedBitmap (void) const;
   135 
   325 
       
   326   /**
       
   327    * Reset the bitmap to 0.
       
   328    */
   136   void ResetBitmap (void);
   329   void ResetBitmap (void);
   137 
   330 
   138 private:
   331 private:
       
   332   /**
       
   333    * Return the block ACK control.
       
   334    *
       
   335    * \return the block ACK control
       
   336    */
   139   uint16_t GetBaControl (void) const;
   337   uint16_t GetBaControl (void) const;
       
   338   /**
       
   339    * Set the block ACK control.
       
   340    *
       
   341    * \param bar
       
   342    */
   140   void SetBaControl (uint16_t bar);
   343   void SetBaControl (uint16_t bar);
   141 
   344 
       
   345   /**
       
   346    * Serialize bitmap to the given buffer.
       
   347    *
       
   348    * \param start
       
   349    * \return Buffer::Iterator to the next available buffer
       
   350    */
   142   Buffer::Iterator SerializeBitmap (Buffer::Iterator start) const;
   351   Buffer::Iterator SerializeBitmap (Buffer::Iterator start) const;
       
   352   /**
       
   353    * Deserialize bitmap from the given buffer.
       
   354    *
       
   355    * \param start
       
   356    * \return Buffer::Iterator to the next available buffer
       
   357    */
   143   Buffer::Iterator DeserializeBitmap (Buffer::Iterator start);
   358   Buffer::Iterator DeserializeBitmap (Buffer::Iterator start);
   144 
   359 
   145   /**
   360   /**
   146    * This function is used to correctly index in both bitmap
   361    * This function is used to correctly index in both bitmap
   147    * and compressed bitmap, one bit or one block of 16 bits respectively.
   362    * and compressed bitmap, one bit or one block of 16 bits respectively.