A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-simple-helper.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2012 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: Manuel Requena <manuel.requena@cttc.es> (Based on lte-helper.cc)
19  */
20 
21 
22 #include "ns3/log.h"
23 #include "ns3/callback.h"
24 #include "ns3/config.h"
25 #include "ns3/simple-channel.h"
26 #include "ns3/error-model.h"
27 
28 #include "lte-simple-helper.h"
29 #include "lte-simple-net-device.h"
30 #include "lte-test-entities.h"
31 
32 
33 NS_LOG_COMPONENT_DEFINE ("LteSimpleHelper");
34 
35 namespace ns3 {
36 
37 
38 NS_OBJECT_ENSURE_REGISTERED (LteSimpleHelper);
39 
41 {
42  NS_LOG_FUNCTION (this);
45 }
46 
47 void
49 {
50  NS_LOG_FUNCTION (this);
51 
52  m_phyChannel = CreateObject<SimpleChannel> ();
53 
54  Object::DoStart ();
55 }
56 
58 {
59  NS_LOG_FUNCTION (this);
60 }
61 
63 {
64  static TypeId
65  tid =
66  TypeId ("ns3::LteSimpleHelper")
67  .SetParent<Object> ()
68  .AddConstructor<LteSimpleHelper> ()
69  .AddAttribute ("RlcEntity",
70  "Specify which type of RLC will be used. ",
71  EnumValue (RLC_UM),
73  MakeEnumChecker (RLC_UM, "RlcUm",
74  RLC_AM, "RlcAm"))
75  ;
76  return tid;
77 }
78 
79 void
81 {
82  NS_LOG_FUNCTION (this);
83  m_phyChannel = 0;
84 
85  m_enbMac->Dispose ();
86  m_enbMac = 0;
87  m_ueMac->Dispose ();
88  m_ueMac = 0;
89 
91 }
92 
93 
96 {
97  NS_LOG_FUNCTION (this);
98  Start (); // will run DoStart () if necessary
99  NetDeviceContainer devices;
100  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
101  {
102  Ptr<Node> node = *i;
103  Ptr<NetDevice> device = InstallSingleEnbDevice (node);
104  devices.Add (device);
105  }
106  return devices;
107 }
108 
111 {
112  NS_LOG_FUNCTION (this);
113  NetDeviceContainer devices;
114  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
115  {
116  Ptr<Node> node = *i;
117  Ptr<NetDevice> device = InstallSingleUeDevice (node);
118  devices.Add (device);
119  }
120  return devices;
121 }
122 
123 
126 {
127  NS_LOG_FUNCTION (this);
128 
129  m_enbRrc = CreateObject<LteTestRrc> ();
130  m_enbPdcp = CreateObject<LtePdcp> ();
131 
132  if (m_lteRlcEntityType == RLC_UM)
133  {
134  m_enbRlc = CreateObject<LteRlcUm> ();
135  }
136  else // m_lteRlcEntityType == RLC_AM
137  {
138  m_enbRlc = CreateObject<LteRlcAm> ();
139  }
140 
141  m_enbRlc->SetRnti (11);
142  m_enbRlc->SetLcId (12);
143 
145  enbDev->SetAddress (Mac48Address::Allocate ());
146  enbDev->SetChannel (m_phyChannel);
147 
148  n->AddDevice (enbDev);
149 
150  m_enbMac = CreateObject<LteTestMac> ();
151  m_enbMac->SetDevice (enbDev);
152 
153  enbDev->SetReceiveCallback (MakeCallback (&LteTestMac::Receive, m_enbMac));
154 
155  // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
156 
157  m_enbRrc->SetLtePdcpSapProvider (m_enbPdcp->GetLtePdcpSapProvider ());
158  m_enbPdcp->SetLtePdcpSapUser (m_enbRrc->GetLtePdcpSapUser ());
159 
160  m_enbPdcp->SetLteRlcSapProvider (m_enbRlc->GetLteRlcSapProvider ());
161  m_enbRlc->SetLteRlcSapUser (m_enbPdcp->GetLteRlcSapUser ());
162 
165 
166  return enbDev;
167 }
168 
171 {
172  NS_LOG_FUNCTION (this);
173 
174  m_ueRrc = CreateObject<LteTestRrc> ();
175  m_uePdcp = CreateObject<LtePdcp> ();
176 
177  if (m_lteRlcEntityType == RLC_UM)
178  {
179  m_ueRlc = CreateObject<LteRlcUm> ();
180  }
181  else // m_lteRlcEntityType == RLC_AM
182  {
183  m_ueRlc = CreateObject<LteRlcAm> ();
184  }
185 
186  m_ueRlc->SetRnti (21);
187  m_ueRlc->SetLcId (22);
188 
190  ueDev->SetAddress (Mac48Address::Allocate ());
191  ueDev->SetChannel (m_phyChannel);
192 
193  n->AddDevice (ueDev);
194 
195  m_ueMac = CreateObject<LteTestMac> ();
196  m_ueMac->SetDevice (ueDev);
197 
198  ueDev->SetReceiveCallback (MakeCallback (&LteTestMac::Receive, m_ueMac));
199 
200  // Connect SAPs: RRC <-> PDCP <-> RLC <-> MAC
201 
202  m_ueRrc->SetLtePdcpSapProvider (m_uePdcp->GetLtePdcpSapProvider ());
203  m_uePdcp->SetLtePdcpSapUser (m_ueRrc->GetLtePdcpSapUser ());
204 
205  m_uePdcp->SetLteRlcSapProvider (m_ueRlc->GetLteRlcSapProvider ());
206  m_ueRlc->SetLteRlcSapUser (m_uePdcp->GetLteRlcSapUser ());
207 
210 
211  return ueDev;
212 }
213 
214 
215 void
217 {
219 
220  LogComponentEnable ("Config", level);
221  LogComponentEnable ("LteSimpleHelper", level);
222  LogComponentEnable ("LteTestEntities", level);
223  LogComponentEnable ("LtePdcp", level);
224  LogComponentEnable ("LteRlc", level);
225  LogComponentEnable ("LteRlcUm", level);
226  LogComponentEnable ("LteRlcAm", level);
227  LogComponentEnable ("LteSimpleNetDevice", level);
228  LogComponentEnable ("SimpleNetDevice", level);
229  LogComponentEnable ("SimpleChannel", level);
230 }
231 
232 void
234 {
235 // EnableMacTraces ();
236  EnableRlcTraces ();
237  EnablePdcpTraces ();
238 }
239 
240 void
242 {
245 }
246 
247 
248 void
250  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
251 {
252  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
253  uint64_t imsi = 111;
254  uint16_t cellId = 222;
255  rlcStats->DlTxPdu (cellId, imsi, rnti, lcid, packetSize);
256 }
257 
258 void
260  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
261 {
262  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
263  uint64_t imsi = 333;
264  rlcStats->DlRxPdu (imsi, rnti, lcid, packetSize, delay);
265 }
266 
267 void
269 {
271 
272  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
273  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_rlcStats));
274  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
275  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_rlcStats));
276 }
277 
278 void
280  uint16_t rnti, uint8_t lcid, uint32_t packetSize)
281 {
282  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize);
283  uint64_t imsi = 1111;
284  rlcStats->UlTxPdu (imsi, rnti, lcid, packetSize);
285 }
286 
287 void
289  uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay)
290 {
291  NS_LOG_FUNCTION (rlcStats << path << rnti << (uint16_t)lcid << packetSize << delay);
292  uint64_t imsi = 444;
293  uint16_t cellId = 555;
294  rlcStats->UlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay);
295 }
296 
297 
298 void
300 {
302 
303  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/TxPDU",
304  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_rlcStats));
305  // Config::Connect ("/NodeList/*/DeviceList/*/LteRlc/RxPDU",
306  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_rlcStats));
307 }
308 
309 
310 void
312 {
315 }
316 
317 void
319 {
321 
322  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
323  // MakeBoundCallback (&LteSimpleHelperDlTxPduCallback, m_pdcpStats));
324  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
325  // MakeBoundCallback (&LteSimpleHelperDlRxPduCallback, m_pdcpStats));
326 }
327 
328 void
330 {
332 
333  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/TxPDU",
334  // MakeBoundCallback (&LteSimpleHelperUlTxPduCallback, m_pdcpStats));
335  // Config::Connect ("/NodeList/*/DeviceList/*/LtePdcp/RxPDU",
336  // MakeBoundCallback (&LteSimpleHelperUlRxPduCallback, m_pdcpStats));
337 }
338 
339 
340 } // namespace ns3