-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability for Conns to send and receive datagrams. No socket handling yet; this only functions in tests for now. Extend testConn to permit tests to send packets to Conns and observe the packets Conns send. There's a circular dependency here: We can't test Handshake and 1-RTT packets until we have the handshake implemented, but we can't implement the handshake without the ability to send and receive Handshake and 1-RTT packets. This CL adds the ability to send and receive those packets; tests for those paths will follow with the handshake implementation. For golang/go#58547 Change-Id: I4e7f88f5f039baf7e01f68a53639022866786af9 Reviewed-on: https://go-review.googlesource.com/c/net/+/509017 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
- Loading branch information
Showing
16 changed files
with
1,184 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
//go:build go1.21 | ||
|
||
package quic | ||
|
||
import "fmt" | ||
|
||
// handleAckOrLoss deals with the final fate of a packet we sent: | ||
// Either the peer acknowledges it, or we declare it lost. | ||
// | ||
// In order to handle packet loss, we must retain any information sent to the peer | ||
// until the peer has acknowledged it. | ||
// | ||
// When information is acknowledged, we can discard it. | ||
// | ||
// When information is lost, we mark it for retransmission. | ||
// See RFC 9000, Section 13.3 for a complete list of information which is retransmitted on loss. | ||
// https://www.rfc-editor.org/rfc/rfc9000#section-13.3 | ||
func (c *Conn) handleAckOrLoss(space numberSpace, sent *sentPacket, fate packetFate) { | ||
// The list of frames in a sent packet is marshaled into a buffer in the sentPacket | ||
// by the packetWriter. Unmarshal that buffer here. This code must be kept in sync with | ||
// packetWriter.append*. | ||
// | ||
// A sent packet meets its fate (acked or lost) only once, so it's okay to consume | ||
// the sentPacket's buffer here. | ||
for !sent.done() { | ||
switch f := sent.next(); f { | ||
default: | ||
panic(fmt.Sprintf("BUG: unhandled lost frame type %x", f)) | ||
case frameTypeAck: | ||
// Unlike most information, loss of an ACK frame does not trigger | ||
// retransmission. ACKs are sent in response to ack-eliciting packets, | ||
// and always contain the latest information available. | ||
// | ||
// Acknowledgement of an ACK frame may allow us to discard information | ||
// about older packets. | ||
largest := packetNumber(sent.nextInt()) | ||
if fate == packetAcked { | ||
c.acks[space].handleAck(largest) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.