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
lte-sinr-chunk-processor.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Centre Tecnologic de Telecomunicacions de Catalunya (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>
20
* (move from CQI to Ctrl and Data SINR Chunk processors
21
*/
22
23
24
#include <ns3/log.h>
25
26
#include "
lte-sinr-chunk-processor.h
"
27
28
NS_LOG_COMPONENT_DEFINE
(
"LteSinrChunkProcessor"
);
29
30
namespace
ns3 {
31
32
LteSinrChunkProcessor::~LteSinrChunkProcessor
()
33
{
34
NS_LOG_FUNCTION
(
this
);
35
}
36
37
38
LteCtrlSinrChunkProcessor::LteCtrlSinrChunkProcessor
(
Ptr<LtePhy>
p)
39
: m_phy (p),
40
m_spectrumPhy (0)
41
{
42
NS_LOG_FUNCTION
(
this
<< p);
43
NS_ASSERT
(
m_phy
);
44
}
45
46
LteCtrlSinrChunkProcessor::LteCtrlSinrChunkProcessor
(
Ptr<LtePhy>
p,
Ptr<LteSpectrumPhy>
s)
47
: m_phy (p),
48
m_spectrumPhy (s)
49
{
50
NS_LOG_FUNCTION
(
this
<< p);
51
NS_ASSERT
(
m_phy
);
52
NS_ASSERT
(
m_spectrumPhy
);
53
}
54
55
56
LteCtrlSinrChunkProcessor::~LteCtrlSinrChunkProcessor
()
57
{
58
NS_LOG_FUNCTION
(
this
);
59
}
60
61
62
void
63
LteCtrlSinrChunkProcessor::Start
()
64
{
65
NS_LOG_FUNCTION
(
this
);
66
m_sumSinr
= 0;
67
m_totDuration
=
MicroSeconds
(0);
68
}
69
70
71
void
72
LteCtrlSinrChunkProcessor::EvaluateSinrChunk
(
const
SpectrumValue
& sinr,
Time
duration)
73
{
74
NS_LOG_FUNCTION
(
this
<< sinr << duration);
75
if
(
m_sumSinr
== 0)
76
{
77
m_sumSinr
= Create<SpectrumValue> (sinr.
GetSpectrumModel
());
78
}
79
(*m_sumSinr) += sinr * duration.
GetSeconds
();
80
m_totDuration
+= duration;
81
}
82
83
void
84
LteCtrlSinrChunkProcessor::End
()
85
{
86
NS_LOG_FUNCTION
(
this
);
87
if
(
m_totDuration
.
GetSeconds
() > 0)
88
{
89
m_phy
->
GenerateCtrlCqiReport
((*
m_sumSinr
) /
m_totDuration
.
GetSeconds
());
90
if
(
m_spectrumPhy
)
91
{
92
m_spectrumPhy
->
UpdateSinrPerceived
((*
m_sumSinr
) /
m_totDuration
.
GetSeconds
());
93
}
94
}
95
else
96
{
97
NS_LOG_WARN
(
"m_numSinr == 0"
);
98
}
99
}
100
101
102
103
104
LteDataSinrChunkProcessor::LteDataSinrChunkProcessor
(
Ptr<LteSpectrumPhy>
s,
Ptr<LtePhy>
p)
105
: m_spectrumPhy (s),
106
m_phy (p)
107
{
108
NS_LOG_FUNCTION
(
this
<< p);
109
NS_ASSERT
(
m_spectrumPhy
);
110
NS_ASSERT
(
m_phy
);
111
}
112
113
LteDataSinrChunkProcessor::LteDataSinrChunkProcessor
(
Ptr<LteSpectrumPhy>
p)
114
: m_spectrumPhy (p),
115
m_phy (0)
116
{
117
NS_LOG_FUNCTION
(
this
<< p);
118
NS_ASSERT
(
m_spectrumPhy
);
119
120
}
121
122
123
124
LteDataSinrChunkProcessor::~LteDataSinrChunkProcessor
()
125
{
126
NS_LOG_FUNCTION
(
this
);
127
}
128
129
130
void
131
LteDataSinrChunkProcessor::Start
()
132
{
133
NS_LOG_FUNCTION
(
this
);
134
m_sumSinr
= 0;
135
m_totDuration
=
MicroSeconds
(0);
136
}
137
138
139
void
140
LteDataSinrChunkProcessor::EvaluateSinrChunk
(
const
SpectrumValue
& sinr,
Time
duration)
141
{
142
NS_LOG_FUNCTION
(
this
<< sinr << duration);
143
if
(
m_sumSinr
== 0)
144
{
145
m_sumSinr
= Create<SpectrumValue> (sinr.
GetSpectrumModel
());
146
}
147
(*m_sumSinr) += sinr * duration.
GetSeconds
();
148
m_totDuration
+= duration;
149
}
150
151
void
152
LteDataSinrChunkProcessor::End
()
153
{
154
NS_LOG_FUNCTION
(
this
);
155
if
(
m_totDuration
.
GetSeconds
() > 0)
156
{
157
m_spectrumPhy
->
UpdateSinrPerceived
((*
m_sumSinr
) /
m_totDuration
.
GetSeconds
());
158
if
(
m_phy
)
159
{
160
m_phy
->
GenerateDataCqiReport
((*
m_sumSinr
) /
m_totDuration
.
GetSeconds
());
161
}
162
}
163
else
164
{
165
NS_LOG_WARN
(
"m_numSinr == 0"
);
166
}
167
}
168
169
170
}
// namespace ns3
src
lte
model
lte-sinr-chunk-processor.cc
Generated on Fri Dec 21 2012 19:00:39 for ns-3 by
1.8.1.2