TCP vs UDP Questions with Answers

53 practice questions on TCP vs UDP (Computer Networks) with answers and step-by-step solutions. Try 10 samples below, then practise all 53 free in the AptiNest app.

Sample questions

Question 1Easy

Which layer's protocols provide process-to-process (port-based) delivery?

  1. Network layer
  2. Physical layer
  3. Data link layer
  4. Transport layer

Answer: D. Transport layer

Explanation

IP delivers host to host; TCP and UDP use port numbers to deliver to the right process.

Step-by-step solution

  1. IP gets a packet from one host to another host.
  2. Delivering it to the exact right application process on that host needs an extra piece of addressing.
  3. That extra addressing, port numbers, is added by the transport layer.

Why the other options are wrong

  • A. The network layer (IP) delivers packets host-to-host, not down to the specific process level.
  • B. The physical layer just deals with raw signals, far below any concept of addressing at all.
  • C. The data link layer delivers frames between adjacent devices on one link, using MAC addresses, not process-level ports.

Tip: IP = host-to-host; TCP/UDP ports = process-to-process, the final mile of delivery.

Question 2Easy

Which statement about TCP is true?

  1. It delivers a reliable, ordered byte stream
  2. It sends data without any connection setup
  3. It preserves the boundaries of each application message
  4. It never retransmits data

Answer: A. It delivers a reliable, ordered byte stream

Explanation

TCP numbers bytes, retransmits lost data and reorders segments; application message boundaries are not preserved (UDP preserves them).

Step-by-step solution

  1. TCP numbers every byte it sends, not just whole messages.
  2. It guarantees those bytes are delivered to the application reliably and in the correct order.
  3. It retransmits anything lost along the way to maintain that guarantee.

Why the other options are wrong

  • B. TCP requires a three-way handshake before any data flows; it is never connectionless.
  • C. TCP treats data as one continuous stream of bytes with no inherent message boundaries; UDP is the one that preserves each datagram's boundary.
  • D. TCP absolutely retransmits lost data; that is one of its core reliability guarantees.

Tip: TCP = reliable, ordered byte stream, no message boundaries preserved.

Question 3Easy

Which sequence of segments opens a TCP connection?

  1. SYN, ACK, FIN
  2. ACK, SYN, SYN-ACK
  3. SYN, SYN-ACK, ACK
  4. SYN, FIN, ACK

Answer: C. SYN, SYN-ACK, ACK

Explanation

The three-way handshake: client sends SYN, server replies SYN-ACK, client sends ACK. Both sides exchange initial sequence numbers.

Step-by-step solution

  1. The client sends a SYN carrying its own initial sequence number.
  2. The server replies with a SYN-ACK, acknowledging the client's SYN and carrying its own initial sequence number.
  3. The client sends a final ACK, acknowledging the server's SYN, completing the handshake.

Why the other options are wrong

  • A. FIN belongs to connection teardown, not to opening a connection.
  • B. This reorders the handshake; the client must send SYN first, before anything else happens.
  • D. FIN belongs to connection teardown; it has no place in opening a new connection.

Tip: SYN -> SYN-ACK -> ACK: both sides confirm they can hear each other and agree on starting sequence numbers.

Question 4Easy

A TCP segment has sequence number 1001 and carries 500 bytes of data. What acknowledgement number does the receiver send if it arrives in order?

  1. 1001
  2. 1502
  3. 1501
  4. 1500

Answer: C. 1501

Explanation

TCP acknowledges the next byte it expects: 1001 + 500 = 1501.

Step-by-step solution

  1. A TCP acknowledgement number names the next byte the receiver expects.
  2. The segment started at sequence number 1001 and carried 500 bytes.
  3. The next expected byte is 1001 + 500 = 1501.

Why the other options are wrong

  • A. 1001 is just the segment's own starting sequence number, not the next byte expected.
  • B. 1502 overshoots by one, as if the segment carried 501 bytes instead of 500.
  • D. 1500 is one byte short; it is the last byte received, not the next one expected.

Tip: ACK number = sequence number of the segment + its data length.

Question 5Medium

Why is UDP often preferred for live voice and video calls?

  1. UDP encrypts media automatically
  2. Late data is useless, so retransmission delays hurt more than occasional loss
  3. UDP has a larger header that carries timing and jitter information for media streams
  4. UDP guarantees in-order delivery

Answer: B. Late data is useless, so retransmission delays hurt more than occasional loss

Explanation

Real-time media tolerates small losses but not the delay of retransmission and head-of-line blocking.

Step-by-step solution

  1. Real-time voice and video tolerate small, occasional losses, like a brief glitch in one frame.
  2. They do not tolerate the delay of waiting for TCP to detect and retransmit a lost packet.
  3. UDP lets the application just move on past a loss instead of stalling for a retransmission.

Why the other options are wrong

  • A. UDP itself provides no encryption at all; that would need to be layered on top separately, for example with SRTP.
  • C. UDP's header is tiny and generic; it does not carry any timing or jitter information specific to media streams.
  • D. UDP guarantees nothing about ordering at all; that is exactly the opposite of one of its defining traits.

Tip: Late data is often worse than lost data for real-time media; that is the whole argument for UDP over TCP here.

Question 6Medium

Which values uniquely identify a TCP connection on the Internet?

  1. Source MAC address and destination MAC address
  2. Source IP and destination IP addresses only, with no port information at all, because ports are optional
  3. Destination port alone
  4. Source IP, source port, destination IP, destination port (and protocol)

Answer: D. Source IP, source port, destination IP, destination port (and protocol)

Explanation

Many clients can talk to port 443 on one server; the 4-tuple (plus protocol) keeps their connections apart.

Step-by-step solution

  1. Many different clients can all connect to the exact same server IP and port at once.
  2. The server's operating system needs a way to keep each of their connections separate.
  3. It does this using the full 4-tuple: source IP, source port, destination IP, destination port (plus the protocol).

Why the other options are wrong

  • A. MAC addresses are a link-local concept that changes at every hop; they play no role in identifying an end-to-end TCP connection.
  • B. Ports are absolutely required; many different clients can connect to the exact same server IP and port at once, and only the full 4-tuple keeps their connections separate.
  • C. The destination port alone is shared by every client connecting to that same service; it cannot distinguish between them.

Tip: TCP connection identity = source IP + source port + destination IP + destination port (+ protocol).

Question 7Medium

Why does TCP choose a random-looking initial sequence number rather than starting at 0?

  1. To make the three-way handshake complete faster
  2. To avoid confusion with old segments and make sequence prediction attacks harder
  3. To encrypt the data in the segment
  4. Because sequence number 0 is reserved for UDP traffic on the same port pair, so TCP must avoid it

Answer: B. To avoid confusion with old segments and make sequence prediction attacks harder

Explanation

Unpredictable ISNs protect against delayed duplicates from older connections and against spoofed segment injection.

Step-by-step solution

  1. If TCP always started at sequence number 0, an attacker could easily predict it.
  2. A predictable sequence number makes it much easier to inject or hijack segments into a connection.
  3. Choosing a random-looking initial sequence number instead makes such attacks far harder, and also helps distinguish a new connection from stray old segments reusing the same port pair.

Why the other options are wrong

  • A. Randomising the ISN has no effect on how quickly the handshake completes.
  • C. Sequence numbers are not a form of encryption; they are just counters for ordering and acknowledgement.
  • D. UDP does not share or reserve any sequence number space with TCP at all; the two protocols are completely independent.

Tip: Random ISN: defends against both sequence-number-guessing attacks and confusion with old connections' leftover segments.

Question 8Medium

What is the purpose of the receive window advertised in TCP headers?

  1. Identifying the application on the receiving host
  2. Flow control: preventing the sender from overwhelming the receiver's buffer
  3. Detecting corrupted segments using a checksum computed over the header and the data
  4. Congestion control in the routers

Answer: B. Flow control: preventing the sender from overwhelming the receiver's buffer

Explanation

The receiver advertises how much buffer space it has. Congestion control uses a separate congestion window maintained by the sender.

Step-by-step solution

  1. The receiver tracks how much free space is left in its own receive buffer.
  2. It advertises that amount in the receive window field of every segment it sends.
  3. The sender must never leave more unacknowledged data outstanding than that advertised window.

Why the other options are wrong

  • A. Identifying the right application is the port number's job, not the receive window's.
  • C. Detecting corruption is the checksum field's job, a separate mechanism from the receive window.
  • D. Congestion control is handled by the sender's own congestion window (cwnd), not by routers or the receive window.

Tip: Flow control (rwnd) protects the receiver; congestion control (cwnd) protects the network. Two separate windows, two separate jobs.

Question 9Hard

Without window scaling the TCP receive window is at most 65,535 bytes. What is the maximum throughput of one TCP connection over a path with 20 ms RTT?

  1. About 52.4 Mbps
  2. About 13.1 Mbps
  3. About 26.2 Mbps
  4. About 3.3 Mbps

Answer: C. About 26.2 Mbps

Explanation

At most one window per RTT: 65,535 x 8 bits / 0.02 s = 26.2 Mbps.

Step-by-step solution

  1. At most one full window of data can be outstanding per RTT without window scaling.
  2. Convert the window to bits: 65,535 x 8 = 524,280 bits.
  3. Divide by the RTT: 524,280 / 0.02 s = approximately 26.2 Mbps.

Why the other options are wrong

  • A. 52.4 Mbps would be double the correct value, as if two windows could be sent per RTT instead of one.
  • B. 13.1 Mbps is half the correct value, as if the window were half its actual size.
  • D. 3.3 Mbps is far too low; it does not match the given window size and RTT at all.

Tip: Max throughput = max window size (bytes) x 8 / RTT (seconds), capped at 65,535 bytes without window scaling.

Question 10Hard

What is TCP head-of-line blocking?

  1. The SYN queue fills up
  2. A lost segment stops delivery of later, already-received data until it is retransmitted
  3. The first byte of every stream is always dropped by routers on the path to the receiver
  4. The header is larger than the data carried

Answer: B. A lost segment stops delivery of later, already-received data until it is retransmitted

Explanation

Because TCP delivers bytes strictly in order, one loss stalls everything behind it, even data for unrelated requests.

Step-by-step solution

  1. TCP insists on delivering bytes to the application strictly in order.
  2. If one segment is lost, later segments that already arrived fine still cannot be delivered until the gap is filled.
  3. This means everything behind the lost segment is stalled, even unrelated data for other requests on the same connection.

Why the other options are wrong

  • A. A full SYN queue is a separate server resource-exhaustion issue (related to SYN flood attacks), not head-of-line blocking.
  • C. Routers do not systematically drop the first byte of every stream; that is not a real networking behaviour.
  • D. Header size relative to data size is just an efficiency concern, unrelated to the ordering problem head-of-line blocking describes.

Tip: TCP head-of-line blocking: one lost segment stalls everything behind it, even unrelated data for other requests on the same connection.

Practise all 53 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Computer Networks topics · All topics