Skip to content

Commit

Permalink
fix: check if repeated packet is all stuffing
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbee committed Aug 29, 2024
1 parent 945c81e commit 7362170
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cmd/pcap-replay/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,28 @@ func (u *udpHandler) AddPacket(dst string, udpPayload []byte, timestamp time.Tim
u.outfiles[dst] = fh
}
}
if bytes.Equal(udpPayload, u.lastPayload) {
extraBytes := len(udpPayload) % 188
if extraBytes == 0 && bytes.Equal(udpPayload, u.lastPayload) {
if u.firstSame == -1 {
u.firstSame = u.pktNr
}
u.nrRepeatedPkts++
u.pktNr++
return
allStuffing := true
for offset := 0; offset < len(udpPayload); offset += tsPacketSize {
pid := (uint16(udpPayload[offset+1]&0x1f) << 8) + uint16(udpPayload[offset+2])
if pid != 8191 {
allStuffing = false
break
}
}
if !allStuffing {
u.nrRepeatedPkts++
u.pktNr++
return
}
}
u.firstSame = -1

ok = true
extraBytes := len(udpPayload) % 188
switch extraBytes {
case 0: // One or more TS packets
// Do nothing
Expand Down

0 comments on commit 7362170

Please sign in to comment.