DESERT 3.6.0
Loading...
Searching...
No Matches
uwphysical.cpp
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#include "uwphysical.h"
40#include "uwphy-clmsg.h"
41#include "uwstats-utilities.h"
42#include <mac.h>
43#include <phymac-clmsg.h>
44#include <sstream>
45#include <string>
46
48 : Stats()
49 , has_error(false)
50 , last_rx_power(0)
51 , last_noise_power(0)
52 , instant_noise_power(0)
53 , last_interf_power(0)
54 , last_sinr(0)
55 , last_ber(0)
56 , last_per(0)
57{
58 type_id = (int) StatsEnum::STATS_PHY_LAYER;
59}
60UwPhysicalStats::UwPhysicalStats(int mod_id, int stck_id)
61 : Stats(mod_id, stck_id)
62 , has_error(false)
63 , last_rx_power(0)
64 , last_noise_power(0)
65 , instant_noise_power(0)
66 , last_interf_power(0)
67 , last_sinr(0)
68 , last_ber(0)
69 , last_per(0)
70{
71 type_id = (int) StatsEnum::STATS_PHY_LAYER;
72}
73
74void
75UwPhysicalStats::updateStats(int mod_id, int stck_id, double rx_pwr,
76 double noise_pwr, double interf_pwr, double sinr, double ber,
77 double per, bool error)
78{
79 module_id = mod_id;
80 stack_id = stck_id;
81 last_rx_power = rx_pwr;
82 last_noise_power = noise_pwr;
83 instant_noise_power = noise_pwr;
84 last_interf_power = interf_pwr;
85 last_sinr = sinr;
86 last_ber = ber;
87 last_per = per;
88 has_error = error;
89}
90
91Stats *
93{
94 return new UwPhysicalStats(*this);
95}
96
97static class UwPhysicalClass : public TclClass
98{
99public:
101 : TclClass("Module/UW/PHYSICAL")
102 {
103 }
104 TclObject *
105 create(int, const char *const *)
106 {
107 return (new UnderwaterPhysical);
108 }
110
112 : modulation_name_("BPSK")
113 , time_ready_to_end_rx_(0)
114 , Tx_Time_(0)
115 , Rx_Time_(0)
116 , Energy_Tx_(0)
117 , Energy_Rx_(0)
118 , Transmitted_bytes_(0)
119 , tx_power_(3.3)
120 , rx_power_(0.620)
121 , tot_pkts_lost(0)
122 , tot_ctrl_pkts_lost(0)
123 , errorCtrlPktsInterf(0)
124 , collisionDataCTRL(0)
125 , collisionCTRL(0)
126 , collisionDATA(0)
127 , Interference_Model("CHUNK")
128 , interference_(nullptr)
129{
130 bind("rx_power_consumption_", &rx_power_);
131 bind("tx_power_consumption_", &tx_power_);
132 stats_ptr = new UwPhysicalStats();
133}
134
136{
137 delete stats_ptr;
138 stats_ptr = nullptr;
139}
140
141int
142UnderwaterPhysical::command(int argc, const char *const *argv)
143{
144 Tcl &tcl = Tcl::instance();
145
146 if (argc == 2) {
147 if (strcasecmp(argv[1], "getTxTime") == 0) {
148 tcl.resultf("%f", Get_Tx_Time());
149 return TCL_OK;
150 } else if (strcasecmp(argv[1], "getRxTime") == 0) {
151 tcl.resultf("%f", Get_Rx_Time());
152 return TCL_OK;
153 } else if (strcasecmp(argv[1], "getConsumedEnergyTx") == 0) {
154 tcl.resultf("%f", Get_Energy_Tx());
155 return TCL_OK;
156 } else if (strcasecmp(argv[1], "getConsumedEnergyRx") == 0) {
157 tcl.resultf("%f", Get_Energy_Rx());
158 return TCL_OK;
159 } else if (strcasecmp(argv[1], "getTransmittedBytes") == 0) {
160 tcl.resultf("%f", Get_Transmitted_bytes());
161 return TCL_OK;
162 } else if (strcasecmp(argv[1], "getTotPktsLost") == 0) {
163 tcl.resultf("%d", getTot_pkts_lost());
164 return TCL_OK;
165 } else if (strcasecmp(argv[1], "getCollisionsDATAvsCTRL") == 0) {
166 tcl.resultf("%d", getCollisionsDATAvsCTRL());
167 return TCL_OK;
168 } else if (strcasecmp(argv[1], "getCollisionsCTRL") == 0) {
169 tcl.resultf("%d", getCollisionsCTRL());
170 return TCL_OK;
171 } else if (strcasecmp(argv[1], "getCollisionsDATA") == 0) {
172 tcl.resultf("%d", getCollisionsDATA());
173 return TCL_OK;
174 } else if (strcasecmp(argv[1], "getTotCtrlPktsLost") == 0) {
175 tcl.resultf("%d", getTot_CtrlPkts_lost());
176 return TCL_OK;
177 } else if (strcasecmp(argv[1], "getErrorCtrlPktsInterf") == 0) {
178 tcl.resultf("%d", getError_CtrlPktsInterf());
179 return TCL_OK;
180 }
181 } else if (argc == 3) {
182 if (strcasecmp(argv[1], "modulation") == 0) {
183 modulation_name_ = ((char *) argv[2]);
184 if (modulation_name_ == "" ||
185 (modulation_name_ != "BPSK" && modulation_name_ != "BFSK" &&
186 modulation_name_ != "8PSK" &&
187 modulation_name_ != "16PSK" &&
188 modulation_name_ != "32PSK")) {
189 tcl.result("Empty or wrong name for the modulation scheme");
190 return TCL_ERROR;
191 }
192
193 return TCL_OK;
194 } else if (strcasecmp(argv[1], "setInterferenceModel") == 0) {
195 Interference_Model = (std::string) argv[2];
196 if (Interference_Model != "CHUNK" &&
197 Interference_Model != "MEANPOWER") {
198 tcl.result(
199 "Empty or wrong name of the Interference Model: "
200 "CHUNK or MEANPOWER are valid interference models");
201 return TCL_ERROR;
202 }
203
204 return TCL_OK;
205 } else if (strcasecmp(argv[1], "setInterference") == 0) {
207 dynamic_cast<uwinterference *>(TclObject::lookup(argv[2]));
208 if (!interference_) {
209 return TCL_ERROR;
210 }
211
212 return TCL_OK;
213 }
214 }
215 return UnderwaterMPhyBpsk::command(argc, argv);
216} /* UnderwaterPhysical::command */
217
218void
220{
221 hdr_cmn *ch = HDR_CMN(p);
222 hdr_MPhy *ph = HDR_MPHY(p);
223
224 if (ch->direction() == hdr_cmn::UP) {
225 ph->dstSpectralMask = getRxSpectralMask(p);
226 ph->dstPosition = getPosition();
227 ph->dstAntenna = getRxAntenna(p);
228
229 assert(ph->dstSpectralMask);
230 assert(ph->dstPosition);
231
232 ph->Pr = getRxPower(p);
233
234 p->txinfo_.RxPr = 0;
235 p->txinfo_.CPThresh = 0;
236
237 if (ph->Pr > 0) {
238 ph->Pn = getNoisePower(p);
239
240 if (interference_) {
242 }
243
244 ph->rxtime = NOW;
245 ph->worth_tracing = true;
246
247 if (isOn == true) {
248 PacketEvent *pe = new PacketEvent(p);
249 Scheduler::instance().schedule(&rxtimer, pe, ph->duration);
250
251 startRx(p);
252 } else {
253 Packet::free(p);
254 }
255 } else {
256 Packet::free(p);
257 }
258 } else { // Direction DOWN
259 assert(isOn);
260
261 ph->Pr = 0;
262 ph->Pn = 0;
263 ph->Pi = 0;
264 ph->txtime = NOW;
265 ph->rxtime = ph->txtime;
266
267 ph->worth_tracing = false;
268
269 ph->srcSpectralMask = getTxSpectralMask(p);
270 ph->srcAntenna = getTxAntenna(p);
271 ph->srcPosition = getPosition();
272 ph->dstSpectralMask = 0;
273 ph->dstPosition = 0;
274 ph->dstAntenna = 0;
275 ph->modulationType = getModulationType(p);
276 ph->duration = getTxDuration(p);
277
278 ph->Pt = getTxPower(p);
279
280 assert(ph->srcSpectralMask);
281 assert(ph->srcPosition);
282 assert(ph->duration > 0);
283 assert(ph->Pt > 0);
284
285 PacketEvent *pe = new PacketEvent(p->copy());
286 Scheduler::instance().schedule(&txtimer, pe, ph->duration);
287
288 startTx(p);
289 }
290} /* UnderwaterPhysical::recv */
291
292void
294{
295 hdr_cmn *ch = HDR_CMN(p);
296 hdr_MPhy *ph = HDR_MPHY(p);
297
298 Tx_Time_ += ph->duration;
299 Energy_Tx_ += consumedEnergyTx(ph->duration);
300
301 Transmitted_bytes_ += ch->size();
302
303 return UnderwaterMPhyBpsk::endTx(p);
304} /* UnderwaterPhysical::endTx */
305
306void
308{
309 hdr_mac *mach = HDR_MAC(p);
310 hdr_MPhy *ph = HDR_MPHY(p);
311
312 static int mac_addr = -1;
313
314 ClMsgPhy2MacAddr msg;
315 sendSyncClMsg(&msg);
316 mac_addr = msg.getAddr();
317
318 if ((PktRx == 0) && (txPending == false)) {
319 // The receiver is is not synchronized on any transmission
320 // so we can sync on this packet
321 std::stringstream log_sstr;
322 double snr_dB = 10 * log10(ph->Pr / ph->Pn);
323
324 log_sstr << "startRx(Packet *)::"
325 << "snr_dB = " << snr_dB
326 << "; AcquisitionThreshold_dB_ = " << getAcquisitionThreshold()
327 << " pr " << 10 * log10(ph->Pr) << " pn " << 10 * log10(ph->Pn)
328 << " end " << NOW + ph->duration << " src "
329 << HDR_CMN(p)->prev_hop_ << " dest " << HDR_CMN(p)->next_hop()
330 << " size " << HDR_CMN(p)->size();
331 printOnLog(Logger::LogLevel::DEBUG, "UWPHY", log_sstr.str());
332
333 if (snr_dB > getAcquisitionThreshold()) {
334 if (ph->modulationType == modid) {
335 // This is a BPSK packet so we sync on it
336 PktRx = p;
337 // Notify the MAC
338 Phy2MacStartRx(p);
339
340 log_sstr.str("");
341 log_sstr << "startRx(Packet *)::"
342 << "sync on PktRx = " << PktRx << " end "
343 << NOW + HDR_CMN(p)->txtime() << " src "
344 << HDR_CMN(p)->prev_hop_ << " dest "
345 << HDR_CMN(p)->next_hop() << " size "
346 << HDR_CMN(p)->size();
347 printOnLog(Logger::LogLevel::DEBUG, "UWPHY", log_sstr.str());
348
349 return;
350 } else {
351 printOnLog(Logger::LogLevel::DEBUG,
352 "UWPHY",
353 "startRx(Packet *)::dropping pkt, wrong modid");
354
355 if ((mach->macDA() == mac_addr) &&
356 (mach->ftype() != MF_CONTROL)) {
358 } else if ((mach->macDA() == mac_addr) &&
359 (mach->ftype() == MF_CONTROL)) {
361 }
362 }
363 } else {
364 printOnLog(Logger::LogLevel::DEBUG,
365 "UWPHY",
366 "startRx(Packet *)::dropping pkt, below threshold");
367
368 incrErrorPktsNoise();
369 if (mach->ftype() != MF_CONTROL) {
371 } else if (mach->ftype() == MF_CONTROL) {
373 }
374 }
375 } else if (txPending == true) {
376 printOnLog(Logger::LogLevel::DEBUG,
377 "UWPHY",
378 "startRx(Packet *)::dropping pkt, tx pending");
379
380 if (mach->ftype() != MF_CONTROL) {
382 }
383 if (mach->ftype() == MF_CONTROL) {
385 }
386 } else {
387 if (mach->ftype() != MF_CONTROL) {
389 } else if (mach->ftype() == MF_CONTROL) {
391 }
392 }
393} /* UnderwaterPhysical::startRx */
394
395void
397{
398 hdr_cmn *ch = HDR_CMN(p);
399 hdr_MPhy *ph = HDR_MPHY(p);
400 hdr_mac *mach = HDR_MAC(p);
401 counter interferent_pkts;
402
403 ClMsgPhy2MacAddr msg;
404 sendSyncClMsg(&msg);
405
406 if (PktRx != 0) {
407 if (PktRx == p) {
408 double per_ni;
409 double ber_ni;
410 double sinr;
411 int nbits = ch->size() * 8;
412 double x = RNG::defaultrng()->uniform_double();
413 bool error_n = 0; // x <= per_n;
414 bool error_ni = 0;
415 double interference_power = 0;
416 if (interference_) {
417 if (Interference_Model == "CHUNK") {
418 const PowerChunkList &power_chunk_list =
419 interference_->getInterferencePowerChunkList(p);
420 if (power_chunk_list.size() < 1) {
421 // we have no interferent
422 sinr = ph->Pr / ph->Pn;
423 per_ni = getPER(sinr, nbits, p);
424 ber_ni = getPER(sinr, 1, p);
425 error_ni = x <= per_ni;
426 } else {
427 for (PowerChunkList::const_iterator itInterf =
428 power_chunk_list.begin();
429 itInterf != power_chunk_list.end();
430 itInterf++) {
431 int nbits2 = itInterf->second * BitRate_;
432 interference_power = itInterf->first;
433 sinr = ph->Pr / (ph->Pn + itInterf->first);
434 per_ni = getPER(sinr, nbits2, p);
435 ber_ni = getPER(sinr, 1, p);
436 x = RNG::defaultrng()->uniform_double();
437 error_ni = x <= per_ni;
438 if (error_ni) {
439 break;
440 }
441 }
442 }
443 } else if (Interference_Model == "MEANPOWER") {
444 interference_power = interference_->getInterferencePower(p);
445 sinr = ph->Pr / (ph->Pn + interference_power);
446 per_ni = getPER(sinr, nbits, p);
447 ber_ni = getPER(sinr, 1, p);
448 error_ni = x <= per_ni;
449 } else {
450 printOnLog(Logger::LogLevel::ERROR,
451 "UWPHY",
452 "endRx(Packet *)::Please choose the right "
453 "interference model "
454 "to use: CHUNK or MEANPOWER");
455
456 exit(1);
457 }
458 interferent_pkts = interference_->getCounters(p);
459
460 } else {
461 interference_power = ph->Pi;
462 sinr = ph->Pr / (ph->Pn + ph->Pi);
463 per_ni = getPER(sinr, nbits, p);
464 ber_ni = getPER(sinr, 1, p);
465 error_ni = x <= per_ni;
466 }
467
468 if (interference_power < (ph->Pn / 10)) {
469 error_n = error_ni;
470 error_ni = 0; // error transfered on noise
471 }
472 // update stats and trigger the modules that collect the stats
473 auto uwphystats = dynamic_cast<UwPhysicalStats *>(stats_ptr);
474 if (uwphystats) {
475 uwphystats->updateStats(getId(),
476 getStackId(),
477 ph->Pr,
478 ph->Pn,
479 interference_power,
480 sinr,
481 ber_ni,
482 per_ni,
483 (error_n > 0 || error_ni > 0));
484 }
486 sendSyncClMsg(&m);
487
488 if (time_ready_to_end_rx_ > Scheduler::instance().clock()) {
489 Rx_Time_ = Rx_Time_ + ph->duration - time_ready_to_end_rx_ +
490 Scheduler::instance().clock();
491 } else {
492 Rx_Time_ += ph->duration;
493 }
495 Scheduler::instance().clock() + ph->duration;
496 Energy_Rx_ += consumedEnergyRx(ph->duration);
497 ch->error() = error_n || error_ni;
498 if (debug_) {
499 if (error_ni == 1) {
500 if (debug_) {
501 printOnLog(Logger::LogLevel::ERROR,
502 "UWPHY",
503 "endRx(Packet *)::packet " +
504 to_string(ch->uid()) +
505 " contains errors due to noise and "
506 "interference.");
507 }
508 } else if (error_n == 1) {
509 if (debug_) {
510 printOnLog(Logger::LogLevel::ERROR,
511 "UWPHY",
512 "endRx(Packet *)::packet " +
513 to_string(ch->uid()) +
514 " contains errors due to noise");
515 }
516 }
517 }
518 if (error_n) {
519 incrErrorPktsNoise();
520 if (mach->ftype() != MF_CONTROL) {
522 } else if (mach->ftype() == MF_CONTROL) {
524 }
525 } else if (error_ni) {
526 if (mach->ftype() != MF_CONTROL) {
527 incrErrorPktsInterf();
529 if (interferent_pkts.second >= 1) {
531 } else {
532 if (interferent_pkts.first > 0) {
534 }
535 }
536 } else if (mach->ftype() == MF_CONTROL) {
539 if (interferent_pkts.first > 0) {
541 }
542 }
543 }
544 sendUp(p);
545 PktRx = 0;
546 } else {
547 dropPacket(p);
548 }
549 } else {
550 dropPacket(p);
551 }
552} /* UnderwaterPhysical::endRx */
553
554double
555UnderwaterPhysical::getPER(double _snr, int _nbits, Packet *_p)
556{
557 double snr_with_penalty = _snr * pow(10, RxSnrPenalty_dB_ / 10.0);
558
559 double ber_ = 0;
560 if (modulation_name_ == "BPSK") {
561 ber_ = 0.5 * erfc(sqrt(snr_with_penalty));
562 } else if (modulation_name_ == "BFSK") {
563 ber_ = 0.5 * exp(-snr_with_penalty / 2);
564 } else if (modulation_name_ == "8PSK") {
565 double const M = 8;
566 ber_ = (1 / this->log2(M)) *
567 get_prob_error_symbol_mpsk(snr_with_penalty, M);
568 } else if (modulation_name_ == "16PSK") {
569 double const M = 16;
570 ber_ = (1 / this->log2(M)) *
571 get_prob_error_symbol_mpsk(snr_with_penalty, M);
572 } else if (modulation_name_ == "32PSK") {
573 double const M = 32;
574 ber_ = (1 / this->log2(M)) *
575 get_prob_error_symbol_mpsk(snr_with_penalty, M);
576 }
577
578 if (_nbits == 1) {
579 return ber_;
580 }
581 // PER calculation
582 return 1 - pow(1 - ber_, _nbits);
583} /* UnderwaterPhysical::getPER */
584
585int
587{
588 if (m->type() == CLMSG_UWPHY_LOSTPKT) {
589 int lost_packet = ((ClMsgUwPhyGetLostPkts *) m)->isControl()
592 ((ClMsgUwPhyGetLostPkts *) m)->setLostPkts(lost_packet);
593 return 0;
594 }
595 if (m->type() == CLMSG_STATS) {
597 (dynamic_cast<ClMsgStats *>(m))->setStats(stats_ptr);
598 return 0;
599 }
600 return UnderwaterMPhyBpsk::recvSyncClMsg(m);
601}
602
603void
605{
606 Packet *temp = Packet::alloc();
607 hdr_MPhy *ph = HDR_MPHY(temp);
608 ph->dstSpectralMask = getRxSpectralMask(temp);
609 ph->dstPosition = getPosition();
610 ph->dstAntenna = getRxAntenna(temp);
611 assert(ph->dstSpectralMask);
612 assert(ph->dstPosition);
613
614 ph->srcSpectralMask = getTxSpectralMask(temp);
615 ph->srcAntenna = getTxAntenna(temp);
616 ph->srcPosition = getPosition();
617 assert(ph->srcSpectralMask);
618
619 (dynamic_cast<UwPhysicalStats *>(stats_ptr))->instant_noise_power =
620 getNoisePower(temp);
621 Packet::free(temp);
622}
ClMsgUwPhyGetLostPkts should be used by a layer to ask the phy how many packets it discarded from the...
void incrTot_pkts_lost()
Increment the number of packets discarded.
Definition uwphysical.h:287
std::string Interference_Model
Interference calcuation mode chosen: CHUNK model or MEANPOWER model.
Definition uwphysical.h:441
int getCollisionsDATAvsCTRL() const
Definition uwphysical.h:371
UnderwaterPhysical()
Constructor of UnderwaterPhysical class.
double tx_power_
Power required in transmission.
Definition uwphysical.h:429
double get_prob_error_symbol_mpsk(const double &_snr, const uint32_t _M) const
Definition uwphysical.h:414
double Tx_Time_
Time (in seconds) spent by the node in transmission.
Definition uwphysical.h:421
uwinterference * interference_
Pointer to the interference module.
Definition uwphysical.h:444
std::string modulation_name_
Modulation scheme name.
Definition uwphysical.h:419
virtual double consumedEnergyTx(const double &_duration) const
Compute the energy (in Joule) spent by the modem in transmission.
Definition uwphysical.h:179
virtual int command(int, const char *const *) override
TCL command interpreter.
double Get_Energy_Rx() const
Returns the energy (in Joule) spent by the node in reception.
Definition uwphysical.h:267
int getCollisionsCTRL() const
Definition uwphysical.h:381
void incrErrorCtrlPktsInterf()
Increment the number of CTRL packets discarded due to interference.
Definition uwphysical.h:305
int getError_CtrlPktsInterf() const
Definition uwphysical.h:361
int getTot_CtrlPkts_lost() const
Definition uwphysical.h:351
double Energy_Rx_
Energy (in Joule) spent by the node in transmission.
Definition uwphysical.h:426
double Transmitted_bytes_
Number of bytes transmitted.
Definition uwphysical.h:428
virtual void updateInstantaneousStats()
Update the stats before sending them through crosslayer message.
double Get_Energy_Tx() const
Returns the energy (in Joule) spent by the node in transmission.
Definition uwphysical.h:256
virtual void endTx(Packet *p) override
Handles the end of a packet transmission.
virtual void recv(Packet *) override
recv method.
double Energy_Tx_
Energy (in Joule) spent by the node in transmission.
Definition uwphysical.h:424
double rx_power_
Power required in reception.
Definition uwphysical.h:430
virtual void startRx(Packet *p) override
Handles the start of a reception.
void incrCollisionCTRL()
Increment the number of CTRL pkts discarded due to a collision.
Definition uwphysical.h:323
void incrCollisionDATAvsCTRL()
Increment the number of collisions DATA/CTRL.
Definition uwphysical.h:314
double time_ready_to_end_rx_
Used to keep track of the rx time.
Definition uwphysical.h:420
virtual double consumedEnergyRx(const double &_duration) const
Compute the energy (in Joule) spent by the modem in reception.
Definition uwphysical.h:192
int recvSyncClMsg(ClMessage *m) override
recv syncronous cross layer messages to require an operation from another module
double Get_Tx_Time() const
Returns the time (in seconds) spent by the node in transmission.
Definition uwphysical.h:234
int getTot_pkts_lost() const
Definition uwphysical.h:341
virtual void endRx(Packet *p) override
Handles the end of a packet reception.
double log2(const double &_input) const
Definition uwphysical.h:402
double Rx_Time_
Time (in seconds) spent by the node in reception.
Definition uwphysical.h:423
virtual ~UnderwaterPhysical()
Destructor of UnderwaterPhysical class.
void incrCollisionDATA()
Increment the number of DATA pkts discarded due to a collision.
Definition uwphysical.h:332
virtual double getPER(double snr, int nbits, Packet *_p)
Returns the packet error rate by using the length of a packet and the information contained in the pa...
void incrTotCrtl_pkts_lost()
Increment the number of CTRL packets discarded.
Definition uwphysical.h:296
int getCollisionsDATA() const
Definition uwphysical.h:391
double Get_Transmitted_bytes() const
Returns the number of bytes transmitted.
Definition uwphysical.h:278
double Get_Rx_Time() const
Returns the time (in seconds) spent by the node in reception.
Definition uwphysical.h:245
TclObject * create(int, const char *const *)
UwPhysicalStats()
Constructor of UwPhysicalStats class.
double last_per
BER of the last received packet.
Definition uwphysical.h:96
double last_rx_power
True if last packet wasn't correctly received.
Definition uwphysical.h:90
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)
Method to update stats with the param of last received packet.
virtual Stats * clone() const
Virtual method used by the Module class in order to copy its stats an a generic fashion,...
double last_ber
SINR of the last received packet.
Definition uwphysical.h:95
double last_noise_power
Power of the last received packet.
Definition uwphysical.h:91
double last_interf_power
Noise power measured on query.
Definition uwphysical.h:93
double last_sinr
Interference power of the last rx packet.
Definition uwphysical.h:94
double instant_noise_power
Noise power of the last received packet.
Definition uwphysical.h:92
virtual counter getCounters(Packet *p)
Returns the counters of collisions.
virtual void addToInterference(Packet *p)
Add a packet to the interference calculation.
virtual double getInterferencePower(Packet *p)
Compute the average interference power for the given packet.
std::pair< int, int > counter
counter of collisions
Definition of ClMsgUwMmac class.
UwPhysicalClass class_module_uwphysical
Definition of UwPhysical class.
Utilities to manage stats.