OMNET++ CODE FOR WIRELESS SENSOR NETWORKS

Wireless sensor network is commonly defined as, Sensing + CPU + Radio = Thousands of potential applications. OMNET++ CODE FOR WIRELESS SENSOR NETWORKS provide a bridge between the real physical and virtual worlds.Wireless Sensor Networks  using omnet++ code allows the ability to observe the previously unobservable at a fine resolution over large spatiotemporal scales.

Sensor nodes anatomy:

  • Radio used for transmitting the acquired data to some storage site.
  • Sensors for temperature, humidity, light.
  • Memory used for the program code and for in-memory buffering.
  • Power source.
  • Processor in various modes like idle, sleep and active.
Architecture of Wireless Sensor Networks
Architecture of Wireless Sensor Networks

 

Applications of sensor network:

  • Predictive maintenance.
  • Enable new knowledge in scientific filed.
  • Intelligent buildings
  • Smart home applications.
  • Improve productivity.
  • Healthcare applications.
  • Improve food and H2O.
  • High confidence transport and assest tracking.
  • . Enhanced safety and security.

Sample OMNeT++ Code for Wireless Sensor Networks.

void Sink::initNodes() {
    cModule* parent = getParentModule();
    cModule* mod;
    int numNodes;
    int trRange;
    int i;
    numNodes = parent->par("numNodes");
    ev << "Main-server numNodes is: " << numNodes << "\n"; trRange = parent->par("trRange");
    ev << "Main-server trRange is: " << trRange << "\n";
    for(i=1;i<=simulation.getLastModuleId();i++) { mod=simulation.getModule(i); if(strcmp(mod->getName(),"node")==0)
        {
            nodePtr[((Node*)mod)->myId]=(Node*)mod;
        }
    }
}

void Sink::releaseConnections() {
    cGate* g;
    cModule* mod;
    int i, j;
    for (i = 1; i <= simulation.getLastModuleId(); i++) { mod = simulation.getModule(i); if (strcmp(mod->getName(), "node") == 0) {
            if(((Node*)mod)->energy>0)

                (mod->getDisplayString()).parse("i=misc/node,yellow");
            for (j = 1; j < nrGates + 1; j++) { g = mod->gate("out", j);
                g->disconnect();
            }
        }
    }
}