What is the difference between UDP and TCP packets? What are you using them for?

I set up IPtable yesterday. My colleague just asked me this question, and I could not answer. I realized that I am much better than a system administrator, and I need to improve this.

And what are they? What are they for? Cons / Pros (if relevant).

+6
udp networking tcp
source share
6 answers

These are the basic questions.

UDP :: User Datagram Protocol

1) There is no end-to-end connection between the machines (maybe on the local network or somewhere on the Internet).

2) The data received at the end of the receiver is not in the stream, as in TCP, but as a complete block of data.

3) At the transport level, packet inspection is not performed. That is, in the event of any error in the received packet, the receiver will not request a retransmission of the same packet to the sender.

4) Due to the above behavior, sending buffers is not required.

5) Since there is no end-to-end connection. and no handshakes are required, UDP is much faster, but less reliable than TCP. Therefore, it is mainly used in games and DNS, etc.

6) No confirmation is required for sending after returning packages.

TCP :: Transmission Control Protocol

1) End-end A connection is maintained between machines (maybe on a local network or somewhere on the Internet).

2) The data received at the end of the receiver is a stream in TCP. Thus, when we perform network programming for servers, we first analyze the header, and then, depending on the size specified in the header, we get much more bytes from the buffer.

3) Error checking and serial number are completed. Thus, in the event that a packet is received out of order (rarely) or is erroneous than this packet for resending. In addition, many other protocols are involved in flow control (flow control to the end).

4) As the establishment of the connection, the establishment of communication and acknowledgment, TCP should be performed generally slower than UDP. (I don't know how sure I am)

5) Many protocols use TCP as the base transport protocol. HTTP, FTP, TELNET, etc.

6) The communication procedure includes:

Server :: 1) Socket Open 2) Socket binding 3) Listen to Socket 4) Receive socket 5) Socket Send / Recv Client :: 1) Socket Open 2) Socket Connect 3) Socket Send / Recv

There are many other differences as well .. but the above are the most common.

+10
source share

TCP is a reliable protocol that ensures that your packets reach their destination and are used in applications where all data must vary exactly between the parties. TCP requires both parties to negotiate a connection before starting data transfer, and this is a robust protocol because it will resend the packet until the packet is received by the intended recipient.

UDP is unreliable in a sense that it allows some packets to be lost in transit. Some UDP applications are streaming movies where you can really lose the frame and not jeopardize the quality of the video. UDP does not require binding between the two parties and is often considered an easy alternative to TCP.

A good table is here: TCP vs UDP

+5
source share

The PR answer is mostly correct, but incomplete.

TCP is a reliable, connected flow protocol. Its data representation is a bidirectional stream of bytes between hosts: any bytes you send will arrive at the other end in the same order, at least depending on the application (the OS will reorder the packets if necessary).

UDP is an unrelated datagram protocol. His presentation of data is the data of discrete datagrams or messages, without guarantee that these messages really reach their recipient or they arrive in the order in which they were sent. It guarantees that if a message arrives, it will be completely and unchanged.

+2
source share
+1
source share

This website probably offers the simplest explanation of the actual difference between UDP and TCP. In terms of implementation, see this question .

For a short answer: TCP works like a registered letter, when UDP looks like a regular letter - with the latter you never know if the receiver received the packet you sent.

+1
source share

Chris is right! One fancy link drop down from google: http://www.skullbox.net/tcpudp.php

0
source share

All Articles