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-gen.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
#ifndef UAN_PHY_GEN_H
23
#define UAN_PHY_GEN_H
24
25
26
#include "
uan-phy.h
"
27
#include "ns3/traced-callback.h"
28
#include "ns3/nstime.h"
29
#include "ns3/device-energy-model.h"
30
#include "ns3/random-variable-stream.h"
31
#include <list>
32
33
namespace
ns3 {
34
41
class
UanPhyPerGenDefault
:
public
UanPhyPer
42
{
43
public
:
44
UanPhyPerGenDefault
();
45
virtual
~UanPhyPerGenDefault
();
46
47
static
TypeId
GetTypeId
(
void
);
48
virtual
double
CalcPer
(
Ptr<Packet>
pkt,
double
sinrDb,
UanTxMode
mode);
49
private
:
50
double
m_thresh
;
51
52
};
53
60
class
UanPhyPerUmodem
:
public
UanPhyPer
61
{
62
public
:
63
UanPhyPerUmodem
();
64
virtual
~UanPhyPerUmodem
();
65
66
static
TypeId
GetTypeId
(
void
);
67
81
virtual
double
CalcPer
(
Ptr<Packet>
pkt,
double
sinrDb,
UanTxMode
mode);
82
private
:
83
double
NChooseK
(uint32_t n, uint32_t k);
84
85
};
93
class
UanPhyCalcSinrDefault
:
public
UanPhyCalcSinr
94
{
95
96
public
:
97
UanPhyCalcSinrDefault
();
98
virtual
~UanPhyCalcSinrDefault
();
99
static
TypeId
GetTypeId
(
void
);
113
virtual
double
CalcSinrDb
(
Ptr<Packet>
pkt,
114
Time
arrTime,
115
double
rxPowerDb,
116
double
ambNoiseDb,
117
UanTxMode
mode,
118
UanPdp
pdp,
119
const
UanTransducer::ArrivalList
&arrivalList
120
)
const
;
121
};
122
133
class
UanPhyCalcSinrFhFsk
:
public
UanPhyCalcSinr
134
{
135
136
public
:
137
UanPhyCalcSinrFhFsk
();
138
virtual
~UanPhyCalcSinrFhFsk
();
139
static
TypeId
GetTypeId
(
void
);
140
virtual
double
CalcSinrDb
(
Ptr<Packet>
pkt,
141
Time
arrTime,
142
double
rxPowerDb,
143
double
ambNoiseDb,
144
UanTxMode
mode,
145
UanPdp
pdp,
146
const
UanTransducer::ArrivalList
&arrivalList
147
)
const
;
148
private
:
149
uint32_t
m_hops
;
150
};
151
161
class
UanPhyGen
:
public
UanPhy
162
{
163
public
:
164
UanPhyGen
();
165
virtual
~UanPhyGen
();
169
static
UanModesList
GetDefaultModes
(
void
);
170
171
static
TypeId
GetTypeId
(
void
);
172
virtual
void
SetEnergyModelCallback
(
DeviceEnergyModel::ChangeStateCallback
cb);
173
virtual
void
EnergyDepletionHandler
(
void
);
174
virtual
void
SendPacket
(
Ptr<Packet>
pkt, uint32_t modeNum);
175
virtual
void
RegisterListener
(
UanPhyListener
*listener);
176
virtual
void
StartRxPacket
(
Ptr<Packet>
pkt,
double
rxPowerDb,
UanTxMode
txMode,
UanPdp
pdp);
177
virtual
void
SetReceiveOkCallback
(
RxOkCallback
cb);
178
virtual
void
SetReceiveErrorCallback
(
RxErrCallback
cb);
179
virtual
bool
IsStateSleep
(
void
);
180
virtual
bool
IsStateIdle
(
void
);
181
virtual
bool
IsStateBusy
(
void
);
182
virtual
bool
IsStateRx
(
void
);
183
virtual
bool
IsStateTx
(
void
);
184
virtual
bool
IsStateCcaBusy
(
void
);
185
virtual
void
SetRxGainDb
(
double
gain);
186
virtual
void
SetTxPowerDb
(
double
txpwr);
187
virtual
void
SetRxThresholdDb
(
double
thresh);
188
virtual
void
SetCcaThresholdDb
(
double
thresh);
189
virtual
double
GetRxGainDb
(
void
);
190
virtual
double
GetTxPowerDb
(
void
);
191
virtual
double
GetRxThresholdDb
(
void
);
192
virtual
double
GetCcaThresholdDb
(
void
);
193
virtual
Ptr<UanChannel>
GetChannel
(
void
)
const
;
194
virtual
Ptr<UanNetDevice>
GetDevice
(
void
);
195
virtual
Ptr<UanTransducer>
GetTransducer
(
void
);
196
virtual
void
SetChannel
(
Ptr<UanChannel>
channel);
197
virtual
void
SetDevice
(
Ptr<UanNetDevice>
device);
198
virtual
void
SetMac
(
Ptr<UanMac>
mac);
199
virtual
void
SetTransducer
(
Ptr<UanTransducer>
trans);
200
virtual
void
NotifyTransStartTx
(
Ptr<Packet>
packet,
double
txPowerDb,
UanTxMode
txMode);
201
virtual
void
NotifyIntChange
(
void
);
202
virtual
uint32_t
GetNModes
(
void
);
203
virtual
UanTxMode
GetMode
(uint32_t n);
204
virtual
Ptr<Packet>
GetPacketRx
(
void
)
const
;
205
virtual
void
Clear
(
void
);
206
207
virtual
void
SetSleepMode
(
bool
sleep);
208
217
int64_t
AssignStreams
(int64_t stream);
218
219
private
:
220
typedef
std::list<UanPhyListener *>
ListenerList
;
221
222
UanModesList
m_modes
;
223
224
State
m_state
;
225
ListenerList
m_listeners
;
226
RxOkCallback
m_recOkCb
;
227
RxErrCallback
m_recErrCb
;
228
Ptr<UanChannel>
m_channel
;
229
Ptr<UanTransducer>
m_transducer
;
230
Ptr<UanNetDevice>
m_device
;
231
Ptr<UanMac>
m_mac
;
232
Ptr<UanPhyPer>
m_per
;
233
Ptr<UanPhyCalcSinr>
m_sinr
;
234
235
double
m_rxGainDb
;
236
double
m_txPwrDb
;
237
double
m_rxThreshDb
;
238
double
m_ccaThreshDb
;
239
240
Ptr<Packet>
m_pktRx
;
241
double
m_minRxSinrDb
;
242
double
m_rxRecvPwrDb
;
243
Time
m_pktRxArrTime
;
244
UanPdp
m_pktRxPdp
;
245
UanTxMode
m_pktRxMode
;
246
247
bool
m_cleared
;
248
bool
m_disabled
;
249
251
Ptr<UniformRandomVariable>
m_pg
;
252
253
DeviceEnergyModel::ChangeStateCallback
m_energyCallback
;
254
TracedCallback<Ptr<const Packet>
, double,
UanTxMode
>
m_rxOkLogger
;
255
TracedCallback<Ptr<const Packet>
, double,
UanTxMode
>
m_rxErrLogger
;
256
TracedCallback<Ptr<const Packet>
, double,
UanTxMode
>
m_txLogger
;
257
258
double
CalculateSinrDb
(
Ptr<Packet>
pkt,
Time
arrTime,
double
rxPowerDb,
UanTxMode
mode,
UanPdp
pdp);
259
double
GetInterferenceDb
(
Ptr<Packet>
pkt);
260
double
DbToKp
(
double
db);
261
double
KpToDb
(
double
kp);
262
void
RxEndEvent
(
Ptr<Packet>
pkt,
double
rxPowerDb,
UanTxMode
txMode);
263
void
TxEndEvent
();
264
void
UpdatePowerConsumption
(
const
State
state);
265
266
void
NotifyListenersRxStart
(
void
);
267
void
NotifyListenersRxGood
(
void
);
268
void
NotifyListenersRxBad
(
void
);
269
void
NotifyListenersCcaStart
(
void
);
270
void
NotifyListenersCcaEnd
(
void
);
271
void
NotifyListenersTxStart
(
Time
duration);
272
protected
:
273
virtual
void
DoDispose
();
274
275
};
276
277
}
// namespace ns3
278
279
#endif
/* UAN_PHY_GEN_H */
src
uan
model
uan-phy-gen.h
Generated on Tue Nov 13 2012 10:32:23 for ns-3 by
1.8.1.2