Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.39 KB | None | 0 0
  1. #include "ns3/core-module.h"
  2. #include "ns3/network-module.h"
  3. #include "ns3/mobility-module.h"
  4. #include "ns3/config-store.h"
  5. #include "ns3/mmwave-helper.h"
  6. #include <ns3/buildings-helper.h>
  7. #include "ns3/global-route-manager.h"
  8. #include "ns3/ipv4-global-routing-helper.h"
  9. #include "ns3/internet-module.h"
  10. #include "ns3/applications-module.h"
  11. #include "ns3/log.h"
  12. #include <iostream>
  13. #include "ns3/mmwave-helper.h"
  14. #include "ns3/core-module.h"
  15. #include "ns3/network-module.h"
  16. #include "ns3/mobility-module.h"
  17. #include "ns3/config-store.h"
  18. #include "ns3/mmwave-helper.h"
  19. #include "ns3/log.h"
  20. #include "ns3/nr-point-to-point-epc-helper.h"
  21. #include "ns3/network-module.h"
  22. #include "ns3/ipv4-global-routing-helper.h"
  23. #include "ns3/internet-module.h"
  24. #include "ns3/applications-module.h"
  25. #include "ns3/point-to-point-helper.h"
  26. #include "ns3/eps-bearer-tag.h"
  27. #include "ns3/abort.h"
  28. #include "ns3/object.h"
  29. #include "ns3/mmwave-mac-scheduler-ns3.h"
  30. #include "ns3/mmwave-mac-scheduler-ofdma.h"
  31. #include "ns3/mmwave-mac-scheduler-ofdma-rr.h"
  32. #include "ns3/mmwave-phy-mac-common.h"
  33. #include "ns3/basic-data-calculators.h"
  34. #include "ns3/antenna-array-3gpp-model.h"
  35. #include "ns3/netanim-module.h"
  36. #include <iostream>
  37. #include <cmath>
  38. #include <ctime>
  39. #include "ns3/mmwave-enb-mac.h"
  40. #include "ns3/mmwave-enb-mac.h"
  41. #include "ns3/mmwave-phy-mac-common.h"
  42. #include "ns3/mmwave-mac-pdu-header.h"
  43. #include "ns3/mmwave-mac-sched-sap.h"
  44. #include "ns3/mmwave-mac-scheduler.h"
  45. #include "ns3/mmwave-control-messages.h"
  46. #include <ns3/lte-radio-bearer-tag.h>
  47. #include <ns3/log.h>
  48.  
  49.  
  50.  
  51.  
  52.  
  53. using namespace ns3;
  54. using namespace std;
  55.  
  56.  
  57. class nr{
  58.  
  59. public:
  60.  
  61. void UeRssiPerProcessedChunk (double rssidBm);
  62. void Run();
  63. ~nr ();
  64. };
  65.  
  66. void nr::UeRssiPerProcessedChunk (double rssidBm)
  67. {
  68.  
  69. cout<<rssidBm<<endl;
  70.  
  71. }
  72.  
  73.  
  74. void UeRssiPerProcessedChunkTrace (nr* scenario, double rssidBm)
  75. {
  76. scenario->UeRssiPerProcessedChunk (rssidBm);
  77. }
  78.  
  79.  
  80.  
  81.  
  82. void nr::Run()
  83. {
  84. Ptr<MmWaveHelper> ptr_mmv = CreateObject<MmWaveHelper>();
  85.  
  86. ptr_mmv->SetAttribute("ChannelModel", StringValue("ns3::MmWave3gppChannel"));
  87. ptr_mmv->SetAttribute("PathlossModel", StringValue("ns3::MmWave3gppPropagationLossModel"));
  88.  
  89.  
  90. Ptr<NrPointToPointEpcHelper> epcHelper = CreateObject<NrPointToPointEpcHelper> ();
  91. ptr_mmv->SetEpcHelper (epcHelper);
  92. ptr_mmv->Initialize();
  93.  
  94.  
  95. // create a ue and an enb
  96. NodeContainer enb;
  97. NodeContainer ue;
  98. enb.Create(3);
  99. ue.Create(1);
  100.  
  101.  
  102. Ptr<ListPositionAllocator> enbposaloc = CreateObject<ListPositionAllocator>();
  103. enbposaloc->Add(Vector( 76, 40, 3));
  104. enbposaloc->Add(Vector( 45 , 12 , 3));
  105. enbposaloc->Add(Vector( 20, 40, 3));
  106. MobilityHelper enbmob;
  107. enbmob.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  108. enbmob.SetPositionAllocator(enbposaloc);
  109. enbmob.Install(enb);
  110.  
  111. Ptr<ListPositionAllocator> ueposaloc = CreateObject<ListPositionAllocator>();
  112. ueposaloc->Add(Vector( 45, 40, 1.5));
  113.  
  114. MobilityHelper uemob;
  115. uemob.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  116. uemob.SetPositionAllocator(ueposaloc);
  117. uemob.Install(ue);
  118. BuildingsHelper::Install(ue);
  119.  
  120.  
  121. NetDeviceContainer enbnetdev = ptr_mmv->InstallEnbDevice (enb);
  122. NetDeviceContainer uenetdev = ptr_mmv->InstallUeDevice (ue);
  123.  
  124. //#######################################
  125.  
  126. // create the internet and install the IP stack on the UEs
  127. // get SGW/PGW and create a single RemoteHost
  128. Ptr<Node> pgw = epcHelper->GetPgwNode ();
  129. NodeContainer remoteHostContainer;
  130. remoteHostContainer.Create (1);
  131. Ptr<Node> remoteHost = remoteHostContainer.Get (0);
  132. InternetStackHelper internet;
  133. internet.Install (remoteHostContainer);
  134.  
  135. // connect a remoteHost to pgw. Setup routing too
  136. PointToPointHelper p2ph;
  137. p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s")));
  138. p2ph.SetDeviceAttribute ("Mtu", UintegerValue (2500));
  139. p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.000)));
  140. NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost);
  141. Ipv4AddressHelper ipv4h;
  142. ipv4h.SetBase ("1.0.0.0", "255.0.0.0");
  143. Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices);
  144. // in this container, interface 0 is the pgw, 1 is the remoteHost
  145. //Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1);
  146.  
  147. Ipv4StaticRoutingHelper ipv4RoutingHelper;
  148. Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
  149. remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
  150. internet.Install (ue);
  151. Ipv4InterfaceContainer ueIpIface;
  152. ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (uenetdev));
  153.  
  154. // Set the default gateway for the UEs
  155.  
  156. Ptr<Ipv4StaticRouting> ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ue.Get(0)->GetObject<Ipv4> ());
  157. ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1);
  158.  
  159.  
  160. ptr_mmv->AttachToEnb (*(uenetdev.Begin()), *(enbnetdev.Begin()));
  161.  
  162. uint16_t dlPort = 1234;
  163. ApplicationContainer clientAppsDl;
  164. ApplicationContainer serverAppsDl;
  165. DataRate udpRate = DataRate ("1Mbps");
  166. Time udpInterval = Time::FromDouble((1000*8) / static_cast<double> (udpRate.GetBitRate ()), Time::S);
  167.  
  168. UdpServerHelper dlPacketSinkHelper (dlPort);
  169. serverAppsDl.Add (dlPacketSinkHelper.Install (ue));
  170. // configure UDP downlink traffic
  171.  
  172. UdpClientHelper dlClient (ueIpIface.GetAddress (0), dlPort); //CHECK AFTER
  173. dlClient.SetAttribute ("MaxPackets", UintegerValue(0xFFFFFFFF));
  174. dlClient.SetAttribute("PacketSize", UintegerValue(1000));
  175. 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
  176. clientAppsDl.Add (dlClient.Install (remoteHost));
  177. Time udpAppStartTimeDl = MilliSeconds (100);
  178. Time udpAppStopTimeDl = MilliSeconds (2000);
  179.  
  180. // start UDP server and client apps
  181. serverAppsDl.Start(udpAppStartTimeDl);
  182. clientAppsDl.Start(udpAppStartTimeDl);
  183.  
  184. serverAppsDl.Stop(udpAppStopTimeDl);
  185. clientAppsDl.Stop(udpAppStopTimeDl);
  186.  
  187. //#######################################
  188.  
  189.  
  190.  
  191.  
  192. /*
  193. enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
  194. EpsBearer bearer (q);
  195. ptr_mmv->ActivateDataRadioBearer (uenetdev, bearer);
  196. */
  197.  
  198. //EpsBearerTag rnti;
  199. //uint16_t m_rnti = rnti.GetRnti();
  200.  
  201. ptr_mmv->EnableTraces();
  202.  
  203.  
  204.  
  205. Ptr<MmWaveSpectrumPhy > ue1SpectrumPhy = DynamicCast<MmWaveUeNetDevice>
  206. (uenetdev.Get(0))->GetPhy(0)->GetSpectrumPhy();
  207. Ptr<mmWaveInterference> ue1SpectrumPhyInterference = ue1SpectrumPhy->GetMmWaveInterference();
  208. NS_ABORT_IF(!ue1SpectrumPhyInterference);
  209. ue1SpectrumPhyInterference->TraceConnectWithoutContext("RssiPerProcessedChunk", MakeBoundCallback (&UeRssiPerProcessedChunkTrace, this));
  210.  
  211.  
  212.  
  213. //LteEnbCmacSapProvider* m_cmacSapProvider;
  214. //m_cmacSapProvider->RemoveUe(m_rnti);
  215.  
  216.  
  217.  
  218.  
  219. AnimationInterface anim("kkk.xml");
  220. anim.SetConstantPosition(enb.Get(0), 76.0, 40.0, 3.0);
  221. anim.SetConstantPosition(enb.Get(1), 45 , 12 , 3);
  222. anim.SetConstantPosition(enb.Get(2), 20, 40, 3);
  223. anim.SetConstantPosition(ue.Get(0), 45, 40, 1.5);
  224.  
  225.  
  226. Simulator::Stop (Seconds (1));
  227. Simulator::Run ();
  228. Simulator::Destroy ();
  229.  
  230. }
  231.  
  232.  
  233. nr::~nr ()
  234. {
  235. cout<<"Exiting"<<endl;
  236. }
  237.  
  238.  
  239. int main(int argc, char *argv[])
  240. {
  241. Config::SetDefault ("ns3::MmWavePhyMacCommon::CenterFreq", DoubleValue(30e9));
  242. Config::SetDefault ("ns3::MmWaveEnbPhy::TxPower", DoubleValue(23));
  243. Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::ChannelCondition", StringValue("n"));
  244. Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::Shadowing", BooleanValue(true));
  245. Config::SetDefault ("ns3::MmWave3gppChannel::Speed", DoubleValue (3.0*1000/3600));
  246. Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::Scenario", StringValue("InH-ShoppingMall"));
  247. Config::SetDefault ("ns3::MmWavePhyMacCommon::MacSchedulerType", TypeIdValue (TypeId::LookupByName("ns3::MmWaveMacSchedulerTdmaPF")));
  248. Config::SetDefault ("ns3::MmWave3gppPropagationLossModel::OptionalNlos", BooleanValue(false));
  249.  
  250.  
  251. nr aa;
  252. aa.Run();
  253.  
  254. return 0;
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement