anacrolix / anacrolix/old-go-utp

Lots of duplicate packets are being send

オープン
#23 コメント 17 件 リアクション 0 件 担当者 1 名 @anacrolix が担当を希望しています GitHub で見る
主要言語
Go
スター
183
フォーク
37
平均マージ
59分
マージ済み PR(30日)
1

説明

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?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。