#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/antenna-model.h"
#include "ns3/isotropic-antenna-model.h"
#include "ns3/config-store.h"
#include "ns3/building.h"
#include "ns3/buildings-helper.h"
#include "ns3/mobility-building-info.h"
#include <ns3/buildings-module.h>
#include "ns3/hybrid-buildings-propagation-loss-model.h"
#include "ns3/oh-buildings-propagation-loss-model.h"
using namespace ns3;
int main (int argc, char *argv[])
{
double speed = 50.0;
double initialPosition = 0.0;
double enbTxPowerDbm = 30.0;
double ueNoiseFigure = 5.0;
CommandLine cmd;
cmd.AddValue ("enbTxPowerDbm", "TX power [dBm] (default = 30.0dBm)", enbTxPowerDbm);
cmd.AddValue ("ueNoiseFigure", "User noise figure [dB] (default = 5.0dB)", ueNoiseFigure);
cmd.Parse (argc, argv);
ConfigStore inputConfig;
inputConfig.ConfigureDefaults ();
// Parse again so you can override default values from the command line
cmd.Parse (argc, argv);
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
//BUILDING CREATION
double x_min = 4.0;
double x_max = 20.0;
double y_min = -10.0;
double y_max = 20.0;
double z_min = -10.0;
double z_max = 10.0;
Ptr<Building> b = CreateObject <Building> ();
b->SetBoundaries (Box (x_min, x_max, y_min, y_max, z_min, z_max));
b->SetBuildingType (Building::Residential);
b->SetExtWallsType (Building::ConcreteWithWindows);
b->SetNFloors (3);
b->SetNRoomsX (3);
b->SetNRoomsY (2);
// Create Nodes: eNodeB and UE
NodeContainer enbNodes;
NodeContainer ueNodes;
enbNodes.Create (1);
ueNodes.Create (1);
// MOBILITY OF ENB
Ptr<ListPositionAllocator> enbPositionAlloc = CreateObject<ListPositionAllocator> ();
enbPositionAlloc->Add(Vector(0.0,0.0,0.1));
MobilityHelper enbMobility;
enbMobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
enbMobility.SetPositionAllocator(enbPositionAlloc);
enbMobility.Install (enbNodes);
BuildingsHelper::Install (enbNodes);
// MOBILITY OF UE
Ptr<ListPositionAllocator> uePositionAlloc = CreateObject<ListPositionAllocator> ();
uePositionAlloc->Add(Vector(initialPosition,0.0,0.1));
MobilityHelper ueMobility;
ueMobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");
ueMobility.SetPositionAllocator(uePositionAlloc);
ueMobility.Install (ueNodes);
ueNodes.Get(0)->GetObject<ConstantVelocityMobilityModel>()->SetVelocity(Vector (speed,0.0,0.0));
BuildingsHelper::Install (ueNodes);
// SET PARAMETERS OF TX
Config::SetDefault ("ns3::LteEnbPhy::TxPower", DoubleValue (enbTxPowerDbm));
Config::SetDefault ("ns3::LteUePhy::NoiseFigure", DoubleValue (ueNoiseFigure));
// Create Devices and install them in the Nodes (eNB and UE)
NetDeviceContainer enbDevs;
NetDeviceContainer ueDevs;
enbDevs = lteHelper->InstallEnbDevice (enbNodes);
ueDevs = lteHelper->InstallUeDevice (ueNodes);
// Attach a UE to a eNB
lteHelper->Attach (ueDevs, enbDevs.Get (0));
// Activate a data radio bearer
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
EpsBearer bearer (q);
lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
lteHelper->EnableDlPhyTraces();
BuildingsHelper::MakeMobilityModelConsistent ();
Simulator::Stop (Seconds (5));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}