diff --git a/frame.go b/frame.go index 1980bf1..1240f79 100644 --- a/frame.go +++ b/frame.go @@ -11,6 +11,7 @@ const ( ethHdrLen = 14 hdrLen = 20 hdrMagic = 0x43424c54 + hdrVer = 1 minFrame = ethHdrLen + hdrLen maxFrame = 9216 @@ -138,7 +139,7 @@ func headerCheck(h []byte) uint16 { func putHeader(buf []byte, patIdx int, stream uint16, seq uint64, payLen int) { h := buf[ethHdrLen:] binary.BigEndian.PutUint32(h[0:4], hdrMagic) - h[4] = 1 + h[4] = hdrVer h[5] = byte(patIdx) binary.BigEndian.PutUint16(h[6:8], stream) binary.BigEndian.PutUint64(h[8:16], seq) @@ -176,6 +177,11 @@ func parseHeader(buf []byte) (parsed, hdrStatus) { if binary.BigEndian.Uint16(h[hdrCheckOff:]) != headerCheck(h) { return p, hdrDamaged } + // Both halves are the same build, so the only way this differs is a checksum + // that happened to agree over damaged bytes. + if h[4] != hdrVer { + return p, hdrDamaged + } p.patIdx = int(h[5]) p.stream = binary.BigEndian.Uint16(h[6:8]) p.seq = binary.BigEndian.Uint64(h[8:16]) diff --git a/main.go b/main.go index 37eeb3f..09cf1c7 100644 --- a/main.go +++ b/main.go @@ -541,8 +541,8 @@ const ( // Deliberately not tied to the refresh: letting a slow or blocked draw set // the sampling clock would stretch the window it reports. sampleInterval = 16 * time.Millisecond - // How far back the shown errors reach and how many buckets the median runs - // over, so a step in the rate lands half this late. + // How far back the shown errors reach. The rate is not taken from this ring + // but from the receive buckets, which are keyed by the mac's clock. rateWindowSpan = time.Second )