基于ns3的LTE仿真基本架构代码
2014-07-05 21:26
393 查看
#include <ns3/core-module.h> #include <ns3/network-module.h> #include <ns3/mobility-module.h> #include <ns3/lte-module.h> #include <ns3/config-store.h> using namespace ns3; int main (int argc, char *argv[]) { CommandLine cmd; cmd.Parse (argc, argv); // Set the Configure File in input-defaults.txt ConfigStore inputConfig; inputConfig.ConfigureDefaults (); inputConfig.SetFileFormat (ConfigStore::RAW_TEXT); inputConfig.SetMode (ConfigStore::LOAD); inputConfig.SetFilename ("input-defaults.txt"); // Create an LteHelper object: Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); // Create Node objects for the eNB(s) and the UEs -- JUST Empty Nodes NodeContainer enbNodes; NodeContainer ueNodes; enbNodes.Create (1); ueNodes.Create (2); // Configure the Mobility model for all the nodes: // The following will place all nodes at the coordinates (0,0,0). MobilityHelper mobility; mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (enbNodes); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (ueNodes); // Install an LTE protocol stack on the eNB(s) and UEs: NetDeviceContainer enbDevs; NetDeviceContainer ueDevs; enbDevs = lteHelper->InstallEnbDevice (enbNodes); ueDevs = lteHelper->InstallUeDevice (ueNodes); // Attach the UEs to an eNB. This will configure each UE according to // the eNB configuration, and create an RRC connection between them: lteHelper->Attach (ueDevs, enbDevs.Get (0)); // Activate a data radio bearer between each UE and the eNB it is attached to: // This method will also activate two saturation traffic generators for that bearer, // one in uplink and one in downlink. enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; EpsBearer bearer (q); lteHelper->ActivateDataRadioBearer (ueDevs, bearer); // Set the stop time -- this is needed otherwise the simulation will last forever: Simulator::Stop (Seconds (0.05)); // configure all the simulation scenario here... lteHelper->EnablePhyTraces (); lteHelper->EnableMacTraces (); lteHelper->EnableRlcTraces (); lteHelper->EnablePdcpTraces (); // Run the simulation: Simulator::Run (); // Cleanup and exit: Simulator::Destroy (); return 0; <span style="font-size:14px;">} </span>
需要在waf执行目录下放置一个配置文本文件input-defaults.txt
文本文件input-defaults.txt内容如下:
default ns3::LteHelper::Scheduler "ns3::PfFfMacScheduler"
default ns3::LteHelper::PathlossModel "ns3::FriisSpectrumPropagationLossModel"
4000
default ns3::LteEnbNetDevice::UlBandwidth "25"
default ns3::LteEnbNetDevice::DlBandwidth "25"
default ns3::LteEnbNetDevice::DlEarfcn "100"
default ns3::LteEnbNetDevice::UlEarfcn "18100"
default ns3::LteUePhy::TxPower "10"
default ns3::LteUePhy::NoiseFigure "9"
default ns3::LteEnbPhy::TxPower "30"
default ns3::LteEnbPhy::NoiseFigure "5"
相关文章推荐
- 基于ns3的LTE仿真基本架构代码
- 基于gridview的三层结构的代码演示 (二 ) 三层架构的实例演示 (原创,如需转载请联系作者)
- JAVA与.NET的相互调用——TCP/IP相互调用基本架构(附原代码) 推荐
- (三层架构入门)最基本的三层架构搭建方法(详细过程及所有代码)
- 基于Elasticsearch2.1.1的JavaAPI基本操作代码示例
- 三层架构dal 层基本代码 非查询/查询
- 『原创』DX图形显示基本流程(基于MESH静态模型绘制----托管代码)
- [置顶] 基于springboot+mybatis的微信公众号开发第一篇-基本架构
- NS3-仿真LTE-bug调试笔记
- [朝花夕拾]基于C#的模拟仿真平台设计(部分)及服务器异步通信代码
- essential c++ 基于第二章的内容采用面向过程的方法实现猜字游戏的基本实现代码
- 一个基于 EasyUI 的前台架构(3)封装操作Tabs的JS代码
- 基于 EntityFramework 的数据库主从读写分离架构(1) - 原理概述和基本功能实现
- 一个基于 EasyUI 的前台架构(3)封装操作Tabs的JS代码
- 大连实训之基于MFC的对数据库的基本操作(整体代码)
- 基于51单片机的花样流水灯仿真(代码)
- 基于arm的fast models的架构仿真和linux kernel 开发
- 一个基于 EasyUI 的前台架构(3)封装操作Tabs的JS代码