Class RemoteCidQueue

java.lang.Object
io.github.mahmoudimus.quic.connection.RemoteCidQueue

public final class RemoteCidQueue extends Object
The connection IDs the peer issued to this endpoint (RFC 9000 section 5.1.2): a window of at most limit IDs, our active_connection_id_limit, starting with the one in use. It may have gaps from loss or reordering.

NEW_CONNECTION_ID frames that would exceed the limit are a CONNECTION_ID_LIMIT_ERROR; Retire Prior To retires the IDs below it, and the caller sends RETIRE_CONNECTION_ID for them.

Threads. Not thread-safe; owned by one connection.

  • Field Details

    • DEFAULT_LIMIT

      public static final int DEFAULT_LIMIT
      quinn's window, and the active_connection_id_limit it advertises.
      See Also:
  • Constructor Details

    • RemoteCidQueue

      public RemoteCidQueue(ConnectionId initial, int limit)
      A queue holding the ID the handshake used, sequence number 0.
      Parameters:
      initial - the peer's first Source Connection ID
      limit - our active_connection_id_limit, at least 2
    • RemoteCidQueue

      public RemoteCidQueue(ConnectionId initial)
      A queue with quinn's window of 5.
      Parameters:
      initial - the peer's first Source Connection ID
  • Method Details

    • insert

      Stores a NEW_CONNECTION_ID frame's ID, retiring those below its Retire Prior To.
      Parameters:
      frame - the frame
      Returns:
      null if nothing was retired, else the sequence numbers to retire and the new active ID's reset token
      Throws:
      RemoteCidQueue.CidInsertException - if the ID was already retired or exceeds the limit
    • onNewConnectionId

      public StatelessResetToken onNewConnectionId(Frame.NewConnectionId frame, Retransmits pending) throws QuicException
      Processes a NEW_CONNECTION_ID frame as the connection does: stores the ID and queues RETIRE_CONNECTION_ID frames for the IDs it retires.
      Parameters:
      frame - the frame
      pending - where to queue RETIRE_CONNECTION_ID
      Returns:
      the reset token of a new active ID, or null if the active ID did not change
      Throws:
      QuicException - PROTOCOL_VIOLATION if the peer uses zero-length IDs or reuses a sequence number for another ID, CONNECTION_ID_LIMIT_ERROR if it exceeds our limit
    • peekNext

      public ConnectionId peekNext()
      The ID next() would switch to, without switching: a probe of a new path uses it before the connection moves there (RFC 9000 section 9.5).
      Returns:
      the ID, or null if the peer supplied no unused one
    • next

      public RemoteCidQueue.Retired next()
      Switches to the next known ID, as when migrating or for a server leaving the handshake ID.
      Returns:
      the new ID's reset token and the sequence numbers to retire, or null if no other ID is known
    • updateInitialCid

      public void updateInitialCid(ConnectionId cid)
      Replaces the initial ID, after a Retry or the server's first Initial.
      Parameters:
      cid - the new ID
    • active

      public ConnectionId active()
      The ID in use.
      Returns:
      the ID
    • activeSeq

      public long activeSeq()
      The sequence number of the ID in use.
      Returns:
      the sequence number
    • activeResetToken

      public StatelessResetToken activeResetToken()
      The reset token of the ID in use.
      Returns:
      the token, or null for the handshake ID (whose token, if any, came in the transport parameters)