Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve packet loss calc #1264

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions bits.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,32 @@ func (b *Bits) Update(l *logrus.Logger, i uint64) bool {
return true
}

// If i packet is greater than current but less than the maximum length of our bitmap,
// flip everything in between to false and move ahead.
if i > b.current && i < b.current+b.length {
// In between current and i need to be zero'd to allow those packets to come in later
for n := b.current + 1; n < i; n++ {
b.bits[n%b.length] = false
// If i packet is greater than current but less than the maximum length of our bitmap,
// flip everything in between to false and move ahead.
if i > b.current && i < b.current+b.length {
// Check and count packet loss for bits that are already false.
for n := b.current + 1; n < i; n++ {
if !b.bits[n%b.length] {
// Increment the lostCounter for each already-false bit.
b.lostCounter.Inc(1)
}
// Set the bit to false to indicate missing packets.
b.bits[n%b.length] = false
}

b.bits[i%b.length] = true
b.current = i
//l.Debugf("missed %d packets between %d and %d\n", i-b.current, i, b.current)
return true
}
// Mark the current packet as received.
b.bits[i%b.length] = true
b.current = i

// Uncomment this line if you want to log the number of missed packets.
// l.Debugf("missed %d packets between %d and %d\n", i-b.current, i, b.current)
return true
}

// If i is greater than the delta between current and the total length of our bitmap,
// just flip everything in the map and move ahead.
if i >= b.current+b.length {
// The current window loss will be accounted for later, only record the jump as loss up until then
// The current window loss will be accounted for later, only record the jump as loss up until then
lost := maxInt64(0, int64(i-b.current-b.length))
//TODO: explain this
if b.current == 0 {
Expand Down
Loading