udp(7) Miscellaneous Information Manual udp(7) udp - UDP (User Datagram Protocol) IPv4 #include #include #include udp_socket = socket(AF_INET, SOCK_DGRAM, 0); (User Datagram Protocol, UDP), RFC 768. . , . UDP , . UDP- . sendto(2) sendmsg(2) . connect(2), send(2) write(2) . , sendto(2) sendmsg(2). bind(2). , /proc/sys/net/ipv4/ip_local_port_range, INADDR_ANY. . , , ; , MSG_TRUNC. MSG_WAITALL . IP , ip(7). , /proc ( , ). ip(7). MSG_DONTROUTE, , . , Linux UDP MTU (Maximum Transmission Unit) . , MTU IP- EMSGSIZE, UDP . , . MTU IP_MTU_DISCOVER /proc/sys/net/ipv4/ip_no_pmtu_disc; ip(7). UDP , MTU . . UDP IPv4 sockaddr_in, ip(7). , , . , . , , . BSD-, , . Linux RFC 1122. Linux 2.0 2.2 SOL_SOCKET SO_BSDCOMPAT, , ( EPROTO EMSGSIZE). , , . ; socket(7). IP_RECVERR, recvmsg(2) MSG_ERRQUEUE. /proc UDP /proc/sys/net/ipv4/. udp_mem ( Linux 2.6.25) , , UDP. min UDP , . , UDP, , UDP . pressure tcp_mem ( tcp(7)). max , UDP. . udp_rmem_min (integer; : PAGE_SIZE; Linux 2.6.25) ( ) , UDP . UDP , UDP udp_mem. udp_wmem_min (integer; : PAGE_SIZE; Linux 2.6.25) ( ) , UDP . UDP , UDP udp_mem. UDP getsockopt(2) setsockopt(2), . IPPROTO_UDP. , optval int. UDP. , UDP, socket(7). UDP_CORK ( Linux 2.5.44) , , , . . UDP_SEGMENT (since Linux 4.18) Enables UDP segmentation offload. Segmentation offload reduces send(2) cost by transferring multiple datagrams worth of data as a single large packet through the kernel transmit path, even when that exceeds MTU. As late as possible, the large packet is split by segment size into a series of datagrams. This segmentation offload step is deferred to hardware if supported, else performed in software. This option takes a value in the range [0, USHRT_MAX] that sets the segment size: the size of datagram payload, excluding the UDP header. The segment size must be chosen such that at most 64 datagrams are sent in a single call and that the datagrams after segmentation meet the same MTU rules that apply to datagrams sent without this option. Segmentation offload depends on checksum offload, as datagram checksums are computed after segmentation. The option may also be set for individual sendmsg(2) calls by passing it as a cmsg(3). A value of zero disables the feature. This option should not be used in code intended to be portable. UDP_GRO (since Linux 5.0) Enables UDP receive offload. If enabled, the socket may receive multiple datagrams worth of data as a single large buffer, together with a cmsg(3) that holds the segment size. This option is the inverse of segmentation offload. It reduces receive cost by handling multiple datagrams worth of data as a single large packet in the kernel receive path, even when that exceeds MTU. This option should not be used in code intended to be portable. ioctl ioctl ioctl(2). : int value; error = ioctl(udp_socket, ioctl_type, &value); FIONREAD (SIOCINQ) integer. ( ) , , 0, . : FIONREAD , . select(2), poll(2), epoll(7). TIOCOUTQ (SIOCOUTQ) . Linux 2.4 . ioctl, ip(7) socket(7). UDP , socket(7) ip(7). ECONNREFUSED . , . IP_RECVERR Linux 2.2. ip(7), raw(7), socket(7), udplite(7) The kernel source file Documentation/networking/ip-sysctl.txt. RFC 768. RFC 1122 . RFC 1191 MTU . () Azamat Hackimov , Dmitriy Ovchinnikov , Dmitry Bolkhovskikh , Katrin Kutepova , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 2 2024 . udp(7)