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

📄 ndma.m

📁 R. Lin and A.P. Petropulu, 揂 New Wireless Medium Access Protocol Based On Cooperation,擨EEE Trans. on
💻 M
字号:


clear all; close all;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                          ndma.m
% This program is designed for the NDMA scheme
% in random access network.  It shows the maximum possible throughput
% vs. traffic load (not only newly generated load) under a certain SNR.  
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

snr = 20;

% Simulation parameters
J = 32; %32; % total number of users                 
N = 424; % length of packet

N1 = N/2 - J; %number of data symbols per packet (QPSK)
ID = hadamard(J)+j*hadamard(J);      % every user has an ID orthogonal to others'
M = 20000;
numTrial = 2000; % number of independent Bernoulli trials

threshold=0.1; % threshold for active user detection.

P = 0.1:0.3:3.1;
P=P/J;

fec = 0.02; % packets received with BER higher than fec is considered lost/corrupted
load channel3;

for ii=1:length(P)
    ii
    Successes = 0;
    
    for jj = 1:numTrial
        succ = 0;
        Load  = rand(1,J);
        Trans = Load <= P(ii);
        num_active=sum(Trans);
        rand('state',ii*171+jj*23+822);
        
        t1 = randsrc(1, 1, [1:M]); %random start time instant
        if num_active > 0
            active = find(Trans)';
            packet = [ID(:,active); sign(rand(N1,num_active)-0.5)+j*sign(rand(N1,num_active)-0.5)];
            noise = sqrt(1/(10^(snr/10)))*(randn(N/2,num_active)+j*randn(N/2,num_active));
           
            y = packet*HA(active, t1:t1+num_active-1) + noise;
            
            %%%%%%%%%% BS side %%%%%%%%%%%%%%%%%%%%
            
            %.....active user detection........
            alpha=ID'* y(1:J, :)/J/2;
            num_DetUser = sum(abs(alpha(:,1))>threshold);
            DetUser = find(abs(alpha(:,1))>threshold);
            
            if ( num_DetUser == num_active ) & (DetUser == active) 
                
                A = alpha(DetUser, :);
                
                % Linear Decoding (Zero Forcing)                    
               tt = y(J+1:end, :)*A'*inv(A*A');
               rev = sign(real(tt)) + j*sign(imag(tt));
                
                %Maximum Likelihood Decoding                
%                rev = decodpac(y(J+1:end, :), A);
                
                for kk=1:num_DetUser
                    bbb=mapper2(packet(J+1:end,kk),1);
                    sss=mapper2(rev(:,kk),1);
                    look=bbb-sss;
                    IBER=find(abs(look)>0);
                    BIT_ERROR_RATE=length(IBER)/N;
                    if (BIT_ERROR_RATE <= fec)
                        succ = succ + 1;
                    end
                end
                
            end %if (num_DetUser...
            if num_DetUser ~= 0
                succ = succ/num_DetUser;
            end
            
        end %end if num_active>0
        
        Successes = Successes + succ;
    end %end of jj = 1:numTrial
    
    Throughput(ii) = Successes/numTrial;
end %end of ii=1:length(Ns)

plot(P*J, Throughput, ':');
% temp = Throughput./(P*J);
% figure; plot(P*J, temp);

⌨️ 快捷键说明

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