user3243499
user3243499

Reputation: 3151

When to use send, sendDirect and sendDelayed in OMNet++?

I am building my own compound module in omnet++ having multiple simple modules in it and having a layered architecture. But using only send() in inter-module communication (like the my App generator sends packet to below buffer using send()) seems to increase the total network latency.

Also, I have seen other well supported models like the inet, mixim etc. uses sendDirect and send and sendDelayed alternatively.

So, my question is, when to use send(), sendDirect() and sendDelayed() ? And do they have any latency differences ?

Upvotes: 3

Views: 2175

Answers (1)

Rudi
Rudi

Reputation: 6681

There are several ways to exchange information between modules. Which one you use depends really on what data you are passing and how much is that exchange related to the protocol itself.

First of all a clarification: Using send() or sendDirect() does NOT increase latency. If you send the message through a normal channel or use sendDirect() the message will be delivered to the destination module at the current simulation time (i.e. now). When the message is processed at the destination the simulation tine will be the same so there is no additional delay in simulation time. sendDelayed() obviously adds delay, but that is its main purpose anyway.

You have to decide whether you want to use message passing as the means of communication between modules (this is asynchronous) or you want to make direct calls into the other module (that is synchronous). In the first case, you can use OMNeT++'s scheduling functions (i.e. send, sendDelayed, sendDirect etc.). In the second case, you are usually calling directly into an other module by obtaining a pointer to it and probably casting it to its appropriate type using check_and_cast<>. Methods like getParentModule() and findSubmodule() are useful here to get a pointer to the desired module.

Direct calling is useful when the communication between the modules are deemed to 'implementation' detail. It is faster also (in terms of CPU usage) and synchronous (so you can get a return value).

If you pass along data that you want to inspect during the simulation using the GUI runtime-environment (i.e. you want to see the little dots flying around) then you should use message definitions and send()/sendDirect() etc.

Finally, the difference between send() and sendDirect(). If you have a topology where you connect the gates via channels (i.e. you now the communication path in advance) you usually use send() (e.g. a wired network). If you don't know the communication path in advance, then you are usually getting the pointer to the destination module, but after that you send an asynchronous message using sendDirect(). This is usually the case in wireless networks.

Upvotes: 7

Related Questions