# Topic covered
* Transmission Control Protocol (TCP)
* TCP Three-Way Handshake Process
* User Datagram Protocol (UDP)
* TCP vs UDP
* When to use UDP and TCP?
4.1 Transmission Control Protocol (TCP)
TCP is a transport layer protocol.
TCP is defined as a connection-oriented communication protocol that allows computing devices and applications to
send data via a network and verify its delivery.
It is a reliable protocol as it detects the error and retransmits the damaged frames.
Therefore, it ensures all the segments must be received and acknowledged before the transmission is considered
to be completed and a virtual circuit is discarded.
At the sending end, TCP divides the whole message into smaller units known as segment, and each segment contains
a sequence number which is required for reordering the frames to form an original message.
At the receiving end, TCP collects all the segments and reorders them based on sequence numbers.
TCP Three-Way Handshake Process
https://www.guru99.com/tcp-3-way-handshake.html
TCP is as a connection-oriented communication protocol,
It creates a virtual circuit between the sender and receiver, and it is active for the duration of the transmission.
When the transmission process is finished the connection is terminated by the closing of an established virtual circuit
The connection is established with the help of three-way handshake protocol like SYN, SYN-ACK, ACK.

Features of TCP
* Connection oriented - Reliability
* Delivery Acknowledgements
* Inorder delivery
* Error Control
* Flow control
* Congestion Control
4.2 User Datagram Protocol (UDP)
UDP is a transport layer protocol. It provides connectionless service and end-to-end delivery of transmission.
It is an unreliable protocol as it discovers the errors but not specify the error.
UDP is a Datagram oriented protocol. It is used for broadcast and multicast type of network transmission.
The UDP protocol works almost similar to TCP, but it throws all the error-checking stuff out,
all the back-and-forth communication and deliverability.
- UDP discovers the error, and ICMP protocol reports the error to the sender that user datagram has been damaged.
- UDP consists of the following fields:
- Source port address: The source port address is the address of the application program that has created the message.
- Destination port address: The destination port address is the address of the application program that receives the message.
- Total length: It defines the total number of bytes of the user datagram in bytes.
- Checksum: The checksum is a 16-bit field used in error detection.
- UDP does not specify which packet is lost. UDP contains only checksum; it does not contain any ID of a data segment.
4.3 TCP vs UDP
https://www.guru99.com/tcp-vs-udp-understanding-the-difference.html
https://www.spiceworks.com/tech/networking/articles/tcp-vs-udp/
.
- Type of Service
- TCP is a
connection-orientedprotocol - UDP is a
connectionlessprotocol.
- TCP is a
- Speed
- TCP is comparatively
slowerthan UDP. - UDP is
faster, simpler, and more efficient than TCP.
- TCP is comparatively
- Reliability
- TCP is reliable as it
guarantees the deliveryof data to the destination router. - The delivery of data to the destination cannot be guaranteed in UDP.
- TCP is reliable as it
- Ordering
- In TCP data in received in Inorder
- In UPD data received is out-of-order
- Error checking
- TCP provides
extensiveerror-checking mechanisms andmandatory. - UDP has only the
basicerror checking mechanism using checksums and isoptional.
- TCP provides
- Retransmission
Retransmissionof lost packets is possible in TCP, but not in UDP.- There is
no retransmissionof lost packets in UDP
- Overhead
- TCP has has
more overhead - UDP has
less overhead
- TCP has has
- TCP handles flow-control, Congestion-control, In UDP there is no FC, CC
- Usage
- TCP - HTTP, FTP
- UDP - DNS, DHCP, RIP
4.4 When to use UDP and TCP?
TCP Applications
- When latency and performance issues are not that critical.
- HTTP protocol used to be based on TCP, but the latest protocol HTTP/3 is based on UDP
UDP Applications
- Query response protocol
One query one response- Eg - DNS, DHCP
- High speed
- Receive data quickly even if accuracy suffers.
- Eg - Games, Voice over IP
- Broadcast/Multicast
- Routing Information Protocol (RIP)
- Continuous Streaming
- Skype, YouTube