A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Giuseppe Piro <g.piro@poliba.it>
7 * Marco Miozzo <mmiozzo@cttc.es>
8 */
9
10#include "lte-phy.h"
11
13#include "lte-net-device.h"
14
15#include "ns3/spectrum-error-model.h"
16#include <ns3/log.h>
17#include <ns3/object-factory.h>
18#include <ns3/simulator.h>
19#include <ns3/waveform-generator.h>
20
21#include <cmath>
22
23namespace ns3
24{
25
27
29
31{
32 NS_LOG_FUNCTION(this);
33 NS_FATAL_ERROR("This constructor should not be called");
34}
35
37 : m_downlinkSpectrumPhy(dlPhy),
38 m_uplinkSpectrumPhy(ulPhy),
39 m_tti(0.001),
40 m_ulBandwidth(0),
41 m_dlBandwidth(0),
42 m_rbgSize(0),
43 m_dlEarfcn(0),
44 m_ulEarfcn(0),
45 m_macChTtiDelay(0),
46 m_cellId(0),
47 m_componentCarrierId(0)
48{
49 NS_LOG_FUNCTION(this);
50}
51
54{
55 static TypeId tid = TypeId("ns3::LtePhy").SetParent<Object>().SetGroupName("Lte");
56 return tid;
57}
58
60{
61 NS_LOG_FUNCTION(this);
62}
63
64void
66{
67 NS_LOG_FUNCTION(this);
68 m_packetBurstQueue.clear();
70 m_downlinkSpectrumPhy->Dispose();
71 m_downlinkSpectrumPhy = nullptr;
72 m_uplinkSpectrumPhy->Dispose();
73 m_uplinkSpectrumPhy = nullptr;
74 m_netDevice = nullptr;
76}
77
78void
84
87{
88 NS_LOG_FUNCTION(this);
89 return m_netDevice;
90}
91
97
103
104void
110
111void
117
118void
119LtePhy::SetTti(double tti)
120{
121 NS_LOG_FUNCTION(this << tti);
122 m_tti = tti;
123}
124
125double
127{
128 NS_LOG_FUNCTION(this << m_tti);
129 return m_tti;
130}
131
132uint16_t
133LtePhy::GetSrsPeriodicity(uint16_t srcCi) const
134{
135 // from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity
136 uint16_t SrsPeriodicity[9] = {0, 2, 5, 10, 20, 40, 80, 160, 320};
137 uint16_t SrsCiLow[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317};
138 uint16_t SrsCiHigh[9] = {0, 1, 6, 16, 36, 76, 156, 316, 636};
139 uint8_t i;
140 for (i = 8; i > 0; i--)
141 {
142 if ((srcCi >= SrsCiLow[i]) && (srcCi <= SrsCiHigh[i]))
143 {
144 break;
145 }
146 }
147 return SrsPeriodicity[i];
148}
149
150uint16_t
151LtePhy::GetSrsSubframeOffset(uint16_t srcCi) const
152{
153 // from 3GPP TS 36.213 table 8.2-1 UE Specific SRS Periodicity
154 uint16_t SrsSubframeOffset[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317};
155 uint16_t SrsCiLow[9] = {0, 0, 2, 7, 17, 37, 77, 157, 317};
156 uint16_t SrsCiHigh[9] = {0, 1, 6, 16, 36, 76, 156, 316, 636};
157 uint8_t i;
158 for (i = 8; i > 0; i--)
159 {
160 if ((srcCi >= SrsCiLow[i]) && (srcCi <= SrsCiHigh[i]))
161 {
162 break;
163 }
164 }
165 return (srcCi - SrsSubframeOffset[i]);
166}
167
168uint8_t
170{
171 return m_rbgSize;
172}
173
174void
176{
177 m_packetBurstQueue.at(m_packetBurstQueue.size() - 1)->AddPacket(p);
178}
179
182{
183 if (m_packetBurstQueue.at(0)->GetSize() > 0)
184 {
185 Ptr<PacketBurst> ret = m_packetBurstQueue.at(0)->Copy();
188 return ret;
189 }
190 else
191 {
194 return nullptr;
195 }
196}
197
198void
200{
201 // In uplink the queue of control messages and packet are of different sizes
202 // for avoiding TTI cancellation due to synchronization of subframe triggers
203 m_controlMessagesQueue.at(m_controlMessagesQueue.size() - 1).push_back(m);
204}
205
206std::list<Ptr<LteControlMessage>>
208{
209 NS_LOG_FUNCTION(this);
210 if (!m_controlMessagesQueue.at(0).empty())
211 {
212 std::list<Ptr<LteControlMessage>> ret = m_controlMessagesQueue.at(0);
214 std::list<Ptr<LteControlMessage>> newlist;
215 m_controlMessagesQueue.push_back(newlist);
216 return ret;
217 }
218 else
219 {
221 std::list<Ptr<LteControlMessage>> newlist;
222 m_controlMessagesQueue.push_back(newlist);
223 std::list<Ptr<LteControlMessage>> emptylist;
224 return emptylist;
225 }
226}
227
228void
229LtePhy::DoSetCellId(uint16_t cellId)
230{
231 m_cellId = cellId;
232 m_downlinkSpectrumPhy->SetCellId(cellId);
233 m_uplinkSpectrumPhy->SetCellId(cellId);
234}
235
236void
238{
239 m_componentCarrierId = index;
240 m_downlinkSpectrumPhy->SetComponentCarrierId(index);
241 m_uplinkSpectrumPhy->SetComponentCarrierId(index);
242}
243
244uint8_t
249
250} // namespace ns3
void DoSetCellId(uint16_t cellId)
Definition lte-phy.cc:229
static TypeId GetTypeId()
Get the type ID.
Definition lte-phy.cc:53
uint8_t GetRbgSize() const
Definition lte-phy.cc:169
uint8_t GetComponentCarrierId() const
Get the component carrier ID.
Definition lte-phy.cc:245
void DoDispose() override
Destructor implementation.
Definition lte-phy.cc:65
uint16_t GetSrsPeriodicity(uint16_t srcCi) const
Definition lte-phy.cc:133
std::vector< Ptr< PacketBurst > > m_packetBurstQueue
A queue of packet bursts to be sent.
Definition lte-phy.h:270
Ptr< PacketBurst > GetPacketBurst()
Definition lte-phy.cc:181
Ptr< LteNetDevice > GetDevice() const
Get the device where the phy layer is attached.
Definition lte-phy.cc:86
void SetDownlinkChannel(Ptr< SpectrumChannel > c)
Set the downlink channel.
Definition lte-phy.cc:105
void SetUplinkChannel(Ptr< SpectrumChannel > c)
Set the uplink channel.
Definition lte-phy.cc:112
uint8_t m_componentCarrierId
component carrier Id used to address sap
Definition lte-phy.h:292
void SetComponentCarrierId(uint8_t index)
Set the component carrier ID.
Definition lte-phy.cc:237
Ptr< LteSpectrumPhy > GetDownlinkSpectrumPhy()
Definition lte-phy.cc:93
Ptr< LteSpectrumPhy > m_downlinkSpectrumPhy
The downlink LteSpectrumPhy associated to this LtePhy.
Definition lte-phy.h:219
Ptr< LteSpectrumPhy > GetUplinkSpectrumPhy()
Definition lte-phy.cc:99
void SetMacPdu(Ptr< Packet > p)
Definition lte-phy.cc:175
std::list< Ptr< LteControlMessage > > GetControlMessages()
Definition lte-phy.cc:207
uint16_t GetSrsSubframeOffset(uint16_t srcCi) const
Definition lte-phy.cc:151
void SetDevice(Ptr< LteNetDevice > d)
Set the device where the phy layer is attached.
Definition lte-phy.cc:79
Ptr< LteNetDevice > m_netDevice
Pointer to the NetDevice where this PHY layer is attached.
Definition lte-phy.h:213
uint16_t m_cellId
Cell identifier.
Definition lte-phy.h:289
void SetControlMessages(Ptr< LteControlMessage > m)
Definition lte-phy.cc:199
double m_tti
Transmission time interval.
Definition lte-phy.h:245
Ptr< LteSpectrumPhy > m_uplinkSpectrumPhy
The uplink LteSpectrumPhy associated to this LtePhy.
Definition lte-phy.h:224
double GetTti() const
Definition lte-phy.cc:126
std::vector< std::list< Ptr< LteControlMessage > > > m_controlMessagesQueue
A queue of control messages to be sent.
Definition lte-phy.h:272
uint8_t m_rbgSize
The RB group size according to the bandwidth.
Definition lte-phy.h:257
~LtePhy() override
Definition lte-phy.cc:59
void SetTti(double tti)
Definition lte-phy.cc:119
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.