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
rem-spectrum-phy.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 CTTC
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: Nicola Baldo <nbaldo@cttc.es>
19
* Modified by: Marco Miozzo <mmiozzo@cttc.es> convert to
20
* LteSpectrumSignalParametersDlCtrlFrame framework
21
*/
22
23
24
#include <ns3/object-factory.h>
25
#include <ns3/log.h>
26
#include <ns3/double.h>
27
#include <ns3/simulator.h>
28
#include <ns3/trace-source-accessor.h>
29
#include <ns3/lte-spectrum-signal-parameters.h>
30
#include <ns3/antenna-model.h>
31
32
#include "
rem-spectrum-phy.h
"
33
34
NS_LOG_COMPONENT_DEFINE
(
"RemSpectrumPhy"
);
35
36
namespace
ns3 {
37
38
NS_OBJECT_ENSURE_REGISTERED
(RemSpectrumPhy);
39
40
RemSpectrumPhy::RemSpectrumPhy
()
41
: m_mobility (0),
42
m_referenceSignalPower (0),
43
m_sumPower (0),
44
m_active (true)
45
{
46
NS_LOG_FUNCTION
(
this
);
47
}
48
49
50
51
RemSpectrumPhy::~RemSpectrumPhy
()
52
{
53
NS_LOG_FUNCTION
(
this
);
54
}
55
56
void
57
RemSpectrumPhy::DoDispose
()
58
{
59
NS_LOG_FUNCTION
(
this
);
60
m_mobility
= 0;
61
SpectrumPhy::DoDispose
();
62
}
63
64
TypeId
65
RemSpectrumPhy::GetTypeId
(
void
)
66
{
67
static
TypeId
tid =
TypeId
(
"ns3::RemSpectrumPhy"
)
68
.
SetParent
<
SpectrumPhy
> ()
69
.AddConstructor<RemSpectrumPhy> ()
70
;
71
return
tid;
72
}
73
74
75
76
void
77
RemSpectrumPhy::SetChannel
(
Ptr<SpectrumChannel>
c)
78
{
79
// this is a no-op, RemSpectrumPhy does not transmit hence it does not need a reference to the channel
80
}
81
82
void
83
RemSpectrumPhy::SetMobility
(
Ptr<MobilityModel>
m)
84
{
85
NS_LOG_FUNCTION
(
this
<< m);
86
m_mobility
= m;
87
}
88
89
void
90
RemSpectrumPhy::SetDevice
(
Ptr<NetDevice>
d)
91
{
92
NS_LOG_FUNCTION
(
this
<< d);
93
// this is a no-op, RemSpectrumPhy does not handle any data hence it does not support the use of a NetDevice
94
}
95
96
Ptr<MobilityModel>
97
RemSpectrumPhy::GetMobility
()
98
{
99
return
m_mobility
;
100
}
101
102
Ptr<NetDevice>
103
RemSpectrumPhy::GetDevice
()
104
{
105
return
0;
106
}
107
108
Ptr<const SpectrumModel>
109
RemSpectrumPhy::GetRxSpectrumModel
()
const
110
{
111
return
m_rxSpectrumModel
;
112
}
113
114
Ptr<AntennaModel>
115
RemSpectrumPhy::GetRxAntenna
()
116
{
117
return
0;
118
}
119
120
121
void
122
RemSpectrumPhy::StartRx
(
Ptr<SpectrumSignalParameters>
params)
123
{
124
NS_LOG_FUNCTION
(
this
<< params);
125
126
if
(
m_active
)
127
{
128
Ptr<LteSpectrumSignalParametersDlCtrlFrame>
lteDlCtrlRxParams = DynamicCast<LteSpectrumSignalParametersDlCtrlFrame> (params);
129
if
(lteDlCtrlRxParams!=0)
130
{
131
double
power =
Integral
(*(params->psd));
132
133
m_sumPower
+= power;
134
if
(power >
m_referenceSignalPower
)
135
{
136
m_referenceSignalPower
= power;
137
}
138
}
139
}
140
}
141
142
void
143
RemSpectrumPhy::SetRxSpectrumModel
(
Ptr<const SpectrumModel>
m)
144
{
145
NS_LOG_FUNCTION
(
this
<< m);
146
m_rxSpectrumModel
= m;
147
}
148
149
double
150
RemSpectrumPhy::GetSinr
(
double
noisePower)
151
{
152
return
m_referenceSignalPower
/ (
m_sumPower
-
m_referenceSignalPower
+ noisePower);
153
}
154
155
void
156
RemSpectrumPhy::Deactivate
()
157
{
158
m_active
=
false
;
159
}
160
161
bool
162
RemSpectrumPhy::IsActive
()
163
{
164
return
m_active
;
165
}
166
167
void
168
RemSpectrumPhy::Reset
()
169
{
170
m_referenceSignalPower
= 0;
171
m_sumPower
= 0;
172
}
173
174
175
}
// namespace ns3
src
lte
model
rem-spectrum-phy.cc
Generated on Tue May 14 2013 11:08:26 for ns-3 by
1.8.1.2