ns2下leach协议的仿真

本文档详细介绍了在ns2环境下对LEACH协议的仿真实验,主要关注三个方面:存活节点数量、节点能耗和网络数据总转发量。通过leach_alive.awk脚本计算不同时间的存活节点,并利用gnuplot绘制图表。此外,还提供了节点能耗和数据转发量的仿真方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ns2下leach协议的仿真主要从以下三个条件予以评价:存活节点的数量,节点能耗,网络数据总转发量

(1).#计算不同时间存活节点的数量  leach_alive.awk脚本程序

BEGIN {  
  countcyl=0;  
  totalleft=0;  
  lasttime=0;  
  time[0]=0;  
  node=0;  
  total[0]=100;  
}  
{  
  
simtime              = $1;  
nodeid               = $2;  
statenode            = $3;  
  
if (simtime>lasttime ) {  
    countcyl++;  
    lasttime=simtime;  
    time[countcyl]=simtime;  
    totalleft=0;  
      }  
  
if (statenode==1)  
     totalleft++;  
     total[countcyl]=totalleft;  
}  
END {  
for(i=0;i<=countcyl;i++)  
printf( "%f %d\n",time[i],total[i]);  
}  

在mit/leach_sims目录下运行 awk   -f   leach_alive.awk   leach.alive   >   leach_alive.txt

会在当前目录下生产一个leach_alive.txt,下面对这个文件使用gnuplot画图

./gnuplot

set title "leach -wcdj"]
set xlabel "round"
set ylabel "the num of alive nodes"
set terminal gif
set output "leach_alive.gif"
pl

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值