Closed HuyTyskland closed 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 androuter
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.
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:
Router
submodule. I can do the signal registration and signal emitting from A.cc and A.ned. dcc
submodule. With the emitting I describe, I will need to subscribe to CountSignal in the initialize()
, and then I will write a function called receiveSignal()
. Am I right?
If so, I have a question about the set of inputs for receiveSignal()
:
cComponent*
simsignal_t signal
int
of the Count variable):int countValue
Let say, I want to assign another variable, ReceivedCount, declared in B.h with Count. I can just do
ReceivedCount = countValue`. Am I right?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?
Am I right?
Yes, that seems correct.
Also, do I need to add anything to
connections
inVanetza.ned
files or anything similar to establish connection betweendcc
submodule androuter
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)
Ah I understand. Thank you very much
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?
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.
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?
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
Dear @riebl and everyone,
Currently I am working with Artery and Vanetza and I have two questions:
I am doing some reading about the location table in GeoNet and I am curious how can I retrieve the number of entries (corresponding to the estimated number of neighbouring of an ITS)? I looked at the location table class and the SoftStateMap class and haven't figured out which function/variable I can use. I can add a counter to the location table class but I want to make sure not reinventing the wheel.
With the Vanetza module, how can I make the
dcc
sub-module androuter
sub-module to exchange information. To be specific, I want to periodically send the number of entries from the first question fromrouter
sub-module todcc
submodules.Kind regards, Huy Nguyen.