author | Vedran Miletić <rivanvx@gmail.com> |
Tue, 02 Aug 2011 17:42:33 -0400 | |
changeset 7385 | 10beb0e53130 |
parent 6865 | 220373544a6c |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
6865
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6705 | 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> |
|
19 |
*/ |
|
20 |
||
21 |
/* |
|
22 |
* Test for LTE PHY layer in the downlink |
|
23 |
* |
|
24 |
* /\ + |
|
25 |
* /--\ __| |
|
26 |
* /....\ | | |
|
27 |
* /------\ |__| |
|
28 |
* eNB UE |
|
29 |
* |
|
30 |
* SendPacket(Pb) |
|
31 |
* | |
|
32 |
* V |
|
33 |
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++| |
|
34 |
* | EnbLtePhy | | EnbLtePhy | |
|
35 |
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++| |
|
36 |
* | SpectrumPhy | SpectrumPhy | | SpectrumPhy | SpectrumPhy | |
|
37 |
* | dl | ul | | dl | ul | |
|
38 |
* |+++++++++++++++++++++++++++++| |+++++++++++++++++++++++++++++| |
|
39 |
* | | |
|
40 |
* | | |
|
41 |
* V | |
|
42 |
* StartTx (pb) StartRx(Pb) |
|
43 |
* | | |
|
44 |
* V | |
|
45 |
* |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| |
|
46 |
* | Downlink Spectrum Channel | |
|
47 |
* |+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| |
|
48 |
*/ |
|
49 |
||
50 |
#include <ns3/core-module.h> |
|
6823
a27f86fb4e55
Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents:
6821
diff
changeset
|
51 |
#include <ns3/network-module.h> |
6705 | 52 |
#include <ns3/single-model-spectrum-channel.h> |
53 |
#include <ns3/log.h> |
|
54 |
#include <ns3/mobility-module.h> |
|
55 |
#include <ns3/spectrum-helper.h> |
|
6848
1f453ad50ef3
Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6823
diff
changeset
|
56 |
#include <ns3/internet-module.h> |
6705 | 57 |
#include <ns3/lte-helper.h> |
58 |
#include <ns3/enb-phy.h> |
|
59 |
#include <ns3/ue-phy.h> |
|
60 |
#include <ns3/packet-burst.h> |
|
61 |
#include <ns3/constant-position-mobility-model.h> |
|
62 |
#include <ns3/constant-velocity-mobility-model.h> |
|
6848
1f453ad50ef3
Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6823
diff
changeset
|
63 |
|
1f453ad50ef3
Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6823
diff
changeset
|
64 |
#include <iostream> |
1f453ad50ef3
Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6823
diff
changeset
|
65 |
#include <string> |
6705 | 66 |
#include <vector> |
67 |
||
68 |
||
69 |
NS_LOG_COMPONENT_DEFINE ("TestSimpleLtePhy"); |
|
70 |
||
71 |
using namespace ns3; |
|
72 |
||
73 |
||
74 |
int main (int argc, char** argv) |
|
75 |
{ |
|
76 |
LteHelper lte; |
|
77 |
||
78 |
lte.EnableLogComponents (); |
|
79 |
||
80 |
// CREATE NODE CONTAINER AND CREATE LTE NODES |
|
81 |
NodeContainer ueNodes; |
|
82 |
NodeContainer enbNodes; |
|
83 |
ueNodes.Create (1); |
|
84 |
enbNodes.Create (1); |
|
85 |
||
86 |
||
87 |
// CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE |
|
88 |
NetDeviceContainer ueDevs, enbDevs; |
|
89 |
ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT); |
|
90 |
enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB); |
|
91 |
||
92 |
||
93 |
||
94 |
// INSTALL INTERNET STACKS |
|
95 |
InternetStackHelper stack; |
|
96 |
stack.Install (ueNodes); |
|
97 |
stack.Install (enbNodes); |
|
98 |
Ipv4AddressHelper address; |
|
99 |
address.SetBase ("10.1.1.0", "255.255.255.0"); |
|
100 |
Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs); |
|
101 |
Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs); |
|
102 |
||
103 |
||
104 |
||
105 |
// MANAGE LTE NET DEVICES |
|
106 |
Ptr<EnbNetDevice> enb; |
|
107 |
enb = enbDevs.Get (0)->GetObject<EnbNetDevice> (); |
|
108 |
||
109 |
Ptr<UeNetDevice> ue = ueDevs.Get (0)->GetObject<UeNetDevice> (); |
|
110 |
lte.RegisterUeToTheEnb (ue, enb); |
|
111 |
||
112 |
||
113 |
||
114 |
||
115 |
// CONFIGURE DL and UL SUB CHANNELS |
|
116 |
// Define a list of sub channels for the downlink |
|
117 |
std::vector<int> dlSubChannels; |
|
118 |
for (int i = 0; i < 25; i++) |
|
119 |
{ |
|
120 |
dlSubChannels.push_back (i); |
|
121 |
} |
|
122 |
// Define a list of sub channels for the uplink |
|
123 |
std::vector<int> ulSubChannels; |
|
124 |
for (int i = 50; i < 100; i++) |
|
125 |
{ |
|
126 |
ulSubChannels.push_back (i); |
|
127 |
} |
|
128 |
||
129 |
enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); |
|
130 |
enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels); |
|
131 |
||
132 |
ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); |
|
133 |
ue->GetPhy ()->SetUplinkSubChannels (ulSubChannels); |
|
134 |
||
135 |
||
136 |
||
137 |
// CONFIGURE MOBILITY |
|
138 |
Ptr<ConstantPositionMobilityModel> enbMobility = CreateObject<ConstantPositionMobilityModel> (); |
|
139 |
enbMobility->SetPosition (Vector (0.0, 0.0, 0.0)); |
|
140 |
lte.AddMobility (enb->GetPhy (), enbMobility); |
|
141 |
||
142 |
Ptr<ConstantVelocityMobilityModel> ueMobility = CreateObject<ConstantVelocityMobilityModel> (); |
|
143 |
ueMobility->SetPosition (Vector (30.0, 0.0, 0.0)); |
|
144 |
ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0)); |
|
145 |
||
146 |
lte.AddMobility (ue->GetPhy (), ueMobility); |
|
147 |
||
6708
c2b7610a6803
restored LteHelper::AddDownlinkChannelRealization () method
Giuseppe Piro <g.piro@poliba.it>
parents:
6707
diff
changeset
|
148 |
lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ()); |
6705 | 149 |
|
150 |
||
151 |
||
152 |
||
153 |
||
154 |
// ****** simulate a packet transmission in the downlink ****** |
|
155 |
||
6710
3cd651349cb6
lte examples now passing valgrind tests
Nicola Baldo <nbaldo@cttc.es>
parents:
6708
diff
changeset
|
156 |
Ptr<PacketBurst> pb = CreateObject<PacketBurst> (); |
6705 | 157 |
Ptr<Packet> p1 = Create<Packet> (500); |
158 |
Ptr<Packet> p2 = Create<Packet> (500); |
|
159 |
pb->AddPacket (p1); |
|
160 |
pb->AddPacket (p2); |
|
161 |
||
162 |
||
163 |
||
164 |
enb->GetPhy ()->SendPacket (pb); |
|
165 |
||
166 |
||
167 |
Simulator::Stop (Seconds (.1)); |
|
168 |
||
169 |
||
170 |
Simulator::Run (); |
|
171 |
||
172 |
Simulator::Destroy (); |
|
173 |
||
174 |
return 0; |
|
175 |
} |