EMANE  1.2.1
neighborentry.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - Adjacent Link LLC, Bridgewater, New Jersey
3  * Copyright (c) 2010-2012 - 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 EMANEMODELSIEEE802ABGNEIGHBORENTRY_HEADER_
35 #define EMANEMODELSIEEE802ABGNEIGHBORENTRY_HEADER_
36 
37 #include "emane/types.h"
38 
39 #include "neighbortype.h"
40 #include "msgtypes.h"
41 
42 #include <map>
43 #include <set>
44 
45 
46 namespace EMANE
47  {
48  namespace Models
49  {
50  namespace IEEE80211ABG
51  {
60  {
61  public:
67  NeighborEntry();
68 
80  void updateChannelActivity(const Microseconds & utilizationMicroseconds,
81  std::uint8_t type,
82  const TimePoint & activityTime,
83  float fRxPowerMilliWatts,
84  size_t numPackets = 1);
85 
91  void storeUtilization();
92 
93 
95 
105  Microseconds getUtilizationMicroseconds(std::uint8_t msgTypeMask) const;
106 
116  size_t getNumberOfPackets(std::uint8_t msgTypeMask) const;
117 
118 
128  float getRxPowerMilliWatts(std::uint8_t msgTypeMask) const;
129 
130  float getEstimatedNumCommonNeighbors() const;
131 
132  void setEstimatedNumCommonNeighbors(float num);
133 
134  float getHiddenChannelActivity() const;
135 
136  void setHiddenChannelActivity(float fActivity);
137 
138  void setAverageHiddenRxPowerMilliWatts(float dAverageHiddenRxPowerMilliWatts);
139 
140  float getAverageHiddenRxPowerMilliWatts() const;
141 
142  void setAverageCommonRxPowerMilliWatts(float dAverageCommonRxPowerMilliWatts);
143 
144  float getAverageCommonRxPowerMilliWatts() const;
145 
146  void setOneHopNeighbors(const NbrSet & nbrs);
147 
148  void setHiddenNeighbors(const NbrSet & nbrs);
149 
150  void setCommonNeighbors(const NbrSet & nbrs);
151 
152  const NbrSet & getOneHopNeighbors() const;
153 
154  const NbrSet & getCommonNeighbors() const;
155 
156  const NbrSet & getHiddenNeighbors() const;
157 
158  bool isOneHopNbr(EMANE::NEMId id) const;
159 
160  bool isCommonNbr(EMANE::NEMId id) const;
161 
162  bool isHiddenNbr(EMANE::NEMId id) const;
163 
164  private:
171  struct Utilization
172  {
173  Microseconds totalUtilizationMicroseconds_;
174  size_t totalNumPackets_;
175  float fTotalRxPowerMilliWatts_;
176 
177  Utilization() :
178  totalUtilizationMicroseconds_{},
179  totalNumPackets_{},
180  fTotalRxPowerMilliWatts_{}
181  { }
182 
183  void reset()
184  {
185  totalUtilizationMicroseconds_ = Microseconds::zero();
186  totalNumPackets_ = 0;
187  fTotalRxPowerMilliWatts_ = 0;
188  }
189 
190  void update(size_t numPackets, const Microseconds & utilizationMicroseconds, float fRxPowerMilliWatts)
191  {
192  totalNumPackets_ += numPackets;
193 
194  totalUtilizationMicroseconds_ += utilizationMicroseconds;
195 
196  fTotalRxPowerMilliWatts_ += fRxPowerMilliWatts;
197  }
198  };
199 
200  using UtilizationTypeMap = std::map<std::uint8_t, Utilization>;
201 
202  UtilizationTypeMap prevUtilizationTypeMap_;
203 
204  UtilizationTypeMap currUtilizationTypeMap_;
205 
206  TimePoint lastActivityTime_;
207 
208  NbrSet oneHopNbrSet_;
209 
210  NbrSet commonNbrSet_;
211 
212  NbrSet hiddenNbrSet_;
213 
214  float fEstimatedNumCommonNeighbors_;
215 
216  float fHiddenChannelActivity_;
217 
218  float fAverageHiddenRxPowerMilliWatts_;
219 
220  float fAverageCommonRxPowerMilliWatts_;
221  };
222  }
223  }
224 }
225 #endif //EMANEMODELSIEEE802ABGNEIGHBORENTRY_HEADER_
void setAverageCommonRxPowerMilliWatts(float dAverageCommonRxPowerMilliWatts)
size_t getNumberOfPackets(std::uint8_t msgTypeMask) const
bool isOneHopNbr(EMANE::NEMId id) const
bool isCommonNbr(EMANE::NEMId id) const
EMANE::TimePoint getLastActivityTime() const
Defines a 1 hop nbr and its bandwidth utilization.
Definition: neighborentry.h:59
void setAverageHiddenRxPowerMilliWatts(float dAverageHiddenRxPowerMilliWatts)
void setHiddenChannelActivity(float fActivity)
Microseconds getUtilizationMicroseconds(std::uint8_t msgTypeMask) const
void setOneHopNeighbors(const NbrSet &nbrs)
float getRxPowerMilliWatts(std::uint8_t msgTypeMask) const
void updateChannelActivity(const Microseconds &utilizationMicroseconds, std::uint8_t type, const TimePoint &activityTime, float fRxPowerMilliWatts, size_t numPackets=1)
std::chrono::microseconds Microseconds
Definition: types.h:45
std::uint16_t NEMId
Definition: types.h:52
void setHiddenNeighbors(const NbrSet &nbrs)
void setCommonNeighbors(const NbrSet &nbrs)
std::set< EMANE::NEMId > NbrSet
Definition: neighbortype.h:47
bool isHiddenNbr(EMANE::NEMId id) const
Clock::time_point TimePoint
Definition: types.h:50
Definition: agent.h:43