问题
I have all the examples up and running for the INET (AODV) simulation. My network comprises of number of AODV Router hosts.
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).
This is the example I used for exchanging messages with a cSimpleModule
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).
回答1:
How you handle this problem depends on what those messages are, and how they are related to the AODV protocol.
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.
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.
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)
来源:https://stackoverflow.com/questions/31711291/how-to-extend-different-modules-of-inet-with-custom-messages