EMANE  1.2.1
modetimingparameters.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 EMANEMODELSIEEE802ABGMODETIMINGPARAMTERS_HEADER_
35 #define EMANEMODELSIEEE802ABGMODETIMINGPARAMTERS_HEADER_
36 
37 #include "emane/types.h"
38 
39 #include "macconfig.h"
40 
41 #include <map>
42 
43 
44 namespace EMANE
45  {
46  namespace Models
47  {
48  namespace IEEE80211ABG
49  {
50  class MACLayer;
51 
58  {
59  private:
60  const MACConfig & macConfig_;
61 
67  struct TimingParams
68  {
69  std::uint16_t u16RtsBitLength_; // rts bit length
70  std::uint16_t u16CtsBitLength_; // cts bit length
71  std::uint16_t u16AckBitLength_; // ack bit length
72  Microseconds slotMicroseconds_; // slot duration
73  Microseconds sifsMicroseconds_; // sifs duration
74  Microseconds preambleMicroseconds_; // preamble duration
75 
76  TimingParams():
77  u16RtsBitLength_{},
78  u16CtsBitLength_{},
79  u16AckBitLength_{},
80  slotMicroseconds_{},
81  sifsMicroseconds_{},
82  preambleMicroseconds_{}
83  { }
84  };
85 
86  TimingParams timingParams_[MODULATION_TYPE_INDEX_MAX + 1];
87 
88  std::uint16_t getRtsBitLength(MODULATION_TYPE) const;
89 
90  std::uint16_t getCtsBitLength(MODULATION_TYPE) const;
91 
92  std::uint16_t getAckBitLength(MODULATION_TYPE) const;
93 
94 
95  Microseconds getSifsMicroseconds(MODULATION_TYPE) const;
96 
97  Microseconds getPreambleMicroseconds(MODULATION_TYPE) const;
98 
99  Microseconds getPropagationMicroseconds(std::uint32_t) const;
100 
101 
102  Microseconds getBroadcastMessageDurationMicroseconds(size_t) const;
103 
104  Microseconds getUnicastMessageDurationMicroseconds(size_t) const;
105 
106  Microseconds getCtsMessageDurationMicroseconds() const;
107 
108  Microseconds getRtsMessageDurationMicroseconds() const;
109 
110 
111  public:
112  ModeTimingParameters(const MACConfig & macConfig);
113 
115 
116  bool packetTimedOut(const Microseconds & txOpMicroseconds, const TimePoint &) const;
117 
118  int getContentionWindow(std::uint8_t, std::uint8_t) const;
119 
121 
122  Microseconds getOverheadMicroseconds(std::uint8_t u8Category) const;
123 
124  Microseconds getMessageDurationMicroseconds(std::uint8_t, size_t) const;
125 
126  Microseconds getDeferIntervalMicroseconds(std::uint8_t) const;
127 
128  TimePoint getSotTime() const;
129  };
130  }
131  }
132 }
133 
134 #endif //EMANEMODELSIEEE802ABGMODETIMINGPARAMTERS_HEADER_
class used to define the mac layer configuration items
Definition: macconfig.h:152
class used to define timing parameters
int getContentionWindow(std::uint8_t, std::uint8_t) const
get the contention window
bool packetTimedOut(const Microseconds &txOpMicroseconds, const TimePoint &) const
check if a packet has timed out
ModeTimingParameters(const MACConfig &macConfig)
constructor
Microseconds getOverheadMicroseconds(std::uint8_t u8Category) const
get the overhead time
std::chrono::microseconds Microseconds
Definition: types.h:45
Microseconds getSlotSizeMicroseconds() const
get the slot duration for a given mode and distance
Clock::time_point TimePoint
Definition: types.h:50
Microseconds getDeferIntervalMicroseconds(std::uint8_t) const
get the defer time
Microseconds getMessageDurationMicroseconds(std::uint8_t, size_t) const
get the message duration
Definition: agent.h:43
const std::uint8_t MODULATION_TYPE_INDEX_MAX
Definition: macconfig.h:72