1. Home
  2. Explore
  3. Computer Science
  4. TCP vs UDP

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

TCP vs UDP

  • 31Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Layer 4 Basics

What is one primary function of Layer 4 (Transport Layer) protocols?

31 questions

  1. 1

    What is one primary function of Layer 4 (Transport Layer) protocols?

    1. A

      Encapsulating data into frames for physical transmission

    2. B

      Performing routing between different networks

    3. C

      Assigning MAC addresses to network interfaces

    4. D

      Providing transparent transfer of data between end hosts

    Correct answer
    D

    Providing transparent transfer of data between end hosts

    Explanation

    Layer 4 provides transparent transfer of data between end hosts, meaning the hosts are unaware of the underlying network details. MAC addresses are Layer 2, routing is Layer 3, and framing is Layer 2.

  2. 2

    Which of the following is NOT a service provided by TCP to applications?

    1. A

      Flow control

    2. B

      Error recovery

    3. C

      Session multiplexing

    4. D

      Reliable data transfer

    Correct answer
    C

    Session multiplexing

    Explanation

    Session multiplexing is provided by both TCP and UDP using port numbers. TCP provides reliable data transfer, error recovery, and flow control, while UDP does not.

  3. 3

    What is the purpose of Layer 4 port numbers?

    1. A

      To provide error checking for the data payload

    2. B

      To identify the physical interface on a network device

    3. C

      To enable routing of packets across different networks

    4. D

      To identify the Application Layer protocol and manage sessions

    Correct answer
    D

    To identify the Application Layer protocol and manage sessions

    Explanation

    Port numbers identify the Application Layer protocol (e.g., HTTP uses port 80) and allow session multiplexing, enabling hosts to handle multiple communication sessions simultaneously.

  4. 4

    According to IANA, which range of port numbers is considered 'well-known'?

    1. A

      0–255

    2. B

      49152–65535

    3. C

      1024–49151

    4. D

      0–1023

    Correct answer
    D

    0–1023

    Explanation

    Well-known port numbers are from 0 to 1023. Registered ports are 1024–49151, and ephemeral/dynamic ports are 49152–65535.

  5. 5

    Which port number range should a host use when selecting a random source port for TCP or UDP?

    1. A

      Reserved range

    2. B

      Well-known range

    3. C

      Ephemeral range

    4. D

      Registered range

    Correct answer
    C

    Ephemeral range

    Explanation

    Source ports are randomly selected from the ephemeral (private/dynamic) range (49152–65535) to ensure uniqueness for each session.

  6. 6

    How many bits are used for the source and destination port fields in the TCP and UDP headers?

    1. A

      16 bits

    2. B

      64 bits

    3. C

      8 bits

    4. D

      32 bits

    Correct answer
    A

    16 bits

    Explanation

    Each port field is 16 bits (2 bytes), providing a total of 65536 port numbers (2162^{16}216).

  7. 7

    Which characteristic distinguishes TCP as a connection-oriented protocol?

    1. A

      It uses a three-way handshake before data exchange

    2. B

      It sends data without establishing a connection

    3. C

      It requires both hosts to use the same subnet mask

    4. D

      It relies on IP for addressing

    Correct answer
    A

    It uses a three-way handshake before data exchange

    Explanation

    TCP is connection-oriented; it establishes a connection via the three-way handshake (SYN, SYN-ACK, ACK) before sending data, ensuring both sides are ready.

  8. 8

    What are the three steps of the TCP three-way handshake in order?

    1. A

      SYN, ACK, SYN-ACK

    2. B

      ACK, SYN, SYN-ACK

    3. C

      SYN, SYN-ACK, ACK

    4. D

      SYN-ACK, SYN, ACK

    Correct answer
    C

    SYN, SYN-ACK, ACK

    Explanation

    The three-way handshake proceeds as: 1) SYN, 2) SYN-ACK, 3) ACK. This establishes a reliable connection.

  9. 9

    Which TCP header flags are used to initiate a connection?

    1. A

      SYN and ACK

    2. B

      FIN and ACK

    3. C

      SYN only

    4. D

      RST and SYN

    Correct answer
    A

    SYN and ACK

    Explanation

    The SYN flag initiates a connection, and the ACK flag acknowledges the SYN during the handshake. The first message uses SYN; the second uses SYN+ACK; the third uses ACK.

  10. 10

    In TCP, what does the acknowledgment number indicate in a segment?

    1. A

      The number of bytes in the segment

    2. B

      The total number of segments sent

    3. C

      The next sequence number the host expects to receive

    4. D

      The sequence number of the last received byte

    Correct answer
    C

    The next sequence number the host expects to receive

    Explanation

    TCP uses forward acknowledgment: the acknowledgment number is the next expected sequence number, telling the sender that all data up to that number minus one has been received.

  11. 11

    How does TCP ensure reliable data delivery?

    1. A

      By using checksums to detect and correct errors

    2. B

      By requiring every segment to be acknowledged and retransmitting if not acknowledged

    3. C

      By resending all data if any error occurs

    4. D

      By using a sliding window to increase throughput

    Correct answer
    B

    By requiring every segment to be acknowledged and retransmitting if not acknowledged

    Explanation

    TCP provides reliability through acknowledgments and retransmission: if a segment is not acknowledged within a timeout, it is retransmitted.

  12. 12

    What is the purpose of the TCP window size field?

    1. A

      To indicate the number of bits in the segment

    2. B

      To enable encryption of the data stream

    3. C

      To specify the version of TCP being used

    4. D

      To provide flow control by limiting how much data can be sent before an acknowledgment

    Correct answer
    D

    To provide flow control by limiting how much data can be sent before an acknowledgment

    Explanation

    The window size field allows flow control; it tells the sender how many bytes of data it can transmit before requiring an acknowledgment, preventing the receiver from being overwhelmed.

  13. 13

    How does TCP handle segments that arrive out of order?

    1. A

      It tells the sender to resend all segments

    2. B

      It uses sequence numbers to reorder them correctly

    3. C

      It ignores the order and processes them as they arrive

    4. D

      It discards them and requests retransmission

    Correct answer
    B

    It uses sequence numbers to reorder them correctly

    Explanation

    TCP sequence numbers allow the receiver to reorder out-of-order segments into the correct order before passing data to the application.

  14. 14

    Which three flags are commonly used in TCP for connection establishment and termination?

    1. A

      ACK, PSH, URG

    2. B

      SYN, RST, FIN

    3. C

      SYN, ACK, FIN

    4. D

      FIN, ACK, RST

    Correct answer
    C

    SYN, ACK, FIN

    Explanation

    SYN and ACK are used for connection establishment (three-way handshake), and FIN is used for connection termination (four-way handshake).

  15. 15

    Which of the following is a characteristic of UDP?

    1. A

      Flow control using window size

    2. B

      Connection-oriented communication

    3. C

      Low overhead communication

    4. D

      Reliable data delivery

    Correct answer
    C

    Low overhead communication

    Explanation

    UDP is connectionless, unreliable, and has low overhead because it has a minimal header (8 bytes) and no flow control or sequencing. It provides best-effort delivery.

  16. 16

    Which fields are present in the UDP header?

    1. A

      Source port, destination port, window size, checksum

    2. B

      Source port, destination port, length, checksum

    3. C

      Source port, destination port, flags, urgent pointer

    4. D

      Source port, destination port, sequence number, acknowledgement number

    Correct answer
    B

    Source port, destination port, length, checksum

    Explanation

    The UDP header contains only four fields: source port, destination port, length, and checksum. It lacks sequence number, acknowledgment number, window size, and flags.

  17. 17

    How does UDP handle lost segments?

    1. A

      It retransmits them after a timeout

    2. B

      It uses forward error correction to recover lost data

    3. C

      It has no mechanism for retransmission; segments are sent best-effort

    4. D

      It requests the sender to resend using a NAK

    Correct answer
    C

    It has no mechanism for retransmission; segments are sent best-effort

    Explanation

    UDP does not provide any reliability; it sends segments best-effort. If a segment is lost, there is no retransmission mechanism.

  18. 18

    UDP does not provide which of the following TCP features? (Select three)

    1. A

      Port numbers

    2. B

      Flow control

    3. C

      Sequencing

    4. D

      Error recovery

    Correct answer
    B

    Flow control

    Explanation

    UDP does not provide error recovery, sequencing, or flow control. However, both TCP and UDP provide port numbers for addressing.

  19. 19

    Which transport protocol is more suitable for real-time voice and video applications?

    1. A

      TCP, because it ensures reliable delivery

    2. B

      UDP, because it supports larger packet sizes

    3. C

      TCP, because it provides flow control

    4. D

      UDP, because it has low overhead and is delay-sensitive

    Correct answer
    D

    UDP, because it has low overhead and is delay-sensitive

    Explanation

    Real-time applications like VoIP and video conferencing are delay-sensitive. UDP's low overhead and lack of retransmission avoid delays, making it preferable despite sacrificing reliability.

  20. 20

    Why is TCP preferred for file downloads over UDP?

    1. A

      TCP guarantees reliable delivery and error recovery

    2. B

      TCP provides faster transfer speeds

    3. C

      TCP uses smaller headers than UDP

    4. D

      TCP does not require acknowledgments

    Correct answer
    A

    TCP guarantees reliable delivery and error recovery

    Explanation

    File downloads require data integrity; TCP ensures all data is received correctly by retransmitting lost segments. UDP does not guarantee delivery.

  21. 21

    Which application layer protocol uses both TCP and UDP?

    1. A

      FTP

    2. B

      DHCP

    3. C

      DNS

    4. D

      HTTP

    Correct answer
    C

    DNS

    Explanation

    DNS uses UDP for most queries (port 53) but can use TCP for zone transfers or when responses exceed 512 bytes.

  22. 22

    Which of the following is true about TCP and UDP?

    1. A

      Both provide sequencing of data segments

    2. B

      Both provide reliable delivery

    3. C

      Both provide flow control

    4. D

      Both provide Layer 4 addressing using port numbers

    Correct answer
    D

    Both provide Layer 4 addressing using port numbers

    Explanation

    Both TCP and UDP use port numbers for Layer 4 addressing. Only TCP provides flow control, reliability, and sequencing.

  23. 23

    What is a common application that uses UDP but implements reliability at the application layer?

    1. A

      HTTP

    2. B

      TFTP

    3. C

      SMTP

    4. D

      SSH

    Correct answer
    B

    TFTP

    Explanation

    TFTP (Trivial File Transfer Protocol) uses UDP but adds its own reliability mechanisms at the application layer, such as acknowledgments and retransmissions.

  24. 24

    Which port numbers are used by FTP for control and data?

    1. A

      TCP 21 and 22

    2. B

      UDP 20 and 21

    3. C

      TCP 20 and 23

    4. D

      TCP 20 and 21

    Correct answer
    D

    TCP 20 and 21

    Explanation

    FTP uses TCP ports 20 for data transfer and 21 for control commands.

  25. 25

    Which protocol uses TCP port 22?

    1. A

      HTTP

    2. B

      SMTP

    3. C

      SSH

    4. D

      Telnet

    Correct answer
    C

    SSH

    Explanation

    SSH (Secure Shell) uses TCP port 22 for secure remote access.

  26. 26

    What is the default TCP port for HTTP?

    1. A

      25

    2. B

      8080

    3. C

      80

    4. D

      443

    Correct answer
    C

    80

    Explanation

    HTTP uses TCP port 80 by default. HTTPS uses port 443.

  27. 27

    Which port does SMTP use by default?

    1. A

      UDP 25

    2. B

      UDP 110

    3. C

      TCP 25

    4. D

      TCP 110

    Correct answer
    C

    TCP 25

    Explanation

    SMTP (Simple Mail Transfer Protocol) uses TCP port 25 for sending email.

  28. 28

    Which protocol uses UDP ports 67 and 68?

    1. A

      DHCP

    2. B

      DNS

    3. C

      TFTP

    4. D

      SNMP

    Correct answer
    A

    DHCP

    Explanation

    DHCP (Dynamic Host Configuration Protocol) uses UDP ports 67 (server) and 68 (client).

  29. 29

    Which application uses UDP port 69?

    1. A

      DNS

    2. B

      SNMP

    3. C

      TFTP

    4. D

      Syslog

    Correct answer
    C

    TFTP

    Explanation

    TFTP (Trivial File Transfer Protocol) uses UDP port 69.

  30. 30

    Which protocol uses UDP ports 161 and 162?

    1. A

      Syslog

    2. B

      SNMP

    3. C

      DHCP

    4. D

      DNS

    Correct answer
    B

    SNMP

    Explanation

    SNMP (Simple Network Management Protocol) uses UDP ports 161 (queries) and 162 (traps).

  31. 31

    Which protocol uses UDP port 514?

    1. A

      DHCP

    2. B

      TFTP

    3. C

      Syslog

    4. D

      SNMP

    Correct answer
    C

    Syslog

    Explanation

    Syslog uses UDP port 514 for sending log messages.

Question 1 of 31
Question 1 of 31

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent