Implementing Inet cars into Veins example simulation - omnet++

I've got the Veins example simulation up and running (on the preset Erlangen map), and also the Veins_Inet subproject functions as it should (a square track with 3 nodes and signal broadcasts between each upon accident). What I would like to do is to retain the initial Veins example simulation, but use the VeinsInetCar module as nodes such that instead of AirFrames being exchanges upon an accident, they exchange a signal broadcast as in the Veins_Inet example.
I thought it probably easiest to alter the Veins folder to make this happen, so I have allowed it import from other projects if referenced and added in the VeinsInetCar module and imported this instead of the Car module in all the relevant files. Moreover, I have added in the setup lines in the omnetpp.ini file to include the wlan implementations. I have included the RadioMedium in the Scenario module and included an integrated visualiser in the omnetpp.ini file. I run the simulation which doesn't complain, but the simulation looks exactly the same. How do I achieve what I want?

Related

Veins V2V only without RSU

Which of the Veins version uses vehicle to vehicle communication (car) only without RSU. The current veins uses RSU, any way to remove RSU and use V2V (CAR) only.
Many thanks
How to add and remove modules from a simulation is documented in the user manual and the topic of lesson one in the tic toc tutorial. From a quick look at the top level .ned file of the simulation you should also see the line where the RSU is instantiated. Simply delete this line.

Omnet++: Parallelize Single Run Simulation

I'm trying to parallelize my model (I want to parallelize a single config run, not run multiple configs in parallel).
I'm using Omnet++ 4.2.2, but probably the version doesn't matter.
I've read the Parallel Distributed Simulation chapter of the Omnet++ manual
and the principle seems very straightforward:
simply assign different modules/submodules to different partitions.
Following the provided cqn example
*.tandemQueue[0]**.partition-id = 0
*.tandemQueue[1]**.partition-id = 1
*.tandemQueue[2]**.partition-id = 2
If I try to simulate relatively simple models everything works fine I can partition the model at wish.
However, when I start to run simulation that use Standardhost module, or modules that are interconnected using ethernet links that doesn't work anymore.
If i take for example the Inet provided example WiredNetWithDHCP (inet/examples/dhcp/eth), as experiment, lets say I want to run hosts in a different partition than the switch
I therefore assign the switch to a partition and everything else to another:
**.switch**.partition-id = 1
**.partition-id = 0
The different partitions are separated by links, there is delay, and therefore it should be possible to partition this way.
When I run the model, using the graphic interface, I can see that the model is correctly partitioned however the connections are somehow wrong and i get the following error message:
during network initialization: the input/output datarates differ
clearly datarates don't differ (and running the model sequentially works perfectly), by checking the error message this exception is triggered also by link not connected. This is indeed what happen. It seems that the gates are not correctly linked.
Clearly I'm missing something in the Link connection mechanism, should I partition somewhere else?
Due to the simplicity of the paradigm I feel like being an idiot but I'm not able to solve this issue by myself
Just to give a feedback,
It seems that directly it cannot be done, not the full INET as it is can be parallelized in short because it uses global variables in some places.
in this particular case, mac addresses assignment are one of the issues (uses a global variable), hence eth interface cannot be parallelized.
for more details refer to this paper explaining why this is not possible:
Enabling Distributed Simulation of OMNeT++ INET Models:
For reference/possible solution refer to authors webpage from aachen university, where you can download a complete copy of omnet++ and INET that can be parallelized:
project overview and code

Run a second antenna on my car with Veins

In my default Veins scenario (the one in the example) I need a second antenna on my car. In Car.ned I entered the following code (doing copy and paste from connections block):
nic2.upperLayerOut --> appl2.lowerLayerIn;
nic2.upperLayerIn <-- appl2.lowerLayerOut;
nic2.upperControlOut --> appl2.lowerControlIn;
nic2.upperControlIn <-- appl2.lowerControlOut;
veinsradioIn2 --> nic2.radioIn;
Now I have two antennas on my node (and they work!). But how can I decide who sends and who receives? In this way I just changed the topology of the network, but I can't handle the communications! I need to reach this scenario: node->node (first antenna) and node->RSU (second antenna). I think I should work on TraCIDemo11p.cc and TraCIDemoRSU11p.cc, but the code is immense and I get lost too easily. The final target is to make sure that these two antennas work with different protocols, but at the moment I make do with the same protocol and with these two different channels I mentioned earlier.
It's a bit difficult to give a concise answer to your question, because it has multiple components, but here are some important things you should look at:
First off: right now, what you've done is specified a car with two network interfaces (nic and nic2) and two separate applications (appl and appl2). I think, by your description, that is not what you want. I would suggest that your first step is to create an application interface that has connections to two network interfaces. This means creating the corresponding .ned file. You can use ./veins/modules/application/traci/TraCIDemo11p.ned as an example. Make sure to define your application object appl (in Car.ned) as that .ned file and connect both of these in the way you described. You'll then have 8 channels from your application to the two network interfaces (I'd call them appl.nic1LayerIn, appl.nic1ControlIn, appl.nic2LayerIn and so on).
After that, you will want to write logic that decides whether a particular message should go to the one network interface, or to the other, and put that code in your application's source. To communicate with the different network interfaces you'll just use the respective channels. To see how this works you'll need to dig in the veins source code a little bit: the code interacting with the channels is not directly in the TraCIDemo11p source, but somewhere in a super class there-of (I think it is BaseWaveApplLayer, but I'm not 100% sure). You could either modify those files to work with multiple antennae, or create new source files -- I'm not sure which one is less code, though.
Another thing to remember is that you'll need to provide the corresponding settings in the omnetpp.ini too (*.**.nic2..., analogous to *.**.nic...). I'm not sure what veins will do with two antennae at the same position (it might lead to some weird effects), but I also don't remember where the antenna position is specified.

How do I take actions every step in Veins?

I am using Veins to implement a scenario in which I shall update a vehicle's route every time step characterized by the step selfmsg. In which module shall I find this behavior? I want to add some more functions to this module in the application layer by extending it. Is it possible to do that?
You can take advantage of the fact that SUMO updates the positions of all vehicles at exactly the same time. By extension, Veins (I am assuming you are using version 4a2) will update the OMNeT++ positions of all vehicles at exactly the same time. See the Veins tutorial demo application for how to execute code whenever the position changes. Indeed, this will make sure that all code is running within in a single OMNeT++ event, which seems to be what you want.

Transmission of vehicular status in Veins

I want to transmit a given car's vehicular data such as it's vType, instantaneous speed and position to a RSU in a scenario in Veins.
How can I obtain the data from SUMO and send it through MiXiM methods to an RSU node?
To achieve your goal you have to use the TraCIMobility component of Veins.
You can do that by first getting a pointer to that component in the initialize() method of your node
cModule *tmpMobility = getParentModule()->getSubmodule("veinsmobility");
mobility = dynamic_cast<Veins::TraCIMobility*>(tmpMobility);
ASSERT(mobility);
Once you have the mobility component you can query it for various data.
The type of data that it can provide can be found in TraCIMobility.h
For example in your case you could do:
mobility->getCurrentSpeed().length()); /* will provide velocity vector */
mobility->getAngleRad()); /* will provide angle of movement */
Then you can attach this data to your message and send it to the RSU of your choice.
If this exact solution does not work for you that could be due to me using a different Veins version than yours.
However you will certainly find what you need in TraCIDemo11p.cc or TraCIDemoRSU.cc of your Veins project.
Also, TraCICommandInterface is something you should have a look at.
In the official Veins website under the Documentation section it is said:
Application modules can use the TraCICommandInterface class and
related classes, conveniently accessible from TraCIMobility, to
interact with the running simulation. The following example shows how
to make a vehicle aware of slow traffic on a road called Second
Street, potentially causing it to change its route to avoid this road.
mobility = TraCIMobilityAccess().get(getParentModule());
traci = mobility->getCommandInterface();
traciVehicle = mobility->getVehicleCommandInterface();
traciVehicle->changeRoute("Second Street", 3600);
Some of the other vehicle related commands are setSpeed or setParking.
Similar methods are available for the whole simulation (e.g.,
addVehicle, addPolygon), roads (getMeanSpeed), individual lanes
(getShape), traffic lights (setProgram), polygons (setShape), points
of interest, junctions, routes, vehicle types, or the graphical user
interface.
How to use these modules is demonstrated in the source code of the
Veins tutorial example. Again, a list of all 80+ available methods can
be found in TraCICommandInterface.h or the autogenerated module
documentation.
A potentially related question/answer here: https://stackoverflow.com/a/29918148/4786271

Resources