-
Notifications
You must be signed in to change notification settings - Fork 0
/
lte-enb-mac.h
297 lines (239 loc) · 9.59 KB
/
lte-enb-mac.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Marco Miozzo <marco.miozzo@cttc.es>
* Nicola Baldo <nbaldo@cttc.es>
*/
#ifndef LTE_ENB_MAC_H
#define LTE_ENB_MAC_H
#include <map>
#include <vector>
#include <ns3/lte-common.h>
#include <ns3/lte-mac-sap.h>
#include <ns3/lte-enb-cmac-sap.h>
#include <ns3/ff-mac-csched-sap.h>
#include <ns3/ff-mac-sched-sap.h>
#include <ns3/lte-enb-phy-sap.h>
#include "ns3/traced-value.h"
#include "ns3/trace-source-accessor.h"
#include <ns3/packet.h>
#include <ns3/packet-burst.h>
namespace ns3 {
class DlCqiLteControlMessage;
class UlCqiLteControlMessage;
class PdcchMapLteControlMessage;
typedef std::vector <std::vector < Ptr<PacketBurst> > > DlHarqProcessesBuffer_t;
/**
* This class implements the MAC layer of the eNodeB device
*/
class LteEnbMac : public Object
{
friend class EnbMacMemberLteEnbCmacSapProvider;
friend class EnbMacMemberLteMacSapProvider<LteEnbMac>;
friend class EnbMacMemberFfMacSchedSapUser;
friend class EnbMacMemberFfMacCschedSapUser;
friend class EnbMacMemberLteEnbPhySapUser;
public:
static TypeId GetTypeId (void);
LteEnbMac (void);
virtual ~LteEnbMac (void);
virtual void DoDispose (void);
/**
* \brief Set the scheduler SAP provider
* \param s a pointer SAP provider of the FF packet scheduler
*/
void SetFfMacSchedSapProvider (FfMacSchedSapProvider* s);
/**
* \brief Get the scheduler SAP user
* \return a pointer to the SAP user of the scheduler
*/
FfMacSchedSapUser* GetFfMacSchedSapUser (void);
/**
* \brief Set the control scheduler SAP provider
* \param s a pointer to the control scheduler SAP provider
*/
void SetFfMacCschedSapProvider (FfMacCschedSapProvider* s);
/**
* \brief Get the control scheduler SAP user
* \return a pointer to the control scheduler SAP user
*/
FfMacCschedSapUser* GetFfMacCschedSapUser (void);
/**
* \brief Set the MAC SAP user
* \param s a pointer to the MAC SAP user
*/
void SetLteMacSapUser (LteMacSapUser* s);
/**
* \brief Get the MAC SAP provider
* \return a pointer to the SAP provider of the MAC
*/
LteMacSapProvider* GetLteMacSapProvider (void);
/**
* \brief Set the control MAC SAP user
* \param s a pointer to the control MAC SAP user
*/
void SetLteEnbCmacSapUser (LteEnbCmacSapUser* s);
/**
* \brief Get the control MAC SAP provider
* \return a pointer to the control MAC SAP provider
*/
LteEnbCmacSapProvider* GetLteEnbCmacSapProvider (void);
/**
* \brief Get the eNB-PHY SAP User
* \return a pointer to the SAP User of the PHY
*/
LteEnbPhySapUser* GetLteEnbPhySapUser ();
/**
* \brief Set the PHY SAP Provider
* \param s a pointer to the PHY SAP provider
*/
void SetLteEnbPhySapProvider (LteEnbPhySapProvider* s);
/**
* TracedCallback signature for DL scheduling events.
*
* \param [in] frame Frame number.
* \param [in] subframe Subframe number.
* \param [in] rnti The C-RNTI identifying the UE.
* \param [in] mcs0 The MCS for transport block..
* \param [in] tbs0Size
* \param [in] mcs1 The MCS for transport block.
* \param [in] tbs1Size
*/
typedef void (* DlSchedulingTracedCallback)
(uint32_t frame, uint32_t subframe, uint16_t rnti,
uint8_t mcs0, uint16_t tbs0Size,
uint8_t mcs1, uint16_t tbs1Size);
/**
* TracedCallback signature for UL scheduling events.
*
* \param [in] frame Frame number.
* \param [in] subframe Subframe number.
* \param [in] rnti The C-RNTI identifying the UE.
* \param [in] mcs The MCS for transport block
* \param [in] tbsSize
*/
typedef void (* UlSchedulingTracedCallback)
(uint32_t frame, uint32_t subframe, uint16_t rnti,
uint8_t mcs, uint16_t tbsSize);
private:
/**
* \brief Receive a DL CQI ideal control message
* \param msg the DL CQI message
*/
void ReceiveDlCqiLteControlMessage (Ptr<DlCqiLteControlMessage> msg);
void DoReceiveLteControlMessage (Ptr<LteControlMessage> msg);
/**
* \brief Receive a CE element containing the buffer status report
* \param bsr the BSR message
*/
void ReceiveBsrMessage (MacCeListElement_s bsr);
void DoUlCqiReport (FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi);
// forwarded from LteEnbCmacSapProvider
void DoConfigureMac (uint8_t ulBandwidth, uint8_t dlBandwidth);
void DoAddUe (uint16_t rnti);
void DoRemoveUe (uint16_t rnti);
void DoAddLc (LteEnbCmacSapProvider::LcInfo lcinfo, LteMacSapUser* msu);
void DoReconfigureLc (LteEnbCmacSapProvider::LcInfo lcinfo);
void DoReleaseLc (uint16_t rnti, uint8_t lcid);
void DoUeUpdateConfigurationReq (LteEnbCmacSapProvider::UeConfig params);
LteEnbCmacSapProvider::RachConfig DoGetRachConfig ();
LteEnbCmacSapProvider::AllocateNcRaPreambleReturnValue DoAllocateNcRaPreamble (uint16_t rnti);
// forwarded from LteMacSapProvider
void DoTransmitPdu (LteMacSapProvider::TransmitPduParameters);
void DoReportBufferStatus (LteMacSapProvider::ReportBufferStatusParameters);
// forwarded from FfMacCchedSapUser
void DoCschedCellConfigCnf (FfMacCschedSapUser::CschedCellConfigCnfParameters params);
void DoCschedUeConfigCnf (FfMacCschedSapUser::CschedUeConfigCnfParameters params);
void DoCschedLcConfigCnf (FfMacCschedSapUser::CschedLcConfigCnfParameters params);
void DoCschedLcReleaseCnf (FfMacCschedSapUser::CschedLcReleaseCnfParameters params);
void DoCschedUeReleaseCnf (FfMacCschedSapUser::CschedUeReleaseCnfParameters params);
void DoCschedUeConfigUpdateInd (FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params);
void DoCschedCellConfigUpdateInd (FfMacCschedSapUser::CschedCellConfigUpdateIndParameters params);
// forwarded from FfMacSchedSapUser
void DoSchedDlConfigInd (FfMacSchedSapUser::SchedDlConfigIndParameters ind);
void DoSchedUlConfigInd (FfMacSchedSapUser::SchedUlConfigIndParameters params);
// forwarded from LteEnbPhySapUser
void DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo);
void DoReceiveRachPreamble (uint8_t prachId);
public:
// legacy public for use the Phy callback
void DoReceivePhyPdu (Ptr<Packet> p);
private:
void DoUlInfoListElementHarqFeeback (UlInfoListElement_s params);
void DoDlInfoListElementHarqFeeback (DlInfoListElement_s params);
// rnti, lcid, SAP of the RLC instance
std::map <uint16_t, std::map<uint8_t, LteMacSapUser*> > m_rlcAttached;
std::vector <CqiListElement_s> m_dlCqiReceived; // DL-CQI received
std::vector <FfMacSchedSapProvider::SchedUlCqiInfoReqParameters> m_ulCqiReceived; // UL-CQI received
std::vector <MacCeListElement_s> m_ulCeReceived; // CE received (BSR up to now)
std::vector <DlInfoListElement_s> m_dlInfoListReceived; // DL HARQ feedback received
std::vector <UlInfoListElement_s> m_ulInfoListReceived; // UL HARQ feedback received
/*
* Map of UE's info element (see 4.3.12 of FF MAC Scheduler API)
*/
// std::map <uint16_t,UlInfoListElement_s> m_ulInfoListElements;
LteMacSapProvider* m_macSapProvider;
LteEnbCmacSapProvider* m_cmacSapProvider;
LteMacSapUser* m_macSapUser;
LteEnbCmacSapUser* m_cmacSapUser;
FfMacSchedSapProvider* m_schedSapProvider;
FfMacCschedSapProvider* m_cschedSapProvider;
FfMacSchedSapUser* m_schedSapUser;
FfMacCschedSapUser* m_cschedSapUser;
// PHY-SAP
LteEnbPhySapProvider* m_enbPhySapProvider;
LteEnbPhySapUser* m_enbPhySapUser;
uint32_t m_frameNo;
uint32_t m_subframeNo;
/**
* Trace information regarding DL scheduling
* Frame number, Subframe number, RNTI, MCS of TB1, size of TB1,
* MCS of TB2 (0 if not present), size of TB2 (0 if not present)
*/
TracedCallback<uint32_t, uint32_t, uint16_t,
uint8_t, uint16_t, uint8_t, uint16_t> m_dlScheduling;
/**
* Trace information regarding UL scheduling
* Frame number, Subframe number, RNTI, MCS of TB, size of TB
*/
TracedCallback<uint32_t, uint32_t, uint16_t,
uint8_t, uint16_t> m_ulScheduling;
uint8_t m_macChTtiDelay; // delay of MAC, PHY and channel in terms of TTIs
std::map <uint16_t, DlHarqProcessesBuffer_t> m_miDlHarqProcessesPackets; // Packet under trasmission of the DL HARQ process
uint8_t m_numberOfRaPreambles;
uint8_t m_preambleTransMax;
uint8_t m_raResponseWindowSize;
/**
* info associated with a preamble allocated for non-contention based RA
*
*/
struct NcRaPreambleInfo
{
uint16_t rnti; ///< rnti previously allocated for this non-contention based RA procedure
Time expiryTime; ///< value the expiration time of this allocation (so that stale preambles can be reused)
};
/**
* map storing as key the random acccess preamble IDs allocated for
* non-contention based access, and as value the associated info
*
*/
std::map<uint8_t, NcRaPreambleInfo> m_allocatedNcRaPreambleMap;
std::map<uint8_t, uint32_t> m_receivedRachPreambleCount;
std::map<uint8_t, uint32_t> m_rapIdRntiMap;
};
} // end namespace ns3
#endif /* LTE_ENB_MAC_ENTITY_H */