Reputation: 125
I want to create a simple wireless ad-hoc network in Omnet++ using inet.
What the network should do is:
I don't care about the protocols that are used under the hood, I just want to model this behaviour in the easiest way possible to see if I can implement some kind of TDMA-protocol in my application.
I already set up a basic network, but now I don't understand how I can send simple messages (packets?) to all hosts in range. This is what I have so far:
MyApp.cc:
#include <omnetpp.h>
#include "inet/common/packet/Packet.h"
using namespace omnetpp;
class MyApp: public cSimpleModule {
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
Define_Module(MyApp);
void MyApp::initialize() {
EV << "Initialize called \n";
inet::Packet *outPacket = new inet::Packet("TEST");
// How to send this packet to all hosts now?
}
void MyApp::handleMessage(cMessage *msg) {
EV << "handleMessage called \n";
}
myNetwork.ned
package mysimpleproject;
import inet.node.inet.INetworkNode;
import inet.physicallayer.contract.packetlevel.IRadioMedium;
import inet.networklayer.configurator.ipv4.Ipv4NetworkConfigurator;
network myNetwork {
submodules:
configurator: Ipv4NetworkConfigurator {
@display("p=580,200");
}
radioMedium: <default("UnitDiskRadioMedium")> like IRadioMedium {
@display("p=300,200");
}
hostA: <default("WirelessHost")> like INetworkNode {
@display("p=50,100");
}
hostB: <default("WirelessHost")> like INetworkNode {
@display("p=100,100");
}
}
myApp.ned
package mysimpleproject;
import inet.applications.contract.IApp;
simple MyApp like IApp {
gates:
input socketIn;
output socketOut;
}
omnetpp.ini
[General]
network = myNetwork
**.wlan[0].typename = "AckingWirelessInterface"
**.wlan[0].bitrate = 1000000bps
**.wlan[0].radio.transmitter.communicationRange = 100m
**.numApps = 1
**.app[0].typename = "MyApp"
I haven't found any real documentation on that as well (the inet Tutorials and even Developer's Guide do not show complete c++ code, so it's really hard to understand how to implement even these basic things), so if someone has more reference where I can read up on that it would also be helpful.
Upvotes: 0
Views: 448
Reputation: 6681
Your question can be formulated differently. Independent of the underlying technology (i.e. wireless or wired), the question is:
How do I send a UDP packet from an application to all other hosts in a network. And the answer is: use the broadcast IP address (255.255.255.255) as the destination address in your application. The underlying protocol will handle the task to send it out to each node in the range.
Upvotes: 1