DESERT 3.5.1
Loading...
Searching...
No Matches
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 <uwphysical.h>
43#include <uwip-module.h>
44#include "uwinterference.h"
45
46#include <packet.h>
47#include <module.h>
48#include <tclcl.h>
49
50#include <fstream>
51#include <sstream>
52#include <vector>
53#include <stdint.h>
54#include <set>
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>
168 string country;
169 string modulation;
170 uint8_t ipAddr_;
172 std::pair<double, double> interf_val;
174 char
178private:
179 ostringstream osstream;
180};
181
182#endif /* UWPHYSICALDB_H */
UnderwaterPhysicaldb()
Constructor of UnderwaterMPhyBpskDb class.
virtual double getPERfromSIR(const double &, const double &)
Packet error rate based on Overlap and SIR.
string modulation
Name of the Modulation.
virtual void recv(Packet *)
recv method.
char token_separator
Token used to parse the elements in a line of the database.
std::pair< double, double > interf_val
(SIR, Overlap)
virtual double getNearestNeighbor(const std::set< double > &, const double &)
Nearest neighbor of a value contained in a set.
virtual double getPERfromSNR(const double &, const int &, const Packet *)
Packet error rate based on SNR.
std::set< double > overlap
Set of the available Overlaps.
uwinterference * interference_
Interference Model.
virtual ~UnderwaterPhysicaldb()
Destructor of UnderwaterMPhyBpskDb class.
virtual void endRx(Packet *p)
Handles the end of a packet reception.
uint8_t ipAddr_
IP of the node.
string country
Name of the Country.
std::map< string, uint8_t > range_nums
Set of the number of ranges for a given pathtype, e.g "AA".
virtual int command(int, const char *const *)
TCL command interpreter.
std::set< double > snr
Set of the available SNRs.
char * path_
Name of the trace file writter for the current node.
virtual const double retrievePerFromFile(const std::string &, const double &) const
const bool isZero(const double &_value) const
Evaluates is the number passed as input is equal to zero.
ostringstream osstream
const double fromKmToMiles(const double &_km) const
Converts from kilometers to miles.
std::map< uint8_t, std::set< double > > range
Set of the available Ranges.
std::map< uint8_t, string > type_of_node
Set of the available type of nodes.
std::set< double > sir
Set of the available SIRs.
static const double FROMKMTOMILES
Implementation of uwinterference class.
Provides the UWIP packets header description. Definition of the class that define the network layer.
Definition of UwPhysical class.