本文介绍了(OMNeT++) 为什么 PacketQueue 总是 0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 OMNeT++ 中编写一个应用程序,该应用程序从调用它的节点获取队列长度并将其发送到另一个节点.

I'm trying to code in OMNeT++ an app that gets the queue length from the node where it is invoked and sends it to another node.

本方案是修改路由器调用的UdpBasicApp.cc文件,使其获取到DropTailQueue模块的队列长度.

The plan is to modify the UdpBasicApp.cc file invoked in a router and make it get the length of the queue of the DropTailQueue module.

上网查了一下,发现这个方法是对的...

Searching online I found that this is the right method...

cModule *mod = getModuleByPath("router3.eth[*].mac.queue");
queueing::PacketQueue *queue = check_and_cast<queueing::PacketQueue*>(mod);
int c = queue->getNumPackets();
EV << c;

...因为 DropTailQueue 扩展了 PacketQueue 模块.我在最后放了一个打印件,看看是否有什么问题.当我使用修改后的 UdpBasicApp 模块运行模拟时,c 始终为 0.我几乎不怀疑队列总是0,但我不知道如何验证这个怀疑.如果是错误,为什么总是0?

...since the DropTailQueue extends the PacketQueue module.I put a print at the end to see if there was something wrong.When I run the simulation, using the modified UdpBasicApp module, c is always 0.I hardly doubt that the queue is always 0, but I don't know how to verify this doubt.If it's an error, why is it always 0?

推荐答案

我的猜测是,您查询的队列与您假设的队列不同.您不应在模型路径中使用模式(即 *),因为这可能会匹配多个 eth 模块,并且未指定将返回哪个模块.

My guess is, that you are querying a different queue than you assume. You should not use patterns (i.e. *) in your model path, because that may match on multiple eth modules, and it's unspecified, which one will be returned.

这篇关于(OMNeT++) 为什么 PacketQueue 总是 0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 13:39
查看更多