author | CTTC |
Thu, 10 Mar 2011 18:15:26 +0100 | |
changeset 7886 | b65c16d4da83 |
parent 6852 | 8f1a53d3f6ca |
permissions | -rw-r--r-- |
6705 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari |
|
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: Giuseppe Piro <g.piro@poliba.it> |
|
7886 | 19 |
* Author: Marco Miozzo <mmiozzo@cttc.es> : Update to FF API Architecture |
20 |
* Author: Nicola Baldo <nbaldo@cttc.es> : Integrated with new RRC and MAC architecture |
|
6705 | 21 |
*/ |
22 |
||
23 |
#include "ns3/llc-snap-header.h" |
|
24 |
#include "ns3/simulator.h" |
|
25 |
#include "ns3/callback.h" |
|
26 |
#include "ns3/node.h" |
|
27 |
#include "ns3/packet.h" |
|
28 |
#include "lte-net-device.h" |
|
29 |
#include "ns3/packet-burst.h" |
|
30 |
#include "ns3/uinteger.h" |
|
31 |
#include "ns3/trace-source-accessor.h" |
|
32 |
#include "ns3/pointer.h" |
|
33 |
#include "ns3/enum.h" |
|
34 |
#include "amc-module.h" |
|
7886 | 35 |
#include "lte-enb-mac.h" |
6705 | 36 |
#include "enb-net-device.h" |
7886 | 37 |
#include "lte-enb-rrc.h" |
6705 | 38 |
#include "ue-net-device.h" |
39 |
#include "enb-phy.h" |
|
7886 | 40 |
#include "rr-ff-mac-scheduler.h" |
6705 | 41 |
|
42 |
NS_LOG_COMPONENT_DEFINE ("EnbNetDevice"); |
|
43 |
||
44 |
namespace ns3 { |
|
45 |
||
46 |
NS_OBJECT_ENSURE_REGISTERED ( EnbNetDevice); |
|
47 |
||
7886 | 48 |
uint16_t EnbNetDevice::m_cellIdCounter = 0; |
49 |
||
6705 | 50 |
TypeId EnbNetDevice::GetTypeId (void) |
51 |
{ |
|
52 |
static TypeId |
|
53 |
tid = |
|
54 |
TypeId ("ns3::EnbNetDevice") |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
55 |
.SetParent<LteNetDevice> (); |
6705 | 56 |
return tid; |
57 |
} |
|
58 |
||
59 |
EnbNetDevice::EnbNetDevice (void) |
|
60 |
{ |
|
61 |
NS_LOG_FUNCTION (this); |
|
7886 | 62 |
NS_FATAL_ERROR ("This constructor should not be called"); |
6705 | 63 |
InitEnbNetDevice (); |
64 |
} |
|
65 |
||
7886 | 66 |
EnbNetDevice::EnbNetDevice (Ptr<Node> node, Ptr<EnbLtePhy> phy) |
67 |
: m_phy (phy) |
|
6705 | 68 |
{ |
69 |
NS_LOG_FUNCTION (this); |
|
70 |
InitEnbNetDevice (); |
|
71 |
SetNode (node); |
|
72 |
} |
|
73 |
||
74 |
EnbNetDevice::~EnbNetDevice (void) |
|
75 |
{ |
|
76 |
NS_LOG_FUNCTION (this); |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
77 |
} |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
78 |
|
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
79 |
void |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
80 |
EnbNetDevice::DoDispose () |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
81 |
{ |
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
82 |
NS_LOG_FUNCTION (this); |
7886 | 83 |
|
84 |
m_mac->Dispose (); |
|
85 |
m_mac = 0; |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
86 |
|
7886 | 87 |
m_rrc->Dispose (); |
88 |
m_rrc = 0; |
|
89 |
||
90 |
m_phy->Dispose (); |
|
91 |
m_phy = 0; |
|
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
92 |
|
6709
4f3100141560
fixed some valgrind errors
Giuseppe Piro <g.piro@poliba.it>
parents:
6705
diff
changeset
|
93 |
LteNetDevice::DoDispose (); |
6705 | 94 |
} |
95 |
||
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6709
diff
changeset
|
96 |
|
6705 | 97 |
void |
98 |
EnbNetDevice::InitEnbNetDevice (void) |
|
99 |
{ |
|
100 |
NS_LOG_FUNCTION (this); |
|
7886 | 101 |
|
102 |
m_mac = CreateObject<LteEnbMac> (); |
|
103 |
// m_mac->SetDevice (this->GetObject<LteNetDevice> ()); |
|
6705 | 104 |
SetNode (0); |
7886 | 105 |
if (GetPhy () == 0) |
106 |
{ |
|
107 |
NS_LOG_DEBUG (this << "PHY NULL"); |
|
108 |
} |
|
109 |
else |
|
110 |
{ |
|
111 |
NS_LOG_DEBUG (this << "PHY ! NULL"); |
|
112 |
} |
|
113 |
m_rrc = Create<LteEnbRrc> (); |
|
114 |
m_rrc->SetLteEnbCmacSapProvider (m_mac->GetLteEnbCmacSapProvider ()); |
|
115 |
m_mac->SetLteEnbCmacSapUser (m_rrc->GetLteEnbCmacSapUser ()); |
|
116 |
m_rrc->SetLteMacSapProvider (m_mac->GetLteMacSapProvider ()); |
|
6705 | 117 |
|
7886 | 118 |
m_scheduler = Create<RrFfMacScheduler> (); |
119 |
m_mac->SetFfMacSchedSapProvider (m_scheduler->GetFfMacSchedSapProvider ()); |
|
120 |
m_mac->SetFfMacCschedSapProvider (m_scheduler->GetFfMacCschedSapProvider ()); |
|
121 |
||
122 |
m_scheduler->SetFfMacSchedSapUser (m_mac->GetFfMacSchedSapUser ()); |
|
123 |
m_scheduler->SetFfMacCschedSapUser (m_mac->GetFfMacCschedSapUser ()); |
|
124 |
||
125 |
GetPhy ()->GetObject<EnbLtePhy> ()->SetLteEnbPhySapUser (m_mac->GetLteEnbPhySapUser ()); |
|
126 |
m_mac->SetLteEnbPhySapProvider (GetPhy ()->GetObject<EnbLtePhy> ()->GetLteEnbPhySapProvider ()); |
|
127 |
||
128 |
m_rrc->ConfigureCell (25, 25); |
|
129 |
NS_ASSERT_MSG (m_cellIdCounter < 65535, "max num eNBs exceeded"); |
|
130 |
m_cellId = ++m_cellIdCounter; |
|
131 |
||
132 |
// WILD HACK - should use the PHY SAP instead. Probably should handle this through the RRC |
|
133 |
GetPhy ()->GetObject<EnbLtePhy> ()->DoSetBandwidth (25,25); |
|
134 |
GetPhy ()->GetObject<EnbLtePhy> ()->DoSetCellId (m_cellId); |
|
135 |
||
6705 | 136 |
Simulator::ScheduleNow (&EnbLtePhy::StartFrame, GetPhy ()->GetObject<EnbLtePhy> ()); |
137 |
} |
|
138 |
||
139 |
||
7886 | 140 |
Ptr<LteEnbMac> |
141 |
EnbNetDevice::GetMac (void) |
|
6705 | 142 |
{ |
143 |
NS_LOG_FUNCTION (this); |
|
7886 | 144 |
return m_mac; |
6705 | 145 |
} |
146 |
||
147 |
||
7886 | 148 |
Ptr<EnbLtePhy> |
149 |
EnbNetDevice::GetPhy (void) const |
|
6705 | 150 |
{ |
151 |
NS_LOG_FUNCTION (this); |
|
7886 | 152 |
return m_phy; |
6705 | 153 |
} |
154 |
||
155 |
||
156 |
bool |
|
157 |
EnbNetDevice::DoSend (Ptr<Packet> packet, const Mac48Address& source, |
|
158 |
const Mac48Address& dest, uint16_t protocolNumber) |
|
159 |
{ |
|
160 |
NS_LOG_FUNCTION (this << source << dest << protocolNumber); |
|
161 |
||
7886 | 162 |
NS_FATAL_ERROR ("IP connectivity not implemented yet"); |
163 |
||
6705 | 164 |
/* |
165 |
* The classification of traffic in DL is done by the PGW (not |
|
166 |
* by the eNB). |
|
167 |
* Hovever, the core network is not implemented yet. |
|
168 |
* For now the classification is managed by the eNB. |
|
169 |
*/ |
|
170 |
||
7886 | 171 |
// if (protocolNumber == 2048) |
172 |
// { |
|
173 |
// // it is an IP packet |
|
174 |
// } |
|
6705 | 175 |
|
7886 | 176 |
// if (protocolNumber != 2048 || bearer == 0) |
177 |
// { |
|
6705 | 178 |
|
7886 | 179 |
// } |
180 |
||
6705 | 181 |
|
7886 | 182 |
return true; |
183 |
} |
|
6705 | 184 |
|
185 |
||
186 |
void |
|
187 |
EnbNetDevice::DoReceive (Ptr<Packet> p) |
|
188 |
{ |
|
189 |
NS_LOG_FUNCTION (this << p); |
|
190 |
ForwardUp (p->Copy ()); |
|
191 |
} |
|
192 |
||
193 |
||
194 |
void |
|
195 |
EnbNetDevice::SendIdealPdcchMessage (void) |
|
196 |
{ |
|
197 |
NS_LOG_FUNCTION (this); |
|
198 |
/* |
|
199 |
* Get both PDCCH ideal message for UL and DL and |
|
200 |
* set assigned resources to UEs using |
|
201 |
* SendAssignedDLResources and SendAssignedULResources |
|
202 |
*/ |
|
203 |
} |
|
204 |
||
7886 | 205 |
Ptr<LteEnbRrc> |
206 |
EnbNetDevice::GetRrc () |
|
207 |
{ |
|
208 |
return m_rrc; |
|
209 |
} |
|
210 |
||
211 |
uint16_t |
|
212 |
EnbNetDevice::GetCellId () |
|
213 |
{ |
|
214 |
return m_cellId; |
|
215 |
} |
|
6705 | 216 |
|
217 |
} // namespace ns3 |