简体   繁体   English

如何使用自定义消息扩展不同的Inet模块?

[英]How to extend different Modules of Inet with custom messages?

I have all the examples up and running for the INET (AODV) simulation. 我已经为INET(AODV)仿真准备了所有示例并正在运行。 My network comprises of number of AODV Router hosts. 我的网络由AODV路由器主机的数量组成。

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). 我的下一个任务是就每个主机的当前位置交换一些自定义消息(将在一定时间后通过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. 我发现的所有示例(通常)都是tictoc ,它要求我在.cc文件中构建simpleModule ,然后在.ned文件中使用该模块。 I want to use the AODVRouter module to exchange these messages (as it already has the implemented things that I need for the network). 我想使用AODVRouter模块交换这些消息(因为它已经具有网络所需的已实现功能)。

This is the example I used for exchanging messages with a cSimpleModule 是我用于与cSimpleModule交换消息的示例

I have tried this example (as described in INET project), but the problem here is that it is only extending cSimpleModule . 我已经尝试了这个示例(如INET项目中所述),但是这里的问题是它仅扩展了cSimpleModule Since I want to use AODVRouter module (from INET) as my sender and receiver, I can't use this example. 由于我想使用AODVRouter模块(来自INET)作为发送者和接收者,因此无法使用此示例。 So my question is, what is the other way to do it (ie sending and receiving messages through INET modules such as AODVRouter module). 所以我的问题是,还有什么其他方式可以做到这一点(即通过INET模块(例如AODVRouter模块)发送和接收消息)。

How you handle this problem depends on what those messages are, and how they are related to the AODV protocol. 您如何处理此问题取决于这些消息是什么,以及它们与AODV协议的关系。

  • 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 . 如果您尝试使用某些位置感知功能来扩展AODV协议,并且该位置将由路由协议本身使用,那么您显然应该查看AODVRouting 源代码 You can check there to see how the messages are sent/received. 您可以在此处查看如何发送/接收消息。

  • 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. 如果消息与AODV完全无关,并且您想实现某种应用程序级别的消息交换,则方法是创建一个“应用程序”模块并将其安装到路由器中。 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). 当然,您必须知道要使用TCP还是UDP发送数据(我猜UDP是因为它更适合于面向消息的数据交换)。 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 (ie the coordinates of the node). 那时,您应该实现类似UDPBasicApp的功能 ,并创建自己的PacketType,其中包含要传输的数据(即节点的坐标)。 Use that for starting. 使用它开始。

Generally, the TicToc tutorial is just a basic example to show how the sending is done by the OMNeT++ kernel. 通常,TicToc教程只是一个基本示例,用于说明OMNeT ++内核如何完成发送。 Sending in INET requires additional works depending from what OSI layer you are try to send the data. 在INET中进行发送需要进行其他工作,具体取决于您尝试从哪个OSI层发送数据。 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代码库的其余部分将处理将信息正确嵌入较低层数据包(UDP,IP,以太网)的复杂性

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

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