mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-07 06:07:36 +03:00
fix flaky 0-RTT packet loss recovery test (#4306)
This commit is contained in:
parent
198de32ef6
commit
dc49f5673b
1 changed files with 8 additions and 18 deletions
|
@ -5,7 +5,6 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
mrand "math/rand"
|
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
@ -380,7 +379,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("transfers 0-RTT data, when 0-RTT packets are lost", func() {
|
It("transfers 0-RTT data, when 0-RTT packets are lost", func() {
|
||||||
var num0RTTPackets, num0RTTDropped atomic.Uint32
|
var num0RTTPackets, numDropped atomic.Uint32
|
||||||
|
|
||||||
tlsConf := getTLSConfig()
|
tlsConf := getTLSConfig()
|
||||||
clientConf := getTLSClientConfig()
|
clientConf := getTLSClientConfig()
|
||||||
|
@ -399,17 +398,8 @@ var _ = Describe("0-RTT", func() {
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
|
|
||||||
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
|
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
|
||||||
RemoteAddr: fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
RemoteAddr: fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
||||||
DelayPacket: func(_ quicproxy.Direction, data []byte) time.Duration {
|
DelayPacket: func(_ quicproxy.Direction, data []byte) time.Duration { return rtt / 2 },
|
||||||
if wire.IsLongHeaderPacket(data[0]) {
|
|
||||||
hdr, _, _, err := wire.ParsePacket(data)
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
if hdr.Type == protocol.PacketType0RTT {
|
|
||||||
num0RTTPackets.Add(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rtt / 2
|
|
||||||
},
|
|
||||||
DropPacket: func(_ quicproxy.Direction, data []byte) bool {
|
DropPacket: func(_ quicproxy.Direction, data []byte) bool {
|
||||||
if !wire.IsLongHeaderPacket(data[0]) {
|
if !wire.IsLongHeaderPacket(data[0]) {
|
||||||
return false
|
return false
|
||||||
|
@ -417,10 +407,11 @@ var _ = Describe("0-RTT", func() {
|
||||||
hdr, _, _, err := wire.ParsePacket(data)
|
hdr, _, _, err := wire.ParsePacket(data)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
if hdr.Type == protocol.PacketType0RTT {
|
if hdr.Type == protocol.PacketType0RTT {
|
||||||
|
count := num0RTTPackets.Add(1)
|
||||||
// drop 25% of the 0-RTT packets
|
// drop 25% of the 0-RTT packets
|
||||||
drop := mrand.Intn(4) == 0
|
drop := count%4 == 0
|
||||||
if drop {
|
if drop {
|
||||||
num0RTTDropped.Add(1)
|
numDropped.Add(1)
|
||||||
}
|
}
|
||||||
return drop
|
return drop
|
||||||
}
|
}
|
||||||
|
@ -433,9 +424,8 @@ var _ = Describe("0-RTT", func() {
|
||||||
transfer0RTTData(ln, proxy.LocalPort(), protocol.DefaultConnectionIDLength, clientConf, nil, PRData)
|
transfer0RTTData(ln, proxy.LocalPort(), protocol.DefaultConnectionIDLength, clientConf, nil, PRData)
|
||||||
|
|
||||||
num0RTT := num0RTTPackets.Load()
|
num0RTT := num0RTTPackets.Load()
|
||||||
numDropped := num0RTTDropped.Load()
|
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets. Dropped %d of those.", num0RTT, numDropped.Load())
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets. Dropped %d of those.", num0RTT, numDropped)
|
Expect(numDropped.Load()).ToNot(BeZero())
|
||||||
Expect(numDropped).ToNot(BeZero())
|
|
||||||
Expect(num0RTT).ToNot(BeZero())
|
Expect(num0RTT).ToNot(BeZero())
|
||||||
Expect(get0RTTPackets(counter.getRcvdLongHeaderPackets())).ToNot(BeEmpty())
|
Expect(get0RTTPackets(counter.getRcvdLongHeaderPackets())).ToNot(BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue