Debian Codegraph @

crt/s2n/docs/usage-guide/topics/ch08-record-sizes.md

raw symbols SCIP
1 # TLS Record Sizes
2
3 ## Throughput vs Latency
4
5 When sending data, s2n-tls uses a default maximum record size which experimentation
6 has suggested provides a reasonable balance of performance and throughput.
7
8 `s2n_connection_prefer_throughput()` can be called to increase the record size, which
9 minimizes overhead. It also increases s2n-tls's memory usage.
10
11 `s2n_connection_prefer_low_latency()` can be called to decrease the record size, which
12 allows the receiver to decrypt the data faster. It also decreases s2n-tls's memory usage.
13
14 These options only affect the size of the records that s2n-tls sends, not the behavior
15 of the peer.
16
17 ## Maximum Fragment Length
18
19 The maximum number of bytes that can be sent in a TLS record is called the "maximum fragment length",
20 and is set to 2^14 bytes by default. Regardless of the maximum record size that s2n-tls
21 uses when sending, it may receive records containing up to 2^14 bytes of plaintext.
22
23 A client can request a lower maximum fragment length by calling `s2n_config_send_max_fragment_length()`,
24 reducing the size of TLS records sent and providing benefits similar to `s2n_connection_prefer_low_latency()`.
25 However, many TLS servers either ignore these requests or handle them incorrectly, so a client should
26 never assume that a lower maximum fragment length will be honored. If a server accepts the requested
27 maximum fragment length, the client will respect that maximum when sending.
28
29 By default, an s2n-tls server will ignore a client's requested maximum fragment length.
30 If `s2n_config_accept_max_fragment_length()` is called, the server will respect the client's requested
31 maximum fragment length when sending, but will not reject client records with a larger fragment size.
32
33 If a maximum fragment length is negotiated during the connection, it will override the behavior
34 configured by `s2n_connection_prefer_throughput()` and `s2n_connection_prefer_low_latency()`.
35
36 ## Dynamic Record Sizing
37
38 Sending smaller records at the beginning of a connection can decrease first byte latency,
39 particularly if TCP slow start is used.
40
41 `s2n_connection_set_dynamic_record_threshold()` can be called to initially send smaller records.
42 The connection will send the first **resize_threshold** bytes in records small enough to
43 fit in a single standard 1500 byte ethernet frame. Whenever **timeout_threshold** seconds
44 pass without sending data, the connection will revert to this behavior and send small records again.
45
46 Dynamic record sizing doesn't completely override `s2n_connection_prefer_throughput()`,
47 `s2n_connection_prefer_low_latency()`, or the negotiated maximum fragment length.
48 Once **resize_threshold** is hit, records return to the maximum size configured for the connection.
49 And if the maximum fragment length negotiated with the peer is lower than what dynamic record sizing
50 would normally produce, the lower value will be used.