2

I'm trying to implement RSU to RSU communication in Veins. To do that, I have added an inout gate into the RSU module (RSU.ned file):

module RSU
{
    parameters:
        string applType; //type of the application layer
        string nicType = default("Nic80211p"); // type of network interface card
    gates:
        input veinsradioIn; // gate for sendDirect
        inout gate[]; // add in out gates to ensure communication between RSUs        
    submodules:
        appl: <applType> like org.car2x.veins.base.modules.IBaseApplLayer {
            parameters:
                @display("p=60,50");
        }

        nic: <nicType> like org.car2x.veins.modules.nic.INic80211p {
            parameters:
                @display("p=60,166");
        }

        mobility: BaseMobility {
            parameters:
                @display("p=130,172;i=block/cogwheel");
        }

    connections allowunconnected:
        nic.upperLayerOut --> appl.lowerLayerIn;
        nic.upperLayerIn <-- appl.lowerLayerOut;
        nic.upperControlOut --> appl.lowerControlIn;
        nic.upperControlIn <-- appl.lowerControlOut;

        veinsradioIn --> nic.radioIn;
}

Also, in the RSUExampleScenario.ned file, I have added a second RSU and connect the two RSUs:

network RSUExampleScenario extends Scenario
{
    types:
        channel myChannel extends ned.DelayChannel {
            delay = 100ms;
        };

    submodules:
        rsu[2]: RSU {                @display("i=veins/sign/yellowdiamond;is=vs;p=150,140;b=10,10,oval;r=1000");
        }            
    connections allowunconnected:
        rsu[0].gate++ <--> myChannel <--> rsu[1].gate++;
}

In the TraciDemoRSU11p.cc file, I attempt to send a message like that:

int nb_gate = gateSize("gate");
int out_ = intuniform(0,nb_gate-1);    
cMessage *msg = dynamic_cast<cMessage*>(hmsg);
cMessage *copy = (cMessage *)msg->dup();
send(copy, "gate$o", out_);

While executing this code, I have the following error: No such gate or gate vector: 'gate' -- in module (TraCIDemoRSU11p) RSUExampleScenario.rsu[1].appl (id=16), at t=26.019453568907s, event #452

How can I deal with?

  • 2
    Your module "rsu" is a compound module which contains many submodules. One submodule is "appl". You are generating the message in " appl", but you only added a gate to "rsu". Thus, the error message is correct. Maybe you want to add another new gate to " appl" and connect this to the new gate of "rsu" – Christoph Sommer Apr 21 '19 at 09:11
  • Thanks M. Christoph Sommer for your response. Actually, I have added an Input gate in both RSU module and appl submodule for send direct. The idea is when executing the TraciDemoRSU11p, the module responsible for sending messages is *.rsu[*].appl. So I have to add a connection to send direct a message from the submodule appl to its parent RSU on the sender side. Thus, the receiving RSU can receive the message, send it directly to appl submodule to be treated. Is this correct? – Medani Khedidja Apr 22 '19 at 00:37
  • I don't exactly understand your follow-up comment. Are you saying your question was not answered? Do you have a second question? Or did you want to ask a different question instead? – Christoph Sommer Apr 22 '19 at 19:07
  • To confirm that what I did is correct, I want to know the exact process of how messages can be exchanged between two RSUs. Because with my actual code, there is no error, but also no messages are exchanged between RSUs. – Medani Khedidja Apr 22 '19 at 21:47
  • So in the RSU module (RSU.ned file), I have the inout gate; I have added the same gate to the submodule appl {gates: gate @directIn;}. Then, I have added this connection: gate appl.gate. In the RSUExampleScenario, I have connected the two RSUs as follows: rsu[0].g rsu[1].g; Now in the TraciDemoRSU11p.cc, I have used sendDirect to communicate the message to its parent (sendDirect(msg, getParentModule(), "gate$o");). I have added an RSU.cc file which contains the handleMessage method for sendDirect income. At this stage, I cannot observe any reception of message on RSU module. – Medani Khedidja Apr 22 '19 at 22:45
  • Also, when I call the handleMessage method in TraciDemoRSU11p.cc, I find that incoming messages from nodes are received on the RSU via this method and not via onWsm/onHello of veins. Also, there is no messages received from the other RSU? – Medani Khedidja Apr 22 '19 at 22:50
  • This sounds like a different question. The discussion here is for your question `While executing this code, I have the following error: No such gate or gate vector: 'gate' [...] How can I deal with?`. – Christoph Sommer Apr 23 '19 at 15:52
  • Problem solved. Thanks M. Christoph Sommer for the aid you provided. The solution is to add an input gate (@directIn) for the submodule appl, as you said, and call the sendDirect method to send messages. Also, the handleMessage method is called to receive these messages. – Medani Khedidja Apr 23 '19 at 23:39

0 Answers0