Check the header version on arrival and say what the error window actually spans

This commit is contained in:
flamingcow
2026-08-04 21:29:03 -07:00
parent 49de171ad0
commit 01d673dc83
2 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -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])
+2 -2
View File
@@ -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
)