Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3851 ping frame added in handshake #3935

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packet_packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,15 @@ func (p *packetPacker) PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.
if initialPayload.length > 0 {
size += p.longHeaderPacketLength(initialHdr, initialPayload, v) + protocol.ByteCount(initialSealer.Overhead())
}
}

// Add a PING frame to Initial packets, if they don't contain any other frames.
// This is not strictly necessary, but it helps speed up the handshake.
if !onlyAck && len(initialPayload.frames) == 0 && initialPayload.ack != nil {
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