0

I use veins-4a2. First, I have executed a scnario with only vehicles. Now I have added RSU in my example. I need that every RSU receives data, displays a message in the module log of Omnet++. Like I did for nodes when they receives data, I have add the bold line in onData() function of the TraCIDemp11p like this:

void TraCIDemoRSU11p::onData(WaveShortMessage* wsm) {

    findHost()->getDisplayString().updateWith("r=16,green");

    annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), mobi->getCurrentPosition(), "blue"));

    **EV << " I am an RSU and I have received a data !  \n";**

    //if (!sentMessage) sendMessage(wsm->getWsmData());
}

My problem is that "I am an RSU and I have received a data ! " isn't displayed in the log module. When an RSU receives a data, this is what is displayed in the log module of omnet++:

** Event #4802  t=9.004337832007  RSUExampleScenario.node[4].nic.phy80211p (PhyLayer80211p, id=161), on `data' (Mac80211Pkt, id=669)
node[4]::PhyLayer80211p: AirFrame encapsulated, length: 1326
Fariha
  • 497
  • 1
  • 5
  • 13

2 Answers2

1

Make sure that is going in the onData function. You can use ASSERT or exit function for that.

Print the message with DBG, EV or cout

DBG << "Test_DBG: I am an RSU and I have received a data!\n";
EV << "Test_EV: I am an RSU and I have received a data!\n";
std::cout << "Test_cout: I am an RSU and I have received a data!\n"

After set on print message, use one code to terminate the simulation

// terminate the simulation with error code 3
   exit(3);

or use ASSERT

 ASSERT2(0,"Test: I'm RSU");

If the simulation terminate with error, you will have sure that the onData is executed, if not, the onData is not called in any part of your code.

-Sorry, I don't have reputation to add just one comment- Good luck!

  • Thank you for your response, I checked by adding ASSERT but my simulation continues to run. Howerver, I defined the call of the onData() function un my code. – Fariha Oct 10 '16 at 11:59
0

I don't know if you are aware of how onData works.

In the default veins, the onData is only called where one package with name data arrived in one car/node or RSU (through the handleLowerMsg).

In your case in a RSU, so are needed:

  1. The cars/nodes need the appl.sendData with true

  2. Calls for send packages with name data

  3. Range of communication with the cars/nodes and the RSU. The default is 1 km of diameter.

A good test is create a small grid with the randomTrips.py and set the RSU in center, where all nodes can achieve it.

-Big for one comment, so I make a new answer - Good luck!

  • Thank you for these informations. In my scenario, all of these are done: the onData() function of RSU and nodes are called through the handleLowerMsg in BaseWaveApplLayer. In the show message of omnet++, an rsu receives data from nodes: #4802 9.004337832007 node[4] --> rsu[4] data id=675 kind=22003 length=166 bytes So, my problem why the onData() of RSU is not executed when it receives data? – Fariha Oct 10 '16 at 15:50
  • Are you using the default veins or made some changes? – João Batista Oct 10 '16 at 17:26
  • I am based on the example of Veins-4a2 but I have changed the application layer of nodes and RSUs according to my scenario. And the application layers (TraCIDemo11p.h et TraCIDemoRSU11p.h) include: #include "veins/modules/application/ieee80211p/BaseWaveApplLayer.h" that containes handleLowerMsg() function that calls onData(). – Fariha Oct 11 '16 at 13:53
  • Probably you changed the Veins in some part and now there is no call for the onData. Put some come of your handleLowerMsg and other, and maybe a I can find where has "an error". Do you don't want to update the Veins to [Veins 4.4](https://github.com/sommer/veins/releases/tag/veins-4.4) (need SUMO 0.25.0)? You can see in the Tkenv some package data received for some node ([as o can see here](https://uploaddeimagens.com.br/imagens/snapshot7-png))? – João Batista Oct 11 '16 at 15:02
  • This is the code of handleLowerMsg() in BaseWaveApplLayerDTNRSU that I have changed its name: /** void BaseWaveApplLayerDTNRSU::handleLowerMsg(cMessage* msg) { WaveShortMessage* wsm = dynamic_cast(msg); ASSERT(wsm); EV <<" The type of the received message is: " << wsm->getName() << "'\n"; if (std::string(wsm->getName()) == "beacon") { onBeacon(wsm); } else if (std::string(wsm->getName()) == "data") { onData(wsm); } – Fariha Oct 12 '16 at 07:55
  • else if (std::string(wsm->getName()) == "ack") { onACK(wsm); } else { DBG << "unknown message (" << wsm->getName() << ") received\n"; } delete(msg); } **/ – Fariha Oct 12 '16 at 07:55
  • In TraCIDemoRSU I have: #include "veins/modules/application/ieee80211pDTNRSU/BaseWaveApplLayerDTNRSU.h" . The code of onData() of RSU is very simple, when it receives data I would that it displays a message, so I modified it like this: – Fariha Oct 12 '16 at 08:00
  • void TraCIDemoRSU::onData(WaveShortMessage* wsm) { findHost()->getDisplayString().updateWith("r=16,green"); annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), mobi->getCurrentPosition(), "blue")); – Fariha Oct 12 '16 at 08:00
  • EV << "Test_EV: I am an RSU and I have received a data!\n"; – Fariha Oct 12 '16 at 08:01
  • } When I executed the simulation, I noted that an RSU receives data from nodes ( as I have shown in previous reviews). So, normally when it receives data it should display the message (written in the function). – Fariha Oct 12 '16 at 08:05
  • I have tried now to execute the simulation from the beginning in order to know where the error comes. I have simulated the original version of Veins-4a2 which the onData() function of RSU works. Then I have only changed the erlangen map by my map (which I have generate its .rou, .net and .poly files from sumo-0.22.0 and it works well). So, I kept the application layer of veins-4a2 (TraCIDemo11p and TraCIDemoRSU11p) with the new map and I lanced the simulation. – Fariha Oct 12 '16 at 15:30
  • In fact, I have the same problem the application layer of the RSU is not executed (I have added exit(3) in onData() function of TraCIDemoRSU11p and the simulation not terminate with error. – Fariha Oct 12 '16 at 15:30
  • So, why if we change the default map, the application layer of RSU will not be executed? – Fariha Oct 12 '16 at 15:32
  • Your code probably is calling the "BaseWaveApplLaye‌​rDTNRSU.h" onData method, that do nothing, [like this one](https://github.com/sommer/veins/blob/master/src/veins/modules/application/ieee80211p/BaseWaveApplLayer.h#L75). You can add one handleLowerMsg in the TraCIDemoRSU11p or add some code in the onData from BaseWaveApplLaye‌​rDTNRSU.h, and make sure with one is called. With exit(1), like below, the simulation will terminate for sure, if the method is called. `std::cout << endl << "RSU received onData" << endl; exit(1);` – João Batista Oct 12 '16 at 18:28
  • In my scenario, I have created two other folders (which represent my application layers for nodes / RSU) that I named "dtnRSU" for nodes and "TraCIDemoRSU" for RSU. The two application layers call the "BaseWaveApplLayerDTNRSU" which replaces the default "BaseWaveApplLayer". In omnetpp.ini, I have specified: "*.rsu[*].applType = "TraCIDemoRSU"" and "*.node[*].applType = "dtnRSU"" – Fariha Oct 13 '16 at 07:48
  • As I explained as above, when a node/RSU receives data , it calls the "handleLowerMsg" in the "BaseWaveApplLayerDTNRSU.cc" in order to execute the onData() function which is declared in "dtnRSU" for nodes and "TraCIDemoRSU" for RSU. The problem that when a node receives data from another node, its onData is executed ( ** Event #4815 t=9.0044578726 RSUExampleScenario.node[2].appl (dtnRSU, id=146), on `data' (WaveShortMessage, id=694)) – Fariha Oct 13 '16 at 07:53
  • And when an RSU receives data from a node, its application layer is not executed. I have added "handleLowerMsg" in the "TraCIDemoRSU" but in vain. I spent a year working with veins in order to Implement an architecture DTN and really I need to add the RSU in my scenario. – Fariha Oct 13 '16 at 08:03
  • Hello, I got all the idea/code, but can't think where is some error for not call the onData. If you like, could post a link with all the code (in Dropbox, Github or any others). With all code, maybe I can help you. Good luck : )! – João Batista Oct 13 '16 at 12:01
  • Hello, thank you very much for your help :) This is the link to dwonload my code: www.transfernow.net/14iq50u2kw4y. You will see that the application layer of RSU is not called in the scenario however it is called from BaseWaveApplLayerDTNRSU. I am waiting your response :) – Fariha Oct 14 '16 at 10:51
  • Hello, I have looked your code and make some tests/changes ([as you can see here](https://github.com/ryuuzaki42/Veins-4a2_Fariha). I compared your veins-4a2 with the on released. You have made some change in "core" of Veins, that is not good idea ([here](https://github.com/ryuuzaki42/Veins-4a2_Fariha/commit/88c09ad2f66e87cf1be54e86903a00e8e74f8076) and [here](https://github.com/ryuuzaki42/Veins-4a2_Fariha/commit/88c09ad2f66e87cf1be54e86903a00e8e74f8076)) I think that is for your scenario (testqgis) works. But it is the scenario the problem (rou, net and poly file). – João Batista Oct 15 '16 at 09:23
  • You can test with the erlangen that will work. Try start with a small scenario or with the earlangen and after change for a "big scenario". You can create a small scenario with the [randomTrips.py](http://sumo.dlr.de/wiki/Tools/Trip#randomTrips.py). Good luck : ) – João Batista Oct 15 '16 at 09:26
  • Look all my changes, maybe can be help for you in some part. – João Batista Oct 15 '16 at 09:27
  • I tested the version that you have changed and it works with erlangen map. But the problem is the testqgis map. I do not understand what's the problem in the (testqgis.rou, testqgis.net and testqgis.poly) files that prevent the execution of the application layer of RSU. – Fariha Oct 17 '16 at 10:35
  • In fact, in my map, I have generated a scenario with the map of lyon, France which the cars ( in my case are bicycles) circulate from a bicycle station to another bicycle station. I have spent many times to do this in the previous months. So, I want to understand the problem of testqgis files to know if I can correct them to execute my simulation. – Fariha Oct 17 '16 at 10:35