// If i is the next number, return true and update current.
ifi==b.current+1{
// Report missed packets, we can only understand what was missed after the first window has been gone through
ifi>b.length&&b.bits[i%b.length]==false{
b.lostCounter.Inc(1)
}
b.bits[i%b.length]=true
b.current=i
returntrue
}
// 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.
ifi>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
forn:=b.current+1;n<i;n++{
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)
returntrue
}
// 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.
ifi>=b.current+b.length{
// 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
ifb.current==0{
lost++
}
forn:=rangeb.bits{
// Don't want to count the first window as a loss
//TODO: this is likely wrong, we are wanting to track only the bit slots that we aren't going to track anymore and this is marking everything as missed