Gate index 0 out of range when accessing vector gate `ethg$o[]' with size 0

870 views
Skip to first unread message

rport...@gmail.com

unread,
May 20, 2013, 2:32:28 PM5/20/13
to omn...@googlegroups.com
Hi

Can anyone help me please?

I'm trying to send a packet from the Application layer (which is a module) on an ethernet gate from one node to 2 other nodes, which are all connected together and to send the packet I am doing the following code:

               send(newpkA, "ethg$o",0);
               send(newpkB, "ethg$o",1);

But I get the error: Gate index 0 out of range when accessing vector gate `ethg$o[]' with size 0
How and where can I define the size of the vector ethg please to solve the problem?


I am declaring ethg in a .ned file:

module NODE
{
    parameters:
        @node();
        @labels(node,ethernet-node,wireless-node);
        @display("i=device/antennatower");
        string mobilityType = default("StationaryMobility"); // Node does not move
        int numRadios = default(1); // the number of radios
        wlan[*].mgmtType = default("Ieee80211MgmtAdhoc");

    gates:
        input radioIn @directIn;
        inout ethg[] @labels(EtherFrame-conn);

    submodules:
       ........
        wlan: Ieee80211Nic {
            parameters:
                @display("p=387,334;q=queue");
                //opMode = "p"; //IEEE 802.11p operation mode
        }


        eth[sizeof(ethg)]: <default("EthernetInterface")> like IWiredNic {
            parameters:
                @display("p=245,233,row;q=queue");
        }

        networkLayer: NetworkLayer {
            parameters:
                proxyARP = false;
                @display("p=387,233;q=queue");
            gates:
                ifIn[1];
                ifOut[1];
        }

     connections allowunconnected:

      ....
        wlan.upperLayerOut --> networkLayer.ifIn[0];
        wlan.upperLayerIn <-- networkLayer.ifOut[0];
       
        radioIn --> wlan.radioIn;

 
        for i=0..sizeof(ethg)-1 {
            ethg[i] <--> eth[i].phys;
            eth[i].upperLayerOut --> networkLayer.ifIn++;
            eth[i].upperLayerIn <-- networkLayer.ifOut++;
         
        }
       
}

---------------------------------------------------------------------------------------------------------------

And in the network .ned file, I declare the size of the ethernet like below:

......
        host1: NODE {
            @display("p=850,960;i=device/antennatower");
            gates:
                ethg[2];
        }

etc..

-----------------------------------------------------------------------------------------------------------------

Also in the application layer module I am declaring the gates in its .ned file by doing the below code:

    gates:
        input udpIn @labels(UDPControlInfo/up);
        output udpOut @labels(UDPControlInfo/down);
        inout ethg[] @labels(EtherFrame-conn);


Can anyone please tell me what I'm doing wrong and how I can solve this please?

Thanks in advance?
Message has been deleted

Muddasir Rahim

unread,
Nov 6, 2018, 10:20:32 AM11/6/18
to omn...@googlegroups.com
what is the error?


On Tuesday, November 6, 2018, 1:25:25 PM GMT+5, Junaid Mohammad <qurashi...@gmail.com> wrote:


I too am facing a similar error:

Gate index 1 out of range when accessing vector gate 'out[]' with size 1 -- in module (Hub) Net1.hub (id=2), at t=0.01s, event #2

Kindly Help.

I am trying to simulate the Traffic generator, sink and hub.

this is the Hub.cc module code:

#include<string.h>

#include<omnetpp.h>

using namespace omnetpp;


class Hub:public cSimpleModule


{

protected:

    virtual void initilize();

    virtual void handleMessage(cMessage *msg);

    virtual void finish();

};


Define_Module(Hub);


void Hub::initilize()

{}


void Hub::handleMessage(cMessage *msg)

{

    cGate *g = msg-> getArrivalGate();

    int i;

    for(i=0;i<g->size();i++);

            {

                if(i!=g->getIndex())

                    {

                        send(msg->dup(),"out",i);


                    }

            }


}


void Hub::finish()

{}


Hub.ned code:

simple Hub

{

    gates:

        input in[];

        output out[];

}


Kindly help

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

Virus-free. www.avast.com
Reply all
Reply to author
Forward
0 new messages