NS3-Using the Tracing System

NS-3跟踪系统的基本目标是:

•对于基本任务,跟踪系统应允许用户为流行的跟踪源生成标准跟踪,并定制哪些对象生成追踪;

•中间用户必须能够扩展跟踪系统以修改生成的输出格式,或插入新的跟踪源,而无需修改模拟器的核心;

•高级用户可以修改模拟器核心以添加新的跟踪源和汇。

ASCII Tracing

在first.cc上添加ASCII Tracing,添加到调用Simulator::Run()之前。

AsciiTraceHelper ascii;
pointToPoint.EnableAsciiAll (ascii.CreateFileStream ("myfirst.tr"));

重新编译运行,就可以看到。。。。

Parsing Ascii Traces

• +: An enqueue operation occurred on the device queue;
• +: 在设备队列中发生了询问操作
• -: A dequeue operation occurred on the device queue;
• -: 在设备队列中发生了出发状态
• d: A packet was dropped, typically because the queue was full;
• d:删除数据包,通常是因为队列已满
• r: A packet was received by the net device
• r:网络设备接收数据包

举例

1 +
2 2
3 /NodeList/0/DeviceList/0/$ns3::PointToPointNetDevice/TxQueue/Enqueue
4 ns3::PppHeader (
5 Point-to-Point Protocol: IP (0x0021))
6 ns3::Ipv4Header (
7 tos 0x0 ttl 64 id 0 protocol 17 offset 0 flags [none]
8 length: 1052 10.1.1.1 > 10.1.1.2)
9 ns3::UdpHeader (
10 length: 1032 49153 > 9)
11 Payload (size=1024)

 PCAP Tracing

NS-3设备帮助程序还可用于以.pcap格式创建跟踪文件。首字母缩略词PCAP(通常用小写字母编写)代表数据包捕获,实际上是包含.pcap文件格式的定义的API。可以读取和显示此格式的最流行的程序是Wireshark(以前称为Ethereal)。但是,有许多流量跟踪分析器使用此数据包格式。我们鼓励用户利用可用于分析PCAP迹线的许多工具。在本教程中,我们专注于使用TCPDump查看PCAP迹线。

pointToPoint.EnablePcapAll ("myfirst")
//myfirst只是前缀名

如何阅读 .pacp文件

tcpdump -nn -tt -r myfirst-0-0.pcap
tcpdump -nn -tt -r myfirst-1-0.pcap

文件内容

reading from file myfirst-0-0.pcap, link-type PPP (PPP)
2.000000 IP 10.1.1.1.49153 > 10.1.1.2.9: UDP, length 1024
2.514648 IP 10.1.1.2.9 > 10.1.1.1.49153: UDP, length 1024


reading from file myfirst-1-0.pcap, link-type PPP (PPP)
2.257324 IP 10.1.1.1.49153 > 10.1.1.2.9: UDP, length 1024
2.257324 IP 10.1.1.2.9 > 10.1.1.1.49153: UDP, length 1024

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值