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 UeRssiPerProcessedChunk (double rssidBm);
- void Run();
- ~nr ();
- };
- void nr::UeRssiPerProcessedChunk (double rssidBm)
- {
- cout<<rssidBm<<endl;
- }
- void UeRssiPerProcessedChunkTrace (nr* scenario, double rssidBm)
- {
- scenario->UeRssiPerProcessedChunk (rssidBm);
- }
- void nr::Run()
- {
- 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( 76, 40, 3));
- enbposaloc->Add(Vector( 45 , 12 , 3));
- enbposaloc->Add(Vector( 20, 40, 3));
- MobilityHelper enbmob;
- enbmob.SetMobilityModel("ns3::ConstantPositionMobilityModel");
- enbmob.SetPositionAllocator(enbposaloc);
- enbmob.Install(enb);
- Ptr<ListPositionAllocator> ueposaloc = CreateObject<ListPositionAllocator>();
- ueposaloc->Add(Vector( 45, 40, 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> ());
- ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
- ptr_mmv->AttachToEnb (*(uenetdev.Begin()), *(enbnetdev.Begin()));
- uint16_t dlPort = 1234;
- ApplicationContainer clientAppsDl;
- ApplicationContainer serverAppsDl;
- DataRate udpRate = DataRate ("1Mbps");
- 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 (2000);
- // start UDP server and client apps
- serverAppsDl.Start(udpAppStartTimeDl);
- clientAppsDl.Start(udpAppStartTimeDl);
- serverAppsDl.Stop(udpAppStopTimeDl);
- clientAppsDl.Stop(udpAppStopTimeDl);
- //#######################################
- /*
- enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
- EpsBearer bearer (q);
- ptr_mmv->ActivateDataRadioBearer (uenetdev, bearer);
- */
- //EpsBearerTag rnti;
- //uint16_t m_rnti = rnti.GetRnti();
- ptr_mmv->EnableTraces();
- Ptr<MmWaveSpectrumPhy > ue1SpectrumPhy = DynamicCast<MmWaveUeNetDevice>
- (uenetdev.Get(0))->GetPhy(0)->GetSpectrumPhy();
- Ptr<mmWaveInterference> ue1SpectrumPhyInterference = ue1SpectrumPhy->GetMmWaveInterference();
- NS_ABORT_IF(!ue1SpectrumPhyInterference);
- ue1SpectrumPhyInterference->TraceConnectWithoutContext("RssiPerProcessedChunk", MakeBoundCallback (&UeRssiPerProcessedChunkTrace, this));
- //LteEnbCmacSapProvider* m_cmacSapProvider;
- //m_cmacSapProvider->RemoveUe(m_rnti);
- AnimationInterface anim("kkk.xml");
- anim.SetConstantPosition(enb.Get(0), 76.0, 40.0, 3.0);
- anim.SetConstantPosition(enb.Get(1), 45 , 12 , 3);
- anim.SetConstantPosition(enb.Get(2), 20, 40, 3);
- anim.SetConstantPosition(ue.Get(0), 45, 40, 1.5);
- Simulator::Stop (Seconds (1));
- Simulator::Run ();
- Simulator::Destroy ();
- }
- nr::~nr ()
- {
- cout<<"Exiting"<<endl;
- }
- 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