forked from quic-go/quic-go
when forcing a retransmittable packet, bundle the PING with other frames
We're sending a retransmittable packet every 20 packets (if there are no other frames to send). To make a packet retransmittable, we add a PING frame. We should bundle this PING with an ACK.
This commit is contained in:
@@ -27,12 +27,13 @@ type packetPacker struct {
|
||||
packetNumberGenerator *packetNumberGenerator
|
||||
streamFramer *streamFramer
|
||||
|
||||
controlFrames []wire.Frame
|
||||
stopWaiting *wire.StopWaitingFrame
|
||||
ackFrame *wire.AckFrame
|
||||
leastUnacked protocol.PacketNumber
|
||||
omitConnectionID bool
|
||||
hasSentPacket bool // has the packetPacker already sent a packet
|
||||
controlFrames []wire.Frame
|
||||
stopWaiting *wire.StopWaitingFrame
|
||||
ackFrame *wire.AckFrame
|
||||
leastUnacked protocol.PacketNumber
|
||||
omitConnectionID bool
|
||||
hasSentPacket bool // has the packetPacker already sent a packet
|
||||
makeNextPacketRetransmittable bool
|
||||
}
|
||||
|
||||
func newPacketPacker(connectionID protocol.ConnectionID,
|
||||
@@ -153,6 +154,15 @@ func (p *packetPacker) PackPacket() (*packedPacket, error) {
|
||||
if len(payloadFrames) == 1 && p.stopWaiting != nil {
|
||||
return nil, nil
|
||||
}
|
||||
// check if this packet only contains an ACK and / or STOP_WAITING
|
||||
if !ackhandler.HasRetransmittableFrames(payloadFrames) {
|
||||
if p.makeNextPacketRetransmittable {
|
||||
payloadFrames = append(payloadFrames, &wire.PingFrame{})
|
||||
p.makeNextPacketRetransmittable = false
|
||||
}
|
||||
} else { // this packet already contains a retransmittable frame. No need to send a PING
|
||||
p.makeNextPacketRetransmittable = false
|
||||
}
|
||||
p.stopWaiting = nil
|
||||
p.ackFrame = nil
|
||||
|
||||
@@ -369,3 +379,7 @@ func (p *packetPacker) SetLeastUnacked(leastUnacked protocol.PacketNumber) {
|
||||
func (p *packetPacker) SetOmitConnectionID() {
|
||||
p.omitConnectionID = true
|
||||
}
|
||||
|
||||
func (p *packetPacker) MakeNextPacketRetransmittable() {
|
||||
p.makeNextPacketRetransmittable = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user