How to control the transmission power and speed based on the distance between two vehicles in Veins - omnet++

I am a beginner about Veins. Now I am trying to simulate dynamic adjustment of the transmission power and speed between 2 running vehicles based on their distance with each other with Veins 4.5, Omnet 5.0 and Sumo 0.29.
So far I have built the Sumo model and run the model in Omnet but without any programming which means the transmission power and speed between 2 vehicles are all set in the .ini file. Now I want to implement an algorithm to adjust them dynamically.
As a beginner I barely know how to start this job. The Veins tutorial didn't tell how to apply the functions provided by Veins. I now build a new .cc file based on our .ned file. And from MyVeinsApp.cc I found some methods I need to implement. But still I need some programming instructions about my problem.
1 how to get the realtime distance between 2 running vehicles?
2 is it possible to control the transmission power and speed with Veins 4.5?
I am sorry for these initial questions.But I really don't know how to develop a Veins simulation from the very beginning step by step at the programming level
Thank you very much!

To get the distance between two vehicles you can use the built-in function distance() from Coord (see this post).
To control the transmit power you can use the parameter txPower from Mac1609_4.
For changing the speed of the vehicle you can check this post.

Related

Setting weights for edges in SUMO using Omnet++

I am using Omnet++ 5.3, veins 4.7.1 and Sumo 0.32.0. I want to set weights to the edges in SUMO. Having done some reading, I realise that traci has a function called seteffort in the python version. I am unable to find a similar function to set weights in traci present in the veins version used for omnet++. Any help to achieve the task is appreciated. Thank you!
It is certainly possible to extend Veins by adding new methods to https://github.com/sommer/veins/blob/veins-5.0/src/veins/modules/mobility/traci/TraCICommandInterface.h following the code that is already there.
The specific method you mentioned, however, might not be a good idea: it is meant to change how every vehicle in the network perceives it. You might be more interested in changing how only a single vehicle chooses its route.

Omnet++- Energy consumption curves

I'm doing network simulation using Omnet ++ software and castalia. so i want to know how to plot power consumption, RSSI value curves
thanks in advance
This question's answer is dependent on what software you're using exactly. OMNeT++ provides a suite and toolchain for visualization, but as user Thanassis points out below, Catalia has its' own specialized evaluation tools.
For general OMNeT++ simulations
The OMNeT++ tutorial covers this in quite a lot of detail. Basically:
tell OMNeT++ what data you're recording (by editing the .ned files) using the #statistic annotation
modify the simulation to track the data you're interested in, either over simulation time (referred to as vectors) or per simulation (referred to as scalars), basically using emit().
make sure that your simulation (omnetpp.ini) is set up to collect the statistics (by setting e.g. histogram or vector as the type of collected data)
use either the graphical OMNeT++ interface or your own scripts to analyze the output of the simulation (which is, by default, stored in a folder called results wherever you're running the simulation, unless you change that in the omnetpp.ini)
Please also refer to these related questions:
How to collect traffic data and macroscopic statistics in Veins?
Calculating end-to-end delay for SimpleServerApp in Veins-LTE

Disable/remove the NIC module of some vehicle in Veins

Dear OMNeT++/SUMO/Veins community,
There is a correct way to disable/remove the NIC module for some vehicle in the Veins?
I have lot of vehicles in my scenario and I want set only one part them with communication module, for example 50 %. For this I created one method that set half the vehicles to start the sendBeacon and other method to drop the beacon/data for half (same half that no start sendBeacon) the vehicles. I already see this question.
I think there is a correct way to do this, because in my code all the vehicle have the communication module and just not use or ignore the package that arrived.
I'd appreciate any help.
If you want only a certain fraction of vehicles to participate in the network simulation, you can set the penetration rate parameter in https://github.com/sommer/veins/blob/veins-4.4/src/veins/modules/mobility/traci/TraCIScenarioManagerLaunchd.ned#L58 to a value smaller than one.
For example, if you set the penetration rate to 0.5 only half of the cars will take part in the network simulation (but still in the road traffic simulation), thus modeling a network where half of the cars are not equipped with VANET technology.

How can I write Traffic Light logic based on Induction Loop data in Omnet++?

I have a simple traffic light intersection in which I have already set the traffic light logic. Suppose the vehicle density is increasing in one road and I want to retrieve this data in Omnet and use the C++ logic to direct the traffic lights to change state. Is it possible to do this in Omnet++?
In short I am looking to control the traffic using the network information obtained by running SUMO and coupling through SUMO. Is it possible to control the traffic through Omnet++? If yes, then can you tell me an example of how to do so?
Veins already includes some TraCI commands to retrieve the state of a SUMO simulation, as well as to change traffic lights. SUMO includes many more TraCI commands which should be able to do what you describe. You would just need to implement them in Veins as well, building on what is already there.

Using a Traffic Light as a RSU in Omnet++, Veins and SUMO

I am doing a project on improving the transit times of buses using 802.11p. Currently I have a SUMO model made and simulating and I am moving on to modeling the network using Omnet++ and Veins. I have completed the TicToc tutorials to become familiar with Omnet++.
I am wondering how I could use the traffic lights in SUMO as Road Side Units in Omnet++. Would I need to write code in Veins to allow Omnet++ "see" the traffic lights as it does with vehicles?
Thanks in advance,
Ciaran
You are right: In order to model whether a transmission from a car to a certain "point" in the simulation is received, you will need to instantiate an OMNeT++ module (let's call it a Virtual Induction Loop, VIL) with an 802.11p radio at that position.
A design decision will be how to estimate where these VILs will need to be.
Naturally, VILs will need to be close to the lanes that are controlled by traffic lights. Each traffic light can control any number of intersections, so putting a VIL at the center of "the intersection" will likely not be possible. This means that, ideally, you would hand-pick the positions.
Alternatively, you can try to estimate a good position automatically. As of Veins 4a2, only rudimentary commands for traffic lights (such as to set a traffic light program) are implemented. SUMO, however, offers many more commands for reading traffic light information. If you implement the commands to enumerate which traffic lights exist, which lanes they control, and where those lanes are, you might be able to derive good position estimates for the VILs.

Resources