A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ie-dot11s-configuration.cc
Go to the documentation of this file.
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  */
21 
23 #include "ns3/packet.h"
24 namespace ns3 {
25 namespace dot11s {
26 
28  acceptPeerLinks (true), MCCASupported (false), MCCAEnabled (false), forwarding (true), beaconTimingReport (
29  true), TBTTAdjustment (true), powerSaveLevel (false)
30 {
31 }
32 uint8_t
34 {
35  return 2;
36 }
37 uint16_t
39 {
40  uint16_t result = 0;
41  if (acceptPeerLinks)
42  {
43  result |= 1 << 0;
44  }
45  if (MCCASupported)
46  {
47  result |= 1 << 1;
48  }
49  if (MCCAEnabled)
50  {
51  result |= 1 << 2;
52  }
53  if (forwarding)
54  {
55  result |= 1 << 3;
56  }
58  {
59  result |= 1 << 4;
60  }
61  if (TBTTAdjustment)
62  {
63  result |= 1 << 5;
64  }
65  if (powerSaveLevel)
66  {
67  result |= 1 << 6;
68  }
69  return result;
70 }
73 {
75  return i;
76 }
79 {
80  uint16_t cap = i.ReadLsbtohU16 ();
81  acceptPeerLinks = Is (cap, 0);
82  MCCASupported = Is (cap, 1);
83  MCCAEnabled = Is (cap, 2);
84  forwarding = Is (cap, 3);
85  beaconTimingReport = Is (cap, 4);
86  TBTTAdjustment = Is (cap, 5);
87  powerSaveLevel = Is (cap, 6);
88  return i;
89 }
90 bool
91 Dot11sMeshCapability::Is (uint16_t cap, uint8_t n) const
92 {
93  uint16_t mask = 1 << n;
94  return (cap & mask);
95 }
98 {
100 }
101 
103  m_APSPId (PROTOCOL_HWMP), m_APSMId (METRIC_AIRTIME), m_CCMId (CONGESTION_NULL), m_SPId (
104  SYNC_NEIGHBOUR_OFFSET), m_APId (AUTH_NULL), m_neighbors (0)
105 {
106 }
107 uint8_t
109 {
110  return 1 // Version
111  + 4 // APSPId
112  + 4 // APSMId
113  + 4 // CCMId
114  + 4 // SPId
115  + 4 // APId
116  + 1 // Mesh formation info (see 7.3.2.86.6 of 802.11s draft 3.0)
118 }
119 void
121 {
122  i.WriteU8 (1); //Version
123  // Active Path Selection Protocol ID:
125  // Active Path Metric ID:
127  // Congestion Control Mode ID:
129  // Sync:
131  // Auth:
133  i.WriteU8 (m_neighbors << 1);
134  m_meshCap.Serialize (i);
135 }
136 uint8_t
138 {
140  uint8_t version;
141  version = i.ReadU8 ();
142  if (version != 1)
143  {
144  NS_FATAL_ERROR ("Other versions not supported yet");
145  }
146  // Active Path Selection Protocol ID:
148  // Active Path Metric ID:
150  // Congestion Control Mode ID:
154  m_neighbors = (i.ReadU8 () >> 1) & 0xF;
155  i = m_meshCap.Deserialize (i);
156  return i.GetDistanceFrom (start);
157 }
158 void
159 IeConfiguration::Print (std::ostream& os) const
160 {
161  os << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
162  os << "Number of neighbors: = " << (uint16_t) m_neighbors
163  << std::endl << "Active Path Selection Protocol ID: = " << (uint32_t) m_APSPId
164  << std::endl << "Active Path Selection Metric ID: = " << (uint32_t) m_APSMId
165  << std::endl << "Congestion Control Mode ID: = " << (uint32_t) m_CCMId
166  << std::endl << "Synchronize protocol ID: = " << (uint32_t) m_SPId
167  << std::endl << "Authentication protocol ID: = " << (uint32_t) m_APId
168  << std::endl << "Capabilities: = " << m_meshCap.GetUint16 () << std::endl;
169  os << "</information_element>" << std::endl;
170 }
171 void
173 {
174  m_APSPId = routingId;
175 }
176 void
178 {
179  m_APSMId = metricId;
180 }
181 bool
183 {
184  return (m_APSPId == PROTOCOL_HWMP);
185 }
186 bool
188 {
189  return (m_APSMId == METRIC_AIRTIME);
190 }
191 void
193 {
194  m_neighbors = (neighbors > 31) ? 31 : neighbors;
195 }
196 uint8_t
198 {
199  return m_neighbors;
200 }
203 {
204  return m_meshCap;
205 }
206 bool
208 {
209  return ((a.acceptPeerLinks == b.acceptPeerLinks) && (a.MCCASupported == b.MCCASupported) && (a.MCCAEnabled
212 }
213 bool
215 {
216  return ((a.m_APSPId == b.m_APSPId) && (a.m_APSMId == b.m_APSMId) && (a.m_CCMId == b.m_CCMId) && (a.m_SPId
217  == b.m_SPId) && (a.m_APId == b.m_APId) && (a.m_neighbors == b.m_neighbors) && (a.m_meshCap
218  == b.m_meshCap));
219 }
220 std::ostream &
221 operator << (std::ostream &os, const IeConfiguration &a)
222 {
223  a.Print (os);
224  return os;
225 }
226 } // namespace dot11s
227 } // namespace ns3
228