Skip to content

Commit

Permalink
fix: Grafana dashboard shows negative packet loss
Browse files Browse the repository at this point in the history
  • Loading branch information
clambin committed Aug 14, 2021
1 parent 8d96f19 commit 56f4c7d
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions pingtracker/pingtracker.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pingtracker

import (
log "github.com/sirupsen/logrus"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -74,8 +73,6 @@ func (tracker *PingTracker) calculateLoss() (gap int) {
index++
}

startingNextExpectedSequenceNumber := tracker.NextSeqNr

// pre-rollover / no rollover
gap = tracker.processRange(tracker.seqNrs[index:])

Expand All @@ -84,13 +81,6 @@ func (tracker *PingTracker) calculateLoss() (gap int) {
gap += tracker.processRange(tracker.seqNrs[:index])
}

if gap < 0 {
log.WithFields(log.Fields{
"sequenceNrs": tracker.seqNrs,
"nextExpected": startingNextExpectedSequenceNumber,
}).Warning("negative gap found")
}

return
}

Expand All @@ -114,8 +104,7 @@ func (tracker *PingTracker) processRange(sequence []int) (gap int) {

index := 0
// skip older packets
for index < count && sequence[index] < tracker.NextSeqNr {
index++
for ; index < count && sequence[index] < tracker.NextSeqNr; index++ {
}

for ; index < count; index++ {
Expand Down

0 comments on commit 56f4c7d

Please sign in to comment.