To implement secondary users routing in OMNeT++ has needs to simulating a network where secondary users (SUs) enthusiastically access the network based on available resources that usually in the aspect of Cognitive Radio Networks (CRNs) or Dynamic Spectrum Access (DSA) scenarios and the secondary users do not have licensed access to the spectrum and should use routing techniques that adjust to the presence of primary users (PUs) who have priority. The below are the procedures to implement the secondary users routing in OMNeT++:
Steps to Implement Secondary Users Routing in OMNeT++
Example: Implementing Secondary Users Routing in OMNeT++
// SecondaryUsersRoutingNetwork.ned
package networkstructure;
import inet.node.inet.WirelessHost;
network SecondaryUsersRoutingNetwork
{
parameters:
int numPUs = default(5); // Number of primary users
int numSUs = default(10); // Number of secondary users
submodules:
primaryUser[numPUs]: WirelessHost {
@display(“p=100,100”);
numApps = 1;
app[0].typename = “PrimaryUserApp”;
}
secondaryUser[numSUs]: WirelessHost {
@display(“p=300,200”);
numApps = 1;
app[0].typename = “SecondaryUserApp”;
}
connections:
// No fixed connections as routing is dynamic based on available spectrum
}
Generate a C++ class for the secondary user application that emulates the dynamic selection of channels and transmit of information.
#include <omnetpp.h>
#include <inet/applications/base/ApplicationBase.h>
using namespace omnetpp;
using namespace inet;
class SecondaryUserApp : public ApplicationBase
{
protected:
virtual void initialize(int stage) override;
virtual void handleMessageWhenUp(cMessage *msg) override;
void senseChannelAndRoute();
public:
virtual int numInitStages() const override { return NUM_INIT_STAGES; }
};
Define_Module(SecondaryUserApp);
void SecondaryUserApp::initialize(int stage)
{
ApplicationBase::initialize(stage);
if (stage == INITSTAGE_APPLICATION_LAYER) {
// Schedule initial channel sensing and routing
scheduleAt(simTime() + uniform(1, 3), new cMessage(“senseAndRoute”));
}
}
void SecondaryUserApp::handleMessageWhenUp(cMessage *msg)
{
if (strcmp(msg->getName(), “senseAndRoute”) == 0) {
senseChannelAndRoute();
scheduleAt(simTime() + uniform(1, 3), msg); // Re-schedule sensing and routing
} else {
delete msg;
}
}
void SecondaryUserApp::senseChannelAndRoute()
{
EV << “Sensing available channels and routing data.” << endl;
// Example: Sense the environment to find available channels
bool channelAvailable = uniform(0, 1) > 0.3; // Simplified sensing logic
if (channelAvailable) {
EV << “Channel is available. Routing data.” << endl;
// Implement routing logic here based on available channels
cMessage *dataPacket = new cMessage(“DataPacket”);
send(dataPacket, “wlan$o”);
} else {
EV << “No channel available. Waiting for the next opportunity.” << endl;
}
}
We can either execute a custom routing protocol or setup an existing one such as AODV or DSR, adjusting it to account for dynamic channel availability.
network = networkstructure.SecondaryUsersRoutingNetwork
sim-time-limit = 300s
# Secondary user settings
*.secondaryUser[*].wlan.mac.maxQueueSize = 1000;
*.secondaryUser[*].wlan.phy.transmitter.power = 2mW;
*.secondaryUser[*].mobility.bounds = “500m 500m”;
*.secondaryUser[*].app[0].sensingInterval = uniform(1s, 5s);
# Primary user settings
*.primaryUser[*].wlan.mac.maxQueueSize = 1000;
*.primaryUser[*].wlan.phy.transmitter.power = 10mW; # PUs generally have higher power
*.primaryUser[*].mobility.bounds = “500m 500m”;
Running the Simulation
Extending the Example
In the end, you can get to know more about the installation and implementation of secondary users routing in OMNeT++. We plan to deliver more information on how the secondary users routing will perform in other scenarios. We’re here to guide you through each step of setting up your Secondary Users Routing in the OMNeT++ tool. Stay in touch with us to find out more about this subject!