Search code examples
omnet++veins

How to fix the transmission range of RSU (1000m) and Vehicles(300m) in Veins-5.0?


From the already existing stack overflow discussion, I knew transmission range is related to power, noise, and sensitivity in the old version of veins.

Change the transmission signal strength for a specific set of vehicles during the run-time

My Question is In the latest version of Veins 5.1, the global transmission range is considered for both RSU and Veins. How can I make it specific? Like I want to specify the range of RSU to 1000m for txPower1 =20mW and

Vehicles to 300m for txPower2 =15.5mW

*.connectionManager.maxInterfDist = 1000m \added for RSU *.connectionManager.maxInterfDistNodes = 300m \added for vehicles

Checked the maxInterfDist in connection manger.cc. By default maximum range is considered for maxInterfDist for both RSU and vehicles.

Also in BaseConnectionManger.cc file, maxInterfDist is used.

Do I need to add another method for vehicles which return the distance (maxInterDistfNodes) and hence used another parameter in Omnet.ini file to define the power and sensitivity? If so please guide me where to make changes and how?

.omnet.ini

*.connectionManager.maxInterfDist = 1000m
*.connectionManager.maxInterfDistNodes = 300m
*.**.nic.mac1609_4.txPower = 20mW

BaseConnection Manager.cc

'''BaseConnectionManager::isInRange(BaseConnectionManager::NicEntries::mapped_type pFromNic, BaseConnectionManager::NicEntries::mapped_type pToNic)
{
    double dDistance = 0.0;

    if(useTorus) 
    {
        dDistance = sqrTorusDist(pFromNic->pos, pToNic->pos, *playgroundSize);
    } 
    else 
    {
        dDistance = pFromNic->pos.sqrdist(pToNic->pos);
    }
    return (dDistance <= maxDistSquared);
}'''

connectionManager.cc

'''double ConnectionManager::calcInterfDist()
{
    if (hasPar("maxInterfDist")) 
    {
        double interfDistance = par("maxInterfDist").doubleValue();
        ccEV << "max interference distance:" << interfDistance << endl;
        return interfDistance;
    } 
   else
   {
        throw cRuntimeError("ConnectionManager: No value for maximum 
        interference distance (maxInterfDist) provided.");
   }
}'''

I made additions as per given in the above link but it shows the error that mac could not be defined like this.

May be my questions seems to be silly, but I need guidance. Please help.

Many Thanks


Solution

  • Congratulations on your editing, you are getting used to use the fundamentals of veins&omnet++. It is sad that I can not test it right now as I am setting the simulations in my other operating system but I can discuss and give few remarks basing on my modest experience:

    • I see that you are using one transmission range for all the communications right? (i.e., 1000m for RSU and 300m for cars) if it is the case then the task will be easier as you need to define the transmission power once per module(node/rsu) creation (I will give the emplacement below).
    • You are using the get and set methods correctly but I feel that you can work on just the conventional (the already deployed) txPower_mW field. You can latter (and depending on the type of the module=RSU/Car) set that txPower_mW only one time during the initialization.
    • As you know, we may sometimes be tricked by the simulation, even if everything is looking like working correctly but there may be some technical errors (as for the match between the used tx_power and what really means in term of coverage, some tests by varying the distances between nodes is needed as well (20mW and 155mW is an example).
    • I do not know why but I feel that it is not so wise to modify the connectionmanager module. Also, from the point of view of that module's working principle, you can only have one interfDistance that is: used to calculate the chance of receiving the packet because the connectionmanager module does not difference between the transmissions basing on the sender's type, thus evaluating them equally. (and still respecting the tx_power of each node)

    I would suggest the following: (they may contain errors as they are not tested)

    • Find the corresponding mac1609_4 of each node (RSU/Car). I do not know what file you are using but equivalently to (TraCITestApp.cc+h) for Cars and (TraCIDemoRSU11p.cc+h) for RSUs. This is, of course, done by adding this into the initialize() of the appropriate file:

    1- in ".h" of the Car+RSU files:

    #include "veins/base/utils/FindModule.h"//added
    #include "veins/modules/mac/ieee80211p/Mac1609_4.h"//added
    

    and

            Mac1609_4* mac;//added
    

    2- in ".cc" of the Car+RSU files, in their "initialize()", more precisely in their "if(stage==0)" add:

        mac = FindModule<Mac1609_4*>::findSubModule(getParentModule());//added
    

    3- you just now have to add, after the step "2-" instruction, the following:

        mac->setTxPower(/*what corresponds the needed transmission power for the node type*/);
    

    And I still recommend to let the other files non-altered as it is a good-habit in codding especially with new languages/platforms/etc. (at least for me as I do not consider my self old enough with veins). Thus: you may return the connectionmanager to its initial state (you can make a back-up to your whole src folder before proceeding as it was working)

    Once again: my long writing text is just to give you my ideas and some tips that worked with me (with just few modifications to the goal) we are always enhancing our abilities with experience as you perfectly did with solving that issue with your code above.

    All the best luck :)