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>
- using namespace ns3;
- using namespace std;
- class nr{
- public:
- void UeRssiPerProcessedChunk1 (double rssidBm);
- void UeRssiPerProcessedChunk2 (double rssidBm);
- void UeRssiPerProcessedChunk3 (double rssidBm);
- void Run();
- ~nr ();
- private:
- ofstream m_outRssiFile1;
- ofstream m_outRssiFile2;
- ofstream m_outRssiFile3;
- };
- void nr::UeRssiPerProcessedChunk1 (double rssidBm)
- {
- string str= " ";
- m_outRssiFile1<<Simulator::Now().GetSeconds()<<str<<rssidBm<<std::endl;
- cout<<Simulator::Now().GetSeconds()<<str<< rssidBm<<endl;
- }
- void UeRssiPerProcessedChunkTrace1 (nr* scenario, double rssidBm)
- {
- scenario->UeRssiPerProcessedChunk1 (rssidBm);
- }
- void nr::UeRssiPerProcessedChunk2 (double rssidBm)
- {
- string str= " ";
- m_outRssiFile2<<Simulator::Now().GetSeconds()<<str<<rssidBm<<std::endl;
- cout<<Simulator::Now().GetSeconds()<<str<< rssidBm<<endl;
- }
- void UeRssiPerProcessedChunkTrace2 (nr* scenario, double rssidBm)
- {
- scenario->UeRssiPerProcessedChunk2 (rssidBm);
- }
- void nr::UeRssiPerProcessedChunk3 (double rssidBm)
- {
- string str= " ";
- m_outRssiFile3<<Simulator::Now().GetSeconds()<<str<<rssidBm<<std::endl;
- cout<<Simulator::Now().GetSeconds()<<str<< rssidBm<<endl;
- }
- void UeRssiPerProcessedChunkTrace3 (nr* scenario, double rssidBm)
- {
- scenario->UeRssiPerProcessedChunk3 (rssidBm);
- }
- void nr::Run()
- {
- m_outRssiFile1.open ("RssiValues1.txt");
- m_outRssiFile2.open ("RssiValues2.txt");
- m_outRssiFile3.open ("RssiValues3.txt");
- 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();
- // create a ue and an enb
- NodeContainer enb;
- NodeContainer ue;
- enb.Create(3);
- ue.Create(1);
- Ptr<ListPositionAllocator> enbposaloc = CreateObject<ListPositionAllocator>();
- enbposaloc->Add(Vector( 10, 40, 3));
- enbposaloc->Add(Vector( 25 , 70 , 3));
- enbposaloc->Add(Vector( 50, 40, 3));
- MobilityHelper enbmob;
- enbmob.SetMobilityModel("ns3::ConstantPositionMobilityModel");
- enbmob.SetPositionAllocator(enbposaloc);
- enbmob.Install(enb);
- Ptr<ListPositionAllocator> ueposaloc = CreateObject<ListPositionAllocator>();
- ueposaloc->Add(Vector( 60, 40, 1.5));
- // ueposaloc->Add(Vector( 25, 70, 1.5));
- //ueposaloc->Add(Vector( 149, 40.0, 1.5));
- MobilityHelper uemob;
- uemob.SetMobilityModel("ns3::ConstantPositionMobilityModel");
- uemob.SetPositionAllocator(ueposaloc);
- uemob.Install(ue);
- BuildingsHelper::Install(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));
- // Set the default gateway for the UEs
- Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue.Get(0)->GetObject<Ipv4> ());
- //Ptr<Ipv4StaticRouting> ueStaticRouting2 = ipv4RoutingHelper.GetStaticRouting (ue.Get(1)->GetObject<Ipv4> ());
- //Ptr<Ipv4StaticRouting> ueStaticRouting3 = ipv4RoutingHelper.GetStaticRouting (ue.Get(2)->GetObject<Ipv4> ());
- ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
- //ueStaticRouting2->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
- //ueStaticRouting3->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
- // ptr_mmv->AttachToEnb (uenetdev.Get(0),enbnetdev.Get(0));
- // ptr_mmv->AttachToEnb (uenetdev.Get(0),enbnetdev.Get(1));
- // ptr_mmv->AttachToEnb (uenetdev.Get(0),enbnetdev.Get(2));
- /* uint16_t dlPort = 1234;
- ApplicationContainer clientAppsDl;
- ApplicationContainer serverAppsDl;
- DataRate udpRate = DataRate ("2Mbps");
- 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
- for (uint32_t i = 0 ; i < 3; i ++)
- {
- ptr_mmv->AttachToEnb (uenetdev.Get(0),enbnetdev.Get(i));
- uint16_t dlPort = 1234;
- ApplicationContainer clientAppsDl;
- ApplicationContainer serverAppsDl;
- DataRate udpRate = DataRate ("2Mbps");
- Time udpInterval = Time::FromDouble((1000*8) / static_cast<double> (udpRate.GetBitRate ()), Time::S);
- UdpServerHelper dlPacketSinkHelper (dlPort);
- serverAppsDl.Add (dlPacketSinkHelper.Install (ue));
- UdpClientHelper dlClient (ueIpIface.GetAddress (i), 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 = NanoSeconds (100);
- Time udpAppStopTimeDl = NanoSeconds (500);
- // start UDP server and client apps
- serverAppsDl.Start(udpAppStartTimeDl);
- clientAppsDl.Start(udpAppStartTimeDl);
- serverAppsDl.Stop(udpAppStopTimeDl);
- clientAppsDl.Stop(udpAppStopTimeDl);
- //#######################################
- 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));
- EpcUeNas Object;
- Object.Disconnect();
- }
- /*Ptr<MmWaveSpectrumPhy > ue1SpectrumPhy2 = DynamicCast<MmWaveUeNetDevice> (uenetdev.Get(1))->GetPhy(0)->GetSpectrumPhy();
- Ptr<mmWaveInterference> ue1SpectrumPhyInterference2 = ue1SpectrumPhy2->GetMmWaveInterference();
- NS_ABORT_IF(!ue1SpectrumPhyInterference2);
- ue1SpectrumPhyInterference2->TraceConnectWithoutContext("RssiPerProcessedChunk", MakeBoundCallback (&UeRssiPerProcessedChunkTrace2, this));
- Ptr<MmWaveSpectrumPhy > ue1SpectrumPhy3 = DynamicCast<MmWaveUeNetDevice> (uenetdev.Get(2))->GetPhy(0)->GetSpectrumPhy();
- Ptr<mmWaveInterference> ue1SpectrumPhyInterference3 = ue1SpectrumPhy3->GetMmWaveInterference();
- NS_ABORT_IF(!ue1SpectrumPhyInterference3);
- ue1SpectrumPhyInterference3->TraceConnectWithoutContext("RssiPerProcessedChunk", MakeBoundCallback (&UeRssiPerProcessedChunkTrace3, this));
- */
- p2ph.EnablePcapAll("x");
- Simulator::Stop (Seconds (0.5));
- Simulator::Run ();
- Simulator::Destroy ();
- }
- nr::~nr ()
- {
- cout<<"Exiting"<<endl;
- m_outRssiFile1.close();
- m_outRssiFile2.close();
- m_outRssiFile3.close();
- }
- int main(int argc, char *argv[])
- {
- Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue(30e9));
- Config::SetDefault ("ns3::MmWaveEnbPhy::TxPower", DoubleValue(23));
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::ChannelCondition", StringValue("n"));
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::Shadowing", BooleanValue(true));
- Config::SetDefault ("ns3::MmWave3gppChannel::Speed", DoubleValue (3.0*1000/3600));
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::Scenario", StringValue("InH-ShoppingMall"));
- Config::SetDefault ("ns3::MmWavePhyMacCommon::MacSchedulerType", TypeIdValue (TypeId::LookupByName("ns3::MmWaveMacSchedulerTdmaPF")));
- Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::OptionalNlos", BooleanValue(false));
- nr aa;
- aa.Run();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement