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 #include <iostream> |
| 22 #include <ns3/single-model-spectrum-channel.h> |
| 23 #include <ns3/log.h> |
| 24 #include <string> |
| 25 #include <ns3/spectrum-helper.h> |
| 26 #include <ns3/lte-helper.h> |
| 27 #include <ns3/enb-phy.h> |
| 28 #include <ns3/ue-phy.h> |
| 29 #include <ns3/packet-burst.h> |
| 30 #include <ns3/constant-position-mobility-model.h> |
| 31 #include <ns3/constant-velocity-mobility-model.h> |
| 32 #include <vector> |
| 33 #include "ns3/log.h" |
| 34 #include "ns3/abort.h" |
| 35 #include "ns3/test.h" |
| 36 #include "ns3/uinteger.h" |
| 37 #include <ns3/simulator.h> |
| 38 |
| 39 |
| 40 using namespace ns3; |
| 41 |
| 42 /* |
| 43 * Test the LTE physical layer. |
| 44 */ |
| 45 class Ns3LtePhyTestCase : public TestCase |
| 46 { |
| 47 public: |
| 48 Ns3LtePhyTestCase (); |
| 49 virtual ~Ns3LtePhyTestCase (); |
| 50 |
| 51 private: |
| 52 virtual bool DoRun (void); |
| 53 |
| 54 }; |
| 55 |
| 56 Ns3LtePhyTestCase::Ns3LtePhyTestCase () |
| 57 : TestCase ("Test the LTE physical layer.") |
| 58 { |
| 59 } |
| 60 |
| 61 Ns3LtePhyTestCase::~Ns3LtePhyTestCase () |
| 62 { |
| 63 } |
| 64 |
| 65 bool |
| 66 Ns3LtePhyTestCase::DoRun (void) |
| 67 { |
| 68 bool testResult = false; |
| 69 |
| 70 LteHelper lte; |
| 71 |
| 72 lte.EnableLogComponents (); |
| 73 |
| 74 // CREATE NODE CONTAINER AND CREATE LTE NODES |
| 75 NodeContainer ueNodes; |
| 76 NodeContainer enbNodes; |
| 77 ueNodes.Create (1); |
| 78 enbNodes.Create (1); |
| 79 |
| 80 |
| 81 // CREATE DEVICE CONTAINER, INSTALL DEVICE TO NODE |
| 82 NetDeviceContainer ueDevs, enbDevs; |
| 83 ueDevs = lte.Install (ueNodes, LteHelper::DEVICE_TYPE_USER_EQUIPMENT); |
| 84 enbDevs = lte.Install (enbNodes, LteHelper::DEVICE_TYPE_ENODEB); |
| 85 |
| 86 |
| 87 /* |
| 88 //INSTALL INTERNET STACKS |
| 89 InternetStackHelper stack; |
| 90 stack.Install (ueNodes); |
| 91 stack.Install (enbNodes); |
| 92 Ipv4AddressHelper address; |
| 93 address.SetBase ("10.1.1.0", "255.255.255.0"); |
| 94 Ipv4InterfaceContainer UEinterfaces = address.Assign (ueDevs); |
| 95 Ipv4InterfaceContainer ENBinterface = address.Assign (enbDevs); |
| 96 */ |
| 97 |
| 98 |
| 99 // MANAGE LTE NET DEVICES |
| 100 Ptr<EnbNetDevice> enb; |
| 101 enb = enbDevs.Get (0)->GetObject<EnbNetDevice> (); |
| 102 |
| 103 Ptr<UeNetDevice> ue = ueDevs.Get (0)->GetObject<UeNetDevice> (); |
| 104 lte.RegisterUeToTheEnb (ue, enb); |
| 105 |
| 106 |
| 107 |
| 108 |
| 109 // CONFIGURE DL and UL SUB CHANNELS |
| 110 // Define a list of sub channels for the downlink |
| 111 std::vector<int> dlSubChannels; |
| 112 for (int i = 0; i < 25; i++) |
| 113 { |
| 114 dlSubChannels.push_back (i); |
| 115 } |
| 116 // Define a list of sub channels for the uplink |
| 117 std::vector<int> ulSubChannels; |
| 118 for (int i = 50; i < 100; i++) |
| 119 { |
| 120 ulSubChannels.push_back (i); |
| 121 } |
| 122 |
| 123 enb->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); |
| 124 enb->GetPhy ()->SetUplinkSubChannels (ulSubChannels); |
| 125 |
| 126 ue->GetPhy ()->SetDownlinkSubChannels (dlSubChannels); |
| 127 ue->GetPhy ()->SetUplinkSubChannels (ulSubChannels); |
| 128 |
| 129 |
| 130 |
| 131 // CONFIGURE MOBILITY |
| 132 Ptr<ConstantPositionMobilityModel> enbMobility = new ConstantPositionMobilityM
odel (); |
| 133 enbMobility->SetPosition (Vector (0.0, 0.0, 0.0)); |
| 134 lte.AddMobility (enb->GetPhy (), enbMobility); |
| 135 |
| 136 Ptr<ConstantVelocityMobilityModel> ueMobility = new ConstantVelocityMobilityMo
del (); |
| 137 ueMobility->SetPosition (Vector (50.0, 50.0, 0.0)); |
| 138 ueMobility->SetVelocity (Vector (50.0, 50.0, 0.0)); |
| 139 |
| 140 lte.AddMobility (ue->GetPhy (), ueMobility); |
| 141 |
| 142 lte.AddDownlinkChannelRealization (enbMobility, ueMobility, ue->GetPhy ()); |
| 143 |
| 144 |
| 145 |
| 146 |
| 147 |
| 148 |
| 149 |
| 150 // ****** simulate a packet transmission in the downlink ****** |
| 151 |
| 152 Ptr<PacketBurst> pb = new PacketBurst (); |
| 153 Ptr<Packet> p1 = new Packet (500); |
| 154 Ptr<Packet> p2 = new Packet (500); |
| 155 pb->AddPacket (p1); |
| 156 pb->AddPacket (p2); |
| 157 |
| 158 |
| 159 if (enb->GetPhy ()->SendPacket (pb)) |
| 160 { |
| 161 testResult = true; |
| 162 } |
| 163 |
| 164 |
| 165 if (ue->GetPhy ()->SendPacket (pb)) |
| 166 { |
| 167 testResult = true; |
| 168 } |
| 169 |
| 170 Simulator::Destroy (); |
| 171 |
| 172 |
| 173 return (testResult); |
| 174 } |
| 175 // =============================================================================
= |
| 176 |
| 177 class Ns3LtePhyTestTestSuite : public TestSuite |
| 178 { |
| 179 public: |
| 180 Ns3LtePhyTestTestSuite (); |
| 181 }; |
| 182 |
| 183 Ns3LtePhyTestTestSuite::Ns3LtePhyTestTestSuite () |
| 184 : TestSuite ("lte-phy", UNIT) |
| 185 { |
| 186 AddTestCase (new Ns3LtePhyTestCase); |
| 187 } |
| 188 |
| 189 Ns3LtePhyTestTestSuite ns3LtePhyTestTestSuite; |
OLD | NEW |