A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lr-wpan-phy.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 The Boeing Company
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:
19  * Gary Pei <guangyu.pei@boeing.com>
20  * Sascha Alexander Jopen <jopen@cs.uni-bonn.de>
21  */
22 #include "lr-wpan-phy.h"
23 #include "lr-wpan-lqi-tag.h"
26 #include "lr-wpan-error-model.h"
27 #include "lr-wpan-net-device.h"
28 #include <ns3/log.h>
29 #include <ns3/abort.h>
30 #include <ns3/simulator.h>
31 #include <ns3/spectrum-value.h>
32 #include <ns3/antenna-model.h>
33 #include <ns3/mobility-model.h>
34 #include <ns3/spectrum-channel.h>
35 #include <ns3/packet.h>
36 #include <ns3/packet-burst.h>
37 #include <ns3/net-device.h>
38 #include <ns3/random-variable-stream.h>
39 #include <ns3/double.h>
40 
41 NS_LOG_COMPONENT_DEFINE ("LrWpanPhy");
42 
43 namespace ns3 {
44 
45 NS_OBJECT_ENSURE_REGISTERED (LrWpanPhy);
46 
47 // Table 22 in section 6.4.1 of ieee802.15.4
48 const uint32_t LrWpanPhy::aMaxPhyPacketSize = 127; // max PSDU in octets
49 const uint32_t LrWpanPhy::aTurnaroundTime = 12; // RX-to-TX or TX-to-RX in symbol periods
50 
51 // IEEE802.15.4-2006 Table 2 in section 6.1.2 (kb/s and ksymbol/s)
52 // The index follows LrWpanPhyOption
53 const LrWpanPhyDataAndSymbolRates
54 LrWpanPhy::dataSymbolRates[7] = { { 20.0, 20.0},
55  { 40.0, 40.0},
56  { 250.0, 12.5},
57  { 250.0, 50.0},
58  { 100.0, 25.0},
59  { 250.0, 62.5},
60  { 250.0, 62.5}};
61 // IEEE802.15.4-2006 Table 19 and Table 20 in section 6.3.
62 // The PHR is 1 octet and it follows phySymbolsPerOctet in Table 23
63 // The index follows LrWpanPhyOption
64 const LrWpanPhyPpduHeaderSymbolNumber
65 LrWpanPhy::ppduHeaderSymbolNumbers[7] = { { 32.0, 8.0, 8.0},
66  { 32.0, 8.0, 8.0},
67  { 2.0, 1.0, 0.4},
68  { 6.0, 1.0, 1.6},
69  { 8.0, 2.0, 2.0},
70  { 8.0, 2.0, 2.0},
71  { 8.0, 2.0, 2.0}};
72 
73 TypeId
75 {
76  static TypeId tid = TypeId ("ns3::LrWpanPhy")
77  .SetParent<Object> ()
78  .AddConstructor<LrWpanPhy> ()
79  .AddTraceSource ("TrxState",
80  "The state of the transceiver",
82  .AddTraceSource ("PhyTxBegin",
83  "Trace source indicating a packet has begun transmitting over the channel medium",
85  .AddTraceSource ("PhyTxEnd",
86  "Trace source indicating a packet has been completely transmitted over the channel.",
88  .AddTraceSource ("PhyTxDrop",
89  "Trace source indicating a packet has been dropped by the device during transmission",
91  .AddTraceSource ("PhyRxBegin",
92  "Trace source indicating a packet has begun being received from the channel medium by the device",
94  .AddTraceSource ("PhyRxEnd",
95  "Trace source indicating a packet has been completely received from the channel medium by the device",
97  .AddTraceSource ("PhyRxDrop",
98  "Trace source indicating a packet has been dropped by the device during reception",
100  ;
101  return tid;
102 }
103 
105  : m_edRequest (),
106  m_setTRXState ()
107 {
110 
111  // default PHY PIB attributes
115  for (uint32_t i = 0; i < 32; i++)
116  {
118  }
120 
121  SetMyPhyOption ();
122 
123  m_edPower.averagePower = 0.0;
124  m_edPower.lastUpdate = Seconds (0.0);
125  m_edPower.measurementLength = Seconds (0.0);
126 
127  // default -110 dBm in W for 2.4 GHz
128  m_rxSensitivity = pow (10.0, -106.58 / 10.0) / 1000.0;
129  LrWpanSpectrumValueHelper psdHelper;
133  m_signal = Create<LrWpanInterferenceHelper> (m_noise->GetSpectrumModel ());
134  m_rxLastUpdate = Seconds (0);
135  Ptr<Packet> none_packet = 0;
136  Ptr<LrWpanSpectrumSignalParameters> none_params = 0;
137  m_currentRxPacket = std::make_pair (none_params, true);
138  m_currentTxPacket = std::make_pair (none_packet, true);
139  m_errorModel = 0;
140 
141  m_random = CreateObject<UniformRandomVariable> ();
142  m_random->SetAttribute ("Min", DoubleValue (0.0));
143  m_random->SetAttribute ("Max", DoubleValue (1.0));
144 
145 
147 }
148 
150 {
151 }
152 
153 void
155 {
156  NS_LOG_FUNCTION (this);
157 
158  // Cancel pending transceiver state change, if one is in progress.
162 
163  m_mobility = 0;
164  m_device = 0;
165  m_channel = 0;
166  m_txPsd = 0;
167  m_noise = 0;
168  m_signal = 0;
169  m_errorModel = 0;
170  m_pdDataIndicationCallback = MakeNullCallback< void, uint32_t, Ptr<Packet>, uint8_t > ();
171  m_pdDataConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration > ();
172  m_plmeCcaConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration > ();
173  m_plmeEdConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration,uint8_t > ();
174  m_plmeGetAttributeConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier, LrWpanPhyPibAttributes* > ();
175  m_plmeSetTRXStateConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration > ();
176  m_plmeSetAttributeConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier > ();
177 
179 }
180 
183 {
184  NS_LOG_FUNCTION (this);
185  return m_device;
186 }
187 
188 
191 {
192  NS_LOG_FUNCTION (this);
193  return m_mobility;
194 }
195 
196 
197 void
199 {
200  NS_LOG_FUNCTION (this << d);
201  m_device = d;
202 }
203 
204 
205 void
207 {
208  NS_LOG_FUNCTION (this << m);
209  m_mobility = m;
210 }
211 
212 
213 void
215 {
216  NS_LOG_FUNCTION (this << c);
217  m_channel = c;
218 }
219 
220 
223 {
224  NS_LOG_FUNCTION (this);
225  return m_channel;
226 }
227 
228 
231 {
232  NS_LOG_FUNCTION (this);
233  if (m_txPsd)
234  {
235  return m_txPsd->GetSpectrumModel ();
236  }
237  else
238  {
239  return 0;
240  }
241 }
242 
245 {
246  NS_LOG_FUNCTION (this);
247  return m_antenna;
248 }
249 
250 void
252 {
253  NS_LOG_FUNCTION (this << a);
254  m_antenna = a;
255 }
256 
257 void
259 {
260  NS_LOG_FUNCTION (this << spectrumRxParams);
261  LrWpanSpectrumValueHelper psdHelper;
262 
263 
264  Ptr<LrWpanSpectrumSignalParameters> lrWpanRxParams = DynamicCast<LrWpanSpectrumSignalParameters> (spectrumRxParams);
265  NS_ASSERT (lrWpanRxParams != 0);
266  Ptr<Packet> p = (lrWpanRxParams->packetBurst->GetPackets ()).front ();
267  NS_ASSERT (p != 0);
268 
269  if (!m_edRequest.IsExpired ())
270  {
271  // Update the average receive power during ED.
272  Time now = Simulator::Now ();
274  m_edPower.lastUpdate = now;
275  }
276 
277  // Prevent PHY from receiving another packet while switching the transceiver state.
279  {
280  // The specification doesn't seem to refer to BUSY_RX, but vendor
281  // data sheets suggest that this is a substate of the RX_ON state
282  // that is entered after preamble detection when the digital receiver
283  // is enabled. Here, for now, we use BUSY_RX to mark the period between
284  // StartRx() and EndRx() states.
285 
286  // We are going to BUSY_RX state when receiving the first bit of an SHR,
287  // as opposed to real receivers, which should go to this state only after
288  // successfully receiving the SHR.
289 
290  // If synchronizing to the packet is possible, change to BUSY_RX state,
291  // otherwise drop the packet and stay in RX state. The actual synchronization
292  // is not modeled.
293 
294  // Add any incoming packet to the current interference before checking the
295  // SINR.
296  NS_LOG_DEBUG (this << " receiving packet with power: " << 10 * log10(LrWpanSpectrumValueHelper::TotalAvgPower (lrWpanRxParams->psd)) + 30 << "dBm");
297  m_signal->AddSignal (lrWpanRxParams->psd);
298  Ptr<SpectrumValue> interferenceAndNoise = m_signal->GetSignalPsd ();
299  *interferenceAndNoise -= *lrWpanRxParams->psd;
300  *interferenceAndNoise += *m_noise;
301  double sinr = LrWpanSpectrumValueHelper::TotalAvgPower (lrWpanRxParams->psd) / LrWpanSpectrumValueHelper::TotalAvgPower (interferenceAndNoise);
302 
303  // Std. 802.15.4-2006, appendix E, Figure E.2
304  // At SNR < -5 the BER is less than 10e-1.
305  // It's useless to even *try* to decode the packet.
306  if (10 * log10 (sinr) > -5)
307  {
309  m_currentRxPacket = std::make_pair (lrWpanRxParams, false);
310  m_phyRxBeginTrace (p);
311 
313  }
314  else
315  {
316  m_phyRxDropTrace (p);
317  }
318  }
320  {
321  // Drop the new packet.
322  NS_LOG_DEBUG (this << " packet collision");
323  m_phyRxDropTrace (p);
324 
325  // Check if we correctly received the old packet up to now.
327 
328  // Add the incoming packet to the current interference after we have
329  // checked for successfull reception of the current packet for the time
330  // before the additional interference.
331  m_signal->AddSignal (lrWpanRxParams->psd);
332  }
333  else
334  {
335  // Simply drop the packet.
336  NS_LOG_DEBUG (this << " transceiver not in RX state");
337  m_phyRxDropTrace (p);
338 
339  // Add the signal power to the interference, anyway.
340  m_signal->AddSignal (lrWpanRxParams->psd);
341  }
342 
343  // Update peak power if CCA is in progress.
344  if (!m_ccaRequest.IsExpired ())
345  {
346  double power = LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd ());
347  if (m_ccaPeakPower < power)
348  {
349  m_ccaPeakPower = power;
350  }
351  }
352 
353  // Always call EndRx to update the interference.
354  // \todo: Do we need to keep track of these events to unschedule them when disposing off the PHY?
355  Simulator::Schedule (lrWpanRxParams->duration, &LrWpanPhy::EndRx, this, lrWpanRxParams);
356 }
357 
358 void
360 {
361  // Calculate whether packet was lost.
362  LrWpanSpectrumValueHelper psdHelper;
364 
365  // We are currently receiving a packet.
367  {
368  // NS_ASSERT (currentRxParams && !m_currentRxPacket.second);
369 
370  Ptr<Packet> currentPacket = currentRxParams->packetBurst->GetPackets ().front ();
371  if (m_errorModel != 0)
372  {
373  // How many bits did we receive since the last calculation?
374  double t = (Simulator::Now () - m_rxLastUpdate).ToDouble (Time::MS);
375  uint32_t chunkSize = ceil (t * (GetDataOrSymbolRate (true) / 1000));
376  Ptr<SpectrumValue> interferenceAndNoise = m_signal->GetSignalPsd ();
377  *interferenceAndNoise -= *currentRxParams->psd;
378  *interferenceAndNoise += *m_noise;
379  double sinr = LrWpanSpectrumValueHelper::TotalAvgPower (currentRxParams->psd) / LrWpanSpectrumValueHelper::TotalAvgPower (interferenceAndNoise);
380  double per = 1.0 - m_errorModel->GetChunkSuccessRate (sinr, chunkSize);
381 
382  // The LQI is the total packet success rate scaled to 0-255.
383  // If not already set, initialize to 255.
384  LrWpanLqiTag tag (std::numeric_limits<uint8_t>::max ());
385  currentPacket->PeekPacketTag (tag);
386  uint8_t lqi = tag.Get ();
387  tag.Set (lqi - (per * lqi));
388  currentPacket->ReplacePacketTag (tag);
389 
390  if (m_random->GetValue () < per)
391  {
392  // The packet was destroyed, drop the packet after reception.
393  m_currentRxPacket.second = true;
394  }
395  }
396  else
397  {
398  NS_LOG_WARN ("Missing ErrorModel");
399  }
400  }
402 }
403 
404 void
406 {
407  NS_LOG_FUNCTION (this);
408  NS_ASSERT (params != 0);
409 
410  if (!m_edRequest.IsExpired ())
411  {
412  // Update the average receive power during ED.
413  Time now = Simulator::Now ();
415  m_edPower.lastUpdate = now;
416  }
417 
419 
420  // Update the interference.
421  m_signal->RemoveSignal (params->psd);
422 
423  // If this is the end of the currently received packet, check if reception was successfull.
425  if (currentRxParams == params)
426  {
427  Ptr<Packet> currentPacket = currentRxParams->packetBurst->GetPackets ().front ();
428  NS_ASSERT (currentPacket != 0);
429 
430  // If there is no error model attached to the PHY, we always report the maximum LQI value.
431  LrWpanLqiTag tag (std::numeric_limits<uint8_t>::max ());
432  currentPacket->PeekPacketTag (tag);
433  m_phyRxEndTrace (currentPacket, tag.Get ());
434 
435  if (!m_currentRxPacket.second)
436  {
437  // The packet was successfully received, push it up the stack.
439  {
440  m_pdDataIndicationCallback (currentPacket->GetSize (), currentPacket, tag.Get ());
441  }
442  }
443  else
444  {
445  // The packet was destroyed, drop it.
446  m_phyRxDropTrace (currentPacket);
447  }
449  m_currentRxPacket = std::make_pair (none, true);
450 
451  // We may be waiting to apply a pending state change.
453  {
454  // Only change the state immediately, if the transceiver is not already
455  // switching the state.
456  if (!m_setTRXState.IsRunning ())
457  {
458  NS_LOG_LOGIC ("Apply pending state change to " << m_trxStatePending);
462  {
464  }
465  }
466  }
467  else
468  {
470  }
471  }
472 }
473 
474 void
475 LrWpanPhy::PdDataRequest (const uint32_t psduLength, Ptr<Packet> p)
476 {
477  NS_LOG_FUNCTION (this << psduLength << p);
478 
479  if (psduLength > aMaxPhyPacketSize)
480  {
482  {
484  }
485  NS_LOG_DEBUG ("Drop packet because psduLength too long: " << psduLength);
486  return;
487  }
488 
489  // Prevent PHY from sending a packet while switching the transceiver state.
490  if (!m_setTRXState.IsRunning ())
491  {
493  {
494  //send down
496 
497  // Remove a possible LQI tag from a previous transmission of the packet.
498  LrWpanLqiTag lqiTag;
499  p->RemovePacketTag (lqiTag);
500 
501  Ptr<LrWpanSpectrumSignalParameters> txParams = Create<LrWpanSpectrumSignalParameters> ();
502  txParams->duration = CalculateTxTime (p);
503  txParams->txPhy = GetObject<SpectrumPhy> ();
504  txParams->psd = m_txPsd;
505  txParams->txAntenna = m_antenna;
506  Ptr<PacketBurst> pb = CreateObject<PacketBurst> ();
507  pb->AddPacket (p);
508  txParams->packetBurst = pb;
509  m_channel->StartTx (txParams);
510  m_pdDataRequest = Simulator::Schedule (txParams->duration, &LrWpanPhy::EndTx, this);
512  m_phyTxBeginTrace (p);
513  m_currentTxPacket.first = p;
514  m_currentTxPacket.second = false;
515  return;
516  }
517  else if ((m_trxState == IEEE_802_15_4_PHY_RX_ON)
520  {
522  {
524  }
525  // Drop packet, hit PhyTxDrop trace
526  m_phyTxDropTrace (p);
527  return;
528  }
529  else
530  {
531  NS_FATAL_ERROR ("This should be unreachable, or else state " << m_trxState << " should be added as a case");
532  }
533  }
534  else
535  {
536  // TODO: This error code is not covered by the standard.
537  // What is the correct behavior in this case?
539  {
541  }
542  // Drop packet, hit PhyTxDrop trace
543  m_phyTxDropTrace (p);
544  return;
545  }
546 }
547 
548 void
550 {
551  NS_LOG_FUNCTION (this);
552 
554  {
555  m_ccaPeakPower = 0.0;
556  Time ccaTime = Seconds (8.0 / GetDataOrSymbolRate (false));
558  }
559  else
560  {
562  {
564  {
566  }
567  else
568  {
570  }
571  }
572  }
573 }
574 
575 void
577 {
578  NS_LOG_FUNCTION (this);
580  {
581  // Average over the powers of all signals received until EndEd()
584  m_edPower.measurementLength = Seconds (8.0 / GetDataOrSymbolRate (false));
586  }
587  else
588  {
591  {
592  result = IEEE_802_15_4_PHY_TX_ON;
593  }
594 
596  {
597  m_plmeEdConfirmCallback (result, 0);
598  }
599  }
600 }
601 
602 void
604 {
605  NS_LOG_FUNCTION (this << id);
606  LrWpanPhyEnumeration status;
607 
608  switch (id)
609  {
610  case phyCurrentChannel:
612  case phyTransmitPower:
613  case phyCCAMode:
614  case phyCurrentPage:
615  case phyMaxFrameDuration:
616  case phySHRDuration:
617  case phySymbolsPerOctet:
618  {
619  status = IEEE_802_15_4_PHY_SUCCESS;
620  break;
621  }
622  default:
623  {
625  break;
626  }
627  }
629  {
630  LrWpanPhyPibAttributes retValue;
631  memcpy (&retValue, &m_phyPIBAttributes, sizeof(LrWpanPhyPibAttributes));
632  m_plmeGetAttributeConfirmCallback (status,id,&retValue);
633  }
634 }
635 
636 // Section 6.2.2.7.3
637 void
639 {
640  NS_LOG_FUNCTION (this << state);
641 
642  // Check valid states (Table 14)
644  && (state != IEEE_802_15_4_PHY_TRX_OFF)
645  && (state != IEEE_802_15_4_PHY_FORCE_TRX_OFF)
646  && (state != IEEE_802_15_4_PHY_TX_ON) );
647 
648  NS_LOG_LOGIC ("Trying to set m_trxState from " << m_trxState << " to " << state);
649  // this method always overrides previous state setting attempts
650  if (!m_setTRXState.IsExpired ())
651  {
652  if (m_trxStatePending == state)
653  {
654  // Simply wait for the ongoing state switch.
655  return;
656  }
657  else
658  {
659  NS_LOG_DEBUG ("Cancel m_setTRXState");
660  // Keep the transceiver state as the old state before the switching attempt.
662  }
663  }
665  {
667  }
668 
669  if (state == m_trxState)
670  {
672  {
674  }
675  return;
676  }
677 
678  if ( ((state == IEEE_802_15_4_PHY_RX_ON)
679  || (state == IEEE_802_15_4_PHY_TRX_OFF))
681  {
682  NS_LOG_DEBUG ("Phy is busy; setting state pending to " << state);
683  m_trxStatePending = state;
684  return; // Send PlmeSetTRXStateConfirm later
685  }
686 
687  // specification talks about being in RX_ON and having received
688  // a valid SFD. Here, we are not modelling at that level of
689  // granularity, so we just test for BUSY_RX state (any part of
690  // a packet being actively received)
691  if (state == IEEE_802_15_4_PHY_TRX_OFF)
692  {
693  CancelEd (state);
694 
696  && (m_currentRxPacket.first) && (!m_currentRxPacket.second))
697  {
698  NS_LOG_DEBUG ("Receiver has valid SFD; defer state change");
699  m_trxStatePending = state;
700  return; // Send PlmeSetTRXStateConfirm later
701  }
703  {
706  {
708  }
709  return;
710  }
711  }
712 
713  if (state == IEEE_802_15_4_PHY_TX_ON)
714  {
715  CancelEd (state);
716 
717  NS_LOG_DEBUG ("turn on PHY_TX_ON");
719  {
720  if (m_currentRxPacket.first)
721  {
722  //terminate reception if needed
723  //incomplete reception -- force packet discard
724  NS_LOG_DEBUG ("force TX_ON, terminate reception");
725  m_currentRxPacket.second = true;
726  }
727 
728  // If CCA is in progress, cancel CCA and return BUSY.
729  if (!m_ccaRequest.IsExpired ())
730  {
731  m_ccaRequest.Cancel ();
733  {
735  }
736  }
737 
739 
740  // Delay for turnaround time
741  // TODO: Does it also take aTurnaroundTime to switch the transceiver state,
742  // even when the receiver is not busy? (6.9.2)
743  Time setTime = Seconds ( (double) aTurnaroundTime / GetDataOrSymbolRate (false));
745  return;
746  }
748  {
749  // We do NOT change the transceiver state here. We only report that
750  // the transceiver is already in TX_ON state.
752  {
754  }
755  return;
756  }
758  {
761  {
763  }
764  return;
765  }
766  }
767 
768  if (state == IEEE_802_15_4_PHY_FORCE_TRX_OFF)
769  {
771  {
772  NS_LOG_DEBUG ("force TRX_OFF, was already off");
773  }
774  else
775  {
776  NS_LOG_DEBUG ("force TRX_OFF, SUCCESS");
777  if (m_currentRxPacket.first)
778  { //terminate reception if needed
779  //incomplete reception -- force packet discard
780  NS_LOG_DEBUG ("force TRX_OFF, terminate reception");
781  m_currentRxPacket.second = true;
782  }
784  {
785  NS_LOG_DEBUG ("force TRX_OFF, terminate transmission");
786  m_currentTxPacket.second = true;
787  }
789  // Clear any other state
791  }
793  {
795  }
796  return;
797  }
798 
799  if (state == IEEE_802_15_4_PHY_RX_ON)
800  {
802  {
803  // Turnaround delay
804  // TODO: Does it really take aTurnaroundTime to switch the transceiver state,
805  // even when the transmitter is not busy? (6.9.1)
807 
808  Time setTime = Seconds ( (double) aTurnaroundTime / GetDataOrSymbolRate (false));
810  return;
811  }
813  {
815  {
817  }
818  return;
819  }
820  }
821 
822  NS_FATAL_ERROR ("Unexpected transition from state " << m_trxState << " to state " << state);
823 }
824 
825 bool
827 {
828  NS_LOG_FUNCTION (this << channel);
829  bool retValue = false;
830 
831  for (uint32_t i = 0; i < 32; i++)
832  {
833  if ((m_phyPIBAttributes.phyChannelsSupported[i] & (1 << channel)) != 0)
834  {
835  retValue = true;
836  break;
837  }
838  }
839 
840  return retValue;
841 }
842 
843 void
845  LrWpanPhyPibAttributes* attribute)
846 {
847  NS_LOG_FUNCTION (this << id << attribute);
848  NS_ASSERT (attribute);
850 
851  switch (id)
852  {
853  case phyCurrentChannel:
854  {
855  if (!ChannelSupported (attribute->phyCurrentChannel))
856  {
858  }
860  {
861  // Cancel a pending tranceiver state change.
862  // Switch off the transceiver.
863  // TODO: Is switching off the transceiver the right choice?
866  {
870  {
872  }
873  }
874 
875  // Any packet in transmission or reception will be corrupted.
876  if (m_currentRxPacket.first)
877  {
878  m_currentRxPacket.second = true;
879  }
880  if (PhyIsBusy ())
881  {
882  m_currentTxPacket.second = true;
884  m_currentTxPacket.first = 0;
886  {
888  }
889  }
891  }
892  break;
893  }
895  { // only the first element is considered in the array
896  if ((attribute->phyChannelsSupported[0] & 0xf8000000) != 0)
897  { //5 MSBs reserved
899  }
900  else
901  {
903  }
904  break;
905  }
906  case phyTransmitPower:
907  {
908  if (attribute->phyTransmitPower > 0xbf)
909  {
911  }
912  else
913  {
915  LrWpanSpectrumValueHelper psdHelper;
917  }
918  break;
919  }
920  case phyCCAMode:
921  {
922  if ((attribute->phyCCAMode < 1) || (attribute->phyCCAMode > 3))
923  {
925  }
926  else
927  {
929  }
930  break;
931  }
932  default:
933  {
935  break;
936  }
937  }
938 
940  {
942  }
943 }
944 
945 void
947 {
948  NS_LOG_FUNCTION (this);
950 }
951 
952 void
954 {
955  NS_LOG_FUNCTION (this);
957 }
958 
959 void
961 {
962  NS_LOG_FUNCTION (this);
964 }
965 
966 void
968 {
969  NS_LOG_FUNCTION (this);
971 }
972 
973 void
975 {
976  NS_LOG_FUNCTION (this);
978 }
979 
980 void
982 {
983  NS_LOG_FUNCTION (this);
985 }
986 
987 void
989 {
990  NS_LOG_FUNCTION (this);
992 }
993 
994 void
996 {
997  NS_LOG_LOGIC (this << " state: " << m_trxState << " -> " << newState);
999  m_trxState = newState;
1000 }
1001 
1002 bool
1004 {
1005  NS_LOG_FUNCTION (this << m_trxState);
1009 }
1010 
1011 void
1013 {
1014  NS_LOG_FUNCTION (this);
1016 
1017  if (!m_edRequest.IsExpired ())
1018  {
1019  m_edRequest.Cancel ();
1021  {
1022  m_plmeEdConfirmCallback (state, 0);
1023  }
1024  }
1025 }
1026 
1027 void
1029 {
1030  NS_LOG_FUNCTION (this);
1031 
1033 
1034  uint8_t energyLevel;
1035 
1036  // Per IEEE802.15.4-2006 sec 6.9.7
1037  double ratio = m_edPower.averagePower / m_rxSensitivity;
1038  ratio = 10.0 * log10 (ratio);
1039  if (ratio <= 10.0)
1040  { // less than 10 dB
1041  energyLevel = 0;
1042  }
1043  else if (ratio >= 40.0)
1044  { // less than 40 dB
1045  energyLevel = 255;
1046  }
1047  else
1048  {
1049  // in-between with linear increase per sec 6.9.7
1050  energyLevel = static_cast<uint8_t> (((ratio - 10.0) / 30.0) * 255.0);
1051  }
1052 
1054  {
1056  }
1057 }
1058 
1059 void
1061 {
1062  NS_LOG_FUNCTION (this);
1064 
1065  // Update peak power.
1066  double power = LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd ());
1067  if (m_ccaPeakPower < power)
1068  {
1069  m_ccaPeakPower = power;
1070  }
1071 
1072  if (PhyIsBusy ())
1073  {
1074  sensedChannelState = IEEE_802_15_4_PHY_BUSY;
1075  }
1076  else if (m_phyPIBAttributes.phyCCAMode == 1)
1077  { //sec 6.9.9 ED detection
1078  // -- ED threshold at most 10 dB above receiver sensitivity.
1079  if (10 * log10 (m_ccaPeakPower / m_rxSensitivity) >= 10.0)
1080  {
1081  sensedChannelState = IEEE_802_15_4_PHY_BUSY;
1082  }
1083  else
1084  {
1085  sensedChannelState = IEEE_802_15_4_PHY_IDLE;
1086  }
1087  }
1088  else if (m_phyPIBAttributes.phyCCAMode == 2)
1089  {
1090  //sec 6.9.9 carrier sense only
1092  {
1093  // We currently do not model PPDU reception in detail. Instead we model
1094  // packet reception starting with the first bit of the preamble.
1095  // Therefore, this code will never be reached, as PhyIsBusy() would
1096  // already lead to a channel busy condition.
1097  // TODO: Change this, if we also model preamble and SFD detection.
1098  sensedChannelState = IEEE_802_15_4_PHY_BUSY;
1099  }
1100  else
1101  {
1102  sensedChannelState = IEEE_802_15_4_PHY_IDLE;
1103  }
1104  }
1105  else if (m_phyPIBAttributes.phyCCAMode == 3)
1106  { //sect 6.9.9 both
1107  if ((10 * log10 (m_ccaPeakPower / m_rxSensitivity) >= 10.0)
1109  {
1110  // Again, this code will never be reached, if we are already receiving
1111  // a packet, as PhyIsBusy() would already lead to a channel busy condition.
1112  // TODO: Change this, if we also model preamble and SFD detection.
1113  sensedChannelState = IEEE_802_15_4_PHY_BUSY;
1114  }
1115  else
1116  {
1117  sensedChannelState = IEEE_802_15_4_PHY_IDLE;
1118  }
1119  }
1120  else
1121  {
1122  NS_ASSERT_MSG (false, "Invalid CCA mode");
1123  }
1124 
1125  NS_LOG_LOGIC (this << "channel sensed state: " << sensedChannelState);
1126 
1128  {
1129  m_plmeCcaConfirmCallback (sensedChannelState);
1130  }
1131 }
1132 
1133 void
1135 {
1136  NS_LOG_FUNCTION (this);
1137 
1141 
1143  {
1145  }
1146 }
1147 
1148 void
1150 {
1151  NS_LOG_FUNCTION (this);
1152 
1154 
1155  if (m_currentTxPacket.second == false)
1156  {
1157  NS_LOG_DEBUG ("Packet successfully transmitted");
1160  {
1162  }
1163  }
1164  else
1165  {
1166  NS_LOG_DEBUG ("Packet transmission aborted");
1169  {
1170  // See if this is ever entered in another state
1173  }
1174  }
1175  m_currentTxPacket.first = 0;
1176  m_currentTxPacket.second = false;
1177 
1178 
1179  // We may be waiting to apply a pending state change.
1181  {
1182  // Only change the state immediately, if the transceiver is not already
1183  // switching the state.
1184  if (!m_setTRXState.IsRunning ())
1185  {
1186  NS_LOG_LOGIC ("Apply pending state change to " << m_trxStatePending);
1190  {
1192  }
1193  }
1194  }
1195  else
1196  {
1198  {
1200  }
1201  }
1202 }
1203 
1204 Time
1206 {
1207  NS_LOG_FUNCTION (this << packet);
1208 
1209  bool isData = true;
1210  Time txTime = GetPpduHeaderTxTime ();
1211 
1212  txTime += Seconds (packet->GetSize () * 8.0 / GetDataOrSymbolRate (isData));
1213 
1214  return txTime;
1215 }
1216 
1217 double
1219 {
1220  NS_LOG_FUNCTION (this << isData);
1221 
1222  double rate = 0.0;
1223 
1225 
1226  if (isData)
1227  {
1229  }
1230  else
1231  {
1233  }
1234 
1235  return (rate * 1000.0);
1236 }
1237 
1238 Time
1240 {
1241  NS_LOG_FUNCTION (this);
1242 
1243  bool isData = false;
1244  double totalPpduHdrSymbols;
1245 
1247 
1248  totalPpduHdrSymbols = ppduHeaderSymbolNumbers[m_phyOption].shrPreamble
1251 
1252  return Seconds (totalPpduHdrSymbols / GetDataOrSymbolRate (isData));
1253 }
1254 
1255 // IEEE802.15.4-2006 Table 2 in section 6.1.2
1256 void
1258 {
1259  NS_LOG_FUNCTION (this);
1260 
1262 
1264  {
1266  { // 868 MHz BPSK
1268  }
1269  else if (m_phyPIBAttributes.phyCurrentChannel <= 10)
1270  { // 915 MHz BPSK
1272  }
1273  else if (m_phyPIBAttributes.phyCurrentChannel <= 26)
1274  { // 2.4 GHz MHz O-QPSK
1276  }
1277  }
1278  else if (m_phyPIBAttributes.phyCurrentPage == 1)
1279  {
1281  { // 868 MHz ASK
1283  }
1284  else if (m_phyPIBAttributes.phyCurrentChannel <= 10)
1285  { // 915 MHz ASK
1287  }
1288  }
1289  else if (m_phyPIBAttributes.phyCurrentPage == 2)
1290  {
1292  { // 868 MHz O-QPSK
1294  }
1295  else if (m_phyPIBAttributes.phyCurrentChannel <= 10)
1296  { // 915 MHz O-QPSK
1298  }
1299  }
1300 }
1301 
1304 {
1305  NS_LOG_FUNCTION (this);
1306  return m_phyOption;
1307 }
1308 
1309 void
1311 {
1312  NS_LOG_FUNCTION (this << txPsd);
1313  NS_ASSERT (txPsd);
1314  m_txPsd = txPsd;
1315  NS_LOG_INFO ("\t computed tx_psd: " << *txPsd << "\t stored tx_psd: " << *m_txPsd);
1316 }
1317 
1318 void
1320 {
1321  NS_LOG_FUNCTION (this << noisePsd);
1322  NS_LOG_INFO ("\t computed noise_psd: " << *noisePsd );
1323  NS_ASSERT (noisePsd);
1324  m_noise = noisePsd;
1325 }
1326 
1329 {
1330  NS_LOG_FUNCTION (this);
1331  return m_noise;
1332 }
1333 
1334 void
1336 {
1337  NS_LOG_FUNCTION (this << e);
1338  NS_ASSERT (e);
1339  m_errorModel = e;
1340 }
1341 
1344 {
1345  NS_LOG_FUNCTION (this);
1346  return m_errorModel;
1347 }
1348 
1349 uint64_t
1351 {
1352  NS_LOG_FUNCTION (this);
1354 
1357 }
1358 
1359 double
1361 {
1362  NS_LOG_FUNCTION (this);
1364 
1366 }
1367 
1368 int64_t
1370 {
1371  NS_LOG_FUNCTION (this);
1372  m_random->SetStream (stream);
1373  return 1;
1374 }
1375 
1376 } // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
void SetPlmeSetTRXStateConfirmCallback(PlmeSetTRXStateConfirmCallback c)
set the callback for the end of an SetTRXState, as part of the interconnections betweenthe PHY and th...
Definition: lr-wpan-phy.cc:981
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the phy layer drops a packet as it tries to transmit it.
Definition: lr-wpan-phy.h:584
static const uint32_t aTurnaroundTime
The turnaround time for switching the transceiver from RX to TX or vice versa.
Definition: lr-wpan-phy.h:226
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
void SetPdDataConfirmCallback(PdDataConfirmCallback c)
set the callback for the end of a TX, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:953
LrWpanPhyOption GetMyPhyOption(void)
Get the currently configured PHY option.
Ptr< UniformRandomVariable > m_random
Uniform random variable stream.
Definition: lr-wpan-phy.h:778
PdDataConfirmCallback m_pdDataConfirmCallback
This callback is used to report packet transmission status to the MAC layer.
Definition: lr-wpan-phy.h:675
void SetPdDataIndicationCallback(PdDataIndicationCallback c)
set the callback for the end of a RX, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:946
void SetPlmeCcaConfirmCallback(PlmeCcaConfirmCallback c)
set the callback for the end of a CCA, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:960
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1018
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
PlmeEdConfirmCallback m_plmeEdConfirmCallback
This callback is used to report ED status to the MAC.
Definition: lr-wpan-phy.h:687
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
void SetDevice(Ptr< NetDevice > d)
set the associated NetDevice instance
Definition: lr-wpan-phy.cc:198
void SetPlmeEdConfirmCallback(PlmeEdConfirmCallback c)
set the callback for the end of an ED, as part of the interconnections betweenthe PHY and the MAC...
Definition: lr-wpan-phy.cc:967
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:744
LrWpanEdPower m_edPower
Helper value for tracking the average power during ED.
Definition: lr-wpan-phy.h:715
LrWpanPhyEnumeration m_trxState
The current transceiver state.
Definition: lr-wpan-phy.h:656
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:335
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:223
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
void ChangeTrxState(LrWpanPhyEnumeration newState)
Change the PHY state to the given new state, firing the state change trace.
Definition: lr-wpan-phy.cc:995
bool IsRunning(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Definition: event-id.cc:59
bool PhyIsBusy(void) const
Check if the PHY is busy, which is the case if the PHY is currently sending or receiving a frame...
PacketAndStatus m_currentTxPacket
Statusinformation of the currently transmitted packet.
Definition: lr-wpan-phy.h:753
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Definition: lr-wpan-phy.h:592
PlmeGetAttributeConfirmCallback m_plmeGetAttributeConfirmCallback
This callback is used to report requested attribute values back to the MAC.
Definition: lr-wpan-phy.h:693
void EndSetTRXState(void)
Called after applying a deferred transceiver state switch.
Ptr< SpectrumValue > m_txPsd
The transmit power spectral density.
Definition: lr-wpan-phy.h:639
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:825
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Definition: lr-wpan-phy.h:607
Doxygen introspection did not find any typical Config paths.
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:128
static const LrWpanPhyPpduHeaderSymbolNumber ppduHeaderSymbolNumbers[7]
The preamble, SFD, and PHR lengths in symbols for the different PHY options.
Definition: lr-wpan-phy.h:446
double m_rxSensitivity
The receiver sensitivity.
Definition: lr-wpan-phy.h:725
double GetDataOrSymbolRate(bool isData)
implement PLME SetAttribute confirm SAP
TracedCallback< Time, LrWpanPhyEnumeration, LrWpanPhyEnumeration > m_trxStateLogger
The trace source fired when the phy layer changes the transceiver state.
Definition: lr-wpan-phy.h:614
PlmeSetTRXStateConfirmCallback m_plmeSetTRXStateConfirmCallback
This callback is used to report transceiver state change status to the MAC.
Definition: lr-wpan-phy.h:699
Ptr< NetDevice > GetDevice(void)
get the associated NetDevice instance
Definition: lr-wpan-phy.cc:182
uint8_t Get(void) const
Get the LQI value.
static const uint32_t aMaxPhyPacketSize
The maximum packet size accepted by the PHY.
Definition: lr-wpan-phy.h:219
static TypeId GetTypeId(void)
Get the type ID.
Definition: lr-wpan-phy.cc:74
void SetPlmeSetAttributeConfirmCallback(PlmeSetAttributeConfirmCallback c)
set the callback for the end of an SetAttribute, as part of the interconnections betweenthe PHY and t...
Definition: lr-wpan-phy.cc:988
Ptr< SpectrumChannel > m_channel
The channel attached to this transceiver.
Definition: lr-wpan-phy.h:629
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
Definition: lr-wpan-phy.cc:214
static const LrWpanPhyDataAndSymbolRates dataSymbolRates[7]
The data and symbol rates for the different PHY options.
Definition: lr-wpan-phy.h:441
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:863
uint32_t phyChannelsSupported[32]
Definition: lr-wpan-phy.h:131
void SetPlmeGetAttributeConfirmCallback(PlmeGetAttributeConfirmCallback c)
set the callback for the end of an GetAttribute, as part of the interconnections betweenthe PHY and t...
Definition: lr-wpan-phy.cc:974
LrWpanPhyEnumeration m_trxStatePending
The next pending state to applied after the current action of the PHY is completed.
Definition: lr-wpan-phy.h:662
void SetErrorModel(Ptr< LrWpanErrorModel > e)
set the error model to use
double m_ccaPeakPower
Helper value for the peak power value during CCA.
Definition: lr-wpan-phy.h:720
Ptr< LrWpanErrorModel > GetErrorModel(void) const
get the error model in use
Time GetPpduHeaderTxTime(void)
Calculate the time required for sending the PPDU header, that is the preamble, SFD and PHR...
Ptr< const SpectrumValue > GetNoisePowerSpectralDensity(void)
Get the noise power spectral density.
Ptr< LrWpanInterferenceHelper > m_signal
The accumulated signals currently received by the transceiver, including the signal of a possibly rec...
Definition: lr-wpan-phy.h:732
void SetMyPhyOption(void)
Configure the PHY option according to the current channel and channel page.
virtual Ptr< const SpectrumModel > GetRxSpectrumModel(void) const
Definition: lr-wpan-phy.cc:230
Ptr< AntennaModel > m_antenna
The antenna used by the transceiver.
Definition: lr-wpan-phy.h:634
void SetTxPowerSpectralDensity(Ptr< SpectrumValue > txPsd)
Set the Power Spectral Density of outgoing signals in W/Hz.
Time m_rxLastUpdate
Timestamp of the last calculation of the PER of a packet currently received.
Definition: lr-wpan-phy.h:737
Ptr< const SpectrumModel > GetSpectrumModel() const
void SetAntenna(Ptr< AntennaModel > a)
Set the attached antenna.
Definition: lr-wpan-phy.cc:251
Ptr< const SpectrumValue > m_noise
The spectral density for for the noise.
Definition: lr-wpan-phy.h:644
EventId m_setTRXState
Scheduler event of a currently running deferred transceiver state switch.
Definition: lr-wpan-phy.h:768
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
Definition: packet.cc:855
This class defines all functions to create spectrum model for LrWpan.
Ptr< NetDevice > m_device
The configured net device.
Definition: lr-wpan-phy.h:624
void PlmeGetAttributeRequest(LrWpanPibAttributeIdentifier id)
IEEE 802.15.4-2006 section 6.2.2.5 PLME-GET.request Get attributes per definition from Table 23 in se...
Definition: lr-wpan-phy.cc:603
LrWpanPhy(void)
Default constructor.
Definition: lr-wpan-phy.cc:104
Ptr< SpectrumChannel > GetChannel(void)
Get the currently attached channel.
Definition: lr-wpan-phy.cc:222
void EndRx(Ptr< LrWpanSpectrumSignalParameters > params)
Finish the reception of a frame.
Definition: lr-wpan-phy.cc:405
Ptr< MobilityModel > GetMobility(void)
get the associated MobilityModel instance
Definition: lr-wpan-phy.cc:190
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
EventId m_edRequest
Scheduler event of a currently running ED request.
Definition: lr-wpan-phy.h:763
std::pair< Ptr< LrWpanSpectrumSignalParameters >, bool > m_currentRxPacket
Statusinformation of the currently received packet.
Definition: lr-wpan-phy.h:745
Ptr< MobilityModel > m_mobility
The mobility model used by the PHY.
Definition: lr-wpan-phy.h:619
LrWpanPhyOption m_phyOption
The currently configured PHY type.
Definition: lr-wpan-phy.h:710
void EndCca(void)
Called at the end of the CCA.
void PlmeSetTRXStateRequest(LrWpanPhyEnumeration state)
IEEE 802.15.4-2006 section 6.2.2.7 PLME-SET-TRX-STATE.request Set PHY state.
Definition: lr-wpan-phy.cc:638
bool ChannelSupported(uint8_t channel)
Check if the given channel is supported by the PHY.
Definition: lr-wpan-phy.cc:826
void SetMobility(Ptr< MobilityModel > m)
Set the mobility model associated with this device.
Definition: lr-wpan-phy.cc:206
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
static double TotalAvgPower(Ptr< const SpectrumValue > psd)
total average power of the signal is the integral of the PSD
PdDataIndicationCallback m_pdDataIndicationCallback
This callback is used to notify incoming packets to the MAC layer.
Definition: lr-wpan-phy.h:669
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
int64_t GetTimeStep(void) const
Definition: nstime.h:354
PlmeSetAttributeConfirmCallback m_plmeSetAttributeConfirmCallback
This callback is used to report attribute set results back to the MAC.
Definition: lr-wpan-phy.h:705
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
Definition: lr-wpan-phy.h:576
Ptr< AntennaModel > GetRxAntenna(void)
get the AntennaModel used by the NetDevice for reception
Definition: lr-wpan-phy.cc:244
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: lr-wpan-phy.h:568
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void EndTx(void)
Finish the transmission of a frame.
EventId m_ccaRequest
Scheduler event of a currently running CCA request.
Definition: lr-wpan-phy.h:758
void CheckInterference(void)
Check if the interference destroys a frame currently received.
Definition: lr-wpan-phy.cc:359
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
double GetPhySymbolsPerOctet(void) const
Get the number of symbols per octet, depending on the currently selected channel. ...
virtual ~LrWpanPhy(void)
Definition: lr-wpan-phy.cc:149
#define NS_ABORT_IF(cond)
Abnormal program termination if cond is true.
Definition: abort.h:71
EventId m_pdDataRequest
Scheduler event of a currently running data transmission request.
Definition: lr-wpan-phy.h:773
PlmeCcaConfirmCallback m_plmeCcaConfirmCallback
This callback is used to report CCA status to the MAC or CSMA/CA.
Definition: lr-wpan-phy.h:681
Ptr< SpectrumValue > CreateNoisePowerSpectralDensity(uint32_t channel)
create spectrum value for noise
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:203
void SetNoisePowerSpectralDensity(Ptr< const SpectrumValue > noisePsd)
Set the noise power spectral density.
LrWpanPhyPibAttributes m_phyPIBAttributes
Definition: lr-wpan-phy.h:650
virtual void StartRx(Ptr< SpectrumSignalParameters > params)
Notify the SpectrumPhy instance of an incoming waveform.
Definition: lr-wpan-phy.cc:258
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:848
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint32_t channel)
create spectrum value
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:213
TracedCallback< Ptr< const Packet >, double > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: lr-wpan-phy.h:600
void EndEd(void)
Called at the end of the ED procedure.
void PlmeSetAttributeRequest(LrWpanPibAttributeIdentifier id, LrWpanPhyPibAttributes *attribute)
IEEE 802.15.4-2006 section 6.2.2.9 PLME-SET.request Set attributes per definition from Table 23 in se...
Definition: lr-wpan-phy.cc:844
void PdDataRequest(const uint32_t psduLength, Ptr< Packet > p)
IEEE 802.15.4-2006 section 6.2.1.1 PD-DATA.request Request to transfer MPDU from MAC (transmitting) ...
Definition: lr-wpan-phy.cc:475
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
LrWpanPhyOption
This Phy option will be used to index various Tables in IEEE802.15.4-2006.
Definition: lr-wpan-phy.h:77
void Set(uint8_t lqi)
Set the LQI to the given value.
a base class which provides memory management and object aggregation
Definition: object.h:64
Time CalculateTxTime(Ptr< const Packet > packet)
Calculate the time required for sending the given packet, including preamble, SFD and PHR...
void PlmeCcaRequest(void)
IEEE 802.15.4-2006 section 6.2.2.1 PLME-CCA.request Perform a CCA per section 6.9.9.
Definition: lr-wpan-phy.cc:549
void PlmeEdRequest(void)
IEEE 802.15.4-2006 section 6.2.2.3 PLME-ED.request Perform an ED per section 6.9.7.
Definition: lr-wpan-phy.cc:576
void CancelEd(LrWpanPhyEnumeration state)
Cancel an ongoing ED procedure.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: lr-wpan-phy.cc:154
uint64_t GetPhySHRDuration(void) const
Get the duration of the SHR (preamble and SFD) in symbols, depending on the currently selected channe...
millisecond
Definition: nstime.h:92
Hold a floating point type.
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:176
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Definition: event-id.cc:53
Ptr< LrWpanErrorModel > m_errorModel
The error model describing the bit and packet error rates.
Definition: lr-wpan-phy.h:649
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
Definition: lr-wpan-phy.h:93
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
Definition: lr-wpan-phy.h:113