1

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

Ravneet_Kaur
  • 33
  • 1
  • 8
  • Could you please give some more background information on what you are trying to model? Your question reads like you want *any* transmission spanning no more than 300m to succeed for vehicles (and *no* transmission spanning more than 300m), but I am not entirely sure. – Christoph Sommer Sep 22 '19 at 08:47
  • Thank you for the reply. I am working on highway model and placing RSU 1000m apart. I want V2V and V2I communication. RSU acts as a backbone for communication and can be used to initiate the communication. When the vehicle is in range of RSU it will communicate to RSU and the vehicle to RSU communication be used for selecting the cluster head and V2V commuication can be used for selecting the cluster members. This is the main project I am working on. – Ravneet_Kaur Sep 23 '19 at 02:18

3 Answers3

1

It looks like you are going to set two transmission ranges depending on the kind of the node (RSU or Car module).

Maybe there is a "sophisticated" way to do that by defining two parameters (namely: maxInterfDistNodes and maxInterfDist for Cars and RSUs respectively) but I may think on doing this on the initialize() part, i.e., doing the following:

  • Instantiating the mac module in both the RSU and Car scenario files (traci folder files).
  • In the first stage (=0), try to adjust the txPower differently (according to the file, if it is for an RSU or a Car).
  • Do not forget to set the upper bound of transmission in the connectionmanager module in the .ini file (since the RSU transmission range is the max, you should set it to the connectionmanager as well)
  • Even if you see that vehicles are transmitting more than what you defined in their initialize() function, it is not a problem as in fact, packets are not received by modules that are far with more than what you have defined (more than 300m), it is just graphical.

If there is a misunderstanding, let us know.

Best regards,

MB_7
  • 103
  • 6
  • 1
    Thank you for the response. I will try to do it and will share then. – Ravneet_Kaur Sep 23 '19 at 02:22
  • You are welcome, that was great as you could solve it, I pasted as well some of the tips, I hope that you will get inspired by them. – MB_7 Sep 24 '19 at 00:14
1

As per the Suggestion, this may be the right answer. Please have a look.

PhysicalControlMsg_m.h

class VEINS_API PhyControlMessage : public ::omnetpp::cMessage
{
protected:
double txPowerNodes_mW; //added
public:
virtual double getTxPowerNodes_mW() const;  //added
virtual void setTxPowerNodes_mW(double txPowerNodes_mW); //added
};

PhysicalControlMsg_m.cc

//added
double PhyControlMessage::getTxPowerNodes_mW() const
{
    return this->txPowerNodes_mW;
}
//added
void PhyControlMessage::setTxPowerNodes_mW(double txPowerNodes_mW)
{
    this->txPowerNodes_mW = txPowerNodes_mW;
}

Mac1609_4.h

void setTxPowerNodes(double txPowerNodes_mW); //added
double txPowerNodes;

Mac1609_4.cc

void Mac1609_4::initialize(int stage)
{
    BaseMacLayer::initialize(stage);
    if (stage == 0) {

        phy11p = FindModule<Mac80211pToPhy11pInterface*>::findSubModule(getParentModule());
        ASSERT(phy11p);

        // this is required to circumvent double precision issues with constants from CONST80211p.h
        ASSERT(simTime().getScaleExp() == -12);

        txPower = par("txPower").doubleValue();
        txPowerNodes = par("txPowerNodes").doubleValue(); //added

}
void Mac1609_4::handleSelfMsg(cMessage* msg)
{
  if (controlInfo) {
            // if MCS is not specified, just use the default one
            MCS explicitMcs = static_cast<MCS>(controlInfo->getMcs());
            if (explicitMcs != MCS::undefined) {
                usedMcs = explicitMcs;
            }
            // apply the same principle to tx power
            txPower_mW = controlInfo->getTxPower_mW();
            if (txPower_mW < 0) {
                txPower_mW = txPower;
            }  

   // apply the same principle to tx power nodes
        //added
                txPowerNodes_mW = controlInfo->getTxPowerNodes_mW();
                if (txPowerNodes_mW < 0) {
                    txPowerNodes_mW = txPowerNodes;
                }

            }
            else {
                txPowerNodes_mW = txPowerNodes;
                txPower_mW = txPower;
            }
}

Mac1609_4.ned

//tx power Nodes [mW]
        double txPowerNodes @unit(mW); //added

ConnectionManager.cc

double ConnectionManager::calcInterfDist()
{
    if (hasPar("maxInterfDist")) {
        double interfDistance = par("maxInterfDist").doubleValue();
        EV_INFO << "max interference distance:" << interfDistance << endl;
        return interfDistance;
    }
    if (hasPar("maxInterfDistNodes")){
        double interfDistanceNodes = par("maxInterfDistNodes").doubleValue();
                EV_INFO << "max interference distance between  Nodes:" << interfDistanceNodes << endl;
                return interfDistanceNodes;

    }
    else {
        throw cRuntimeError("ConnectionManager: No value for maximum interference distance (maxInterfDist) provided.");
    }
}  

omnet.ini

*.connectionManager.sendDirect = true
*.connectionManager.maxInterfDist = 1000m
*.connectionManager.maxInterfDistNodes = 300m
*.connectionManager.drawMaxIntfDist = false

*.**.nic.mac1609_4.useServiceChannel = false
*.**.nic.mac1609_4.txPower = 20mW
*.**.nic.mac1609_4.txPowerNodes = 15.5mW #added

It is working for my case. I think it is the right way to do this. Thank You for the great guidance. It really means alot.

Ravneet_Kaur
  • 33
  • 1
  • 8
0

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 :)

MB_7
  • 103
  • 6
  • Thnak You for the suggestion. But U see in traceDemoRSU11p.cc file doestnot contain if(stage==0) method. if you will have time pleas look into the latest version and guide me. Many thanks – Ravneet_Kaur Sep 24 '19 at 06:17
  • You are right, the traceDemoRSU11p.cc does not contain such a method. In that case, how about defining the txPower to be that of the max (which is the RSU) in the main *.ini* file then, in the *if(stage==0)* of the *TraCIDemo11p.cc* you add the instruction of changing the txPower? this would work as only the cars will have less txPower (compared to the original one). Best regards, – MB_7 Sep 24 '19 at 15:13
  • 1
    I LL try to do. Thank you – Ravneet_Kaur Sep 27 '19 at 02:18
  • Hi sorry for late reply. I followed your guidance but mac->setTxpower(10); is showing error that it is not defined in DemoBaseApplLayerToMac1609_4Interface. but their only virtual functions are written. Can you please give directions how to deal with this? – Ravneet_Kaur Nov 07 '19 at 03:51
  • Hi again. As I use the 4.7 version, I did not face that problem. I tried to compare the 5a2 version (not 5.1) and there was indeed few different things. I do not know if this will give you an idea about the problem; find in the link below the same folder of the mac module: https://mega.nz/#!KdFFHQpa!mU0Rv81SdKs14K4FfWfQb_cPx80YUGwGBo-nfnirCxE I hope you can figure out what is wrong. – MB_7 Nov 08 '19 at 16:42
  • 1
    Thank you for the help. I did it. the only difference I need to define Mac= findModule::findSubModule(getparentModule); in demoBaseApplLayer.cc. It is working. Big Thanks!! – Ravneet_Kaur Nov 11 '19 at 07:17
  • @MB_7 I would like to know what is the default transmission power of the RSU and the Vehicle – ksa Mar 26 '20 at 19:11