APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.net.http.quic

public sealed Class PacketSpaceManager

extends Object
implements PacketSpace
permits OneRttPacketSpaceManager, HandshakePacketSpaceManager
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.quic.packets.PacketSpace
Known Direct Subclasses
jdk.internal.net.http.quic.PacketSpaceManager.OneRttPacketSpaceManager, jdk.internal.net.http.quic.PacketSpaceManager.HandshakePacketSpaceManager
Imports
java.io.IOException, java.lang.invoke.MethodHandles, .MethodHandles.Lookup, .VarHandle, java.time.Duration, java.time.temporal.ChronoUnit, java.util.ArrayList, .Iterator, .List, java.util.concurrent.CompletableFuture, .ConcurrentLinkedQueue, .ConcurrentSkipListMap, .TimeUnit, java.util.concurrent.atomic.AtomicBoolean, .AtomicLong, java.util.concurrent.locks.ReentrantLock, java.util.function.Function, .Supplier, java.util.stream.Collectors, .LongStream, jdk.internal.net.http.common.Deadline, .Log, .Logger, .MinimalFuture, .SequentialScheduler, .TimeLine, .TimeSource, .Utils, jdk.internal.net.http.quic.frames.AckFrame, .AckFrame.AckFrameBuilder, .ConnectionCloseFrame, jdk.internal.net.http.quic.packets.PacketSpace, .QuicPacket, .QuicPacket.PacketNumberSpace, .QuicPacket.PacketType, jdk.internal.net.quic.QuicKeyUnavailableException, .QuicOneRttContext, .QuicTLSEngine, .QuicTransportErrors, .QuicTransportException

A PacketSpaceManager takes care of acknowledgement and retransmission of packets for a given PacketNumberSpace.
External Specification
https://www.rfc-editor.org/info/rfc9000, https://www.rfc-editor.org/info/rfc9002

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
PacketSpaceManager.EmittedAckTracker

A class to keep track of the largest packet that was acknowledged by a packet that is being acknowledged.

private static class
pack-priv static class
pack-priv static record
PacketSpaceManager.NextAckFrame

A record that stores the next AckFrame that should be sent within this packet number space.

pack-priv static class
pack-priv class
PacketSpaceManager.PacketTransmissionTask

A task that sends packets to the peer.

private static record
PacketSpaceManager.PendingAcknowledgement

A record to store a packet that hasn't been acknowledged, and should be scheduled for retransmission if not acknowledged when the deadline is reached.

private static record
private static record
PacketSpaceManager.PreviousNumbers

A record to store previous numbers with which a packet has been retransmitted.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
private volatile boolean
private volatile boolean
pack-priv volatile boolean
private final QuicCongestionController
protected final Logger
private final Supplier<String>
private final PacketSpaceManager.EmittedAckTracker
private volatile boolean
private volatile boolean
private long
private final TimeLine
private static final long
private static final int
private volatile long
private volatile long
private volatile long
private volatile long
private volatile long
private volatile long
private volatile Deadline
private final ConcurrentLinkedQueue<PacketSpaceManager.PendingAcknowledgement>
public static final int
public static final int
private final long
private volatile PacketSpaceManager.NextAckFrame
private final AtomicLong
private final PacketEmitter
private final QuicPacket.PacketNumberSpace
private final PacketSpaceManager.PacketTransmissionTask
private volatile long
private volatile long
private final ConcurrentLinkedQueue<PacketSpaceManager.PendingAcknowledgement>
private final ConcurrentLinkedQueue<PacketSpaceManager.PingRequest>
private final ConcurrentLinkedQueue<PacketSpaceManager.PendingAcknowledgement>
private volatile CompletableFuture<Long>
private final QuicTLSEngine
private final QuicRttEstimator
private final ConcurrentSkipListMap<Long, Deadline>
public static final int
private final ReentrantLock
private final ReentrantLock
private volatile boolean
private final ConcurrentLinkedQueue<PacketSpaceManager.PendingAcknowledgement>

Constructor Summary

AccessConstructor and Description
public
PacketSpaceManager(final QuicConnectionImpl
The connection for which this manager is created.
connection
,
final QuicPacket.PacketNumberSpace
The packet number space.
packetNumberSpace
)

Creates a new PacketSpaceManager for the given packet number space.

public
PacketSpaceManager(QuicPacket.PacketNumberSpace
the packet number space.
packetNumberSpace
,
PacketEmitter
the packet emitter
packetEmitter
,
TimeLine instantSource, QuicRttEstimator rttEstimator, QuicCongestionController
the congestion controller
congestionController
,
QuicTLSEngine quicTLSEngine, Supplier<String>
a supplier for a debug tag to use for logging purposes
debugStrSupplier
)

Creates a new PacketSpaceManager for the given packet number space.

Method Summary

Modifier and TypeMethod and Description
private long
ackElicitingPacketProcessed(long packetNumber)

private void
private void
addToAckFrame(long packetNumber, boolean isAckEliciting)

public long
allocateNextPN()

Implements jdk.internal.net.http.quic.packets.PacketSpace.allocateNextPN.

Returns a new packet number atomically allocated in this space.

private void
private void
public void
close()

Implements jdk.internal.net.http.quic.packets.PacketSpace.close.

Stops retransmission for this packet space.

private Deadline
computeNewDeadlineFor(AckFrame frame, Deadline now, Deadline deadline, long packetNumber, long previousLargest, long ackDelay)

public Deadline

Returns:

the deadline at which the scheduler's task for this packet space should be scheduled to wake up
computeNextDeadline
()

Computes the next deadline for generating a non ACK eliciting packet containing the next ACK frame, or for retransmitting unacknowledged packets for which retransmission is due.

public Deadline
computeNextDeadline(boolean verbose)

public void
confirmHandshake()

Implements jdk.internal.net.http.quic.packets.PacketSpace.confirmHandshake.

Signals that the peer confirmed the handshake.

pack-priv Deadline
pack-priv void
pack-priv void
private int
detectAndRemoveLostPackets(Deadline
current time, used for time-based loss detection.
now
)

Returns the count of unacknowledged packets that were declared lost.

private long

Returns:

the packet number of the emitted packet
emitAckPacket
(AckFrame
The ACK frame to send.
ackFrame
,
boolean sendPing)

Called by the PacketTransmissionTask to generate a non ACK eliciting packet containing only the given ACK frame.

public void
fastRetransmit()

Implements jdk.internal.net.http.quic.packets.PacketSpace.fastRetransmit.

Immediately retransmit one unacknowledged initial packet

public long
getLargestPeerAckedPN()

Implements jdk.internal.net.http.quic.packets.PacketSpace.getLargestPeerAckedPN.

The largest received acked PN is used to compute the packet number that we include in an outgoing Quic packet.

public long
getLargestProcessedPN()

Implements jdk.internal.net.http.quic.packets.PacketSpace.getLargestProcessedPN.

The largest processed PN is used to compute the packet number of an incoming Quic packet.

public long
getLargestSentAckedPN()

Implements jdk.internal.net.http.quic.packets.PacketSpace.getLargestSentAckedPN.

Returns the largest packet number that we have acknowledged in this space.

private Deadline
public long

Returns:

the max delay before emitting a non ACK-eliciting packet to acknowledge a received ACK-eliciting packet, in milliseconds
getMaxAckDelay
()

Returns the max delay before emitting a non ACK-eliciting packet to acknowledge a received ACK-eliciting packet, in milliseconds.

public long
getMinPNThreshold()

Implements jdk.internal.net.http.quic.packets.PacketSpace.getMinPNThreshold.

Returns the packet number threshold below which packets should be discarded without being processed in this space.

private PacketSpaceManager.NextAckFrame
getNextAck(boolean onlyOverdue, int maxSize)

public AckFrame
getNextAckFrame(boolean onlyOverdue)

Implements jdk.internal.net.http.quic.packets.PacketSpace.getNextAckFrame.

Get the next ack frame to send.

public AckFrame
getNextAckFrame(boolean onlyOverdue, int maxSize)

Implements jdk.internal.net.http.quic.packets.PacketSpace.getNextAckFrame.

Get the next ack frame to send.

public AtomicLong
public long

Returns:

the max ACK delay of the peer, in milliseconds
getPeerMaxAckDelayMillis
()

Returns the max ACK delay of the peer, in milliseconds.

pack-priv Duration
private Deadline
pack-priv Duration
public ReentrantLock
getTransmitLock()

Implements jdk.internal.net.http.quic.packets.PacketSpace.getTransmitLock.

Returns a lock used by the transmission task.

public boolean
isAcknowledged(long packetNumber)

Implements jdk.internal.net.http.quic.packets.PacketSpace.isAcknowledged.

Returns true if a packet with that packet number is already being acknowledged (will be, or has been acknowledged).

private boolean
private boolean
public boolean
isClosed()

Implements jdk.internal.net.http.quic.packets.PacketSpace.isClosed.

Returns true if this packet space is closed.

pack-priv boolean
private boolean

Returns:

true if this packet space isn't closed and if the underlying packet emitter is open, else returns false
isOpenForTransmission
()

Returns true if this packet space isn't closed and if the underlying packet emitter is open, else returns false.

private boolean

Returns:

true if PTO timer expired, false otherwise
isPTO
(Deadline now)

Returns true if PTO timer expired, false otherwise.

private boolean
largestAckReceived(long packetNumber)

private long
largestAckSent(long packetNumber)

private synchronized void
lastAckElicitingSent(long packetNumber)

private Deadline
private static Deadline
min(Deadline one, Deadline two)

public Deadline

Returns:

the next deadline at which the scheduler's task for this packet space is currently scheduled to wake up
nextScheduledDeadline
()

Returns the next deadline at which the scheduler's task for this packet space is currently scheduled to wake up.

private Deadline
now()

public QuicPacket.PacketNumberSpace
packetNumberSpace()

Implements jdk.internal.net.http.quic.packets.PacketSpace.packetNumberSpace.

Returns the packet number space managed by this class.

private long
packetProcessed(long packetNumber)

public void
packetReceived(QuicPacket.PacketType packet, long packetNumber, boolean isAckEliciting)

Implements jdk.internal.net.http.quic.packets.PacketSpace.packetReceived.

Called when a packet is received.

public void
packetSent(QuicPacket packet, long previousPacketNumber, long packetNumber)

Implements jdk.internal.net.http.quic.packets.PacketSpace.packetSent.

Signals that a packet has been sent.

pack-priv QuicPacket.PacketType
private long
peerAckDelayToMicros(long ackDelay)

public <T> T
public <T> T
public void
private void
processPingResponses(long
the acknowledged packet number
packetNumber
)

Theoretically we should wait for the packet that contains the ping frame to be acknowledged, but if we receive the ack of a packet with a larger number, we can assume that the connection is still alive, and therefore complete the ping response.

pack-priv Deadline
private void
purgeSendTimes(long largestAcknowledged)

private void
public CompletableFuture<Long>

Returns:

a completable future that will be completed with the time it took, in milliseconds, for the peer to acknowledge the packet that contained the PingFrame (or any packet that was sent after)
requestSendPing
()

Implements jdk.internal.net.http.quic.packets.PacketSpace.requestSendPing.

Used to request sending of a ping frame, for instance, to verify that the connection is alive.

private boolean
private void
public void
retry()

Implements jdk.internal.net.http.quic.packets.PacketSpace.retry.

This method is called by QuicConnectionImpl upon reception of and successful processing of retry packet.

public void
runTransmitter()

Implements jdk.internal.net.http.quic.packets.PacketSpace.runTransmitter.

Triggers immediate run of transmit loop.

private boolean
private QuicTLSEngine.KeySpace
tlsEncryptionLevel()

returns the TLS encryption level of this packet space as specified in RFC-9001, section 4, table 1.

private boolean

Returns:

whether the given pending unacknowledged packet is being acknowledged by this ack frame.
trackAcknowlegment
(PacketSpaceManager.PendingAcknowledgement
a yet unacknowledged packet that may be acknowledged by the givenAckFrame.
pending
,
AckFrame
a received AckFrame
frame
)

Tracks the largest packet acknowledged by the packets acknowledged in the given AckFrame.

public <T> T
public void
updatePeerTransportParameters(long
the new delay, in milliseconds
peerDelay
,
long
the new ack delay exponent
ackDelayExponent
)

Implements jdk.internal.net.http.quic.packets.PacketSpace.updatePeerTransportParameters.

Changes the value of the peer max ACK delay and ack delay exponent

public void
versionChanged()

Implements jdk.internal.net.http.quic.packets.PacketSpace.versionChanged.

This method is called by QuicConnectionImpl upon reception of and successful negotiation of a new version.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait