A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lte-ue-mac.h
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Nicola Baldo <nbaldo@cttc.es>
19  * Author: Marco Miozzo <mmiozzo@cttc.es>
20  */
21 
22 #ifndef LTE_UE_MAC_ENTITY_H
23 #define LTE_UE_MAC_ENTITY_H
24 
25 
26 
27 #include <map>
28 
29 #include <ns3/lte-mac-sap.h>
30 #include <ns3/lte-ue-cmac-sap.h>
31 #include <ns3/lte-ue-phy-sap.h>
32 #include <ns3/nstime.h>
33 #include <ns3/event-id.h>
34 #include <vector>
35 #include <ns3/packet.h>
36 #include <ns3/packet-burst.h>
37 
38 
39 namespace ns3 {
40 
41 class UniformRandomVariable;
42 
43 class LteUeMac : public Object
44 {
45  friend class UeMemberLteUeCmacSapProvider;
46  friend class UeMemberLteMacSapProvider;
47  friend class UeMemberLteUePhySapUser;
48 
49 public:
50  static TypeId GetTypeId (void);
51 
52  LteUeMac ();
53  virtual ~LteUeMac ();
54  virtual void DoDispose (void);
55 
56  LteMacSapProvider* GetLteMacSapProvider (void);
57  void SetLteUeCmacSapUser (LteUeCmacSapUser* s);
58  LteUeCmacSapProvider* GetLteUeCmacSapProvider (void);
59 
65 
71 
78  void DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo);
79 
88  int64_t AssignStreams (int64_t stream);
89 
90 private:
91  // forwarded from MAC SAP
92  void DoTransmitPdu (LteMacSapProvider::TransmitPduParameters params);
93  void DoReportBufferStatus (LteMacSapProvider::ReportBufferStatusParameters params);
94 
95  // forwarded from UE CMAC SAP
96  void DoConfigureRach (LteUeCmacSapProvider::RachConfig rc);
97  void DoStartContentionBasedRandomAccessProcedure ();
98  void DoStartNonContentionBasedRandomAccessProcedure (uint16_t rnti, uint8_t rapId, uint8_t prachMask);
99  void DoAddLc (uint8_t lcId, LteUeCmacSapProvider::LogicalChannelConfig lcConfig, LteMacSapUser* msu);
100  void DoRemoveLc (uint8_t lcId);
101  void DoReset ();
102 
103  // forwarded from PHY SAP
104  void DoReceivePhyPdu (Ptr<Packet> p);
105  void DoReceiveLteControlMessage (Ptr<LteControlMessage> msg);
106 
107  // internal methods
108  void RandomlySelectAndSendRaPreamble ();
109  void SendRaPreamble (bool contention);
110  void StartWaitingForRaResponse ();
111  void RecvRaResponse (BuildRarListElement_s raResponse);
112  void RaResponseTimeout (bool contention);
113  void SendReportBufferStatus (void);
114  void RefreshHarqProcessesPacketBuffer (void);
115 
116 private:
117 
118  struct LcInfo
119  {
121  LteMacSapUser* macSapUser;
122  };
123 
124  std::map <uint8_t, LcInfo> m_lcInfoMap;
125 
126  LteMacSapProvider* m_macSapProvider;
127 
128  LteUeCmacSapUser* m_cmacSapUser;
129  LteUeCmacSapProvider* m_cmacSapProvider;
130 
131  LteUePhySapProvider* m_uePhySapProvider;
132  LteUePhySapUser* m_uePhySapUser;
133 
134  std::map <uint8_t, LteMacSapProvider::ReportBufferStatusParameters> m_ulBsrReceived; // BSR received from RLC (the last one)
135 
136 
137  Time m_bsrPeriodicity;
138  Time m_bsrLast;
139 
140  bool m_freshUlBsr; // true when a BSR has been received in the last TTI
141 
142  uint8_t m_harqProcessId;
143  std::vector < Ptr<PacketBurst> > m_miUlHarqProcessesPacket; // Packets under trasmission of the UL HARQ processes
144  std::vector < uint8_t > m_miUlHarqProcessesPacketTimer; // timer for packet life in the buffer
145 
146  uint16_t m_rnti;
147 
148  bool m_rachConfigured;
150  uint8_t m_raPreambleId;
151  uint8_t m_preambleTransmissionCounter;
152  uint16_t m_backoffParameter;
153  EventId m_noRaResponseReceivedEvent;
154  Ptr<UniformRandomVariable> m_raPreambleUniformVariable;
155 
156  uint32_t m_frameNo;
157  uint32_t m_subframeNo;
158  uint8_t m_raRnti;
159  bool m_waitingForRaResponse;
160 };
161 
162 } // namespace ns3
163 
164 #endif // LTE_UE_MAC_ENTITY
keep track of time unit.
Definition: nstime.h:149
See section 4.3.10 buildRARListElement.
void SetLteUePhySapProvider(LteUePhySapProvider *s)
Set the PHY SAP Provider.
Definition: lte-ue-mac.cc:253
void DoSubframeIndication(uint32_t frameNo, uint32_t subframeNo)
Forwarded from LteUePhySapUser: trigger the start from a new frame.
Definition: lte-ue-mac.cc:732
LteUePhySapUser * GetLteUePhySapUser()
Get the PHY SAP user.
Definition: lte-ue-mac.cc:247
an identifier for simulation events.
Definition: event-id.h:46
virtual void DoDispose(void)
Definition: lte-ue-mac.cc:235
a base class which provides memory management and object aggregation
Definition: object.h:63
int64_t AssignStreams(int64_t stream)
Definition: lte-ue-mac.cc:748
a unique identifier for an interface.
Definition: type-id.h:44