# [10GBASE-T] Matlab code

Here is the matlab code used to obtain the capacity results that I
presented in Dallas last week.  As mentioned, the results were very
similar to the results produced by other code on the reflector.

To run this code, run the function main_snr1 with 4 parameters, AWGN_on,
ANEXT_on, ANEXT_reduction, FEXT_AS_SIGNAL.  This function will in turn
call snr11.

Please let me know if you have any comments or questions.  Thanks,

...PJ

--
P.J. Sallaway <pj@myricanetworks.com>
Myrica Networks Inc.
function main_snr1(AWGN_on, ANEXT_on, ANEXT_reduction, FEXT_AS_SIGNAL)

% Compute capacity as a function of variable BW (MHz)
% Numerical integration: lower limit 1 Hz; upper limit fup
% step size: 5 MHz
% command line arguments are:  AWNG_on         - do we have add additive white gaussian noise
%                              ANEXT_on        - do we add Alien NEXT
%                              ANEXT_reduction - Alien NEXT cancellation in dB
%                              FEXT_AS_SIGNAL  - do we include FEXT power in the signal power

fup=100:5:835;                           %the Bandwidth upper limits that will be tested
%fup=416;

cat6 = 0;                                %Run Capacity calculation for 100m Cat-5E cable
q_5e = zeros(1,length(fup));

for i=1:length(fup)                      %For each BW, use Matlab's numerical integration to calculate capacity for Cat-5E
uplim=fup(i);
q_5e(i)=quad(@snr11,1e-6,fup(i),1e-6,[],uplim, cat6, ANEXT_on, AWGN_on, ANEXT_reduction, FEXT_AS_SIGNAL);
end

cat6 = 1;                                %Run Capacity calculation for 100m Cat5E cable
q_6 = zeros(1,length(fup));

for i=1:length(fup)                      %For each BW, use Matlab's numerical integration to calculate capacity for Cat-6
uplim=fup(i);
q_6(i)=quad(@snr11,1e-6,fup(i),1e-6,[],uplim, cat6, ANEXT_on, AWGN_on, ANEXT_reduction, FEXT_AS_SIGNAL);
end

figure(1); plot(fup,q_5e/1000,fup,q_6/1000); grid on;   %plot Capacity as a function of Bandwidth
xlabel('One-sided BW (MHz)')
ylabel('Shannon Capacity in GBps')

if AWGN_on && (~ANEXT_on)
title('Capacity with AWGN')
else if AWGN_on && ANEXT_on
title(['Capacity with AWGN and ANEXT with ', num2str(ANEXT_reduction),'dB of ANEXT cancellation'])
else if (~AWGN_on) && ANEXT_on
title(['Capacity with ANEXT with ', num2str(ANEXT_reduction),'dB of ANEXT cancellation'])
end
end
end

[c,i] = max(q_5e);                          % Maximum capacity and corresponding bw for Cat-5E
cat5e_capacity = c / 1000;
cat5e_optimum_bw = fup(i);

[c,i] = max(q_6);                           % Maximum capacity and corresponding bw for Cat-6
cat6_capacity = c / 1000;
cat6_optimum_bw = fup(i);

if AWGN_on
fprintf(1,'\nAWGN is ON, ');
else
fprintf(1,'\nAWGN is OFF, ');
end
if ANEXT_on
fprintf(1,'ANEXT is ON, ANEXT_reduction = %.2fdB, ', ANEXT_reduction);
else
fprintf(1,'ANEXT is OFF, ');
end
if FEXT_AS_SIGNAL
fprintf(1,'FEXT utilized in signal\n\n');
else
fprintf(1,'FEXT NOT utilized in signal\n\n');
end

fprintf(1,'Cat-5E: Capcity = %4.4f Gbps at a bandwidth of %4.0f MHz\n', cat5e_capacity, cat5e_optimum_bw);
fprintf(1,'Cat-6 : Capcity = %4.4f Gbps at a bandwidth of %4.0f MHz\n\n', cat6_capacity,  cat6_optimum_bw);

function y=snr11(f,uplim, cat6, ANEXT_on, AWGN_on, ANEXT_reduction, FEXT_AS_SIGNAL)
% compute capacity in AWGN + ANEXT
% f in MHz

% Insertion Loss based on Chris DiMinico's 1/17/03 email attachment (dB)
% Compute received p.s.d at 100 m corr. to input power S_i = 10 dBm
% Flat input p.s.d assumed

tx_pow = 10;                    % Total transmit power = +10dBm

if cat6
IL=-(1.05*(1.82*sqrt(f)+0.0169*f+0.25./sqrt(f))+4*0.02*sqrt(f));                    % Insertion loss for Cat6 cable
FEXT=20*log10(10.^((64.8-20*log10(f))/(-20))+4*10.^((80.1-20*log10(f))/(-20)));     % PSELFEXT based on Chris DiMinico's 1/17/03 email attachment
else
IL=-(1.05*(1.9108*sqrt(f)+0.0222*f+0.2./sqrt(f))+4*0.04*sqrt(f));                   % Insertion loss for Cat5E cable
FEXT=20*log10(10.^((60.8-20*log10(f))/(-20))+4*10.^((72.1-20*log10(f))/(-20)));     % PSELFEXT based on Chris DiMinico's 1/17/03 email attachment
end

Si = 10*log10(10^(tx_pow/10)/uplim);                                                    % Input signal power

if FEXT_AS_SIGNAL                                                                       % If utilizing FEXT, FEXT is added to added to signal output
So = 10*log10( (10.^((Si+IL)/10)) + (10.^((Si+IL+FEXT)/10)) );
else                                                                                    % else just calculate signal output
So = 10*log10( (10.^((Si+IL)/10)));
end

% Alien NEXT Loss (dB)[f in MHz]
if cat6
ANEXT=max(-65*ones(size(f)), -41.1+15*log10(f/100));
else
ANEXT= max(-65*ones(size(f)),  -38.3 + 15*log10(f/100));
end

ANEXT = ANEXT - ANEXT_reduction;                                                        % Alien NEXT cancellation
% Compute ANEXT p.s.d at receiver input for launch power S_i = 10 dBm
ANEXTrcv = 10*log10(10/uplim) +  ANEXT;

% noise PSD (dBm/MHz): equivalent to -140dBm/Hz, single sided
No = -80;
% compute SNR and Capacity for 4-pairs
Npow=10.^(No/10);
ANEXTpow= 10.^(ANEXTrcv/10);

if ANEXT_on
Ipow=ANEXTpow;
else
Ipow=0;
end

if AWGN_on
Ipow=Ipow + Npow;
end
Spow=10.^(So/10);
y=4*log2(1+Spow./Ipow);