如何使用自定义消息扩展不同的Inet模块? [英] How to extend different Modules of Inet with custom messages?

查看:91
本文介绍了如何使用自定义消息扩展不同的Inet模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为INET(AODV)仿真准备了所有示例并正在运行。我的网络由AODV路由器主机的数量组成。

I have all the examples up and running for the INET (AODV) simulation. My network comprises of number of AODV Router hosts.

我的下一个任务是就每个主机的当前位置交换一些自定义消息(将在一定时间后通过Mobility更新) )。我发现的所有示例(通常)都是 tictoc 的,它要求我在<$ c中构建 simpleModule $ c> .cc 文件,然后在 .ned 文件中使用该模块。我想使用 AODVRouter 模块交换这些消息(因为它已经具有网络所需的已实现的东西)。

My next task is to exchange some custom massages regarding each host's current position (which will be updated after a certain time through Mobility). All the examples I found (normally) are of tictoc which is asking me to build a simpleModule in a .cc file and then use that module in the .ned file. I want to use the AODVRouter module to exchange these messages (as it already has the implemented things that I need for the network).

是我用于交换的示例带有 cSimpleModule

This is the example I used for exchanging messages with a cSimpleModule

我已经尝试了这个示例(如INET项目中所述),但是这里的问题是它只是扩展 cSimpleModule 。由于我想使用 AODVRouter 模块(来自INET)作为我的发送者和接收者,因此无法使用此示例。所以我的问题是,还有另一种方法(即通过INET模块,例如 AODVRouter 模块发送和接收消息)。

I have tried this example (as described in INET project), but the problem here is that it is only extending cSimpleModule. Since I want to use AODVRouter module (from INET) as my sender and receiver, I can't use this example. So my question is, what is the other way to do it (i.e. sending and receiving messages through INET modules such as AODVRouter module).

推荐答案

如何处理此问题取决于这些消息是什么以及它们与AODV协议的关系。

How you handle this problem depends on what those messages are, and how they are related to the AODV protocol.


  • 如果您尝试使用某些位置感知功能扩展AODV协议,并且该位置将由路由协议本身使用,那么您显然应该考虑AODVRouting 源代码。您可以在此处查看消息的发送/接收方式。

  • If you are trying to extend the AODV protocol with some location aware features and the location will be used by the routing protocol itself, then you should obviously look into the AODVRouting source code. You can check there to see how the messages are sent/received.

如果消息与AODV完全无关,并且您想要实现某种应用程序级别消息交换,那么方法是创建一个应用程序模块并将其安装到路由器中。当然,您必须知道要使用TCP还是UDP发送数据(我猜UDP是因为它更适合于面向消息的数据交换)。届时,您应该实现 UDPBasicApp ,另外还要创建自己的PacketType,其中包含要传输的数据(即节点的坐标)。

If the message is completely unrelated to AODV and you want to implement some kind of application level message exchanges, then the way is to create an "Application" module and install it into the router. Of course, you have to know whether you want to send the data using TCP or UDP (I'm guessing UDP as that is more suited to message oriented data exchange). At that point you should implement something like the UDPBasicApp with the addition that you create your own PacketType that contains the data you want to transmit (i.e. the coordinates of the node). Use that for starting.

通常,TicToc教程只是一个基本示例,用于说明如何通过以下方式完成发送OMNeT ++内核。在INET中进行发送需要进行其他工作,具体取决于您尝试从哪个OSI层发送数据。例如,在应用程序层上,您必须打开套接字(请参见代码)并将其用于发送。 INET代码库的其余部分将处理将信息正确嵌入较低层数据包(UDP,IP,以太网)中的复杂性。

Generally, the TicToc tutorial is just a basic example to show how the sending is done by the OMNeT++ kernel. Sending in INET requires additional works depending from what OSI layer you are try to send the data. On application layer for example, you have to open sockets (see the code) and use that for the sending. The rest of the INET codebase will deal with the complexity of embedding that information correctly in lower layer packets (UDP, IP, Ethernet)

这篇关于如何使用自定义消息扩展不同的Inet模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆