A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lena-intercell-interference.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 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>
19  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
22 
23 #include "ns3/core-module.h"
24 #include "ns3/network-module.h"
25 #include "ns3/mobility-module.h"
26 #include "ns3/lte-module.h"
27 #include "ns3/config-store.h"
28 #include "ns3/radio-bearer-stats-calculator.h"
29 
30 #include <iomanip>
31 #include <string>
32 
33 using namespace ns3;
34 
40 int main (int argc, char *argv[])
41 {
42  double enbDist = 100.0;
43  double radius = 50.0;
44  uint32_t numUes = 1;
45  double simTime = 1.0;
46 
47  CommandLine cmd;
48  cmd.AddValue ("enbDist", "distance between the two eNBs", enbDist);
49  cmd.AddValue ("radius", "the radius of the disc where UEs are placed around an eNB", radius);
50  cmd.AddValue ("numUes", "how many UEs are attached to each eNB", numUes);
51  cmd.AddValue ("simTime", "Total duration of the simulation (in seconds)", simTime);
52  cmd.Parse (argc, argv);
53 
54  ConfigStore inputConfig;
55  inputConfig.ConfigureDefaults ();
56 
57  // parse again so you can override default values from the command line
58  cmd.Parse (argc, argv);
59 
60  // determine the string tag that identifies this simulation run
61  // this tag is then appended to all filenames
62 
63  IntegerValue runValue;
64  GlobalValue::GetValueByName ("RngRun", runValue);
65 
66  std::ostringstream tag;
67  tag << "_enbDist" << std::setw (3) << std::setfill ('0') << std::fixed << std::setprecision (0) << enbDist
68  << "_radius" << std::setw (3) << std::setfill ('0') << std::fixed << std::setprecision (0) << radius
69  << "_numUes" << std::setw (3) << std::setfill ('0') << numUes
70  << "_rngRun" << std::setw (3) << std::setfill ('0') << runValue.Get () ;
71 
72  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
73 
74  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
75 
76  // Create Nodes: eNodeB and UE
77  NodeContainer enbNodes;
78  NodeContainer ueNodes1, ueNodes2;
79  enbNodes.Create (2);
80  ueNodes1.Create (numUes);
81  ueNodes2.Create (numUes);
82 
83  // Position of eNBs
84  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
85  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
86  positionAlloc->Add (Vector (enbDist, 0.0, 0.0));
87  MobilityHelper enbMobility;
88  enbMobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
89  enbMobility.SetPositionAllocator (positionAlloc);
90  enbMobility.Install (enbNodes);
91 
92  // Position of UEs attached to eNB 1
93  MobilityHelper ue1mobility;
94  ue1mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
95  "X", DoubleValue (0.0),
96  "Y", DoubleValue (0.0),
97  "rho", DoubleValue (radius));
98  ue1mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
99  ue1mobility.Install (ueNodes1);
100 
101  // Position of UEs attached to eNB 2
102  MobilityHelper ue2mobility;
103  ue2mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
104  "X", DoubleValue (enbDist),
105  "Y", DoubleValue (0.0),
106  "rho", DoubleValue (radius));
107  ue2mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
108  ue2mobility.Install (ueNodes2);
109 
110 
111 
112  // Create Devices and install them in the Nodes (eNB and UE)
113  NetDeviceContainer enbDevs;
114  NetDeviceContainer ueDevs1;
115  NetDeviceContainer ueDevs2;
116  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
117  ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
118  ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
119 
120  // Attach UEs to a eNB
121  lteHelper->Attach (ueDevs1, enbDevs.Get (0));
122  lteHelper->Attach (ueDevs2, enbDevs.Get (1));
123 
124  // Activate a data radio bearer each UE
126  EpsBearer bearer (q);
127  lteHelper->ActivateDataRadioBearer (ueDevs1, bearer);
128  lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
129 
130  Simulator::Stop (Seconds (simTime));
131 
132  // Insert RLC Performance Calculator
133  std::string dlOutFname = "DlRlcStats";
134  dlOutFname.append (tag.str ());
135  std::string ulOutFname = "UlRlcStats";
136  ulOutFname.append (tag.str ());
137 
138  lteHelper->EnableMacTraces ();
139  lteHelper->EnableRlcTraces ();
140 
141  Simulator::Run ();
143  return 0;
144 }