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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 * Author: Marco Miozzo <mmiozzo@cttc.es>
8 */
9
10#ifndef LTE_UE_MAC_ENTITY_H
11#define LTE_UE_MAC_ENTITY_H
12
13#include "ff-mac-common.h"
14#include "lte-mac-sap.h"
15#include "lte-ue-cmac-sap.h"
16#include "lte-ue-phy-sap.h"
17
18#include <ns3/event-id.h>
19#include <ns3/nstime.h>
20#include <ns3/packet-burst.h>
21#include <ns3/packet.h>
22#include <ns3/traced-callback.h>
23
24#include <map>
25#include <vector>
26
27namespace ns3
28{
29
30class UniformRandomVariable;
31
32class LteUeMac : public Object
33{
34 /// allow UeMemberLteUeCmacSapProvider class friend access
36 /// allow UeMemberLteMacSapProvider class friend access
38 /// allow UeMemberLteUePhySapUser class friend access
40
41 public:
42 /**
43 * \brief Get the type ID.
44 * \return the object TypeId
45 */
46 static TypeId GetTypeId();
47
48 LteUeMac();
49 ~LteUeMac() override;
50 void DoDispose() override;
51
52 /**
53 * \brief TracedCallback signature for RA response timeout events
54 * exporting IMSI, contention flag, preamble transmission counter
55 * and the max limit of preamble transmission
56 *
57 * \param [in] imsi
58 * \param [in] contention
59 * \param [in] preambleTxCounter
60 * \param [in] maxPreambleTxLimit
61 */
62 typedef void (*RaResponseTimeoutTracedCallback)(uint64_t imsi,
63 bool contention,
64 uint8_t preambleTxCounter,
65 uint8_t maxPreambleTxLimit);
66
67 /**
68 * \brief Get the LTE MAC SAP provider
69 * \return a pointer to the LTE MAC SAP provider
70 */
72 /**
73 * \brief Set the LTE UE CMAC SAP user
74 * \param s the LTE UE CMAC SAP User
75 */
77 /**
78 * \brief Get the LTE CMAC SAP provider
79 * \return a pointer to the LTE CMAC SAP provider
80 */
82
83 /**
84 * \brief Set the component carried ID
85 * \param index the component carrier ID
86 */
87 void SetComponentCarrierId(uint8_t index);
88
89 /**
90 * \brief Get the PHY SAP user
91 * \return a pointer to the SAP user of the PHY
92 */
94
95 /**
96 * \brief Set the PHY SAP Provider
97 * \param s a pointer to the PHY SAP Provider
98 */
100
101 /**
102 * \brief Forwarded from LteUePhySapUser: trigger the start from a new frame
103 *
104 * \param frameNo frame number
105 * \param subframeNo subframe number
106 */
107 void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo);
108
109 /**
110 * Assign a fixed random variable stream number to the random variables
111 * used by this model. Return the number of streams (possibly zero) that
112 * have been assigned.
113 *
114 * \param stream first stream index to use
115 * \return the number of stream indices assigned by this model
116 */
117 int64_t AssignStreams(int64_t stream);
118
119 private:
120 // forwarded from MAC SAP
121 /**
122 * Transmit PDU function
123 *
124 * \param params LteMacSapProvider::TransmitPduParameters
125 */
127 /**
128 * Report buffers status function
129 *
130 * \param params LteMacSapProvider::ReportBufferStatusParameters
131 */
133
134 // forwarded from UE CMAC SAP
135 /**
136 * Configure RACH function
137 *
138 * \param rc LteUeCmacSapProvider::RachConfig
139 */
141 /**
142 * Start contention based random access procedure function
143 */
145 /**
146 * Set RNTI
147 *
148 * \param rnti the RNTI
149 */
150 void DoSetRnti(uint16_t rnti);
151 /**
152 * Start non contention based random access procedure function
153 *
154 * \param rnti the RNTI
155 * \param rapId the RAPID
156 * \param prachMask the PRACH mask
157 */
159 uint8_t rapId,
160 uint8_t prachMask);
161 /**
162 * Add LC function
163 *
164 * \param lcId the LCID
165 * \param lcConfig the logical channel config
166 * \param msu the MSU
167 */
168 void DoAddLc(uint8_t lcId,
170 LteMacSapUser* msu);
171 /**
172 * Remove LC function
173 *
174 * \param lcId the LCID
175 */
176 void DoRemoveLc(uint8_t lcId);
177 /**
178 * \brief Reset function
179 */
180 void DoReset();
181 /**
182 * \brief Notify MAC about the successful RRC connection
183 * establishment.
184 */
186 /**
187 * Set IMSI
188 *
189 * \param imsi the IMSI of the UE
190 */
191 void DoSetImsi(uint64_t imsi);
192
193 // forwarded from PHY SAP
194 /**
195 * Receive Phy PDU function
196 *
197 * \param p the packet
198 */
200 /**
201 * Receive LTE control message function
202 *
203 * \param msg the LTE control message
204 */
206
207 // internal methods
208 /// Randomly select and send RA preamble function
210 /**
211 * Send RA preamble function
212 *
213 * \param contention if true randomly select and send the RA preamble
214 */
215 void SendRaPreamble(bool contention);
216 /// Start waiting for RA response function
218 /**
219 * Receive the RA response function
220 *
221 * \param raResponse RA response received
222 */
223 void RecvRaResponse(BuildRarListElement_s raResponse);
224 /**
225 * RA response timeout function
226 *
227 * \param contention if true randomly select and send the RA preamble
228 */
229 void RaResponseTimeout(bool contention);
230 /// Send report buffer status
232 /// Refresh HARQ processes packet buffer function
234
235 /// component carrier Id --> used to address sap
237
238 private:
239 /// LcInfo structure
240 struct LcInfo
241 {
243 LteMacSapUser* macSapUser; ///< MAC SAP user
244 };
245
246 std::map<uint8_t, LcInfo> m_lcInfoMap; ///< logical channel info map
247
248 LteMacSapProvider* m_macSapProvider; ///< MAC SAP provider
249
250 LteUeCmacSapUser* m_cmacSapUser; ///< CMAC SAP user
252
253 LteUePhySapProvider* m_uePhySapProvider; ///< UE Phy SAP provider
254 LteUePhySapUser* m_uePhySapUser; ///< UE Phy SAP user
255
256 std::map<uint8_t, LteMacSapProvider::ReportBufferStatusParameters>
257 m_ulBsrReceived; ///< BSR received from RLC (the last one)
258
259 Time m_bsrPeriodicity; ///< BSR periodicity
260 Time m_bsrLast; ///< BSR last
261
262 bool m_freshUlBsr; ///< true when a BSR has been received in the last TTI
263
264 uint8_t m_harqProcessId; ///< HARQ process ID
265 std::vector<Ptr<PacketBurst>>
266 m_miUlHarqProcessesPacket; ///< Packets under transmission of the UL HARQ processes
267 std::vector<uint8_t> m_miUlHarqProcessesPacketTimer; ///< timer for packet life in the buffer
268
269 uint16_t m_rnti; ///< RNTI
270 uint16_t m_imsi; ///< IMSI
271
272 bool m_rachConfigured; ///< is RACH configured?
274 uint8_t m_raPreambleId; ///< RA preamble ID
275 uint8_t m_preambleTransmissionCounter; ///< preamble tranamission counter
276 uint16_t m_backoffParameter; ///< backoff parameter
277 EventId m_noRaResponseReceivedEvent; ///< no RA response received event ID
279
280 uint32_t m_frameNo; ///< frame number
281 uint32_t m_subframeNo; ///< subframe number
282 uint8_t m_raRnti; ///< RA RNTI
283 bool m_waitingForRaResponse; ///< waiting for RA response
284
285 /**
286 * \brief The `RaResponseTimeout` trace source. Fired RA response timeout.
287 * Exporting IMSI, contention flag, preamble transmission counter
288 * and the max limit of preamble transmission.
289 */
291};
292
293} // namespace ns3
294
295#endif // LTE_UE_MAC_ENTITY
An identifier for simulation events.
Definition event-id.h:45
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition lte-mac-sap.h:25
Service Access Point (SAP) offered by the MAC to the RLC See Femto Forum MAC Scheduler Interface Spec...
Definition lte-mac-sap.h:85
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:282
std::vector< Ptr< PacketBurst > > m_miUlHarqProcessesPacket
Packets under transmission of the UL HARQ processes.
Definition lte-ue-mac.h:266
LteUePhySapUser * m_uePhySapUser
UE Phy SAP user.
Definition lte-ue-mac.h:254
uint8_t m_componentCarrierId
component carrier Id --> used to address sap
Definition lte-ue-mac.h:236
void RaResponseTimeout(bool contention)
RA response timeout function.
LteUeCmacSapProvider::RachConfig m_rachConfig
RACH configuration.
Definition lte-ue-mac.h:273
uint32_t m_frameNo
frame number
Definition lte-ue-mac.h:280
void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Forwarded from LteUePhySapUser: trigger the start from a new frame.
void SendReportBufferStatus()
Send report buffer status.
void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters params)
Report buffers status function.
TracedCallback< uint64_t, bool, uint8_t, uint8_t > m_raResponseTimeoutTrace
The RaResponseTimeout trace source.
Definition lte-ue-mac.h:290
LteUePhySapProvider * m_uePhySapProvider
UE Phy SAP provider.
Definition lte-ue-mac.h:253
void SetLteUePhySapProvider(LteUePhySapProvider *s)
Set the PHY SAP Provider.
Time m_bsrPeriodicity
BSR periodicity.
Definition lte-ue-mac.h:259
void RefreshHarqProcessesPacketBuffer()
Refresh HARQ processes packet buffer function.
uint16_t m_imsi
IMSI.
Definition lte-ue-mac.h:270
EventId m_noRaResponseReceivedEvent
no RA response received event ID
Definition lte-ue-mac.h:277
LteUeCmacSapProvider * m_cmacSapProvider
CMAC SAP provider.
Definition lte-ue-mac.h:251
uint8_t m_preambleTransmissionCounter
preamble tranamission counter
Definition lte-ue-mac.h:275
Ptr< UniformRandomVariable > m_raPreambleUniformVariable
RA preamble random variable.
Definition lte-ue-mac.h:278
void SetComponentCarrierId(uint8_t index)
Set the component carried ID.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void DoConfigureRach(LteUeCmacSapProvider::RachConfig rc)
Configure RACH function.
LteUePhySapUser * GetLteUePhySapUser()
Get the PHY SAP user.
bool m_rachConfigured
is RACH configured?
Definition lte-ue-mac.h:272
void DoRemoveLc(uint8_t lcId)
Remove LC function.
void RecvRaResponse(BuildRarListElement_s raResponse)
Receive the RA response function.
void DoReceivePhyPdu(Ptr< Packet > p)
Receive Phy PDU function.
uint8_t m_raPreambleId
RA preamble ID.
Definition lte-ue-mac.h:274
void DoNotifyConnectionSuccessful()
Notify MAC about the successful RRC connection establishment.
Time m_bsrLast
BSR last.
Definition lte-ue-mac.h:260
std::vector< uint8_t > m_miUlHarqProcessesPacketTimer
timer for packet life in the buffer
Definition lte-ue-mac.h:267
void DoReceiveLteControlMessage(Ptr< LteControlMessage > msg)
Receive LTE control message function.
uint16_t m_rnti
RNTI.
Definition lte-ue-mac.h:269
static TypeId GetTypeId()
Get the type ID.
void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters params)
Transmit PDU function.
uint32_t m_subframeNo
subframe number
Definition lte-ue-mac.h:281
std::map< uint8_t, LteMacSapProvider::ReportBufferStatusParameters > m_ulBsrReceived
BSR received from RLC (the last one)
Definition lte-ue-mac.h:257
void DoDispose() override
Destructor implementation.
void DoReset()
Reset function.
~LteUeMac() override
LteUeCmacSapUser * m_cmacSapUser
CMAC SAP user.
Definition lte-ue-mac.h:250
bool m_freshUlBsr
true when a BSR has been received in the last TTI
Definition lte-ue-mac.h:262
LteMacSapProvider * GetLteMacSapProvider()
Get the LTE MAC SAP provider.
void DoStartNonContentionBasedRandomAccessProcedure(uint16_t rnti, uint8_t rapId, uint8_t prachMask)
Start non contention based random access procedure function.
LteUeCmacSapProvider * GetLteUeCmacSapProvider()
Get the LTE CMAC SAP provider.
bool m_waitingForRaResponse
waiting for RA response
Definition lte-ue-mac.h:283
void DoAddLc(uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser *msu)
Add LC function.
uint8_t m_harqProcessId
HARQ process ID.
Definition lte-ue-mac.h:264
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Definition lte-ue-mac.h:248
void RandomlySelectAndSendRaPreamble()
Randomly select and send RA preamble function.
void DoStartContentionBasedRandomAccessProcedure()
Start contention based random access procedure function.
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:62
uint16_t m_backoffParameter
backoff parameter
Definition lte-ue-mac.h:276
void StartWaitingForRaResponse()
Start waiting for RA response function.
void DoSetRnti(uint16_t rnti)
Set RNTI.
void DoSetImsi(uint64_t imsi)
Set IMSI.
void SendRaPreamble(bool contention)
Send RA preamble function.
void SetLteUeCmacSapUser(LteUeCmacSapUser *s)
Set the LTE UE CMAC SAP user.
std::map< uint8_t, LcInfo > m_lcInfoMap
logical channel info map
Definition lte-ue-mac.h:246
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:78
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
UeMemberLteMacSapProvider class.
UeMemberLteUeCmacSapProvider class.
Definition lte-ue-mac.cc:37
UeMemberLteUePhySapUser.
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:58
Parameters for LteMacSapProvider::TransmitPdu.
Definition lte-mac-sap.h:34
LcInfo structure.
Definition lte-ue-mac.h:241
LteUeCmacSapProvider::LogicalChannelConfig lcConfig
logical channel config
Definition lte-ue-mac.h:242
LteMacSapUser * macSapUser
MAC SAP user.
Definition lte-ue-mac.h:243