Ethernet basics: Difference Between TCP and UDP

Source: Internet
Author: User
Tags file transfer protocol ping and traceroute

 

The difference between TCP and UDP is described below:
1. Connection-based and connectionless
2. Requirements on system resources (more TCP and less UDP)
3. UDPProgramSimple Structure
4. Stream mode and datagram Mode
5. TCP ensures data correctness, UDP may cause packet loss, and TCP ensures data sequence. UDP does not guarantee data consistency. In addition, let's talk about their differences based on the situation of the GPRS network:
1. TCP transmission has a certain latency, which is about 1600 ms (provided by mobile devices). The UDP response speed is slightly faster.
2. Minimum TCP packet header size. it is 20 bytes. UDP packets are much smaller. indeed. because UDP is a non-reliable connection. the original intention is to send data packets as quickly as possible. therefore, the UDP protocol is very streamlined.

TCP and UDP are two of the most famous transport layer protocols, both of which use IP as the network layer protocol.

Although TCP uses an unreliable IP service, it provides a reliable transport layer service. From Chapter 1 to Chapter 2, this book will discuss in detail the internal operation details of TCP. Next, we will introduce some TCP applications, such as telnet and rlogin in Chapter 26th, FTP in Chapter 27th, and SMTP in Chapter 28th. These applications are generally user processes.

UDP sends and receives data packets for applications. A datagram refers to an information unit transmitted from the sender to the receiver (for example, a certain number of bytes specified by the sender ). However, unlike TCP, UDP is unreliable and cannot guarantee that the datagram can reach the ultimate goal safely and without error. Chapter 1 of this book will discuss UDP, and in chapter 11th (Domain Name System: Domain Name System), Chapter 14th (simple File Transfer Protocol Trivial File Transfer Protocol ), chapter 4 (Bootstrap Protocol) describes the application that uses UDP. SNMP (Simple Network Management Protocol) also uses UDP protocol, but since it also needs to handle many other protocols, this book will leave it to Chapter 25th for further discussion.

IP is the main Protocol on the network layer and is used by both TCP and UDP. Each group of TCP and UDP data is transmitted through the end system and the IP layer of each intermediate router in the Internet. In Figure 1.4, we provide an application that directly accesses the IP address. This is rare, but it is also possible. (Some older routing protocols are implemented in this way. Of course, the new transport layer protocol may also try this method .) Chapter 2 mainly discusses the IP protocol, but in order to make the content more targeted, some details will be discussed later. Chapter 2 and Chapter 2 discuss how to select routes for IP addresses.

ICMP is a subsidiary protocol of the IP protocol. The IP layer uses it to exchange error messages and other important information with other hosts or routers. Chapter 4 discusses the details of ICMP. Although ICMP is mainly used by IP addresses, applications may also access it. We will analyze two popular diagnostic tools, Ping and traceroute (Chapter 7th and Chapter 8th), both of which use ICMP.

IGMP is an internet group management protocol. It is used to multicast a UDP datagram to multiple hosts. In Chapter 12th, we describe the general features of broadcasting (sending a UDP datagram to all hosts on a specified network) and multi-point transmission, and then describe the IGMP protocol itself in Chapter 13th.

ARP (Address Resolution Protocol) and RARP (Reverse Address Resolution Protocol) are special protocols used by some network interfaces (such as Ethernet and ring-based network, it is used to convert the addresses used by the IP layer and network interface layer. We will analyze and introduce the two protocols in Chapter 4th and Chapter 5th respectively.

TCP/IP protocol families are divided into four layers: link layer, network layer, transport layer, and application layer. Each layer has different responsibilities. In TCP/IP, the difference between the network layer and transport layer is the most critical: the network layer (IP) provides point-to-point services, while the transport layer (TCP and UDP) provides end-to-end services.

 
The conclusion is that TCP is oriented to edge connections, so it will be slower, but it is safer, while UDP is the opposite.

TCP (Transmission Control Protocol) UDP (User Datagram Protocol) both TCP and UDP are transport layer protocols responsible for data transmission tasks. TCP is a reliable connection-oriented service, UDP is an unreliable connectionless datagram service. TCP requires three-way handshakes to establish a secure connection. Therefore, the efficiency is relatively low, but the security is high. UDP does not need it, just like a telegram, no matter whether you receive it or not, it is highly efficient but unreliable. For example, the DNS requests in our network are sent using UDP, And the UDP direct connection voice in QQ is the fastest speed.
 
User Datagram Protocol (UDP) is the protocol from another host of an IP address to a host (corresponding to the transport layer of the OSI reference model ). UDP provides any advanced functions supported by TCP. No timer, no stream control and management mechanisms, accelerated transmission of response and emergency data, or any other functions. UDP does not support retransmission. UDP and TCP are very different protocols designed to do different things. TCP provides higher reliability, while UDP is a simple protocol that sends packets as much as possible. TCP is more complex and requires a lot of functional overhead, while UDP is simple and efficient. UDP is generally considered unreliable because it does not have any reliability mechanism of TCP. There is no receiving and response mechanism, data delivery in disordered order, or even no re-transmission mechanism for damaged data. UDP cannot guarantee that the data will arrive at the destination without being damaged. Therefore, UDP is suitable for sending small-scale data. TCP is more suitable for dividing the data into multiple heat preservation and mediation of Data Liu.
UDP header the UDP header contains a 16-bit source port number, a 16-bit destination port number, a 16-bit UDP length, a 16-bit checksum, and a UDP data segment (if any ). UDP port numbers and TCP port numbers exist independently. The UDP length field refers to the byte length of the UDP header and UDP data. The minimum value of this field is 8 (2 32 bit long ). The UDP checksum and UDP checksum overwrite the UDP header and UDP data. In addition, UDP checksum is optional.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.