TCP and UDP protocol characteristics and differences

1. Features of TCP protocol

  • TCP is a connection-oriented (virtual connection) transport layer protocol.

    Before the application uses the TCP protocol, it needs to establish a TCP connection first, and then release the connection after transmitting the data.

    Virtual connection: does not belong to the actual physical connection of the transport layer (the datagram is added to the header of each layer and then placed on the link for transmission, and then to the receiving end to decapsulate step by step), and the use of the TCP protocol is like A point-to-point connection established between two processes from one point to another.

  • Each TCP connection can only have two endpoints, and each TCP connection can only be a point-to-point connection.

  • TCP provides reliable delivery services, with no errors, no loss, no duplication, and orderly arrival. (Reliable and orderly, neither lost nor heavy)

  • TCP provides full-duplex communication.
    Sending buffer: data to be sent & data that has been sent but not yet received confirmation.
    Receiving buffer: data arriving in sequence but not yet read by the receiving application & data arriving out of sequence.

  • TCP is oriented towards byte streams. TCP treats the data handed over by the application as just a series of unstructured byte streams.
    Insert picture description here
    To transmit data, the sender first takes 123 bytes to form a TCP segment, and then adds the TCP header to this segment to form a complete segment, and then transmits it on the link. The number of bytes is not definite.

2. Features of UDP protocol:

UDP only adds a few functions to the IP datagram service, namely multiplexing and demultiplexing.
  1. UDP is connectionless, reducing overhead and delay before sending data.
  2. UDP uses best effort delivery, that is, reliable delivery is not guaranteed.
  3. UDP is message-oriented and suitable for network applications that transmit a small amount of data at once.
    Insert picture description here
  4. UDP has no congestion control and is suitable for many real-time applications.
  5. The header overhead of UDP is small. 8B and TCP is 20B.

Three, the difference between TCP and UDP:

TCP is a transmission control protocol, and UDP is a user datagram protocol. UDP does not necessarily provide reliable data transmission and cannot guarantee that the data will arrive at the destination accurately and without error. And TCP provides reliable delivery services, so that data arrives in order without errors, loss, duplication, and order.

Guess you like

Origin blog.csdn.net/weixin_43690348/article/details/112566133