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  break;
304 
305  // taken from Ronell B. Sicat, "Bit Error Probability Computations for M-ary Quadrature Amplitude Modulation",
306  // EE 242 Digital Communications and Codings, 2009
307  case UanTxMode::QAM:
308  {
309  // generic EbNo
310  EbNo *= mode.GetDataRateBps () / mode.GetBandwidthHz ();
311 
312  double M = (double) mode.GetConstellationSize ();
313 
314  // standard squared quantized QAM, even number of bits per symbol supported
315  int log2sqrtM = (int) ::std::log2 ( sqrt (M));
316 
317  double log2M = ::std::log2 (M);
318 
319  if ((int)log2M % 2)
320  {
321  NS_FATAL_ERROR ("constellation " << M << " not supported");
322  }
323 
324  double sqrtM = ::std::sqrt (M);
325 
326  NS_LOG_DEBUG ("M=" << M << "; log2sqrtM=" << log2sqrtM << "; log2M=" << log2M << "; sqrtM=" << sqrtM);
327 
328  BER = 0.0;
329 
330  // Eq (75)
331  for (int k = 0; k < log2sqrtM; k++)
332  {
333  int sum_items = (int) ((1.0 - ::std::pow ( 2.0, (-1.0) * (double) k)) * ::std::sqrt (M) - 1.0);
334  double pow2k = ::std::pow (2.0, (double) k - 1.0);
335 
336  NS_LOG_DEBUG ("k=" << k << "; sum_items=" << sum_items << "; pow2k=" << pow2k);
337 
338  double PbK = 0;
339 
340  // Eq (74)
341  for (int j = 0; j < sum_items; ++j)
342  {
343  PbK += ::std::pow (-1.0, (double) j * pow2k / sqrtM)
344  * (pow2k - ::std::floor ( (double) (j * pow2k / sqrtM) - 0.5))
345  * erfc ((2.0 * (double)j + 1.0) * ::std::sqrt (3.0 * (log2M * EbNo) / (2.0 * (M - 1.0))));
346 
347  NS_LOG_DEBUG ("j=" << j << "; PbK=" << PbK);
348 
349  }
350  PbK *= 1.0 / sqrtM;
351 
352  BER += PbK;
353 
354  NS_LOG_DEBUG ("k=" << k << "; PbK=" << PbK << "; BER=" << BER);
355  }
356 
357  BER *= 1.0 / (double) log2sqrtM;
358 
359  break;
360  }
361 
362  case UanTxMode::FSK:
363  switch (mode.GetConstellationSize ())
364  {
365  case 2:
366  {
367  BER = 0.5 * erfc (sqrt (0.5 * EbNo));
368  break;
369  }
370 
371  default:
372  NS_FATAL_ERROR ("constellation " << mode.GetConstellationSize () << " not supported");
373  }
374  break;
375 
376  default: // OTHER and error
377  NS_FATAL_ERROR ("Mode " << mode.GetModType () << " not supported");
378  break;
379  }
380 
381  PER = (1.0 - pow (1.0 - BER, (double) pkt->GetSize () * 8.0));
382 
383  NS_LOG_DEBUG ("BER=" << BER << "; PER=" << PER);
384 
385  return PER;
386 }
387 
388 /*************** UanPhyPerUmodem definition *****************/
390 {
391 
392 }
394 {
395 
396 }
397 
399 {
400  static TypeId tid = TypeId ("ns3::UanPhyPerUmodem")
401  .SetParent<UanPhyPer> ()
402  .SetGroupName ("Uan")
403  .AddConstructor<UanPhyPerUmodem> ()
404  ;
405  return tid;
406 }
407 
408 double
409 UanPhyPerUmodem::NChooseK (uint32_t n, uint32_t k)
410 {
411  double result;
412 
413  result = 1.0;
414 
415  for (uint32_t i = std::max (k,n - k) + 1; i <= n; ++i)
416  {
417  result *= i;
418  }
419 
420  for (uint32_t i = 2; i <= std::min (k,n - k); ++i)
421  {
422  result /= i;
423  }
424 
425  return result;
426 }
427 
428 double
430 {
431  uint32_t d[] =
432  { 12, 14, 16, 18, 20, 22, 24, 26, 28 };
433  double Bd[] =
434  {
435  33, 281, 2179, 15035LLU, 105166LLU, 692330LLU, 4580007LLU, 29692894LLU,
436  190453145LLU
437  };
438 
439  // double Rc = 1.0 / 2.0;
440  double ebno = std::pow (10.0, sinr / 10.0);
441  double perror = 1.0 / (2.0 + ebno);
442  double P[9];
443 
444  if ((mode.GetModType () != UanTxMode::FSK) && (mode.GetConstellationSize () != 13))
445  {
446  NS_FATAL_ERROR ("Calculating SINR for unsupported mode type");
447  }
448  if (sinr >= 10)
449  {
450  return 0;
451  }
452  if (sinr <= 6)
453  {
454  return 1;
455  }
456 
457  for (uint32_t r = 0; r < 9; r++)
458  {
459  double sumd = 0;
460  for (uint32_t k = 0; k < d[r]; k++)
461  {
462  sumd = sumd + NChooseK (d[r] - 1 + k, k) * std::pow (1 - perror, (double) k);
463  }
464  P[r] = std::pow (perror, (double) d[r]) * sumd;
465 
466  }
467 
468  double Pb = 0;
469  for (uint32_t r = 0; r < 8; r++)
470  {
471  Pb = Pb + Bd[r] * P[r];
472  }
473 
474  // cout << "Pb = " << Pb << endl;
475  uint32_t bits = pkt->GetSize () * 8;
476 
477  double Ppacket = 1;
478  double temp = NChooseK (bits, 0);
479  temp *= std::pow ( (1 - Pb), (double) bits);
480  Ppacket -= temp;
481  temp = NChooseK (288, 1) * Pb * std::pow ( (1 - Pb), bits - 1.0);
482  Ppacket -= temp;
483 
484  if (Ppacket > 1)
485  {
486  return 1;
487  }
488  else
489  {
490  return Ppacket;
491  }
492 }
493 
494 /*************** UanPhyGen definition *****************/
496  : UanPhy (),
497  m_state (IDLE),
498  m_channel (0),
499  m_transducer (0),
500  m_device (0),
501  m_mac (0),
502  m_txPwrDb (0),
503  m_rxThreshDb (0),
504  m_ccaThreshDb (0),
505  m_pktRx (0),
506  m_pktTx (0),
507  m_cleared (false)
508 {
509  m_pg = CreateObject<UniformRandomVariable> ();
510 
512 }
513 
515 {
516 
517 }
518 
519 void
521 {
522  if (m_cleared)
523  {
524  return;
525  }
526  m_cleared = true;
527  m_listeners.clear ();
528  if (m_channel)
529  {
530  m_channel->Clear ();
531  m_channel = 0;
532  }
533  if (m_transducer)
534  {
535  m_transducer->Clear ();
536  m_transducer = 0;
537  }
538  if (m_device)
539  {
540  m_device->Clear ();
541  m_device = 0;
542  }
543  if (m_mac)
544  {
545  m_mac->Clear ();
546  m_mac = 0;
547  }
548  if (m_per)
549  {
550  m_per->Clear ();
551  m_per = 0;
552  }
553  if (m_sinr)
554  {
555  m_sinr->Clear ();
556  m_sinr = 0;
557  }
558  m_pktRx = 0;
559 }
560 
561 void
563 {
564  Clear ();
567 }
568 
571 {
572  UanModesList l;
573  l.AppendMode (UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 22000, 4000, 13, "FH-FSK")); // micromodem only
574  l.AppendMode (UanTxModeFactory::CreateMode (UanTxMode::PSK, 200, 200, 22000, 4000, 4, "QPSK"));
575  l.AppendMode (UanTxModeFactory::CreateMode (UanTxMode::PSK, 5000, 5000, 25000, 5000, 4, "QPSK")); // micromodem2
576 
577  return l;
578 }
579 
580 TypeId
582 {
583 
584  static TypeId tid = TypeId ("ns3::UanPhyGen")
585  .SetParent<UanPhy> ()
586  .SetGroupName ("Uan")
587  .AddConstructor<UanPhyGen> ()
588  .AddAttribute ("CcaThreshold",
589  "Aggregate energy of incoming signals to move to CCA Busy state dB.",
590  DoubleValue (10),
592  MakeDoubleChecker<double> ())
593  .AddAttribute ("RxThreshold",
594  "Required SNR for signal acquisition in dB.",
595  DoubleValue (10),
597  MakeDoubleChecker<double> ())
598  .AddAttribute ("TxPower",
599  "Transmission output power in dB.",
600  DoubleValue (190),
602  MakeDoubleChecker<double> ())
603  .AddAttribute ("SupportedModes",
604  "List of modes supported by this PHY.",
608  .AddAttribute ("PerModel",
609  "Functor to calculate PER based on SINR and TxMode.",
610  StringValue ("ns3::UanPhyPerGenDefault"),
612  MakePointerChecker<UanPhyPer> ())
613  .AddAttribute ("SinrModel",
614  "Functor to calculate SINR based on pkt arrivals and modes.",
615  StringValue ("ns3::UanPhyCalcSinrDefault"),
617  MakePointerChecker<UanPhyCalcSinr> ())
618  .AddTraceSource ("RxOk",
619  "A packet was received successfully.",
621  "ns3::UanPhy::TracedCallback")
622  .AddTraceSource ("RxError",
623  "A packet was received unsuccessfully.",
625  "ns3::UanPhy::TracedCallback")
626  .AddTraceSource ("Tx",
627  "Packet transmission beginning.",
629  "ns3::UanPhy::TracedCallback")
630  ;
631  return tid;
632 
633 }
634 
635 void
637 {
638  NS_LOG_FUNCTION (this);
639  m_energyCallback = cb;
640 }
641 
642 void
644 {
645  NS_LOG_FUNCTION (this);
646 
647  if (!m_energyCallback.IsNull ())
648  {
649  m_energyCallback (state);
650  }
651 }
652 
653 void
655 {
656  NS_LOG_FUNCTION (this);
657  NS_LOG_DEBUG ("Energy depleted at node " << m_device->GetNode ()->GetId () <<
658  ", stopping rx/tx activities");
659 
660  m_state = DISABLED;
661  if (m_txEndEvent.IsRunning ())
662  {
665  m_pktTx = 0;
666  }
667  if (m_rxEndEvent.IsRunning ())
668  {
671  m_pktRx = 0;
672  }
673 }
674 
675 void
677 {
678  NS_LOG_FUNCTION (this);
679  NS_LOG_DEBUG ("Energy recharged at node " << m_device->GetNode ()->GetId () <<
680  ", restoring rx/tx activities");
681 
682  m_state = IDLE;
683 }
684 
685 void
686 UanPhyGen::SendPacket (Ptr<Packet> pkt, uint32_t modeNum)
687 {
688  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": Transmitting packet");
689  if (m_state == DISABLED)
690  {
691  NS_LOG_DEBUG ("Energy depleted, node cannot transmit any packet. Dropping.");
692  return;
693  }
694 
695  if (m_state == TX)
696  {
697  NS_LOG_DEBUG ("PHY requested to TX while already Transmitting. Dropping packet.");
698  return;
699  }
700  else if (m_state == SLEEP)
701  {
702  NS_LOG_DEBUG ("PHY requested to TX while sleeping. Dropping packet.");
703  return;
704  }
705 
706  UanTxMode txMode = GetMode (modeNum);
707 
708  if (m_pktRx != 0)
709  {
710  m_minRxSinrDb = -1e30;
711  m_pktRx = 0;
712  }
713 
714  m_transducer->Transmit (Ptr<UanPhy> (this), pkt, m_txPwrDb, txMode);
715  m_state = TX;
717  double txdelay = pkt->GetSize () * 8.0 / txMode.GetDataRateBps ();
718  m_pktTx = pkt;
720  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << " notifying listeners");
721  NotifyListenersTxStart (Seconds (txdelay));
722  m_txLogger (pkt, m_txPwrDb, txMode);
723 }
724 
725 void
727 {
728  if (m_state == SLEEP || m_state == DISABLED)
729  {
730  NS_LOG_DEBUG ("Transmission ended but node sleeping or dead");
731  return;
732  }
733 
734  NS_ASSERT (m_state == TX);
736  {
737  m_state = CCABUSY;
739  }
740  else
741  {
742  m_state = IDLE;
743  }
745 }
746 
747 void
749 {
750  m_listeners.push_back (listener);
751 }
752 
753 
754 void
755 UanPhyGen::StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
756 {
757  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": rx power after RX gain = " << rxPowerDb << " dB re uPa");
758 
759  switch (m_state)
760  {
761  case DISABLED:
762  NS_LOG_DEBUG ("Energy depleted, node cannot receive any packet. Dropping.");
763  NotifyRxDrop (pkt); // traced source netanim
764  return;
765  case TX:
766  NotifyRxDrop (pkt); // traced source netanim
767  NS_ASSERT (false);
768  break;
769  case RX:
770  {
771  NS_ASSERT (m_pktRx);
773  m_minRxSinrDb = (newSinrDb < m_minRxSinrDb) ? newSinrDb : m_minRxSinrDb;
774  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": Starting RX in RX mode. SINR of pktRx = " << m_minRxSinrDb);
775  NotifyRxBegin (pkt); // traced source netanim
776  }
777  break;
778 
779  case CCABUSY:
780  case IDLE:
781  {
782  NS_ASSERT (!m_pktRx);
783  bool hasmode = false;
784  for (uint32_t i = 0; i < GetNModes (); i++)
785  {
786  if (txMode.GetUid () == GetMode (i).GetUid ())
787  {
788  hasmode = true;
789  break;
790  }
791  }
792  if (!hasmode)
793  {
794  break;
795  }
796 
797 
798  double newsinr = CalculateSinrDb (pkt, Simulator::Now (), rxPowerDb, txMode, pdp);
799  NS_LOG_DEBUG ("PHY " << m_mac->GetAddress () << ": Starting RX in IDLE mode. SINR = " << newsinr);
800  if (newsinr > m_rxThreshDb)
801  {
802  m_state = RX;
804  NotifyRxBegin (pkt); // traced source netanim
805  m_rxRecvPwrDb = rxPowerDb;
806  m_minRxSinrDb = newsinr;
807  m_pktRx = pkt;
809  m_pktRxMode = txMode;
810  m_pktRxPdp = pdp;
811  double txdelay = pkt->GetSize () * 8.0 / txMode.GetDataRateBps ();
812  m_rxEndEvent = Simulator::Schedule (Seconds (txdelay), &UanPhyGen::RxEndEvent, this, pkt, rxPowerDb, txMode);
814  }
815 
816  }
817  break;
818  case SLEEP:
819  NS_LOG_DEBUG ("Sleep mode. Dropping packet.");
820  NotifyRxDrop (pkt); // traced source netanim
821  break;
822  }
823 
825  {
826  m_state = CCABUSY;
828  }
829 
830 }
831 
832 void
833 UanPhyGen::RxEndEvent (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode)
834 {
835  NS_UNUSED (rxPowerDb);
836  if (pkt != m_pktRx)
837  {
838  return;
839  }
840 
841  if (m_state == DISABLED || m_state == SLEEP)
842  {
843  NS_LOG_DEBUG ("Sleep mode or dead. Dropping packet");
844  m_pktRx = 0;
845  NotifyRxDrop (pkt); // traced source netanim
846  return;
847  }
848 
849  NotifyRxEnd (pkt); // traced source netanim
851  {
852  m_state = CCABUSY;
854  }
855  else
856  {
857  m_state = IDLE;
859  }
860 
861  if (m_pg->GetValue (0, 1) > m_per->CalcPer (m_pktRx, m_minRxSinrDb, txMode))
862  {
863  m_rxOkLogger (pkt, m_minRxSinrDb, txMode);
865  if (!m_recOkCb.IsNull ())
866  {
867  m_recOkCb (pkt, m_minRxSinrDb, txMode);
868  }
869 
870  }
871  else
872  {
873  m_rxErrLogger (pkt, m_minRxSinrDb, txMode);
875  if (!m_recErrCb.IsNull ())
876  {
877  m_recErrCb (pkt, m_minRxSinrDb);
878  }
879  }
880 
881  m_pktRx = 0;
882 }
883 
884 void
886 {
887  m_recOkCb = cb;
888 }
889 
890 void
892 {
893  m_recErrCb = cb;
894 }
895 bool
897 {
898  return m_state == SLEEP;
899 }
900 bool
902 {
903  return m_state == IDLE;
904 }
905 bool
907 {
908  return !IsStateIdle () && !IsStateSleep ();
909 }
910 bool
912 {
913  return m_state == RX;
914 }
915 bool
917 {
918  return m_state == TX;
919 }
920 
921 bool
923 {
924  return m_state == CCABUSY;
925 }
926 
927 
928 void
930 {
931  m_txPwrDb = txpwr;
932 }
933 void
935 {
936  m_rxThreshDb = thresh;
937 }
938 void
940 {
941  m_ccaThreshDb = thresh;
942 }
943 
944 double
946 {
947  return m_txPwrDb;
948 
949 }
950 
951 double
953 {
954  return m_rxThreshDb;
955 }
956 double
958 {
959  return m_ccaThreshDb;
960 }
961 
964 {
965  return m_channel;
966 }
967 
970 {
971  return m_device;
972 }
973 
976 {
977  return m_transducer;
978 }
979 void
981 {
982  m_channel = channel;
983 }
984 
985 void
987 {
988  m_device = device;
989 }
990 
991 void
993 {
994  m_mac = mac;
995 }
996 
997 void
999 {
1000  m_transducer = trans;
1001  m_transducer->AddPhy (this);
1002 }
1003 
1004 void
1006 {
1007  if (sleep )
1008  {
1009  m_state = SLEEP;
1010  if (!m_energyCallback.IsNull ())
1011  {
1013  }
1014  }
1015  else if (m_state == SLEEP)
1016  {
1018  {
1019  m_state = CCABUSY;
1021  }
1022  else
1023  {
1024  m_state = IDLE;
1025  }
1026 
1027  if (!m_energyCallback.IsNull ())
1028  {
1030  }
1031  }
1032 }
1033 
1034 int64_t
1036 {
1037  NS_LOG_FUNCTION (this << stream);
1038  m_pg->SetStream (stream);
1039  return 1;
1040 }
1041 
1042 void
1043 UanPhyGen::NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode)
1044 {
1045  NS_UNUSED (txPowerDb);
1046  if (m_pktRx)
1047  {
1048  m_minRxSinrDb = -1e30;
1049  }
1050 }
1051 
1052 void
1054 {
1056  {
1057  m_state = IDLE;
1059  }
1060 }
1061 
1062 double
1063 UanPhyGen::CalculateSinrDb (Ptr<Packet> pkt, Time arrTime, double rxPowerDb, UanTxMode mode, UanPdp pdp)
1064 {
1065  double noiseDb = m_channel->GetNoiseDbHz ( (double) mode.GetCenterFreqHz () / 1000.0) + 10 * std::log10 (mode.GetBandwidthHz ());
1066  return m_sinr->CalcSinrDb (pkt, arrTime, rxPowerDb, noiseDb, mode, pdp, m_transducer->GetArrivalList ());
1067 }
1068 
1069 double
1071 {
1072 
1073  const UanTransducer::ArrivalList &arrivalList = m_transducer->GetArrivalList ();
1074 
1075  UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
1076 
1077  double interfPower = 0;
1078 
1079  for (; it != arrivalList.end (); it++)
1080  {
1081  if (pkt != it->GetPacket ())
1082  {
1083  interfPower += DbToKp (it->GetRxPowerDb ());
1084  }
1085  }
1086 
1087  return KpToDb (interfPower);
1088 
1089 }
1090 
1091 double
1093 {
1094  return std::pow (10, db / 10.0);
1095 }
1096 double
1098 {
1099  return 10 * std::log10 (kp);
1100 }
1101 
1102 void
1104 {
1105  ListenerList::const_iterator it = m_listeners.begin ();
1106  for (; it != m_listeners.end (); it++)
1107  {
1108  (*it)->NotifyRxStart ();
1109  }
1110 
1111 }
1112 void
1114 {
1115  ListenerList::const_iterator it = m_listeners.begin ();
1116  for (; it != m_listeners.end (); it++)
1117  {
1118  (*it)->NotifyRxEndOk ();
1119  }
1120 }
1121 void
1123 {
1124  ListenerList::const_iterator it = m_listeners.begin ();
1125  for (; it != m_listeners.end (); it++)
1126  {
1127  (*it)->NotifyRxEndError ();
1128  }
1129 }
1130 void
1132 {
1133  ListenerList::const_iterator it = m_listeners.begin ();
1134  for (; it != m_listeners.end (); it++)
1135  {
1136  (*it)->NotifyCcaStart ();
1137  }
1138 }
1139 void
1141 {
1142  ListenerList::const_iterator it = m_listeners.begin ();
1143  for (; it != m_listeners.end (); it++)
1144  {
1145  (*it)->NotifyCcaEnd ();
1146  }
1147 }
1148 
1149 void
1151 {
1152  ListenerList::const_iterator it = m_listeners.begin ();
1153  for (; it != m_listeners.end (); it++)
1154  {
1155  (*it)->NotifyTxStart (duration);
1156  }
1157 }
1158 
1159 uint32_t
1161 {
1162  return m_modes.GetNModes ();
1163 }
1164 
1165 UanTxMode
1167 {
1168  NS_ASSERT (n < m_modes.GetNModes ());
1169 
1170  return m_modes[n];
1171 }
1172 
1175 {
1176  return m_pktRx;
1177 }
1178 
1179 
1180 } // namespace ns3
virtual void NotifyTransStartTx(Ptr< Packet > packet, double txPowerDb, UanTxMode txMode)
Called when a transmission is beginning on the attached transducer.
virtual bool IsStateBusy(void)
Definition: uan-phy-gen.cc:906
virtual Ptr< UanTransducer > GetTransducer(void)
Get the attached transducer.
Definition: uan-phy-gen.cc:975
double SumTapsNc(Time begin, Time end) const
Compute the non-coherent sum of tap amplitudes between a start and end time.
virtual double GetRxThresholdDb(void)
Get the minimum received signal strength required to receive a packet without errors.
Definition: uan-phy-gen.cc:952
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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:911
#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.
Iterator GetBegin(void) const
Get the beginning of the tap vector.
virtual void SetEnergyModelCallback(DeviceEnergyModel::ChangeStateCallback cb)
Set the DeviceEnergyModel callback for UanPhy device.
Definition: uan-phy-gen.cc:636
uint32_t m_hops
Number of hops.
Definition: uan-phy-gen.h:251
Transmitting.
Definition: uan-phy.h:184
#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
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
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:891
#define min(a, b)
Definition: 80211b.c:42
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:654
virtual void SetTransducer(Ptr< UanTransducer > trans)
Attach a transducer to this Phy.
Definition: uan-phy-gen.cc:998
def start()
Definition: core.py:1858
Packet error rate calculation for common tx modes based on UanPhyPerUmodem.
Definition: uan-phy-gen.h:126
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
uint32_t GetDataRateBps(void) const
Get the data rate of the transmit mode.
Definition: uan-tx-mode.cc:45
#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:514
Ptr< UniformRandomVariable > m_pg
Provides uniform random variables.
Definition: uan-phy-gen.h:358
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:204
double m_rxRecvPwrDb
Receiver power.
Definition: uan-phy-gen.h:347
Packet error rate calculation assuming WHOI Micromodem-like PHY (FH-FSK)
Definition: uan-phy-gen.h:74
virtual void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
virtual void StartRxPacket(Ptr< Packet > pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
Packet arriving from channel: i.e.
Definition: uan-phy-gen.cc:755
Channel busy.
Definition: uan-phy.h:182
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
uint32_t GetBandwidthHz(void) const
Get the transmission signal bandwidth.
Definition: uan-tx-mode.cc:63
virtual double GetTxPowerDb(void)
Get the current transmit power, in dB.
Definition: uan-phy-gen.cc:945
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event&#39;s associated function will not be invoked when it expires...
Definition: simulator.cc:290
virtual double GetCcaThresholdDb(void)
Get the CCA threshold signal strength required to detect channel busy.
Definition: uan-phy-gen.cc:957
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
EventId m_rxEndEvent
Rx event.
Definition: uan-phy-gen.h:355
double m_rxThreshDb
Receive SINR threshold.
Definition: uan-phy-gen.h:341
uint32_t GetNModes(void) const
Get the number of modes in this list.
Definition: uan-tx-mode.cc:259
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
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
Unspecified/undefined.
Definition: uan-tx-mode.h:54
virtual void DoDispose()
Destructor implementation.
Definition: uan-phy-gen.cc:562
channel
Definition: third.py:85
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&#39;ve been cleared.
Definition: uan-phy-gen.h:352
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:398
double NChooseK(uint32_t n, uint32_t k)
Binomial coefficient.
Definition: uan-phy-gen.cc:409
Quadrature amplitude modulation.
Definition: uan-tx-mode.h:52
WHOI Micromodem like FH-FSK model.
Definition: uan-phy-gen.h:227
static TypeId GetTypeId(void)
Register this type.
Definition: uan-phy-gen.cc:581
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:1389
virtual bool IsStateTx(void)
Definition: uan-phy-gen.cc:916
#define max(a, b)
Definition: 80211b.c:43
virtual void SetDevice(Ptr< UanNetDevice > device)
Set the device hosting this Phy.
Definition: uan-phy-gen.cc:986
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:676
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:393
Hold an unsigned integer type.
Definition: uinteger.h:44
Ptr< UanNetDevice > m_device
Device hosting this Phy.
Definition: uan-phy-gen.h:335
double m_txPwrDb
Transmit power.
Definition: uan-phy-gen.h:340
The power delay profile returned by propagation models.
Receiving.
Definition: uan-phy.h:183
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:41
mac
Definition: third.py:92
double m_thresh
SINR threshold.
Definition: uan-phy-gen.h:60
Idle state.
Definition: uan-phy.h:181
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
uint32_t GetPhyRateSps(void) const
Get the physical signaling rate.
Definition: uan-tx-mode.cc:51
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
Phase shift keying.
Definition: uan-tx-mode.h:51
double DbToKp(double db) const
Convert dB re 1 uPa to kilopascals.
Definition: uan-phy.h:82
virtual void SetCcaThresholdDb(double thresh)
Set the threshold for detecting channel busy.
Definition: uan-phy-gen.cc:939
Sleeping.
Definition: uan-phy.h:185
virtual void NotifyIntChange(void)
Called when there has been a change in the amount of interference this node is experiencing from othe...
UanPdp m_pktRxPdp
Power delay profile of packet.
Definition: uan-phy-gen.h:349
Ptr< UanPhyCalcSinr > m_sinr
SINR calculator.
Definition: uan-phy-gen.h:338
virtual Ptr< UanChannel > GetChannel(void) const
Get the attached channel.
Definition: uan-phy-gen.cc:963
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:934
Frequency shift keying.
Definition: uan-tx-mode.h:53
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:726
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double DbToKp(double db)
Convert dB to kilopascals.
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
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:643
const Tap & GetTap(uint32_t i) const
Get the Tap at the specified delay index.
void NotifyListenersRxStart(void)
Call UanListener::NotifyRxStart on all listeners.
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:429
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:833
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
virtual void SetChannel(Ptr< UanChannel > channel)
Attach to a channel.
Definition: uan-phy-gen.cc:980
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
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 GetCenterFreqHz(void) const
Get the transmission center frequency.
Definition: uan-tx-mode.cc:57
virtual ~UanPhyPerGenDefault()
Destructor.
Definition: uan-phy-gen.cc:217
double KpToDb(double kp) const
Convert kilopascals to dB re 1 uPa.
Definition: uan-phy.h:92
UanPhyCalcSinrFhFsk()
Constructor.
Definition: uan-phy-gen.cc:101
uint32_t GetUid(void) const
Get a unique id for the mode.
Definition: uan-tx-mode.cc:81
Time GetDelay(void) const
Get the delay time, usually from first arrival of signal.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:264
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:901
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:272
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:1062
void AppendMode(UanTxMode mode)
Add mode to this list.
Definition: uan-tx-mode.cc:232
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
double GetInterferenceDb(Ptr< Packet > pkt)
Calculate interference power from overlapping packet arrivals, in dB.
virtual Ptr< UanNetDevice > GetDevice(void) const
Get the device hosting this Phy.
Definition: uan-phy-gen.cc:969
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:389
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:495
virtual ~UanPhyPerCommonModes()
Destructor.
Definition: uan-phy-gen.cc:258
virtual Ptr< Packet > GetPacketRx(void) const
Get the packet currently being received.
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 ~UanPhyCalcSinrDefault()
Destructor.
Definition: uan-phy-gen.cc:57
Iterator GetEnd(void) const
Get the end of the tap list (one beyond the last entry).
virtual void SendPacket(Ptr< Packet > pkt, uint32_t modeNum)
Send a packet using a specific transmission mode.
Definition: uan-phy-gen.cc:686
Default Packet Error Rate calculator for UanPhyGen.
Definition: uan-phy-gen.h:44
double SumTapsFromMaxNc(Time delay, Time duration) const
Compute the non-coherent sum of tap amplitudes starting after a delay from the maximum amplitude for ...
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:922
virtual void RegisterListener(UanPhyListener *listener)
Register a UanPhyListener to be notified of common UanPhy events.
Definition: uan-phy-gen.cc:748
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
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 &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
virtual bool IsStateSleep(void)
Definition: uan-phy-gen.cc:896
virtual void SetMac(Ptr< UanMac > mac)
Set the MAC forwarding messages to this Phy.
Definition: uan-phy-gen.cc:992
virtual void SetReceiveOkCallback(RxOkCallback cb)
Set the callback to be used when a packet is received without error.
Definition: uan-phy-gen.cc:885
UanPhyPerCommonModes()
Constructor.
Definition: uan-phy-gen.cc:252
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:570
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
uint32_t GetConstellationSize(void) const
Get the number of constellation points in the modulation scheme.
Definition: uan-tx-mode.cc:69
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
virtual void Clear(void)
Clear all pointer references.
Definition: uan-phy-gen.cc:520
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.
AttributeValue implementation for UanModesList.
Definition: uan-tx-mode.h:314
virtual void SetTxPowerDb(double txpwr)
Set the transmit power.
Definition: uan-phy-gen.cc:929
ModulationType GetModType(void) const
Get the modulation type of the mode.
Definition: uan-tx-mode.cc:39