riebl / artery

OMNeT++ V2X simulation framework for ETSI ITS-G5
GNU General Public License v2.0
204 stars 132 forks source link

Information exchanging between modules and Number of entries in Location table #303

Closed HuyTyskland closed 1 year ago

HuyTyskland commented 1 year ago

Dear @riebl and everyone,

Currently I am working with Artery and Vanetza and I have two questions:

Kind regards, Huy Nguyen.

fysch commented 1 year ago

how can I retrieve the number of entries (corresponding to the estimated number of neighbouring of an ITS)?

You can get an iterator over all neighbours by calling LocationTable::neighbours(). std::distance(neighbours.begin(), neighbours.end()) should then give you the number of neighbours. However, if efficiency is important, it might be better to implement a new counter.

With the Vanetza module, how can I make the dcc sub-module and router sub-module to exchange information.

If you want communication between modules in Artery, the easiest way might be using omnetpp signals. The dcc submodule can then subscribe to the signal and the router can emit signals. There are plenty of examples in Artery, where you can get inspired.

HuyTyskland commented 1 year ago

hello @fysch , thank you for your reply. Indeed there are examples about emitting signals and subscribing signals in Artery as I am reading those.

However, I am a bit confused about the process so would you mind correcting me on this:

HuyTyskland commented 1 year ago

Also, do I need to add anything to connections in Vanetza.ned files or anything similar to establish connection between dcc submodule and router submodule?

fysch commented 1 year ago

Am I right?

Yes, that seems correct.

Also, do I need to add anything to connections in Vanetza.ned files or anything similar to establish connection between dcc submodule and router submodule?

Afaik: no. Your sender-class just needs to inherit from omnetpp::cComponent and the receiver-class from omnetpp::cIListener. And in the .ned file of the sender-class you need to declare the signal by using @signal.

A more detailed explanation is also available in the Simulation Manual (chapter 4.14.2)

HuyTyskland commented 1 year ago

Ah I understand. Thank you very much

HuyTyskland commented 1 year ago

Hello @fysch , sorry for bothering you again.

the LocationTable::neighbours().std::distance(neighbours.begin(), neighbours.end()) seems like it does not work. The error when I used it is std::distance is not a class member and when I put using namespace std before the line, the error is that the range (of neighbour) has no member distance. I did some research on how to get the number of elements in a boost range but I haven't been able to find anything yet.

Would you mind helping me at this?

fysch commented 1 year ago

Assuming you are in src/artery/networking/Router.cc:

auto neighbours = getLocationTable().neighbours();
auto numNeighbours = std::distance(neighbours.begin(), neighbours.end());

If you are somewhere else, you need to find a way to get access to the LocationTable.

HuyTyskland commented 1 year ago

Hello @fysch , your suggestion works so thank you for that.

On the listener's side, there is an issue. So the class I am working right now is LimericDccEntity class inherited from DccEntityBase class inherited from omnetpp::cListener class. In the DccEntityBase class, the function receiveSignal() is defined. However that is not what I want. That is why I defined another receiveSignal() in LimericDccEntity. And I think that leads to my problem.

Problem: before declaring receiveSignal() in LimericDccEntity.h and defining it in LimericDccEntity.c and after subscribing the signal I want in LimericDccEntity, I have a signal called avgCBR and it is displayed as a vector. However, right after I declared and defined receiveSignal(), that caused avgCBR to disappear.

What might be the cause of this issue and do you have any suggestion on this? Is it an inheritance error or Artery does not allow me to do that?

HuyTyskland commented 1 year ago

I can solve it now. I misunderstood the subscribe() and that was why I could not receive anything.

No worries and thank you. I shall close this issue