mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
use the same packet number space for received 0-RTT and 1-RTT packets
This commit is contained in:
parent
b25b2f6921
commit
d6b50cf15a
2 changed files with 19 additions and 7 deletions
|
@ -34,7 +34,7 @@ const (
|
||||||
type receivedPacketHandler struct {
|
type receivedPacketHandler struct {
|
||||||
initialPackets *receivedPacketTracker
|
initialPackets *receivedPacketTracker
|
||||||
handshakePackets *receivedPacketTracker
|
handshakePackets *receivedPacketTracker
|
||||||
oneRTTPackets *receivedPacketTracker
|
appDataPackets *receivedPacketTracker
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ReceivedPacketHandler = &receivedPacketHandler{}
|
var _ ReceivedPacketHandler = &receivedPacketHandler{}
|
||||||
|
@ -48,7 +48,7 @@ func NewReceivedPacketHandler(
|
||||||
return &receivedPacketHandler{
|
return &receivedPacketHandler{
|
||||||
initialPackets: newReceivedPacketTracker(rttStats, logger, version),
|
initialPackets: newReceivedPacketTracker(rttStats, logger, version),
|
||||||
handshakePackets: newReceivedPacketTracker(rttStats, logger, version),
|
handshakePackets: newReceivedPacketTracker(rttStats, logger, version),
|
||||||
oneRTTPackets: newReceivedPacketTracker(rttStats, logger, version),
|
appDataPackets: newReceivedPacketTracker(rttStats, logger, version),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +63,9 @@ func (h *receivedPacketHandler) ReceivedPacket(
|
||||||
h.initialPackets.ReceivedPacket(pn, rcvTime, shouldInstigateAck)
|
h.initialPackets.ReceivedPacket(pn, rcvTime, shouldInstigateAck)
|
||||||
case protocol.EncryptionHandshake:
|
case protocol.EncryptionHandshake:
|
||||||
h.handshakePackets.ReceivedPacket(pn, rcvTime, shouldInstigateAck)
|
h.handshakePackets.ReceivedPacket(pn, rcvTime, shouldInstigateAck)
|
||||||
case protocol.Encryption1RTT:
|
case protocol.Encryption0RTT, protocol.Encryption1RTT:
|
||||||
h.oneRTTPackets.ReceivedPacket(pn, rcvTime, shouldInstigateAck)
|
// TODO: implement a check that the client doesn't switch back to 0-RTT after sending a 1-RTT packet
|
||||||
|
h.appDataPackets.ReceivedPacket(pn, rcvTime, shouldInstigateAck)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("received packet with unknown encryption level: %s", encLevel))
|
panic(fmt.Sprintf("received packet with unknown encryption level: %s", encLevel))
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ func (h *receivedPacketHandler) ReceivedPacket(
|
||||||
|
|
||||||
// only to be used with 1-RTT packets
|
// only to be used with 1-RTT packets
|
||||||
func (h *receivedPacketHandler) IgnoreBelow(pn protocol.PacketNumber) {
|
func (h *receivedPacketHandler) IgnoreBelow(pn protocol.PacketNumber) {
|
||||||
h.oneRTTPackets.IgnoreBelow(pn)
|
h.appDataPackets.IgnoreBelow(pn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *receivedPacketHandler) DropPackets(encLevel protocol.EncryptionLevel) {
|
func (h *receivedPacketHandler) DropPackets(encLevel protocol.EncryptionLevel) {
|
||||||
|
@ -94,7 +95,7 @@ func (h *receivedPacketHandler) GetAlarmTimeout() time.Time {
|
||||||
if h.handshakePackets != nil {
|
if h.handshakePackets != nil {
|
||||||
handshakeAlarm = h.handshakePackets.GetAlarmTimeout()
|
handshakeAlarm = h.handshakePackets.GetAlarmTimeout()
|
||||||
}
|
}
|
||||||
oneRTTAlarm := h.oneRTTPackets.GetAlarmTimeout()
|
oneRTTAlarm := h.appDataPackets.GetAlarmTimeout()
|
||||||
return utils.MinNonZeroTime(utils.MinNonZeroTime(initialAlarm, handshakeAlarm), oneRTTAlarm)
|
return utils.MinNonZeroTime(utils.MinNonZeroTime(initialAlarm, handshakeAlarm), oneRTTAlarm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +111,8 @@ func (h *receivedPacketHandler) GetAckFrame(encLevel protocol.EncryptionLevel) *
|
||||||
ack = h.handshakePackets.GetAckFrame()
|
ack = h.handshakePackets.GetAckFrame()
|
||||||
}
|
}
|
||||||
case protocol.Encryption1RTT:
|
case protocol.Encryption1RTT:
|
||||||
return h.oneRTTPackets.GetAckFrame()
|
// 0-RTT packets can't contain ACK frames
|
||||||
|
return h.appDataPackets.GetAckFrame()
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,16 @@ var _ = Describe("Received Packet Handler", func() {
|
||||||
Expect(oneRTTAck.DelayTime).To(BeNumerically("~", time.Second, 50*time.Millisecond))
|
Expect(oneRTTAck.DelayTime).To(BeNumerically("~", time.Second, 50*time.Millisecond))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("uses the same packet number space for 0-RTT and 1-RTT packets", func() {
|
||||||
|
sendTime := time.Now().Add(-time.Second)
|
||||||
|
handler.ReceivedPacket(2, protocol.Encryption0RTT, sendTime, true)
|
||||||
|
handler.ReceivedPacket(3, protocol.Encryption1RTT, sendTime, true)
|
||||||
|
ack := handler.GetAckFrame(protocol.Encryption1RTT)
|
||||||
|
Expect(ack).ToNot(BeNil())
|
||||||
|
Expect(ack.AckRanges).To(HaveLen(1))
|
||||||
|
Expect(ack.AckRanges[0]).To(Equal(wire.AckRange{Smallest: 2, Largest: 3}))
|
||||||
|
})
|
||||||
|
|
||||||
It("drops Initial packets", func() {
|
It("drops Initial packets", func() {
|
||||||
sendTime := time.Now().Add(-time.Second)
|
sendTime := time.Now().Add(-time.Second)
|
||||||
handler.ReceivedPacket(2, protocol.EncryptionInitial, sendTime, true)
|
handler.ReceivedPacket(2, protocol.EncryptionInitial, sendTime, true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue