how can I get the Id for a rsu in veins? - omnet++

I have three rsu in my app. is there any id for rsu like car id for cars? if yes, how can I get rsu id in rsu initializer method? if not how can I distinguish between rsus?

If you the consider the demo scenario, it has one RSU integrated stored in an Array structure. However, you can have an arbitrary number of RSUs by increasing the number in the brackets.
Therefore, you can address every RSU individually by its module id *.rsu[<index>] (e.g. RSUExampleScenario.rsu[0]) which is also available in the code via getId(). OMNeT++ also provides other useful functions for getting the name of a module.
If this is identifier is not enough for you, at least in the Mac layer there is an additional id which you can use to distinguish nodes.
If this is not not enough, you would need to add your own identifier variable to the NED module.

Related

How to get Vehicle ID from SUMO in Veins

In my Veins simulation, I want to use SUMO vehicle ID as the ID of the vehicle (instead of using Veins module id). I tried different method but was not successful. I tried to obtain sumo id using mobility -> getExternalId() in DemoBaseApplLayer.cc file. Build was successful but it does not run. If i do, getParentModule->getId() - it works fine. But I need SUMO Id not module id for my work,
Is there a way to use SUMO vehicle Id as the id of the vehicle in Veins?
If you mean that the wireless node with node vector index 1 in OMNeT++ should correspond to a vehicle named vehicle_1 in SUMO this will not easily be possible. If all you want to do is inquire about which name SUMO uses to refer to a wireless node managed via TraCIMobility in OMNeT++ then its getExternalId method is exactly the right one to call. If using the method gives you a runtime error, please post the precise output and messages you are seeing, the precise software versions you are using, and the steps needed to reproduce your error on another machine.

How to get the position of a destination node?

I have been working on a position-based protocol using veins-inet and I want to get the position of the destination node.
In my code, I got the IP Address of the destination from the datagram.
const L3Address& destAddr = datagram->getDestinationAddress();
and I want to get the current position of this node.
I already checked the following question
How to get RSU coordinate from TraCIDem11p.cc?
But it seems that it refers to the node by using the node ID.
Is there a way to get the position of the node by referring to its IP Address?
I am using instant veins-4.7.1
A very simple solution would be to have each node publish its current L3Address and Coord to a lookup table whenever it moves. This lookup table could be located in a shared module or every node could have its own lookup table. Remember, you are writing C++ code, so even a simple singleton class with methods for getting/setting information is enough to coordinate this.
If, however, the process of "a node figures out where another node is" is something you would like to model (e.g., this should be a process that takes some time, can fail, causes load on the wireless channel, ...) you would first need to decide how this information would be transferred in real life, then model this using messages exchanged between nodes.

How can I perform unicast communication in Veins?

While looking for various information on Stackoverflow, I read that Veins 5.x and above support Unicast communication.
I understood that unicast communication is possible through populateWSM(). However, I don't understand which LAddress::L2Type rcvId should be in the ID value of the second parameter.
Should I pass the ID value obtained through
getParentModule() -> getIndex()
Or is it necessary to pass the ID value of the left node list when running the simulation? If it's the latter, how can I get the ID value?
The demo implementation of Veins 5.1 uses the OMNeT++ module ID. For more robustness, I would recommend querying the MAC layer. See, for example, https://github.com/sommer/veins/blob/veins-5.1/src/veins/modules/application/ieee80211p/DemoBaseApplLayer.cc#L83

Veins : multiple WSMs for different purpose

I want to send two WSMs, one on regular intervals to enable a vehicle (V1) receive the information about vehicle behind them (V2) from the vehicle (V3), which is behind V2.
The second WSM is only sent out in certain cases (as a warning message) and as soon as vehicles receive the warning WSM, I want them to change the lane.
Question is: how can I implement two WSM actions independent from each other? Can I at all use multiple WSMs for this purpose or shall I define a new message type for it?

How to enable SUMO TraCI using SimuLTE and Veins?

I am using SimuLTE and Veins simulating sending safety message via LTE. The content of the message depends on the real-time values of the traffic, e.g., mean speed. In order to get such values, I plan to use TraCICommandInterface supported by Veins. However, I could not find out how and where I can do this. To be specific, in Veins without SimuLTE, I know the vehicle node is a module of TraCIMobility, which has an application layer, where we can customize the functions for receiving/sending messages, such as wsm, and managed by TraCIScenarioManager. However in the simulation example provided by SimuLTE, the vehicle/node is a module of VeinInetMobility, which is managed by VeinInetManager. Neither of them are using TraCICommandInterface or TraCIMobility. Besides, the lte applications are not using the same layer as BaseWaveApplLayer, where we can take some action as soon as the vehicle/node updates the position. Can anyone help explain how I could possibly implement the following using SimuLTE and Veins:
In order to monitor the vehicle/node values using TraCI, which class should I modify to use TraCI? VeinsInetMobility, VeinsInetManager or else?
How can I take action in the application only when there is a position update to the vehicle/node?
What is the essential difference between VeinsInetMobility and TraCIMobility? Can I use the latter for LTE scenario?
In Veins 4.6, a TraCIMobility module is used to update the Veins channel models every time a node's position changes. Quite similarly, in Veins_INET of Veins 4.6, a VeinsInetMobility module is used to update the INET Framework channel models every time a node's position changes. Because SimuLTE uses INET Framework channel models, this is the class that must be used here (otherwise the INET channel models would not know, e.g, whether two nodes are too far away to communicate).
If you want to take action every time a SUMO time step has completed, you can just add this to the executeOneTimestep method of TraCIScenarioManager.
Note that if you ever want to interact with the SUMO vehicle via the VeinsInetMobility module (e.g., changing a vehicle's route) a few changes will be necessary: Veins_INET of Veins 4.6 does not track a node's external id (the ID that SUMO uses to refer to the corresponding vehicle), so this would need to be added to VeinsInetMobility (line 54) along with code to use it, similar to TraCIMobility (line 127).

Resources