NS2 sample source code for Wireless Sensor Networks

  In NS2, WSN simulation is done by creating multiple sensor nodes and sink or base station nodes. Each sensor node can be configured with different communication and sensing range specifications. Energy model of the sensor nodes can be applied with initial energy and power consumption specifications. The sensor deployment can be done either randomly or in a deterministic manner. Coverage hole creation and healing process can be simulated. Cluster formation, Cluster head selection and cluster based data aggregation and routing process can be simulated. Cluster based routing protocols such as LEACH can be patched to existing ns2 package. Trace file generated at the end of WSN simulation consists of residual energy of the nodes at every instance of the simulation using which the energy consumption, network lifetime, alive and dead nodes can be computed.

The samples given below deals with WSN simulation in NS2: