#!/usr/bin/env python # Round Trip Time -> Smoothed RTT -> # -> Retransmission Timeout (RTO) Simulation # See RFC 793 http://www.faqs.org/rfcs/rfc793.html import random import pylab alpha = 0.8 beta = 2.0 ubound = 20.0 lbound = 10.0 rtt = [random.randrange(2,10) for i in range(100)] srtt = [0.0] for i in range(1,100): srtt.append(alpha * srtt[i-1] + ((1 - alpha) * rtt[i])) rto = [min(ubound, max(lbound, beta*srtt[i])) for i in range(100)] pylab.plot(rtt) pylab.plot(srtt) pylab.plot(rto) pylab.show()