r94241 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94240‎ | r94241 | r94242 >
Date:13:38, 11 August 2011
Author:mark
Status:deferred
Tags:
Comment:
Account for transid restarts and counter wraps
Modified paths:
  • /trunk/udpmcast/htcpseqcheck.py (modified) (history)

Diff [purge]

Index: trunk/udpmcast/htcpseqcheck.py
@@ -31,6 +31,8 @@
3232 Implements TCP window like behavior
3333 """
3434
 35+ RESTART_WINDOW = 10
 36+
3537 def __init__(self, iterable=[], maxlen=None, buffersize=timedelta(seconds=5)):
3638 self.counts = Counter()
3739 self.buffersize = buffersize
@@ -64,7 +66,16 @@
6567 self.append((seqnr, ts, True))
6668 debug("Filled gap of %d packets before new packet seqnr %d, timestamp %s" % (seqnr-tailseq-1, seqnr, ts))
6769 elif seqnr < headseq:
68 - counts['ancient'] += 1
 70+ if seqnr < RESTART_WINDOW:
 71+ debug("Source %s started from scratch with seqnr %d" % (seqnr, ts))
 72+ self.clear()
 73+ # Clear some counters
 74+ for c in ['dequeued', 'lost', 'dups', 'outoforder', 'ancient']:
 75+ self.counts[c] = 0
 76+ counts['restarts'] += 1
 77+ self.append((seqnr, ts, True))
 78+ else:
 79+ counts['ancient'] += 1
6980 elif seqnr <= tailseq:
7081 # Late packet
7182 assert self[seqnr-headseq][0] == seqnr # Incorrect seqnr?
@@ -139,22 +150,24 @@
140151 print "Ancient packet from %s, id %d" % (srcaddr, transid)
141152
142153 if counts['lost'] and sb.counts['dequeued']:
143 - print "%d/%d losses (%.2f%%), %d out-of-order, %d dups, %d ancient, %d received from %s" % (
 154+ print "%d/%d losses (%.2f%%), %d out-of-order, %d dups, %d ancient, %d restarts, %d received from %s" % (
144155 sb.counts['lost'],
145156 sb.counts['dequeued'],
146157 float(sb.counts['lost'])*100/sb.counts['dequeued'],
147158 sb.counts['outoforder'],
148159 sb.counts['dups'],
149160 sb.counts['ancient'],
 161+ sb.counts['restarts'],
150162 sb.counts['received'],
151163 srcaddr)
152 - print "Totals: %d/%d losses (%.2f%%), %d out-of-order, %d dups, %d ancient, %d received from %d sources" % (
 164+ print "Totals: %d/%d losses (%.2f%%), %d out-of-order, %d dups, %d ancient, %d restarts, %d received from %d sources" % (
153165 slidingcounts['lost'],
154166 slidingcounts['dequeued'],
155167 float(slidingcounts['lost'])*100/slidingcounts['dequeued'],
156168 totalcounts['outoforder'],
157169 totalcounts['dups'],
158170 totalcounts['ancient'],
 171+ totalcounts['restarts'],
159172 totalcounts['received'],
160173 len(sourcebuf.keys()))
161174

Status & tagging log