⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reliability3.m

📁 无线传感器网络的可靠路由算法
💻 M
字号:
o=zeros(9,7);p=0.2628;
for l=1:9
    x=0;
    for k=1:7
        x=x+1;
        s=0;
        suc=0;
       for i=1:1000
            count=0;
            count1=0;
           for j=1:8
                v=1;
               for h=1:5
                    if v==1
                       s=s+1;
                       a=rand();
                       if a<p^k
                          v=0;
                       else
                           for m=1:k
                               if a<p^m
                                   s=s+1;
                               end
                           end
                       end
                    end
                end
                if v==1
                   count=count+1;
                end
            end
           for j=8:8+l-1
                v=1;
               for h=1:5
                   if v==1
                      s=s+1;
                      a=rand();
                      if a<p^k
                         v=0;
                     else
                           for m=1:k
                               if a<p^m
                                   s=s+1;
                               end
                           end
                      end
                   end
                end
                if v==1
                   count1=count1+1;
                end
            end
            if count1+count>=8
               suc=suc+8;
            else
                suc=suc+count;
            end
        end
        o(l,x)=s/5/suc;
    end
end
i=[0:1:6];
plot(i,o(1,:),'-o',i,o(2,:),'-+',i,o(3,:),'-*',i,o(4,:),'-d',i,o(5,:),'-p',i,o(6,:),'-x',i,o(7,:),'-s',i,o(8,:),'-h',i,o(9,:),'->')
% axis([0,6,0,4]);
legend 0 1 2 3 4 5 6 7 8
xlabel('maximum number of retransmission');
ylabel('overhead');
grid;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -