anacrolix / anacrolix/old-go-utp

Lots of duplicate packets are being send

Offen
#23 17 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @anacrolix Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
183
Forks
37
Ø Merge
59 Min.
Gemergte PRs (30 T.)
1

Beschreibung

I am trying to hunt down an issue I have with this library where I notice that the uTP transfer does not back-off when there is TCP background traffic.

Tracing this issue I noticed that an extensive number of packets are being resend. I noticed this was primarily due to [this call to `resend`](https://github.com/anacrolix/utp/blob/master/conn.go#L322) which is caused by [this call to `ackSkipped`](https://github.com/anacrolix/utp/blob/master/conn.go#L410). Using wireshark I noticed that lots of ACK packets do have the `Selective ACKs` extension enabled but do not have an extension bitmask:

![screen shot 2017-05-30 at 15 14 07](https://cloud.githubusercontent.com/assets/795579/26585190/b647dc2e-454b-11e7-85fc-c63d68e9f61e.png)

According to the specification the length should be:

> Note that the len field of extensions refer to bytes, which in this extension must be at least 4, and in multiples of 4.

There are also ACK packets that do have this set correctly:

![screen shot 2017-05-30 at 15 13 23](https://cloud.githubusercontent.com/assets/795579/26585211/c404a54a-454b-11e7-9c31-f1268a386e1b.png)

Now as a quick hack I've tried not calling `ackSkipped` when there are no bytes in the extension:

```go
switch ext.Type {
case extensionTypeSelectiveAck:
if len(ext.Bytes) > 0 {
c.ackSkipped(h.AckNr + 1)
bitmask := selectiveAckBitmask{ext.Bytes}
for i := 0; i < bitmask.NumBits(); i++ {
if bitmask.BitIsSet(i) {
nr := h.AckNr + 2 + uint16(i)
c.ack(nr)
} else {
c.ackSkipped(h.AckNr + 2 + uint16(i))
}
}
}
}
```

and I've also changed `ackSkipped` to not resend the packets that often:

```golang
switch send.acksSkipped {
case 60, 120: // was 3, 60
if logLevel >= 1 {
log.Printf("acksSkipped = %d", send.acksSkipped)
}
ackSkippedResends.Add(1)
send.resend()
send.resendTimer.Reset(c.resendTimeout() * time.Duration(send.numResends))
default:
}
```

For me this is dramatically decreasing the number of duplicates that are being send.

However it does not fix my issue with uTP traffic throttling back when there is TCP background traffic.

Does this make sense?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.