DESERT 3.5.1
Loading...
Searching...
No Matches
uwhmmphysical.h
Go to the documentation of this file.
1//
2// Copyright (c) 2021 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 UWHMMPHYSICAL_H
40#define UWHMMPHYSICAL_H
41
42#include "uwphysical.h"
43#include "mclink.h"
44
45
47{
48public:
49
53 virtual ~UwHMMPhysicalStats() = default;
59 virtual Stats* clone() const;
60
72 virtual void updateStats(int mod_id, int stck_id, double rx_pwr,
73 double noise_pwr, double interf_pwr, double sinr, double ber, double per, bool error,
75
77};
78
79
80
85{
86
87public:
92
96 virtual ~UnderwaterHMMPhysical();
97
108 virtual int command(int, const char *const *);
109
116 void setMCLink(int mac, MCLink *link);
117
122 int getPktsTotBad() const
123 {
124 return pkts_tot_bad;
125 }
126
132 {
133 return pkts_tot_medium;
134 }
135
140 int getPktsTotGood() const
141 {
142 return pkts_tot_good;
143 }
144
151 {
152 if (ch_state == MCLink::GOOD) {
154 } else if (ch_state == MCLink::MEDIUM) {
156 } else if (ch_state == MCLink::BAD) {
157 pkts_tot_bad++;
158 }
159 }
160
161protected:
162
169 virtual void endRx(Packet *p) override;
170
179 virtual double ber2per(double ber, Packet * p);
180
181
182 // Variables
183 std::map<int, MCLink*> link_map;
188private:
189 // Variables
190};
191
192#endif /* UWHMMPHYSICAL_H */
UnderwaterHMMPhysical models an hidden Markov Model phy channel.
virtual double ber2per(double ber, Packet *p)
Returns the packet error rate by using the BER from HMM and the size of a packet.
virtual void endRx(Packet *p) override
Handles the end of a packet reception.
int getPktsTotMedium() const
void incrTotPkts(MCLink::ChState ch_state)
increase the counter of packets sent taking into account the channel state
void setMCLink(int mac, MCLink *link)
Adds the Markov Chain transition matrix for each source MAC.
virtual ~UnderwaterHMMPhysical()
Destructor of UnderwaterHMMPhysical class.
virtual int command(int, const char *const *)
TCL command interpreter.
int pkts_tot_good
Total number of packets arrived with good channel.
int pkts_tot_bad
Total number of packets arrived with bad channel.
int pkts_tot_medium
Total number of packets arrived with medium channel.
UnderwaterHMMPhysical()
Constructor of UnderwaterHMMPhysical class.
std::map< int, MCLink * > link_map
maps source mac to associated MCLink
virtual ~UwHMMPhysicalStats()=default
Destructor of UwPhysicalStats class.
virtual Stats * clone() const
Virtual method used by the Module class in order to copy its stats an a generic fashion,...
MCLink::ChState channel_state
HMM channel state.
virtual void updateStats(int mod_id, int stck_id, double rx_pwr, double noise_pwr, double interf_pwr, double sinr, double ber, double per, bool error, MCLink::ChState channel_state=MCLink::ChState::NOT_DEFINED)
Method to update stats with the param of last received packet.
Definition of UwPhysical class.