mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-19 20:46:35 +00:00
Increase the TCP socket buffer length
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
17ea6e91b0
commit
76d4b180d0
@ -53,11 +53,23 @@ impl<T> UnboundSocket<T> {
|
||||
}
|
||||
}
|
||||
|
||||
// For TCP
|
||||
pub const TCP_RECV_BUF_LEN: usize = 65536;
|
||||
pub const TCP_SEND_BUF_LEN: usize = 65536;
|
||||
// TCP socket buffer sizes:
|
||||
//
|
||||
// According to
|
||||
// <https://github.com/torvalds/linux/blob/9852d85ec9d492ebef56dc5f229416c925758edc/include/net/sock.h#L2798-L2806>
|
||||
// and
|
||||
// <https://github.com/torvalds/linux/blob/9852d85ec9d492ebef56dc5f229416c925758edc/net/core/sock.c#L286-L287>,
|
||||
// it seems that the socket buffer should be 256 packets * 256 bytes/packet = 65536 bytes by
|
||||
// default. However, the loopback MTU is also 65536 bytes, and having the same size for the socket
|
||||
// buffer and the MTU will cause the implementation of Nagle's algorithm in smoltcp to behave
|
||||
// abnormally (see <https://github.com/asterinas/asterinas/pull/1396>). So the socket buffer size
|
||||
// is increased from 64K to 128K.
|
||||
//
|
||||
// TODO: Consider allowing user programs to set the socket buffer length via `setsockopt` system calls.
|
||||
pub const TCP_RECV_BUF_LEN: usize = 65536 * 2;
|
||||
pub const TCP_SEND_BUF_LEN: usize = 65536 * 2;
|
||||
|
||||
// For UDP
|
||||
// UDP socket buffer sizes:
|
||||
pub const UDP_SEND_PAYLOAD_LEN: usize = 65536;
|
||||
pub const UDP_RECV_PAYLOAD_LEN: usize = 65536;
|
||||
const UDP_METADATA_LEN: usize = 256;
|
||||
|
Reference in New Issue
Block a user