# sink.useChksum(lambda x: checkPolynomialChksum(x,mycrc)) crc16 = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1] ccitt = [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] crc32 = [ 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1 ] mycrc = [1, 1, 0, 0, 0, 0, 0, 0, 1] source.useChksum(IPChksum) sink.useChksum(checkIPChksum) # Set the error model of the link # You may use uniform or bernoulli errors: # badlink.errorModel('uniform',0,10): 0 to 10 bits may be modified, and all # numbers of bit errors are equally likely #badlink.errorModel('bernoulli',0.001): Independent bit errors with a BER=0.001 badlink.errorModel('bernoulli', 0.07) # =========================================================================== # Run the simulation def printErrors(a, b, c=None): print a, b, c REGISTER_LISTENER("undetected errors", printErrors) source.start() RUN(1000)
# - doubleParityChksum and checkDoubleParityChksum # - polynomialChksum and checkDoubleParityChksum. # For the polynomialChksum, you have to provide a polynomial in the form # of the list of coefficients. To use the polynomial x**8 + x**2 + 1 do e.g.: # mycrc = [1,0,0,0,0,0,1,0,1] # source.useChksum(lambda x: polynomialChksum(x,mycrc)) and # sink.useChksum(lambda x: checkPolynomialChksum(x,mycrc)) crc16 = [1, 1,0,0,0,0,0,0,0, 0,0,0,0,0,1,0,1] ccitt = [1, 0,0,0,1,0,0,0,0, 0,0,1,0,0,0,0,1] crc32 = [1, 0,0,0,0,0,1,0,0, 1,1,0,0,0,0,0,1, 0,0,0,1,1,1,0,1, 1,0,1,1,0,1,1,1] mycrc = [1,1,0,0,0,0,0,0,1] source.useChksum(IPChksum) sink.useChksum(checkIPChksum) # Set the error model of the link # You may use uniform or bernoulli errors: # badlink.errorModel('uniform',0,10): 0 to 10 bits may be modified, and all # numbers of bit errors are equally likely #badlink.errorModel('bernoulli',0.001): Independent bit errors with a BER=0.001 badlink.errorModel('bernoulli', 0.07) # =========================================================================== # Run the simulation def printErrors(a,b,c=None): print a,b,c REGISTER_LISTENER("undetected errors", printErrors) source.start() RUN(1000)
# Set the data rate of the link interfaces (in bits/s) dataRate = 1e6 h1.eth0.phy.setDataRate(dataRate) h2.eth0.phy.setDataRate(dataRate) # Set the propagation delay of the link. # The link is 1000 km long and we cannot easily change this. # But we can adapt the signal speed to obtain the required propagation delay. propDelay = 0.01 # in seconds link.signalSpeed = 1000000.0 / propDelay # Set the error model of the link # Use the bernoulli error model with the required Bit Error Rate. # A BER of 0.0 gives an error free link, of course. BER = 0.0001 link.errorModel('bernoulli', BER) # ARQ STRATEGIES (Data link layer) # ------------------------------- # Set the retransmission timeout timeout = 0.021 h1.eth0.dl.retransmissionTimeout = timeout h2.eth0.dl.retransmissionTimeout = timeout # Set the sliding window size (Only for GoBackNDL, and SelectiveRepeatDL) window = 1 #h1.eth0.dl.setWindowSize(window) #h2.eth0.dl.setWindowSize(window) # =========================================================================== # Run the simulation