Network programming (two)-tcp, udp basis

1. The maximum size of an ipv4 data packet is 65535 bytes, including the ipv4 header
2. The maximum transmission unit MTU is usually 1500 bytes, and the minimum link MTU required by IPv4 is 68 bytes, which is the smallest segment that allows the most IPv4 header to be spliced , When the size of an IP packet exceeds the MTU, it will be fragmented 3.
MSS (Maximum Segment Size) in TCP is used to notify the opposite end of the maximum amount of data that the opposite end can send in each segment
4. tcp send buffer
Insert picture description here
Insert picture description here
tcp calls write just to copy the data in the application buffer to the socket buffer. If the data in the socket buffer cannot fit the contents of the application buffer, the write call is blocked until all the data is Copy to the socket buffer, and then the write call returns; the write call returns successfully, but it means that the data is copied to the socket buffer, but it does not mean that the transmission is successful.
5. UDP transmission size limit
udp does not have a transmission buffer, but there is UDP data The upper limit of the size of the report. If the sent datagram exceeds this limit, the kernel will return an EMSGSIZE error to the process. The limit can be set using SO_SNDBUF;
the successful return of UDP write indicates that the written datagram has been added to the data chain. The output queue of the circuit layer, if the queue does not have enough space, the kernel usually returns an ENOBUFS error to the application process
. 6. The socket read/write
EINTR error indicates that the system call was interrupted by a signal. If the error occurs, continue to be hit. Interrupted read and write operations
Insert picture description here
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/chengcheng1024/article/details/115230803