Index: trunk/udpmcast/htcpseqcheck.py |
— | — | @@ -31,6 +31,8 @@ |
32 | 32 | Implements TCP window like behavior |
33 | 33 | """ |
34 | 34 | |
| 35 | + RESTART_WINDOW = 10 |
| 36 | + |
35 | 37 | def __init__(self, iterable=[], maxlen=None, buffersize=timedelta(seconds=5)): |
36 | 38 | self.counts = Counter() |
37 | 39 | self.buffersize = buffersize |
— | — | @@ -64,7 +66,16 @@ |
65 | 67 | self.append((seqnr, ts, True)) |
66 | 68 | debug("Filled gap of %d packets before new packet seqnr %d, timestamp %s" % (seqnr-tailseq-1, seqnr, ts)) |
67 | 69 | 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 |
69 | 80 | elif seqnr <= tailseq: |
70 | 81 | # Late packet |
71 | 82 | assert self[seqnr-headseq][0] == seqnr # Incorrect seqnr? |
— | — | @@ -139,22 +150,24 @@ |
140 | 151 | print "Ancient packet from %s, id %d" % (srcaddr, transid) |
141 | 152 | |
142 | 153 | 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" % ( |
144 | 155 | sb.counts['lost'], |
145 | 156 | sb.counts['dequeued'], |
146 | 157 | float(sb.counts['lost'])*100/sb.counts['dequeued'], |
147 | 158 | sb.counts['outoforder'], |
148 | 159 | sb.counts['dups'], |
149 | 160 | sb.counts['ancient'], |
| 161 | + sb.counts['restarts'], |
150 | 162 | sb.counts['received'], |
151 | 163 | 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" % ( |
153 | 165 | slidingcounts['lost'], |
154 | 166 | slidingcounts['dequeued'], |
155 | 167 | float(slidingcounts['lost'])*100/slidingcounts['dequeued'], |
156 | 168 | totalcounts['outoforder'], |
157 | 169 | totalcounts['dups'], |
158 | 170 | totalcounts['ancient'], |
| 171 | + totalcounts['restarts'], |
159 | 172 | totalcounts['received'], |
160 | 173 | len(sourcebuf.keys())) |
161 | 174 | |