Search code examples
simulationsimulatorwirelessomnet++

OMNET++ wireless communication client-server


It's the first time I'm using OMNET++.

I want to start from the very basic stuff to understand how it works. I successuffly created my first simulation with two hosts continuosly exhanging mesagges (from tictoc example).

What I would like to do now is to simulate a simple client-server wireless communication between one AP and one wireless node. I'm trying to do that using elements from the inet class but I'm stuck and it is not working.

import inet.networklayer.configurator.base.NetworkConfiguratorBase;
import inet.networklayer.configurator.ipv4.IPv4NetworkConfigurator;
import inet.networklayer.configurator.ipv4.IPv4NodeConfigurator;
import inet.node.inet.WirelessHost;
import inet.node.wireless.AccessPoint;
import inet.physicallayer.common.packetlevel.RadioMedium;
import inet.physicallayer.contract.packetlevel.IRadioMedium;
import inet.physicallayer.ieee80211.packetlevel.Ieee80211RadioMedium;


//
// TODO documentation
//
network net
{
    string mediumType = default("IdealRadioMedium");
    @display("bgb=620,426");
    submodules:
        wirelessHost1: WirelessHost {
            @display("p=423,164");
        }
        accessPoint1: AccessPoint {
            @display("p=147,197");
        }
        iRadioMedium: <mediumType> like IRadioMedium {
            @display("p=523,302");
        }
        iPv4NetworkConfigurator: IPv4NetworkConfigurator {
        @display("p=270,324");
        assignDisjunctSubnetAddresses = false;
    }
}

and then I created a wirelessHost.cc source file using the tictoc beahviour to make the two nodes communicate.

But it is not working, I get this error:

<!> Error in module (inet::IPv4NodeConfigurator) infrastructure.wirelessHost1.networkLayer.configurator (id=13) during network initialization: Configurator module 'configurator' not found (check the 'networkConfiguratorModule' parameter).

But before doing something, it was another error about the Access Point (could not find wlan[0] module). Can someone help me to understand how to configure this model?

EDIT Here's the configuration .ini file

[General]
network = infrastructure

#cmdenv-output-file = omnetpp.log
#debug-on-errors = true
tkenv-plugin-path = ../../../etc/plugins
#record-eventlog = true

**.constraintAreaMinX = 0m
**.constraintAreaMinY = 0m
**.constraintAreaMinZ = 0m
**.constraintAreaMaxX = 600m
**.constraintAreaMaxY = 500m
**.constraintAreaMaxZ = 0m

**.mobility.typename = "StationaryMobility"
**.mobilityType = "StationaryMobility"


# access point
*.accessPoint.wlan[0].mac.address = "004444444444"
*.accessPoint.wlan[0].radio.channelNumber = 11


# host1 is associated with AP1 on channel 0
**.wirelessHost1.wlan[0].mgmt.accessPointAddress = "004444444444"
*.wirelessHost1.**.mgmtType = "Ieee80211MgmtSTASimplified"


# global data rates
**.wlan*.bitrate = 11Mbps

# application level: host1 pings host2
**.numPingApps = 1
*.wirelessHost1.pingApp[0].destAddr = "accessPoint"
*.wirelessHost1.pingApp[0].sendInterval = 10ms

but running the simulation I get

<!> Error in module (inet::ICMP) infrastructure.wirelessHost1.networkLayer.icmp (id=17) at event #4, t=0.008442657441: check_and_cast(): cannot cast (inet::GenericNetworkProtocolControlInfo*) to type 'inet::IPv4ControlInfo *'.

Solution

  • An instance of IPv4NetworkConfigurator in network has to be named configurator. After changing its name your second problem should be resolved too.
    Moreover, the name of RadioMedium instance module has to be: radioMedium (instead of iRadioMedium).

    EDIT
    You have made two mistakes.

    1. AccessPoint does not have network layer, because it only relays and sends MAC frames using MAC layer and MAC addresses - like in real network. As a consequence, it does not have an IP address and it is impossible to send ICMP ping to it.

    2. OMNeT++ allows to use module's name instead of an IP address in ini file, for example **.destAddr = "wirelessHost1". In your ini you are trying to use non existing accessPoint instead of accessPoint1 (which is incorrectly because of the first error).

    I suggest adding a new WirelesHost (for example wirelessHost2) and sending ping towards it, i.e.

    *.wirelessHost1.pingApp[0].destAddr = "wirelessHost2"