EMANE  1.0.1
models/mac/rfpipe/maclayer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2016 - Adjacent Link LLC, Bridgewater, New Jersey
3  * Copyright (c) 2008,2009,2010 - 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 RFPIPEMAC_MACLAYER_HEADER_
35 #define RFPIPEMAC_MACLAYER_HEADER_
36 
37 #include "emane/maclayerimpl.h"
38 #include "emane/mactypes.h"
42 #include "emane/statisticnumeric.h"
43 
47 
48 #include "downstreamqueue.h"
49 #include "pcrmanager.h"
50 
51 #include <memory>
52 
53 namespace EMANE
54 {
55  namespace Models
56  {
57  namespace RFPipe
58  {
68  {
69  public:
78  MACLayer(NEMId id,
79  PlatformServiceProvider *pPlatformServiceProvider,
80  RadioServiceProvider * pRadioServiceProvider);
81 
87  ~MACLayer();
88 
89 
90  // mac layer implementor api below
91 
92  void initialize(Registrar & registrar) override;
93 
94  void configure(const ConfigurationUpdate & update) override;
95 
96  void start() override;
97 
98  void postStart() override;
99 
100  void stop() override;
101 
102  void destroy() throw() override;
103 
104  void processUpstreamControl(const ControlMessages & msgs) override;
105 
106 
107  void processUpstreamPacket(const CommonMACHeader & hdr,
108  UpstreamPacket & pkt,
109  const ControlMessages & msgs) override;
110 
111  void processDownstreamControl(const ControlMessages & msgs) override;
112 
113 
115  const ControlMessages & msgs) override;
116 
117  void processConfiguration(const ConfigurationUpdate & update) override;
118 
119  private:
125  static const RegistrationId type_ = REGISTERED_EMANE_MAC_RF_PIPE;
126 
127  DownstreamQueue downstreamQueue_;
128 
129  std::uint64_t u64TxSequenceNumber_;
130 
131  FlowControlManager flowControlManager_;
132 
133  PCRManager pcrManager_;
134 
135  NeighborMetricManager neighborMetricManager_;
136 
137  QueueMetricManager queueMetricManager_;
138 
139  // config items
140  bool bPromiscuousMode_;
141 
142  std::uint64_t u64DataRatebps_;
143 
144  Microseconds delayMicroseconds_;
145 
146  bool bFlowControlEnable_;
147 
148  bool bRadioMetricEnable_;
149 
150  std::uint16_t u16FlowControlTokens_;
151 
152  std::string sPCRCurveURI_;
153 
154  Microseconds radioMetricReportIntervalMicroseconds_;
155 
156  Microseconds neighborMetricDeleteTimeMicroseconds_;
157 
158  TimerEventId radioMetricTimedEventId_;
159 
160  Utils::CommonLayerStatistics commonLayerStatistics_;
161 
162  Utils::RandomNumberDistribution<std::mt19937,
163  std::uniform_real_distribution<float>> RNDZeroToOne_;
164 
165  std::unique_ptr<Utils::RandomNumberDistribution<std::mt19937,
166  std::uniform_real_distribution<float>>> pRNDJitter_;
167 
168  float fJitterSeconds_;
169 
170  StatisticNumeric<std::uint64_t> * pNumDownstreamQueueDelay_;
171 
172  Utils::RunningAverage<float> avgDownstreamQueueDelay_;
173 
174  TimerEventId downstreamQueueTimedEventId_;
175 
176  bool bHasPendingDownstreamQueueEntry_;
177 
178  DownstreamQueueEntry pendingDownstreamQueueEntry_;
179 
180  TimePoint currentEndOfTransmissionTime_;
181 
182  Microseconds currentDelay_;
183 
184  void handleDownstreamQueueEntry(TimePoint sot,
185  std::uint64_t u64TxSequenceNumber);
186 
187  Microseconds getDurationMicroseconds(size_t lengthInBytes);
188 
189  Microseconds getJitter();
190 
191  bool checkPOR(float fSINR, size_t packetSize);
192  };
193  }
194  }
195 }
196 
197 #endif //RFPIPEMAC_MACLAYER_HEADER_
A Packet class that allows upstream processing to strip layer headers as the packet travels up the st...
const RegistrationId REGISTERED_EMANE_MAC_RF_PIPE
Definition: mactypes.h:65
The Registrar interface provides access to all of the emulator registrars.
Definition: registrar.h:50
Flow Control Manager (token producer) side.
std::list< const ControlMessage * > ControlMessages
void processDownstreamControl(const ControlMessages &msgs) override
Provides a queue implementation for the RFPipe Mac layer.
void initialize(Registrar &registrar) override
Common NEM layer statistics and drop reason tables.
RFPipe MAC downstream queue entry definition.
Manager Queue metrics.
The PlatformServiceProvider interface provides access to emulator services.
void processDownstreamPacket(DownstreamPacket &pkt, const ControlMessages &msgs) override
void processUpstreamControl(const ControlMessages &msgs) override
Specialized packet the allows downstream processing to add layer specific headers as the packet trave...
std::uint16_t RegistrationId
Definition: types.h:59
void processConfiguration(const ConfigurationUpdate &update) override
MACLayer(NEMId id, PlatformServiceProvider *pPlatformServiceProvider, RadioServiceProvider *pRadioServiceProvider)
std::chrono::microseconds Microseconds
Definition: types.h:45
std::uint16_t NEMId
Definition: types.h:52
void configure(const ConfigurationUpdate &update) override
The RadioServiceProvider interface provides access to radio (RF) model specific services.
std::vector< ConfigurationNameAnyValues > ConfigurationUpdate
void processUpstreamPacket(const CommonMACHeader &hdr, UpstreamPacket &pkt, const ControlMessages &msgs) override
std::size_t TimerEventId
Definition: types.h:54
Clock::time_point TimePoint
Definition: types.h:50
Implementation of the rf pipe mac layer.
Definition: agent.h:43
A utility wrapper around a generator and a distribution.
Manages neighbor metrics and sends neighbor metric control message upstream.
Interface used to create a MAC layer plugin implementation.
Definition: maclayerimpl.h:48