Sie sind auf Seite 1von 4

TCP vs UDP - Difference and Comparison | Diffen http://www.diffen.

com/difference/TCP_vs_UDP

Dien Technology Computers Computer Networking

There are two types of Internet Protocol (IP) trac. They are TCP or
Transmission Control Protocol and UDP or User Datagram Protocol. TCP is
connection oriented once a connection is established, data can be sent
bidirectional. UDP is a simpler, connectionless Internet protocol. Multiple
messages are sent as packets in chunks using UDP.

Acronym for Transmission Control Protocol User Datagram Protocol or


Universal Datagram Protocol

Connection TCP is a connection-oriented UDP is a connectionless protocol.


protocol.

Function As a message makes its way UDP is also a protocol used in


across the internet from one message transport or transfer.
computer to another. This is This is not connection based
connection based. which means that one program
can send a load of packets to
another and that would be the
end of the relationship.

Usage TCP is suited for applications UDP is suitable for applications


that require high reliability, and that need fast, ecient
transmission time is relatively transmission, such as games.
less critical. UDPs stateless nature is also
useful for servers that answer
small queries from huge numbers
of clients.

Use by other HTTP, HTTPs, FTP, SMTP, Telnet DNS, DHCP, TFTP, SNMP, RIP,
protocols VOIP.

Ordering of data TCP rearranges data packets in UDP has no inherent order as all
packets the order specied. packets are independent of each
other. If ordering is required, it
has to be managed by the
application layer.

Speed of transfer The speed for TCP is slower than UDP is faster because there is no
UDP. error-checking for packets.

1 of 6 11/19/2015 4:43 PM
TCP vs UDP - Difference and Comparison | Diffen http://www.diffen.com/difference/TCP_vs_UDP
vs. GO

Reliability There is absolute guarantee that There is no guarantee that the


the data transferred remains messages or packets sent would
intact and arrives in the same reach at all.
order in which it was sent.

Header Size TCP header size is 20 bytes UDP Header size is 8 bytes.

Common Header Source port, Destination port, Source port, Destination port,
Fields Check Sum Check Sum

Streaming of data Data is read as a byte stream, no Packets are sent individually and
distinguishing indications are are checked for integrity only if
transmi ed to signal message they arrive. Packets have denite
(segment) boundaries. boundaries which are honored
upon receipt, meaning a read
operation at the receiver socket
will yield an entire message as it
was originally sent.

Weight TCP is heavy-weight. TCP UDP is lightweight. There is no


requires three packets to set up a ordering of messages, no tracking
socket connection, before any connections, etc. It is a small
user data can be sent. TCP transport layer designed on top
handles reliability and congestion of IP.
control.

Data Flow TCP does Flow Control. TCP UDP does not have an option for
Control requires three packets to set up a ow control
socket connection, before any
user data can be sent. TCP
handles reliability and congestion
control.

Error Checking TCP does error checking UDP does error checking, but no
recovery options.

Fields 1. Sequence Number, 2. AcK 1. Length, 2. Source port, 3.


number, 3. Data oset, 4. Destination port, 4. Check Sum
Reserved, 5. Control bit, 6.
Window, 7. Urgent Pointer 8.
Options, 9. Padding, 10. Check
Sum, 11. Source port, 12.
Destination port

Acknowledgemen Acknowledgement segments No Acknowledgment


t

Handshake SYN, SYN-ACK, ACK No handshake (connectionless


protocol)

Checksum checksum to detect errors

1 Dierences in Data Transfer Features 2 How TCP and UDP work


1.1 Reliability 3 Dierent Applications of TCP and UDP
1.2 Ordering 3.1 TCP vs. UDP for Game Servers
1.3 Connection
4 References
1.4 Method of transfer

TCP ensures a reliable and ordered delivery of a stream of bytes from user to server or
vice versa. UDP is not dedicated to end to end connections and communication does
not check readiness of receiver.

TCP is more reliable since it manages message acknowledgment and retransmissions

2 of 6 11/19/2015 4:43 PM
TCP vs UDP - Difference and Comparison | Diffen http://www.diffen.com/difference/TCP_vs_UDP
in case of lost parts. Thus there is absolutely no missing data. UDP does not ensure that vs. GO
communication has reached receiver since concepts of acknowledgment, time out and
retransmission are not present.

TCP transmissions are sent in a sequence and they are received in the same sequence.
In the event of data segments arriving in wrong order, TCP reorders and delivers
application. In the case of UDP, sent message sequence may not be maintained when it
reaches receiving application. There is absolutely no way of predicting the order in
which message will be received.

TCP is a heavy weight connection requiring three packets for a socket connection and
handles congestion control and reliability. UDP is a lightweight transport layer
designed atop an IP. There are no tracking connections or ordering of messages.

TCP reads data as a byte stream and message is transmi ed to segment boundaries.
UDP messages are packets which are sent individually and on arrival are checked for
their integrity. Packets have dened boundaries while data stream has none.

A TCP connection is established via a three way handshake, which is a process of


initiating and acknowledging a connection. Once the connection is established data
transfer can begin. After transmission, the connection is terminated by closing of all
established virtual circuits.

UDP uses a simple transmission model without implicit hand-shaking dialogues for
guaranteeing reliability, ordering, or data integrity. Thus, UDP provides an unreliable
service and datagrams may arrive out of order, appear duplicated, or go missing
without notice. UDP assumes that error checking and correction is either not necessary
or performed in the application, avoiding the overhead of such processing at the
network interface level. Unlike TCP, UDP is compatible with packet broadcasts
(sending to all on local network) and multicasting (send to all subscribers).

Web browsing, email and le transfer are common applications that make use of TCP.
TCP is used to control segment size, rate of data exchange, ow control and network
congestion. TCP is preferred where error correction facilities are required at network
interface level. UDP is largely used by time sensitive applications as well as by servers
that answer small queries from huge number of clients. UDP is compatible with packet
broadcast - sending to all on a network and multicasting sending to all subscribers.
UDP is commonly used in Domain Name System, Voice over IP, Trivial File Transfer
Protocol and online games.

3 of 6 11/19/2015 4:43 PM
TCP vs UDP - Difference and Comparison | Diffen http://www.diffen.com/difference/TCP_vs_UDP
vs. GO

For massively multiplayer online (MMO) games, developers often have to make an
architectural choice between using UDP or TCP persistent connections. The advantages
of TCP are persistent connections, reliability, and being able to use packets of arbitrary
sizes. The biggest problem with TCP in this scenario is its congestion control algorithm,
which treats packet loss as a sign of bandwidth limitations and automatically thro les
the sending of packets. On 3G or Wi-Fi networks, this can cause a signicant latency.

Experienced developer Christoer Lern weighed the pros and cons and recommends
the following criteria to choose whether to use TCP or UDP for your game:

Use HTTP over TCP for making occasional, client-initiated stateless queries when
its OK to have an occasional delay.
Use persistent plain TCP sockets if both client and server independently send
packets but an occasional delay is OK (e.g. Online Poker, many MMOs).
Use UDP if both client and server may independently send packets and
occasional lag is not OK (e.g. Most multiplayer action games, some MMOs).

Wikipedia: Transmission Control Protocol


Wikipedia: User Datagram Protocol
UDP vs TCP for game servers

WPA vs WPA2 Hub vs Switch Cat5 vs Cat5e

Internet vs World Wide Router vs Switch Modem vs Router


Web

4 of 6 11/19/2015 4:43 PM

Das könnte Ihnen auch gefallen