anacrolix / anacrolix/old-go-utp

Lots of duplicate packets are being send

Abierto
#23 17 comentarios 0 reacciones 1 asignado Reclamado por @anacrolix Ver en GitHub
Lenguaje dominante
Go
Estrellas
183
Forks
37
Merge medio
59 min
PR fusionados (30 d)
1

Descripción

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?

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.