EMANE  1.2.1
macconfig.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - Adjacent Link LLC, Bridgewater, New Jersey
3  * Copyright (c) 2008 - DRS CenGen, LLC, Columbia, Maryland
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of DRS CenGen, LLC nor the names of its
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef EMANEMODELSIEEE802ABGMACCONFIG_HEADER_
35 #define EMANEMODELSIEEE802ABGMACCONFIG_HEADER_
36 
37 
38 #include "emane/types.h"
39 #include "emane/packetinfo.h"
40 #include "emane/registrar.h"
43 
44 #include <string>
45 #include <vector>
46 
47 namespace EMANE
48  {
49  namespace Models
50  {
51  namespace IEEE80211ABG
52  {
53 
54  // currently supporting modes 802.11a, 802.11b, 802.11b/g
60  };
61 
62  // number of queues
63  const std::uint8_t MAX_ACCESS_CATEGORIES{4};
64 
65  const std::uint8_t QUEUE_SIZE_DEFAULT{255};
66 
67  // max packet size
68  const std::uint16_t MAX_PACKET_SIZE{0xFFFF};
69 
70  // modulation type
71  const std::uint8_t MODULATION_TYPE_INDEX_MIN{0};
72  const std::uint8_t MODULATION_TYPE_INDEX_MAX{3};
73 
74 
75  typedef std::vector<float> CWRatioVector;
76  typedef std::vector<CWRatioVector> CWRatioTable;
77 
83  struct ConfigItems
84  {
85  bool bWmmEnable_; // enable wmm
86  bool bPromiscousModeEnable_; // enable promiscous mode
87  bool bFlowControlEnable_; // flow control enable
88  bool bRadioMetricEnable_; // radio metrics enable
89 
90  std::uint8_t u8ModeIndex_; // mode index (modulation type)
91 
92  std::uint8_t u8UnicastDataRateIndex_; // unicast data rate index
93  std::uint8_t u8BroadcastDataRateIndex_; // broadcast data rate index
94  std::uint16_t u16RtsThreshold_; // rtc cts enable threshold
95  std::uint16_t u16FlowControlTokens_; // flow control tokens
96 
97  std::uint32_t u32MaxP2PDistance_; // max p2p distance
98 
99  std::string sPcrUri_; // pcr uri
100 
103  Microseconds radioMetricReportIntervalMicroseconds_; // radio metric report intrval
104  Microseconds neighborMetricDeleteTimeMicroseconds_; // nbr metric delate time (age)
105 
106  std::uint16_t u16CWMin0_; // contention window min category 1
107  std::uint16_t u16CWMin1_; // contention window min category 2
108  std::uint16_t u16CWMin2_; // contention window min category 3
109  std::uint16_t u16CWMin3_; // contention window min category 4
110 
111  std::uint16_t u16CWMax0_; // contention window min category 1
112  std::uint16_t u16CWMax1_; // contention window min category 2
113  std::uint16_t u16CWMax2_; // contention window min category 3
114  std::uint16_t u16CWMax3_; // contention window min category 4
115 
116  Microseconds txopMicroseconds0_; // tx opportunity category 0
117  Microseconds txopMicroseconds1_; // tx opportunity category 1
118  Microseconds txopMicroseconds2_; // tx opportunity category 2
119  Microseconds txopMicroseconds3_; // tx opportunity category 3
120 
121  Microseconds aifsMicroseconds0_; // aifs duration microseconds category 0
122  Microseconds aifsMicroseconds1_; // aifs duration microseconds category 1
123  Microseconds aifsMicroseconds2_; // aifs duration microseconds category 2
124  Microseconds aifsMicroseconds3_; // aifs duration microseconds category 3
125 
126  std::uint8_t u8RetryLimit0_; // retry limit category 0
127  std::uint8_t u8RetryLimit1_; // retry limit category 1
128  std::uint8_t u8RetryLimit2_; // retry limit category 2
129  std::uint8_t u8RetryLimit3_; // retry limit category 3
130 
131  std::uint8_t u8QueueSize0_; // queue size category 0
132  std::uint8_t u8QueueSize1_; // queue size category 1
133  std::uint8_t u8QueueSize2_; // queue size category 2
134  std::uint8_t u8QueueSize3_; // queue size category 3
135 
136  std::uint16_t u16MSDU0_; // max queue entry size category 0
137  std::uint16_t u16MSDU1_; // max queue entry size category 1
138  std::uint16_t u16MSDU2_; // max queue entry size category 2
139  std::uint16_t u16MSDU3_; // max queue entry size category 3
140 
141  CWRatioTable CWMinRatioTable_;
142 
143  ConfigItems();
144  };
145 
146 
152  class MACConfig
153  {
154  public:
155 
156  MACConfig(LogServiceProvider & logServiceProvider, NEMId id);
157 
158  ~MACConfig();
159 
160  bool getPromiscuosEnable() const;
161 
162  bool getWmmEnable() const;
163 
164  void registerConfiguration(ConfigurationRegistrar & configRegistrar);
165 
166  MODULATION_TYPE getModulationType() const;
167 
168  std::uint8_t getUnicastDataRateIndex() const;
169 
170  std::uint8_t getBroadcastDataRateIndex() const;
171 
172  std::uint32_t getUnicastDataRateKbps() const;
173 
174  std::uint32_t getBroadcastDataRateKbps() const;
175 
176  std::uint32_t getMaxDataRateKbps() const;
177 
178  std::uint32_t getUnicastDataRateKbps(std::uint8_t) const;
179 
180  std::uint32_t getBroadcastDataRateKbps(std::uint8_t) const;
181 
182  std::uint32_t getMaxP2pDistance() const;
183 
184  std::uint8_t getNumAccessCategories() const;
185 
186  std::uint16_t getRtsThreshold() const;
187 
188  std::uint8_t getQueueSize(std::uint8_t) const;
189 
190  std::uint16_t getQueueEntrySize(std::uint8_t) const;
191 
192  std::uint16_t getCWMin(std::uint8_t) const;
193 
194  std::uint16_t getCWMax(std::uint8_t) const;
195 
196  void setCWMin0(std::uint16_t u16Value);
197 
198  void setCWMin1(std::uint16_t u16Value);
199 
200  void setCWMin2(std::uint16_t u16Value);
201 
202  void setCWMin3(std::uint16_t u16Value);
203 
204  void setCWMax0(std::uint16_t u16Value);
205 
206  void setCWMax1(std::uint16_t u16Value);
207 
208  void setCWMax2(std::uint16_t u16Value);
209 
210  void setCWMax3(std::uint16_t u16Value);
211 
212  Microseconds getAifsMicroseconds(std::uint8_t) const;
213 
214  Microseconds getTxOpMicroseconds(std::uint8_t) const;
215 
216  std::uint8_t getRetryLimit(std::uint8_t) const;
217 
218  std::uint16_t getFlowControlTokens() const;
219 
220  bool getFlowControlEnable() const;
221 
222  std::string getPcrUri() const;
223 
224  Microseconds getNeighborTimeoutMicroseconds() const;
225 
226  Microseconds getChannelActivityIntervalMicroseconds() const;
227 
228  bool configure(const ConfigurationUpdate & update);
229 
230  bool processConfiguration(const ConfigurationUpdate & update);
231 
232  CWRatioVector getCWMinRatioVector(std::uint8_t) const;
233 
234  Microseconds getNeighborMetricDeleteTimeMicroseconds() const;
235 
236  Microseconds getRadioMetricReportIntervalMicroseconds() const;
237 
238  bool getRadioMetricEnable() const;
239 
240  private:
241  LogServiceProvider & logServiceProvider_;
242 
243  NEMId id_;
244 
245  ConfigItems configItems_;
246 
247  bool configureStaticItems(const ConfigurationNameAnyValues & item);
248 
249  bool configureDynamicItems(const ConfigurationNameAnyValues & item);
250 
251  void setCWMinRatioVector(std::uint8_t u8Category);
252 
253  void initCWMinRatioTable();
254  };
255  }
256  }
257 }
258 
259 #endif //EMANEMODELSIEEE802ABGMACCONFIG_HEADER_
std::vector< CWRatioVector > CWRatioTable
Definition: macconfig.h:76
class used to define the mac layer configuration items
Definition: macconfig.h:152
const std::uint8_t MAX_ACCESS_CATEGORIES
Definition: macconfig.h:63
Log service provider interface.
mac configuration items.
Definition: macconfig.h:83
ConfigItems()
ieee80211abg mac configuration initializer.
Definition: macconfig.cc:62
const std::uint16_t MAX_PACKET_SIZE
Definition: macconfig.h:68
std::chrono::microseconds Microseconds
Definition: types.h:45
std::uint16_t NEMId
Definition: types.h:52
const std::uint8_t MODULATION_TYPE_INDEX_MIN
Definition: macconfig.h:71
const std::uint8_t QUEUE_SIZE_DEFAULT
Definition: macconfig.h:65
The ConfigurationRegistrar allows NEM layers to register the configuration items they require...
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
std::pair< std::string, std::vector< EMANE::Any > > ConfigurationNameAnyValues
std::vector< float > CWRatioVector
Definition: macconfig.h:75
Definition: agent.h:43
const std::uint8_t MODULATION_TYPE_INDEX_MAX
Definition: macconfig.h:72