Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.2] - 2026-06-08

### Fixed

- Budget CRYPTO handshake fragmentation off the peer's advertised `max_udp_payload_size` rather than the local 1200-byte floor, so the handshake flight fits the peer's datagram limit (#5)

## [1.0.1] - 2026-06-03

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pure Erlang QUIC transport for Erlang/OTP 27+.
## Getting started

```erlang
{deps, [{nquic, "1.0.1"}]}.
{deps, [{nquic, "1.0.2"}]}.
```

### Client
Expand Down
2 changes: 1 addition & 1 deletion src/nquic.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, nquic, [
{description, "QUIC transport protocol (RFC 9000/9001/9002) for Erlang/OTP 27+"},
{vsn, "1.0.1"},
{vsn, "1.0.2"},
{registered, []},
{applications, [
kernel,
Expand Down
5 changes: 2 additions & 3 deletions src/nquic_protocol_send.erl
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,15 @@ batch_frames([F | Rest], Budget, Used, Cur, Batches) ->

-spec handshake_payload_budget(nquic_protocol:state()) -> pos_integer().
handshake_payload_budget(#conn_state{
dcid = DCID, scid = SCID, max_payload_size = MaxPayload, remote_params = RP
dcid = DCID, scid = SCID, remote_params = RP
}) ->
PeerMax =
case RP of
#transport_params{max_udp_payload_size = M} when is_integer(M), M >= 1200 -> M;
_ -> 1200
end,
Limit = min(MaxPayload, PeerMax),
Overhead = 1 + 4 + 1 + byte_size(DCID) + 1 + byte_size(SCID) + 2 + 4 + ?AEAD_TAG_SIZE,
max(1, Limit - Overhead).
PeerMax - Overhead.

-spec presplit_crypto_frames([nquic_frame:t()], pos_integer()) -> [nquic_frame:t()].
presplit_crypto_frames(Frames, Budget) ->
Expand Down
16 changes: 13 additions & 3 deletions test/nquic_protocol_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1675,14 +1675,24 @@ build_handshake_packets_small_flight_single_packet_test() ->
?assertEqual(1, length(Packets)).

build_handshake_packets_splits_large_flight_test() ->
State = queue_handshake_flight(make_handshake_send_state(1472), crypto:strong_rand_bytes(4000)),
PeerMax = 1472,
State = queue_handshake_flight(
make_handshake_send_state(PeerMax), crypto:strong_rand_bytes(4000)
),
{Packets, _State1} = nquic_protocol_send_queues:flush_handshake(State),
?assert(length(Packets) >= 4),
?assert(length(Packets) >= 2),
lists:foreach(
fun(P) -> ?assert(byte_size(iolist_to_binary(P)) =< 1200) end,
fun(P) -> ?assert(byte_size(iolist_to_binary(P)) =< PeerMax) end,
Packets
).

build_handshake_packets_large_peer_keeps_flight_single_test() ->
State = queue_handshake_flight(
make_handshake_send_state(65527), crypto:strong_rand_bytes(1500)
),
{Packets, _State1} = nquic_protocol_send_queues:flush_handshake(State),
?assertEqual(1, length(Packets)).

build_handshake_packets_respects_peer_max_udp_payload_test() ->
PeerMax = 1300,
State0 = (make_handshake_send_state(PeerMax))#conn_state{max_payload_size = 9000},
Expand Down
Loading