6622
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
|
2 |
/*
|
|
3 |
* Copyright (c) 2009 University of Washington
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License version 2 as
|
|
7 |
* published by the Free Software Foundation;
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
*
|
|
18 |
* Author: Leonard Tracy <lentracy@gmail.com>
|
|
19 |
*/
|
|
20 |
|
|
21 |
#include "uan-phy.h"
|
|
22 |
#include "uan-phy-dual.h"
|
|
23 |
#include "uan-phy-gen.h"
|
|
24 |
#include "uan-tx-mode.h"
|
|
25 |
#include "uan-net-device.h"
|
|
26 |
#include "uan-channel.h"
|
|
27 |
#include "ns3/double.h"
|
|
28 |
#include "ns3/log.h"
|
|
29 |
#include "ns3/ptr.h"
|
|
30 |
#include "ns3/traced-callback.h"
|
|
31 |
#include "ns3/trace-source-accessor.h"
|
|
32 |
#include "ns3/simulator.h"
|
|
33 |
#include "uan-header-common.h"
|
|
34 |
#include "uan-mac-rc.h"
|
|
35 |
|
|
36 |
#include <cmath>
|
|
37 |
|
|
38 |
|
|
39 |
NS_LOG_COMPONENT_DEFINE ("UanPhyDual");
|
|
40 |
|
|
41 |
namespace ns3 {
|
|
42 |
namespace uan {
|
|
43 |
|
|
44 |
NS_OBJECT_ENSURE_REGISTERED (UanPhyDual);
|
|
45 |
NS_OBJECT_ENSURE_REGISTERED (UanPhyCalcSinrDual);
|
|
46 |
|
|
47 |
UanPhyCalcSinrDual::UanPhyCalcSinrDual ()
|
|
48 |
{
|
|
49 |
|
|
50 |
}
|
|
51 |
UanPhyCalcSinrDual::~UanPhyCalcSinrDual ()
|
|
52 |
{
|
|
53 |
|
|
54 |
}
|
|
55 |
|
|
56 |
TypeId
|
|
57 |
UanPhyCalcSinrDual::GetTypeId (void)
|
|
58 |
{
|
|
59 |
static TypeId tid = TypeId ("ns3::UanPhyCalcSinrDual")
|
|
60 |
.SetParent<Object> ()
|
|
61 |
.AddConstructor<UanPhyCalcSinrDual> ()
|
|
62 |
;
|
|
63 |
return tid;
|
|
64 |
}
|
|
65 |
|
|
66 |
double
|
|
67 |
UanPhyCalcSinrDual::CalcSinrDb (Ptr<Packet> pkt,
|
|
68 |
Time arrTime,
|
|
69 |
double rxPowerDb,
|
|
70 |
double ambNoiseDb,
|
|
71 |
UanTxMode mode,
|
|
72 |
UanPdp pdp,
|
|
73 |
const UanTransducer::ArrivalList &arrivalList) const
|
|
74 |
{
|
|
75 |
|
|
76 |
if (mode.GetModType () != UanTxMode::OTHER)
|
|
77 |
{
|
|
78 |
NS_LOG_WARN ("Calculating SINR for unsupported modulation type");
|
|
79 |
}
|
|
80 |
|
|
81 |
double intKp = -DbToKp (rxPowerDb); // This packet is in the arrivalList
|
|
82 |
UanTransducer::ArrivalList::const_iterator it = arrivalList.begin ();
|
|
83 |
for (; it != arrivalList.end (); it++)
|
|
84 |
{
|
|
85 |
// Only count interference if there is overlap in incoming frequency
|
|
86 |
if (std::abs ( (double) it->GetTxMode ().GetCenterFreqHz () - (double) mode.GetCenterFreqHz ())
|
|
87 |
< (double)(it->GetTxMode ().GetBandwidthHz () / 2 + mode.GetBandwidthHz () / 2) - 0.5)
|
|
88 |
{
|
|
89 |
UanHeaderCommon ch, ch2;
|
|
90 |
if (pkt)
|
|
91 |
{
|
|
92 |
pkt->PeekHeader (ch);
|
|
93 |
}
|
|
94 |
it->GetPacket ()->PeekHeader (ch2);
|
|
95 |
|
|
96 |
if (pkt)
|
|
97 |
{
|
|
98 |
if (ch.GetType () == UanMacRc::TYPE_DATA)
|
|
99 |
{
|
|
100 |
NS_LOG_DEBUG ("Adding interferer from " << ch2.GetSrc () << " against " << ch.GetSrc () << ": PktRxMode: "
|
|
101 |
<< mode.GetName () << " Int mode: " << it->GetTxMode ().GetName () << " Separation: "
|
|
102 |
<< std::abs ( (double) it->GetTxMode ().GetCenterFreqHz () - (double) mode.GetCenterFreqHz ())
|
|
103 |
<< " Combined bandwidths: " << (double)(it->GetTxMode ().GetBandwidthHz () / 2 + mode.GetBandwidthHz () / 2) - 0.5);
|
|
104 |
}
|
|
105 |
}
|
|
106 |
intKp += DbToKp (it->GetRxPowerDb ());
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
double totalIntDb = KpToDb (intKp + DbToKp (ambNoiseDb));
|
|
111 |
|
|
112 |
NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Calculating SINR: RxPower = " << rxPowerDb << " dB. Number of interferers = " << arrivalList.size () << " Interference + noise power = " << totalIntDb << " dB. SINR = " << rxPowerDb - totalIntDb << " dB.");
|
|
113 |
return rxPowerDb - totalIntDb;
|
|
114 |
}
|
|
115 |
|
|
116 |
UanPhyDual::UanPhyDual ()
|
|
117 |
: UanPhy ()
|
|
118 |
{
|
|
119 |
|
|
120 |
m_phy1 = CreateObject<UanPhyGen> ();
|
|
121 |
m_phy2 = CreateObject<UanPhyGen> ();
|
|
122 |
|
|
123 |
m_phy1->SetReceiveOkCallback (m_recOkCb);
|
|
124 |
m_phy2->SetReceiveOkCallback (m_recOkCb);
|
|
125 |
|
|
126 |
m_phy1->SetReceiveErrorCallback (m_recErrCb);
|
|
127 |
m_phy2->SetReceiveErrorCallback (m_recErrCb);
|
|
128 |
|
|
129 |
}
|
|
130 |
|
|
131 |
UanPhyDual::~UanPhyDual ()
|
|
132 |
{
|
|
133 |
}
|
|
134 |
|
|
135 |
void
|
|
136 |
UanPhyDual::Clear ()
|
|
137 |
{
|
|
138 |
if (m_phy1)
|
|
139 |
{
|
|
140 |
m_phy1->Clear ();
|
|
141 |
m_phy1 = 0;
|
|
142 |
}
|
|
143 |
if (m_phy2)
|
|
144 |
{
|
|
145 |
m_phy2->Clear ();
|
|
146 |
m_phy2 = 0;
|
|
147 |
}
|
|
148 |
}
|
|
149 |
void
|
|
150 |
UanPhyDual::DoDispose ()
|
|
151 |
{
|
|
152 |
Clear ();
|
|
153 |
UanPhy::DoDispose ();
|
|
154 |
}
|
|
155 |
|
|
156 |
TypeId
|
|
157 |
UanPhyDual::GetTypeId (void)
|
|
158 |
{
|
|
159 |
static TypeId tid = TypeId ("ns3::UanPhyDual")
|
|
160 |
.SetParent<UanPhy> ()
|
|
161 |
.AddConstructor<UanPhyDual> ()
|
|
162 |
.AddAttribute ("CcaThresholdPhy1",
|
|
163 |
"Aggregate energy of incoming signals to move to CCA Busy state dB of Phy1",
|
|
164 |
DoubleValue (10),
|
|
165 |
MakeDoubleAccessor (&UanPhyDual::GetCcaThresholdPhy1, &UanPhyDual::SetCcaThresholdPhy1),
|
|
166 |
MakeDoubleChecker<double> ())
|
|
167 |
.AddAttribute ("CcaThresholdPhy2",
|
|
168 |
"Aggregate energy of incoming signals to move to CCA Busy state dB of Phy2",
|
|
169 |
DoubleValue (10),
|
|
170 |
MakeDoubleAccessor (&UanPhyDual::GetCcaThresholdPhy2, &UanPhyDual::SetCcaThresholdPhy2),
|
|
171 |
MakeDoubleChecker<double> ())
|
|
172 |
.AddAttribute ("TxPowerPhy1",
|
|
173 |
"Transmission output power in dB of Phy1",
|
|
174 |
DoubleValue (190),
|
|
175 |
MakeDoubleAccessor (&UanPhyDual::GetTxPowerDbPhy1, &UanPhyDual::SetTxPowerDbPhy1),
|
|
176 |
MakeDoubleChecker<double> ())
|
|
177 |
.AddAttribute ("TxPowerPhy2",
|
|
178 |
"Transmission output power in dB of Phy2",
|
|
179 |
DoubleValue (190),
|
|
180 |
MakeDoubleAccessor (&UanPhyDual::GetTxPowerDbPhy2, &UanPhyDual::SetTxPowerDbPhy2),
|
|
181 |
MakeDoubleChecker<double> ())
|
|
182 |
.AddAttribute ("RxGainPhy1",
|
|
183 |
"Gain added to incoming signal at receiver of Phy1",
|
|
184 |
DoubleValue (0),
|
|
185 |
MakeDoubleAccessor (&UanPhyDual::GetRxGainDbPhy1, &UanPhyDual::SetRxGainDbPhy1),
|
|
186 |
MakeDoubleChecker<double> ())
|
|
187 |
.AddAttribute ("RxGainPhy2",
|
|
188 |
"Gain added to incoming signal at receiver of Phy2",
|
|
189 |
DoubleValue (0),
|
|
190 |
MakeDoubleAccessor (&UanPhyDual::GetRxGainDbPhy2, &UanPhyDual::SetRxGainDbPhy2),
|
|
191 |
MakeDoubleChecker<double> ())
|
|
192 |
.AddAttribute ("SupportedModesPhy1",
|
|
193 |
"List of modes supported by Phy1",
|
|
194 |
UanModesListValue (UanPhyGen::GetDefaultModes ()),
|
|
195 |
MakeUanModesListAccessor (&UanPhyDual::GetModesPhy1, &UanPhyDual::SetModesPhy1),
|
|
196 |
MakeUanModesListChecker () )
|
|
197 |
.AddAttribute ("SupportedModesPhy2",
|
|
198 |
"List of modes supported by Phy2",
|
|
199 |
UanModesListValue (UanPhyGen::GetDefaultModes ()),
|
|
200 |
MakeUanModesListAccessor (&UanPhyDual::GetModesPhy2, &UanPhyDual::SetModesPhy2),
|
|
201 |
MakeUanModesListChecker () )
|
|
202 |
.AddAttribute ("PerModelPhy1",
|
|
203 |
"Functor to calculate PER based on SINR and TxMode for Phy1",
|
|
204 |
PointerValue (CreateObject<UanPhyPerGenDefault> ()),
|
|
205 |
MakePointerAccessor (&UanPhyDual::GetPerModelPhy1, &UanPhyDual::SetPerModelPhy1),
|
|
206 |
MakePointerChecker<UanPhyPer> ())
|
|
207 |
.AddAttribute ("PerModelPhy2",
|
|
208 |
"Functor to calculate PER based on SINR and TxMode for Phy2",
|
|
209 |
PointerValue (CreateObject<UanPhyPerGenDefault> ()),
|
|
210 |
MakePointerAccessor (&UanPhyDual::GetPerModelPhy2, &UanPhyDual::SetPerModelPhy2),
|
|
211 |
MakePointerChecker<UanPhyPer> ())
|
|
212 |
.AddAttribute ("SinrModelPhy1",
|
|
213 |
"Functor to calculate SINR based on pkt arrivals and modes for Phy1",
|
|
214 |
PointerValue (CreateObject<UanPhyCalcSinrDual> ()),
|
|
215 |
MakePointerAccessor (&UanPhyDual::GetSinrModelPhy1, &UanPhyDual::SetSinrModelPhy1),
|
|
216 |
MakePointerChecker<UanPhyCalcSinr> ())
|
|
217 |
.AddAttribute ("SinrModelPhy2",
|
|
218 |
"Functor to calculate SINR based on pkt arrivals and modes for Phy2",
|
|
219 |
PointerValue (CreateObject<UanPhyCalcSinrDual> ()),
|
|
220 |
MakePointerAccessor (&UanPhyDual::GetSinrModelPhy2, &UanPhyDual::SetSinrModelPhy2),
|
|
221 |
MakePointerChecker<UanPhyCalcSinr> ())
|
|
222 |
.AddTraceSource ("RxOk",
|
|
223 |
"A packet was received successfully",
|
|
224 |
MakeTraceSourceAccessor (&UanPhyDual::m_rxOkLogger))
|
|
225 |
.AddTraceSource ("RxError",
|
|
226 |
"A packet was received unsuccessfully",
|
|
227 |
MakeTraceSourceAccessor (&UanPhyDual::m_rxErrLogger))
|
|
228 |
.AddTraceSource ("Tx",
|
|
229 |
"Packet transmission beginning",
|
|
230 |
MakeTraceSourceAccessor (&UanPhyDual::m_txLogger))
|
|
231 |
|
|
232 |
;
|
|
233 |
|
|
234 |
return tid;
|
|
235 |
}
|
|
236 |
|
|
237 |
void
|
|
238 |
UanPhyDual::SendPacket (Ptr<Packet> pkt, uint32_t modeNum)
|
|
239 |
{
|
|
240 |
if (modeNum <= m_phy1->GetNModes () - 1)
|
|
241 |
{
|
|
242 |
NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Sending packet on Phy1 with mode number " << modeNum);
|
|
243 |
m_txLogger (pkt, m_phy1->GetTxPowerDb (), m_phy1->GetMode (modeNum));
|
|
244 |
m_phy1->SendPacket (pkt, modeNum);
|
|
245 |
|
|
246 |
}
|
|
247 |
else
|
|
248 |
{
|
|
249 |
NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Sending packet on Phy2 with mode number " << modeNum - m_phy1->GetNModes ());
|
|
250 |
m_txLogger (pkt, m_phy2->GetTxPowerDb (), m_phy2->GetMode (modeNum - m_phy1->GetNModes ()));
|
|
251 |
m_phy2->SendPacket (pkt, modeNum - m_phy1->GetNModes ());
|
|
252 |
}
|
|
253 |
}
|
|
254 |
void
|
|
255 |
UanPhyDual::RegisterListener (UanPhyListener *listener)
|
|
256 |
{
|
|
257 |
m_phy1->RegisterListener (listener);
|
|
258 |
m_phy2->RegisterListener (listener);
|
|
259 |
}
|
|
260 |
|
|
261 |
void
|
|
262 |
UanPhyDual::StartRxPacket (Ptr<Packet> pkt, double rxPowerDb, UanTxMode txMode, UanPdp pdp)
|
|
263 |
{
|
|
264 |
// Not called. StartRxPacket in m_phy1 and m_phy2 are called directly from Transducer.
|
|
265 |
}
|
|
266 |
|
|
267 |
void
|
|
268 |
UanPhyDual::SetReceiveOkCallback (RxOkCallback cb)
|
|
269 |
{
|
|
270 |
m_phy1->SetReceiveOkCallback (cb);
|
|
271 |
m_phy2->SetReceiveOkCallback (cb);
|
|
272 |
}
|
|
273 |
|
|
274 |
void
|
|
275 |
UanPhyDual::SetReceiveErrorCallback (RxErrCallback cb)
|
|
276 |
{
|
|
277 |
m_phy1->SetReceiveErrorCallback (cb);
|
|
278 |
m_phy2->SetReceiveErrorCallback (cb);
|
|
279 |
}
|
|
280 |
|
|
281 |
void
|
|
282 |
UanPhyDual::SetRxGainDb (double gain)
|
|
283 |
{
|
|
284 |
m_phy1->SetRxGainDb (gain);
|
|
285 |
m_phy2->SetRxGainDb (gain);
|
|
286 |
}
|
|
287 |
void
|
|
288 |
UanPhyDual::SetRxGainDbPhy1 (double gain)
|
|
289 |
{
|
|
290 |
m_phy1->SetRxGainDb (gain);
|
|
291 |
}
|
|
292 |
|
|
293 |
void
|
|
294 |
UanPhyDual::SetRxGainDbPhy2 (double gain)
|
|
295 |
{
|
|
296 |
m_phy2->SetRxGainDb (gain);
|
|
297 |
}
|
|
298 |
|
|
299 |
void
|
|
300 |
UanPhyDual::SetTxPowerDb (double txpwr)
|
|
301 |
{
|
|
302 |
m_phy1->SetTxPowerDb (txpwr);
|
|
303 |
m_phy2->SetTxPowerDb (txpwr);
|
|
304 |
}
|
|
305 |
|
|
306 |
void
|
|
307 |
UanPhyDual::SetTxPowerDbPhy1 (double txpwr)
|
|
308 |
{
|
|
309 |
m_phy1->SetTxPowerDb (txpwr);
|
|
310 |
}
|
|
311 |
void
|
|
312 |
UanPhyDual::SetTxPowerDbPhy2 (double txpwr)
|
|
313 |
{
|
|
314 |
m_phy2->SetTxPowerDb (txpwr);
|
|
315 |
}
|
|
316 |
|
|
317 |
void
|
|
318 |
UanPhyDual::SetRxThresholdDb (double thresh)
|
|
319 |
{
|
|
320 |
NS_LOG_WARN ("SetRxThresholdDb is deprecated and has no effect. Look at PER Functor attribute");
|
|
321 |
m_phy1->SetRxThresholdDb (thresh);
|
|
322 |
m_phy2->SetRxThresholdDb (thresh);
|
|
323 |
}
|
|
324 |
void
|
|
325 |
UanPhyDual::SetCcaThresholdDb (double thresh)
|
|
326 |
{
|
|
327 |
m_phy1->SetCcaThresholdDb (thresh);
|
|
328 |
m_phy2->SetCcaThresholdDb (thresh);
|
|
329 |
}
|
|
330 |
|
|
331 |
void
|
|
332 |
UanPhyDual::SetCcaThresholdPhy1 (double thresh)
|
|
333 |
{
|
|
334 |
m_phy1->SetCcaThresholdDb (thresh);
|
|
335 |
}
|
|
336 |
void
|
|
337 |
UanPhyDual::SetCcaThresholdPhy2 (double thresh)
|
|
338 |
{
|
|
339 |
m_phy2->SetCcaThresholdDb (thresh);
|
|
340 |
}
|
|
341 |
|
|
342 |
double
|
|
343 |
UanPhyDual::GetRxGainDb (void)
|
|
344 |
{
|
|
345 |
NS_LOG_WARN ("Warning: UanPhyDual::GetRxGainDb returns RxGain of Phy 1");
|
|
346 |
return m_phy1->GetRxGainDb ();
|
|
347 |
}
|
|
348 |
double
|
|
349 |
UanPhyDual::GetRxGainDbPhy1 (void) const
|
|
350 |
{
|
|
351 |
return m_phy1->GetRxGainDb ();
|
|
352 |
}
|
|
353 |
double
|
|
354 |
UanPhyDual::GetRxGainDbPhy2 (void) const
|
|
355 |
{
|
|
356 |
return m_phy2->GetRxGainDb ();
|
|
357 |
}
|
|
358 |
|
|
359 |
double
|
|
360 |
UanPhyDual::GetTxPowerDb (void)
|
|
361 |
{
|
|
362 |
NS_LOG_WARN ("Warning: Dual Phy only returns TxPowerDb of Phy 1");
|
|
363 |
return m_phy1->GetTxPowerDb ();
|
|
364 |
}
|
|
365 |
|
|
366 |
double
|
|
367 |
UanPhyDual::GetTxPowerDbPhy1 (void) const
|
|
368 |
{
|
|
369 |
return m_phy1->GetTxPowerDb ();
|
|
370 |
}
|
|
371 |
|
|
372 |
double
|
|
373 |
UanPhyDual::GetTxPowerDbPhy2 (void) const
|
|
374 |
{
|
|
375 |
return m_phy2->GetTxPowerDb ();
|
|
376 |
}
|
|
377 |
|
|
378 |
double
|
|
379 |
UanPhyDual::GetRxThresholdDb (void)
|
|
380 |
{
|
|
381 |
return m_phy1->GetRxThresholdDb ();
|
|
382 |
}
|
|
383 |
|
|
384 |
double
|
|
385 |
UanPhyDual::GetCcaThresholdDb (void)
|
|
386 |
{
|
|
387 |
NS_LOG_WARN ("Dual Phy only returns CCAThreshold of Phy 1");
|
|
388 |
return m_phy1->GetCcaThresholdDb ();
|
|
389 |
}
|
|
390 |
double
|
|
391 |
UanPhyDual::GetCcaThresholdPhy1 (void) const
|
|
392 |
{
|
|
393 |
return m_phy1->GetCcaThresholdDb ();
|
|
394 |
}
|
|
395 |
double
|
|
396 |
UanPhyDual::GetCcaThresholdPhy2 (void) const
|
|
397 |
{
|
|
398 |
return m_phy2->GetCcaThresholdDb ();
|
|
399 |
}
|
|
400 |
|
|
401 |
bool
|
|
402 |
UanPhyDual::IsPhy1Idle (void)
|
|
403 |
{
|
|
404 |
return m_phy1->IsStateIdle ();
|
|
405 |
}
|
|
406 |
bool
|
|
407 |
UanPhyDual::IsPhy2Idle (void)
|
|
408 |
{
|
|
409 |
return m_phy2->IsStateIdle ();
|
|
410 |
}
|
|
411 |
|
|
412 |
bool
|
|
413 |
UanPhyDual::IsPhy1Rx (void)
|
|
414 |
{
|
|
415 |
return m_phy1->IsStateRx ();
|
|
416 |
}
|
|
417 |
|
|
418 |
bool
|
|
419 |
UanPhyDual::IsPhy2Rx (void)
|
|
420 |
{
|
|
421 |
return m_phy2->IsStateRx ();
|
|
422 |
}
|
|
423 |
|
|
424 |
bool
|
|
425 |
UanPhyDual::IsPhy1Tx (void)
|
|
426 |
{
|
|
427 |
return m_phy1->IsStateTx ();
|
|
428 |
}
|
|
429 |
|
|
430 |
Ptr<Packet>
|
|
431 |
UanPhyDual::GetPhy1PacketRx (void) const
|
|
432 |
{
|
|
433 |
return m_phy1->GetPacketRx ();
|
|
434 |
}
|
|
435 |
|
|
436 |
Ptr<Packet>
|
|
437 |
UanPhyDual::GetPhy2PacketRx (void) const
|
|
438 |
{
|
|
439 |
return m_phy2->GetPacketRx ();
|
|
440 |
}
|
|
441 |
|
|
442 |
bool
|
|
443 |
UanPhyDual::IsPhy2Tx (void)
|
|
444 |
{
|
|
445 |
return m_phy2->IsStateTx ();
|
|
446 |
}
|
|
447 |
|
|
448 |
bool
|
|
449 |
UanPhyDual::IsStateIdle (void)
|
|
450 |
{
|
|
451 |
return m_phy1->IsStateIdle () && m_phy2->IsStateIdle ();
|
|
452 |
}
|
|
453 |
bool
|
|
454 |
UanPhyDual::IsStateBusy (void)
|
|
455 |
{
|
|
456 |
return !IsStateIdle ();
|
|
457 |
}
|
|
458 |
bool
|
|
459 |
UanPhyDual::IsStateRx (void)
|
|
460 |
{
|
|
461 |
return m_phy1->IsStateRx () || m_phy2->IsStateRx ();
|
|
462 |
}
|
|
463 |
bool
|
|
464 |
UanPhyDual::IsStateTx (void)
|
|
465 |
{
|
|
466 |
return m_phy1->IsStateTx () || m_phy2->IsStateTx ();
|
|
467 |
}
|
|
468 |
bool
|
|
469 |
UanPhyDual::IsStateCcaBusy (void)
|
|
470 |
{
|
|
471 |
return m_phy1->IsStateCcaBusy () || m_phy2->IsStateCcaBusy ();
|
|
472 |
}
|
|
473 |
Ptr<UanChannel>
|
|
474 |
UanPhyDual::GetChannel (void) const
|
|
475 |
{
|
|
476 |
return m_phy1->GetChannel ();
|
|
477 |
}
|
|
478 |
Ptr<UanNetDevice>
|
|
479 |
UanPhyDual::GetDevice (void)
|
|
480 |
{
|
|
481 |
return m_phy1->GetDevice ();
|
|
482 |
}
|
|
483 |
void
|
|
484 |
UanPhyDual::SetChannel (Ptr<UanChannel> channel)
|
|
485 |
{
|
|
486 |
m_phy1->SetChannel (channel);
|
|
487 |
m_phy2->SetChannel (channel);
|
|
488 |
}
|
|
489 |
void
|
|
490 |
UanPhyDual::SetDevice (Ptr<UanNetDevice> device)
|
|
491 |
{
|
|
492 |
m_phy1->SetDevice (device);
|
|
493 |
m_phy2->SetDevice (device);
|
|
494 |
}
|
|
495 |
void
|
|
496 |
UanPhyDual::SetMac (Ptr<UanMac> mac)
|
|
497 |
{
|
|
498 |
m_phy1->SetMac (mac);
|
|
499 |
m_phy2->SetMac (mac);
|
|
500 |
}
|
|
501 |
void
|
|
502 |
UanPhyDual::NotifyTransStartTx (Ptr<Packet> packet, double txPowerDb, UanTxMode txMode)
|
|
503 |
{
|
|
504 |
|
|
505 |
}
|
|
506 |
void
|
|
507 |
UanPhyDual::NotifyIntChange (void)
|
|
508 |
{
|
|
509 |
m_phy1->NotifyIntChange ();
|
|
510 |
m_phy2->NotifyIntChange ();
|
|
511 |
|
|
512 |
}
|
|
513 |
void
|
|
514 |
UanPhyDual::SetTransducer (Ptr<UanTransducer> trans)
|
|
515 |
{
|
|
516 |
m_phy1->SetTransducer (trans);
|
|
517 |
m_phy2->SetTransducer (trans);
|
|
518 |
}
|
|
519 |
Ptr<UanTransducer>
|
|
520 |
UanPhyDual::GetTransducer (void)
|
|
521 |
{
|
|
522 |
NS_LOG_WARN ("DualPhy Returning transducer of Phy1");
|
|
523 |
return m_phy1->GetTransducer ();
|
|
524 |
}
|
|
525 |
uint32_t
|
|
526 |
UanPhyDual::GetNModes (void)
|
|
527 |
{
|
|
528 |
return m_phy1->GetNModes () + m_phy2->GetNModes ();
|
|
529 |
}
|
|
530 |
UanTxMode
|
|
531 |
UanPhyDual::GetMode (uint32_t n)
|
|
532 |
{
|
|
533 |
if (n < m_phy1->GetNModes ())
|
|
534 |
{
|
|
535 |
return m_phy1->GetMode (n);
|
|
536 |
}
|
|
537 |
else
|
|
538 |
{
|
|
539 |
return m_phy2->GetMode (n - m_phy1->GetNModes ());
|
|
540 |
}
|
|
541 |
}
|
|
542 |
|
|
543 |
UanModesList
|
|
544 |
UanPhyDual::GetModesPhy1 (void) const
|
|
545 |
{
|
|
546 |
|
|
547 |
UanModesListValue modeValue;
|
|
548 |
m_phy1->GetAttribute ("SupportedModes", modeValue);
|
|
549 |
return modeValue.Get ();
|
|
550 |
}
|
|
551 |
|
|
552 |
UanModesList
|
|
553 |
UanPhyDual::GetModesPhy2 (void) const
|
|
554 |
{
|
|
555 |
UanModesListValue modeValue;
|
|
556 |
m_phy2->GetAttribute ("SupportedModes", modeValue);
|
|
557 |
return modeValue.Get ();
|
|
558 |
}
|
|
559 |
|
|
560 |
void
|
|
561 |
UanPhyDual::SetModesPhy1 (UanModesList modes)
|
|
562 |
{
|
|
563 |
m_phy1->SetAttribute ("SupportedModes", UanModesListValue (modes));
|
|
564 |
}
|
|
565 |
|
|
566 |
void
|
|
567 |
UanPhyDual::SetModesPhy2 (UanModesList modes)
|
|
568 |
{
|
|
569 |
m_phy2->SetAttribute ("SupportedModes", UanModesListValue (modes));
|
|
570 |
}
|
|
571 |
|
|
572 |
Ptr<UanPhyPer>
|
|
573 |
UanPhyDual::GetPerModelPhy1 (void) const
|
|
574 |
{
|
|
575 |
PointerValue perValue;
|
|
576 |
m_phy1->GetAttribute ("PerModel", perValue);
|
|
577 |
return perValue;
|
|
578 |
}
|
|
579 |
|
|
580 |
Ptr<UanPhyPer>
|
|
581 |
UanPhyDual::GetPerModelPhy2 (void) const
|
|
582 |
{
|
|
583 |
PointerValue perValue;
|
|
584 |
m_phy2->GetAttribute ("PerModel", perValue);
|
|
585 |
return perValue;
|
|
586 |
}
|
|
587 |
|
|
588 |
void
|
|
589 |
UanPhyDual::SetPerModelPhy1 (Ptr<UanPhyPer> per)
|
|
590 |
{
|
|
591 |
m_phy1->SetAttribute ("PerModel", PointerValue (per));
|
|
592 |
}
|
|
593 |
|
|
594 |
void
|
|
595 |
UanPhyDual::SetPerModelPhy2 (Ptr<UanPhyPer> per)
|
|
596 |
{
|
|
597 |
m_phy2->SetAttribute ("PerModel", PointerValue (per));
|
|
598 |
}
|
|
599 |
|
|
600 |
Ptr<UanPhyCalcSinr>
|
|
601 |
UanPhyDual::GetSinrModelPhy1 (void) const
|
|
602 |
{
|
|
603 |
PointerValue sinrValue;
|
|
604 |
m_phy1->GetAttribute ("SinrModel", sinrValue);
|
|
605 |
return sinrValue;
|
|
606 |
}
|
|
607 |
|
|
608 |
Ptr<UanPhyCalcSinr>
|
|
609 |
UanPhyDual::GetSinrModelPhy2 (void) const
|
|
610 |
{
|
|
611 |
PointerValue sinrValue;
|
|
612 |
m_phy2->GetAttribute ("SinrModel", sinrValue);
|
|
613 |
return sinrValue;
|
|
614 |
}
|
|
615 |
|
|
616 |
void
|
|
617 |
UanPhyDual::SetSinrModelPhy1 (Ptr<UanPhyCalcSinr> sinr)
|
|
618 |
{
|
|
619 |
m_phy1->SetAttribute ("SinrModel", PointerValue (sinr));
|
|
620 |
}
|
|
621 |
|
|
622 |
void
|
|
623 |
UanPhyDual::SetSinrModelPhy2 (Ptr<UanPhyCalcSinr> sinr)
|
|
624 |
{
|
|
625 |
m_phy2->SetAttribute ("SinrModel", PointerValue (sinr));
|
|
626 |
}
|
|
627 |
|
|
628 |
void
|
|
629 |
UanPhyDual::RxOkFromSubPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode)
|
|
630 |
{
|
|
631 |
NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Received packet");
|
|
632 |
m_recOkCb (pkt, sinr, mode);
|
|
633 |
m_rxOkLogger (pkt, sinr, mode);
|
|
634 |
}
|
|
635 |
|
|
636 |
void
|
|
637 |
UanPhyDual::RxErrFromSubPhy (Ptr<Packet> pkt, double sinr)
|
|
638 |
{
|
|
639 |
m_recErrCb (pkt, sinr);
|
|
640 |
m_rxErrLogger (pkt, sinr, m_phy1->GetMode (0));
|
|
641 |
}
|
|
642 |
|
|
643 |
Ptr<Packet>
|
|
644 |
UanPhyDual::GetPacketRx (void) const
|
|
645 |
{
|
|
646 |
NS_FATAL_ERROR ("GetPacketRx not valid for UanPhyDual. Must specify GetPhy1PacketRx or GetPhy2PacketRx");
|
|
647 |
return Create<Packet> ();
|
|
648 |
}
|
|
649 |
|
|
650 |
} // namespace uan
|
|
651 |
} // namespace ns3
|