OLD | NEW |
(Empty) | |
| 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> |
| 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 <iostream> |
| 51 #include <ns3/core-module.h> |
| 52 #include <ns3/common-module.h> |
| 53 #include <ns3/node-module.h> |
| 54 #include <ns3/simulator-module.h> |
| 55 #include <ns3/single-model-spectrum-channel.h> |
| 56 #include <ns3/log.h> |
| 57 #include <string> |
| 58 #include <ns3/mobility-module.h> |
| 59 #include <ns3/spectrum-helper.h> |
| 60 #include <ns3/helper-module.h> |
| 61 #include <ns3/lte-helper.h> |
| 62 #include <ns3/enb-phy.h> |
| 63 #include <ns3/ue-phy.h> |
| 64 #include <ns3/packet-burst.h> |
| 65 #include <ns3/constant-position-mobility-model.h> |
| 66 #include <ns3/constant-velocity-mobility-model.h> |
| 67 #include <vector> |
| 68 |
| 69 |
| 70 NS_LOG_COMPONENT_DEFINE ("TestSimpleLtePhy"); |
| 71 |
| 72 using namespace ns3; |
| 73 |
| 74 |
| 75 int main (int argc, char** argv) |
| 76 { |
| 77 LteHelper lte; |
| 78 ·· |
| 79 lte.EnableLogComponents (); |
| 80 |
| 81 // CREATE NODE CONTAINER AND CREATE LTE NODES |
| 82 NodeContainer ueNodes; |
| 83 NodeContainer enbNodes; |
| 84 ueNodes.Create (1); |
| 85 enbNodes.Create (1); |
| 86 |
| 87 |
| 88 //CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE |
| 89 NetDeviceContainer ueDevs, enbDevs; |
| 90 ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT); |
| 91 enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB); |
| 92 |
| 93 |
| 94 |
| 95 //INSTALL INTERNET STACKS |
| 96 InternetStackHelper stack; |
| 97 stack.Install (ueNodes); |
| 98 stack.Install (enbNodes); |
| 99 Ipv4AddressHelper address; |
| 100 address.SetBase ("10.1.1.0", "255.255.255.0"); |
| 101 Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs); |
| 102 Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs); |
| 103 |
| 104 |
| 105 |
| 106 //MANAGE LTE NET DEVICES |
| 107 Ptr<EnbNetDevice> enb; |
| 108 enb = enbDevs.Get (0)->GetObject<EnbNetDevice> (); |
| 109 |
| 110 Ptr<UeNetDevice> ue = ueDevs.Get (0)->GetObject<UeNetDevice> (); |
| 111 lte.RegisterUeToTheEnb (ue, enb); |
| 112 |
| 113 |
| 114 |
| 115 |
| 116 //CONFIGURE DL and UL SUB CHANNELS |
| 117 //Define a list of sub channels for the downlink |
| 118 std::vector<int> dlSubChannels; |
| 119 for (int i=0; i < 25; i++) |
| 120 { |
| 121 dlSubChannels.push_back(i); |
| 122 } |
| 123 //Define a list of sub channels for the uplink |
| 124 std::vector<int> ulSubChannels; |
| 125 for (int i=50; i < 100; i++) |
| 126 { |
| 127 ulSubChannels.push_back(i); |
| 128 } |
| 129 |
| 130 enb->GetPhy ()->SetDownlinkSubChannels(dlSubChannels); |
| 131 enb->GetPhy ()->SetUplinkSubChannels(ulSubChannels); |
| 132 |
| 133 ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); |
| 134 ue->GetPhy ()->SetUplinkSubChannels (ulSubChannels); |
| 135 |
| 136 |
| 137 ·· |
| 138 //CONFIGURE MOBILITY |
| 139 Ptr<ConstantPositionMobilityModel> enbMobility = new ConstantPositionMobilityM
odel (); |
| 140 enbMobility->SetPosition (Vector (0.0, 0.0, 0.0)); |
| 141 lte.AddMobility (enb->GetPhy (), enbMobility); |
| 142 |
| 143 Ptr<ConstantVelocityMobilityModel> ueMobility = new ConstantVelocityMobilityMo
del (); |
| 144 ueMobility->SetPosition (Vector (30.0, 0.0, 0.0)); |
| 145 ueMobility->SetVelocity (Vector (30.0, 0.0, 0.0)); |
| 146 ······ |
| 147 lte.AddMobility (ue->GetPhy (), ueMobility); |
| 148 ···· |
| 149 lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ()); |
| 150 |
| 151 |
| 152 |
| 153 |
| 154 |
| 155 //****** simulate a packet transmission in the downlink ****** |
| 156 |
| 157 Ptr<PacketBurst> pb = new PacketBurst (); |
| 158 Ptr<Packet> p1 = new Packet (500); |
| 159 Ptr<Packet> p2 = new Packet (500); |
| 160 pb->AddPacket (p1); |
| 161 pb->AddPacket (p2); |
| 162 |
| 163 |
| 164 · |
| 165 enb->GetPhy ()->SendPacket (pb); |
| 166 |
| 167 |
| 168 Simulator::Stop (Seconds (.1)); |
| 169 |
| 170 |
| 171 Simulator::Run (); |
| 172 |
| 173 Simulator::Destroy (); |
| 174 |
| 175 return 0; |
| 176 } |
OLD | NEW |