简体   繁体   English

(OMNeT++) 数据包 go 在哪里?

[英](OMNeT++) Where do packets go?

I'm trying to do a project described also here: PacketQueue is 0我正在尝试做一个在这里也描述的项目: PacketQueue is 0

I've modified the UdpBasicApp.cc to suit my needs, and in the handleMessage() function I added a piece of code to retrieve the length of the ethernet queue of a router.我修改了 UdpBasicApp.cc 以满足我的需要,并在 handleMessage() function 中添加了一段代码来检索路由器的以太网队列的长度。 However the value returned is always 0.但是返回的值始终为 0。

My.ned file regarding the queue of routers is this:关于路由器队列的 My.ned 文件是这样的:

**.router*.eth[*].mac.queue.typename = "DropTailQueue"
**.router*.eth[*].mac.queue.packetCapacity = 51

The code added in the UdpBasicApp.cc file is this: UdpBasicApp.cc 文件中添加的代码是这样的:

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

So my question is this: is this the right way to create a queue in a router linked to other nodes with an ethernet link?所以我的问题是:这是在通过以太网链路链接到其他节点的路由器中创建队列的正确方法吗? My doubt is that maybe packets don't pass through the specified interface, ie I've set the ini parameters for the wrong queue.我怀疑可能数据包没有通过指定的接口,即我为错误的队列设置了 ini 参数。

You are not creating that queue.您没有创建该队列。 It was already instantiated by the OMNeT++ kernel.它已经由 OMNeT++ kernel 实例化。 You are just getting a reference to an already existing module with the getModuleByPath() call.您只是通过getModuleByPath()调用获得对现有模块的引用。

The router3.eth[*].mac.queue. router3.eth[*].mac.queue. module path is rather suspicious in that call.模块路径在该调用中相当可疑。 It is hard-coded in all of your application to get the queue length from router3 even if the app is installed in router1 .即使应用程序安装在router1中,它在所有应用程序中都经过硬编码以从router3获取队列长度。 ie you are trying to look at the queue length in a completely different node.即,您正在尝试查看完全不同节点中的队列长度。 Then, the eth[*] is wrong.然后, eth[*]是错误的。 As a router obviously contains more than one ethernet interface (otherwise it would not be a router), you must explicitly specify which interface you want to sepcify.由于路由器显然包含多个以太网接口(否则它不会是路由器),您必须明确指定要指定接口。 You must not specify patterns in module path (ie eth[0] or something like that, with an exact index must be specified).您不能在模块路径中指定模式(即eth[0]或类似的东西,必须指定精确的索引)。 And at this point, you have to answer the question which ethernet interface I'm interested in, and specify that index.此时,您必须回答我感兴趣的以太网接口的问题,并指定该索引。 Finally the .最后. end the end is also invalid, so I believe, your code never executes, otherwise the check_and_cast part would have raised an error already. end end 也是无效的,所以我相信,你的代码永远不会执行,否则check_and_cast部分已经引发了错误。

If you wanted to reach the first enthern interface from an UDP app in the same node, you would use relative path, something like this: ^.eth[0].mac.queue如果您想从同一节点中的 UDP 应用程序访问第一个 enthern 接口,您将使用相对路径,如下所示: ^.eth[0].mac.queue

Finally, if you are unsure whether your model works correctly, why not start the model with Qtenv, and check whether the given module receives any packet?最后,如果您不确定您的 model 是否正常工作,为什么不使用 Qtenv 启动 model,并检查给定模块是否收到任何数据包? Like,, drill down in the model until the given queue is opened as a simple module (ie you see the empty inside of the queue module) and then tap the run/fast run until next event in this module .就像,在 model 中向下钻取,直到给定队列作为一个简单模块打开(即您看到队列模块内部为空),然后点击运行/快速运行,直到此模块中的下一个事件 If the simulation does not stop, then that module indeed did not received any packets and your configuration is wrong.如果模拟没有停止,那么该模块确实没有收到任何数据包,并且您的配置错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM