A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-ue-mac.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Nicola Baldo <nbaldo@cttc.es>
18 * Author: Marco Miozzo <mmiozzo@cttc.es>
19 */
20
21#ifndef LTE_UE_MAC_ENTITY_H
22#define LTE_UE_MAC_ENTITY_H
23
24#include "ff-mac-common.h"
25#include "lte-mac-sap.h"
26#include "lte-ue-cmac-sap.h"
27#include "lte-ue-phy-sap.h"
28
29#include <ns3/event-id.h>
30#include <ns3/nstime.h>
31#include <ns3/packet-burst.h>
32#include <ns3/packet.h>
33#include <ns3/traced-callback.h>
34
35#include <map>
36#include <vector>
37
38namespace ns3
39{
40
41class UniformRandomVariable;
42
43class LteUeMac : public Object
44{
45 /// allow UeMemberLteUeCmacSapProvider class friend access
47 /// allow UeMemberLteMacSapProvider class friend access
49 /// allow UeMemberLteUePhySapUser class friend access
51
52 public:
53 /**
54 * \brief Get the type ID.
55 * \return the object TypeId
56 */
57 static TypeId GetTypeId();
58
59 LteUeMac();
60 ~LteUeMac() override;
61 void DoDispose() override;
62
63 /**
64 * \brief TracedCallback signature for RA response timeout events
65 * exporting IMSI, contention flag, preamble transmission counter
66 * and the max limit of preamble transmission
67 *
68 * \param [in] imsi
69 * \param [in] contention
70 * \param [in] preambleTxCounter
71 * \param [in] maxPreambleTxLimit
72 */
73 typedef void (*RaResponseTimeoutTracedCallback)(uint64_t imsi,
74 bool contention,
75 uint8_t preambleTxCounter,
76 uint8_t maxPreambleTxLimit);
77
78 /**
79 * \brief Get the LTE MAC SAP provider
80 * \return a pointer to the LTE MAC SAP provider
81 */
83 /**
84 * \brief Set the LTE UE CMAC SAP user
85 * \param s the LTE UE CMAC SAP User
86 */
88 /**
89 * \brief Get the LTE CMAC SAP provider
90 * \return a pointer to the LTE CMAC SAP provider
91 */
93
94 /**
95 * \brief Set the component carried ID
96 * \param index the component carrier ID
97 */
98 void SetComponentCarrierId(uint8_t index);
99
100 /**
101 * \brief Get the PHY SAP user
102 * \return a pointer to the SAP user of the PHY
103 */
105
106 /**
107 * \brief Set the PHY SAP Provider
108 * \param s a pointer to the PHY SAP Provider
109 */
111
112 /**
113 * \brief Forwarded from LteUePhySapUser: trigger the start from a new frame
114 *
115 * \param frameNo frame number
116 * \param subframeNo subframe number
117 */
118 void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo);
119
120 /**
121 * Assign a fixed random variable stream number to the random variables
122 * used by this model. Return the number of streams (possibly zero) that
123 * have been assigned.
124 *
125 * \param stream first stream index to use
126 * \return the number of stream indices assigned by this model
127 */
128 int64_t AssignStreams(int64_t stream);
129
130 private:
131 // forwarded from MAC SAP
132 /**
133 * Transmit PDU function
134 *
135 * \param params LteMacSapProvider::TransmitPduParameters
136 */
138 /**
139 * Report buffers status function
140 *
141 * \param params LteMacSapProvider::ReportBufferStatusParameters
142 */
144
145 // forwarded from UE CMAC SAP
146 /**
147 * Configure RACH function
148 *
149 * \param rc LteUeCmacSapProvider::RachConfig
150 */
152 /**
153 * Start contention based random access procedure function
154 */
156 /**
157 * Set RNTI
158 *
159 * \param rnti the RNTI
160 */
161 void DoSetRnti(uint16_t rnti);
162 /**
163 * Start non contention based random access procedure function
164 *
165 * \param rnti the RNTI
166 * \param rapId the RAPID
167 * \param prachMask the PRACH mask
168 */
170 uint8_t rapId,
171 uint8_t prachMask);
172 /**
173 * Add LC function
174 *
175 * \param lcId the LCID
176 * \param lcConfig the logical channel config
177 * \param msu the MSU
178 */
179 void DoAddLc(uint8_t lcId,
181 LteMacSapUser* msu);
182 /**
183 * Remove LC function
184 *
185 * \param lcId the LCID
186 */
187 void DoRemoveLc(uint8_t lcId);
188 /**
189 * \brief Reset function
190 */
191 void DoReset();
192 /**
193 * \brief Notify MAC about the successful RRC connection
194 * establishment.
195 */
197 /**
198 * Set IMSI
199 *
200 * \param imsi the IMSI of the UE
201 */
202 void DoSetImsi(uint64_t imsi);
203
204 // forwarded from PHY SAP
205 /**
206 * Receive Phy PDU function
207 *
208 * \param p the packet
209 */
211 /**
212 * Receive LTE control message function
213 *
214 * \param msg the LTE control message
215 */
217
218 // internal methods
219 /// Randomly select and send RA preamble function
221 /**
222 * Send RA preamble function
223 *
224 * \param contention if true randomly select and send the RA preamble
225 */
226 void SendRaPreamble(bool contention);
227 /// Start waiting for RA response function
229 /**
230 * Receive the RA response function
231 *
232 * \param raResponse RA response received
233 */
234 void RecvRaResponse(BuildRarListElement_s raResponse);
235 /**
236 * RA response timeout function
237 *
238 * \param contention if true randomly select and send the RA preamble
239 */
240 void RaResponseTimeout(bool contention);
241 /// Send report buffer status
243 /// Refresh HARQ processes packet buffer function
245
246 /// component carrier Id --> used to address sap
248
249 private:
250 /// LcInfo structure
251 struct LcInfo
252 {
254 LteMacSapUser* macSapUser; ///< MAC SAP user
255 };
256
257 std::map<uint8_t, LcInfo> m_lcInfoMap; ///< logical channel info map
258
259 LteMacSapProvider* m_macSapProvider; ///< MAC SAP provider
260
261 LteUeCmacSapUser* m_cmacSapUser; ///< CMAC SAP user
263
264 LteUePhySapProvider* m_uePhySapProvider; ///< UE Phy SAP provider
265 LteUePhySapUser* m_uePhySapUser; ///< UE Phy SAP user
266
267 std::map<uint8_t, LteMacSapProvider::ReportBufferStatusParameters>
268 m_ulBsrReceived; ///< BSR received from RLC (the last one)
269
270 Time m_bsrPeriodicity; ///< BSR periodicity
271 Time m_bsrLast; ///< BSR last
272
273 bool m_freshUlBsr; ///< true when a BSR has been received in the last TTI
274
275 uint8_t m_harqProcessId; ///< HARQ process ID
276 std::vector<Ptr<PacketBurst>>
277 m_miUlHarqProcessesPacket; ///< Packets under transmission of the UL HARQ processes
278 std::vector<uint8_t> m_miUlHarqProcessesPacketTimer; ///< timer for packet life in the buffer
279
280 uint16_t m_rnti; ///< RNTI
281 uint16_t m_imsi; ///< IMSI
282
283 bool m_rachConfigured; ///< is RACH configured?
285 uint8_t m_raPreambleId; ///< RA preamble ID
286 uint8_t m_preambleTransmissionCounter; ///< preamble tranamission counter
287 uint16_t m_backoffParameter; ///< backoff parameter
288 EventId m_noRaResponseReceivedEvent; ///< no RA response received event ID
290
291 uint32_t m_frameNo; ///< frame number
292 uint32_t m_subframeNo; ///< subframe number
293 uint8_t m_raRnti; ///< RA RNTI
294 bool m_waitingForRaResponse; ///< waiting for RA response
295
296 /**
297 * \brief The `RaResponseTimeout` trace source. Fired RA response timeout.
298 * Exporting IMSI, contention flag, preamble transmission counter
299 * and the max limit of preamble transmission.
300 */
302};
303
304} // namespace ns3
305
306#endif // LTE_UE_MAC_ENTITY
An identifier for simulation events.
Definition: event-id.h:55
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:36
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition: lte-mac-sap.h:96
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
Service Access Point (SAP) offered by the UE MAC to the UE RRC.
uint8_t m_raRnti
RA RNTI.
Definition: lte-ue-mac.h:293
std::vector< Ptr< PacketBurst > > m_miUlHarqProcessesPacket
Packets under transmission of the UL HARQ processes.
Definition: lte-ue-mac.h:277
LteUePhySapUser * m_uePhySapUser
UE Phy SAP user.
Definition: lte-ue-mac.h:265
uint8_t m_componentCarrierId
component carrier Id --> used to address sap
Definition: lte-ue-mac.h:247
void RaResponseTimeout(bool contention)
RA response timeout function.
Definition: lte-ue-mac.cc:486
LteUeCmacSapProvider::RachConfig m_rachConfig
RACH configuration.
Definition: lte-ue-mac.h:284
uint32_t m_frameNo
frame number
Definition: lte-ue-mac.h:291
void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Forwarded from LteUePhySapUser: trigger the start from a new frame.
Definition: lte-ue-mac.cc:907
void SendReportBufferStatus()
Send report buffer status.
Definition: lte-ue-mac.cc:352
void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params)
Report buffers status function.
Definition: lte-ue-mac.cc:332
TracedCallback< uint64_t, bool, uint8_t, uint8_t > m_raResponseTimeoutTrace
The RaResponseTimeout trace source.
Definition: lte-ue-mac.h:301
LteUePhySapProvider * m_uePhySapProvider
UE Phy SAP provider.
Definition: lte-ue-mac.h:264
void SetLteUePhySapProvider(LteUePhySapProvider *s)
Set the PHY SAP Provider.
Definition: lte-ue-mac.cc:289
Time m_bsrPeriodicity
BSR periodicity.
Definition: lte-ue-mac.h:270
void RefreshHarqProcessesPacketBuffer()
Refresh HARQ processes packet buffer function.
Definition: lte-ue-mac.cc:883
uint16_t m_imsi
IMSI.
Definition: lte-ue-mac.h:281
EventId m_noRaResponseReceivedEvent
no RA response received event ID
Definition: lte-ue-mac.h:288
LteUeCmacSapProvider * m_cmacSapProvider
CMAC SAP provider.
Definition: lte-ue-mac.h:262
uint8_t m_preambleTransmissionCounter
preamble tranamission counter
Definition: lte-ue-mac.h:286
Ptr< UniformRandomVariable > m_raPreambleUniformVariable
RA preamble random variable.
Definition: lte-ue-mac.h:289
void SetComponentCarrierId(uint8_t index)
Set the component carried ID.
Definition: lte-ue-mac.cc:313
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: lte-ue-mac.cc:927
void DoConfigureRach(LteUeCmacSapProvider::RachConfig rc)
Configure RACH function.
Definition: lte-ue-mac.cc:517
LteUePhySapUser * GetLteUePhySapUser()
Get the PHY SAP user.
Definition: lte-ue-mac.cc:283
bool m_rachConfigured
is RACH configured?
Definition: lte-ue-mac.h:283
void DoRemoveLc(uint8_t lcId)
Remove LC function.
Definition: lte-ue-mac.cc:582
void RecvRaResponse(BuildRarListElement_s raResponse)
Receive the RA response function.
Definition: lte-ue-mac.cc:444
void DoReceivePhyPdu(Ptr< Packet > p)
Receive Phy PDU function.
Definition: lte-ue-mac.cc:624
uint8_t m_raPreambleId
RA preamble ID.
Definition: lte-ue-mac.h:285
void DoNotifyConnectionSuccessful()
Notify MAC about the successful RRC connection establishment.
Definition: lte-ue-mac.cc:617
Time m_bsrLast
BSR last.
Definition: lte-ue-mac.h:271
std::vector< uint8_t > m_miUlHarqProcessesPacketTimer
timer for packet life in the buffer
Definition: lte-ue-mac.h:278
void DoReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive LTE control message function.
Definition: lte-ue-mac.cc:648
uint16_t m_rnti
RNTI.
Definition: lte-ue-mac.h:280
static TypeId GetTypeId()
Get the type ID.
Definition: lte-ue-mac.cc:223
void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params)
Transmit PDU function.
Definition: lte-ue-mac.cc:319
uint32_t m_subframeNo
subframe number
Definition: lte-ue-mac.h:292
std::map< uint8_t, LteMacSapProvider::ReportBufferStatusParameters > m_ulBsrReceived
BSR received from RLC (the last one)
Definition: lte-ue-mac.h:268
void DoDispose() override
Destructor implementation.
Definition: lte-ue-mac.cc:272
void DoReset()
Reset function.
Definition: lte-ue-mac.cc:591
~LteUeMac() override
Definition: lte-ue-mac.cc:266
LteUeCmacSapUser * m_cmacSapUser
CMAC SAP user.
Definition: lte-ue-mac.h:261
bool m_freshUlBsr
true when a BSR has been received in the last TTI
Definition: lte-ue-mac.h:273
LteMacSapProvider * GetLteMacSapProvider()
Get the LTE MAC SAP provider.
Definition: lte-ue-mac.cc:295
void DoStartNonContentionBasedRandomAccessProcedure(uint16_t rnti, uint8_t rapId, uint8_t prachMask)
Start non contention based random access procedure function.
Definition: lte-ue-mac.cc:551
LteUeCmacSapProvider * GetLteUeCmacSapProvider()
Get the LTE CMAC SAP provider.
Definition: lte-ue-mac.cc:307
bool m_waitingForRaResponse
waiting for RA response
Definition: lte-ue-mac.h:294
void DoAddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Add LC function.
Definition: lte-ue-mac.cc:567
uint8_t m_harqProcessId
HARQ process ID.
Definition: lte-ue-mac.h:275
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition: lte-ue-mac.h:259
void RandomlySelectAndSendRaPreamble()
Randomly select and send RA preamble function.
Definition: lte-ue-mac.cc:400
void DoStartContentionBasedRandomAccessProcedure()
Start contention based random access procedure function.
Definition: lte-ue-mac.cc:525
void(* RaResponseTimeoutTracedCallback)(uint64_t imsi, bool contention, uint8_t preambleTxCounter, uint8_t maxPreambleTxLimit)
TracedCallback signature for RA response timeout events exporting IMSI, contention flag,...
Definition: lte-ue-mac.h:73
uint16_t m_backoffParameter
backoff parameter
Definition: lte-ue-mac.h:287
void StartWaitingForRaResponse()
Start waiting for RA response function.
Definition: lte-ue-mac.cc:437
void DoSetRnti(uint16_t rnti)
Set RNTI.
Definition: lte-ue-mac.cc:537
void DoSetImsi(uint64_t imsi)
Set IMSI.
Definition: lte-ue-mac.cc:544
void SendRaPreamble(bool contention)
Send RA preamble function.
Definition: lte-ue-mac.cc:413
void SetLteUeCmacSapUser(LteUeCmacSapUser *s)
Set the LTE UE CMAC SAP user.
Definition: lte-ue-mac.cc:301
std::map< uint8_t, LcInfo > m_lcInfoMap
logical channel info map
Definition: lte-ue-mac.h:257
Service Access Point (SAP) offered by the UE-PHY to the UE-MAC.
Service Access Point (SAP) offered by the PHY to the MAC.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
UeMemberLteMacSapProvider class.
Definition: lte-ue-mac.cc:139
UeMemberLteUeCmacSapProvider class.
Definition: lte-ue-mac.cc:48
UeMemberLteUePhySapUser.
Definition: lte-ue-mac.cc:177
Every class exported by the ns3 library is enclosed in the ns3 namespace.
See section 4.3.10 buildRARListElement.
Parameters for LteMacSapProvider::ReportBufferStatus.
Definition: lte-mac-sap.h:69
Parameters for LteMacSapProvider::TransmitPdu.
Definition: lte-mac-sap.h:45
LcInfo structure.
Definition: lte-ue-mac.h:252
LteUeCmacSapProvider::LogicalChannelConfig lcConfig
logical channel config
Definition: lte-ue-mac.h:253
LteMacSapUser * macSapUser
MAC SAP user.
Definition: lte-ue-mac.h:254