cloudflare / quiche

🥧 Savoury implementation of the QUIC transport protocol and HTTP/3
https://docs.quic.tech/quiche/
BSD 2-Clause "Simplified" License
9.4k stars 709 forks source link

What is the proper way to recovery the connection when UPD socket changes? #887

Open psionic12 opened 3 years ago

psionic12 commented 3 years ago

According to the doc:

QUIC connections are not strictly bound to a single network path. Connection migration uses connection identifiers to allow connections to transfer to a new network path. Only clients are able to migrate in this version of QUIC. This design also allows connections to continue after changes in network topology or address mappings, such as might be caused by NAT rebinding.¶

Does the UDP socket changes counts "network path changed"? Since the Quiche API do not need a socket fd to passed in, I guess Quiche connection is dependent with sockets.

Then I did a test: First I create a Quiche+H3 connection and sending requests, it works well. Then before the connection closed, I create a new socket, and send requests with this new one.

But each time I tried this, the library said:

quiche: da224c50979456051252ba5dfae97fc8 rx pkt Short dcid=bc16ec7742ebc3f1b73e2b3b784cae2a key_phase=true len=49 pn=5607456
quiche: da224c50979456051252ba5dfae97fc8 dropped invalid packet

it considered my requests as invalid packet. I tried calling on_timeout()(since on_timeout() does the recovery jobs) after creating a new socket, but still not working.

So what is the proper way to do this?

P.S. re-use Quiche connection while socket changing is extremely useful, in case a user's network changes from 4G to Wifi.

ghedo commented 3 years ago

We don't really support network migration yet (e.g. we don't probe/validate new paths), but in your specific case I think there might be something else going on with your application, as you wouldn't see the "invalid packet" error even if the migration happened.

psionic12 commented 3 years ago

Hi @ghedo, So what is the expected behavior (for now) in the case I mentioned above? Does the server just ignore my packet which is sent from the new UPD socket, and my client never receive a response?