跳转至

PingMesh

Pingmesh是一个基于ns-3网络模拟器的测量工具,通过持续发送UDP ping包来测量网络端点间的往返时间(RTT)。它包含两种使用模式:

  1. 推荐模式:通过调度器自动管理全流程
  2. 手动模式:直接安装客户端/服务器应用

关键测量指标包括:单向延迟(latency_to_there_ns/latency_from_there_ns)、往返时间(rtt_ns)和数据包丢失状态(YES/LOST)。

组件

  • 客户端模块:udp-rtt-client.cc/h
  • 服务端模块:udp-rtt-server.cc/h
  • 调度器模块:pingmesh-scheduler.cc/h
  • 助手工具:udp-rtt-helper.cc/h

部署应用

部署模式对比

依然是两种部署模式!

特性 调度器模式 手动模式
配置复杂度 低(自动批量管理) 高(逐节点配置)
测量覆盖范围 全网络/指定端点对 自定义节点组合
推荐场景 全局网络监控 特定路径调试

使用调度器

  1. 配置文件设置 (config_ns3.properties):
    Properties
    1
    2
    3
    enable_pingmesh_scheduler=true
    pingmesh_interval_ns=100000000    # 100ms测量间隔
    pingmesh_endpoint_pairs=all       # 监控所有端点
    
  2. 代码集成
    C++
    1
    2
    3
    4
    5
    #include "ns3/pingmesh-scheduler.h"
    
    PingmeshScheduler scheduler(basicSimulation, topology);
    
    scheduler.WriteResults();  // 仿真后调用
    

手动安装

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
// 服务端安装(节点B)
UdpRttServerHelper serverHelper(1025);
serverHelper.Install(node_b).Start(Seconds(0));

// 客户端安装(节点A)
UdpRttClientHelper clientHelper(
    node_b_ip, 
    1025, 
    node_a_id, 
    node_b_id
);

clientHelper.SetAttribute("Interval", TimeValue(NanoSeconds(1e8)));
ApplicationContainer clientApp = clientHelper.Install(node_a);
clientApp.Start(NanoSeconds(start_time));

数据采集接口

C++
1
2
3
4
5
6
Ptr<UdpRttClient> client = app_a_to_b->GetObject<UdpRttClient>();

// 获取测量数据(时间戳为-1表示数据包丢失)
std::vector<int64_t> send_times = client->GetSendRequestTimestamps(); // 发送时间戳
std::vector<int64_t> reply_times = client->GetReplyTimestamps();      // 回复时间戳
std::vector<int64_t> receive_times = client->GetReceiveReplyTimestamps(); // 接收时间戳

日志文件解析

文件名 格式
pingmesh.csv src,dst,seq,send_ns,reply_ns,recv_ns,latency_fwd,latency_bwd,rtt,status
pingmesh.txt 可视化表格,标记[LOST]丢包事件

状态码说明

  • YES: 成功完成测量
  • LOST: 数据包丢失

注:时间戳为-1表示数据包丢失,RTT计算为(recv_ns - send_ns)

Note

调度器模式默认生成全节点拓扑测量矩阵,结果文件存放于logs_ns3目录。

这实际上可以优化,就像之前 link_utilization_trackerlink_queue_tracker一样,目前都是只能全局统一开启

最好的方式应该是可以局部开启,用户自行指定运行的范围