Tip:
Highlight text to annotate it
X
Hello, In this video we will understand the implementation
and working of LEACH (Low Energy Adaptive Cluster Hierarchy Algorithm) in Wireless Sensor
Networks (WSN) in NetSim. LEACH is a MAC protocol which involves clustering,
aimed at lowering energy consumption and improving lifetime of the Wireless Sensor Networks.
For our example, we use a scenario with 64 nodes divided into 4 clusters. LEACH can also
be implemented for networks with different number of sensors and clusters. The sensor
with maximum energy in each cluster is selected as the cluster head. Cluster heads are updated
continuously throughout the simulation. The member sensors in each cluster communicate
only with the cluster head, via a single hop transmission. The cluster heads forward this
data to the Sink or Base Station, either directly or via other cluster heads along the static
routes defined in the source code. Note that NetSim’s default WSN libraries
only have AoDV and DSR in layer 3. The DSR source code is taken and a new file called
LEACH.c which contains the code for the above mentioned algorithm is written. This has been
built and a new binary is placed in the application path.
Now, to enable LEACH, uncomment the line “#define _LEACH” at the beginning of the DSR.h file.
Next, to enable Static ARP, uncomment the “#define _STATIC_ARP” line in the same
DSR.h file. Rebuild the DSR and Zigbee dlls in the bin path after making the above modifications.
Advanced users can modify this code for a different implementation of LEACH or for a
different L3 routing algorithm. Next to simulate LEACH in NetSim, create a
new project by clicking on Simulation - New - Wireless Sensor Networks. Specify the side
length as 50m, select Uniform Placement, enter the number of nodes as 64. Place the Sink
Node and Agent as shown. Next, right click on any sensor and select properties. Change
the Max Frame Retries as 0 and Transmission power as 100mW. Right click anywhere on the
grid and select properties for the Environment. We have chosen Channel characteristics as
Line of Sight and Path loss Exponent is 2. Once the properties have been set, click the
“Packet Trace” button. Enter the file name, select file type as .csv and specify
a location. Next, click Simulate button. Select Simulation
Time as 30s, enter Experiment Name, and select Record Animation. Then click OK.
After the simulation is complete, click ‘View packet animation’ link on the left side.
A window opens showing the network along with playback controls for Play, Pause, Simulation
Time, and a slider to control the animation speed.
Now let us study the simulation in detail with the help of the packet animator.
As can be seen from the simulation, the cluster heads continuously change. The packet is first
transmitted to the cluster head, which then forwards it towards the Sink. Sometimes, a
packet is dropped during this transmission on account of propagation losses.
Let us look at the flow of two packets to get a clear picture. The first packet (Packet
ID-12) is generated by Sensor 13, which transmits it to the Cluster head Sensor 22. Sensor 22
transmits it to the next cluster head Sensor 46, which then forwards it to the sink. The
next packet, which originates from Sensor 7, is sent to the Cluster head Sensor 22,
where it is dropped due to CCA failure. Similarly, the transmissions happen for all the other
packets. The entire flow of packets can be better understood
by running the packet animation at a slower speed, and verifying it against the generated
Packet Trace. For more advanced users, the mechanism of
changing of the cluster heads can be seen by debugging the code using Visual Studio.
Add the variable array CH to Watch Window, set a breakpoint at the beginning of the LEACH.c
file and debug through the code. Hope you enjoyed this video on LEACH implementation
in NetSim.