The UDP protocol of computer network

Preface

This article combs UDP protocol
UDP: User Datagram Protocol, user datagram protocol

UDP is a connectionless transport layer protocol. It does not require server monitoring like TCP, nor does it need to wait for the client to establish a connection with the server before communicating. Of course, UDP cannot guarantee whether the data can be successfully transmitted in the end. This service provides unreliable, best-effort delivery of the data transmitted in the message. This means that it does not guarantee the arrival of the datagram, nor does it guarantee the correct order of the transmitted data packets.

TCP uses a connection-oriented message segment (data segment) mode, while UDP uses a connectionless datagram transmission mode.
TCP is transmitted in the unit of data segment (segment), and UDP is transmitted in the unit of datagram (datagram).

Main features of UDP

  • Connectionless
    UDP is connectionless, reducing overhead and delay before sending data.

  • Unreliable
    because UDP data transmission does not require prior establishment of a special transport connection, so it is not reliable transmission, we will use best efforts to deliver, that does not guarantee reliable delivery.

  • Taking the message as the boundary,
    UDP directly encapsulates and transmits the message submitted by the application layer, but does not split or merge it, and retains the boundary of the original message.
    Therefore, UDP is a message stream, and TCP is a byte stream.
    Because UDP does not split packets, there is naturally no segmentation, but after UDP packets are transmitted to the network layer, the network layer can still be divided according to the network MTU value, so it is suitable for networks that transmit a small amount of data at once application. For example, it is suitable for some short message data transmission. For example, some messages in DHCP and DNS are transmitted by UDP.

  • No flow control and congestion control
    When using UDP for data transmission, flow control and congestion control cannot be performed, because the continuity of this type of data transmission is more important than the integrity of the data, allowing partial data loss during transmission, which is suitable for many real-time Applications, such as IP telephony, streaming media communications, etc.

  • UDP header overhead is
    8B lower, TCP is 20B

  • Support various interactive communication methods
    TCP does not support multicast and broadcast communication methods, but only supports one-to-one unicast methods, but UDP supports various communication methods, that is, one-to-one, one-to-many, many-to-one and many The way to many.

UDP message

Insert picture description here
Because there is no flow control, congestion control is relatively simple.

UDP check

Check whether the entire UDP datagram is wrong, discard it if it is wrong, or hand it over to the application layer with a warning of the error.
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/u014099894/article/details/112383512