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

📄 fixed_freqhopping.m

📁 L. Dong and A. P. Petropulu, 揗ultichannel ALLIANCES: A Cross-layer Cooperative Scheme for Wireless
💻 M
字号:
% frequency hopping of the fixed subchannel selection scheme
% for packets of type II
clear all
close all
G=4; % number of groups (i.e.,number of subchannels)
M=20000;    % simulation slots
J=32;   % number of users
simurange=20;   % number of points of Poisson traffic

throughput=zeros(1,simurange); % ideal
throughput1=zeros(1,simurange); % with frequency hopping
throughput2=zeros(1,simurange); % without frequency hopping
num_trial=20;
WorkLoad=[0:simurange-1]/simurange+0.01;

for ss=1:num_trial
    ss
    
    % generate the traffic
    [Traffic,WorkLoad] = gen_traffic(M, J, simurange);
    
    for ii = 1:simurange 
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        
        % the proposed scheme
        sm_traffic = Traffic(:,:,ii); % Generate new traffic
        Loads = zeros(1,J);
        
        flag=zeros(1,J);
        time_table=zeros(J,M+J);
        
        pos_pack=zeros(J,M+J);
        for nn=1:J
            temp=find(Traffic(nn,:,ii)==1);
            pos_pack(nn,1:length(temp))=temp;
        end
        count_pack=0;
        count_pack1=0;
        count_pack2=0;
        flag_CTE=0;
        
        for t1 = 1:M
            newLoads = sm_traffic(:,t1)';
            Loads = Loads + newLoads; % Add to buffer
            Trans = Loads >0;
            num_active=sum(Trans);
            
            flag_CTE=max(0,flag_CTE-1);
            
            if num_active>0 & flag_CTE==0
                
                active = find(Trans)';
                flag_CTE=num_active;
                ret_array = zeros(1,J);
                ret_array(active)=1;
                
                Loads = Loads - ret_array;
                
                count_pack=count_pack+num_active;
                
                
                % with frequency hopping
                % from our simulations, ML equalizer can always successfully recover packets
                % under moderate and high SNR
                % for convenience, here we simply assume the use of ML equalizer
                % and the packets can be resolved if active user detection is correct 
                subch=1+mod(t1,G);                    
                if ~isempty(find(active==1)) & subch==1
                    count_pack1=count_pack1;  
                else
                    count_pack1=count_pack1+num_active;
                end
                
                % without frequency hopping
                % wrong active user detecion results in loss of all
                % packets
                
                if ~isempty(find(active==1))
                    count_pack2=count_pack2;
                else
                    count_pack2=count_pack2+num_active;
                end
                
                for kk=1:num_active
                    flag(active(kk))=flag(active(kk))+1;
                    t_gen=pos_pack(active(kk),flag(active(kk)));
                    time_table(active(kk),flag(active(kk)))=num_active+t1-t_gen;
                end
                
            end
            
            
        end
        if count_pack>0
            throughput2(ii)=throughput2(ii)+count_pack2/M;
            throughput1(ii)=throughput1(ii)+count_pack1/M;
            throughput(ii)=throughput(ii)+count_pack/M;
        end
        
        
    end
end

figure
hold on
plot(WorkLoad,throughput/num_trial,'k-','linewidth',2)
plot(WorkLoad,throughput1/num_trial,'k-.','linewidth',2)
plot(WorkLoad,throughput2/num_trial,'k--','linewidth',2)
legend('ideal','with frequency hopping','without frequency hopping')

⌨️ 快捷键说明

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