Home Networking Basis

Walter Chen (view profile)

11 Aug 2003 (Updated )

M-files for chapters 2-10 and Simulink models for Ethernet and Wireless Ethernet.

PLNmodel.m
```psize=2049;
nsub=500;
perc=0.5;
f=[0:psize-1]/2048*50e6;
f(1)=0.00001;
%define shortwave radio bands
%define 30 random peaks
rloc1=rand(1,30)*50e6;
rloc2=rand(1,30)*50e6;
rloc3=rand(1,30)*50e6;
rloc4=rand(1,30)*50e6;
rloc5=rand(1,30)*50e6;
rloc6=rand(1,30)*50e6;
rloc7=rand(1,30)*50e6;
rloc8=rand(1,30)*50e6;
rloc9=rand(1,30)*50e6;
rloc10=rand(1,30)*50e6;
%noise floor
nsfllog=-145;
nsflflog=ones(1,psize)*nsfllog;
nsflf=10.^(nsflflog/10);
%radio background noise level, e-filed
efildlog=34.5-20;
efildflog=ones(1,psize)*efildlog;
epowflog=efildflog-149.5;
epowf=10.^(epowflog/10);
%radio interference noise level, random e-field
erfildflog=rand(1,psize)*65;
for i=1:psize
end
end
end
end
end
end
end
end
for j=1:30
if f(i)>rloc1(j)-100e3 & f(i)<rloc1(j)+100e3
end
if f(i)>rloc2(j)-100e3 & f(i)<rloc2(j)+100e3
end
if f(i)>rloc3(j)-100e3 & f(i)<rloc3(j)+100e3
end
if f(i)>rloc4(j)-100e3 & f(i)<rloc4(j)+100e3
end
if f(i)>rloc5(j)-100e3 & f(i)<rloc5(j)+100e3
end
if f(i)>rloc6(j)-100e3 & f(i)<rloc6(j)+100e3
end
if f(i)>rloc7(j)-100e3 & f(i)<rloc7(j)+100e3
end
if f(i)>rloc8(j)-100e3 & f(i)<rloc8(j)+100e3
end
end
end
%conversion at 10 MHz
erpowflog=erfildflog-149.5;
erpowf=10.^(erpowflog/10);
%sum of background and interference noise power
epowf=epowf+erpowf;
%field to power: propotional to the power of wavelength
epowf=epowf.*(5e6./f).^2;
epowft=perc*epowf+nsflf;
f(1)=0;
nfilt=fir2(900,f/max(f),sqrt(epowft));
[h,w]=freqz(nfilt,1,1024);
px=[1:1024]/1024*50e6;
py=20*log10(abs(h));
plot(px(10:1024),py(10:1024),'k');
grid
xlabel('Frequency (Hz)')
ylabel('Noise Level (dBm/Hz)')```