import math
#Variable declaration
Fl=902; #lower limit frequency MHz
Fh=928; #higher limit frequency in MHz
Rt=0.5; #symbol transmission rate in Mega symbols per sec
S=16; #No of symbols
BER=10**-5;#Bir error rate
SG=2.6;#sector gain
B=0.5; #Interference factor
a=0.9; #power control efficiency
#Calculations&Results
BW=Fh-Fl;
Rb=Rt*math.log(S,2);
Gp=BW/Rb;
Eb_by_No=10 #dB
M = (Gp*a*SG)/(Eb_by_No*(1+B))
print 'Number of users that can be supported by the WLAN are %d'%M
eff=Rb*int(M)/BW;
print 'The bandwidth efficiency is %.2f bps/Hz'%eff
#Variable declaration
Stepsize=200.; #in Hz
Chipsmin=20.;#length of linear feedback shift register
Datarate=1.2*10**3; #bps
#Calculations
No_of_tones=2**Chipsmin;
Bss=No_of_tones*Stepsize;
Chiprate=Datarate*Chipsmin;
Gp=Bss/Datarate;#processing gain
Symbolrate=Datarate/3; #8-ary FSK is used
Chips_symbol=Chiprate/Symbolrate;
#Results
print 'The Hopping Bandwidth is %.3f MHz'%(Bss/10**6);
print 'The chiprate is %d kchip/sec'%(Chiprate/10**3);
print 'Chips per symbol are %d'%(Chips_symbol);
print 'The processing gain is %.1f'%Gp
#Variable declaration
InfoSc=48.;#Information subcarriers
SyncSc=4.;#synchronization subcarriers
ReservedSc=12.;#Reserved subcarriers
Symrate=250.; #ksps(kilosymbols per second)
BW=20.; #/in MHz
Grdt=800.; #Guard time in nsec
#Calculations
TotalSc=InfoSc+SyncSc+ReservedSc;#Total subcarriers
BW_Sch=BW*10**6/TotalSc;#BW of subchannel
Mod_eff=Symrate*10**3/(BW_Sch);#Modulation efficiency
User_txrate=InfoSc*Symrate*10**3;
User_bitsymbol=4; #16-QPSK is used
User_DR=36; #Mbps
Sym_Dur=1./(Symrate*10**3);
TimeUti=Sym_Dur/(Sym_Dur+(Grdt/10**9));
#Results
print 'The bandwidth of subchannel is %.1f kHz'%(BW_Sch/10**3);
print 'Modulation efficiency is %.1f symbols/sec/Hz'%Mod_eff
print 'User symbol rate is %d Msps'%(User_txrate/10**6);
print 'Time Utilization efficiency is %.2f'%TimeUti
import math
#Variable declaration
Eb_No=10; #in dB
Noise=-120; #in dBm
Pt=20; #in mwatt
R=1; #Data rate in Mbps
CHBW=0.5; #BW in MHz
A=37.7; #path loss at the first meter in dB
Y=3.3; #path loss exponent
Lf=19; #function relating power loss with number of floors n (in dB)
Ls=10; # lognormally distributed random variable representing the shadow effect in dB
#Calculations
S2Nreqd=Eb_No*R/CHBW;
Rx_sensi=Noise+S2Nreqd;
Lp=10*math.log10(20)-Rx_sensi;
#Lp=A+10Ylod(d)+Lf+Ls;therefore
d=10**((Lp-A-Lf-Ls)/(10*Y));
#Result
print 'The coverage of AP is %.1f metres'%d;
#Variable declaration
R=3./4;#code rate of convolution encoder
M1=9.; #payload transmission rate in Mbps for mode 1
M2=36.; #payload transmission rate in Mbps for mode 2
#Calculations&Results
D1=M1*10**6/48;#user data rate in kbps for mode 1
D2=M2*10**6/48;#user data rate in kbps for mode 2
#Refering to Table 21.11
print 'Data transmission rate per carrier with 3/4 convolution encoder are %.1f Kbps and %d Kbps'%(D1/10**3,D2/10**3);
C1=D1/R;
C2=D2/R;
print 'Carrier transmission rate with R=3/4 convolutional encoder are %d Kbps and %d Kbps'%(C1/10**3,C2/10**3);
print 'Carrier symbol rate with R=3/4 convolutional encoder are %d ksps and %d Ksps'%(C1/10**3,C2/4/10**3); #Mode1 as BPSK and MOde2 as 16-QAM
import math
#Variable declaration
R=3./4; #code rate for convolution encoder
#Calculations
#64-QAM modulation is used
Sc=250; #Carrier symbol rate(ksps) from Exa 21.5
Bits_sym=math.log(64,2); #64-QAM is used
User_R=Bits_sym*Sc*10**3*R*48;
#Result
print 'The user data rate is %d Mbps'%(User_R/10**6);
#Variable declaration
D=1000.*8; #packet size in bits
R=2.*10**6; #transmission rate in bps
L=3.; #msec(Dwell time)
H=0.625; #msec(Duration of BT packet)
#Calculations
Tw=10**3*D/R; #the packet duration of IEEE 802.11 in msec
H_L=1.;
G=(H_L)*L-Tw-H;
Gm=abs(G);
PER_FH=1-((1-Gm/L)*(78./79)**(H_L)+Gm/L*(78./79)**((H_L)-G/Gm));
PER_DS=1-((1-Gm/L)*(57./79)**(H_L)+Gm/L*(57./79)**((H_L)-G/Gm));
#Results
print 'The PER for FH packet and PER for DS packet are %d percent & %.2f percent respectively'%(round(PER_FH*100),PER_DS*100);
print "The collision probability with 802.11 DS is much higher than with 802.11 FH."
import math
#Variable declaration
d=10; # distance between AP and IEEE 802.11 device in metres
Y=4; #path loss exponent
PBt=20; #the transmitted power by the BT in dBm
PAp=40; #the transmitted power by the AP in dBm
Pe=10**-5;#acceptable error probability
#Calculations
#Pe=0.5*e**(-0.5*Eb/No)
SIR=math.log(Pe/0.5)/(-0.5);# signal-to-interference ratio
rmax=d*(SIR*PBt/PAp)**(1./Y);# range of interference between Bluetooth and 802.11 device
#Results
print 'Minimum SIR is %.2f dB = %.1f'%(10*math.log10(SIR),SIR);
print 'Maximum coverage range is %.2f metres'%rmax;
#Variable declaration
SIRmin=21.6; #From eg 21.8 i.e(13.36 dB)
d=10; #distance between AP and IEEE 802.11 device in m
PMs=40; # transmitted power of the IEEE 802.11 device in dBm
PBt=20; #the transmitted power by the BT in dBm
Y=4 ; #path loss exponent
#Calculations
rmax=d*(SIRmin*PMs/PBt)**(1./Y);
#Result
print 'Maximum coverage range is %.1f metres'%rmax
import math
#Variable declaration
Gp=11;#processing gain(given)
#Defining variables from Exa 21.8 & 21.9
PBt=20; # transmitted power by the BT in dBm
PMs=40; # transmitted power of the IEEE 802.11 device in dBm
PAp=40; # transmitted power by the AP in dBm
d=10; # distance between AP and IEEE 802.11 device in m
Y=4; #path loss exponent
Pe=10**-5;#Error probability
#Calculations&Results
#Pe=0.5*e**(-0.5*Eb/No)
SIR=math.log(Pe/0.5)/(-0.5);
r1max=d*(SIR*PBt/(PAp*Gp))**(1./Y);# range of interference between Bluetooth and 802.11 device
print 'Maximum coverage range for IEEE 802.11 DS is %.2f metres'%r1max
r2max=d*(SIR*PMs/(PBt*Gp))**(1./Y);
print 'Maximum coverage range for IEEE 802.11 FH is %.2f metres'%r2max;
print "Thus, the interference ranges are smaller for the IEEE 802.11 DS device than the IEEE 802.11 FH device."