基于ns3的LTE仿真基本架构代码

#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;
}

需要在waf执行目录下放置一个配置文本文件input-defaults.txt

文本文件input-defaults.txt内容如下:

default ns3::LteHelper::Scheduler "ns3::PfFfMacScheduler"
default ns3::LteHelper::PathlossModel "ns3::FriisSpectrumPropagationLossModel"
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"

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值