91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-15
  • 語言: Matlab
  • 標(biāo)簽: TAODV_MATLAB??

資源簡介

關(guān)于TAODV路由協(xié)議的完整matlab程序代碼以及詳細(xì)注釋。

資源截圖

代碼片段和文件信息

function?[pathcost]=hopbyhop(startstopadmatrix)?
%This?function?performs?hop-by-hop?routing?by?selecting?the?next?hop?with?
%the?highest?trust?value.?
%the?inputs?of?this?function?are:?
%start?=source?node?
%stop=?destination?node?
%admatrix?=?adjacency?matrix?storing?the?trust?values?of?the?nodes?
%the?function?returns?the?selected?path?and?the?average?cost?of?the?path?
%the?function?is?used?as?follows:?
%[pathcost]=hopbyhop(startstopadmatrix)?
%NB:the?function?does?not?work?correctly?in?some?casesfurther?improvements?
%will?done?in?future.?
??
%initialisation?
noOfNodes?=?size(admatrix?1);?
rpath=[];?
rpath(1)=start;?
pathS=start;?
parent=pathS;?
cosy?=?0;?
[route]=hopsdij(pathSstopadmatrix);%checking?if?path?exists?between?source?and?destination?node?
if?(pathS~=stop?&&?route?==1)%main?loop?
????k=1;%counter?for?neighbours?
????i=2;%path?counter?
????while(pathS~=stop)?
????????B=[];%vector?of?neighbours?and?trust?values?
????????jj=1;?
????????for?j=?1:noOfNodes?
??
????????????if?admatrix(pathS?j)~=inf??
????????????????B(jj1)=j;?
????????????????B(jj2)=admatrix(pathSj);?
????????????????jj=jj+1;?
????????????end?
????????end?
??B?=sortrows(B-2);?
??nexthop?=?B(k1);%nexthop?with?the?highest?trust?value?
??chk?=?searchp(rpathnexthop);?
??if?chk==1?
???
?[route]=hopsdij(nexthopstopadmatrix);?
???????if(route==0)?
??????????k=k+1;?
???????else?
???????????rpath(i)=nexthop;?
???????????pathS=nexthop;?
???????????k?=1;?
???????????i=i+1;?
??????????
???????end?
????else?
??????k?=?k+1;?
??end?
????end?
else?
????disp(‘source?=dest?or?cannot?reach?destination‘)?
end?
path?=rpath;%selected?path?
cost=0;?
for?d=2:length(path)?
????????cost=?cost+admatrix(path(d-1)path(d));?
end?
cost=cost/length(path);%average?cost?of?the?path?
??
%searching?for?visited?nodes?
function?c?=searchp(rpnp)?
counter?=0;?
for?z=1:length(rp)?
????if?np==rp(z)?
????????counter=counter+1;?
????end?
end?
if?counter>0?
????c?=?0;?
else?
????c?=?1;?
end?
?
function?[route]=hopsdij(pathSstopadmatrix)
if?admatrix(pathSstop)~=0?||?admatrix(pathSstop)~=inf
????route=1;
else
????route=0;
end


return?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2212??2003-07-14?21:04??TAODV\hopbyhop.m

?????文件???????1861??2003-07-14?21:11??TAODV\TAODV.m

?????目錄??????????0??2014-08-11?19:34??TAODV

-----------?---------??----------?-----??----

?????????????????4073????????????????????3


評論

共有 條評論

相關(guān)資源