A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
uan-phy.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Leonard Tracy <lentracy@gmail.com>
19
* Andrea Sacco <andrea.sacco85@gmail.com>
20
*/
21
22
23
#ifndef UAN_PHY_H
24
#define UAN_PHY_H
25
26
#include "ns3/object.h"
27
#include "ns3/uan-mac.h"
28
#include "ns3/uan-tx-mode.h"
29
#include "ns3/uan-prop-model.h"
30
#include "ns3/uan-transducer.h"
31
#include "ns3/device-energy-model.h"
32
33
namespace
ns3 {
34
35
43
class
UanPhyCalcSinr
:
public
Object
44
{
45
46
public
:
47
static
TypeId
GetTypeId
(
void
);
48
58
virtual
double
CalcSinrDb
(
Ptr<Packet>
pkt,
59
Time
arrTime,
60
double
rxPowerDb,
61
double
ambNoiseDb,
62
UanTxMode
mode,
63
UanPdp
pdp,
64
const
UanTransducer::ArrivalList
&arrivalList
65
)
const
= 0;
69
virtual
void
Clear
(
void
);
70
71
virtual
void
DoDispose
(
void
);
72
78
inline
double
DbToKp
(
double
db)
const
79
{
80
return
pow (10, db / 10.0);
81
}
87
inline
double
KpToDb
(
double
kp)
const
88
{
89
return
10 * log10 (kp);
90
}
91
};
92
98
class
UanPhyPer
:
public
Object
99
{
100
public
:
101
static
TypeId
GetTypeId
(
void
);
102
111
virtual
double
CalcPer
(
Ptr<Packet>
pkt,
double
sinrDb,
UanTxMode
mode) = 0;
115
virtual
void
Clear
(
void
);
116
117
virtual
void
DoDispose
(
void
);
118
};
119
120
128
class
UanPhyListener
129
{
130
public
:
131
virtual
~UanPhyListener
()
132
{
133
}
137
virtual
void
NotifyRxStart
(
void
) = 0;
141
virtual
void
NotifyRxEndOk
(
void
) = 0;
145
virtual
void
NotifyRxEndError
(
void
) = 0;
149
virtual
void
NotifyCcaStart
(
void
) = 0;
153
virtual
void
NotifyCcaEnd
(
void
) = 0;
158
virtual
void
NotifyTxStart
(
Time
duration) = 0;
159
};
160
166
class
UanPhy
:
public
Object
167
{
168
public
:
169
static
TypeId
GetTypeId
(
void
);
170
172
enum
State
173
{
174
IDLE
,
CCABUSY
,
RX
,
TX
,
SLEEP
175
};
176
182
typedef
Callback<void, Ptr<Packet>
, double,
UanTxMode
>
RxOkCallback
;
183
188
typedef
Callback<void, Ptr<Packet>
,
double
>
RxErrCallback
;
189
196
virtual
void
SetEnergyModelCallback
(
DeviceEnergyModel::ChangeStateCallback
callback) = 0;
201
virtual
void
EnergyDepletionHandler
(
void
) = 0;
206
virtual
void
SendPacket
(
Ptr<Packet>
pkt, uint32_t modeNum) = 0;
207
213
virtual
void
RegisterListener
(
UanPhyListener
*listener) = 0;
214
222
virtual
void
StartRxPacket
(
Ptr<Packet>
pkt,
double
rxPowerDb,
UanTxMode
txMode,
UanPdp
pdp) = 0;
223
227
virtual
void
SetReceiveOkCallback
(
RxOkCallback
cb) = 0;
228
232
virtual
void
SetReceiveErrorCallback
(
RxErrCallback
cb) = 0;
233
238
virtual
void
SetRxGainDb
(
double
gain) = 0;
239
243
virtual
void
SetTxPowerDb
(
double
txpwr) = 0;
244
248
virtual
void
SetRxThresholdDb
(
double
thresh) = 0;
249
254
virtual
void
SetCcaThresholdDb
(
double
thresh) = 0;
255
259
virtual
double
GetRxGainDb
(
void
) = 0;
260
264
virtual
double
GetTxPowerDb
(
void
) = 0;
265
269
virtual
double
GetRxThresholdDb
(
void
) = 0;
270
274
virtual
double
GetCcaThresholdDb
(
void
) = 0;
279
virtual
bool
IsStateSleep
(
void
) = 0;
284
virtual
bool
IsStateIdle
(
void
) = 0;
289
virtual
bool
IsStateBusy
(
void
) = 0;
294
virtual
bool
IsStateRx
(
void
) = 0;
299
virtual
bool
IsStateTx
(
void
) = 0;
304
virtual
bool
IsStateCcaBusy
(
void
) = 0;
305
309
virtual
Ptr<UanChannel>
GetChannel
(
void
)
const
= 0;
310
314
virtual
Ptr<UanNetDevice>
GetDevice
(
void
) = 0;
315
319
virtual
void
SetChannel
(
Ptr<UanChannel>
channel) = 0;
320
324
virtual
void
SetDevice
(
Ptr<UanNetDevice>
device) = 0;
325
329
virtual
void
SetMac
(
Ptr<UanMac>
mac) = 0;
330
340
virtual
void
NotifyTransStartTx
(
Ptr<Packet>
packet,
double
txPowerDb,
UanTxMode
txMode) = 0;
341
348
virtual
void
NotifyIntChange
(
void
) = 0;
349
354
virtual
void
SetTransducer
(
Ptr<UanTransducer>
trans) = 0;
355
359
virtual
Ptr<UanTransducer>
GetTransducer
(
void
) = 0;
360
364
virtual
uint32_t
GetNModes
(
void
) = 0;
365
370
virtual
UanTxMode
GetMode
(uint32_t n) = 0;
371
376
virtual
Ptr<Packet>
GetPacketRx
(
void
)
const
= 0;
377
381
virtual
void
Clear
(
void
) = 0;
382
383
virtual
void
SetSleepMode
(
bool
sleep) = 0;
384
385
390
void
NotifyTxBegin
(
Ptr<const Packet>
packet);
391
396
void
NotifyTxEnd
(
Ptr<const Packet>
packet);
397
402
void
NotifyTxDrop
(
Ptr<const Packet>
packet);
403
408
void
NotifyRxBegin
(
Ptr<const Packet>
packet);
409
414
void
NotifyRxEnd
(
Ptr<const Packet>
packet);
415
420
void
NotifyRxDrop
(
Ptr<const Packet>
packet);
421
430
virtual
int64_t
AssignStreams
(int64_t stream) = 0;
431
432
private
:
439
TracedCallback<Ptr<const Packet>
>
m_phyTxBeginTrace
;
440
447
TracedCallback<Ptr<const Packet>
>
m_phyTxEndTrace
;
448
455
TracedCallback<Ptr<const Packet>
>
m_phyTxDropTrace
;
456
463
TracedCallback<Ptr<const Packet>
>
m_phyRxBeginTrace
;
464
471
TracedCallback<Ptr<const Packet>
>
m_phyRxEndTrace
;
472
478
TracedCallback<Ptr<const Packet>
>
m_phyRxDropTrace
;
479
};
480
481
}
482
483
#endif
/* UAN_PHY_H */
src
uan
model
uan-phy.h
Generated on Tue Nov 13 2012 10:32:23 for ns-3 by
1.8.1.2