提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
提示:以下是本篇文章正文内容,下面案例可供参考
一 准备
ubuntu 20.0.4
ns-3.31
netanim-3.108
Wireshark
二 原始LTE脚本
选择src/lte/examples/lena-simple-epc.cc
包含无线接入网(RAN)和分组核心网(EPC)
将其复制到scratch/下
三 添加Log辅助信息+trace输出
(1)添加如下代码
//使用netanim相关接口
#include "ns3/netanim-module.h"
//使能相关的log组件,可以看到应用层使用了UdpClientHelper和PacketSinkHelper
LogComponentEnable("UdpClient",LOG_LEVEL_INFO);
LogComponentEnable("PacketSink",LOG_LEVEL_INFO);
//ltehelper是关于UE和eNB的无线信道的数据传输,
//p2ph是应用了p2p协议的有线信道,包含eNB,pgw,sgw,remotehost之间的数据传输。
//前者导出的是txt文件,后者是pcap文件可由wireshark查看
lteHelper->EnableTraces ();
p2ph.EnablePcapAll("data/simple-epc");
//以下部分是由netanim查看的xml文件
//总共8个节点,均设置为固定位置,具体坐标可以自由考虑
//另外设置了各节点的别名和颜色,以便查看
AnimationInterface anim("data/simple-epc.xml");
anim.EnablePacketMetadata();
anim.UpdateNodeDescription(pgw,"pgw");
anim.UpdateNodeColor(pgw,255,0,0);
anim.UpdateNodeDescription(epcHelper->GetSgwNode(),"sgw");
anim.UpdateNodeColor(epcHelper->GetSgwNode(),255,0,0);
anim.UpdateNodeDescription(remoteHost,"remoteHost");
anim.UpdateNodeColor(remoteHost,255,0,0);
AnimationInterface::SetConstantPosition(remoteHost,15,0);
AnimationInterface::SetConstantPosition(pgw,0,30);
AnimationInterface::SetConstantPosition(epcHelper->GetSgwNode(),30,30);
AnimationInterface::SetConstantPosition(enbNodes.Get(0),0,50);
AnimationInterface::SetConstantPosition(enbNodes.Get(1),0,60);
AnimationInterface::SetConstantPosition(ueNodes.Get(0),30,50);
AnimationInterface::SetConstantPosition(ueNodes.Get(1),30,60);
for(uint32_t i = 0; i < ueNodes.GetN(); ++i)
{
anim.UpdateNodeDescription(ueNodes.Get(i),"ue");
anim.