QUIC Connection IDs and Network Migration
QUIC connection IDs are opaque identifiers that endpoints put in packet headers so they can associate packets with a connection independently of the sender’s network address. That separation is what lets an established QUIC connection survive a client moving between networks or receiving a new NAT mapping.
The problem with identifying connections by address
In traditional network protocols, a connection is commonly associated with a five-tuple: the transport protocol, source IP address, source port, destination IP address, and destination port. A TCP connection, for example, is normally found by matching its packets against that tuple.
That works until the client’s apparent address changes. A laptop might switch from Wi-Fi to cellular data. A phone might move between wireless networks. A NAT (a device that rewrites private addresses and ports when traffic crosses into another network) might expire a mapping and create a new one. The server then sees packets arriving from a new source IP address or port.
To a system relying only on the five-tuple, those packets look like they belong to a new connection. The old connection state is still associated with the previous address, so the application may need to reconnect.
QUIC avoids making the address the connection’s identity. It uses connection IDs for that purpose.
What a connection ID is
A connection ID, or CID, is a byte string chosen by a QUIC endpoint. It has no required meaning to the other endpoint: it is not necessarily an encoded IP address, port, user ID, or session number. Its main job is to give the receiving endpoint a value it can use to find the right connection state.
QUIC packets carry a destination connection ID (DCID), which tells the receiver which connection the packet is intended for. Depending on the packet header, a packet can also carry a source connection ID (SCID), which gives the peer an identifier to use as the destination ID in later packets.
The IDs are directional. If a client sends a packet with a server-chosen CID as its DCID, the server uses that value to find the client’s connection. When the server sends a packet back, it uses a client-chosen CID as the DCID, and the client uses that value to find the same connection on its side.
This arrangement also helps servers that distribute traffic across workers or machines. A front-end device can use the DCID to route a packet to the process or server holding the connection, without relying on the packet’s current source address. Some deployments encode routing information into a CID; that is an implementation choice, not something QUIC requires.
A CID is an address-independent lookup key, not a replacement IP address and not an authentication credential.
How endpoints learn and use IDs
Connection IDs are established as part of creating a QUIC connection. The client includes a destination ID in its first packet, and the handshake allows both endpoints to learn the identifiers they should use. QUIC packets are then encrypted and authenticated, so after using a CID to locate candidate connection state, an endpoint still verifies that the packet is valid for that connection.
An endpoint keeps track of the CIDs its peer may use. During the connection, it can provide additional IDs with a NEW_CONNECTION_ID frame. A frame is a structured piece of information carried inside a QUIC packet. The peer can later switch to one of these IDs, while the endpoint can retire IDs that should no longer be accepted.
Having several IDs matters for more than migration. It lets an endpoint replace an ID that may have become identifiable or tied to a particular routing path. It can also make connection routing more practical when traffic moves between network paths.
The lookup sequence is therefore roughly:
- A packet arrives with a source address, source port, and DCID.
- The endpoint examines the DCID to locate a candidate QUIC connection.
- It decrypts and authenticates the packet using that connection’s cryptographic state.
- If valid, it processes the packet as traffic for that connection, regardless of whether the source address changed.
A packet with an unknown or invalid CID is not automatically accepted as a new connection. QUIC’s packet protection and protocol rules still determine whether it is meaningful.
Surviving a client address change
Suppose a client has an established connection to a server. Its current network path is identified by the client’s old IP address and UDP port. The client then changes networks, and its next packet arrives from a different address or port.
The client sends that packet using the same connection state and an appropriate DCID for the server. The server looks up the connection by CID rather than requiring the old five-tuple. It can therefore recognize the packet as belonging to the existing connection.
Before sending substantial traffic over the new path, QUIC validates that path. Path validation is a small exchange that tests whether the endpoint can receive packets at the new address and is willing to use it. The endpoint sends a PATH_CHALLENGE; the peer answers with a matching PATH_RESPONSE. This prevents an attacker from easily tricking an endpoint into sending large amounts of traffic to an unwilling third party.
After validation, the connection continues with its existing cryptographic keys, stream state, flow-control state, and application requests. The application does not need to establish a new HTTP session merely because the client’s network address changed.
A related case is NAT rebinding, where the client did not intentionally migrate but a NAT assigned a new public port or address. QUIC treats the newly observed address as a possible new path and can validate it while continuing to identify the connection through its CID.
The limits of migration
Connection IDs do not make every network change invisible. The client must still be able to send packets to the server, and the new path must pass validation. A broken network, blocked UDP traffic, or a server policy that disallows migration can still end the connection. QUIC also has rules about when migration is allowed and which connection IDs may be used; a zero-length CID provides less help for identifying packets after an address change.
When a log mentions a CID, “connection migration,” “path validation,” or a packet arriving from an unexpected address, it is usually describing this separation between where a packet came from and which connection it belongs to. The connection ID preserves the latter while the network path changes underneath it.