Skip to content

Commit 806f474

Browse files
authored
[docs] Changed the buffer size description to be clearer (#2670).
1 parent d9c1794 commit 806f474

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

docs/API/configuration-guidelines.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,29 @@ The default receiver buffer size is 8192 packets. It is approximately:
1919

2020
### Setting Receiver Buffer Size
2121

22-
As already mentioned, the maximum allowed size of the receiver buffer is limited by the value of `SRTO_FC`.
2322
When the `SRTO_RCVBUF` option value is set using the `srt_setsockopt(..)` function,
24-
the provided size in bytes is internally converted to the corresponding size in packets
25-
using the configured value of the `SRTO_MSS` option to estimate the maximum possible payload of a packet.
23+
the provided size in bytes is internally converted to the corresponding size in packets.
24+
The size of a cell for a single packet in the buffer is defined by the
25+
`SRTO_MSS` option, which is 1500 by default. This value, decreased by 28 in
26+
the case of IPv4 (20 bytes for the IPv4 header and 8 bytes for the UDP header), gives 1472
27+
bytes per packet to be allocated. The actual memory occupied by the receiver
28+
buffer will be a multiple of that value. For the default 8192 packets it
29+
will be 11776 kB (11.5 MB).
30+
31+
Note that every cell has 16 bytes for the SRT header. The remaining space
32+
is for the payload.
33+
34+
As already mentioned, the maximum allowed size of the receiver buffer is limited by the value of `SRTO_FC`.
2635

27-
The following function returns the buffer size in packets:
36+
The following function returns the configured buffer size in packets depending on the SRTO_RCVBUF, SRTO_MSS and SRTO_FC values set:
2837

2938
```c++
3039
int getRbufSizePkts(int SRTO_RCVBUF, int SRTO_MSS, int SRTO_FC)
3140
{
32-
// UDP header size is assumed to be 28 bytes
41+
// UDP/IPv4 header size is assumed to be 28 bytes
3342
// 20 bytes IPv4 + 8 bytes of UDP
34-
const int UDPHDR_SIZE = 28;
35-
const int pkts = (rbuf_size / (SRTO_MSS - UDPHDR_SIZE));
43+
const int UDP_IPv4_HDR= 28;
44+
const int pkts = (rbuf_size / (SRTO_MSS - UDP_IPv4_HDR));
3645

3746
return min(pkts, SRTO_FC);
3847
}
@@ -56,16 +65,13 @@ where
5665
5766
If the whole remainder of the MTU is expected to be used, payload size is calculated as follows:
5867
59-
`bytePayloadSize = MSS - 44`
68+
`bytePayloadSize = MSS - UDP_IPv4_HDR - SRT_HDR`
6069
6170
where
6271
63-
- 44 is the size in bytes of an **IPv4** header:
64-
- 20 bytes **IPv4**
65-
- 8 bytes of UDP
66-
- 16 bytes of SRT packet header.
67-
68-
- `MSS` is the Maximum Segment Size (aka MTU); see `SRTO_MSS`.
72+
- `MSS`: Maximum Segment Size (size of the MTU); see `SRTO_MSS` (default: 1500)
73+
- `UDP_IPv4_HDR`: 20 bytes for IPv4 + 8 bytes for UDP
74+
- `SRT_HDR`: 16 bytes of SRT header (belonging to the user space)
6975
7076
### Calculating Target Size to Set
7177

0 commit comments

Comments
 (0)