author | Tommaso Pecorella <tommaso.pecorella@unifi.it> |
Sun, 15 Mar 2015 09:14:50 +0100 | |
changeset 11232 | 865dcb3bf5a0 |
parent 11205 | 29b708f01eb1 |
child 11265 | 9fa2628d32cb |
permissions | -rw-r--r-- |
10711 | 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 |
* |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
18 |
* Author: |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
19 |
* Gary Pei <guangyu.pei@boeing.com> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
20 |
* Sascha Alexander Jopen <jopen@cs.uni-bonn.de> |
10711 | 21 |
*/ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
22 |
#include "lr-wpan-phy.h" |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
23 |
#include "lr-wpan-lqi-tag.h" |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
24 |
#include "lr-wpan-spectrum-signal-parameters.h" |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
25 |
#include "lr-wpan-spectrum-value-helper.h" |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
26 |
#include "lr-wpan-error-model.h" |
10736
0de55db7c94e
Tweaks to the collision tests
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10730
diff
changeset
|
27 |
#include "lr-wpan-net-device.h" |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
28 |
#include <ns3/log.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
29 |
#include <ns3/abort.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
30 |
#include <ns3/simulator.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
31 |
#include <ns3/spectrum-value.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
32 |
#include <ns3/antenna-model.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
33 |
#include <ns3/mobility-model.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
34 |
#include <ns3/spectrum-channel.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
35 |
#include <ns3/packet.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
36 |
#include <ns3/packet-burst.h> |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
37 |
#include <ns3/net-device.h> |
10750
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
38 |
#include <ns3/random-variable-stream.h> |
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
39 |
#include <ns3/double.h> |
10711 | 40 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10811
diff
changeset
|
41 |
namespace ns3 { |
10711 | 42 |
|
10968
2d29fee2b7b8
[Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10811
diff
changeset
|
43 |
NS_LOG_COMPONENT_DEFINE ("LrWpanPhy"); |
10711 | 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 |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
50 |
|
10711 | 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 |
|
74 |
LrWpanPhy::GetTypeId (void) |
|
75 |
{ |
|
76 |
static TypeId tid = TypeId ("ns3::LrWpanPhy") |
|
77 |
.SetParent<Object> () |
|
78 |
.AddConstructor<LrWpanPhy> () |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
79 |
.AddTraceSource ("TrxState", |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
80 |
"The state of the transceiver", |
11086
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
81 |
MakeTraceSourceAccessor (&LrWpanPhy::m_trxStateLogger), |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
82 |
"ns3::LrWpanPhy::StateTracedCallback") |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
83 |
.AddTraceSource ("PhyTxBegin", |
11086
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
84 |
"Trace source indicating a packet has " |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
85 |
"begun transmitting over the channel medium", |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
86 |
MakeTraceSourceAccessor (&LrWpanPhy::m_phyTxBeginTrace), |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
87 |
"ns3::Packet::TracedCallback") |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
88 |
.AddTraceSource ("PhyTxEnd", |
11086
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
89 |
"Trace source indicating a packet has been " |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
90 |
"completely transmitted over the channel.", |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
91 |
MakeTraceSourceAccessor (&LrWpanPhy::m_phyTxEndTrace), |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
92 |
"ns3::Packet::TracedCallback") |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
93 |
.AddTraceSource ("PhyTxDrop", |
11086
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
94 |
"Trace source indicating a packet has been " |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
95 |
"dropped by the device during transmission", |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
96 |
MakeTraceSourceAccessor (&LrWpanPhy::m_phyTxDropTrace), |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
97 |
"ns3::Packet::TracedCallback") |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
98 |
.AddTraceSource ("PhyRxBegin", |
11086
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
99 |
"Trace source indicating a packet has begun " |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
100 |
"being received from the channel medium by the device", |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
101 |
MakeTraceSourceAccessor (&LrWpanPhy::m_phyRxBeginTrace), |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
102 |
"ns3::Packet::TracedCallback") |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
103 |
.AddTraceSource ("PhyRxEnd", |
11086
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
104 |
"Trace source indicating a packet has been " |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
105 |
"completely received from the channel medium " |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
106 |
"by the device", |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
107 |
MakeTraceSourceAccessor (&LrWpanPhy::m_phyRxEndTrace), |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
108 |
"ns3::LrWpanPhy::RxEndTracedCallback") |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
109 |
.AddTraceSource ("PhyRxDrop", |
11086
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
110 |
"Trace source indicating a packet has been " |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
111 |
"dropped by the device during reception", |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
112 |
MakeTraceSourceAccessor (&LrWpanPhy::m_phyRxDropTrace), |
65914b1ed5b3
TracedCallback function signatures, the rest.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
10968
diff
changeset
|
113 |
"ns3::Packet::TracedCallback") |
10711 | 114 |
; |
115 |
return tid; |
|
116 |
} |
|
117 |
||
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
118 |
LrWpanPhy::LrWpanPhy (void) |
10711 | 119 |
: m_edRequest (), |
120 |
m_setTRXState () |
|
121 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
122 |
m_trxState = IEEE_802_15_4_PHY_TRX_OFF; |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
123 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
10711 | 124 |
|
125 |
// default PHY PIB attributes |
|
126 |
m_phyPIBAttributes.phyCurrentChannel = 11; |
|
127 |
m_phyPIBAttributes.phyTransmitPower = 0; |
|
128 |
m_phyPIBAttributes.phyCurrentPage = 0; |
|
129 |
for (uint32_t i = 0; i < 32; i++) |
|
130 |
{ |
|
131 |
m_phyPIBAttributes.phyChannelsSupported[i] = 0x07ffffff; |
|
132 |
} |
|
133 |
m_phyPIBAttributes.phyCCAMode = 1; |
|
134 |
||
135 |
SetMyPhyOption (); |
|
136 |
||
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
137 |
m_edPower.averagePower = 0.0; |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
138 |
m_edPower.lastUpdate = Seconds (0.0); |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
139 |
m_edPower.measurementLength = Seconds (0.0); |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
140 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
141 |
// default -110 dBm in W for 2.4 GHz |
10747
9d94cd7b245f
Changed default receiver sensitivity value.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10742
diff
changeset
|
142 |
m_rxSensitivity = pow (10.0, -106.58 / 10.0) / 1000.0; |
10711 | 143 |
LrWpanSpectrumValueHelper psdHelper; |
144 |
m_txPsd = psdHelper.CreateTxPowerSpectralDensity (m_phyPIBAttributes.phyTransmitPower, |
|
145 |
m_phyPIBAttributes.phyCurrentChannel); |
|
146 |
m_noise = psdHelper.CreateNoisePowerSpectralDensity (m_phyPIBAttributes.phyCurrentChannel); |
|
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
147 |
m_signal = Create<LrWpanInterferenceHelper> (m_noise->GetSpectrumModel ()); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
148 |
m_rxLastUpdate = Seconds (0); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
149 |
Ptr<Packet> none_packet = 0; |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
150 |
Ptr<LrWpanSpectrumSignalParameters> none_params = 0; |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
151 |
m_currentRxPacket = std::make_pair (none_params, true); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
152 |
m_currentTxPacket = std::make_pair (none_packet, true); |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
153 |
m_errorModel = 0; |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
154 |
|
10750
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
155 |
m_random = CreateObject<UniformRandomVariable> (); |
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
156 |
m_random->SetAttribute ("Min", DoubleValue (0.0)); |
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
157 |
m_random->SetAttribute ("Max", DoubleValue (1.0)); |
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
158 |
|
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
159 |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
160 |
ChangeTrxState (IEEE_802_15_4_PHY_TRX_OFF); |
10711 | 161 |
} |
162 |
||
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
163 |
LrWpanPhy::~LrWpanPhy (void) |
10711 | 164 |
{ |
165 |
} |
|
166 |
||
167 |
void |
|
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
168 |
LrWpanPhy::DoDispose (void) |
10711 | 169 |
{ |
170 |
NS_LOG_FUNCTION (this); |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
171 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
172 |
// Cancel pending transceiver state change, if one is in progress. |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
173 |
m_setTRXState.Cancel (); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
174 |
m_trxState = IEEE_802_15_4_PHY_TRX_OFF; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
175 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
176 |
|
10711 | 177 |
m_mobility = 0; |
178 |
m_device = 0; |
|
179 |
m_channel = 0; |
|
180 |
m_txPsd = 0; |
|
181 |
m_noise = 0; |
|
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
182 |
m_signal = 0; |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
183 |
m_errorModel = 0; |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
184 |
m_pdDataIndicationCallback = MakeNullCallback< void, uint32_t, Ptr<Packet>, uint8_t > (); |
10711 | 185 |
m_pdDataConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration > (); |
186 |
m_plmeCcaConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration > (); |
|
187 |
m_plmeEdConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration,uint8_t > (); |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
188 |
m_plmeGetAttributeConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier, LrWpanPhyPibAttributes* > (); |
10711 | 189 |
m_plmeSetTRXStateConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration > (); |
190 |
m_plmeSetAttributeConfirmCallback = MakeNullCallback< void, LrWpanPhyEnumeration, LrWpanPibAttributeIdentifier > (); |
|
191 |
||
192 |
SpectrumPhy::DoDispose (); |
|
193 |
} |
|
194 |
||
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
195 |
Ptr<NetDevice> |
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
196 |
LrWpanPhy::GetDevice (void) |
10711 | 197 |
{ |
198 |
NS_LOG_FUNCTION (this); |
|
199 |
return m_device; |
|
200 |
} |
|
201 |
||
202 |
||
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
203 |
Ptr<MobilityModel> |
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
204 |
LrWpanPhy::GetMobility (void) |
10711 | 205 |
{ |
206 |
NS_LOG_FUNCTION (this); |
|
207 |
return m_mobility; |
|
208 |
} |
|
209 |
||
210 |
||
211 |
void |
|
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
212 |
LrWpanPhy::SetDevice (Ptr<NetDevice> d) |
10711 | 213 |
{ |
214 |
NS_LOG_FUNCTION (this << d); |
|
215 |
m_device = d; |
|
216 |
} |
|
217 |
||
218 |
||
219 |
void |
|
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
220 |
LrWpanPhy::SetMobility (Ptr<MobilityModel> m) |
10711 | 221 |
{ |
222 |
NS_LOG_FUNCTION (this << m); |
|
223 |
m_mobility = m; |
|
224 |
} |
|
225 |
||
226 |
||
227 |
void |
|
228 |
LrWpanPhy::SetChannel (Ptr<SpectrumChannel> c) |
|
229 |
{ |
|
230 |
NS_LOG_FUNCTION (this << c); |
|
231 |
m_channel = c; |
|
232 |
} |
|
233 |
||
234 |
||
235 |
Ptr<SpectrumChannel> |
|
236 |
LrWpanPhy::GetChannel (void) |
|
237 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
238 |
NS_LOG_FUNCTION (this); |
10711 | 239 |
return m_channel; |
240 |
} |
|
241 |
||
242 |
||
243 |
Ptr<const SpectrumModel> |
|
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
244 |
LrWpanPhy::GetRxSpectrumModel (void) const |
10711 | 245 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
246 |
NS_LOG_FUNCTION (this); |
10711 | 247 |
if (m_txPsd) |
248 |
{ |
|
249 |
return m_txPsd->GetSpectrumModel (); |
|
250 |
} |
|
251 |
else |
|
252 |
{ |
|
253 |
return 0; |
|
254 |
} |
|
255 |
} |
|
256 |
||
10714
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
257 |
Ptr<AntennaModel> |
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
258 |
LrWpanPhy::GetRxAntenna (void) |
10714
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
259 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
260 |
NS_LOG_FUNCTION (this); |
10714
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
261 |
return m_antenna; |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
262 |
} |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
263 |
|
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
264 |
void |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
265 |
LrWpanPhy::SetAntenna (Ptr<AntennaModel> a) |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
266 |
{ |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
267 |
NS_LOG_FUNCTION (this << a); |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
268 |
m_antenna = a; |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
269 |
} |
03e748ce8893
align with SpectrumPhy antenna model changes for ns-3.14
Tom Henderson <tomh@tomh.org>
parents:
10713
diff
changeset
|
270 |
|
10711 | 271 |
void |
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
272 |
LrWpanPhy::StartRx (Ptr<SpectrumSignalParameters> spectrumRxParams) |
10711 | 273 |
{ |
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
274 |
NS_LOG_FUNCTION (this << spectrumRxParams); |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
275 |
LrWpanSpectrumValueHelper psdHelper; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
276 |
|
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
277 |
if (!m_edRequest.IsExpired ()) |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
278 |
{ |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
279 |
// Update the average receive power during ED. |
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
280 |
Time now = Simulator::Now (); |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
281 |
m_edPower.averagePower += LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd (), m_phyPIBAttributes.phyCurrentChannel) * (now - m_edPower.lastUpdate).GetTimeStep () / m_edPower.measurementLength.GetTimeStep (); |
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
282 |
m_edPower.lastUpdate = now; |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
283 |
} |
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
284 |
|
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
285 |
Ptr<LrWpanSpectrumSignalParameters> lrWpanRxParams = DynamicCast<LrWpanSpectrumSignalParameters> (spectrumRxParams); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
286 |
|
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
287 |
if ( lrWpanRxParams == 0) |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
288 |
{ |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
289 |
CheckInterference (); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
290 |
m_signal->AddSignal (spectrumRxParams->psd); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
291 |
|
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
292 |
// Update peak power if CCA is in progress. |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
293 |
if (!m_ccaRequest.IsExpired ()) |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
294 |
{ |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
295 |
double power = LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd (), m_phyPIBAttributes.phyCurrentChannel); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
296 |
if (m_ccaPeakPower < power) |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
297 |
{ |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
298 |
m_ccaPeakPower = power; |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
299 |
} |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
300 |
} |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
301 |
|
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
302 |
Simulator::Schedule (spectrumRxParams->duration, &LrWpanPhy::EndRx, this, spectrumRxParams); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
303 |
return; |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
304 |
} |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
305 |
|
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
306 |
Ptr<Packet> p = (lrWpanRxParams->packetBurst->GetPackets ()).front (); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
307 |
NS_ASSERT (p != 0); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
308 |
|
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
309 |
// Prevent PHY from receiving another packet while switching the transceiver state. |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
310 |
if (m_trxState == IEEE_802_15_4_PHY_RX_ON && !m_setTRXState.IsRunning ()) |
10711 | 311 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
312 |
// The specification doesn't seem to refer to BUSY_RX, but vendor |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
313 |
// data sheets suggest that this is a substate of the RX_ON state |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
314 |
// that is entered after preamble detection when the digital receiver |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
315 |
// is enabled. Here, for now, we use BUSY_RX to mark the period between |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
316 |
// StartRx() and EndRx() states. |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
317 |
|
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
318 |
// We are going to BUSY_RX state when receiving the first bit of an SHR, |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
319 |
// as opposed to real receivers, which should go to this state only after |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
320 |
// successfully receiving the SHR. |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
321 |
|
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
322 |
// If synchronizing to the packet is possible, change to BUSY_RX state, |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
323 |
// otherwise drop the packet and stay in RX state. The actual synchronization |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
324 |
// is not modeled. |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
325 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
326 |
// Add any incoming packet to the current interference before checking the |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
327 |
// SINR. |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
328 |
NS_LOG_DEBUG (this << " receiving packet with power: " << 10 * log10(LrWpanSpectrumValueHelper::TotalAvgPower (lrWpanRxParams->psd, m_phyPIBAttributes.phyCurrentChannel)) + 30 << "dBm"); |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
329 |
m_signal->AddSignal (lrWpanRxParams->psd); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
330 |
Ptr<SpectrumValue> interferenceAndNoise = m_signal->GetSignalPsd (); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
331 |
*interferenceAndNoise -= *lrWpanRxParams->psd; |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
332 |
*interferenceAndNoise += *m_noise; |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
333 |
double sinr = LrWpanSpectrumValueHelper::TotalAvgPower (lrWpanRxParams->psd, m_phyPIBAttributes.phyCurrentChannel) / LrWpanSpectrumValueHelper::TotalAvgPower (interferenceAndNoise, m_phyPIBAttributes.phyCurrentChannel); |
10730
3db83bcc026d
Tweaks to Rx values
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10729
diff
changeset
|
334 |
|
3db83bcc026d
Tweaks to Rx values
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10729
diff
changeset
|
335 |
// Std. 802.15.4-2006, appendix E, Figure E.2 |
3db83bcc026d
Tweaks to Rx values
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10729
diff
changeset
|
336 |
// At SNR < -5 the BER is less than 10e-1. |
3db83bcc026d
Tweaks to Rx values
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10729
diff
changeset
|
337 |
// It's useless to even *try* to decode the packet. |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
338 |
if (10 * log10 (sinr) > -5) |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
339 |
{ |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
340 |
ChangeTrxState (IEEE_802_15_4_PHY_BUSY_RX); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
341 |
m_currentRxPacket = std::make_pair (lrWpanRxParams, false); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
342 |
m_phyRxBeginTrace (p); |
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
343 |
|
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
344 |
m_rxLastUpdate = Simulator::Now (); |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
345 |
} |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
346 |
else |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
347 |
{ |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
348 |
m_phyRxDropTrace (p); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
349 |
} |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
350 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
351 |
else if (m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
352 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
353 |
// Drop the new packet. |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
354 |
NS_LOG_DEBUG (this << " packet collision"); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
355 |
m_phyRxDropTrace (p); |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
356 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
357 |
// Check if we correctly received the old packet up to now. |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
358 |
CheckInterference (); |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
359 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
360 |
// Add the incoming packet to the current interference after we have |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
361 |
// checked for successfull reception of the current packet for the time |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
362 |
// before the additional interference. |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
363 |
m_signal->AddSignal (lrWpanRxParams->psd); |
10711 | 364 |
} |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
365 |
else |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
366 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
367 |
// Simply drop the packet. |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
368 |
NS_LOG_DEBUG (this << " transceiver not in RX state"); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
369 |
m_phyRxDropTrace (p); |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
370 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
371 |
// Add the signal power to the interference, anyway. |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
372 |
m_signal->AddSignal (lrWpanRxParams->psd); |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
373 |
} |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
374 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
375 |
// Update peak power if CCA is in progress. |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
376 |
if (!m_ccaRequest.IsExpired ()) |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
377 |
{ |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
378 |
double power = LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd (), m_phyPIBAttributes.phyCurrentChannel); |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
379 |
if (m_ccaPeakPower < power) |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
380 |
{ |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
381 |
m_ccaPeakPower = power; |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
382 |
} |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
383 |
} |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
384 |
|
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
385 |
// Always call EndRx to update the interference. |
10730
3db83bcc026d
Tweaks to Rx values
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10729
diff
changeset
|
386 |
// \todo: Do we need to keep track of these events to unschedule them when disposing off the PHY? |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
387 |
|
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
388 |
Simulator::Schedule (spectrumRxParams->duration, &LrWpanPhy::EndRx, this, spectrumRxParams); |
10711 | 389 |
} |
390 |
||
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
391 |
void |
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
392 |
LrWpanPhy::CheckInterference (void) |
10711 | 393 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
394 |
// Calculate whether packet was lost. |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
395 |
LrWpanSpectrumValueHelper psdHelper; |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
396 |
Ptr<LrWpanSpectrumSignalParameters> currentRxParams = m_currentRxPacket.first; |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
397 |
|
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
398 |
// We are currently receiving a packet. |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
399 |
if (m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
400 |
{ |
10738
0cf3ef65b4c0
Add back debugging code, seems we have a bug in interference handling.
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10737
diff
changeset
|
401 |
// NS_ASSERT (currentRxParams && !m_currentRxPacket.second); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
402 |
|
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
403 |
Ptr<Packet> currentPacket = currentRxParams->packetBurst->GetPackets ().front (); |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
404 |
if (m_errorModel != 0) |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
405 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
406 |
// How many bits did we receive since the last calculation? |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
407 |
double t = (Simulator::Now () - m_rxLastUpdate).ToDouble (Time::MS); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
408 |
uint32_t chunkSize = ceil (t * (GetDataOrSymbolRate (true) / 1000)); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
409 |
Ptr<SpectrumValue> interferenceAndNoise = m_signal->GetSignalPsd (); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
410 |
*interferenceAndNoise -= *currentRxParams->psd; |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
411 |
*interferenceAndNoise += *m_noise; |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
412 |
double sinr = LrWpanSpectrumValueHelper::TotalAvgPower (currentRxParams->psd, m_phyPIBAttributes.phyCurrentChannel) / LrWpanSpectrumValueHelper::TotalAvgPower (interferenceAndNoise, m_phyPIBAttributes.phyCurrentChannel); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
413 |
double per = 1.0 - m_errorModel->GetChunkSuccessRate (sinr, chunkSize); |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
414 |
|
10740
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
415 |
// The LQI is the total packet success rate scaled to 0-255. |
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
416 |
// If not already set, initialize to 255. |
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
417 |
LrWpanLqiTag tag (std::numeric_limits<uint8_t>::max ()); |
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
418 |
currentPacket->PeekPacketTag (tag); |
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
419 |
uint8_t lqi = tag.Get (); |
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
420 |
tag.Set (lqi - (per * lqi)); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
421 |
currentPacket->ReplacePacketTag (tag); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
422 |
|
10750
8a9e91fac9c0
First Doxygen documentation batch and code cleanups.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10748
diff
changeset
|
423 |
if (m_random->GetValue () < per) |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
424 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
425 |
// The packet was destroyed, drop the packet after reception. |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
426 |
m_currentRxPacket.second = true; |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
427 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
428 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
429 |
else |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
430 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
431 |
NS_LOG_WARN ("Missing ErrorModel"); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
432 |
} |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
433 |
} |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
434 |
m_rxLastUpdate = Simulator::Now (); |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
435 |
} |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
436 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
437 |
void |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
438 |
LrWpanPhy::EndRx (Ptr<SpectrumSignalParameters> par) |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
439 |
{ |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
440 |
NS_LOG_FUNCTION (this); |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
441 |
|
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
442 |
Ptr<LrWpanSpectrumSignalParameters> params = DynamicCast<LrWpanSpectrumSignalParameters> (par); |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
443 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
444 |
if (!m_edRequest.IsExpired ()) |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
445 |
{ |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
446 |
// Update the average receive power during ED. |
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
447 |
Time now = Simulator::Now (); |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
448 |
m_edPower.averagePower += LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd (), m_phyPIBAttributes.phyCurrentChannel) * (now - m_edPower.lastUpdate).GetTimeStep () / m_edPower.measurementLength.GetTimeStep (); |
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
449 |
m_edPower.lastUpdate = now; |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
450 |
} |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
451 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
452 |
CheckInterference (); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
453 |
|
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
454 |
// Update the interference. |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
455 |
m_signal->RemoveSignal (par->psd); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
456 |
|
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
457 |
if (params == 0) |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
458 |
{ |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
459 |
NS_LOG_LOGIC ("Node: " << m_device->GetAddress() << " Removing interferent: " << *(par->psd)); |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
460 |
return; |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
461 |
} |
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
462 |
|
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
463 |
// If this is the end of the currently received packet, check if reception was successful. |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
464 |
Ptr<LrWpanSpectrumSignalParameters> currentRxParams = m_currentRxPacket.first; |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
465 |
if (currentRxParams == params) |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
466 |
{ |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
467 |
Ptr<Packet> currentPacket = currentRxParams->packetBurst->GetPackets ().front (); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
468 |
NS_ASSERT (currentPacket != 0); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
469 |
|
10740
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
470 |
// If there is no error model attached to the PHY, we always report the maximum LQI value. |
aaaf22c97012
Added LQI calculation as the PER of the complete packet scaled to 255.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10738
diff
changeset
|
471 |
LrWpanLqiTag tag (std::numeric_limits<uint8_t>::max ()); |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
472 |
currentPacket->PeekPacketTag (tag); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
473 |
m_phyRxEndTrace (currentPacket, tag.Get ()); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
474 |
|
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
475 |
if (!m_currentRxPacket.second) |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
476 |
{ |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
477 |
// The packet was successfully received, push it up the stack. |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
478 |
if (!m_pdDataIndicationCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
479 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
480 |
m_pdDataIndicationCallback (currentPacket->GetSize (), currentPacket, tag.Get ()); |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
481 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
482 |
} |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
483 |
else |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
484 |
{ |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
485 |
// The packet was destroyed, drop it. |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
486 |
m_phyRxDropTrace (currentPacket); |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
487 |
} |
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
488 |
Ptr<LrWpanSpectrumSignalParameters> none = 0; |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
489 |
m_currentRxPacket = std::make_pair (none, true); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
490 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
491 |
// We may be waiting to apply a pending state change. |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
492 |
if (m_trxStatePending != IEEE_802_15_4_PHY_IDLE) |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
493 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
494 |
// Only change the state immediately, if the transceiver is not already |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
495 |
// switching the state. |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
496 |
if (!m_setTRXState.IsRunning ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
497 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
498 |
NS_LOG_LOGIC ("Apply pending state change to " << m_trxStatePending); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
499 |
ChangeTrxState (m_trxStatePending); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
500 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
501 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
502 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
503 |
m_plmeSetTRXStateConfirmCallback (IEEE_802_15_4_PHY_SUCCESS); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
504 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
505 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
506 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
507 |
else |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
508 |
{ |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
509 |
ChangeTrxState (IEEE_802_15_4_PHY_RX_ON); |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
510 |
} |
10711 | 511 |
} |
512 |
} |
|
513 |
||
514 |
void |
|
515 |
LrWpanPhy::PdDataRequest (const uint32_t psduLength, Ptr<Packet> p) |
|
516 |
{ |
|
517 |
NS_LOG_FUNCTION (this << psduLength << p); |
|
518 |
||
519 |
if (psduLength > aMaxPhyPacketSize) |
|
520 |
{ |
|
521 |
if (!m_pdDataConfirmCallback.IsNull ()) |
|
522 |
{ |
|
523 |
m_pdDataConfirmCallback (IEEE_802_15_4_PHY_UNSPECIFIED); |
|
524 |
} |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
525 |
NS_LOG_DEBUG ("Drop packet because psduLength too long: " << psduLength); |
10711 | 526 |
return; |
527 |
} |
|
528 |
||
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
529 |
// Prevent PHY from sending a packet while switching the transceiver state. |
10760
d7d73e3ceb3c
Apply utils/check-style.py script on lr-wpan source code again
Tom Henderson <tomh@tomh.org>
parents:
10758
diff
changeset
|
530 |
if (!m_setTRXState.IsRunning ()) |
10711 | 531 |
{ |
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
532 |
if (m_trxState == IEEE_802_15_4_PHY_TX_ON) |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
533 |
{ |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
534 |
//send down |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
535 |
NS_ASSERT (m_channel); |
10713
84e9327f67ba
align lr-wpan with ns-3.13 spectrum API changes
Gary Pei <guangyu.pei@boeing.com>
parents:
10712
diff
changeset
|
536 |
|
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
537 |
// Remove a possible LQI tag from a previous transmission of the packet. |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
538 |
LrWpanLqiTag lqiTag; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
539 |
p->RemovePacketTag (lqiTag); |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
540 |
|
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
541 |
Ptr<LrWpanSpectrumSignalParameters> txParams = Create<LrWpanSpectrumSignalParameters> (); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
542 |
txParams->duration = CalculateTxTime (p); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
543 |
txParams->txPhy = GetObject<SpectrumPhy> (); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
544 |
txParams->psd = m_txPsd; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
545 |
txParams->txAntenna = m_antenna; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
546 |
Ptr<PacketBurst> pb = CreateObject<PacketBurst> (); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
547 |
pb->AddPacket (p); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
548 |
txParams->packetBurst = pb; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
549 |
m_channel->StartTx (txParams); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
550 |
m_pdDataRequest = Simulator::Schedule (txParams->duration, &LrWpanPhy::EndTx, this); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
551 |
ChangeTrxState (IEEE_802_15_4_PHY_BUSY_TX); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
552 |
m_phyTxBeginTrace (p); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
553 |
m_currentTxPacket.first = p; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
554 |
m_currentTxPacket.second = false; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
555 |
return; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
556 |
} |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
557 |
else if ((m_trxState == IEEE_802_15_4_PHY_RX_ON) |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
558 |
|| (m_trxState == IEEE_802_15_4_PHY_TRX_OFF) |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
559 |
|| (m_trxState == IEEE_802_15_4_PHY_BUSY_TX) ) |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
560 |
{ |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
561 |
if (!m_pdDataConfirmCallback.IsNull ()) |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
562 |
{ |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
563 |
m_pdDataConfirmCallback (m_trxState); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
564 |
} |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
565 |
// Drop packet, hit PhyTxDrop trace |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
566 |
m_phyTxDropTrace (p); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
567 |
return; |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
568 |
} |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
569 |
else |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
570 |
{ |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
571 |
NS_FATAL_ERROR ("This should be unreachable, or else state " << m_trxState << " should be added as a case"); |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
572 |
} |
10711 | 573 |
} |
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
574 |
else |
10711 | 575 |
{ |
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
576 |
// TODO: This error code is not covered by the standard. |
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
577 |
// What is the correct behavior in this case? |
10711 | 578 |
if (!m_pdDataConfirmCallback.IsNull ()) |
579 |
{ |
|
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
580 |
m_pdDataConfirmCallback (IEEE_802_15_4_PHY_UNSPECIFIED); |
10711 | 581 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
582 |
// Drop packet, hit PhyTxDrop trace |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
583 |
m_phyTxDropTrace (p); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
584 |
return; |
10711 | 585 |
} |
586 |
} |
|
587 |
||
588 |
void |
|
589 |
LrWpanPhy::PlmeCcaRequest (void) |
|
590 |
{ |
|
591 |
NS_LOG_FUNCTION (this); |
|
10736
0de55db7c94e
Tweaks to the collision tests
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10730
diff
changeset
|
592 |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
593 |
if (m_trxState == IEEE_802_15_4_PHY_RX_ON || m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
10711 | 594 |
{ |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
595 |
m_ccaPeakPower = 0.0; |
10711 | 596 |
Time ccaTime = Seconds (8.0 / GetDataOrSymbolRate (false)); |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
597 |
m_ccaRequest = Simulator::Schedule (ccaTime, &LrWpanPhy::EndCca, this); |
10711 | 598 |
} |
599 |
else |
|
600 |
{ |
|
601 |
if (!m_plmeCcaConfirmCallback.IsNull ()) |
|
602 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
603 |
if (m_trxState == IEEE_802_15_4_PHY_TRX_OFF) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
604 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
605 |
m_plmeCcaConfirmCallback (IEEE_802_15_4_PHY_TRX_OFF); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
606 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
607 |
else |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
608 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
609 |
m_plmeCcaConfirmCallback (IEEE_802_15_4_PHY_BUSY); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
610 |
} |
10711 | 611 |
} |
612 |
} |
|
613 |
} |
|
614 |
||
615 |
void |
|
616 |
LrWpanPhy::PlmeEdRequest (void) |
|
617 |
{ |
|
618 |
NS_LOG_FUNCTION (this); |
|
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
619 |
if (m_trxState == IEEE_802_15_4_PHY_RX_ON || m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
10711 | 620 |
{ |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
621 |
// Average over the powers of all signals received until EndEd() |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
622 |
m_edPower.averagePower = 0; |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
623 |
m_edPower.lastUpdate = Simulator::Now (); |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
624 |
m_edPower.measurementLength = Seconds (8.0 / GetDataOrSymbolRate (false)); |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
625 |
m_edRequest = Simulator::Schedule (m_edPower.measurementLength, &LrWpanPhy::EndEd, this); |
10711 | 626 |
} |
627 |
else |
|
628 |
{ |
|
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
629 |
LrWpanPhyEnumeration result = m_trxState; |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
630 |
if (m_trxState == IEEE_802_15_4_PHY_BUSY_TX) |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
631 |
{ |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
632 |
result = IEEE_802_15_4_PHY_TX_ON; |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
633 |
} |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
634 |
|
10711 | 635 |
if (!m_plmeEdConfirmCallback.IsNull ()) |
636 |
{ |
|
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
637 |
m_plmeEdConfirmCallback (result, 0); |
10711 | 638 |
} |
639 |
} |
|
640 |
} |
|
641 |
||
642 |
void |
|
643 |
LrWpanPhy::PlmeGetAttributeRequest (LrWpanPibAttributeIdentifier id) |
|
644 |
{ |
|
645 |
NS_LOG_FUNCTION (this << id); |
|
646 |
LrWpanPhyEnumeration status; |
|
647 |
||
648 |
switch (id) |
|
649 |
{ |
|
650 |
case phyCurrentChannel: |
|
651 |
case phyChannelsSupported: |
|
652 |
case phyTransmitPower: |
|
653 |
case phyCCAMode: |
|
654 |
case phyCurrentPage: |
|
655 |
case phyMaxFrameDuration: |
|
656 |
case phySHRDuration: |
|
657 |
case phySymbolsPerOctet: |
|
658 |
{ |
|
659 |
status = IEEE_802_15_4_PHY_SUCCESS; |
|
660 |
break; |
|
661 |
} |
|
662 |
default: |
|
663 |
{ |
|
664 |
status = IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE; |
|
665 |
break; |
|
666 |
} |
|
667 |
} |
|
668 |
if (!m_plmeGetAttributeConfirmCallback.IsNull ()) |
|
669 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
670 |
LrWpanPhyPibAttributes retValue; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
671 |
memcpy (&retValue, &m_phyPIBAttributes, sizeof(LrWpanPhyPibAttributes)); |
10711 | 672 |
m_plmeGetAttributeConfirmCallback (status,id,&retValue); |
673 |
} |
|
674 |
} |
|
675 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
676 |
// Section 6.2.2.7.3 |
10711 | 677 |
void |
678 |
LrWpanPhy::PlmeSetTRXStateRequest (LrWpanPhyEnumeration state) |
|
679 |
{ |
|
680 |
NS_LOG_FUNCTION (this << state); |
|
681 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
682 |
// Check valid states (Table 14) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
683 |
NS_ABORT_IF ( (state != IEEE_802_15_4_PHY_RX_ON) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
684 |
&& (state != IEEE_802_15_4_PHY_TRX_OFF) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
685 |
&& (state != IEEE_802_15_4_PHY_FORCE_TRX_OFF) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
686 |
&& (state != IEEE_802_15_4_PHY_TX_ON) ); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
687 |
|
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
688 |
NS_LOG_LOGIC ("Trying to set m_trxState from " << m_trxState << " to " << state); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
689 |
// this method always overrides previous state setting attempts |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
690 |
if (!m_setTRXState.IsExpired ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
691 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
692 |
if (m_trxStatePending == state) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
693 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
694 |
// Simply wait for the ongoing state switch. |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
695 |
return; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
696 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
697 |
else |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
698 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
699 |
NS_LOG_DEBUG ("Cancel m_setTRXState"); |
10721
ac0a504fa91e
- Fixed error in MAC state machine when sending an ACK and enqueuing a data packet at the same time.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10720
diff
changeset
|
700 |
// Keep the transceiver state as the old state before the switching attempt. |
10760
d7d73e3ceb3c
Apply utils/check-style.py script on lr-wpan source code again
Tom Henderson <tomh@tomh.org>
parents:
10758
diff
changeset
|
701 |
m_setTRXState.Cancel (); |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
702 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
703 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
704 |
if (m_trxStatePending != IEEE_802_15_4_PHY_IDLE) |
10711 | 705 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
706 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
10711 | 707 |
} |
708 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
709 |
if (state == m_trxState) |
10711 | 710 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
711 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
10711 | 712 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
713 |
m_plmeSetTRXStateConfirmCallback (state); |
10711 | 714 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
715 |
return; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
716 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
717 |
|
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
718 |
if ( ((state == IEEE_802_15_4_PHY_RX_ON) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
719 |
|| (state == IEEE_802_15_4_PHY_TRX_OFF)) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
720 |
&& (m_trxState == IEEE_802_15_4_PHY_BUSY_TX) ) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
721 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
722 |
NS_LOG_DEBUG ("Phy is busy; setting state pending to " << state); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
723 |
m_trxStatePending = state; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
724 |
return; // Send PlmeSetTRXStateConfirm later |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
725 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
726 |
|
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
727 |
// specification talks about being in RX_ON and having received |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
728 |
// a valid SFD. Here, we are not modelling at that level of |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
729 |
// granularity, so we just test for BUSY_RX state (any part of |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
730 |
// a packet being actively received) |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
731 |
if (state == IEEE_802_15_4_PHY_TRX_OFF) |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
732 |
{ |
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
733 |
CancelEd (state); |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
734 |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
735 |
if ((m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
736 |
&& (m_currentRxPacket.first) && (!m_currentRxPacket.second)) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
737 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
738 |
NS_LOG_DEBUG ("Receiver has valid SFD; defer state change"); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
739 |
m_trxStatePending = state; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
740 |
return; // Send PlmeSetTRXStateConfirm later |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
741 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
742 |
else if (m_trxState == IEEE_802_15_4_PHY_RX_ON || m_trxState == IEEE_802_15_4_PHY_TX_ON) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
743 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
744 |
ChangeTrxState (IEEE_802_15_4_PHY_TRX_OFF); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
745 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
746 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
747 |
m_plmeSetTRXStateConfirmCallback (state); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
748 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
749 |
return; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
750 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
751 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
752 |
|
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
753 |
if (state == IEEE_802_15_4_PHY_TX_ON) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
754 |
{ |
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
755 |
CancelEd (state); |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
756 |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
757 |
NS_LOG_DEBUG ("turn on PHY_TX_ON"); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
758 |
if ((m_trxState == IEEE_802_15_4_PHY_BUSY_RX) || (m_trxState == IEEE_802_15_4_PHY_RX_ON)) |
10711 | 759 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
760 |
if (m_currentRxPacket.first) |
10711 | 761 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
762 |
//terminate reception if needed |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
763 |
//incomplete reception -- force packet discard |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
764 |
NS_LOG_DEBUG ("force TX_ON, terminate reception"); |
10711 | 765 |
m_currentRxPacket.second = true; |
766 |
} |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
767 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
768 |
// If CCA is in progress, cancel CCA and return BUSY. |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
769 |
if (!m_ccaRequest.IsExpired ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
770 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
771 |
m_ccaRequest.Cancel (); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
772 |
if (!m_plmeCcaConfirmCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
773 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
774 |
m_plmeCcaConfirmCallback (IEEE_802_15_4_PHY_BUSY); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
775 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
776 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
777 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
778 |
m_trxStatePending = IEEE_802_15_4_PHY_TX_ON; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
779 |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
780 |
// Delay for turnaround time |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
781 |
// TODO: Does it also take aTurnaroundTime to switch the transceiver state, |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
782 |
// even when the receiver is not busy? (6.9.2) |
10711 | 783 |
Time setTime = Seconds ( (double) aTurnaroundTime / GetDataOrSymbolRate (false)); |
784 |
m_setTRXState = Simulator::Schedule (setTime, &LrWpanPhy::EndSetTRXState, this); |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
785 |
return; |
10711 | 786 |
} |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
787 |
else if (m_trxState == IEEE_802_15_4_PHY_BUSY_TX || m_trxState == IEEE_802_15_4_PHY_TX_ON) |
10711 | 788 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
789 |
// We do NOT change the transceiver state here. We only report that |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
790 |
// the transceiver is already in TX_ON state. |
10711 | 791 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
792 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
793 |
m_plmeSetTRXStateConfirmCallback (IEEE_802_15_4_PHY_TX_ON); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
794 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
795 |
return; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
796 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
797 |
else if (m_trxState == IEEE_802_15_4_PHY_TRX_OFF) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
798 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
799 |
ChangeTrxState (IEEE_802_15_4_PHY_TX_ON); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
800 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
801 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
802 |
m_plmeSetTRXStateConfirmCallback (IEEE_802_15_4_PHY_TX_ON); |
10711 | 803 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
804 |
return; |
10711 | 805 |
} |
806 |
} |
|
807 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
808 |
if (state == IEEE_802_15_4_PHY_FORCE_TRX_OFF) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
809 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
810 |
if (m_trxState == IEEE_802_15_4_PHY_TRX_OFF) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
811 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
812 |
NS_LOG_DEBUG ("force TRX_OFF, was already off"); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
813 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
814 |
else |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
815 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
816 |
NS_LOG_DEBUG ("force TRX_OFF, SUCCESS"); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
817 |
if (m_currentRxPacket.first) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
818 |
{ //terminate reception if needed |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
819 |
//incomplete reception -- force packet discard |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
820 |
NS_LOG_DEBUG ("force TRX_OFF, terminate reception"); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
821 |
m_currentRxPacket.second = true; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
822 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
823 |
if (m_trxState == IEEE_802_15_4_PHY_BUSY_TX) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
824 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
825 |
NS_LOG_DEBUG ("force TRX_OFF, terminate transmission"); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
826 |
m_currentTxPacket.second = true; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
827 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
828 |
ChangeTrxState (IEEE_802_15_4_PHY_TRX_OFF); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
829 |
// Clear any other state |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
830 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
831 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
832 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
833 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
834 |
m_plmeSetTRXStateConfirmCallback (IEEE_802_15_4_PHY_SUCCESS); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
835 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
836 |
return; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
837 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
838 |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
839 |
if (state == IEEE_802_15_4_PHY_RX_ON) |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
840 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
841 |
if (m_trxState == IEEE_802_15_4_PHY_TX_ON || m_trxState == IEEE_802_15_4_PHY_TRX_OFF) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
842 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
843 |
// Turnaround delay |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
844 |
// TODO: Does it really take aTurnaroundTime to switch the transceiver state, |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
845 |
// even when the transmitter is not busy? (6.9.1) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
846 |
m_trxStatePending = IEEE_802_15_4_PHY_RX_ON; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
847 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
848 |
Time setTime = Seconds ( (double) aTurnaroundTime / GetDataOrSymbolRate (false)); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
849 |
m_setTRXState = Simulator::Schedule (setTime, &LrWpanPhy::EndSetTRXState, this); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
850 |
return; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
851 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
852 |
else if (m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
853 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
854 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
855 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
856 |
m_plmeSetTRXStateConfirmCallback (IEEE_802_15_4_PHY_RX_ON); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
857 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
858 |
return; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
859 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
860 |
} |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
861 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
862 |
NS_FATAL_ERROR ("Unexpected transition from state " << m_trxState << " to state " << state); |
10711 | 863 |
} |
864 |
||
865 |
bool |
|
866 |
LrWpanPhy::ChannelSupported (uint8_t channel) |
|
867 |
{ |
|
868 |
NS_LOG_FUNCTION (this << channel); |
|
869 |
bool retValue = false; |
|
870 |
||
871 |
for (uint32_t i = 0; i < 32; i++) |
|
872 |
{ |
|
873 |
if ((m_phyPIBAttributes.phyChannelsSupported[i] & (1 << channel)) != 0) |
|
874 |
{ |
|
875 |
retValue = true; |
|
876 |
break; |
|
877 |
} |
|
878 |
} |
|
879 |
||
880 |
return retValue; |
|
881 |
} |
|
882 |
||
883 |
void |
|
884 |
LrWpanPhy::PlmeSetAttributeRequest (LrWpanPibAttributeIdentifier id, |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
885 |
LrWpanPhyPibAttributes* attribute) |
10711 | 886 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
887 |
NS_LOG_FUNCTION (this << id << attribute); |
10711 | 888 |
NS_ASSERT (attribute); |
889 |
LrWpanPhyEnumeration status = IEEE_802_15_4_PHY_SUCCESS; |
|
890 |
||
891 |
switch (id) |
|
892 |
{ |
|
893 |
case phyCurrentChannel: |
|
894 |
{ |
|
895 |
if (!ChannelSupported (attribute->phyCurrentChannel)) |
|
896 |
{ |
|
897 |
status = IEEE_802_15_4_PHY_INVALID_PARAMETER; |
|
898 |
} |
|
899 |
if (m_phyPIBAttributes.phyCurrentChannel != attribute->phyCurrentChannel) |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
900 |
{ |
11232
865dcb3bf5a0
Bug 2025 - (lr-wpan) Changing the channel doesn't affect the Tx params
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11205
diff
changeset
|
901 |
// Cancel a pending transceiver state change. |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
902 |
// Switch off the transceiver. |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
903 |
// TODO: Is switching off the transceiver the right choice? |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
904 |
m_trxState = IEEE_802_15_4_PHY_TRX_OFF; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
905 |
if (m_trxStatePending != IEEE_802_15_4_PHY_IDLE) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
906 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
907 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
908 |
m_setTRXState.Cancel (); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
909 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
910 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
911 |
m_plmeSetTRXStateConfirmCallback (IEEE_802_15_4_PHY_TRX_OFF); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
912 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
913 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
914 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
915 |
// Any packet in transmission or reception will be corrupted. |
10711 | 916 |
if (m_currentRxPacket.first) |
917 |
{ |
|
918 |
m_currentRxPacket.second = true; |
|
919 |
} |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
920 |
if (PhyIsBusy ()) |
10711 | 921 |
{ |
922 |
m_currentTxPacket.second = true; |
|
923 |
m_pdDataRequest.Cancel (); |
|
924 |
m_currentTxPacket.first = 0; |
|
925 |
if (!m_pdDataConfirmCallback.IsNull ()) |
|
926 |
{ |
|
927 |
m_pdDataConfirmCallback (IEEE_802_15_4_PHY_TRX_OFF); |
|
928 |
} |
|
929 |
} |
|
930 |
m_phyPIBAttributes.phyCurrentChannel = attribute->phyCurrentChannel; |
|
11232
865dcb3bf5a0
Bug 2025 - (lr-wpan) Changing the channel doesn't affect the Tx params
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11205
diff
changeset
|
931 |
LrWpanSpectrumValueHelper psdHelper; |
865dcb3bf5a0
Bug 2025 - (lr-wpan) Changing the channel doesn't affect the Tx params
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11205
diff
changeset
|
932 |
m_txPsd = psdHelper.CreateTxPowerSpectralDensity (m_phyPIBAttributes.phyTransmitPower, m_phyPIBAttributes.phyCurrentChannel); |
10711 | 933 |
} |
934 |
break; |
|
935 |
} |
|
936 |
case phyChannelsSupported: |
|
937 |
{ // only the first element is considered in the array |
|
938 |
if ((attribute->phyChannelsSupported[0] & 0xf8000000) != 0) |
|
939 |
{ //5 MSBs reserved |
|
940 |
status = IEEE_802_15_4_PHY_INVALID_PARAMETER; |
|
941 |
} |
|
942 |
else |
|
943 |
{ |
|
944 |
m_phyPIBAttributes.phyChannelsSupported[0] = attribute->phyChannelsSupported[0]; |
|
945 |
} |
|
946 |
break; |
|
947 |
} |
|
948 |
case phyTransmitPower: |
|
949 |
{ |
|
950 |
if (attribute->phyTransmitPower > 0xbf) |
|
951 |
{ |
|
952 |
status = IEEE_802_15_4_PHY_INVALID_PARAMETER; |
|
953 |
} |
|
954 |
else |
|
955 |
{ |
|
956 |
m_phyPIBAttributes.phyTransmitPower = attribute->phyTransmitPower; |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
957 |
LrWpanSpectrumValueHelper psdHelper; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
958 |
m_txPsd = psdHelper.CreateTxPowerSpectralDensity (m_phyPIBAttributes.phyTransmitPower, m_phyPIBAttributes.phyCurrentChannel); |
10711 | 959 |
} |
960 |
break; |
|
961 |
} |
|
962 |
case phyCCAMode: |
|
963 |
{ |
|
964 |
if ((attribute->phyCCAMode < 1) || (attribute->phyCCAMode > 3)) |
|
965 |
{ |
|
966 |
status = IEEE_802_15_4_PHY_INVALID_PARAMETER; |
|
967 |
} |
|
968 |
else |
|
969 |
{ |
|
970 |
m_phyPIBAttributes.phyCCAMode = attribute->phyCCAMode; |
|
971 |
} |
|
972 |
break; |
|
973 |
} |
|
974 |
default: |
|
975 |
{ |
|
976 |
status = IEEE_802_15_4_PHY_UNSUPPORTED_ATTRIBUTE; |
|
977 |
break; |
|
978 |
} |
|
979 |
} |
|
980 |
||
981 |
if (!m_plmeSetAttributeConfirmCallback.IsNull ()) |
|
982 |
{ |
|
983 |
m_plmeSetAttributeConfirmCallback (status, id); |
|
984 |
} |
|
985 |
} |
|
986 |
||
987 |
void |
|
988 |
LrWpanPhy::SetPdDataIndicationCallback (PdDataIndicationCallback c) |
|
989 |
{ |
|
990 |
NS_LOG_FUNCTION (this); |
|
991 |
m_pdDataIndicationCallback = c; |
|
992 |
} |
|
993 |
||
994 |
void |
|
995 |
LrWpanPhy::SetPdDataConfirmCallback (PdDataConfirmCallback c) |
|
996 |
{ |
|
997 |
NS_LOG_FUNCTION (this); |
|
998 |
m_pdDataConfirmCallback = c; |
|
999 |
} |
|
1000 |
||
1001 |
void |
|
1002 |
LrWpanPhy::SetPlmeCcaConfirmCallback (PlmeCcaConfirmCallback c) |
|
1003 |
{ |
|
1004 |
NS_LOG_FUNCTION (this); |
|
1005 |
m_plmeCcaConfirmCallback = c; |
|
1006 |
} |
|
1007 |
||
1008 |
void |
|
1009 |
LrWpanPhy::SetPlmeEdConfirmCallback (PlmeEdConfirmCallback c) |
|
1010 |
{ |
|
1011 |
NS_LOG_FUNCTION (this); |
|
1012 |
m_plmeEdConfirmCallback = c; |
|
1013 |
} |
|
1014 |
||
1015 |
void |
|
1016 |
LrWpanPhy::SetPlmeGetAttributeConfirmCallback (PlmeGetAttributeConfirmCallback c) |
|
1017 |
{ |
|
1018 |
NS_LOG_FUNCTION (this); |
|
1019 |
m_plmeGetAttributeConfirmCallback = c; |
|
1020 |
} |
|
1021 |
||
1022 |
void |
|
1023 |
LrWpanPhy::SetPlmeSetTRXStateConfirmCallback (PlmeSetTRXStateConfirmCallback c) |
|
1024 |
{ |
|
1025 |
NS_LOG_FUNCTION (this); |
|
1026 |
m_plmeSetTRXStateConfirmCallback = c; |
|
1027 |
} |
|
1028 |
||
1029 |
void |
|
1030 |
LrWpanPhy::SetPlmeSetAttributeConfirmCallback (PlmeSetAttributeConfirmCallback c) |
|
1031 |
{ |
|
1032 |
NS_LOG_FUNCTION (this); |
|
1033 |
m_plmeSetAttributeConfirmCallback = c; |
|
1034 |
} |
|
1035 |
||
1036 |
void |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1037 |
LrWpanPhy::ChangeTrxState (LrWpanPhyEnumeration newState) |
10711 | 1038 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1039 |
NS_LOG_LOGIC (this << " state: " << m_trxState << " -> " << newState); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1040 |
m_trxStateLogger (Simulator::Now (), m_trxState, newState); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1041 |
m_trxState = newState; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1042 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1043 |
|
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1044 |
bool |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1045 |
LrWpanPhy::PhyIsBusy (void) const |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1046 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1047 |
NS_LOG_FUNCTION (this << m_trxState); |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1048 |
return ((m_trxState == IEEE_802_15_4_PHY_BUSY_TX) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1049 |
|| (m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1050 |
|| (m_trxState == IEEE_802_15_4_PHY_BUSY)); |
10711 | 1051 |
} |
1052 |
||
1053 |
void |
|
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1054 |
LrWpanPhy::CancelEd (LrWpanPhyEnumeration state) |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1055 |
{ |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1056 |
NS_LOG_FUNCTION (this); |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1057 |
NS_ASSERT (state == IEEE_802_15_4_PHY_TRX_OFF || state == IEEE_802_15_4_PHY_TX_ON); |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1058 |
|
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1059 |
if (!m_edRequest.IsExpired ()) |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1060 |
{ |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1061 |
m_edRequest.Cancel (); |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1062 |
if (!m_plmeEdConfirmCallback.IsNull ()) |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1063 |
{ |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1064 |
m_plmeEdConfirmCallback (state, 0); |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1065 |
} |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1066 |
} |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1067 |
} |
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1068 |
|
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1069 |
void |
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
1070 |
LrWpanPhy::EndEd (void) |
10711 | 1071 |
{ |
1072 |
NS_LOG_FUNCTION (this); |
|
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1073 |
|
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
1074 |
m_edPower.averagePower += LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd (), m_phyPIBAttributes.phyCurrentChannel) * (Simulator::Now () - m_edPower.lastUpdate).GetTimeStep () / m_edPower.measurementLength.GetTimeStep (); |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1075 |
|
10711 | 1076 |
uint8_t energyLevel; |
1077 |
||
1078 |
// Per IEEE802.15.4-2006 sec 6.9.7 |
|
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1079 |
double ratio = m_edPower.averagePower / m_rxSensitivity; |
10711 | 1080 |
ratio = 10.0 * log10 (ratio); |
1081 |
if (ratio <= 10.0) |
|
1082 |
{ // less than 10 dB |
|
1083 |
energyLevel = 0; |
|
1084 |
} |
|
1085 |
else if (ratio >= 40.0) |
|
1086 |
{ // less than 40 dB |
|
1087 |
energyLevel = 255; |
|
1088 |
} |
|
1089 |
else |
|
1090 |
{ |
|
1091 |
// in-between with linear increase per sec 6.9.7 |
|
10748
167fad4925ff
Bug fixes and test for energy detection code.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10747
diff
changeset
|
1092 |
energyLevel = static_cast<uint8_t> (((ratio - 10.0) / 30.0) * 255.0); |
10711 | 1093 |
} |
1094 |
||
1095 |
if (!m_plmeEdConfirmCallback.IsNull ()) |
|
1096 |
{ |
|
1097 |
m_plmeEdConfirmCallback (IEEE_802_15_4_PHY_SUCCESS, energyLevel); |
|
1098 |
} |
|
1099 |
} |
|
1100 |
||
1101 |
void |
|
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
1102 |
LrWpanPhy::EndCca (void) |
10711 | 1103 |
{ |
1104 |
NS_LOG_FUNCTION (this); |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1105 |
LrWpanPhyEnumeration sensedChannelState = IEEE_802_15_4_PHY_UNSPECIFIED; |
10711 | 1106 |
|
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1107 |
// Update peak power. |
11205
29b708f01eb1
bug 1774: compute signal power around channel, not across whole band
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
11086
diff
changeset
|
1108 |
double power = LrWpanSpectrumValueHelper::TotalAvgPower (m_signal->GetSignalPsd (), m_phyPIBAttributes.phyCurrentChannel); |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1109 |
if (m_ccaPeakPower < power) |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1110 |
{ |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1111 |
m_ccaPeakPower = power; |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1112 |
} |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1113 |
|
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1114 |
if (PhyIsBusy ()) |
10711 | 1115 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1116 |
sensedChannelState = IEEE_802_15_4_PHY_BUSY; |
10711 | 1117 |
} |
1118 |
else if (m_phyPIBAttributes.phyCCAMode == 1) |
|
1119 |
{ //sec 6.9.9 ED detection |
|
1120 |
// -- ED threshold at most 10 dB above receiver sensitivity. |
|
10811
31dbab5c8a28
bug 1924 - sensing radius and CCA
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10760
diff
changeset
|
1121 |
if (10 * log10 (m_ccaPeakPower / m_rxSensitivity) >= 10.0) |
10711 | 1122 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1123 |
sensedChannelState = IEEE_802_15_4_PHY_BUSY; |
10711 | 1124 |
} |
1125 |
else |
|
1126 |
{ |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1127 |
sensedChannelState = IEEE_802_15_4_PHY_IDLE; |
10711 | 1128 |
} |
1129 |
} |
|
1130 |
else if (m_phyPIBAttributes.phyCCAMode == 2) |
|
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1131 |
{ |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1132 |
//sec 6.9.9 carrier sense only |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1133 |
if (m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
10711 | 1134 |
{ |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1135 |
// We currently do not model PPDU reception in detail. Instead we model |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1136 |
// packet reception starting with the first bit of the preamble. |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1137 |
// Therefore, this code will never be reached, as PhyIsBusy() would |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1138 |
// already lead to a channel busy condition. |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1139 |
// TODO: Change this, if we also model preamble and SFD detection. |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1140 |
sensedChannelState = IEEE_802_15_4_PHY_BUSY; |
10711 | 1141 |
} |
1142 |
else |
|
1143 |
{ |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1144 |
sensedChannelState = IEEE_802_15_4_PHY_IDLE; |
10711 | 1145 |
} |
1146 |
} |
|
1147 |
else if (m_phyPIBAttributes.phyCCAMode == 3) |
|
1148 |
{ //sect 6.9.9 both |
|
10811
31dbab5c8a28
bug 1924 - sensing radius and CCA
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10760
diff
changeset
|
1149 |
if ((10 * log10 (m_ccaPeakPower / m_rxSensitivity) >= 10.0) |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1150 |
&& m_trxState == IEEE_802_15_4_PHY_BUSY_RX) |
10711 | 1151 |
{ |
10742
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1152 |
// Again, this code will never be reached, if we are already receiving |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1153 |
// a packet, as PhyIsBusy() would already lead to a channel busy condition. |
f44545c197c2
Make ED and CCA interference aware.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10740
diff
changeset
|
1154 |
// TODO: Change this, if we also model preamble and SFD detection. |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1155 |
sensedChannelState = IEEE_802_15_4_PHY_BUSY; |
10711 | 1156 |
} |
1157 |
else |
|
1158 |
{ |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1159 |
sensedChannelState = IEEE_802_15_4_PHY_IDLE; |
10711 | 1160 |
} |
1161 |
} |
|
1162 |
else |
|
1163 |
{ |
|
1164 |
NS_ASSERT_MSG (false, "Invalid CCA mode"); |
|
1165 |
} |
|
1166 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1167 |
NS_LOG_LOGIC (this << "channel sensed state: " << sensedChannelState); |
10711 | 1168 |
|
1169 |
if (!m_plmeCcaConfirmCallback.IsNull ()) |
|
1170 |
{ |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1171 |
m_plmeCcaConfirmCallback (sensedChannelState); |
10711 | 1172 |
} |
1173 |
} |
|
1174 |
||
1175 |
void |
|
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
1176 |
LrWpanPhy::EndSetTRXState (void) |
10711 | 1177 |
{ |
1178 |
NS_LOG_FUNCTION (this); |
|
1179 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1180 |
NS_ABORT_IF ( (m_trxStatePending != IEEE_802_15_4_PHY_RX_ON) && (m_trxStatePending != IEEE_802_15_4_PHY_TX_ON) ); |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1181 |
ChangeTrxState (m_trxStatePending); |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1182 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
10711 | 1183 |
|
1184 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
|
1185 |
{ |
|
1186 |
m_plmeSetTRXStateConfirmCallback (m_trxState); |
|
1187 |
} |
|
1188 |
} |
|
1189 |
||
1190 |
void |
|
10758
9ae6fc0e8032
Added firing of missing MAC TX trace sources.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10754
diff
changeset
|
1191 |
LrWpanPhy::EndTx (void) |
10711 | 1192 |
{ |
1193 |
NS_LOG_FUNCTION (this); |
|
1194 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1195 |
NS_ABORT_IF ( (m_trxState != IEEE_802_15_4_PHY_BUSY_TX) && (m_trxState != IEEE_802_15_4_PHY_TRX_OFF)); |
10711 | 1196 |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1197 |
if (m_currentTxPacket.second == false) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1198 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1199 |
NS_LOG_DEBUG ("Packet successfully transmitted"); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1200 |
m_phyTxEndTrace (m_currentTxPacket.first); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1201 |
if (!m_pdDataConfirmCallback.IsNull ()) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1202 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1203 |
m_pdDataConfirmCallback (IEEE_802_15_4_PHY_SUCCESS); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1204 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1205 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1206 |
else |
10711 | 1207 |
{ |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1208 |
NS_LOG_DEBUG ("Packet transmission aborted"); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1209 |
m_phyTxDropTrace (m_currentTxPacket.first); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1210 |
if (!m_pdDataConfirmCallback.IsNull ()) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1211 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1212 |
// See if this is ever entered in another state |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1213 |
NS_ASSERT (m_trxState == IEEE_802_15_4_PHY_TRX_OFF); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1214 |
m_pdDataConfirmCallback (m_trxState); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1215 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1216 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1217 |
m_currentTxPacket.first = 0; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1218 |
m_currentTxPacket.second = false; |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1219 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1220 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1221 |
// We may be waiting to apply a pending state change. |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1222 |
if (m_trxStatePending != IEEE_802_15_4_PHY_IDLE) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1223 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1224 |
// Only change the state immediately, if the transceiver is not already |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1225 |
// switching the state. |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1226 |
if (!m_setTRXState.IsRunning ()) |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1227 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1228 |
NS_LOG_LOGIC ("Apply pending state change to " << m_trxStatePending); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1229 |
ChangeTrxState (m_trxStatePending); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1230 |
m_trxStatePending = IEEE_802_15_4_PHY_IDLE; |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1231 |
if (!m_plmeSetTRXStateConfirmCallback.IsNull ()) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1232 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1233 |
m_plmeSetTRXStateConfirmCallback (IEEE_802_15_4_PHY_SUCCESS); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1234 |
} |
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1235 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1236 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1237 |
else |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1238 |
{ |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1239 |
if (m_trxState != IEEE_802_15_4_PHY_TRX_OFF) |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1240 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1241 |
ChangeTrxState (IEEE_802_15_4_PHY_TX_ON); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1242 |
} |
10711 | 1243 |
} |
1244 |
} |
|
1245 |
||
1246 |
Time |
|
1247 |
LrWpanPhy::CalculateTxTime (Ptr<const Packet> packet) |
|
1248 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1249 |
NS_LOG_FUNCTION (this << packet); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1250 |
|
10711 | 1251 |
bool isData = true; |
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
1252 |
Time txTime = GetPpduHeaderTxTime (); |
10711 | 1253 |
|
10730
3db83bcc026d
Tweaks to Rx values
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10729
diff
changeset
|
1254 |
txTime += Seconds (packet->GetSize () * 8.0 / GetDataOrSymbolRate (isData)); |
10711 | 1255 |
|
1256 |
return txTime; |
|
1257 |
} |
|
1258 |
||
1259 |
double |
|
1260 |
LrWpanPhy::GetDataOrSymbolRate (bool isData) |
|
1261 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1262 |
NS_LOG_FUNCTION (this << isData); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1263 |
|
10711 | 1264 |
double rate = 0.0; |
1265 |
||
1266 |
NS_ASSERT (m_phyOption < IEEE_802_15_4_INVALID_PHY_OPTION); |
|
1267 |
||
1268 |
if (isData) |
|
1269 |
{ |
|
1270 |
rate = dataSymbolRates [m_phyOption].bitRate; |
|
1271 |
} |
|
1272 |
else |
|
1273 |
{ |
|
1274 |
rate = dataSymbolRates [m_phyOption].symbolRate; |
|
1275 |
} |
|
1276 |
||
1277 |
return (rate * 1000.0); |
|
1278 |
} |
|
1279 |
||
10728
62d4098c1c22
First version with interference handling.
Sascha Jopen <jopen@cs.uni-bonn.de>
parents:
10722
diff
changeset
|
1280 |
Time |
10711 | 1281 |
LrWpanPhy::GetPpduHeaderTxTime (void) |
1282 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1283 |
NS_LOG_FUNCTION (this); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1284 |
|
10711 | 1285 |
bool isData = false; |
1286 |
double totalPpduHdrSymbols; |
|
1287 |
||
1288 |
NS_ASSERT (m_phyOption < IEEE_802_15_4_INVALID_PHY_OPTION); |
|
1289 |
||
1290 |
totalPpduHdrSymbols = ppduHeaderSymbolNumbers[m_phyOption].shrPreamble |
|
1291 |
+ ppduHeaderSymbolNumbers[m_phyOption].shrSfd |
|
1292 |
+ ppduHeaderSymbolNumbers[m_phyOption].phr; |
|
1293 |
||
10730
3db83bcc026d
Tweaks to Rx values
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10729
diff
changeset
|
1294 |
return Seconds (totalPpduHdrSymbols / GetDataOrSymbolRate (isData)); |
10711 | 1295 |
} |
1296 |
||
1297 |
// IEEE802.15.4-2006 Table 2 in section 6.1.2 |
|
1298 |
void |
|
1299 |
LrWpanPhy::SetMyPhyOption (void) |
|
1300 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1301 |
NS_LOG_FUNCTION (this); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1302 |
|
10711 | 1303 |
m_phyOption = IEEE_802_15_4_INVALID_PHY_OPTION; |
1304 |
||
1305 |
if (m_phyPIBAttributes.phyCurrentPage == 0) |
|
1306 |
{ |
|
1307 |
if (m_phyPIBAttributes.phyCurrentChannel == 0) |
|
1308 |
{ // 868 MHz BPSK |
|
1309 |
m_phyOption = IEEE_802_15_4_868MHZ_BPSK; |
|
1310 |
} |
|
1311 |
else if (m_phyPIBAttributes.phyCurrentChannel <= 10) |
|
1312 |
{ // 915 MHz BPSK |
|
1313 |
m_phyOption = IEEE_802_15_4_915MHZ_BPSK; |
|
1314 |
} |
|
1315 |
else if (m_phyPIBAttributes.phyCurrentChannel <= 26) |
|
1316 |
{ // 2.4 GHz MHz O-QPSK |
|
1317 |
m_phyOption = IEEE_802_15_4_2_4GHZ_OQPSK; |
|
1318 |
} |
|
1319 |
} |
|
1320 |
else if (m_phyPIBAttributes.phyCurrentPage == 1) |
|
1321 |
{ |
|
1322 |
if (m_phyPIBAttributes.phyCurrentChannel == 0) |
|
1323 |
{ // 868 MHz ASK |
|
1324 |
m_phyOption = IEEE_802_15_4_868MHZ_ASK; |
|
1325 |
} |
|
1326 |
else if (m_phyPIBAttributes.phyCurrentChannel <= 10) |
|
1327 |
{ // 915 MHz ASK |
|
1328 |
m_phyOption = IEEE_802_15_4_915MHZ_ASK; |
|
1329 |
} |
|
1330 |
} |
|
1331 |
else if (m_phyPIBAttributes.phyCurrentPage == 2) |
|
1332 |
{ |
|
1333 |
if (m_phyPIBAttributes.phyCurrentChannel == 0) |
|
1334 |
{ // 868 MHz O-QPSK |
|
1335 |
m_phyOption = IEEE_802_15_4_868MHZ_OQPSK; |
|
1336 |
} |
|
1337 |
else if (m_phyPIBAttributes.phyCurrentChannel <= 10) |
|
1338 |
{ // 915 MHz O-QPSK |
|
1339 |
m_phyOption = IEEE_802_15_4_915MHZ_OQPSK; |
|
1340 |
} |
|
1341 |
} |
|
1342 |
} |
|
1343 |
||
1344 |
LrWpanPhyOption |
|
1345 |
LrWpanPhy::GetMyPhyOption (void) |
|
1346 |
{ |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1347 |
NS_LOG_FUNCTION (this); |
10711 | 1348 |
return m_phyOption; |
1349 |
} |
|
1350 |
||
1351 |
void |
|
1352 |
LrWpanPhy::SetTxPowerSpectralDensity (Ptr<SpectrumValue> txPsd) |
|
1353 |
{ |
|
1354 |
NS_LOG_FUNCTION (this << txPsd); |
|
1355 |
NS_ASSERT (txPsd); |
|
1356 |
m_txPsd = txPsd; |
|
1357 |
NS_LOG_INFO ("\t computed tx_psd: " << *txPsd << "\t stored tx_psd: " << *m_txPsd); |
|
1358 |
} |
|
1359 |
||
1360 |
void |
|
1361 |
LrWpanPhy::SetNoisePowerSpectralDensity (Ptr<const SpectrumValue> noisePsd) |
|
1362 |
{ |
|
1363 |
NS_LOG_FUNCTION (this << noisePsd); |
|
1364 |
NS_LOG_INFO ("\t computed noise_psd: " << *noisePsd ); |
|
1365 |
NS_ASSERT (noisePsd); |
|
1366 |
m_noise = noisePsd; |
|
1367 |
} |
|
1368 |
||
1369 |
Ptr<const SpectrumValue> |
|
1370 |
LrWpanPhy::GetNoisePowerSpectralDensity (void) |
|
1371 |
{ |
|
1372 |
NS_LOG_FUNCTION (this); |
|
1373 |
return m_noise; |
|
1374 |
} |
|
1375 |
||
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1376 |
void |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1377 |
LrWpanPhy::SetErrorModel (Ptr<LrWpanErrorModel> e) |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1378 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1379 |
NS_LOG_FUNCTION (this << e); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1380 |
NS_ASSERT (e); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1381 |
m_errorModel = e; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1382 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1383 |
|
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1384 |
Ptr<LrWpanErrorModel> |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1385 |
LrWpanPhy::GetErrorModel (void) const |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1386 |
{ |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1387 |
NS_LOG_FUNCTION (this); |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1388 |
return m_errorModel; |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1389 |
} |
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
1390 |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1391 |
uint64_t |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1392 |
LrWpanPhy::GetPhySHRDuration (void) const |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1393 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1394 |
NS_LOG_FUNCTION (this); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1395 |
NS_ASSERT (m_phyOption < IEEE_802_15_4_INVALID_PHY_OPTION); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1396 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1397 |
return ppduHeaderSymbolNumbers[m_phyOption].shrPreamble |
10760
d7d73e3ceb3c
Apply utils/check-style.py script on lr-wpan source code again
Tom Henderson <tomh@tomh.org>
parents:
10758
diff
changeset
|
1398 |
+ ppduHeaderSymbolNumbers[m_phyOption].shrSfd; |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1399 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1400 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1401 |
double |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1402 |
LrWpanPhy::GetPhySymbolsPerOctet (void) const |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1403 |
{ |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1404 |
NS_LOG_FUNCTION (this); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1405 |
NS_ASSERT (m_phyOption < IEEE_802_15_4_INVALID_PHY_OPTION); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1406 |
|
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1407 |
return dataSymbolRates [m_phyOption].symbolRate / (dataSymbolRates [m_phyOption].bitRate / 8); |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1408 |
} |
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10714
diff
changeset
|
1409 |
|
10754
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1410 |
int64_t |
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1411 |
LrWpanPhy::AssignStreams (int64_t stream) |
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1412 |
{ |
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1413 |
NS_LOG_FUNCTION (this); |
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1414 |
m_random->SetStream (stream); |
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1415 |
return 1; |
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1416 |
} |
e02848bde991
enable assignment of lr-wpan random variable stream indices
Tom Henderson <tomh@tomh.org>
parents:
10750
diff
changeset
|
1417 |
|
10711 | 1418 |
} // namespace ns3 |