💥1 概述
无线传感器网络(WSN)数据传输离不开路由协议,路由协议是其组网的基础。由于WSN是一种资源受限网络,尤其是能量的受限,因此路由协议必须维持较小的路由信息并尽可能的减少能耗。文中从其体系结构、协议栈、网络层次等几个方面分析介绍了无线传感器网络,在对传感器网络路由协议作了充分了解的基础上深入研究了经典的聚类路由算法——LEACH(Low Energy Adaptive Clustering Hierarchy),提出了对它的改进方案并用OPNET对改进前后的算法进行了仿真比较。仿真结果证明了改进后算法的有效性,并且在能耗和网络生存时间上比LEACH有了提高。
📚2 运行结果
🎉3 参考文献
[1]胡钢,谢冬梅,吴元忠.无线传感器网络路由协议LEACH的研究与改进[J].传感技术学报,2007(06):1391-1396.
👨💻4 Matlab代码
主函数部分代码:
clc; clear all; close all; NUM_NODES = 100; no_of_clusters = 5; angle_sector = 2*pi/no_of_clusters; radius_field = 100; x0 = 0; y0 = 0; packet_length = 500; ad_length = 10; radius_ms = 25; %%%%Energy parameters Eo = 0.5; Eelec=50*10^(-9); % units in Joules/bit Efs = 10*10^(-12); Emp = 13*10^(-16); EDA=5*10^(-9); do = sqrt(Efs/Emp); figure(1); viscircles([x0,y0],radius_field); hold on for i = 1:NUM_NODES t = 2*pi*rand(1,1); r = radius_field*sqrt(rand(1,1)); S(i, 1) = x0 + r*cos(t); S(i, 2) = y0 + r*sin(t); plot(S(i, 1), S(i, 2), 'red .'); title 'Wireless Sensor Network'; xlabel '(m)'; ylabel '(m)'; hold on; end a2 = 0; for i = 1:no_of_clusters a1 = a2; % A random direction a2 = a1 + angle_sector; t = linspace(a1,a2); x = x0 + radius_field*cos(t); y = y0 + radius_field*sin(t); plot([x0,x,x0],[y0,y,y0],'k -') axis equal hold on; end for i = 1:NUM_NODES nodes(i).id=i; % sensor's ID number nodes(i).x=S(i, 1); % X-axis coordinates of sensor node nodes(i).y=S(i, 2); % Y-axis coordinates of sensor node nodes(i).battery=Eo; % nodes energy levels (initially set to be equal to "Eo" nodes(i).role=0; % node acts as normal if the value is '0', if elected as a cluster head it gets the value '1' (initially all nodes are normal) nodes(i).cluster=0; % the cluster which a node belongs to nodes(i).cond=1; nodes(i).dist_origin = sqrt((nodes(i).x-x0)^2+(nodes(i).y-y0)^2); nodes(i).role=0; nodes(i).cond=1; nodes(i).dist_CH=0; end