What's new

Closed Tcp vs. udp

Status
Not open for further replies.

PHC-JEFFREY

Honorary Poster
Joined
Feb 5, 2017
Posts
765
Reaction
197
Points
237
Age
23
network-switches--1.jpg

There are two types of Internet Protocol (IP) traffic. 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.




Comparison chart

TCP versus UDP comparison chart
TCP UDP

Acronym for

Transmission Control Protocol User Datagram Protocol or Universal Datagram Protocol

Connection

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

Function

As a message makes its way across the You do not have permission to view the full content of this post. Log in or register now.from one computer to another. This is connection based. UDP is also a protocol used in message transport or transfer. This is not 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 that require high reliability, and transmission time is relatively less critical. UDP is suitable for applications that need fast, efficient transmission, such as games. UDP's stateless nature is also useful for servers that answer small queries from huge numbers of clients.

Use by other protocols

HTTP, HTTPs, FTP, SMTP, Telnet DNS, DHCP, TFTP, SNMP, RIP, VOIP.

Ordering of data packets

TCP rearrangesYou do not have permission to view the full content of this post. Log in or register now. packets in the order specified. UDP has no inherent order as all 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. UDP is faster because error recovery is not attempted. It is a "best effort" protocol.

Reliability

There is absolute guarantee that the data transferred remains intact and arrives in the same order in which it was sent. There is no guarantee that the messages or packets sent would reach at all.

Header Size

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

Common Header Fields

Source port, Destination port, Check Sum Source port, Destination port, Check Sum

Streaming of data

Data is read as a byte stream, no distinguishing indications are transmitted to signal message (segment) boundaries. Packets are sent individually and are checked for integrity only if they arrive. Packets have definite 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 requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control. UDP is lightweight. There is no ordering of messages, no tracking connections, etc. It is a small transport layer designed on top of IP.

Data Flow Control

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

Error Checking

TCP does error checking and error recovery. Erroneous packets are retransmitted from the source to the destination. UDP does error checking but simply discards erroneous packets. Error recovery is not attempted.

Fields

1. Sequence Number, 2. AcK number, 3. Data offset, 4. Reserved, 5. Control bit, 6. Window, 7. Urgent Pointer 8. Options, 9. Padding, 10. Check Sum, 11. Source port, 12. Destination port 1. Length, 2. Source port, 3. Destination port, 4. Check Sum

Acknowledgement

Acknowledgement segments No Acknowledgment

Handshake

SYN, SYN-ACK, ACK No handshake (connectionless protocol)




You do not have permission to view the full content of this post. Log in or register now. a reliable and ordered delivery of a stream of bytes from user toYou do not have permission to view the full content of this post. Log in or register now. or vice versa. UDP is not dedicated to end to end connections and communication does not check readiness of receiver.




You do not have permission to view the full content of this post. Log in or register now., 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).


You do not have permission to view the full content of this post. Log in or register now. and file transfer are common applications that make use of TCP. TCP is used to control segment size, rate of data exchange, flow 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.







You do not have permission to view the full content of this post. Log in or register now. 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 it's 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 pøkêr, 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).
 

Attachments

Pwede po mag-request?
Pwede pong pa-LIKE para po makatulong sa pagpapataas ko ng Rank. OK lang po kung hindi pwede. ☺
 
Status
Not open for further replies.
Back
Top