A Discrete-Event Network Simulator
API
uan-phy-gen.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Leonard Tracy <lentracy@gmail.com>
19  * Andrea Sacco <andrea.sacco85@gmail.com>
20  */
21 
22 #include "uan-phy-gen.h"
23 #include "uan-transducer.h"
24 #include "uan-channel.h"
25 #include "uan-net-device.h"
26 #include "ns3/simulator.h"
27 #include "ns3/traced-callback.h"
28 #include "ns3/ptr.h"
29 #include "ns3/trace-source-accessor.h"
30 #include "ns3/double.h"
31 #include "ns3/string.h"
32 #include "ns3/log.h"
33 #include "ns3/uan-tx-mode.h"
34 #include "ns3/node.h"
35 #include "ns3/uinteger.h"
36 #include "ns3/energy-source-container.h"
37 #include "ns3/acoustic-modem-energy-model.h"
38 
39 
40 namespace ns3 {
41 
42 NS_LOG_COMPONENT_DEFINE ("UanPhyGen");
43 
44 NS_OBJECT_ENSURE_REGISTERED (UanPhyGen);
45 NS_OBJECT_ENSURE_REGISTERED (UanPhyPerGenDefault);
46 NS_OBJECT_ENSURE_REGISTERED (UanPhyCalcSinrDefault);
47 NS_OBJECT_ENSURE_REGISTERED (UanPhyCalcSinrFhFsk);
48 NS_OBJECT_ENSURE_REGISTERED (UanPhyPerUmodem);
49 NS_OBJECT_ENSURE_REGISTERED (UanPhyPerCommonModes);
50 
51 
52 /*************** UanPhyCalcSinrDefault definition *****************/
54 {
55 
56 }
58 {
59 
60 }
61 
62 TypeId
64 {
65  static TypeId tid = TypeId ("ns3::UanPhyCalcSinrDefault")
67  .SetGroupName ("Uan")
68  .AddConstructor<UanPhyCalcSinrDefault> ()
69  ;
70  return tid;
71 }
72 
73 double
75  Time arrTime,
76  double rxPowerDb,
77  double ambNoiseDb,
78  UanTxMode mode,
79  UanPdp pdp,
80  const UanTransducer::ArrivalList &arrivalList) const
81 {
82  if (mode.GetModType () == UanTxMode::OTHER)
83  {
84  NS_LOG_WARN ("Calculating SINR for unsupported modulation type");
85  }
86 
87  double intKp = -DbToKp (rxPowerDb); // This packet is in the arrivalList
88  UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
89  for (; it != arrivalList.end (); it++)
90  {
91  intKp += DbToKp (it->GetRxPowerDb ());
92  }
93 
94  double totalIntDb = KpToDb (intKp + DbToKp (ambNoiseDb));
95 
96  NS_LOG_DEBUG ("Calculating SINR: RxPower = " << rxPowerDb << " dB. Number of interferers = " << arrivalList.size () << " Interference + noise power = " << totalIntDb << " dB. SINR = " << rxPowerDb - totalIntDb << " dB.");
97  return rxPowerDb - totalIntDb;
98 }
99 
100 /*************** UanPhyCalcSinrFhFsk definition *****************/
102 {
103 
104 }
106 {
107 
108 }
109 
110 TypeId
112 {
113  static TypeId tid = TypeId ("ns3::UanPhyCalcSinrFhFsk")
115  .SetGroupName ("Uan")
116  .AddConstructor<UanPhyCalcSinrFhFsk> ()
117  .AddAttribute ("NumberOfHops",
118  "Number of frequencies in hopping pattern.",
119  UintegerValue (13),
121  MakeUintegerChecker<uint32_t> ())
122  ;
123  return tid;
124 }
125 double
127  Time arrTime,
128  double rxPowerDb,
129  double ambNoiseDb,
130  UanTxMode mode,
131  UanPdp pdp,
132  const UanTransducer::ArrivalList &arrivalList) const
133 {
134  if ((mode.GetModType () != UanTxMode::FSK) && (mode.GetConstellationSize () != 13))
135  {
136  NS_FATAL_ERROR ("Calculating SINR for unsupported mode type");
137  }
138 
139  double ts = 1.0 / mode.GetPhyRateSps ();
140  double clearingTime = (m_hops - 1.0) * ts;
141  double csp = pdp.SumTapsFromMaxNc (Seconds (0), Seconds (ts));
142 
143  // Get maximum arrival offset
144  double maxAmp = -1;
145  double maxTapDelay = 0.0;
146  UanPdp::Iterator pit = pdp.GetBegin ();
147  for (; pit != pdp.GetEnd (); pit++)
148  {
149  if (std::abs (pit->GetAmp ()) > maxAmp)
150  {
151  maxAmp = std::abs (pit->GetAmp ());
152  // Modified in order to subtract delay of first tap (maxTapDelay appears to be used later in code
153  // as delay from first reception, not from TX time)
154  maxTapDelay = pit->GetDelay ().GetSeconds () - pdp.GetTap(0).GetDelay().GetSeconds();
155  }
156  }
157 
158 
159  double effRxPowerDb = rxPowerDb + KpToDb (csp);
160  //It appears to be just the first elements of the sum in Parrish paper,
161  // "System Design Considerations for Undersea Networks: Link and Multiple Access Protocols", eq. 14
162  double isiUpa = DbToKp(rxPowerDb) * pdp.SumTapsFromMaxNc (Seconds (ts + clearingTime), Seconds (ts)); // added DpToKp()
163  UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
164  double intKp = -DbToKp (effRxPowerDb);
165  for (; it != arrivalList.end (); it++)
166  {
167  UanPdp intPdp = it->GetPdp ();
168  double tDelta = std::abs (arrTime.GetSeconds () + maxTapDelay - it->GetArrivalTime ().GetSeconds ());
169  // We want tDelta in terms of a single symbol (i.e. if tDelta = 7.3 symbol+clearing
170  // times, the offset in terms of the arriving symbol power is
171  // 0.3 symbol+clearing times.
172 
173  int32_t syms = (uint32_t)( (double) tDelta / (ts + clearingTime));
174  tDelta = tDelta - syms * (ts + clearingTime);
175 
176  // Align to pktRx
177  if (arrTime + Seconds (maxTapDelay) > it->GetArrivalTime ())
178  {
179  tDelta = ts + clearingTime - tDelta;
180  }
181 
182  double intPower = 0.0;
183  if (tDelta < ts) // Case where there is overlap of a symbol due to interferer arriving just after desired signal
184  {
185  //Appears to be just the first two elements of the sum in Parrish paper, eq. 14
186  intPower += intPdp.SumTapsNc (Seconds (0), Seconds (ts - tDelta));
187  intPower += intPdp.SumTapsNc (Seconds (ts - tDelta + clearingTime),
188  Seconds (2 * ts - tDelta + clearingTime));
189  }
190  else // Account for case where there's overlap of a symbol due to interferer arriving with a tDelta of a symbol + clearing time later
191  {
192  // Appears to be just the first two elements of the sum in Parrish paper, eq. 14
193  Time start = Seconds (ts + clearingTime - tDelta);
194  Time end = /*start +*/ Seconds (ts); // Should only sum over portion of ts that overlaps, not entire ts
195  intPower += intPdp.SumTapsNc (start, end);
196 
197  start = start + Seconds (ts + clearingTime);
198  //Should only sum over portion of ts that overlaps, not entire ts
199  end = end + Seconds (ts + clearingTime); //start + Seconds (ts);
200  intPower += intPdp.SumTapsNc (start, end);
201  }
202  intKp += DbToKp (it->GetRxPowerDb ()) * intPower;
203  }
204 
205  double totalIntDb = KpToDb (isiUpa + intKp + DbToKp (ambNoiseDb));
206 
207  NS_LOG_DEBUG ("Calculating SINR: RxPower = " << rxPowerDb << " dB. Effective Rx power " << effRxPowerDb << " dB. Number of interferers = " << arrivalList.size () << " Interference + noise power = " << totalIntDb << " dB. SINR = " << effRxPowerDb - totalIntDb << " dB.");
208  return effRxPowerDb - totalIntDb;
209 }
210 
211 /*************** UanPhyPerGenDefault definition *****************/
213 {
214 
215 }
216 
218 {
219 
220 }
221 TypeId
223 {
224  static TypeId tid = TypeId ("ns3::UanPhyPerGenDefault")
225  .SetParent<UanPhyPer> ()
226  .SetGroupName ("Uan")
227  .AddConstructor<UanPhyPerGenDefault> ()
228  .AddAttribute ("Threshold", "SINR cutoff for good packet reception.",
229  DoubleValue (8),
231  MakeDoubleChecker<double> ());
232  return tid;
233 }
234 
235 
236 // Default PER calculation simply compares SINR to a threshold which is configurable
237 // via an attribute.
238 double
240 {
241  if (sinrDb >= m_thresh)
242  {
243  return 0;
244  }
245  else
246  {
247  return 1;
248  }
249 }
250 
251 /*************** UanPhyPerCommonModes definition *****************/
253  : UanPhyPer ()
254 {
255 
256 }
257 
259 {
260 
261 }
262 
263 TypeId
265 {
266  static TypeId tid = TypeId ("ns3::UanPhyPerCommonModes")
267  .SetParent<UanPhyPer> ()
268  .SetGroupName ("Uan")
269  .AddConstructor<UanPhyPerCommonModes> ();
270 
271  return tid;
272 }
273 
274 double
276 {
277  NS_LOG_FUNCTION (this);
278 
279  double EbNo = std::pow (10.0, sinrDb / 10.0);
280  double BER = 1.0;
281  double PER = 0.0;
282 
283  switch (mode.GetModType ())
284  {
285  case UanTxMode::PSK:
286  switch (mode.GetConstellationSize ())
287  {
288  case 2: // BPSK
289  {
290  BER = 0.5 * erfc (sqrt (EbNo));
291  break;
292  }
293  case 4: // QPSK, half BPSK EbNo
294  {
295  BER = 0.5 * erfc (sqrt (0.5 * EbNo));
296  break;
297  }
298 
299  default:
300  NS_FATAL_ERROR ("constellation " << mode.GetConstellationSize () << " not supported");
301  break;
302  }
303 
304  // taken from Ronell B. Sicat, "Bit Error Probability Computations for M-ary Quadrature Amplitude Modulation",
305  // EE 242 Digital Communications and Codings, 2009
306  case UanTxMode::QAM:
307  {
308  // generic EbNo
309  EbNo *= mode.GetDataRateBps () / mode.GetBandwidthHz ();
310 
311  double M = (double) mode.GetConstellationSize ();
312 
313  // standard squared quantized QAM, even number of bits per symbol supported
314  int log2sqrtM = (int) ::std::log2 ( sqrt (M));
315 
316  double log2M = ::std::log2 (M);
317 
318  if ((int)log2M % 2)
319  {
320  NS_FATAL_ERROR ("constellation " << M << " not supported");
321  }
322 
323  double sqrtM = ::std::sqrt (M);
324 
325  NS_LOG_DEBUG ("M=" << M << "; log2sqrtM=" << log2sqrtM << "; log2M=" << log2M << "; sqrtM=" << sqrtM);
326 
327  BER = 0.0;
328 
329  // Eq (75)
330  for (int k = 0; k < log2sqrtM; k++)
331  {
332  int sum_items = (int) ((1.0 - ::std::pow ( 2.0, (-1.0) * (double) k)) * ::std::sqrt (M) - 1.0);
333  double pow2k = ::std::pow (2.0, (double) k - 1.0);
334 
335  NS_LOG_DEBUG ("k=" << k << "; sum_items=" << sum_items << "; pow2k=" << pow2k);
336 
337  double PbK = 0;
338 
339  // Eq (74)
340  for (int j = 0; j < sum_items; ++j)
341  {
342  PbK += ::std::pow (-1.0, (double) j * pow2k / sqrtM)
343  * (pow2k - ::std::floor ( (double) (j * pow2k / sqrtM) - 0.5))
344  * erfc ((2.0 * (double)j + 1.0) * ::std::sqrt (3.0 * (log2M * EbNo) / (2.0 * (M - 1.0))));
345 
346  NS_LOG_DEBUG ("j=" << j << "; PbK=" << PbK);
347 
348  }
349  PbK *= 1.0 / sqrtM;
350 
351  BER += PbK;
352 
353  NS_LOG_DEBUG ("k=" << k << "; PbK=" << PbK << "; BER=" << BER);
354  }
355 
356  BER *= 1.0 / (double) log2sqrtM;
357 
358  break;
359  }
360 
361  case UanTxMode::FSK:
362  switch (mode.GetConstellationSize ())
363  {
364  case 2:
365  {
366  BER = 0.5 * erfc (sqrt (0.5 * EbNo));
367  break;
368  }
369 
370  default:
371  NS_FATAL_ERROR ("constellation " << mode.GetConstellationSize () << " not supported");
372  break;
373  }
374 
375  default: // OTHER and error
376  NS_FATAL_ERROR ("Mode " << mode.GetModType () << " not supported");
377  break;
378  }
379 
380  PER = (1.0 - pow (1.0 - BER, (double) pkt->GetSize () * 8.0));
381 
382  NS_LOG_DEBUG ("BER=" << BER << "; PER=" << PER);
383 
384  return PER;
385 }
386 
387 /*************** UanPhyPerUmodem definition *****************/
389 {
390 
391 }
393 {
394 
395 }
396 
398 {
399  static TypeId tid = TypeId ("ns3::UanPhyPerUmodem")
400  .SetParent<UanPhyPer> ()
401  .SetGroupName ("Uan")
402  .AddConstructor<UanPhyPerUmodem> ()
403  ;
404  return tid;
405 }
406 
407 double
408 UanPhyPerUmodem::NChooseK (uint32_t n, uint32_t k)
409 {
410  double result;
411 
412  result = 1.0;
413 
414  for (uint32_t i = std::max (k,n - k) + 1; i <= n; ++i)
415  {
416  result *= i;
417  }
418 
419  for (uint32_t i = 2; i <= std::min (k,n - k); ++i)
420  {
421  result /= i;
422  }
423 
424  return result;
425 }
426 
427 double
429 {
430  uint32_t d[] =
431  { 12, 14, 16, 18, 20, 22, 24, 26, 28 };
432  double Bd[] =
433  {
434  33, 281, 2179, 15035LLU, 105166LLU, 692330LLU, 4580007LLU, 29692894LLU,
435  190453145LLU
436  };
437 
438  // double Rc = 1.0 / 2.0;
439  double ebno = std::pow (10.0, sinr / 10.0);
440  double perror = 1.0 / (2.0 + ebno);
441  double P[9];
442 
443  if ((mode.GetModType () != UanTxMode::FSK) && (mode.GetConstellationSize () != 13))
444  {
445  NS_FATAL_ERROR ("Calculating SINR for unsupported mode type");
446  }
447  if (sinr >= 10)
448  {
449  return 0;
450  }
451  if (sinr <= 6)
452  {
453  return 1;
454  }
455 
456  for (uint32_t r = 0; r < 9; r++)
457  {
458  double sumd = 0;
459  for (uint32_t k = 0; k < d[r]; k++)
460  {
461  sumd = sumd + NChooseK (d[r] - 1 + k, k) * std::pow (1 - perror, (double) k);
462  }
463  P[r] = std::pow (perror, (double) d[r]) * sumd;
464 
465  }
466 
467  double Pb = 0;
468  for (uint32_t r = 0; r < 8; r++)
469  {
470  Pb = Pb + Bd[r] * P[r];
471  }
472 
473  // cout << "Pb = " << Pb << endl;
474  uint32_t bits = pkt->GetSize () * 8;
475 
476  double Ppacket = 1;
477  double temp = NChooseK (bits, 0);
478  temp *= std::pow ( (1 - Pb), (double) bits);
479  Ppacket -= temp;
480  temp = NChooseK (288, 1) * Pb * std::pow ( (1 - Pb), bits - 1.0);
481  Ppacket -= temp;
482 
483  if (Ppacket > 1)
484  {
485  return 1;
486  }
487  else
488  {
489  return Ppacket;
490  }
491 }
492 
493 /*************** UanPhyGen definition *****************/
495  : UanPhy (),
496  m_state (IDLE),
497  m_channel (0),
498  m_transducer (0),
499  m_device (0),
500  m_mac (0),
501  m_txPwrDb (0),
502  m_rxThreshDb (0),
503  m_ccaThreshDb (0),
504  m_pktRx (0),
505  m_pktTx (0),
506  m_cleared (false)
507 {
508  m_pg = CreateObject<UniformRandomVariable> ();
509 
511 }
512 
514 {
515 
516 }
517 
518 void
520 {
521  if (m_cleared)
522  {
523  return;
524  }
525  m_cleared = true;
526  m_listeners.clear ();
527  if (m_channel)
528  {
529  m_channel->Clear ();
530  m_channel = 0;
531  }
532  if (m_transducer)
533  {
534  m_transducer->Clear ();
535  m_transducer = 0;
536  }
537  if (m_device)
538  {
539  m_device->Clear ();
540  m_device = 0;
541  }
542  if (m_mac)
543  {
544  m_mac->Clear ();
545  m_mac = 0;
546  }
547  if (m_per)
548  {
549  m_per->Clear ();
550  m_per = 0;
551  }
552  if (m_sinr)
553  {
554  m_sinr->Clear ();
555  m_sinr = 0;
556  }
557  m_pktRx = 0;
558 }
559 
560 void
562 {
563  Clear ();
566 }
567 
570 {
571  UanModesList l;
572  l.AppendMode (UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 22000, 4000, 13, "FH-FSK")); // micromodem only
573  l.AppendMode (UanTxModeFactory::CreateMode (UanTxMode::PSK, 200, 200, 22000, 4000, 4, "QPSK"));
574  l.AppendMode (UanTxModeFactory::CreateMode (UanTxMode::PSK, 5000, 5000, 25000, 5000, 4, "QPSK")); // micromodem2
575 
576  return l;
577 }
578 
579 TypeId
581 {
582 
583  static TypeId tid = TypeId ("ns3::UanPhyGen")
584  .SetParent<UanPhy> ()
585  .SetGroupName ("Uan")
586  .AddConstructor<UanPhyGen> ()
587  .AddAttribute ("CcaThreshold",
588  "Aggregate energy of incoming signals to move to CCA Busy state dB.",
589  DoubleValue (10),
591  MakeDoubleChecker<double> ())
592  .AddAttribute ("RxThreshold",
593  "Required SNR for signal acquisition in dB.",
594  DoubleValue (10),
596  MakeDoubleChecker<double> ())
597  .AddAttribute ("TxPower",
598  "Transmission output power in dB.",
599  DoubleValue (190),
601  MakeDoubleChecker<double> ())
602  .AddAttribute ("SupportedModes",
603  "List of modes supported by this PHY.",
607  .AddAttribute ("PerModel",
608  "Functor to calculate PER based on SINR and TxMode.",
609  StringValue ("ns3::UanPhyPerGenDefault"),
611  MakePointerChecker<UanPhyPer> ())
612  .AddAttribute ("SinrModel",
613  "Functor to calculate SINR based on pkt arrivals and modes.",
614  StringValue ("ns3::UanPhyCalcSinrDefault"),
616  MakePointerChecker<UanPhyCalcSinr> ())
617  .AddTraceSource ("RxOk",
618  "A packet was received successfully.",
620  "ns3::UanPhy::TracedCallback")
621  .AddTraceSource ("RxError",
622  "A packet was received unsuccessfully.",
624  "ns3::UanPhy::TracedCallback")
625  .AddTraceSource ("Tx",
626  "Packet transmission beginning.",
628  "ns3::UanPhy::TracedCallback")
629  ;
630  return tid;
631 
632 }
633 
634 void
636 {
637  NS_LOG_FUNCTION (this);
638  m_energyCallback = cb;
639 }
640 
641 void
643 {
644  NS_LOG_FUNCTION (this);
645 
646  if (!m_energyCallback.IsNull ())
647  {
648  m_energyCallback (state);
649  }
650 }
651 
652 void
654 {
655  NS_LOG_FUNCTION (this);
656  NS_LOG_DEBUG ("Energy depleted at node " << m_device->GetNode ()->GetId () <<
657  ", stopping rx/tx activities");
658 
659  m_state = DISABLED;
660  if (m_txEndEvent.IsRunning ())
661  {
664  m_pktTx = 0;
665  }
666  if (m_rxEndEvent.IsRunning ())
667  {
670  m_pktRx = 0;
671  }
672 }
673 
674 void
676 {
677  NS_LOG_FUNCTION (this);
678  NS_LOG_DEBUG ("Energy recharged at node " << m_device->GetNode ()->GetId () <<
679  ", restoring rx/tx activities");
680 
681  m_state = IDLE;
682 }
683 
684 void
685 UanPhyGen::SendPacket (Ptr<Packet> pkt, uint32_t modeNum)
686 {
687  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": Transmitting packet");
688  if (m_state == DISABLED)
689  {
690  NS_LOG_DEBUG ("Energy depleted, node cannot transmit any packet. Dropping.");
691  return;
692  }
693 
694  if (m_state == TX)
695  {
696  NS_LOG_DEBUG ("PHY requested to TX while already Transmitting. Dropping packet.");
697  return;
698  }
699  else if (m_state == SLEEP)
700  {
701  NS_LOG_DEBUG ("PHY requested to TX while sleeping. Dropping packet.");
702  return;
703  }
704 
705  UanTxMode txMode = GetMode (modeNum);
706 
707  if (m_pktRx != 0)
708  {
709  m_minRxSinrDb = -1e30;
710  m_pktRx = 0;
711  }
712 
713  m_transducer->Transmit (Ptr<UanPhy> (this), pkt, m_txPwrDb, txMode);
714  m_state = TX;
716  double txdelay = pkt->GetSize () * 8.0 / txMode.GetDataRateBps ();
717  m_pktTx = pkt;
719  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << " notifying listeners");
720  NotifyListenersTxStart (Seconds (txdelay));
721  m_txLogger (pkt, m_txPwrDb, txMode);
722 }
723 
724 void
726 {
727  if (m_state == SLEEP || m_state == DISABLED)
728  {
729  NS_LOG_DEBUG ("Transmission ended but node sleeping or dead");
730  return;
731  }
732 
733  NS_ASSERT (m_state == TX);
735  {
736  m_state = CCABUSY;
738  }
739  else
740  {
741  m_state = IDLE;
742  }
744 }
745 
746 void
748 {
749  m_listeners.push_back (listener);
750 }
751 
752 
753 void
754 UanPhyGen::StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
755 {
756  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": rx power after RX gain = " << rxPowerDb << " dB re uPa");
757 
758  switch (m_state)
759  {
760  case DISABLED:
761  NS_LOG_DEBUG ("Energy depleted, node cannot receive any packet. Dropping.");
762  NotifyRxDrop (pkt); // traced source netanim
763  return;
764  case TX:
765  NotifyRxDrop (pkt); // traced source netanim
766  NS_ASSERT (false);
767  break;
768  case RX:
769  {
770  NS_ASSERT (m_pktRx);
772  m_minRxSinrDb = (newSinrDb < m_minRxSinrDb) ? newSinrDb : m_minRxSinrDb;
773  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": Starting RX in RX mode. SINR of pktRx = " << m_minRxSinrDb);
774  NotifyRxBegin (pkt); // traced source netanim
775  }
776  break;
777 
778  case CCABUSY:
779  case IDLE:
780  {
781  NS_ASSERT (!m_pktRx);
782  bool hasmode = false;
783  for (uint32_t i = 0; i < GetNModes (); i++)
784  {
785  if (txMode.GetUid () == GetMode (i).GetUid ())
786  {
787  hasmode = true;
788  break;
789  }
790  }
791  if (!hasmode)
792  {
793  break;
794  }
795 
796 
797  double newsinr = CalculateSinrDb (pkt, Simulator::Now (), rxPowerDb, txMode, pdp);
798  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": Starting RX in IDLE mode. SINR = " << newsinr);
799  if (newsinr > m_rxThreshDb)
800  {
801  m_state = RX;
803  NotifyRxBegin (pkt); // traced source netanim
804  m_rxRecvPwrDb = rxPowerDb;
805  m_minRxSinrDb = newsinr;
806  m_pktRx = pkt;
808  m_pktRxMode = txMode;
809  m_pktRxPdp = pdp;
810  double txdelay = pkt->GetSize () * 8.0 / txMode.GetDataRateBps ();
811  m_rxEndEvent = Simulator::Schedule (Seconds (txdelay), &UanPhyGen::RxEndEvent, this, pkt, rxPowerDb, txMode);
813  }
814 
815  }
816  break;
817  case SLEEP:
818  NS_LOG_DEBUG ("Sleep mode. Dropping packet.");
819  NotifyRxDrop (pkt); // traced source netanim
820  break;
821  }
822 
824  {
825  m_state = CCABUSY;
827  }
828 
829 }
830 
831 void
832 UanPhyGen::RxEndEvent (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode)
833 {
834  if (pkt != m_pktRx)
835  {
836  return;
837  }
838 
839  if (m_state == DISABLED || m_state == SLEEP)
840  {
841  NS_LOG_DEBUG ("Sleep mode or dead. Dropping packet");
842  m_pktRx = 0;
843  NotifyRxDrop (pkt); // traced source netanim
844  return;
845  }
846 
847  NotifyRxEnd (pkt); // traced source netanim
849  {
850  m_state = CCABUSY;
852  }
853  else
854  {
855  m_state = IDLE;
857  }
858 
859  if (m_pg->GetValue (0, 1) > m_per->CalcPer (m_pktRx, m_minRxSinrDb, txMode))
860  {
861  m_rxOkLogger (pkt, m_minRxSinrDb, txMode);
863  if (!m_recOkCb.IsNull ())
864  {
865  m_recOkCb (pkt, m_minRxSinrDb, txMode);
866  }
867 
868  }
869  else
870  {
871  m_rxErrLogger (pkt, m_minRxSinrDb, txMode);
873  if (!m_recErrCb.IsNull ())
874  {
875  m_recErrCb (pkt, m_minRxSinrDb);
876  }
877  }
878 
879  m_pktRx = 0;
880 }
881 
882 void
884 {
885  m_recOkCb = cb;
886 }
887 
888 void
890 {
891  m_recErrCb = cb;
892 }
893 bool
895 {
896  return m_state == SLEEP;
897 }
898 bool
900 {
901  return m_state == IDLE;
902 }
903 bool
905 {
906  return !IsStateIdle () && !IsStateSleep ();
907 }
908 bool
910 {
911  return m_state == RX;
912 }
913 bool
915 {
916  return m_state == TX;
917 }
918 
919 bool
921 {
922  return m_state == CCABUSY;
923 }
924 
925 
926 void
928 {
929  m_txPwrDb = txpwr;
930 }
931 void
933 {
934  m_rxThreshDb = thresh;
935 }
936 void
938 {
939  m_ccaThreshDb = thresh;
940 }
941 
942 double
944 {
945  return m_txPwrDb;
946 
947 }
948 
949 double
951 {
952  return m_rxThreshDb;
953 }
954 double
956 {
957  return m_ccaThreshDb;
958 }
959 
962 {
963  return m_channel;
964 }
965 
968 {
969  return m_device;
970 }
971 
974 {
975  return m_transducer;
976 }
977 void
979 {
980  m_channel = channel;
981 }
982 
983 void
985 {
986  m_device = device;
987 }
988 
989 void
991 {
992  m_mac = mac;
993 }
994 
995 void
997 {
998  m_transducer = trans;
999  m_transducer->AddPhy (this);
1000 }
1001 
1002 void
1004 {
1005  if (sleep )
1006  {
1007  m_state = SLEEP;
1008  if (!m_energyCallback.IsNull ())
1009  {
1011  }
1012  }
1013  else if (m_state == SLEEP)
1014  {
1016  {
1017  m_state = CCABUSY;
1019  }
1020  else
1021  {
1022  m_state = IDLE;
1023  }
1024 
1025  if (!m_energyCallback.IsNull ())
1026  {
1028  }
1029  }
1030 }
1031 
1032 int64_t
1034 {
1035  NS_LOG_FUNCTION (this << stream);
1036  m_pg->SetStream (stream);
1037  return 1;
1038 }
1039 
1040 void
1041 UanPhyGen::NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode)
1042 {
1043  if (m_pktRx)
1044  {
1045  m_minRxSinrDb = -1e30;
1046  }
1047 }
1048 
1049 void
1051 {
1053  {
1054  m_state = IDLE;
1056  }
1057 }
1058 
1059 double
1060 UanPhyGen::CalculateSinrDb (Ptr<Packet> pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp)
1061 {
1062  double noiseDb = m_channel->GetNoiseDbHz ( (double) mode.GetCenterFreqHz () / 1000.0) + 10 * std::log10 (mode.GetBandwidthHz ());
1063  return m_sinr->CalcSinrDb (pkt, arrTime, rxPowerDb, noiseDb, mode, pdp, m_transducer->GetArrivalList ());
1064 }
1065 
1066 double
1068 {
1069 
1070  const UanTransducer::ArrivalList &arrivalList = m_transducer->GetArrivalList ();
1071 
1072  UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
1073 
1074  double interfPower = 0;
1075 
1076  for (; it != arrivalList.end (); it++)
1077  {
1078  if (pkt != it->GetPacket ())
1079  {
1080  interfPower += DbToKp (it->GetRxPowerDb ());
1081  }
1082  }
1083 
1084  return KpToDb (interfPower);
1085 
1086 }
1087 
1088 double
1090 {
1091  return std::pow (10, db / 10.0);
1092 }
1093 double
1095 {
1096  return 10 * std::log10 (kp);
1097 }
1098 
1099 void
1101 {
1102  ListenerList::const_iterator it = m_listeners.begin ();
1103  for (; it != m_listeners.end (); it++)
1104  {
1105  (*it)->NotifyRxStart ();
1106  }
1107 
1108 }
1109 void
1111 {
1112  ListenerList::const_iterator it = m_listeners.begin ();
1113  for (; it != m_listeners.end (); it++)
1114  {
1115  (*it)->NotifyRxEndOk ();
1116  }
1117 }
1118 void
1120 {
1121  ListenerList::const_iterator it = m_listeners.begin ();
1122  for (; it != m_listeners.end (); it++)
1123  {
1124  (*it)->NotifyRxEndError ();
1125  }
1126 }
1127 void
1129 {
1130  ListenerList::const_iterator it = m_listeners.begin ();
1131  for (; it != m_listeners.end (); it++)
1132  {
1133  (*it)->NotifyCcaStart ();
1134  }
1135 }
1136 void
1138 {
1139  ListenerList::const_iterator it = m_listeners.begin ();
1140  for (; it != m_listeners.end (); it++)
1141  {
1142  (*it)->NotifyCcaEnd ();
1143  }
1144 }
1145 
1146 void
1148 {
1149  ListenerList::const_iterator it = m_listeners.begin ();
1150  for (; it != m_listeners.end (); it++)
1151  {
1152  (*it)->NotifyTxStart (duration);
1153  }
1154 }
1155 
1156 uint32_t
1158 {
1159  return m_modes.GetNModes ();
1160 }
1161 
1162 UanTxMode
1164 {
1165  NS_ASSERT (n < m_modes.GetNModes ());
1166 
1167  return m_modes[n];
1168 }
1169 
1172 {
1173  return m_pktRx;
1174 }
1175 
1176 
1177 } // namespace ns3
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attched transducer.
Phase shift keying.
Definition: uan-tx-mode.h:51
tuple channel
Definition: third.py:85
virtual bool IsStateBusy(void)
Definition: uan-phy-gen.cc:904
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
Definition: uan-phy-gen.cc:973
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
Definition: uan-phy-gen.cc:950
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint32_t GetNModes(void) const
Get the number of modes in this list.
Definition: uan-tx-mode.cc:259
Idle state.
Definition: uan-phy.h:181
Ptr< const AttributeChecker > MakeUanModesListChecker(void)
Definition: uan-tx-mode.cc:303
std::vector< Tap >::const_iterator Iterator
Convenience iterator typedef.
virtual bool IsStateRx(void)
Definition: uan-phy-gen.cc:909
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
double KpToDb(double kp)
Convert kilopascals to dB.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback cb)
Set the DeviceEnergyModel callback for UanPhy device.
Definition: uan-phy-gen.cc:635
uint32_t m_hops
Number of hops.
Definition: uan-phy-gen.h:251
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void NotifyRxDrop(Ptr< const Packet > packet)
Called when the Phy drops a packet.
Definition: uan-phy.cc:144
Ptr< Packet > m_pktTx
Sent packet.
Definition: uan-phy-gen.h:345
Hold variables of type string.
Definition: string.h:41
virtual void SetReceiveErrorCallback(RxErrCallback cb)
Set the callback to be used when a packet is received with errors.
Definition: uan-phy-gen.cc:889
#define min(a, b)
Definition: 80211b.c:44
double CalculateSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp)
Calculate the SINR value for a packet.
virtual void EnergyDepletionHandler(void)
Handle the energy depletion event.
Definition: uan-phy-gen.cc:653
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
Definition: uan-phy-gen.cc:996
def start()
Definition: core.py:1790
Packet error rate calculation for common tx modes based on UanPhyPerUmodem.
Definition: uan-phy-gen.h:126
Sleeping.
Definition: uan-phy.h:185
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
virtual ~UanPhyGen()
Dummy destructor, see DoDispose.
Definition: uan-phy-gen.cc:513
Ptr< UniformRandomVariable > m_pg
Provides uniform random variables.
Definition: uan-phy-gen.h:358
Receiving.
Definition: uan-phy.h:183
Channel is IDLE, no packet is being transmitted.
Definition: csma-channel.h:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
double m_rxRecvPwrDb
Receiver power.
Definition: uan-phy-gen.h:347
double SumTapsFromMaxNc(Time delay, Time duration) const
Compute the non-coherent sum of tap amplitudes starting after a delay from the maximum amplitude for ...
Packet error rate calculation assuming WHOI Micromodem-like PHY (FH-FSK)
Definition: uan-phy-gen.h:74
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:796
virtual void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
Definition: uan-phy-gen.cc:754
virtual uint32_t GetNModes(void)
Get the number of transmission modes supported by this Phy.
Container for UanTxModes.
Definition: uan-tx-mode.h:257
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.
Definition: uan-phy-gen.cc:943
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition: simulator.cc:346
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-gen.cc:955
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
EventId m_rxEndEvent
Rx event.
Definition: uan-phy-gen.h:355
ModulationType GetModType(void) const
Get the modulation type of the mode.
Definition: uan-tx-mode.cc:39
double m_rxThreshDb
Receive SINR threshold.
Definition: uan-phy-gen.h:341
void NotifyTxDrop(Ptr< const Packet > packet)
Called when the transducer attempts to transmit a new packet while already transmitting a prior packe...
Definition: uan-phy.cc:126
void NotifyRxEnd(Ptr< const Packet > packet)
Called when a packet is received without error.
Definition: uan-phy.cc:138
EventId m_txEndEvent
Tx event.
Definition: uan-phy-gen.h:354
static UanTxMode CreateMode(UanTxMode::ModulationType type, uint32_t dataRateBps, uint32_t phyRateSps, uint32_t cfHz, uint32_t bwHz, uint32_t constSize, std::string name)
Definition: uan-tx-mode.cc:132
Ptr< UanPhyPer > m_per
Error model.
Definition: uan-phy-gen.h:337
virtual void DoDispose()
Destructor implementation.
Definition: uan-phy-gen.cc:561
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Time m_pktRxArrTime
Packet arrival time.
Definition: uan-phy-gen.h:348
bool m_cleared
Flag when we've been cleared.
Definition: uan-phy-gen.h:352
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:397
double NChooseK(uint32_t n, uint32_t k)
Binomial coefficient.
Definition: uan-phy-gen.cc:408
WHOI Micromodem like FH-FSK model.
Definition: uan-phy-gen.h:227
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:580
virtual double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const
Calculate the SINR value for a packet.
Definition: uan-phy-gen.cc:74
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1375
virtual bool IsStateTx(void)
Definition: uan-phy-gen.cc:914
#define max(a, b)
Definition: 80211b.c:45
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
Definition: uan-phy-gen.cc:984
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
virtual void EnergyRechargeHandler(void)
Handle the energy recharge event.
Definition: uan-phy-gen.cc:675
uint32_t GetDataRateBps(void) const
Get the data rate of the transmit mode.
Definition: uan-tx-mode.cc:45
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxErrLogger
A packet destined for this Phy was received with error.
Definition: uan-phy-gen.h:365
virtual ~UanPhyPerUmodem()
Destructor.
Definition: uan-phy-gen.cc:392
Channel busy.
Definition: uan-phy.h:182
Hold an unsigned integer type.
Definition: uinteger.h:44
double KpToDb(double kp) const
Convert kilopascals to dB re 1 uPa.
Definition: uan-phy.h:92
Ptr< UanNetDevice > m_device
Device hosting this Phy.
Definition: uan-phy-gen.h:335
virtual Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
double m_txPwrDb
Transmit power.
Definition: uan-phy-gen.h:340
The power delay profile returned by propagation models.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:41
double m_thresh
SINR threshold.
Definition: uan-phy-gen.h:60
Calculate packet error probability, based on received SINR and modulation (mode). ...
Definition: uan-phy.h:110
DeviceEnergyModel::ChangeStateCallback m_energyCallback
Energy model callback.
Definition: uan-phy-gen.h:361
double m_ccaThreshDb
CCA busy threshold.
Definition: uan-phy-gen.h:342
void NotifyListenersRxGood(void)
Call UanListener::NotifyRxEndOk on all listeners.
void NotifyListenersCcaEnd(void)
Call UanListener::NotifyCcaEnd on all listeners.
Generic PHY model.
Definition: uan-phy-gen.h:266
std::list< UanPacketArrival > ArrivalList
List of arriving packets overlapping in time.
Ptr< Packet > m_pktRx
Received packet.
Definition: uan-phy-gen.h:344
tuple mac
Definition: third.py:92
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
Definition: uan-phy-gen.cc:937
virtual void NotifyIntChange(void)
Called when there has been a change in the ammount of interference this node is experiencing from oth...
UanPdp m_pktRxPdp
Power delay profile of packet.
Definition: uan-phy-gen.h:349
virtual double CalcSinrDb(Ptr< Packet > pkt, Time arrTime, double rxPowerDb, double ambNoiseDb, UanTxMode mode, UanPdp pdp, const UanTransducer::ArrivalList &arrivalList) const
Calculate the SINR value for a packet.
Definition: uan-phy-gen.cc:126
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
Definition: uan-phy-gen.cc:961
Ptr< UanPhyCalcSinr > m_sinr
SINR calculator.
Definition: uan-phy-gen.h:338
virtual UanTxMode GetMode(uint32_t n)
Get a specific transmission mode.
virtual void SetRxThresholdDb(double thresh)
Set the minimum SINR threshold to receive a packet without errors.
Definition: uan-phy-gen.cc:932
void NotifyRxBegin(Ptr< const Packet > packet)
Called when the Phy begins to receive a packet.
Definition: uan-phy.cc:132
void TxEndEvent()
Event to process end of packet transmission.
Definition: uan-phy-gen.cc:725
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double DbToKp(double db)
Convert dB to kilopascals.
Frequency shift keying.
Definition: uan-tx-mode.h:53
RxOkCallback m_recOkCb
Callback for packets received without error.
Definition: uan-phy-gen.h:331
UanModesList m_modes
List of modes supported by this PHY.
Definition: uan-phy-gen.h:327
uint32_t GetCenterFreqHz(void) const
Get the transmission center frequency.
Definition: uan-tx-mode.cc:57
Interface for PHY event listener.
Definition: uan-phy.h:146
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:222
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
void UpdatePowerConsumption(const State state)
Update energy source with new state.
Definition: uan-phy-gen.cc:642
void NotifyListenersRxStart(void)
Call UanListener::NotifyRxStart on all listeners.
Time GetDelay(void) const
Get the delay time, usually from first arrival of signal.
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)
Calculate the packet error probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:428
State m_state
Phy state.
Definition: uan-phy-gen.h:329
virtual ~UanPhyCalcSinrFhFsk()
Destructor.
Definition: uan-phy-gen.cc:105
void RxEndEvent(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode)
Event to process end of packet reception.
Definition: uan-phy-gen.cc:832
double DbToKp(double db) const
Convert dB re 1 uPa to kilopascals.
Definition: uan-phy.h:82
virtual Ptr< UanNetDevice > GetDevice(void) const
Get the device hosting this Phy.
Definition: uan-phy-gen.cc:967
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
Definition: uan-phy-gen.cc:978
Default SINR calculator for UanPhyGen.
Definition: uan-phy-gen.h:166
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)
Calculate the Packet ERror probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:275
Class used for calculating SINR of packet in UanPhy.
Definition: uan-phy.h:44
Ptr< UanMac > m_mac
MAC layer.
Definition: uan-phy-gen.h:336
Iterator GetEnd(void) const
Get the end of the tap list (one beyond the last entry).
Base class for UAN Phy models.
Definition: uan-phy.h:175
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
uint32_t GetPhyRateSps(void) const
Get the physical signaling rate.
Definition: uan-tx-mode.cc:51
virtual ~UanPhyPerGenDefault()
Destructor.
Definition: uan-phy-gen.cc:217
UanPhyCalcSinrFhFsk()
Constructor.
Definition: uan-phy-gen.cc:101
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_txLogger
A packet was sent from this Phy.
Definition: uan-phy-gen.h:367
virtual bool IsStateIdle(void)
Definition: uan-phy-gen.cc:899
RxErrCallback m_recErrCb
Callback for packets received with errors.
Definition: uan-phy-gen.h:332
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:63
Ptr< UanChannel > m_channel
Attached channel.
Definition: uan-phy-gen.h:333
void NotifyListenersCcaStart(void)
Call UanListener::NotifyCcaStart on all listeners.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
void AppendMode(UanTxMode mode)
Add mode to this list.
Definition: uan-tx-mode.cc:232
Unspecified/undefined.
Definition: uan-tx-mode.h:54
double GetInterferenceDb(Ptr< Packet > pkt)
Calculate interference power from overlapping packet arrivals, in dB.
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:264
void NotifyListenersRxBad(void)
Call UanListener::NotifyRxEndError on all listeners.
Ptr< UanTransducer > m_transducer
Associated transducer.
Definition: uan-phy-gen.h:334
void Nullify(void)
Discard the implementation, set it to null.
Definition: callback.h:1274
UanPhyPerUmodem()
Constructor.
Definition: uan-phy-gen.cc:388
UanPhyPerGenDefault()
Constructor.
Definition: uan-phy-gen.cc:212
Ptr< const AttributeAccessor > MakeUanModesListAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uan-tx-mode.h:314
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:111
UanPhyGen()
Constructor.
Definition: uan-phy-gen.cc:494
uint32_t GetConstellationSize(void) const
Get the number of constellation points in the modulation scheme.
Definition: uan-tx-mode.cc:69
virtual ~UanPhyPerCommonModes()
Destructor.
Definition: uan-phy-gen.cc:258
virtual ~UanPhyCalcSinrDefault()
Destructor.
Definition: uan-phy-gen.cc:57
uint32_t GetBandwidthHz(void) const
Get the transmission signal bandwidth.
Definition: uan-tx-mode.cc:63
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
Definition: uan-phy-gen.cc:685
Default Packet Error Rate calculator for UanPhyGen.
Definition: uan-phy-gen.h:44
Iterator GetBegin(void) const
Get the beginning of the tap vector.
const Tap & GetTap(uint32_t i) const
Get the Tap at the specified delay index.
UanTxMode m_pktRxMode
Packet transmission mode at receiver.
Definition: uan-phy-gen.h:350
ListenerList m_listeners
List of listeners.
Definition: uan-phy-gen.h:330
virtual bool IsStateCcaBusy(void)
Definition: uan-phy-gen.cc:920
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
Definition: uan-phy-gen.cc:747
double m_minRxSinrDb
Minimum receive SINR during packet reception.
Definition: uan-phy-gen.h:346
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
virtual bool IsStateSleep(void)
Definition: uan-phy-gen.cc:894
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
Definition: uan-phy-gen.cc:990
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Definition: uan-phy-gen.cc:883
UanPhyPerCommonModes()
Constructor.
Definition: uan-phy-gen.cc:252
uint32_t GetUid(void) const
Get a unique id for the mode.
Definition: uan-tx-mode.cc:81
double SumTapsNc(Time begin, Time end) const
Compute the non-coherent sum of tap amplitudes between a start and end time.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
static UanModesList GetDefaultModes(void)
Get the default transmission modes.
Definition: uan-phy-gen.cc:569
a unique identifier for an interface.
Definition: type-id.h:58
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)
Calculate the packet error probability based on SINR at the receiver and a tx mode.
Definition: uan-phy-gen.cc:239
Transmitting.
Definition: uan-phy.h:184
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
virtual void Clear(void)
Clear all pointer references.
Definition: uan-phy-gen.cc:519
UanPhyCalcSinrDefault()
Constructor.
Definition: uan-phy-gen.cc:53
ns3::TracedCallback< Ptr< const Packet >, double, UanTxMode > m_rxOkLogger
A packet destined for this Phy was received without error.
Definition: uan-phy-gen.h:363
void NotifyListenersTxStart(Time duration)
Call UanListener::NotifyTxStart on all listeners.
Quadrature amplitude modulation.
Definition: uan-tx-mode.h:52
AttributeValue implementation for UanModesList.
Definition: uan-tx-mode.h:314
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
Definition: uan-phy-gen.cc:927