【问题标题】:error when using RandomWPMobility, omnet++ simulation environment使用RandomWPMobility、omnet++模拟环境时出错
【发布时间】:2025-11-23 10:05:02
【问题描述】:

我正在学习使用 AODV 协议(作为 INET 库的一部分实现)在 omnet++(版本 5.1.1,在 ubuntu 16.04,x64 上)模拟无线通信的教程。 我使用了以下代码:

*.host*.mobilityType = "RandomWPMobility"
*.host*.mobility.waitTime= uniform (100s,500s)
*.host*.mobility.speed = uniform(1mps, 10mps)
*.host*.mobility.updateInterval = 0.1s

运行代码时出现错误:

无法安排消息 (omnetpp::cMessage) 移动到过去,t=-9.22337e+06 -- 在模块 (inet::RandomWPMobility) Basic.hostA.mobility (id=39) 中,在网络初始化期间

有人可以帮我解决这个错误吗?

【问题讨论】:

    标签: c++ omnet++ inet


    【解决方案1】:

    我在本教程中遇到了同样的错误。我不知道它的确切来源,但这是我找到的解决方案:

    omnetpp.ini

    [Config TestRandomWPMobility2]
    network = MobileNetwork
    
    *.host[0].udpApp[0].typename = "UDPBasicApp" # Protocole de communication
    *.host[1].udpApp[0].typename = "UDPSink"    # hostMobB = jette les messages recus
    *.host*.wlan[0].typename = "IdealWirelessNic"
    
    **.constraintAreaMinX = 0m
    **.constraintAreaMinY = 0m
    **.constraintAreaMinZ = 0m
    **.constraintAreaMaxX = 600m
    **.constraintAreaMaxY = 400m
    **.constraintAreaMaxZ = 0m
    **.updateInterval = 0.1s # test with 0s too, and let getCurrentPosition update the display string from a test module
    
    *.numHosts = 5
    **.host*.mobilityType = "RandomWPMobility"
    **.host[0].mobility.speed = 10*uniform(20mps,50mps)
    **.host*.mobility.speed = uniform(20mps,50mps)
    **.host*.mobility.waitTime = uniform(3s,8s)
    

    MobileNetwork.ned:

    network MobileNetwork
    {
        parameters:
            int numHosts;
            @display("bgb=600,400");
        submodules:
            host[numHosts]: MobileHost {
                parameters:
                    @display("p=400+50*numHosts,300+50*numHosts;r=,,#707070");
            }
    }
    

    希望对你有帮助。

    【讨论】: