src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu Nov 12 13:01:01 2009 +0100 (2009-11-12)
changeset 5505 c0ac392289c3
parent 5184 a109c38131dd
child 6273 8d70de29d514
permissions -rw-r--r--
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2008,2009 IITP RAS
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License version 2 as
     7  * published by the Free Software Foundation;
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17  *
    18  * Author: Kirill Andreev <andreev@iitp.ru>
    19  */
    20 
    21 #ifndef WIFI_TIMING_ELEMENT_H
    22 #define WIFI_TIMING_ELEMENT_H
    23 
    24 #include <vector>
    25 #include "ns3/nstime.h"
    26 #include "ns3/wifi-information-element-vector.h"
    27 
    28 namespace ns3 {
    29 namespace dot11s {
    30 /**
    31  * \ingroup dot11s
    32  * \brief Describes one unit of beacon timing element
    33  */
    34 class IeBeaconTimingUnit : public SimpleRefCount<IeBeaconTimingUnit>
    35 {
    36 public:
    37   IeBeaconTimingUnit ();
    38   void SetAid (uint8_t aid);
    39   void SetLastBeacon (uint16_t lastBeacon);
    40   void SetBeaconInterval (uint16_t beaconInterval);
    41 
    42   uint8_t GetAid () const;
    43   uint16_t GetLastBeacon () const;
    44   uint16_t GetBeaconInterval () const;
    45 
    46 private:
    47   /// Least significant octet of AID:
    48   uint8_t m_aid;
    49   /// Last time we received a beacon in accordance with a local TSF measured in 256 microseconds unit
    50   uint16_t m_lastBeacon;
    51   /// Beacon interval of remote mesh point
    52   uint16_t m_beaconInterval;
    53   friend bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b);
    54 };
    55 
    56 /**
    57  * \ingroup dot11s
    58  * \brief See 7.3.2.89 of 802.11s draft 2.07
    59  */
    60 class IeBeaconTiming : public WifiInformationElement
    61 {
    62 public:
    63   /**
    64    * \ingroup dot11s
    65    * This type is a list of timing elements obtained from neigbours with their beacons:
    66    */
    67   typedef std::vector< Ptr<IeBeaconTimingUnit> > NeighboursTimingUnitsList;
    68 
    69   IeBeaconTiming ();
    70   /**
    71    * This methods are needed for beacon collision
    72    * avoidance module:
    73    */
    74   NeighboursTimingUnitsList GetNeighboursTimingElementsList ();
    75   void AddNeighboursTimingElementUnit (
    76     uint16_t aid,
    77     Time last_beacon,
    78     Time beacon_interval
    79   );
    80   void   DelNeighboursTimingElementUnit (
    81     uint16_t aid,
    82     Time  last_beacon,
    83     Time  beacon_interval
    84   );
    85   void   ClearTimingElement ();
    86   /**
    87    * \name Inherited from WifiInformationElement
    88    * \{
    89    */
    90   virtual WifiElementId ElementId () const;
    91   virtual uint8_t  GetInformationSize () const;
    92   virtual void SerializeInformation (Buffer::Iterator i) const;
    93   virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
    94   virtual void Print (std::ostream& os) const;
    95   ///\}
    96   bool operator== (WifiInformationElement const & a);
    97 private:
    98   /**
    99    * Converters:
   100    */
   101   static uint16_t TimestampToU16 (Time x);
   102   static uint16_t BeaconIntervalToU16 (Time x);
   103   static uint8_t AidToU8 (uint16_t x);
   104 
   105   NeighboursTimingUnitsList  m_neighbours;
   106   /**
   107    * Timing element parameters:
   108    */
   109   uint16_t  m_numOfUnits;
   110 };
   111 bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b);
   112 std::ostream &operator << (std::ostream &os, const IeBeaconTiming &beaconTiming);
   113 } // namespace dot11s
   114 } //namespace ns3
   115 #endif