What is the difference between TCP and UDP? Also explain the TCP/IP model briefly.
ReportedSource: GeeksforGeeks interview experience: TCS Ninja
TCP: connection-oriented, reliable, ordered, congestion-controlled (web, email). UDP: connectionless, fast, no guarantees (DNS, video, games). TCP/IP layers: application, transport, internet, link.
TCP (Transmission Control Protocol). Connection-oriented (three-way handshake), reliable (acknowledgements, retransmission), ordered delivery, flow and congestion control. Higher overhead and latency. Used for web (HTTP/1.1, HTTP/2), email, file transfer, SSH.
UDP (User Datagram Protocol). Connectionless, no delivery or ordering guarantee, tiny header, low latency. The application handles loss if it cares. Used for DNS queries, video calls, live streaming, online games; QUIC (HTTP/3) builds reliability on top of UDP.
TCP/IP model (4 layers).
- Application: HTTP, DNS, SMTP, FTP.
- Transport: TCP, UDP (ports identify processes).
- Internet: IP routing and addressing, ICMP.
- Network access / link: Ethernet, Wi-Fi, MAC addresses.
The OSI model splits these into 7 layers (application, presentation, session, transport, network, data link, physical); interviewers often ask you to map one onto the other.