🎓 BookMCQ
← Back to 24. Transport Layer Protocols

📝 TCP connection establishment teardown (23 MCQs)

Opening and Closing a Stateful TCP Connection

TCP uses a three-way handshake to establish a connection and sequence spaces, then uses FIN and ACK exchanges to close each direction. The procedure operates at the transport layer over IP. Connection setup synchronizes initial sequence numbers and confirms reachability; teardown supports half-close, allowing one endpoint to stop sending while it can still receive data. It defines the boundary between application processes and packet delivery.

Why Setup and Teardown Need Explicit Control

Before exchanging stream data, both endpoints must agree that a connection exists and synchronize independent sequence spaces. A two-message exchange cannot reliably demonstrate that both sides received the other's latest sequence information under all delayed-segment conditions. Teardown must also distinguish completion of one sending direction from termination of the entire full-duplex connection.

SYN Handshake and FIN-Based Shutdown

The active opener sends SYN with an initial sequence number. The peer replies with SYN-ACK, acknowledging that number and supplying its own; the opener returns ACK. During shutdown, each direction is closed with FIN and acknowledged separately. A normal close often uses four segments, although acknowledgments may be combined and simultaneous close is possible.

Sequence Values During a Three-Way Handshake

Assume client initial sequence number is 100 and server initial sequence number is 500. The client sends SYN sequence 100; the server replies SYN 500 and ACK 101. The client sends ACK 501. SYN consumes one sequence number even though it carries no application data, so the first data byte can begin at 101.

Connection Lifecycle and Delayed Segment Protection

The handshake creates state and negotiates options such as MSS and window scaling. FIN-based close permits each direction to finish independently, while TIME-WAIT helps prevent delayed duplicate segments from contaminating a later connection with the same tuple. Setup and teardown add latency and state, but support orderly stream semantics. Actual performance also depends on path conditions and implementation.

Misconceptions About SYN, FIN and Connection Close

'SYN does not use sequence space' is false: it consumes one sequence number. 'One FIN closes both directions immediately' is false: TCP is full duplex and each direction closes separately. 'The final ACK always ends all connection state' is false: the active closer normally enters TIME-WAIT. These distinctions separate similar mechanisms that are often confused.

Exam Focus: Handshake Sequence and Close States

Trace SYN, SYN-ACK, and ACK with correct sequence and acknowledgment values. Remember that SYN and FIN each consume one sequence number. Compare a normal four-segment close with half-close and simultaneous close, and identify which endpoint enters TIME-WAIT in an ordinary active-close scenario. Use the assumptions stated in each question when calculating.

Key Terms for TCP Connection Establishment and Teardown

  • SYN - Requests setup and consumes one sequence number.
  • SYN-ACK - Acknowledges SYN and supplies peer sequence.
  • FIN - Closes one direction of the stream.
  • Half-close - One direction closes.
  • TIME-WAIT - Protects against delayed segments.
  • Initial sequence number - Starting byte position for a direction.
7
Easy
11
Medium
5
Hard

📝 All TCP connection establishment teardown MCQs

Q1. In the Stop-and-Wait protocol, when the sender receives an error‑free ACK with ackNo = (S + 1) modulo 2, which action is taken?

A.The timer is stopped and the sender returns to the ready state. ✅
B.The timer continues running and the sender stays in the blocking state.
C.The packet is discarded and a new packet is created.
D.The sender immediately sends another packet without waiting.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: When the ACK matches the expected value (S+1) modulo 2, the sender knows the outstanding packet was received correctly. It stops the timer that was protecting that packet and transitions from the blocking state back to the ready state, allowing a new application request to be processed.

Q2. How does the sender treat a corrupted ACK compared with an error‑free ACK whose ackNo does not equal (S + 1) modulo 2?

A.Both are treated as valid and advance S.
B.Both cause the timer to stop and the sender to move to ready.
C.Both are discarded while the timer continues running. ✅
D.Both trigger an immediate retransmission of the packet.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: A corrupted ACK cannot be trusted, so it is discarded. An error‑free ACK with a mismatched number is also discarded because it does not acknowledge the outstanding packet. In both cases the sender keeps the timer active, waiting for a correct acknowledgment before advancing.

Q3. Why does the Stop‑and‑Wait protocol use sequence numbers modulo‑2?

A.To detect duplicate packets. ✅
B.To increase throughput.
C.To synchronize clocks between ends.
D.To encrypt the data payload.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Modulo‑2 sequence numbers alternate between 0 and 1, allowing the receiver to recognize whether an arriving packet is a new transmission or a retransmission of the previous one. This simple scheme is sufficient because only one packet can be outstanding at any time, enabling duplicate detection without extra bits.

Q4. What is the initial value of the sender variable S?

A.0 ✅
B.1
C.2
D.Undefined
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: At the start of a Stop‑and‑Wait connection, the sender initializes its sequence counter S to zero. This establishes the first sequence number that will be used for the initial data packet, aligning with the receiver’s expected sequence number R, which also starts at zero.

Q5. If the sender sends packet 0 and the ACK is lost, what state transition occurs after the timeout?

A.Ready → Blocking → Ready
B.Blocking → Ready → Blocking
C.Ready → Blocking → Ready
D.Remains in the blocking state and restarts the timer ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: After transmitting packet 0, the sender enters the blocking state. When the ACK is lost, the timer expires, causing a timeout event. The sender resends the same packet and restarts the timer, but it stays in the blocking state until a valid ACK is finally received.

Q6. Compared with a sliding‑window protocol, how does the throughput of Stop‑and‑Wait change when the bandwidth‑delay product is large?

A.It stays the same
B.It decreases dramatically ✅
C.It increases slightly
D.It becomes independent of bandwidth‑delay product
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: When the product of bandwidth and round‑trip delay is large, the channel can hold many bits in flight, but Stop‑and‑Wait can only have one packet in transit. Consequently, most of the pipe remains idle, causing throughput to drop sharply relative to protocols that can utilize the full pipe.

Q7. When the receiver’s expected sequence number R = 1 and it receives an error‑free packet with seqNo = 0, what does it do?

A.Deliver to application and send ACK 1
B.Discard packet and send ACK 1 ✅
C.Deliver and send ACK 0
D.Discard and send ACK 0
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Because the packet’s sequence number does not match the receiver’s expected value, the packet is considered out‑of‑order or a duplicate. The receiver discards the payload, keeps its current R unchanged, and sends an ACK containing the current expected number (R = 1) to inform the sender.

Q8. The product of channel bandwidth (bits per second) and round‑trip delay (seconds) is called what?

A.Propagation delay
B.Transmission time
C.Bandwidth‑delay product ✅
D.Window size
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: The bandwidth‑delay product quantifies the amount of data that can be in flight on a link at any moment. It is calculated by multiplying the link’s data‑rate (bits per second) by the round‑trip time (seconds), yielding a value expressed in bits that represents the pipe’s capacity.

Q9. During the sender’s blocking state, what specific timer action is taken when a timeout occurs?

A.Timer is stopped permanently
B.Timer is reset and packet is resent ✅
C.Timer is ignored
D.Timer is extended without retransmission
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: If the timer expires while the sender is in the blocking state, the protocol interprets this as a lost ACK. The sender immediately retransmits the outstanding packet and restarts the timer to protect the new transmission, ensuring the packet will be resent again if necessary.

Q10. If the timeout interval is increased significantly, what is the most likely effect on the protocol’s throughput?

A.Throughput improves due to fewer retransmissions
B.Throughput degrades because idle time grows ✅
C.No effect
D.Throughput becomes maximal
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: A longer timeout means the sender may wait longer before detecting a lost ACK. During this waiting period no new data can be sent, so the channel remains idle more often. The extra idle time outweighs any reduction in unnecessary retransmissions, leading to lower overall throughput.

Q11. Explain how Stop‑and‑Wait guarantees reliable delivery despite possible loss of packets or ACKs.

A.By using checksum only
B.By retransmitting on timeout and using cumulative ACKs ✅
C.By sending multiple copies simultaneously
D.By relying on underlying physical layer
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Reliability is achieved because every transmitted packet is protected by a timer. If the corresponding ACK does not arrive before the timer expires, the sender retransmits the packet. The receiver’s ACK number, which indicates the next expected sequence, allows the sender to know exactly which packet was successfully received.

Q12. Suppose the sender’s S = 1 and it receives an ACK with ackNo = 0. What can be inferred about the network event?

A.The ACK is for a previous packet and the current packet was lost
B.The ACK is corrupted
C.The ACK acknowledges packet 0 correctly ✅
D.The sender should advance S to 0
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: When S = 1, the expected ACK number is (1+1) modulo 2 = 0. Receiving ackNo = 0 therefore matches the expected value, indicating that the receiver successfully got the packet with sequence number 1 and is now ready for the next packet. No loss or corruption is implied.

Q13. Differentiate the sender’s response to a corrupted ACK versus an ACK whose ackNo does not match (S+1) modulo 2.

A.Both cause timer stop
B.Corrupted ACK is ignored while mismatched ACK is discarded but timer continues ✅
C.Both are treated as valid and advance S
D.Both cause immediate retransmission
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: A corrupted ACK cannot be verified, so the sender discards it and keeps the timer running, awaiting a valid acknowledgment. An ACK with a wrong number is also discarded because it does not confirm receipt of the outstanding packet, but the timer similarly continues, leading to a possible timeout and retransmission.

Q14. Why are two sequence numbers (modulo‑2) sufficient for Stop‑and‑Wait but insufficient for protocols with larger windows?

A.Because only one packet can be outstanding
B.Because bandwidth is low
C.Because modulo‑2 provides encryption
D.Because larger windows need more bits to avoid ambiguity ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: Stop‑and‑Wait never has more than one unacknowledged packet, so a single bit (0 or 1) uniquely identifies the current packet versus the next expected one. In protocols that allow multiple outstanding packets, a two‑bit space would cause ambiguity about which packet a given ACK refers to, requiring more sequence numbers.

Q15. What is the name of the sender state in which it waits for an ACK after transmitting a packet?

A.Ready
B.Blocking ✅
C.Idle
D.Listening
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: After sending a packet, the sender enters the Blocking state. In this state it monitors the timer and awaits an acknowledgment. The name reflects that the sender’s ability to proceed is blocked until the ACK arrives or a timeout forces a retransmission.

Q16. If the receiver’s current R = 0 and it successfully receives a packet with seqNo = 0, what ACK number does it send?

A.0
B.1 ✅
C.2
D.0 modulo 2
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: When the receiver correctly receives a packet whose sequence number matches its expected value R, it increments R using modulo‑2 arithmetic. The ACK number it transmits is the new R value, which in this case becomes 1, indicating the next packet it expects.

Q17. Compare the events handled in the sender’s Ready state versus the Blocking state.

A.Ready handles only timeouts, Blocking handles only ACKs
B.Ready handles application requests, Blocking handles ACKs, timeouts, and corrupted ACKs ✅
C.Both handle the same events
D.Ready handles ACKs while Blocking handles application requests
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: In the Ready state the sender waits for a request from the application layer, at which point it creates and sends a packet and moves to Blocking. The Blocking state is responsible for processing acknowledgments, handling timer expirations, and discarding any corrupted or unexpected ACKs.

Q18. How many packets can be outstanding at any time in the Stop‑and‑Wait protocol?

A.Zero
B.One ✅
C.Two
D.Unlimited
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: Stop‑and‑Wait restricts the communication to a single unacknowledged packet. As soon as the sender transmits a packet, it must wait for the corresponding acknowledgment before sending any further data, ensuring that at most one packet is in flight at any moment.

Q19. When an error‑free packet arrives with seqNo different from the receiver’s R, what is the receiver’s immediate action?

A.Deliver and update R
B.Discard and resend ACK with current R ✅
C.Buffer the out‑of‑order packet
D.Reset the connection
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The receiver recognizes that the packet does not match the expected sequence number, so it discards the payload to avoid delivering out‑of‑order data. It still sends an ACK containing the current expected sequence number R, informing the sender that the previous packet is still awaited.

Q20. If a packet is duplicated due to a retransmission, how does the Stop‑and‑Wait protocol maintain correctness?

A.It treats the duplicate as new data
B.It discards the duplicate using sequence numbers ✅
C.It crashes
D.It sends a NACK
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Because each packet carries a sequence number that alternates between 0 and 1, the receiver can detect a duplicate when the sequence number matches the one it has already accepted. The duplicate is simply ignored, preventing the application layer from receiving the same data twice.

Q21. What would be the effect of initializing both sender S and receiver R to 1 instead of 0?

A.Protocol would fail immediately
B.It would work unchanged because only relative values matter ✅
C.It would cause off‑by‑one errors
D.It would double throughput
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The protocol relies on the relative relationship between S and R, not on their absolute values. Starting both at 1 simply shifts the numbering but preserves the invariant that the ACK number equals the next expected sequence, so communication proceeds without error.

Q22. Given the sequence: sender sends packet 0, ACK is lost, timeout, sender resends packet 0, ACK received. What is the final value of S?

A.0
B.1 ✅
C.2 modulo 2
D.Undefined
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: After the ACK finally arrives, the sender validates that ackNo = (S+1) modulo 2, where S was 0. Consequently, S is updated to (0+1) modulo 2 = 1, reflecting that the next packet to be sent will use sequence number 1.

Q23. Compare the impact on retransmission count when an ACK is corrupted versus when it is lost.

A.Corrupted ACK leads to more retransmissions
B.Lost ACK leads to more retransmissions
C.Both cause the same number of retransmissions ✅
D.Neither cause retransmissions
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: Both a corrupted ACK (which is discarded) and a lost ACK (which never arrives) prevent the sender from receiving a valid acknowledgment. In either case the sender’s timer will eventually expire, causing a retransmission. Thus the number of retransmissions is identical for the two scenarios.

🔗 Related Topics (MCQs)