author | Giuseppe Piro <g.piro@poliba.it> |
Mon, 06 Dec 2010 12:53:04 +0100 | |
changeset 6707 | 2ac68a0381ca |
parent 6705 | 422c67049471 |
child 6710 | 3cd651349cb6 |
permissions | -rw-r--r-- |
6705 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari |
|
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: Giuseppe Piro <g.piro@poliba.it> |
|
19 |
*/ |
|
20 |
||
21 |
#include <ns3/waveform-generator.h> |
|
22 |
#include <ns3/object-factory.h> |
|
23 |
#include <ns3/log.h> |
|
24 |
#include <math.h> |
|
25 |
#include <ns3/simulator.h> |
|
26 |
#include "ns3/spectrum-error-model.h" |
|
27 |
#include "enb-phy.h" |
|
28 |
#include "lte-net-device.h" |
|
29 |
#include "lte-spectrum-value-helper.h" |
|
30 |
#include "ideal-control-messages.h" |
|
31 |
#include "enb-net-device.h" |
|
32 |
#include "enb-mac-entity.h" |
|
33 |
#include "packet-scheduler.h" |
|
34 |
||
35 |
NS_LOG_COMPONENT_DEFINE ("EnbLtePhy"); |
|
36 |
||
37 |
namespace ns3 { |
|
38 |
||
39 |
||
40 |
NS_OBJECT_ENSURE_REGISTERED (EnbLtePhy); |
|
41 |
||
42 |
||
43 |
EnbLtePhy::EnbLtePhy () |
|
44 |
{ |
|
45 |
SetDevice (0); |
|
46 |
SetDownlinkSpectrumPhy (0); |
|
47 |
SetUplinkSpectrumPhy (0); |
|
48 |
SetTxPower (43); // dBm |
|
49 |
SetTti (0.001); |
|
50 |
SetNrFrames (0); |
|
51 |
SetNrSubFrames (0); |
|
52 |
} |
|
53 |
||
54 |
||
55 |
EnbLtePhy::EnbLtePhy (Ptr<LteNetDevice> d) |
|
56 |
{ |
|
57 |
SetDevice (d); |
|
58 |
SetDownlinkSpectrumPhy (0); |
|
59 |
SetUplinkSpectrumPhy (0); |
|
60 |
SetTxPower (43); // dBm |
|
61 |
SetTti (0.001); |
|
62 |
SetNrFrames (0); |
|
63 |
SetNrSubFrames (0); |
|
64 |
} |
|
65 |
||
66 |
||
67 |
TypeId |
|
68 |
EnbLtePhy::GetTypeId (void) |
|
69 |
{ |
|
70 |
static TypeId tid = TypeId ("ns3::EnbLtePhy") |
|
6707
2ac68a0381ca
improved module after Tom's review
Giuseppe Piro <g.piro@poliba.it>
parents:
6705
diff
changeset
|
71 |
.SetParent<LtePhy> () |
6705 | 72 |
.AddConstructor<EnbLtePhy> () |
73 |
; |
|
74 |
return tid; |
|
75 |
} |
|
76 |
||
77 |
||
78 |
EnbLtePhy::~EnbLtePhy () |
|
79 |
{ |
|
80 |
} |
|
81 |
||
82 |
||
83 |
bool |
|
84 |
EnbLtePhy::SendPacket (Ptr<PacketBurst> pb) |
|
85 |
{ |
|
86 |
NS_LOG_FUNCTION (this << pb->GetNPackets () << pb->GetSize ()); |
|
87 |
return GetDownlinkSpectrumPhy ()->StartTx (pb); |
|
88 |
} |
|
89 |
||
90 |
void |
|
91 |
EnbLtePhy::DoSetDownlinkSubChannels () |
|
92 |
{ |
|
93 |
NS_LOG_FUNCTION (this); |
|
94 |
Ptr<SpectrumValue> txPsd = CreateTxPowerSpectralDensity (); |
|
95 |
GetDownlinkSpectrumPhy ()->SetTxPowerSpectralDensity (txPsd); |
|
96 |
} |
|
97 |
||
98 |
||
99 |
Ptr<SpectrumValue> |
|
100 |
EnbLtePhy::CreateTxPowerSpectralDensity () |
|
101 |
{ |
|
102 |
NS_LOG_FUNCTION (this); |
|
103 |
||
104 |
LteSpectrumValueHelper psdHelper; |
|
105 |
Ptr<SpectrumValue> psd = psdHelper.CreateDownlinkTxPowerSpectralDensity (GetTxPower (), GetDownlinkSubChannels ()); |
|
106 |
||
107 |
return psd; |
|
108 |
} |
|
109 |
||
110 |
||
111 |
void |
|
112 |
EnbLtePhy::CalcChannelQualityForUe (std::vector <double> sinr, Ptr<LteSpectrumPhy> ue) |
|
113 |
{ |
|
114 |
NS_LOG_FUNCTION (this); |
|
115 |
} |
|
116 |
||
117 |
void |
|
118 |
EnbLtePhy::SendIdealControlMessage (IdealControlMessage* msg) |
|
119 |
{ |
|
120 |
NS_LOG_FUNCTION (this << msg); |
|
121 |
} |
|
122 |
||
123 |
||
124 |
void |
|
125 |
EnbLtePhy::ReceiveIdealControlMessage (IdealControlMessage* msg) |
|
126 |
{ |
|
127 |
NS_LOG_FUNCTION (this << msg); |
|
128 |
if (msg->GetMessageType () == IdealControlMessage::CQI_FEEDBACKS) |
|
129 |
{ |
|
130 |
CqiIdealControlMessage* msg2 = dynamic_cast<CqiIdealControlMessage*> (msg); |
|
131 |
Ptr<EnbMacEntity> macEntity = GetDevice ()->GetObject<EnbNetDevice> ()->GetMacEntity (); |
|
132 |
macEntity->ReceiveCqiIdealControlMessage (msg2); |
|
133 |
} |
|
134 |
||
135 |
else |
|
136 |
{ |
|
137 |
// XXX at this time, the eNB must receive only CQI feedbacks! |
|
138 |
} |
|
139 |
||
140 |
} |
|
141 |
||
142 |
||
143 |
||
144 |
void |
|
145 |
EnbLtePhy::StartFrame (void) |
|
146 |
{ |
|
147 |
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ()); |
|
148 |
NS_LOG_INFO ("-----frame " << GetNrFrames () + 1 << "-----"); |
|
149 |
||
150 |
SetNrFrames (GetNrFrames () + 1); |
|
151 |
SetNrSubFrames (0); |
|
152 |
||
153 |
StartSubFrame (); |
|
154 |
} |
|
155 |
||
156 |
||
157 |
void |
|
158 |
EnbLtePhy::StartSubFrame (void) |
|
159 |
{ |
|
160 |
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ()); |
|
161 |
NS_LOG_INFO ("-----sub frame " << GetNrSubFrames () + 1 << "-----"); |
|
162 |
||
163 |
SetNrSubFrames (GetNrSubFrames () + 1); |
|
164 |
||
165 |
||
166 |
/* |
|
167 |
XXX: the packet scheduler is not implemented yet! |
|
168 |
The enb take the fist packet from the default bearer |
|
169 |
and send it. |
|
170 |
*/ |
|
171 |
||
172 |
Ptr<EnbMacEntity> macEntity = GetDevice ()->GetObject<EnbNetDevice> ()->GetMacEntity (); |
|
173 |
||
174 |
// macEntity->GetUplinkPacketScheduler ()->RunPacketScheduler (); |
|
175 |
macEntity->GetDownlinkPacketScheduler ()->RunPacketScheduler (); |
|
176 |
||
177 |
Simulator::Schedule (Seconds (GetTti ()), |
|
178 |
&EnbLtePhy::EndSubFrame, |
|
179 |
this); |
|
180 |
||
181 |
} |
|
182 |
||
183 |
||
184 |
void |
|
185 |
EnbLtePhy::EndSubFrame (void) |
|
186 |
{ |
|
187 |
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ()); |
|
188 |
if (GetNrSubFrames () == 10) |
|
189 |
{ |
|
190 |
Simulator::ScheduleNow (&EnbLtePhy::EndFrame, this); |
|
191 |
} |
|
192 |
else |
|
193 |
{ |
|
194 |
Simulator::ScheduleNow (&EnbLtePhy::StartSubFrame, this); |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
||
199 |
void |
|
200 |
EnbLtePhy::EndFrame (void) |
|
201 |
{ |
|
202 |
NS_LOG_FUNCTION (this << Simulator::Now ().GetSeconds ()); |
|
203 |
Simulator::ScheduleNow (&EnbLtePhy::StartFrame, this); |
|
204 |
} |
|
205 |
||
206 |
||
207 |
||
208 |
}; |