Posts tagged Networking interview questions

TCP vs UDP differences



Difference between TCP and UDP Protocol :


  • Connection based
  • Guaranteed reliable and ordered
  • Automatically breaks up your data into packets for you
  • Makes sure it doesn’t send data too fast for the internet connection to handle (flow control)
  • Easy to use, you just read and write data like its a file


  • No concept of connection, you have to code this yourself
  • No guarantee of reliability or ordering of packets, they may arrive out of order, be duplicated, or not arrive at all!
  • You have to manually break your data up into packets and send them
  • You have to make sure you don’t send data too fast for your internet connection to handle
  • If a packet is lost, you need to devise some way to detect this, and resend that data if necessary

Reliability: TCP is connection-oriented protocol. When a file or message send it will get delivered unless connections fails. If connection lost, the server will request the lost part. There is no corruption while transferring a message. Reliability: UDP is connection-less protocol. When you a send a data or message, you don’t know if it’ll get there, it could get lost on the way. There may be corruption while transferring a message.
Ordered: If you send two messages along a connection, one after the other, you know the first message will get there first. You don’t have to worry about data arriving in the wrong order. Ordered: If you send two messages out, you don’t know what order they’ll arrive in i.e. no ordered
Heavyweight: – when the low level parts of the TCP “stream” arrive in the wrong order, resend requests have to be sent, and all the out of sequence parts have to be put back together, so requires a bit of work to piece together. Lightweight: No ordering of messages, no tracking connections, etc. It’s just fire and forget! This means it’s a lot quicker, and the network card / OS have to do very little work to translate the data back from the packets.
Streaming: Data is read as a “stream,” with nothing distinguishing where one packet ends and another begins. There may be multiple packets per read call. Data grams: Packets are sent individually and are guaranteed to be whole if they arrive. One packet per one read call.
Examples: World Wide Web (Apache TCP port 80), e-mail (SMTP TCP port 25 Postfix MTA), File Transfer Protocol (FTP port 21) and Secure Shell (OpenSSH port 22) etc. Examples: Domain Name System (DNS UDP port 53), streaming media applications such as IPTV or movies, Voice over IP (VoIP), Trivial File Transfer Protocol (TFTP) and online multi player games etc

Networking interview questions


Question 1: How does the race condition occur?

It occurs when two or more processes are reading or writing some shared data and the final result depends on who runs precisely when.

Question 2: What is multiprogramming?

Multiprogramming is a rapid switching of the CPU back and forth between processes.

Question 3: Name the seven layers of the OSI Model and describe them briefly.

Physical Layer – covers the physical interface between devices and the rules by which bits are passed from one to another.

Data Link Layer – attempts o make the physical link reliable and provides the means to activate, maintain, and deactivate the link.

Network Layer – provides for the transfer of information between end systems across

some sort communications network.

Transport Layer – provides a mechanism for the exchange of data between end system.

Session Layer – provides the mechanism for controlling the dialogue between applications

in end systems.

Presentation Layer – defines the format of the data to be exchanged between applications

and offers application programs a set of data transformation services.

Application Layer – provides a means for application programs to access the OSI environment.

Question 4: What is the difference between TCP and UDP?

TCP and UDP are both transport-level protocols. TCP is designed to provide reliable

communication across a variety of reliable and unreliable networks and internets.

UDP provides a connectionless service for application-level procedures. Thus, UDP is basically

an unreliable service; delivery and duplicate protection are not guareented.

Question 5: What does a socket consists of?

The combination of an IP address and a port number is called a socket.

Go to Top