A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lena-cqi-threshold.cc
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  */
20 
21 
22 #include "ns3/core-module.h"
23 #include "ns3/network-module.h"
24 #include "ns3/mobility-module.h"
25 #include "ns3/lte-module.h"
26 #include "ns3/config-store.h"
27 //#include "ns3/gtk-config-store.h"
28 
29 using namespace ns3;
30 
31 // position functions insipred by /examples/wireless/wifi-ap.cc
32 static void
33 SetPosition (Ptr<Node> node, Vector position)
34 {
35  Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
36  mobility->SetPosition (position);
37 }
38 
39 static Vector
40 GetPosition (Ptr<Node> node)
41 {
42  Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
43  return mobility->GetPosition ();
44 }
45 
46 static void
47 ChangePosition (Ptr<Node> node)
48 {
49  Vector pos = GetPosition (node);
50 
51  if (pos.x <= 10.0)
52  {
53  pos.x = 100000.0; // force CQI to 0
54  }
55  else
56  {
57  pos.x = 5.0;
58  }
59  SetPosition (node, pos);
60 
61 }
62 
63 int main (int argc, char *argv[])
64 {
65  CommandLine cmd;
66  cmd.Parse (argc, argv);
67 
68  // to save a template default attribute file run it like this:
69  // ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lena-first-sim
70  //
71  // to load a previously created default attribute file
72  // ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lena-first-sim
73 
74  ConfigStore inputConfig;
75  inputConfig.ConfigureDefaults ();
76 
77  // parse again so you can override default values from the command line
78  cmd.Parse (argc, argv);
79 
80  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
81  lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel"));
82  // Uncomment to enable logging
83  //lteHelper->EnableLogComponents ();
84 
85  // Create Nodes: eNodeB and UE
86  NodeContainer enbNodes;
87  NodeContainer ueNodes;
88  enbNodes.Create (1);
89  ueNodes.Create (1);
90 
91  // Install Mobility Model
92  MobilityHelper mobility;
93  mobility.SetMobilityModel ("ns3::BuildingsMobilityModel");
94  mobility.Install (enbNodes);
95  mobility.SetMobilityModel ("ns3::BuildingsMobilityModel");
96  mobility.Install (ueNodes);
97 
98  // Create Devices and install them in the Nodes (eNB and UE)
99  NetDeviceContainer enbDevs;
100  NetDeviceContainer ueDevs;
101 // lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
102  lteHelper->SetSchedulerType ("ns3::PfFfMacScheduler");
103  lteHelper->SetSchedulerAttribute ("CqiTimerThreshold", UintegerValue (3));
104  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
105  ueDevs = lteHelper->InstallUeDevice (ueNodes);
106 
107  lteHelper->EnableRlcTraces();
108  lteHelper->EnableMacTraces();
109 
110  // Attach a UE to a eNB
111  lteHelper->Attach (ueDevs, enbDevs.Get (0));
112 
113  Simulator::Schedule (Seconds (0.010), &ChangePosition, ueNodes.Get (0));
114  Simulator::Schedule (Seconds (0.020), &ChangePosition, ueNodes.Get (0));
115 
116  // Activate a data radio bearer
117  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
118  EpsBearer bearer (q);
119  lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
120 
121 
122  Simulator::Stop (Seconds (0.030));
123 
124  Simulator::Run ();
125 
126  //GtkConfigStore config;
127  //config.ConfigureAttributes ();
128 
130  return 0;
131 }
double x
Definition: vector.h:49
NetDeviceContainer InstallEnbDevice(NodeContainer c)
Definition: lte-helper.cc:285
hold variables of type string
Definition: string.h:19
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
static void Run(void)
Definition: simulator.cc:157
void EnableRlcTraces(void)
Definition: lte-helper.cc:829
Vector GetPosition(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:820
void ActivateDataRadioBearer(NetDeviceContainer ueDevices, EpsBearer bearer)
Definition: lte-helper.cc:773
a 3d vector
Definition: vector.h:31
void SetSchedulerType(std::string type)
Definition: lte-helper.cc:183
Keep track of the current position and velocity of an object.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Hold an unsigned integer type.
Definition: uinteger.h:46
void SetSchedulerAttribute(std::string n, const AttributeValue &v)
Definition: lte-helper.cc:191
void Attach(NetDeviceContainer ueDevices, Ptr< NetDevice > enbDevice)
Definition: lte-helper.cc:562
holds a vector of ns3::NetDevice pointers
parse command-line argumentsInstances of this class can be used to parse command-line arguments: user...
Definition: command-line.h:50
static void Destroy(void)
Definition: simulator.cc:121
keep track of a set of node pointers.
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void SetPosition(const Vector &position)
NetDeviceContainer InstallUeDevice(NodeContainer c)
Definition: lte-helper.cc:300
Helper class used to assign positions and mobility models to nodes.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
static void Stop(void)
Definition: simulator.cc:164
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void Parse(int argc, char *argv[]) const
Definition: command-line.cc:84
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void EnableMacTraces(void)
Definition: lte-helper.cc:1204
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:160
Ptr< T > GetObject(void) const
Definition: object.h:332