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