TCP vs UDP
- 31Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary function of Layer 4 in the OSI model?
31 questions
- 1
What is the primary function of Layer 4 in the OSI model?
Model answer
Layer 4 provides transparent transfer of data between end hosts.
Explanation
The transport layer encapsulates data with a Layer 4 header and uses lower layers to deliver data unchanged, making the transfer transparent to the hosts.
- 2
What services does TCP provide to applications that UDP does not?
Model answer
TCP provides reliable data transfer, error recovery, data sequencing, and flow control.
Explanation
TCP includes mechanisms for acknowledgments, retransmissions, ordering, and flow control, while UDP does not.
- 3
What are the two main functions of Layer 4 port numbers?
Model answer
Port numbers identify the Application Layer protocol and enable session multiplexing.
Explanation
Destination port indicates the application (e.g., HTTP on port 80), and source/destination port pairs track multiple simultaneous sessions.
- 4
Define a session in the context of network communication.
Model answer
A session is an exchange of data between two or more communicating devices.
Explanation
Sessions allow a host to handle multiple communication streams simultaneously, using port numbers to distinguish them.
- 5
What are the three port number ranges designated by IANA?
Model answer
Well-known (0–1023), Registered (1024–49151), and Ephemeral/private/dynamic (49152–65535).
Explanation
Well-known ports are for major protocols, registered require registration, and ephemeral are used for random source ports.
- 6
Which port range should hosts use when randomly selecting a source port number?
Model answer
The ephemeral port range (49152–65535).
Explanation
Source ports are randomly chosen from the ephemeral range to avoid conflicts and support session multiplexing.
- 7
What does 'connection-oriented' mean in the context of TCP?
Model answer
TCP establishes a connection with the destination host before sending data, using a three-way handshake.
Explanation
The three-way handshake (SYN, SYN-ACK, ACK) sets up the connection, ensuring both sides are ready to communicate.
- 8
Describe the three steps of the TCP three-way handshake.
Model answer
- Host A sends SYN. 2. Host B replies with SYN-ACK. 3. Host A sends ACK. The connection is then established.
Explanation
This process synchronizes sequence numbers and establishes a reliable connection before data exchange.
- 9
How does TCP provide reliable communication?
Model answer
The destination host must acknowledge each received segment; if the source does not receive an acknowledgment, it retransmits the segment.
Explanation
Acknowledgments and retransmissions ensure all data arrives intact.
- 10
What is forward acknowledgment in TCP?
Model answer
Forward acknowledgment means the acknowledgment field indicates the next sequence number the host expects to receive, not the last one received.
Explanation
This allows the sender to know which segments have been successfully received and which need retransmission.
- 11
How does TCP handle sequencing of data?
Model answer
TCP uses sequence numbers in its header to allow the destination to reorder segments that arrive out of order.
Explanation
Each TCP segment has a sequence number; the receiver uses these numbers to reconstruct the original data stream.
- 12
What mechanism does TCP use for flow control?
Model answer
TCP uses a window size field and a sliding window to adjust the rate of data transmission so the receiver is not overwhelmed.
Explanation
The window size determines how much data can be sent before an acknowledgment is required, and the sliding window dynamically adjusts based on network conditions.
- 13
List three flags in the TCP header used for connection establishment and termination.
Model answer
SYN (synchronize), ACK (acknowledgment), and FIN (finish).
Explanation
SYN and ACK are used in the three-way handshake; FIN is used to terminate a connection.
- 14
Explain how TCP terminates a connection.
Model answer
Host A sends FIN, Host B replies with ACK, then B sends its own FIN, and A replies with ACK. This is sometimes called the four-way handshake.
Explanation
Each side must send a FIN and receive an ACK to close its end of the connection.
- 15
What happens if a TCP segment is not acknowledged?
Model answer
The sender waits a certain time and then retransmits the unacknowledged segment.
Explanation
TCP retransmission ensures reliability; if no ACK is received within a timeout, the segment is resent.
- 16
How does UDP differ from TCP in terms of connection establishment?
Model answer
UDP is connectionless; it sends data without first establishing a connection with the destination.
Explanation
UDP simply transmits datagrams without any handshake, reducing overhead but offering no reliability.
- 17
Does UDP provide acknowledgments or retransmission?
Model answer
No, UDP does not provide acknowledgments or retransmission; it sends data best-effort.
Explanation
UDP has no mechanism to confirm receipt or resend lost segments.
- 18
Does UDP provide sequencing of data?
Model answer
No, UDP does not provide sequencing; segments may arrive out of order without any reordering.
Explanation
The UDP header lacks a sequence number field, so ordering is not guaranteed.
- 19
What fields are present in the UDP header?
Model answer
Source port, destination port, length, and checksum.
Explanation
The UDP header is minimal with only four fields, providing basic addressing and error checking.
- 20
Why is UDP preferred for real-time applications like VoIP?
Model answer
UDP has lower overhead and no retransmission delays, making it faster and more suitable for delay-sensitive applications.
Explanation
Real-time voice/video can tolerate some packet loss but require low latency; TCP's reliability mechanisms introduce unacceptable delays.
- 21
Give an example of an application that typically uses TCP and one that uses UDP.
Model answer
TCP: HTTP (web browsing). UDP: DNS (typically).
Explanation
HTTP requires reliable delivery; DNS usually uses UDP for speed but can switch to TCP for large responses.
- 22
Name an application that uses both TCP and UDP.
Model answer
DNS (Domain Name System).
Explanation
DNS primarily uses UDP for queries but falls back to TCP when the response is large or for zone transfers.
- 23
What port number does HTTP use?
Model answer
TCP port 80.
Explanation
HTTP is a web protocol that uses TCP port 80 for communication.
- 24
What port number does HTTPS use?
Model answer
TCP port 443.
Explanation
HTTPS is the secure version of HTTP and uses TCP port 443.
- 25
Which ports does FTP use?
Model answer
TCP ports 20 and 21.
Explanation
FTP uses port 21 for control and port 20 for data transfer.
- 26
What port does SSH use?
Model answer
TCP port 22.
Explanation
SSH (Secure Shell) is used for secure remote access and uses TCP port 22.
- 27
What port does SMTP use?
Model answer
TCP port 25.
Explanation
SMTP (Simple Mail Transfer Protocol) is used for sending email and uses TCP port 25.
- 28
What port does DHCP use?
Model answer
UDP ports 67 and 68.
Explanation
DHCP (Dynamic Host Configuration Protocol) uses UDP ports 67 (server) and 68 (client).
- 29
What port does TFTP use?
Model answer
UDP port 69.
Explanation
TFTP (Trivial File Transfer Protocol) uses UDP port 69 for file transfer.
- 30
What ports does SNMP use?
Model answer
UDP ports 161 and 162.
Explanation
SNMP (Simple Network Management Protocol) uses port 161 for queries and 162 for traps.
- 31
What port does Syslog use?
Model answer
UDP port 514.
Explanation
Syslog is used for logging system messages and typically uses UDP port 514.

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