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

📄 caltime.m

📁 L. Dong and A. P. Petropulu, 揗ultichannel ALLIANCES: A Cross-layer Cooperative Scheme for Wireless
💻 M
字号:
% calculate the processing time and maximum time for the adaptive p scheme
% G: number of subchannels
% subch: the subchannel used for each packet
% num_active1: number of totally transmitted packets

function  [process_time, maxtime]=caltime(G,subch,num_active1)
% pick subchannels randomly

% find the number of collided packets in each subchannel
for pp=1:G
    temp=find(subch==pp);
    ch(pp)=length(temp);
end

% collision order
col_order=zeros(num_active1,1);
for tt=1:num_active1
    col_order(tt)=ch(subch(tt));
end

% sort the collision order
% use highest-to-lowerest scheme to resolve collisions
sort_order=sort(ch)-1;
num_col_ch=length(find(sort_order>0));
if num_col_ch>0
    temp=[];
    for iii=1:num_col_ch
        temp=[temp zeros(1,sort_order(end+1-iii)-1) sort_order(end+1-iii)];
    end
end

% calculate CTE time
for iii=1:G
    if ch(iii)==0
        time(iii)=0;
    elseif  ch(iii)==1
        time(iii)=1;
    elseif ch(iii)>1
        temp1=find(temp==(ch(iii)-1));
        temp(temp1(1))=0;
        time(iii)=1+ceil(temp1(1)/G);

    end
end

% maximum time
maxtime=max(time);

for jj=1:num_active1
    process_time(jj)= time(subch(jj));
end

⌨️ 快捷键说明

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