APIdia Launch Partner
Top Description Methods
jdk.internal.net.http.quic.packets

public sealed Interface PacketSpace

permits PacketSpaceManager
Known Direct Implementers
jdk.internal.net.http.quic.PacketSpaceManager
Imports
java.util.concurrent.CompletableFuture, java.util.concurrent.locks.ReentrantLock, jdk.internal.net.http.quic.QuicConnectionImpl, .PacketSpaceManager, jdk.internal.net.http.quic.frames.AckFrame, jdk.internal.net.http.quic.packets.QuicPacket.PacketNumberSpace, .QuicPacket.PacketType, jdk.internal.net.quic.QuicTransportException

An interface implemented by classes which keep track of packet numbers for a given packet number space.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

a new packet number atomically allocated in this space
allocateNextPN
()

Returns a new packet number atomically allocated in this space.

public void
close()

Stops retransmission for this packet space.

public void
confirmHandshake()

Signals that the peer confirmed the handshake.

public void
fastRetransmit()

Immediately retransmit one unacknowledged initial packet

public long

Returns:

the largest packet number that was acknowledged by the peer in this space.
getLargestPeerAckedPN
()

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

public long

Returns:

the largest incoming packet number that was successfully processed in this space.
getLargestProcessedPN
()

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

public long

Returns:

the largest packet number that we have acknowledged in this space
getLargestSentAckedPN
()

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

public long

Returns:

the packet number threshold below which packets should be discarded without being processed in this space
getMinPNThreshold
()

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

public AckFrame

Returns:

The next AckFrame to send to the peer, or null if there is nothing to acknowledge.
getNextAckFrame
(boolean
if true, the frame will only be returned if it's overdue
onlyOverdue
)

Get the next ack frame to send.

public AckFrame

Returns:

The next AckFrame to send to the peer, or null if there is nothing to acknowledge.
getNextAckFrame
(boolean
if true, the frame will only be returned if it's overdue
onlyOverdue
,
int maxSize)

Get the next ack frame to send.

public ReentrantLock

Returns:

a lock used by the transmission task
getTransmitLock
()

Returns a lock used by the transmission task.

public boolean

Returns:

true if a packet with that packet number is already being acknowledged (will be, or has been acknowledged)
isAcknowledged
(long
the packet number
packetNumber
)

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

public boolean

Returns:

true if this packet space is closed
isClosed
()

Returns true if this packet space is closed.

public QuicPacket.PacketNumberSpace

Returns:

the packet number space managed by this class
packetNumberSpace
()

Returns the packet number space managed by this class.

public void
packetReceived(QuicPacket.PacketType
the received packet
packet
,
long
the received packet number
packetNumber
,
boolean
whether this packet is ack eliciting
isAckEliciting
)

Called when a packet is received.

public void
packetSent(QuicPacket
the new packet being retransmitted
packet
,
long
the packet number of the previous packet that was not acknowledged, or -1 if this is not a retransmission
previousPacketNumber
,
long
the new packet number under which this packet is being retransmitted
packetNumber
)

Signals that a packet has been sent.

public void
processAckFrame(AckFrame
the ACK frame received.
frame
)

Processes a received ACK frame.

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
()

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

public void
retry()

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

public void
runTransmitter()

Triggers immediate run of transmit loop.

public void
updatePeerTransportParameters(long
max_ack_delay
peerDelay
,
long
ack_delay_exponent
ackDelayExponent
)

called on application packet space to record peer's transport parameters

public void
versionChanged()

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

Method Detail

allocateNextPNback to summary
public long allocateNextPN()

Returns a new packet number atomically allocated in this space.

Returns:long

a new packet number atomically allocated in this space

closeback to summary
public void close()

Stops retransmission for this packet space.

confirmHandshakeback to summary
public void confirmHandshake()

Signals that the peer confirmed the handshake. Application space only.

fastRetransmitback to summary
public void fastRetransmit()

Immediately retransmit one unacknowledged initial packet

External Specification
https://www.rfc-editor.org/rfc/rfc9002#name-speeding-up-handshake-compl
getLargestPeerAckedPNback to summary
public long getLargestPeerAckedPN()

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

Returns:long

the largest packet number that was acknowledged by the peer in this space.

getLargestProcessedPNback to summary
public long getLargestProcessedPN()

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

Returns:long

the largest incoming packet number that was successfully processed in this space.

getLargestSentAckedPNback to summary
public long getLargestSentAckedPN()

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

API Note

This is necessarily greater or equal to the packet number returned by getMinPNThreshold().

Returns:long

the largest packet number that we have acknowledged in this space

getMinPNThresholdback to summary
public long getMinPNThreshold()

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

API Note

This corresponds to the largest acknowledged packet number carried in an outgoing ACK frame whose packet number has been acknowledged by the peer. In other words, the largest packet number sent by the peer for which we know that the peer has received an acknowledgement.

Note that we need to track the ACK of outgoing packets that contain ACK frames in order to figure out whether a peer knows that a particular packet number has been received and avoid retransmission. However - we don't want ACK frames to grow too big and therefore we can drop some of the information, based on the largestSentAckedPN - see RFC 9000 Section 13.2

Returns:long

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

getNextAckFrameback to summary
public AckFrame getNextAckFrame(boolean onlyOverdue)

Get the next ack frame to send. This method returns the prepared ack frame if: - it was not sent yet - there are new ack-eliciting packets to acknowledge - optionally, if the ack frame is overdue

Parameters
onlyOverdue:boolean

if true, the frame will only be returned if it's overdue

Returns:AckFrame

The next AckFrame to send to the peer, or null if there is nothing to acknowledge.

getNextAckFrameback to summary
public AckFrame getNextAckFrame(boolean onlyOverdue, int maxSize)

Get the next ack frame to send. This method returns the prepared ack frame if: - it was not sent yet - there are new ack-eliciting packets to acknowledge - the ack frame size doesn't exceed maxSize - optionally, if the ack frame is overdue

Parameters
onlyOverdue:boolean

if true, the frame will only be returned if it's overdue

Returns:AckFrame

The next AckFrame to send to the peer, or null if there is nothing to acknowledge.

getTransmitLockback to summary
public ReentrantLock getTransmitLock()

Returns a lock used by the transmission task. . Used to ensure that the transmission task does not observe partial changes during processing of incoming Versions and Retry packets.

Returns:ReentrantLock

a lock used by the transmission task

isAcknowledgedback to summary
public boolean isAcknowledged(long packetNumber)

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

Parameters
packetNumber:long

the packet number

Returns:boolean

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

isClosedback to summary
public boolean isClosed()

Returns true if this packet space is closed.

Returns:boolean

true if this packet space is closed

packetNumberSpaceback to summary
public QuicPacket.PacketNumberSpace packetNumberSpace()

Returns the packet number space managed by this class.

Returns:QuicPacket.PacketNumberSpace

the packet number space managed by this class

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

Called when a packet is received. Causes the next ack frame to be updated. If a packet contains an AckFrame, the caller is expected to also later call processAckFrame(AckFrame) when processing the packet payload.

Parameters
packet:QuicPacket.PacketType

the received packet

packetNumber:long

the received packet number

isAckEliciting:boolean

whether this packet is ack eliciting

packetSentback to summary
public void packetSent(QuicPacket packet, long previousPacketNumber, long packetNumber)

Signals that a packet has been sent. This method is called by QuicConnectionImpl when a packet has been pushed to the endpoint for sending.

The retransmitted packet is taken out the pendingRetransmission list and the new packet is inserted in the pendingAcknowledgement list.

Parameters
packet:QuicPacket

the new packet being retransmitted

previousPacketNumber:long

the packet number of the previous packet that was not acknowledged, or -1 if this is not a retransmission

packetNumber:long

the new packet number under which this packet is being retransmitted

Exceptions
IllegalArgumentException:
If newPacketNumber is lesser than 0
processAckFrameback to summary
public void processAckFrame(AckFrame frame) throws QuicTransportException

Processes a received ACK frame. This method is called by QuicConnectionImpl.

Parameters
frame:AckFrame

the ACK frame received.

requestSendPingback to summary
public CompletableFuture<Long> requestSendPing()

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

API Note

The returned completable future is actually completed if any packet whose packet number is greater than the packet number that contained the ping frame is acknowledged.

Returns:CompletableFuture<Long>

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)

retryback to summary
public void retry()

This method is called by QuicConnectionImpl upon reception of and successful processing of retry packet. In that case we should treat all previously sent packets as lost.

runTransmitterback to summary
public void runTransmitter()

Triggers immediate run of transmit loop. This method is called by QuicConnectionImpl when new data may be available for sending, for example: - new stream data is available - new receive credit is available - stream is forcibly closed

updatePeerTransportParametersback to summary
public void updatePeerTransportParameters(long peerDelay, long ackDelayExponent)

called on application packet space to record peer's transport parameters

Parameters
peerDelay:long

max_ack_delay

ackDelayExponent:long

ack_delay_exponent

versionChangedback to summary
public void versionChanged()

This method is called by QuicConnectionImpl upon reception of and successful negotiation of a new version. In that case we should stop retransmitting packet that have the "wrong" version: they will never be acknowledged.