LTE用户文档

(如有不当的地方,欢迎指正!)

1.背景

假定读者已经熟悉 ns-3 simulator ,能运行一般的仿真程序。如果不是的话,强烈推荐读者参考 [ns3tutorial]
 

2. 使用概述

ns-3 LTE 模块是一个软件库,允许仿真LTE网络,一些情况下还可以仿真核心网 Evolved Packet Core (EPC)。仿真过程通常涉及以下几个步骤:
  1. 定义仿真场景。
  2. 编写程序,重建期望的仿真场景拓扑/架构,通过使用 ns3::LteHelper API(定义在 src/lte/helper/lte-helper.h 中)访问 ns-3 LTE 模型库。
  3. 指定 objects 的配置参数,通过使用 input files(通过 ns3::ConfigStore)或直接在仿真程序中编写。
  4. 配置仿真器期望的输出。
  5. 运行仿真。

下面将通过实例解释这些步骤。

3. 基本的仿真程序

下面是一个最简单的仿真程序,只能允许 LTE-only 仿真(没有EPC)。
 
1. 初始模板:
#include <ns3/core-module.h>
#include <ns3/network-module.h>
#include <ns3/mobility-module.h>
#include <ns3/lte-module.h> using namespace ns3; int main (int argc, char *argv[])
{
// the rest of the simulation program follows
2. 创建一个 LteHelper 对象:
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
这会实例化一些常见对象(例如信道对象),并提供方法用于添加 eNBs 和UEs 然后配置它们。
 
3. 为 eNB(s) 和 UEs 创建 Node 对象:

NodeContainer enbNodes;
enbNodes.Create ();
NodeContainer ueNodes;
ueNodes.Create ();
注意上述节点实例此时并没有安装 LTE 协议栈;它们还是空节点。
 
4. 为所有节点配置移动性模型:

MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (enbNodes);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (ueNodes);

上述代码会将所有节点放置在坐标 (0,0,0)。请参考 ns-3 移动性模型文档学习如何设置自己想要的位置或者配置节点运动。

 
5. 在 eNB(s) 上安装 LTE 协议栈:
NetDeviceContainer enbDevs;
enbDevs = lteHelper->InstallEnbDevice (enbNodes);
 
6. 在 UEs 上安装LTE协议栈:
NetDeviceContainer ueDevs;
ueDevs = lteHelper->InstallUeDevice (ueNodes);
 
7. 连接 UEs  到 一个 eNB。这会根据 eNB  配置来配置每个 UE ,并在 eNB 和 UE 之间创建 RRC 连接。
lteHelper->Attach (ueDevs, enbDevs.Get ());
 
8.在每个 UE 和它所连接的 eNB 之间激活数据无线承载:
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
EpsBearer bearer (q);
lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
 该方法也激活了该承载的两种饱和业务生成器,分别用于上行和下行。
 
9.设置仿真停止时间:
Simulator::Stop (Seconds (0.005));

4 配置 LTE 模型参数

所有与LTE 模型相关的参数都可以通过 ns-3 属性系统管理。关于实现它的所有可能方法(例如环境变量, C++ API, GtkConfigStore...)的详细信息请参考[ns3tutorial] 和 [ns3manual] 。
接下来,我们开始简短总结如何使用 input files 和 ns-3 ConfigStore 来实现它。首先,你需要把下列程序放入到代码中,在 main () 开始的后面:
CommandLine cmd;
cmd.Parse (argc, argv);
ConfigStore inputConfig;
inputConfig.ConfigureDefaults ();
// parse again so you can override default values from the command line
cmd.Parse (argc, argv);
 
要想上述代码工作,确保包含头文件 #include "ns3/cinfug-store.h"。现在创建一个文本文件命名为(例如)input-defaults.txt 指定你想使用的一些属性的新的默认值:
default ns3::LteHelper::Scheduler "ns3::PfFfMacScheduler"
default ns3::LteHelper::PathlossModel "ns3::FriisSpectrumPropagationLossModel"
default ns3::LteEnbNetDevice::UlBandwidth ""
default ns3::LteEnbNetDevice::DlBandwidth ""
default ns3::LteEnbNetDevice::DlEarfcn ""
default ns3::LteEnbNetDevice::UlEarfcn ""
default ns3::LteUePhy::TxPower ""
default ns3::LteUePhy::NoiseFigure ""
default ns3::LteEnbPhy::TxPower ""
default ns3::LteEnbPhy::NoiseFigure ""

假定你的仿真程序称为  src/lte/examples/lte-sim-with-input,可以通过以下方式传递属性设置到仿真程序中:
./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lte-sim-with-input

而且,你可以使用下列命令生成模板输入文件:
./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lte-sim-with-input
注意上述代码会将所有的默认值(注册在你特定建立的仿真器中)放入到输入文件 input-defaults.txt 中,还包括一些非 LTE 属性。
 
 

我的仿真过程:
 
首先创建一个输入文件 input-defaults.txt  ,如下: 
 
其次,按照前面的步骤编写一个最简单的 LTE 程序 “lte-sim-with-input.cc”。代码如下:
 #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"
#include <ns3/buildings-helper.h>
//#include "ns3/gtk-config-store.h" using namespace ns3; int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv); //注意,先load 再 save!
// to save a template default attribute file run it like this:
// ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lte-sim-with-input
//
// to load a previously created default attribute file
// ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lte-sim-with-input ConfigStore inputConfig;
inputConfig.ConfigureDefaults (); // Parse again so you can override default values from the command line
cmd.Parse (argc, argv); Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); // Uncomment to enable logging
// lteHelper->EnableLogComponents (); // Create Nodes: eNodeB and UE
NodeContainer enbNodes;
NodeContainer ueNodes;
enbNodes.Create ();
ueNodes.Create (); // Install Mobility Model
MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (enbNodes);
BuildingsHelper::Install (enbNodes);
// mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
// mobility.Install (ueNodes);
// BuildingsHelper::Install (ueNodes); mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
"X", StringValue ("100.0"),
"Y", StringValue ("100.0"),
"Rho", StringValue ("ns3::UniformRandomVariable[Min=0|Max=30]"));
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
"Mode", StringValue ("Time"),
"Time", StringValue ("2s"),
"Speed", StringValue ("ns3::ConstantRandomVariable[Constant=1.0]"),
"Bounds", StringValue ("0|200|0|200"));
mobility.Install(ueNodes);
BuildingsHelper::Install (ueNodes); // Create Devices and install them in the Nodes (eNB and UE)
NetDeviceContainer enbDevs;
NetDeviceContainer ueDevs;
// Default scheduler is PF, uncomment to use RR
//lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler"); enbDevs = lteHelper->InstallEnbDevice (enbNodes);
ueDevs = lteHelper->InstallUeDevice (ueNodes); // Attach a UE to a eNB
lteHelper->Attach (ueDevs, enbDevs.Get ()); // Activate a data radio bearer
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
EpsBearer bearer (q);
lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
//lteHelper->EnableTraces (); Simulator::Stop (Seconds (1.05)); // configure all the simulation scenario here...
lteHelper->EnablePhyTraces ();
lteHelper->EnableMacTraces ();
lteHelper->EnableRlcTraces ();
lteHelper->EnablePdcpTraces (); Simulator::Run (); // GtkConfigStore config;
// config.ConfigureAttributes (); Simulator::Destroy ();
return ;
}
 
 
然后在终端执行"load"命令,传递属性设置到仿真程序中 :
 执行完成后, 会增加以下关键性能指标(KPI)文件:
注意:由于程序“lte-sim-with-input.cc”是 LTE only 程序,没有 EPC,所以 DlPdcpStats.txt 和 UlPdcpStats.txt 内容为空。
 
接着在终端执行 "save" 命令,生成模板输入文件 :
 
执行完成后,input-defaults.txt 增加了很多属性,部分内容截图如下: 
 
 
 
 
 
 

参考文献

https://www.nsnam.org/docs/models/html/lte-user.html

LTE Module User Documentation(翻译1)——背景、使用概述、基本的仿真程序和配置LTE模型参数的更多相关文章

  1. LTE Module User Documentation(翻译15)——示例程序、参考场景以及故障检测和调试技巧

    LTE用户文档 (如有不当的地方,欢迎指正!)     21 Examples Programs(示例程序)   路径 src/lte/examples/ 包含一些示例仿真程序,这些例子表明如何仿真不 ...

  2. LTE Module User Documentation(翻译13)——频率复用算法(Frequency Reuse Algorithms)

    LTE用户文档 (如有不当的地方,欢迎指正!)   19 Frequency Reuse Algorithms(频率复用算法)   本节我们将描述如何在 LTE 仿真中使用频率复用(FR)算法.共有两 ...

  3. LTE Module User Documentation(翻译8)——核心网(EPC)

    LTE用户文档 (如有不当的地方,欢迎指正!) 14 Evolved Packet Core (EPC)   我们现在讲解如何编写一个仿真程序——除了 LTE 无线接入网外,还允许仿真 EPC. EP ...

  4. LTE Module User Documentation(翻译5)——Mobility Model with Buildings

    LTE用户文档 (如有不当的地方,欢迎指正!) 8 Mobility Model with Buildings   我们现在通过例子解释如何在 ns-3 仿真程序中使用 buildings 模型(特别 ...

  5. LTE Module User Documentation(翻译2)——配置LTE MAC 调度器

    LTE用户文档 (如有不当的地方,欢迎指正!) 5 配置 LTE MAC 调度器   这里有几种 LTE MAC 调度器用户可以选择.使用下面的代码定义调度器的类型: Ptr<LteHelper ...

  6. LTE Module User Documentation(翻译14)——Uplink Power Control(上行功率控制)

    LTE用户文档 (如有不当的地方,欢迎指正!) 20 Uplink Power Control(上行功率控制)   上行功率控制功能默认是开启的.用户可以通过设置布尔属性 ns3::LteUePhy: ...

  7. LTE Module User Documentation(翻译12)——X2切换(X2-based handover)

    LTE用户文档 (如有不当的地方,欢迎指正!) 18 X2-based handover   正如 3GPP 定义的,切换是改变用户服务小区的连接方式的过程.这一过程中涉及的两个基站通常称为源基站和目 ...

  8. LTE Module User Documentation(翻译11)——配置用户测量

    LTE用户文档 (如有不当的地方,欢迎指正!) 17 Configure UE measurements   仿真中激活的用户测量配置取决于所选的 “consumers”,例如切换算法.用户可能需要添 ...

  9. LTE Module User Documentation(翻译10)——网络连接(Network Attachment)

    LTE用户文档 (如有不当的地方,欢迎指正!) 16 Network Attachment(网络连接)   正如前面章节 Basic simulation program 所述,连接用户到基站时通过调 ...

随机推荐

  1. java中使用反射做一个工具类,来为指定类中的成员变量进行赋值操作,使用与多个类对象的成员变量的赋值。

    //------------------------------------------------我是代码的分割线 // 首选是一个工具类,在该工具类里面,定义了一个方法,public void s ...

  2. NLog

    C# 使用NLog记录日志 C#第三方日志库Nlog NLog类库使用探索——详解配置 使用Nlog记录日志到数据库 NLog文章系列——系列文章目录以及简要介绍 NLog日志框架简写用法(write ...

  3. 1、java基础回顾与加强

    一.    基础回顾 1   集合 1.1  集合的类型与各自的特性 ---|Collection: 单列集合 ---|List: 有存储顺序, 可重复 ---|ArrayList:    数组实现, ...

  4. 【转】MYSQL入门学习之七:MYSQL常用函数

    转载地址:http://www.2cto.com/database/201212/175864.html 一.数学函数  www.2cto.com           ABS(x)           ...

  5. Collection的toArray()使用上需要注意的地方

    转载:http://llade.iteye.com/blog/199818 Collection在很多情况下需要转换为数组来处理(很多接口方法都使用array作为参数). Collection的toA ...

  6. [小技巧] git: Your branch and 'origin/master' have diverged

    本文参考:http://stackoverflow.com/questions/19864934/git-your-branch-and-origin-master-have-diverged-how ...

  7. hbase centOS生产环境配置笔记 (1 NameNode, 1 ResourceManager, 3 DataNode)

    本次是第一次在生产环境部署HBase,本文若有配置上的不妥之处还请高手指正. hadoop版本:hadoop-2.4.1 HBase版本:hbase-0.98.6.1-hadoop2 Zookeepe ...

  8. Java提高篇---Stack

    在Java中Stack类表示后进先出(LIFO)的对象堆栈.栈是一种非常常见的数据结构,它采用典型的先进后出的操作方式完成的.每一个栈都包含一个栈顶,每次出栈是将栈顶的数据取出,如下: Stack通过 ...

  9. 2017年1月8日 星期日 --出埃及记 Exodus 21:34

    2017年1月8日 星期日 --出埃及记 Exodus 21:34 the owner of the pit must pay for the loss; he must pay its owner, ...

  10. Win8.1系统下搭建IIS8.5+php-5.6运行环境教程

    本文是在window 8.1 的IIS8.5 中搭建php环境 步骤: 1.下载php-5.6程序包 ,官网地址为:http://windows.php.net/download/     注意要下载 ...