You have to know the TCP and UDP! ! !

TCP and UDP are the OSI model transport layer protocol. TCP provides reliable communication transmission, UDP is often used to make broadcasting and communication transmission to control the details of the application.

  1. The TCP (Transmission Control Protocol)
    the TCP is a connection-oriented, reliable delivery, and full-duplex communication service, end to end transport layer protocol is byte-oriented.
    TCP must establish a connection before transmitting data (see TCP connection process: https://blog.csdn.net/qq_44837912/article/details/104727087 ), to be released after the end of the data transfer connection.
    Each TCP connection can have only two endpoints, so the TCP does not provide broadcast or multicast service.
    TCP provides reliable delivery, the TCP connection via a data transfer, error-free, is not lost, will not be repeated, and arrive in order.
    TCP is a byte-oriented stream. Although the application process and TCP interaction is one chunk (of varying sizes), but the English TCP program to pay down the stream of bytes of data as just a series of unstructured. TCP does not know the meaning of the transmitted stream of bytes.

  2. UDP (User Data Protocol)
    protocol (1) UDP is a non-connected, and a source terminal before transmitting data connection is not established, when it wants to transmit data is simply to grab from the application, and as quickly as possible He threw it on the network. At the transmitting end, UDP data transfer speed is only generated by the speed of the application data, computer capabilities and limitations of the transmission bandwidth; receiving end, UDP segment to each message in a queue from the queue each time an application reading a message segment.
    (2) Since the data transmission connection is not established, and therefore there is no need to maintain a connection state, comprises a transceiver status, and therefore a same machine can simultaneously service a plurality of clients to a message transmission.
    Title (3) UDP packet is very short, only 8 bytes, with 20 bytes for TCP packet overhead is small.
    (4) from a certain adjustment congestion control algorithm, limited only by the software application generating the data rate, transmission bandwidth, and a source terminal host capability.
    (5) UDP use a best effort delivery, that does not guarantee reliable delivery, so the host does not need to maintain complex link state table (and there are many parameters).
    (6) UDP is a message-oriented. UDP sender application packet delivery down, after adding the header to the IP layer delivered downwardly. Neither split nor merge, but keep these messages boundary, therefore, the application needs to select the appropriate size of the packet.

    UDP scenarios :
    1. datagram-oriented mode;
    most 2. Network data message;
    3. Client has lots;
    4. No specific data security requirements;
    5 very heavy burden on the network, but requires a high response speed.

  3. Difference between TCP and UDP is
    a connection-based and connectionless;
    2 TCP is a reliable guarantee correct data; UDP unreliable and guarantee correct data;
    . 3 TCP guarantee that the data in order of arrival; UDP does not guarantee that the data arrive out of order;
    . 4 TCP slow, because TCP connection must be created; the UDP speed, without establishing a connection;
    5 because of this overhead, TCP is a heavyweight protocol; the UDP is a lightweight protocol;
    size 6 a TCP packet header is 20 bytes; a UDP packet header is 8 bytes;
    . 7 the TCP flow control and congestion control; UDP flow rate control can not be performed;
    . 8 the TCP byte stream oriented; for UDP packets;
    different scenarios 9, TCP suitable for relatively low efficiency requirements, However, relatively high accuracy required or there is a scene connection, TCP generally used for file transfer (HTTP, HTTPS, FTP etc. protocol), the message (POP, SMTP protocol, etc.), remote login etc. scene; the UDP is more suitable for efficiency requirements relatively high, relatively low accuracy requirement scenario, UDP is generally used for instant messaging (QQ chat), online video (RTSP stream speed must be fast, it does not matter occasional loss) Internet voice telephony and other scenes;

Published 70 original articles · won praise 4 · Views 6344

Guess you like

Origin blog.csdn.net/qq_44837912/article/details/104729784