Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Omnet++ 执行OMNET++;/如果车辆和RSU都周期性地广播消息,模拟速度会非常慢吗?_Omnet++_Veins - Fatal编程技术网

Omnet++ 执行OMNET++;/如果车辆和RSU都周期性地广播消息,模拟速度会非常慢吗?

Omnet++ 执行OMNET++;/如果车辆和RSU都周期性地广播消息,模拟速度会非常慢吗?,omnet++,veins,Omnet++,Veins,让我先简要介绍一下情况: 我有一个场景,RSU大约每秒钟广播一条固定消息“RSUmessage”。我已经为RSU广播实现了以下代码(同样,这些固定消息的Psid为-100以区别于其他消息): void TraCIDemoRSU11p::handleSelfMsg(cMessage*msg){ if(WaveShortMessage*wsm=动态广播(msg)){ 如果(wsm->getPsid()=-100){ 发送(RSUmessage->dup()); scheduleAt(simTime(

让我先简要介绍一下情况:

我有一个场景,RSU大约每秒钟广播一条固定消息“RSUmessage”。我已经为RSU广播实现了以下代码(同样,这些固定消息的Psid为-100以区别于其他消息):

void TraCIDemoRSU11p::handleSelfMsg(cMessage*msg){
if(WaveShortMessage*wsm=动态广播(msg)){
如果(wsm->getPsid()=-100){
发送(RSUmessage->dup());
scheduleAt(simTime()+trsu+uniform(0.02,0.05),RSUmessage);
}
}
否则{
BaseWaveApplLayer::handleSelfMsg(wsm);
}
}
汽车可以从其他汽车以及RSU接收这些信息。RSU丢弃从汽车接收到的信息。cars将接收多条此类消息,进行一些比较,并定期广播类似类型的消息:“聚合消息””每间隔Tcar一次。aggregatedMessage还具有Psid=-100,因此可以轻松地将消息与其他消息区分开来

我正在使用自我信息安排汽车活动。(虽然我相信这可以在handlePositionUpdate内部完成)。汽车的把手如下所示:

void TraCIDemo11p::handleSelfMsg(cMessage* msg) {

    if (WaveShortMessage* wsm = dynamic_cast<WaveShortMessage*>(msg)) {
        wsm->setSerial(wsm->getSerial() +1);

        if (wsm->getPsid() == -100) { 
            sendDown(aggregatedMessage->dup());
            //sendDelayedDown(aggregatedMessage->dup(), simTime()+uniform(0.1,0.5));
            scheduleAt(simTime()+tcar+uniform(0.01, 0.05), aggregatedMessage);
        }
        //send this message on the service channel until the counter is 3 or higher.
        //this code only runs when channel switching is enabled
        else if (wsm->getSerial() >= 3) {
            //stop service advertisements
            stopService();
            delete(wsm);
        }
        else {
            scheduleAt(simTime()+1, wsm);
        }
    }
    else {
            BaseWaveApplLayer::handleSelfMsg(msg);
    }
}
void TraCIDemo11p::handleSelfMsg(cMessage*msg){
if(WaveShortMessage*wsm=动态广播(msg)){
wsm->setSerial(wsm->getSerial()+1);
如果(wsm->getPsid()=-100){
发送(聚合消息->dup());
//sendDelayedDown(aggregatedMessage->dup(),simTime()+统一(0.1,0.5));
scheduleAt(simTime()+tcar+uniform(0.01,0.05),aggregatedMessage);
}
//在服务频道上发送此消息,直到计数器为3或更高。
//此代码仅在启用通道切换时运行
如果(wsm->getSerial()>=3),则为else{
//停止服务广告
停止服务();
删除(wsm);
}
否则{
scheduleAt(simTime()+1,wsm);
}
}
否则{
BaseWaveApplLayer::handleSelfMsg(msg);
}
}
问题:使用此设置,模拟速度非常慢。在OMNETGUI的Express模式下,我在5-6小时或更长的时间内得到大约50秒的模拟时间。(RSU数量:64辆,车辆数量:40辆,约1kmx1km地图)

另外,我指的是邮报。OP说,他通过在每个RSU收到一条消息后取消发送消息来提高速度。在我的情况下,我不能删除它,因为我需要在每个间隔后发送广播消息

问题:我认为这种缓慢是因为每个节点都试图在每秒钟开始时发送消息。当所有车辆和节点同时调度和发送消息时,OMNET是否会减速?(放慢速度是有意义的,但要降低到什么程度)但是,模拟中总共只有大约100个节点。当然不能这么慢

我尝试的内容:我尝试使用
senddayeddown(wsm->dup(),simTime()+uniform(0.1,0.5))
将消息发送扩展到每一模拟秒的前半部分。这似乎可以阻止消息在每一次模拟开始时堆积起来,并稍微加快了速度,但总体上没有这么多

有人能告诉我这是正常行为还是我做错了什么。


我也为这篇冗长的文章道歉。如果不给出上下文,我无法解释我的问题。

似乎您的网络中充斥着消息:来自RSU的每一条消息都会被收到该消息的每一辆汽车复制并再次传输。因此,计算时间随着网络中节点(消息发送者)的数量呈二次增长(每个发送的消息必须由接收它的范围内的每个节点处理)。每个消息3次传输的限制似乎没有多大帮助,正如代码中的注释所示,如果没有通道切换,则根本不使用

因此,如果您不能改进/更改代码以发送更少的消息,那么您必须接受这一点。以延迟方式发送消息的小小调整只会在一秒钟内分发消息,但无法解决洪水问题

但是,您仍然可以遵循一些提示来提高模拟的性能:

  • 在发布模式下编译:
    make mode=release
  • 在终端环境中运行模拟
    Cmdenv
    /Run-u Cmdenv…
  • 如果您需要通过各种方式使用图形环境,您至少应该使用界面上部的滑块来加速动画

  • 从omnetpp.ini文件中删除
    simtime resolution
    参数可以解决此问题

    当信道延迟与仿真时间分辨率不匹配时,仿真内核似乎存在问题

    您可以通过克隆以下存储库来验证解决方案。请注意,您需要OMNeT++框架的功能性安装。具体来说,我在OMNeT++5.6.2中测试了此修复程序

    void TraCIDemo11p::handleSelfMsg(cMessage* msg) {
    
        if (WaveShortMessage* wsm = dynamic_cast<WaveShortMessage*>(msg)) {
            wsm->setSerial(wsm->getSerial() +1);
    
            if (wsm->getPsid() == -100) { 
                sendDown(aggregatedMessage->dup());
                //sendDelayedDown(aggregatedMessage->dup(), simTime()+uniform(0.1,0.5));
                scheduleAt(simTime()+tcar+uniform(0.01, 0.05), aggregatedMessage);
            }
            //send this message on the service channel until the counter is 3 or higher.
            //this code only runs when channel switching is enabled
            else if (wsm->getSerial() >= 3) {
                //stop service advertisements
                stopService();
                delete(wsm);
            }
            else {
                scheduleAt(simTime()+1, wsm);
            }
        }
        else {
                BaseWaveApplLayer::handleSelfMsg(msg);
        }
    }