Breaking up calc for easier reading. (#402)

* WIP commit

* fix test

* More clean up

* cast to right size

* use local variable

* set a default RTT

* Do not log RTX, although need to figure out source of RTX

* fix test
This commit is contained in:
Raja Subramanian
2022-02-04 14:18:25 +05:30
committed by GitHub
parent 05c8a6b2fd
commit 4388a68b7e
6 changed files with 156 additions and 122 deletions
+5 -3
View File
@@ -26,15 +26,17 @@ func NewBucket(buf *[]byte) *Bucket {
}
}
func (b *Bucket) AddPacket(pkt []byte, sn uint16, latest bool) ([]byte, error) {
func (b *Bucket) AddPacket(pkt []byte) ([]byte, error) {
sn := binary.BigEndian.Uint16(pkt[2:4])
if !b.init {
b.headSN = sn - 1
b.init = true
}
if !latest {
diff := sn - b.headSN
if diff > (1 << 15) {
// out-of-order
return b.set(sn, pkt)
}
diff := sn - b.headSN
b.headSN = sn
for i := uint16(1); i < diff; i++ {
b.step++