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  * Authors: Kirill Andreev <andreev@iitp.ru>
19  *          Aleksey Kovalenko <kovalenko@iitp.ru>
20  *          Pavel Boyko <boyko@iitp.ru>
21  */
22 
23 #ifndef HWMP_TAG_H
24 #define HWMP_TAG_H
25 
26 #include "ns3/tag.h"
27 #include "ns3/object.h"
28 #include "ns3/mac48-address.h"
29 namespace ns3 {
30 namespace dot11s {
31 /**
32  * \ingroup dot11s
33  *
34  * \brief Hwmp tag implements interaction between HWMP
35  * protocol and MeshWifiMac
36  *
37  * Hwmp tag keeps the following:
38  * 1. When packet is passed from Hwmp to 11sMAC:
39  *  - retransmitter address,
40  *  - TTL value,
41  * 2. When packet is passed to Hwmp from 11sMAC:
42  *  - lasthop address,
43  *  - TTL value,
44  *  - metric value (metric of link is recalculated
45  *  at each packet, but routing table stores metric
46  *  obtained during path discovery procedure)
47  */
48 class HwmpTag : public Tag
49 {
50 public:
51   HwmpTag ();
52   ~HwmpTag ();
53   /**
54    * Set address
55    * \param retransmitter the MAC address of the retransmitter
56    */
57   void SetAddress (Mac48Address retransmitter);
58   /**
59    * Get address from tag
60    * \return the MAC address
61    */
62   Mac48Address GetAddress ();
63   /**
64    * Set the TTL value
65    * \param ttl
66    */
67   void SetTtl (uint8_t ttl);
68   /**
69    * Get the TTL value
70    * \returns the TTL
71    */
72   uint8_t GetTtl ();
73   /**
74    * Set the metric value
75    * \param metric the metric
76    */
77   void SetMetric (uint32_t metric);
78   /**
79    * Get the metric value
80    * \returns the metric
81    */
82   uint32_t GetMetric ();
83   /**
84    * Set sequence number
85    * \param seqno the sequence number
86    */
87   void SetSeqno (uint32_t seqno);
88   /**
89    * Get the sequence number
90    * \returns the sequence number
91    */
92   uint32_t GetSeqno ();
93   /// Decrement TTL
94   void  DecrementTtl ();
95 
96   /**
97    * \brief Get the type ID.
98    * \return the object TypeId
99    */
100   static  TypeId  GetTypeId ();
101   virtual TypeId  GetInstanceTypeId () const;
102   virtual uint32_t GetSerializedSize () const;
103   virtual void  Serialize (TagBuffer i) const;
104   virtual void  Deserialize (TagBuffer i);
105   virtual void  Print (std::ostream &os) const;
106 private:
107   Mac48Address m_address; ///< address
108   uint8_t  m_ttl; ///< TTL
109   uint32_t m_metric; ///< metric
110   uint32_t m_seqno; ///< sequence no
111 };
112 } // namespace dot11s
113 } // namespace ns3
114 #endif
115