In [19]:
%pylab inline
from random import gauss, uniform
alpha = .125
EstimatedRTT = 1.0
samples = []
estimates = []
for i in range(100):
SampleRTT = uniform(-0.5,.5) + 1.5
EstimatedRTT = (1.0-alpha) * EstimatedRTT + alpha * SampleRTT
samples.append(SampleRTT)
estimates.append(EstimatedRTT)
In [20]:
plot(range(100), samples,range(100),estimates)
Out[20]:
In [22]:
alpha = .125
beta = 0.25
EstimatedRTT = 1.0
DevRTT = 0.0
samples = []
estimates = []
tointervals = []
for i in range(100):
SampleRTT = uniform(-0.5,.5) + 1.5
EstimatedRTT = (1.0-alpha) * EstimatedRTT + alpha * SampleRTT
DevRTT = (1-beta) * DevRTT + beta * abs(SampleRTT-EstimatedRTT)
TimeoutInterval = EstimatedRTT + 4 * DevRTT
samples.append(SampleRTT)
estimates.append(EstimatedRTT)
tointervals.append(TimeoutInterval)
plot(range(100), samples,range(100),estimates,range(100),tointervals)
Out[22]:
In [ ]: