Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ns3/core-module.h"
- #include "ns3/network-module.h"
- #include "ns3/mobility-module.h"
- #include "ns3/config-store.h"
- #include "ns3/mmwave-helper.h"
- #include <ns3/buildings-helper.h>
- #include "ns3/global-route-manager.h"
- #include "ns3/ipv4-global-routing-helper.h"
- #include "ns3/internet-module.h"
- #include "ns3/applications-module.h"
- #include "ns3/log.h"
- #include <iostream>
- #include "ns3/mmwave-helper.h"
- #include "ns3/core-module.h"
- #include "ns3/network-module.h"
- #include "ns3/mobility-module.h"
- #include "ns3/config-store.h"
- #include "ns3/mmwave-helper.h"
- #include "ns3/log.h"
- #include "ns3/nr-point-to-point-epc-helper.h"
- #include "ns3/network-module.h"
- #include "ns3/ipv4-global-routing-helper.h"
- #include "ns3/internet-module.h"
- #include "ns3/applications-module.h"
- #include "ns3/point-to-point-helper.h"
- #include "ns3/eps-bearer-tag.h"
- #include "ns3/abort.h"
- #include "ns3/object.h"
- #include "ns3/mmwave-mac-scheduler-ns3.h"
- #include "ns3/mmwave-mac-scheduler-ofdma.h"
- #include "ns3/mmwave-mac-scheduler-ofdma-rr.h"
- #include "ns3/mmwave-phy-mac-common.h"
- #include "ns3/basic-data-calculators.h"
- #include "ns3/antenna-array-3gpp-model.h"
- #include "ns3/netanim-module.h"
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include "ns3/mmwave-enb-mac.h"
- #include "ns3/mmwave-enb-mac.h"
- #include "ns3/mmwave-phy-mac-common.h"
- #include "ns3/mmwave-mac-pdu-header.h"
- #include "ns3/mmwave-mac-sched-sap.h"
- #include "ns3/mmwave-mac-scheduler.h"
- #include "ns3/mmwave-control-messages.h"
- #include <ns3/lte-radio-bearer-tag.h>
- #include <ns3/log.h>
- #include <thread>
- #include "ns3/gnuplot.h"
- #include "ns3/command-line.h"
- #include "ns3/config.h"
- #include "ns3/uinteger.h"
- #include "ns3/double.h"
- #include "ns3/log.h"
- #include "ns3/yans-wifi-helper.h"
- #include "ns3/ssid.h"
- #include "ns3/mobility-helper.h"
- #include "ns3/internet-stack-helper.h"
- #include "ns3/ipv4-address-helper.h"
- #include "ns3/packet-sink-helper.h"
- #include "ns3/on-off-helper.h"
- #include "ns3/yans-wifi-channel.h"
- #include "ns3/wifi-net-device.h"
- #include "ns3/wifi-mac.h"
- #include "ns3/wifi-mac-header.h"
- #include "ns3/mobility-model.h"
- #include "ns3/propagation-loss-model.h"
- #include "ns3/flow-monitor.h"
- #include "ns3/flow-monitor-helper.h"
- #include "ns3/ipv4-flow-classifier.h"
- #include "ns3/ipv4-global-routing-helper.h"
- using namespace ns3;
- using namespace std;
- int j =0;
- double rssi1=0.0;
- double rssi2=0.0;
- double rssi3=0.0;
- int count1, count2, count3;
- double maxPower = 23;
- double minPower = 0;
- double frequency = 30e9;
- double C = 299792458.0;
- double m_lambda = C / frequency;
- double m_systemLoss = 1.0;
- double m_minLoss = 0;
- double m_pi = 3.141592;
- struct point
- {
- double x,y;
- };
- double norm (point p) // get the norm of a vector
- {
- return pow(pow(p.x,2)+pow(p.y,2),.5);
- }
- //#########################################################
- //#########################################################
- point trilateration(point point1, point point2, point point3, double r1, double r2, double r3) {
- point resultPose;
- //unit vector in a direction from point1 to point 2
- double p2p1Distance = pow(pow(point2.x-point1.x,2) + pow(point2.y- point1.y,2),0.5);
- point ex = {(point2.x-point1.x)/p2p1Distance, (point2.y-point1.y)/p2p1Distance};
- point aux = {point3.x-point1.x,point3.y-point1.y};
- //signed magnitude of the x component
- double i = ex.x * aux.x + ex.y * aux.y;
- //the unit vector in the y direction.
- point aux2 = { point3.x-point1.x-i*ex.x, point3.y-point1.y-i*ex.y};
- point ey = { aux2.x / norm (aux2), aux2.y / norm (aux2) };
- //the signed magnitude of the y component
- double j = ey.x * aux.x + ey.y * aux.y;
- //coordinates
- double x = (pow(r1,2) - pow(r2,2) + pow(p2p1Distance,2))/ (2 * p2p1Distance);
- double y = (pow(r1,2) - pow(r3,2) + pow(i,2) + pow(j,2))/(2*j) - i*x/j;
- //result coordinates
- double finalX = point1.x+ x*ex.x + y*ey.x;
- double finalY = point1.y+ x*ex.y + y*ey.y;
- resultPose.x = finalX;
- resultPose.y = finalY;
- return resultPose;
- }
- double doCalcDistance(double Pt, double Pr)
- {
- /*
- double loss = Pt - Pr;
- double x = pow(10, (loss / -10));
- double xx = (m_lambda * m_lambda) / x;
- double xxx = xx / m_systemLoss / 16 / m_pi / m_pi;
- double distance = sqrt(xxx);
- return distance;
- */
- return pow(10, (Pr-(-31.3))/(-10 * 2));
- }
- //#########################################################
- //#########################################################
- enum AntennaModelEnum{
- _ISO,
- _3GPP,
- };
- static ns3::GlobalValue g_duration ("duration",
- "simulation duration in milliseconds, should be greater than 100 ms to allow the collection of traces",
- ns3::UintegerValue (150),
- ns3::MakeUintegerChecker<uint32_t>());
- static ns3::GlobalValue g_shadowing ("shadowing",
- "if true, shadowing is enabled in 3gpp propagation loss model;"
- "if false, shadowing is disabled",
- ns3::BooleanValue (true),
- ns3::MakeBooleanChecker ());
- static ns3::GlobalValue g_antennaOrientation ("antennaOrientation",
- "the orientation of the antenna on gNB and UE",
- ns3::EnumValue (AntennaArray3gppModel::Z0),
- ns3::MakeEnumChecker (AntennaArray3gppModel::Z0, "Z0",
- AntennaArray3gppModel::X0, "X0"));
- static ns3::GlobalValue g_antennaModelgNb ("antennaModelGnb",
- "the antenna model of gNb, can be ISO or 3GPP",
- ns3::EnumValue (_3GPP),
- ns3::MakeEnumChecker (_ISO, "ISO",
- _3GPP, "3GPP"));
- static ns3::GlobalValue g_antennaModelUe ("antennaModelUe",
- "the antenna model of Ue, can be ISO or 3GPP",
- ns3::EnumValue (_3GPP),
- ns3::MakeEnumChecker (_ISO, "ISO",
- _3GPP, "3GPP"));
- static ns3::GlobalValue g_resultsDir ("resultsDir",
- "directory where to store the simulation results",
- ns3::StringValue ("./"),
- ns3::MakeStringChecker ());
- static ns3::GlobalValue g_simTag ("simTag",
- "tag to be appended to the output filenames to distinguish different simulation campaign output files",
- ns3::StringValue (""),
- ns3::MakeStringChecker ());
- static ns3::GlobalValue g_indoorScenario ("indoorScenario",
- "the indoor scenario to be used can be: InH-OfficeMixed, InH-OfficeOpen or InH-ShoppingMall",
- ns3::StringValue ("InH-OfficeOpen"),
- ns3::MakeStringChecker ());
- static ns3::GlobalValue g_speed ("speed",
- "UE speed in km/h",
- ns3::DoubleValue (3.00),
- ns3::MakeDoubleChecker<double> (0.0, 10.0));
- static ns3::GlobalValue g_isBeamSearchMethod ("isBeamSearchMethod",
- "if true, beam search method will be used;"
- "if false, long term covariance matrix will be used",
- ns3::BooleanValue (true),
- ns3::MakeBooleanChecker ());
- static ns3::GlobalValue g_beamSearchMethodAngle ("beamSearchMethodAngle",
- "beam search method angle step",
- ns3::DoubleValue (5.0),
- ns3::MakeDoubleChecker<double> (0.0, 360.0));
- static ns3::GlobalValue g_gNbAntennaMount ("gnbAntennaMount",
- "gNb antenna mount type. Can be Wall mount or Sector mount. Doc: 38.802-e20. A.2.1-7",
- ns3::EnumValue (ns3::AntennaArray3gppModel::GnbWallMount),
- ns3::MakeEnumChecker (ns3::AntennaArray3gppModel::GnbWallMount, "WALL",
- ns3::AntennaArray3gppModel::GnbSingleSector, "SECT"));
- //############################
- void LocationUE (NodeContainer ue, NodeContainer gnb)
- {
- cout<<"At: "<<Simulator::Now().GetSeconds()<<" Seconds"<<endl;
- ofstream m_distace;
- m_distace.open("distance"+to_string(j)+".txt");
- for(int i = 0; i<12;i++)
- {
- Vector posGNB=gnb.Get (i)->GetObject<ConstantPositionMobilityModel> ()->GetPosition();
- Vector posUE=ue.Get (i)->GetObject<ConstantPositionMobilityModel> ()->GetPosition();
- cout<<"At: "<<Simulator::Now().GetSeconds()<<" "<<" Node #"<<i+1<<"\t"<<"(" <<posUE.x <<","<<posUE.y<<")"<<endl;
- double dis;
- string str= " ";
- dis = sqrt( pow((posUE.x - posGNB.x), 2.0) + pow((posUE.y - posGNB.y),2.0) + pow((posUE.z - posGNB.z), 2.0));
- m_distace<<i<<str<<dis<<std::endl;
- }
- cout<<"######################################"<<endl;
- j++;
- }
- void SetInitialVelocity(NodeContainer ue)
- {
- ue.Get (0)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (300, 0, 0));
- }
- void CourseChange(NodeContainer ue, int c)
- {
- if(c==1) //Move into the Y Access
- {
- cout<<"Change course into +Y Access"<<endl;
- ue.Get (0)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.831, 0));
- ue.Get (1)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.8334, 0));
- ue.Get (2)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.8335, 0));
- ue.Get (3)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.8333, 0));
- ue.Get (4)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.8323, 0));
- ue.Get (5)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.833, 0));
- ue.Get (6)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.83734, 0));
- ue.Get (7)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.83344, 0));
- ue.Get (8)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.83743, 0));
- ue.Get (9)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.83434, 0));
- ue.Get (10)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.8341, 0));
- ue.Get (11)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, 50.8324, 0));
- }
- if(c==2) //Move back into the X Access in minus
- {
- cout<<"Change course into -X Access"<<endl;
- ue.Get (0)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.831, 0, 0));
- ue.Get (1)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.8334, 0, 0));
- ue.Get (2)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.8335, 0, 0));
- ue.Get (3)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.8333, 0, 0));
- ue.Get (4)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.8323, 0, 0));
- ue.Get (5)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.833, 0, 0));
- ue.Get (6)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.83734, 0, 0));
- ue.Get (7)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.83344, 0, 0));
- ue.Get (8)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.83743, 0, 0));
- ue.Get (9)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.83434, 0, 0));
- ue.Get (10)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.8341, 0, 0));
- ue.Get (11)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (-50.8324, 0, 0));
- }
- if(c==3) //Move back into the Y Access in minus
- {
- cout<<"Change course into -Y Access"<<endl;
- ue.Get (0)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.831, 0));
- ue.Get (1)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.8334, 0));
- ue.Get (2)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.8335, 0));
- ue.Get (3)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.8333, 0));
- ue.Get (4)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.8323, 0));
- ue.Get (5)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.833, 0));
- ue.Get (6)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.83734, 0));
- ue.Get (7)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.83344, 0));
- ue.Get (8)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.83743, 0));
- ue.Get (9)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.83434, 0));
- ue.Get (10)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.8341, 0));
- ue.Get (11)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (0, -50.8324, 0));
- }
- if(c==4) //Move back into the +X Access
- {
- ue.Get (0)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.831, 0, 0));
- ue.Get (1)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.8334, 0, 0));
- ue.Get (2)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.8335, 0, 0));
- ue.Get (3)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.8333, 0, 0));
- ue.Get (4)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.8323, 0, 0));
- ue.Get (5)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.833, 0, 0));
- ue.Get (6)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.83734, 0, 0));
- ue.Get (7)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.83344, 0, 0));
- ue.Get (8)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.83743, 0, 0));
- ue.Get (9)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.83434, 0, 0));
- ue.Get (10)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.8341, 0, 0));
- ue.Get (11)->GetObject<ConstantVelocityMobilityModel> ()->SetVelocity (Vector (50.8324, 0, 0));
- }
- }
- class nr{
- public:
- void UeRssiPerProcessedChunk1 (double rssidBm);
- void UeRssiPerProcessedChunk2 (double rssidBm);
- void UeRssiPerProcessedChunk3 (double rssidBm);
- void Run (bool shadowing, AntennaArrayModel::AntennaOrientation antOrientation, TypeId gNbAntennaModel,
- TypeId ueAntennaModel, std::string scenario, double speed,
- std::string resultsDirPath, std::string tag,
- bool isBeamSearchMethod, double beamSearchMethodAngle,
- AntennaArray3gppModel::GnbAntennaMount gNbAntennaMount, uint32_t duration);
- ~nr ();
- private:
- ofstream m_outRssiFile1;
- };
- //#####################################################
- //#####################################################
- //#####################################################
- void nr::UeRssiPerProcessedChunk1 (double rssidBm)
- {
- count1++;
- string str= " ";
- m_outRssiFile1<<Simulator::Now().GetSeconds()<<str<<rssidBm<<std::endl;
- //cout<<Simulator::Now().GetSeconds()<<str<< rssidBm<<endl;
- rssi1= rssi1+rssidBm;
- }
- void UeRssiPerProcessedChunkTrace1 (nr* scenario, double rssidBm)
- {
- scenario->UeRssiPerProcessedChunk1 (rssidBm);
- }
- //#####################################################
- //#####################################################
- void nr::Run(bool shadowing, AntennaArrayModel::AntennaOrientation antOrientation,
- TypeId gNbAntennaModel, TypeId ueAntennaModel, std::string scenario, double speed,
- std::string resultsDirPath, std::string tag,
- bool isBeamSearchMethod, double beamSearchMethodAngle,
- AntennaArray3gppModel::GnbAntennaMount gNbAntennaMount, uint32_t duration)
- {
- m_outRssiFile1.open ("RssiValues1.txt");
- Config::SetDefault ("ns3::AntennaArray3gppModel::GnbAntennaMountType", EnumValue (gNbAntennaMount));
- Config::SetDefault ("ns3::AntennaArrayModel::AntennaOrientation", EnumValue (antOrientation));
- // configure antenna gain for the ISO antenna
- Config::SetDefault ("ns3::AntennaArrayModel::AntennaGain", DoubleValue (5));
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::Scenario", StringValue(scenario));
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::Shadowing", BooleanValue(shadowing));
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::Frequency", DoubleValue(30e9));
- // Config::SetDefault ("ns3::MmWave3gppChannel::UpdatePeriod", TimeValue(MilliSeconds(100))); // interval after which the channel for a moving user is updated,
- // with spatial consistency procedure. If 0, spatial consistency is not used
- // we tried also with the optional nLos model and both 3gpp antennas, and it is not better calibrated
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::OptionalNlos", BooleanValue(false));
- // Default scenario configuration that are summarised in to R1-1703534 3GPP TSG RAN WG1 Meeting #88
- Config::SetDefault ("ns3::MmWave3gppChannel::Speed", DoubleValue (speed*1000/3600));
- // Disable channel matrix update to speed up the simulation execution
- Config::SetDefault ("ns3::MmWave3gppChannel::UpdatePeriod", TimeValue (MilliSeconds(0)));
- Config::SetDefault ("ns3::MmWavePhyMacCommon::MacSchedulerType", TypeIdValue (TypeId::LookupByName("ns3::MmWaveMacSchedulerTdmaPF")));
- Config::SetDefault ("ns3::MmWave3gppChannel::CellScan", BooleanValue (isBeamSearchMethod));
- Config::SetDefault ("ns3::MmWave3gppChannel::BeamSearchAngleStep", DoubleValue (beamSearchMethodAngle));
- Config::SetDefault ("ns3::LteEnbRrc::SrsPeriodicity", UintegerValue (320));
- // Parameters according to R1-1703534 3GPP TSG RAN WG1 Meetging #88, 2017
- // Evaluation assumptions for Phase 1 NR MIMO system level calibration,
- Config::SetDefault ("ns3::MmWaveEnbPhy::TxPower", DoubleValue(23));
- Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue(30e9));
- Config::SetDefault ("ns3::MmWavePhyMacCommon::Numerology", UintegerValue(2));
- Config::SetDefault ("ns3::MmWavePhyMacCommon::Bandwidth", DoubleValue(40e6));
- // Should be 4x8 = 32 antenna elements
- Config::SetDefault ("ns3::MmWaveEnbPhy::AntennaArrayType", TypeIdValue(gNbAntennaModel));
- Config::SetDefault ("ns3::MmWaveEnbPhy::AntennaNumDim1", UintegerValue(8));
- Config::SetDefault ("ns3::MmWaveEnbPhy::AntennaNumDim2", UintegerValue(8));
- // Should be 2x4 = 8 antenna elements
- Config::SetDefault ("ns3::MmWaveUePhy::AntennaArrayType", TypeIdValue(ueAntennaModel));
- Config::SetDefault ("ns3::MmWaveUePhy::AntennaNumDim1", UintegerValue(4));
- Config::SetDefault ("ns3::MmWaveUePhy::AntennaNumDim2", UintegerValue(4));
- // UE antenna gain shall be set to 5 dBi
- // gNB noise figure shall be set to 7 dB
- Config::SetDefault("ns3::MmWaveEnbPhy::NoiseFigure", DoubleValue (7));
- // UE noise figure shall be set to 10 dB
- Config::SetDefault("ns3::MmWaveUePhy::NoiseFigure", DoubleValue (10));
- // set LOS,NLOS condition
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::ChannelCondition", StringValue("a"));
- // setup the mmWave simulation
- Ptr<MmWaveHelper> ptr_mmv = CreateObject<MmWaveHelper>();
- ptr_mmv->SetAttribute("ChannelModel", StringValue("ns3::MmWave3gppChannel"));
- ptr_mmv->SetAttribute("PathlossModel", StringValue("ns3::MmWave3gppPropagationLossModel"));
- Ptr<NrPointToPointEpcHelper> epcHelper = CreateObject<NrPointToPointEpcHelper> ();
- ptr_mmv->SetEpcHelper (epcHelper);
- ptr_mmv->Initialize();
- NodeContainer enb;
- NodeContainer ue;
- enb.Create(1);
- ue.Create(1);
- Ptr<ListPositionAllocator> enbposaloc = CreateObject<ListPositionAllocator>();
- enbposaloc->Add(Vector( 10, 15, 3));
- MobilityHelper enbmob;
- enbmob.SetMobilityModel("ns3::ConstantPositionMobilityModel");
- enbmob.SetPositionAllocator(enbposaloc);
- enbmob.Install(enb);
- MobilityHelper uemob;
- uemob.SetMobilityModel("ns3::ConstantVelocityMobilityModel");
- uemob.Install(ue);
- ue.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (11, 15, 1.5));
- SetInitialVelocity(ue);
- NetDeviceContainer enbnetdev = ptr_mmv->InstallEnbDevice (enb);
- NetDeviceContainer uenetdev = ptr_mmv->InstallUeDevice (ue);
- //#######################################
- // create the internet and install the IP stack on the UEs
- // get SGW/PGW and create a single RemoteHost
- Ptr<Node> pgw = epcHelper->GetPgwNode ();
- NodeContainer remoteHostContainer;
- remoteHostContainer.Create (1);
- Ptr<Node> remoteHost = remoteHostContainer.Get (0);
- InternetStackHelper internet;
- internet.Install (remoteHostContainer);
- // connect a remoteHost to pgw. Setup routing too
- PointToPointHelper p2ph;
- p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
- p2ph.SetDeviceAttribute ("Mtu", UintegerValue (2500));
- p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.000)));
- NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
- Ipv4AddressHelper ipv4h;
- ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
- Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
- // in this container, interface 0 is the pgw, 1 is the remoteHost
- //Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
- Ipv4StaticRoutingHelper ipv4RoutingHelper;
- Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
- remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
- internet.Install (ue);
- Ipv4InterfaceContainer ueIpIface;
- ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (uenetdev));
- for (uint32_t k = 0; k < 1; ++k)
- {
- Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue.Get(k)->GetObject<Ipv4> ());
- ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
- }
- ptr_mmv->AttachToEnb (uenetdev.Get(0),enbnetdev.Get(0));
- uint16_t dlPort = 1234;
- ApplicationContainer clientAppsDl;
- ApplicationContainer serverAppsDl;
- DataRate udpRate = DataRate ("4Mbps");
- Time udpInterval = Time::FromDouble((1000*8) / static_cast<double> (udpRate.GetBitRate ()), Time::S);
- UdpServerHelper dlPacketSinkHelper (dlPort);
- serverAppsDl.Add (dlPacketSinkHelper.Install (ue));
- // configure UDP downlink traffic
- UdpClientHelper dlClient (ueIpIface.GetAddress (0), dlPort); //CHECK AFTER
- dlClient.SetAttribute ("MaxPackets", UintegerValue(0xFFFFFFFF));
- dlClient.SetAttribute("PacketSize", UintegerValue(1000));
- dlClient.SetAttribute ("Interval", TimeValue (udpInterval)); // we try to saturate, we just need to measure during a short time, how much traffic can handle each BWP
- clientAppsDl.Add (dlClient.Install (remoteHost));
- Time udpAppStartTimeDl = MilliSeconds (100);
- Time udpAppStopTimeDl = MilliSeconds (300);
- // start UDP server and client apps
- serverAppsDl.Start(udpAppStartTimeDl);
- clientAppsDl.Start(udpAppStartTimeDl);
- serverAppsDl.Stop(udpAppStopTimeDl);
- clientAppsDl.Stop(udpAppStopTimeDl);
- //LocationUE(ue,enb);
- //#######################################
- Ptr<MmWaveSpectrumPhy > ue1SpectrumPhy1 = DynamicCast<MmWaveUeNetDevice> (uenetdev.Get(0))->GetPhy(0)->GetSpectrumPhy();
- Ptr<mmWaveInterference> ue1SpectrumPhyInterference1 = ue1SpectrumPhy1->GetMmWaveInterference();
- NS_ABORT_IF(!ue1SpectrumPhyInterference1);
- ue1SpectrumPhyInterference1->TraceConnectWithoutContext("RssiPerProcessedChunk", MakeBoundCallback (&UeRssiPerProcessedChunkTrace1, this));
- LogComponentEnable ("MmWave3gppPropagationLossModel", LOG_LEVEL_ALL);
- //LogComponentEnable ("mmWaveInterference", LOG_LEVEL_ALL);
- //p2ph.EnablePcapAll("x");
- /*
- Simulator:: Schedule (Seconds(0.1), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(0.2), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(0.3), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(0.8), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(0.9), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(1), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(1.1), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(1.2), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(1.3), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(1.9), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(2), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(2), &CourseChange, ue, 1);
- Simulator:: Schedule (Seconds(2.2), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(2.3), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(2.5), &CourseChange, ue, 2);
- Simulator:: Schedule (Seconds(2.6), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(2.9), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(3.3), &CourseChange, ue, 3);
- Simulator:: Schedule (Seconds(3.5), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(3.8), &CourseChange, ue, 4);
- Simulator:: Schedule (Seconds(3.8), &LocationUE, ue, enb);
- Simulator:: Schedule (Seconds(4), &LocationUE, ue, enb);
- */
- Simulator::Stop (MilliSeconds (180));
- Simulator::Run ();
- /*
- double x1,x2,x3;
- point ue1;
- point xy1,xy2,xy3;
- xy1 = {10,15};
- xy2 = {10,35};
- xy3 = {30,15};
- cout<<"\nThe RSSI Averages: \n"<<rssi1/count1<<"\n"<<rssi2/count2<<"\n"<<rssi3/count3<<endl<<endl;
- x1=doCalcDistance(23.0,rssi1/count1);
- x2=doCalcDistance(23.0,rssi2/count2);
- x3=doCalcDistance(23.0,rssi3/count3);
- cout<<x1<<" "<<x2<<" "<<x3 <<endl;
- ue1= trilateration(xy1,xy2,xy3,x1,x2,x3);
- cout<<"\n"<<ue1.x<<","<<ue1.y<<endl;
- LocationUE(ue,enb);
- cout<<endl;
- */
- Simulator::Destroy ();
- }
- nr::~nr ()
- {
- cout<<"Exiting"<<endl;
- m_outRssiFile1.close();
- }
- int main(int argc, char *argv[])
- {
- CommandLine cmd;
- cmd.Parse (argc, argv);
- ConfigStore inputConfig;
- inputConfig.ConfigureDefaults ();
- // parse again so you can override input file default values via command line
- cmd.Parse (argc, argv);
- EnumValue enumValue;
- DoubleValue doubleValue;
- BooleanValue booleanValue;
- StringValue stringValue;
- TypeIdValue typeIdValue;
- UintegerValue uintValue;
- GlobalValue::GetValueByName ("duration", uintValue);
- uint32_t duration = uintValue.Get ();
- GlobalValue::GetValueByName ("shadowing", booleanValue);
- bool shadowing = booleanValue.Get ();
- GlobalValue::GetValueByName ("antennaOrientation", enumValue);
- enum AntennaArray3gppModel::AntennaOrientation antennaOrientation = (AntennaArray3gppModel::AntennaOrientation) enumValue.Get ();
- GlobalValue::GetValueByName ("antennaModelGnb", enumValue);
- enum AntennaModelEnum antennaGnb = (AntennaModelEnum) enumValue.Get ();
- TypeId antennaModelGnb;
- if (antennaGnb == _3GPP)
- {
- antennaModelGnb = AntennaArray3gppModel::GetTypeId();
- }
- else
- {
- antennaModelGnb = AntennaArrayModel::GetTypeId();
- }
- GlobalValue::GetValueByName ("antennaModelUe", enumValue);
- enum AntennaModelEnum antennaUe = (AntennaModelEnum) enumValue.Get ();
- TypeId antennaModelUe;
- if (antennaUe == _3GPP)
- {
- antennaModelUe = AntennaArray3gppModel::GetTypeId();
- }
- else
- {
- antennaModelUe = AntennaArrayModel::GetTypeId();
- }
- GlobalValue::GetValueByName ("indoorScenario", stringValue);
- std::string indoorScenario = stringValue.Get ();
- GlobalValue::GetValueByName ("speed", doubleValue);
- double speed = doubleValue.Get ();
- GlobalValue::GetValueByName ("resultsDir", stringValue);
- std::string resultsDir = stringValue.Get ();
- GlobalValue::GetValueByName ("simTag", stringValue);
- std::string tag = stringValue.Get ();
- GlobalValue::GetValueByName ("isBeamSearchMethod", booleanValue);
- bool isBeamSearchMethod = booleanValue.Get ();
- GlobalValue::GetValueByName ("beamSearchMethodAngle", doubleValue);
- double beamSearchMethodAngle = doubleValue.Get ();
- GlobalValue::GetValueByName ("gnbAntennaMount", enumValue);
- enum AntennaArray3gppModel::GnbAntennaMount gnbAntennaMount = (AntennaArray3gppModel::GnbAntennaMount) enumValue.Get ();
- nr phase1CalibrationScenario;
- phase1CalibrationScenario.Run(shadowing, antennaOrientation, antennaModelGnb, antennaModelUe,
- indoorScenario, speed, resultsDir, tag, isBeamSearchMethod, beamSearchMethodAngle, gnbAntennaMount, duration);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement