EMANE  1.2.1
ieee80211abg/pcrmanager.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 
35 #ifndef EMANEMODELSIEEE802ABGIEEE80211MACPCRMANAGER_HEADER_
36 #define EMANEMODELSIEEE802ABGIEEE80211MACPCRMANAGER_HEADER_
37 
38 #include "emane/types.h"
41 
42 #include <libxml/parser.h>
43 
44 #include <string>
45 #include <vector>
46 #include <map>
47 
48 namespace EMANE
49  {
50  namespace Models
51  {
52  namespace IEEE80211ABG
53  {
61  class PCRManager
62  {
70  struct PCREntry
71  {
72  float fSINR_;
73  float fPOR_;
74 
80  PCREntry():
81  fSINR_{},
82  fPOR_{}
83  { }
84 
93  PCREntry(float fSinr, float por):
94  fSINR_{fSinr},
95  fPOR_{por}
96  { }
97  };
98 
104  typedef std::vector <PCREntry> PCREntryVector;
105 
111  typedef std::vector <float> PORVector;
112 
120  struct PCRPOR
121  {
122  PCREntryVector pcr_;
123  PORVector por_;
124  };
125 
131  typedef std::map <std::uint16_t, PCRPOR> PCRPORMap;
132 
133  public:
142  PCRManager(NEMId id, PlatformServiceProvider * pPlatformService);
143 
149  ~PCRManager();
150 
159  void load(const std::string & uri);
160 
172  float getPCR(float fSinr, size_t size, std::uint16_t DataRateIndex);
173 
174  private:
175  void openDoc(const std::string & uri, xmlParserCtxtPtr * ppContext,
176  xmlDoc ** ppDocument, xmlNode ** ppRoot);
177 
178  void closeDoc(xmlParserCtxtPtr * ppContext, xmlDoc ** ppDocument);
179 
180  std::string getAttribute(xmlNodePtr cur, const xmlChar * id);
181 
182  std::string getContent(xmlNodePtr cur);
183 
184  void getTable(xmlNodePtr cur, PCRManager::PCRPORMap & map);
185 
186  void getDataRate(xmlNodePtr cur, PCRManager::PCRPORMap & map);
187 
188  void getRows(xmlNodePtr cur, PCRManager::PCREntryVector & vec);
189 
190  void interpolate();
191 
192  const NEMId id_;
193 
194  PlatformServiceProvider * pPlatformService_;
195 
196  PCRPORMap pcrPorMap_;
197 
198  size_t tablePacketSize_;
199  };
200  }
201  }
202 }
203 
204 
205 #endif //EMANEMODELSIEEE802ABGIEEE80211MACPCRMANAGER_HEADER_
provides access to the pcr curves
The PlatformServiceProvider interface provides access to emulator services.
PCRManager(NEMId id, PlatformServiceProvider *pPlatformService)
std::uint16_t NEMId
Definition: types.h:52
float getPCR(float fSinr, size_t size, std::uint16_t DataRateIndex)
Definition: agent.h:43