import math
#variable declaration
system_margin = 6 # (dB)
alpha = 3.5 #attenuation (dB/Km)
L =6 #Length of transmission path (Km)
lc = 1 #connector loss (dB)
#calculation
PT = 2*lc+alpha*L+system_margin #total optical power loss(dB)
#result
print "Total optical power loss = " , round(PT) ,"dB"
import math
#variable declaration
Ps = 3 #laser output (dBm)
APD_sen = -32 #APD sensitivity (dBm)
lsc = 1 #source connectorloss (dB)
ljc = 2*4 #two (jumper+connector loss) (dB)
alpha = 0.3 #attenuation (dB/Km)
L = 60 #cable length (Km)
cable_att = alpha*60 #cable attenuation (dB)
lrc = 1 #receiver connector loss (dB)
#calculation
Allowed_Loss = Ps-APD_sen # (dB)
system_margin = Allowed_Loss-lsc-ljc-cable_att-lrc #system margin(dB)
#result
print "Allowed loss between light source and photodetector = ",Allowed_Loss,"dB"
print "The Final power margin = " , round(system_margin) , "dB"
import math
#variable declaration
t_tx = 15*10**-9 #transmitter rise time(ns)
t_mat = 21*10**-9 #material dispersion related rise time(ns)
t_mod = 3.9*10**-9 #rise time resulting from modal dispersion(ns)
t_rx = 14*10**-9 #receiver rise time(ns)
#calculation
tsys = math.sqrt(t_tx**2+t_mat**2+t_mod**2+t_rx**2) #link rise time(ns)
#result
print "Link rise time = " , round(tsys*10**9),"ns"
import math
#variable declaration
t_tx = 25*10**-12 #transmission rise time (sec)
t_GVD = 12*10**-12 #GVD rise time (sec)
t_rx = 0.14*10**-9 #receiver rise time (sec)
#calculation
tsys = math.sqrt(t_tx**2+t_GVD**2+t_rx**2) #Link rise time(ns)
#result
print "System rise time = " , round(tsys*10**9,2) , "ns"
import math
#variable declaration
bit_error_dur = 1*10**-3 #bit-corrupting burst noise duration (ms)
B = 10*10**3 #data rate (kb/sec)
#calculation
N = B*bit_error_dur #number of bits affected by by burst error (MB/s)
#result
print "Number of bits affected by a burst error = " , round(N) , "Mb/s"
import math
#variable declaration
x=1
#calculation
polynomial = str(x**7)+"0"+str(x**5)+"0"+"0"+str(x**2)+str(x)+"1" #generator polynommial
#result
print "The generator polynomial to 8-bit binary represantation = ",polynomial
import math
#variable declaration
N = 32.0 #number of CRC
#calculation
Ped = 1.0-(1.0/(2.0**N)) #burst error
#result
print "Burst error detected by CRC = " , round(Ped*100,8), "%"
import math
#variable declaration
S = 8 #Reed-Solomon code with 1 byte
n = (2**S-1) #length of coded sequence
k = 239.0 #length of message sequence
#calculation
r = n-k #number of redundent bytes
over_head = (r/k) #overhead %
#result
print "Number of redundent bytes r = " ,round(r),"bytes"
print "Percent overhead = " , round(over_head*100) , "%"