Boadcast using modulepath protocol

89 views
Skip to first unread message

Maurício Bertanha

unread,
May 5, 2016, 10:09:18 PM5/5/16
to OMNeT++ Users
Hello everyone!

I am trying to broadcast a message in my application, I've seen that for IPv4 there is IPv4Address::ALLONES_ADDRESS that I can use as destination address, this constant is in the file IPv4Address.cc, I am trying to do the same think, but using ModulePathAddress.cc and there is no constant like this.

In other words, i am trying to do this:

controlInfo->setDestinationAddress(IPv4Address::ALLONES_ADDRESS);

But using modulepath, does anyone know how to do it?

Thanks.

Alfonso Ariza Quintana

unread,
May 6, 2016, 1:37:43 PM5/6/16
to omn...@googlegroups.com

It is a bit confusing your request, I suppose that you want that an application module using UDP could broadcast packets

The broadcast mechanism is a limited broadcast, the packet is sent in a particular interface,  it is necessary also to include the interface in which you want to send the packet.

--
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.

Maurício Bertanha

unread,
May 6, 2016, 9:34:06 PM5/6/16
to OMNeT++ Users
I will try to make myself clear.

I have an Ieee802.15.4 network and I am using the inet framework. In my ini file I have declared the destination address of my hosts:

**.host[*].packetControl.destAddresses = "sink(modulepath)"

In the PacketControl.cc, I have the follow code:

destAddresses.clear();
const char *destAddrs = par("destAddresses");
cStringTokenizer tokenizer(destAddrs);

const char *token;
while ((token = tokenizer.nextToken()) != nullptr) {
    L3Address result;
    L3AddressResolver().tryResolve(token, result);
    if (result.isUnspecified())
        EV_ERROR << "cannot resolve destination address: " << token << endl;
    else
        destAddresses.push_back(result);
}

And to send a packet I use the following code:

L3Address PacketControl::chooseDestAddr()
{
    int k = intrand(destAddresses.size());
    return destAddresses[k];
}

void PacketControl::send(cPacket *packet) {
    L3Address destAddr = chooseDestAddr();
    IL3AddressType *addressType = destAddr.getAddressType();
    INetworkProtocolControlInfo *controlInfo = addressType->createNetworkProtocolControlInfo();
    controlInfo->setDestinationAddress(destAddr);
    controlInfo->setTransportProtocol(protocol);

    packet->setControlInfo(check_and_cast<cObject *>(controlInfo));

    EV_INFO << "Sending packet: ";
    printPacket(packet);
    emit(sentPkSignal, packet);
    cSimpleModule::send(packet, "ipOut");
    numSent++;
}

This code works fine to send the packet to my sink, however now I want to broadcast a packet to all neighbors, I tried the following code:

void PacketControl::send(cPacket *packet) {
    L3Address destAddr = chooseDestAddr();
    IL3AddressType *addressType = destAddr.getAddressType();
    INetworkProtocolControlInfo *controlInfo = addressType->createNetworkProtocolControlInfo();
    controlInfo->setDestinationAddress(addressType->getBroadcastAddress());

    controlInfo->setTransportProtocol(protocol);

    packet->setControlInfo(check_and_cast<cObject *>(controlInfo));

    EV_INFO << "Sending packet: ";
    printPacket(packet);
    emit(sentPkSignal, packet);
    cSimpleModule::send(packet, "ipOut");
    numSent++;
}

But no packet is send when I run the simulation, I also tried with IPv4Address:

void PacketControl::send(cPacket *packet) {
    L3Address destAddr = IPv4Address::ALLONES_ADDRESS;
    IL3AddressType *addressType = destAddr.getAddressType();
    INetworkProtocolControlInfo *controlInfo = addressType->createNetworkProtocolControlInfo();
    controlInfo->setDestinationAddress(destAddr);
    controlInfo->setTransportProtocol(protocol);

    packet->setControlInfo(check_and_cast<cObject *>(controlInfo));

    EV_INFO << "Sending packet: ";
    printPacket(packet);
    emit(sentPkSignal, packet);
    cSimpleModule::send(packet, "ipOut");
    numSent++;
}

But I get the following error:

---------------------------
Confirm
---------------------------
Error in module (inet::GenericNetworkProtocol) IEEE802154Network.sink.networkLayer.gnp (id=15) at event #13, t=0: check_and_cast(): cannot cast (inet::IPv4ControlInfo *) to type 'inet::GenericNetworkProtocolControlInfo *'.
---------------------------
OK   
---------------------------

So instead of the IPv4Address, I would like to use the ModulePathAddress which is the one that I am using when sending packets to the sink.

This is my problem, do you know how can I broadcast the packet?

Thank you.

Maurício Bertanha

unread,
May 6, 2016, 10:38:17 PM5/6/16
to OMNeT++ Users
I am using this project as example:


If you check the ini file, there is the destAddress, how do I change it to broadcast?


On Thursday, May 5, 2016 at 10:09:18 PM UTC-4, Maurício Bertanha wrote:

Maurício Bertanha

unread,
May 9, 2016, 12:22:53 AM5/9/16
to OMNeT++ Users
I was asked for my project, it project can be found in: https://github.com/mbertanha/thesis

Basically I have a sink sending packets to the nodes, even if I set in the ini file that the destination addresses:

**.sink.packetControl.destAddresses = "host[0](modulepath) host[1](modulepath) host[2](modulepath)"

Each packet is only received by one node. If you run the example you can see the console with all the received packets.

The send logic is in the file PacketControl.cc in the function PacketControl::sendPacket(), there is a ToDo there to learn how to broadcast once now only one destination address is being picked.

        //TODO: How to broadcast?
        L3Address destAddr = chooseDestAddr();
        IL3AddressType *addressType = destAddr.getAddressType();
        INetworkProtocolControlInfo *controlInfo = addressType->createNetworkProtocolControlInfo();
        controlInfo->setDestinationAddress(destAddr);


I am using Omnet++ 4.6 to do the simulations.

Thanks. 

On Thursday, May 5, 2016 at 10:09:18 PM UTC-4, Maurício Bertanha wrote:

Maurício Bertanha

unread,
May 17, 2016, 3:21:47 AM5/17/16
to OMNeT++ Users
Hello Alfonso, could you please take a look in the project that I shared and tell me what I am doing wrong, please?

Alfonso Ariza Quintana

unread,
May 17, 2016, 3:43:10 AM5/17/16
to omn...@googlegroups.com
The limited broadcast need to set the output interface, when you send an interface identification to the IP laer, the packet is sent with the broadcast address in a particular interface, not in all interfaces.

If you set the parameter
**.forceBroadcast = true

The Ip module will ignore the output interface and will send the packet in all output interfaces.


-----Mensaje original-----
De: omn...@googlegroups.com [mailto:omn...@googlegroups.com] En nombre de Maurício Bertanha
Enviado el: martes, 17 de mayo de 2016 9:22
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: [Omnetpp-l] Re: Boadcast using modulepath protocol

Hello Alfonso, could you please take a look in the project that I shared and tell me what I am doing wrong, please?

Maurício Bertanha

unread,
May 17, 2016, 1:40:01 PM5/17/16
to OMNeT++ Users, aari...@hotmail.com
Thank you Alfonso, thank you very much!
Reply all
Reply to author
Forward
0 new messages