Skip to content

Commit

Permalink
#3851 ping frame added in initial packet when size greater than 1 MTU
Browse files Browse the repository at this point in the history
  • Loading branch information
SahibYar committed Jul 2, 2023
1 parent f4eda47 commit ca32299
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packet_packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,14 @@ func (p *packetPacker) PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.
initialHdr, initialPayload = p.maybeGetCryptoPacket(maxPacketSize-protocol.ByteCount(initialSealer.Overhead()), protocol.EncryptionInitial, onlyAck, true, v)
if initialPayload.length > 0 {
size += p.longHeaderPacketLength(initialHdr, initialPayload, v) + protocol.ByteCount(initialSealer.Overhead())

if size >= maxPacketSize-protocol.MinCoalescedPacketSize {
ping := ackhandler.Frame{Frame: &wire.PingFrame{}}
initialPayload.frames = append(initialPayload.frames, ping)
initialPayload.length += ping.Frame.Length(v)
}
}
}

// Add a Handshake packet.
var handshakeSealer sealer
if (onlyAck && size == 0) || (!onlyAck && size < maxPacketSize-protocol.MinCoalescedPacketSize) {
Expand Down

0 comments on commit ca32299

Please sign in to comment.