DESERT 4.0.0
uwphysicaldb.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
39#ifndef UWPHYSICALDB_H
40#define UWPHYSICALDB_H
41
42#include "uwinterference.h"
43#include <uwip-module.h>
44#include <uwphysical.h>
45
46#include <module.h>
47#include <packet.h>
48#include <tclcl.h>
49
50#include <fstream>
51#include <set>
52#include <sstream>
53#include <stdint.h>
54#include <vector>
55
56namespace uwphysicaldb
57{
58static const double FROMKMTOMILES = 0.621371192237;
59}
60
62{
63
64public:
69
74 {
75 }
76
87 virtual int command(int, const char *const *);
88
89 virtual void recv(Packet *);
90
91protected:
92 virtual void endRx(Packet *p);
93
102 virtual double getPERfromSNR(const double &, const int &, const Packet *);
103
111 virtual double getPERfromSIR(const double &, const double &);
112
120 virtual double getNearestNeighbor(const std::set<double> &, const double &);
121
122 virtual const double retrievePerFromFile(
123 const std::string &, const double &) const;
124
137 inline const bool
138 isZero(const double &_value) const
139 {
140 return std::fabs(_value) < std::numeric_limits<double>::epsilon();
141 }
142
149 inline const double
150 fromKmToMiles(const double &_km) const
151 {
152 return _km * uwphysicaldb::FROMKMTOMILES;
153 }
154
155 // Variables
156 char *path_;
158 std::set<double> snr;
159 std::set<double> overlap;
160 std::set<double> sir;
161 std::map<uint8_t, std::set<double>>
163 std::map<uint8_t, string>
165 std::map<string, uint8_t> range_nums;
167 string country;
168 string modulation;
169 uint8_t ipAddr_;
171 std::pair<double, double> interf_val;
176private:
177 ostringstream osstream;
178};
179
180#endif /* UWPHYSICALDB_H */
Definition uwphysical.h:100
Definition uwphysicaldb.h:62
UnderwaterPhysicaldb()
Definition uwphysicaldb.cpp:57
virtual double getPERfromSIR(const double &, const double &)
Definition uwphysicaldb.cpp:426
string modulation
Definition uwphysicaldb.h:168
virtual void recv(Packet *)
Definition uwphysicaldb.cpp:167
char token_separator
Definition uwphysicaldb.h:173
std::pair< double, double > interf_val
Definition uwphysicaldb.h:171
virtual double getNearestNeighbor(const std::set< double > &, const double &)
Definition uwphysicaldb.cpp:450
virtual double getPERfromSNR(const double &, const int &, const Packet *)
Definition uwphysicaldb.cpp:320
std::set< double > overlap
Definition uwphysicaldb.h:159
uwinterference * interference_
Definition uwphysicaldb.h:157
virtual ~UnderwaterPhysicaldb()
Definition uwphysicaldb.h:73
virtual void endRx(Packet *p)
Definition uwphysicaldb.cpp:244
uint8_t ipAddr_
Definition uwphysicaldb.h:169
string country
Definition uwphysicaldb.h:167
std::map< string, uint8_t > range_nums
Definition uwphysicaldb.h:165
virtual int command(int, const char *const *)
Definition uwphysicaldb.cpp:79
std::set< double > snr
Definition uwphysicaldb.h:158
char * path_
Definition uwphysicaldb.h:156
virtual const double retrievePerFromFile(const std::string &, const double &) const
Definition uwphysicaldb.cpp:483
const bool isZero(const double &_value) const
Definition uwphysicaldb.h:138
ostringstream osstream
Definition uwphysicaldb.h:177
const double fromKmToMiles(const double &_km) const
Definition uwphysicaldb.h:150
std::map< uint8_t, std::set< double > > range
Definition uwphysicaldb.h:162
std::map< uint8_t, string > type_of_node
Definition uwphysicaldb.h:164
std::set< double > sir
Definition uwphysicaldb.h:160
Definition uwinterference.h:151
Definition uwphysicaldb.h:57
Implementation of uwinterference class.
Provides the UWIP packets header description. Definition of the class that define the network layer.
Definition of UwPhysical class.