You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何统计OMNET++中WLAN仿真的Ping发送、接收与丢失数量?

OMNeT++ INET PingApp WLAN仿真统计问题解决

问题背景

使用INET框架的PingApp完成WLAN仿真,已配置部分统计项,但仅能看到pingRxSeq和pingTxSeq序列向量,无法获取:

  • 已发送的Ping数量
  • 已接收的Ping数量
  • 上述数据与sendInterval的关联
  • 丢失的Ping数量

解决方案

1. 修正NED文件的统计配置

原NED中全局定义的@statistic无法正确关联到PingApp实例,需移除全局统计项,让PingApp自带的信号生效:

import inet.applications.pingapp.PingApp;
import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
import inet.node.inet.WirelessHost;
import inet.node.wireless.AccessPoint;
import inet.physicallayer.wireless.ieee80211.packetlevel.Ieee80211ScalarRadioMedium;

network WLAN
{
    parameters:
        int numHosts = default(2);
        **.mgmt.numChannels = 2;
        @display("bgb=645,452");

    submodules:
        host[numHosts]: WirelessHost {
            @display("p=287,101");
            wlan[*].mgmt.typename = "Ieee80211MgmtStaSimplified";
        }

        ap: AccessPoint {
            @display("p=111,260");
            wlan[*].mgmt.typename = "Ieee80211MgmtApSimplified";
        }

        radioMedium: Ieee80211ScalarRadioMedium {
            @display("p=462,201");
        }
        configurator: Ipv4NetworkConfigurator {
            @display("p=462,320");
        }
}

2. 调整INI文件的统计配置

PingApp内置了sentPk(发送包信号)、rcvdPk(接收包信号)、lostPk(丢包信号)等,只需在INI中开启这些信号的统计记录,并配置合适的统计模式:

[General]
network = WLAN
#cmdenv-output-file = omnetpp.log
#debug-on-errors = true
#record-eventlog = true

**.constraintAreaMinX = 0m
**.constraintAreaMinY = 0m
**.constraintAreaMinZ = 0m
**.constraintAreaMaxX = 500m
**.constraintAreaMaxY = 300m
**.constraintAreaMaxZ = 0m

# access point
**.ap.wlan[*].address = "10:00:00:00:00:00"
**.host[*].**.mgmt.accessPointAddress = "10:00:00:00:00:00"
**.mgmt.frameCapacity = 10 

# ping app (host[0] pinged by others)
**.numApps = 1
**.app[0].typename = "PingApp"
*.host[0].app[0].destAddr = ""
*.host[*].app[0].destAddr = "host[0]"
*.host[*].app[0].sendInterval = 10ms

# 开启所有PingApp的统计记录
**.app[*].statistic-recording = true
**.app[*].result-recording-modes = "all"

# 配置具体统计项:发送数、接收数、丢包数
**.app[*].@statistic[sentPk](title="Pings Sent"; record=last,vector; interpolationmode=none; source=sentPk)
**.app[*].@statistic[rcvdPk](title="Pings Received"; record=last,vector; interpolationmode=none; source=rcvdPk)
**.app[*].@statistic[lostPk](title="Pings Lost"; record=last,vector; interpolationmode=none; source=lostPk)

# 保留原有WLAN配置
**.wlan[*].mac.retryLimit = 7
**.bandName = "5 GHz (20 MHz)"
**.opMode = "ac"
**.wlan[*].radio.antenna.numAntennas = 8
**.bitrate = 693.3Mbps
**.wlan[*].radio.transmitter.power = 100mW
**.wlan[*].radio.transmitter.headerBitLength = 100b
**.carrierFrequency = 5GHz
**.wlan[*].radio.receiver.sensitivity = -85dBm
**.wlan[*].radio.receiver.snirThreshold = 4dB

[Config Ping1]
description = "host1 pinging host0"
*.numHosts = 2

3. 结果说明

  • 已发送/接收/丢失Ping数量:仿真结束后,在结果文件中可查看每个host[*].app[0]对应的sentPk:last、rcvdPk:last、lostPk:last数值,分别对应总发送、总接收、总丢包数。
  • 与sendInterval的关联:sentPk和rcvdPk的vector序列会记录每个包的发送/接收时间戳,由于sendInterval=10ms,发送时间点会呈现10ms间隔的规律,可通过向量数据直观看到时间间隔与发送/接收的关联。

内容的提问来源于stack exchange,提问作者nisar007

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 08:46:06