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