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 
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.Parse (argc, argv);
52 
53  ConfigStore inputConfig;
54  inputConfig.ConfigureDefaults ();
55 
56  // parse again so you can override default values from the command line
57  cmd.Parse (argc, argv);
58 
59  // determine the string tag that identifies this simulation run
60  // this tag is then appended to all filenames
61 
62  IntegerValue runValue;
63  GlobalValue::GetValueByName ("RngRun", runValue);
64 
65  std::ostringstream tag;
66  tag << "_enbDist" << std::setw (3) << std::setfill ('0') << std::fixed << std::setprecision (0) << enbDist
67  << "_radius" << std::setw (3) << std::setfill ('0') << std::fixed << std::setprecision (0) << radius
68  << "_numUes" << std::setw (3) << std::setfill ('0') << numUes
69  << "_rngRun" << std::setw (3) << std::setfill ('0') << runValue.Get () ;
70 
71  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
72 
73  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
74 
75  // Create Nodes: eNodeB and UE
76  NodeContainer enbNodes;
77  NodeContainer ueNodes1, ueNodes2;
78  enbNodes.Create (2);
79  ueNodes1.Create (numUes);
80  ueNodes2.Create (numUes);
81 
82  // Position of eNBs
83  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
84  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
85  positionAlloc->Add (Vector (enbDist, 0.0, 0.0));
86  MobilityHelper enbMobility;
87  enbMobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
88  enbMobility.SetPositionAllocator (positionAlloc);
89  enbMobility.Install (enbNodes);
90 
91  // Position of UEs attached to eNB 1
92  MobilityHelper ue1mobility;
93  ue1mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
94  "X", DoubleValue (0.0),
95  "Y", DoubleValue (0.0),
96  "rho", DoubleValue (radius));
97  ue1mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
98  ue1mobility.Install (ueNodes1);
99 
100  // Position of UEs attached to eNB 2
101  MobilityHelper ue2mobility;
102  ue2mobility.SetPositionAllocator ("ns3::UniformDiscPositionAllocator",
103  "X", DoubleValue (enbDist),
104  "Y", DoubleValue (0.0),
105  "rho", DoubleValue (radius));
106  ue2mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
107  ue2mobility.Install (ueNodes2);
108 
109 
110 
111  // Create Devices and install them in the Nodes (eNB and UE)
112  NetDeviceContainer enbDevs;
113  NetDeviceContainer ueDevs1;
114  NetDeviceContainer ueDevs2;
115  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
116  ueDevs1 = lteHelper->InstallUeDevice (ueNodes1);
117  ueDevs2 = lteHelper->InstallUeDevice (ueNodes2);
118 
119  // Attach UEs to a eNB
120  lteHelper->Attach (ueDevs1, enbDevs.Get (0));
121  lteHelper->Attach (ueDevs2, enbDevs.Get (1));
122 
123  // Activate an EPS bearer on all UEs
125  EpsBearer bearer (q);
126  lteHelper->ActivateEpsBearer (ueDevs1, bearer, EpcTft::Default ());
127  lteHelper->ActivateEpsBearer (ueDevs2, bearer, EpcTft::Default ());
128 
129  Simulator::Stop (Seconds (10));
130 
131  // Insert RLC Performance Calculator
132  std::string dlOutFname = "DlRlcStats";
133  dlOutFname.append (tag.str ());
134  std::string ulOutFname = "UlRlcStats";
135  ulOutFname.append (tag.str ());
136 
137  lteHelper->EnableMacTraces ();
138  lteHelper->EnableRlcTraces ();
139 
140  Simulator::Run ();
142  return 0;
143 }