OMNET++ CODE FOR LEACH PROTOCOL

OMNET++ CODE FOR LEACH PROTOCOL Leach referred as Low Energy Adaptive Clustering Hierarchy.LEACH is a TDMA based MAC Protocol.(LEACH) protocol is a TDMA based MAC protocol. OMNET++ CODE FOR LEACH PROTOCOL aim of this protocol is to improve the lifespan of wireless sensor networks by lowering the energy consumption required to create and maintain Cluster Heads.

OMNET++ CODE FOR LEACH PROTOCOL

Features of leach:

  • Load balancing is achieved.
  • All nodes die at a time.
  • Better utilization and system lifetime.

Techniques:

Techniques which are used in leach to achieve the design goals are mentioned below

  • Low energy media access control.
  • Application specific data processing like data aggregation and compression.
  • Localized control of data transfers.
  • Randomized, adaptive, self-configuring cluster formation.

Procedure of leach routing protocol:

  • Cluster head selection.
  • Steady state phase.
  • Cluster formation.
  • LEACH-C: BS cluster formation.
OMNET++ CODE FOR LEACH PROTOCOL

Download OMNET++ CODE FOR LEACH PROTOCOL


[code lang="js"]
#define NANO 0.001
#define PICO 0.000001
#define CL_TOBS		1	//	red
#define CL_TOHEAD	2	//	green
#define CL_TDMA		3	//	blue
#define CL_CHDATA	4	//	yellow
#define SMSG_SENDDATA		11
#define SMSG_DATA2BS		12
#define SMSG_STATUS2BS		13
#define SMSG_MAKETDMA		14
#define SMSG_INIT			15
#define SMSG_CHANGESTATUS	16
#define BROADCAST 0
#define STATUS_OK	1
#define STATUS_DEAD	2
#define INIT_WAIT	1
struct _node
{
	int id;
	int status;
	int outgate;
	int hops;
	int bcount;
	int scount;
	int seqNumber;
};
struct _adv
{
	int id;
	double energy;
	int status;
	double rating;
	double xpos;
	double ypos;
};
struct _peerInfo
{	int id;
	double xpos;
	double ypos;
};
void ClusterMessage::parsimPack(cCommBuffer *b)
{
    ::cMessage::parsimPack(b);
    doPacking(b,this->displayString_var);
    doPacking(b,this->proto_var);
    doPacking(b,this->srcAddress_var);
    doPacking(b,this->destAddress_var);
}

[/code]