omnet++ retrieve network topology from code - omnet++

I'm very new to OMNeT++ and I'm writing my first simulation with it. What I'm trying to do is to retrieve the complete topology of the network at execution time from a node.
Basically, I have a router node that needs to know the entire topology (which node is connect to who) but I don't want to statically change the C++ code according to the Network selected. Instead, the idea is that the router is able in its initialization function to discover all the connections between nodes.
How can I do that?
Thanks in advance.

What you need is the omnetpp::cTopology class from the OMNeT++ API: https://omnetpp.org/doc/omnetpp/api/classomnetpp_1_1cTopology.html
If you are using INET, there is a slightly enhanced version of this class in inet::common::Topology

Related

Omnetpp wirelesshost sending useful information

I am new to Omnetpp, and I am trying to send messages from one node to another wirelessly.
Basically, I would like to do something as in the tictoc example of Omnetpp (https://docs.omnetpp.org/tutorials/tictoc/) but then wirelessly.
I have installed INET already, and I have seen the wireless example, which uses the UdpBasicAPP. However, I do not know how to change the data of the message send while using the UdPBasicAPP. In my case, what I am sending (i.e. the data) is very important because it is part of a bigger project. Eventually, the idea is to use the 802.11p standard (which exists in VEINS) and multiple nodes, but I thought this was a good place to start.
I hope someone can help me out.
Kind regards
just to be aware: 802.11p is also supported directly in INET. Just set the opMode parameter on the network interface.
You will need to create your own application module. Take a look/copy UdpBasicApp and modify it according to your needs. Check the sendPacket() function which creates an ApplicationPacket. ApplicationPacket contains only a single sequence number, but you can create your own application level data structure and use that for sending.

Is there a way to connect multiple TraCI modules to the OMNet++/veins simulation?

To launch any veins simulation veins_launchd daemon is used. It basically takes the sumo config file, finds an unused port, starts sumo and bridges the connection between sumo and OMNet++. Now as this is a socket-based communication, I want to connect a separate TraCI script(written in python) and hopefully retrieve the simulation data and maybe control some vehicles through it.
Is there anything that I'm missing here?
From what I understand it is possible to connect with multiple clients(as done in the Sumo-TraCI connection), but I'm not sure how to proceed here. I believe modifying the veins_launchd daemon can be a solution. It'll be very helpful if anyone working on this can give some insights.
You are correct: Veins 5.1 contains veins_launchd, a convenience script that launches one SUMO instance for every client that connects to it.
You are also correct that this is not what you want to use if multiple clients are supposed to connect to a single SUMO instance (veins_launchd would spawn two instances of SUMO for the two clients connecting to it).
One possible way forward would be to modify veins_launchd to accept two clients for every SUMO instance.
Another would be to use Veins 5.1 without veins_launchd, by basing your simulations not on TraCIScenarioManagerLaunchd but on TraCIScenarioManager. This module connects directly to SUMO, so you have full control of when and how to launch SUMO -- but, of course, before running a simulation you will have to launch SUMO yourself.

How to connect RSUs to Controller node via cable in omnet++ Veins?

I am trying to connect two (or more, in the future) RSUs (one is not in the transmission radius of the other) in the Controller node that will receive the information from the RSUs and build global knowledge of the scenario.
I've tried to approach as in the links LINK1 and LINK2, and I was unsuccessful.
Is there a similar example?
PS: I am using Omnet++ 5.3, Veins 4.7.1, and Sumo 0.32.0.
Depending on how much focus you want to put on simulating the wired network, it might make sense to write your simulation as an INET simulation first and then use Veins (with its veins_inet submodule) to make nodes behave like vehicles.

Omnet++ How to connect up a network in my application

I am trying to build a simple simulation using omnet++. I'd like to avoid using things like ned. Instead I want to allocate the modules set up the simulation topology entirely under program control. (i.e. I'll configure my simulation and set up connections etc. in main() instead of using ned)
How do I go about doing this ? (any examples you can point me to?)
thanks
Create a top level network in NED and drop a single simple module called builder or something like that. Then create/connect the necessary modules in that module's initialize method (or schedule a message at t=0s and do the network buildup there).
There is an example in OMNeT++ that does exactly like this, in samples/routing. Choose the NetBuilder configuration. That example is reading the network topology from an external file, but you can change it to create any topology you would like to have.
The actual code for the network generation is in samples/routing/builder/netbuilder.cc in NetBuilder::buildNetwork

omnet++/veins : how to register interface entry for nic 80211p

while trying to connect veins and inet, I've noticed my cars don't register
the nic80211p interfaceEntry in the InterfaceTable.
Indeed, the interfacetable contains only loopback l0 for every node.
In the omnet/inet manual it is written :
"Interfaces are registered dynamically in the initialization phase by modules that represent
network interface cards (NICs). The INET Framework makes use of the multi-stage initialization feature of OMNeT++, and interface registration takes place in the first stage (i.e. stage
INITSTAGE_LINK_LAYER
)."
So if I understand the registration shoud be done in Nic80211p.ned and specifically in Mac1609_4::initialize()?
What do you think?
Thanks for any help.
Regards,
Since this question was asked, the Veins repository on Github was amended to include a sample subproject (veins_inet) that runs an INET Framework (INET 3.4.0) simulation using Veins for nodes' mobility.
You can see the necessary code (and, after clicking on Browse Files, you can download a .zip archive of the complete project) on https://github.com/sommer/veins/commit/90d4586e

Resources