Classroom Glossary Public site

TCP Three-Way Handshake Replay Workout (NET-101 Week 6)

3,036 words · worksheet

This is a Tier-1-graded worksheet. Submit this filled worksheet only. The Tier-2 manual table-fill lab (Lab 6-1) is the deeper artifact; today is the annotated calibration that prepares you for it. After you finish this worksheet, Lab 6-1 will feel like recognition rather than discovery.

Purpose

Week 6 §2 introduced the arithmetic that drives every TCP connection (SYN consumes one sequence number; ACK = peer's ISN + 1). Week 6 §3 introduced the three packets that negotiate the connection (SYN, SYN-ACK, ACK). Week 6 §5 introduced the state machine each endpoint walks (CLOSED / LISTEN / SYN_SENT / SYN_RCVD / ESTABLISHED). Today's worksheet drives the TCP handshake replay panel in pcap-tools over the fundamentals-tcp-3way.pcap fixture so you can see all three play out at once.

The replay panel pairs the standard pcap-tools 3-pane view (packet table + protocol-tree + hex) with four extras: step controls, a client/server state-pill display, authored callout text per step, and a monospace arithmetic box showing the ack = peer_ISN + 1 derivation in real values. Clicking Step forward advances the underlying packet selection, so the protocol-tree and hex panes follow along. You use those affordances to answer two kinds of question this worksheet poses: predictive (what flags will be set on packet 2? what ACK value should it carry?) and observational (the state pills now read SYN_SENT and SYN_RCVD; what packet was just played, and what is each side waiting for?).

The pedagogical claim of Week 6 §2-3 is that the handshake is purely arithmetic and state: three packets, two ISNs, two endpoints moving through a small number of named states. The replay makes that claim visual: the same three numbers (0xa1b2c3d4 and 0x55667788 from the lecture worked example) carry through every panel; the state pills flip exactly when the lecture says they should. The pedagogical claim of §5 is that the state asymmetry between the two endpoints is why the third packet exists. The replay surfaces the asymmetry directly: after step 2 the client reaches ESTABLISHED but the server is still in SYN_RCVD, waiting.

The deeper purpose: this worksheet calibrates your mental model of the handshake against the canonical packet sequence. Lab 6-1 will hand you the same capture and ask you to fill in the fields by eye; if today's calibration sticks, Lab 6-1 is a recognition exercise rather than a discovery exercise. Forward into Week 7 (sliding windows + flow control), the same window-size and MSS fields you observe here drive every later TCP scenario.

Learning Objectives

By the end of this worksheet, you will be able to:

  1. Identify the TCP flag set on each of the three handshake packets (SYN only; SYN and ACK; ACK only) and explain why each combination is correct (Apply; Week 6 §3).
  2. Verify the acknowledgment-number arithmetic that ACK in packet 2 = client ISN + 1 and ACK in packet 3 = server ISN + 1, using the actual fixture values (Apply; Week 6 §2).
  3. Name both endpoints' TCP state after each packet plays and explain the SYN_RCVD-after-step-2 asymmetry that motivates the third packet (Analyze; Week 6 §5).
  4. Distinguish the two independent byte streams established by the handshake (client-to-server and server-to-client) and explain why each carries its own ISN (Analyze; Week 6 §2).
  5. Articulate one observation about the handshake that the static sequence diagram (Week 6 Figure 6.1) could not surface, in 3-5 sentences (Evaluate; replay-vs-static-diagram distinction).

Equipment Checklist

Step-by-Step Procedure

This worksheet takes ~60 minutes. Plan one sitting.

Stage 1 - Load pcap-tools and pick the fixture

Stage 2 - Predict the handshake before stepping

Before you click any Step button, fill the prediction columns in Tables A, B, and C from the Week 6 prose alone. The replay will then either confirm or correct each prediction.

Stage 3 - Step through the replay

Stage 4 - Verify the arithmetic by hand

Stage 5 - Replay the edge cases

Stage 6 - Reflection

Answer the 5 reflection prompts below in 2-4 sentences each.

Data Entry Tables

Table A - SEQ and ACK Arithmetic per Packet (Steps 6, 8-12; PREDICT before stepping)

Pkt Flag set Predicted seq Predicted ack Observed seq Observed ack Match
1 SYN _____ (invalid; ACK not set) _____ _____ [ ]
2 SYN, ACK _____ _____ _____ _____ [ ]
3 ACK _____ _____ _____ _____ [ ]

Arithmetic verification (hand-compute):

Table B - Client + Server State per Step (Steps 5, 8-10; PREDICT before stepping)

When Predicted client state Predicted server state Observed client state Observed server state Match
Initial (before any packet) _____ _____ _____ _____ [ ]
After packet 1 (SYN) _____ _____ _____ _____ [ ]
After packet 2 (SYN-ACK) _____ _____ _____ _____ [ ]
After packet 3 (ACK) _____ _____ _____ _____ [ ]

State-asymmetry observation. Looking at the row "after packet 2 (SYN-ACK)" above: the client state and the server state disagree. One sentence: which one is further along, and why?


Table C - TCP Flag Set per Packet (Steps 4, 8-10; PREDICT before stepping)

Pkt Predicted flags Observed flags Hex value of tcp.flags Match
1 _____________ _____________ 0x___ [ ]
2 _____________ _____________ 0x___ [ ]
3 _____________ _____________ 0x___ [ ]

(Hint: tcp.flags is a 9-bit field. SYN occupies bit 1 (value 0x002); ACK occupies bit 4 (value 0x010). A packet with SYN and ACK both set has tcp.flags = 0x012.)

Table D - Callout-Text Reproduction (Steps 8-10; transcribe the first sentence verbatim)

Step Replay callout title First sentence of the callout
1 (SYN) "_______________________________________" "_______________________________________________________________"
2 (SYN-ACK) "_______________________________________" "_______________________________________________________________"
3 (ACK) "_______________________________________" "_______________________________________________________________"

(Transcribing the first sentence forces a second pass through the prose. The reflection prompts below assume you have done this.)

Table E - Summary Screen (Step 11)

Value the summary screen lists Your transcription
Client -> Server stream starts at _____
Server -> Client stream starts at _____
MSS (both directions) _____ bytes
Client's receive window _____ bytes
Server's receive window _____ bytes

Verification. The "Client -> Server stream starts at" value should equal client ISN + 1. Confirm: 2712847316 + 1 = ___________ matches the value above. [ ] Yes [ ] No

Reflection Prompts

Answer in 2-4 sentences each.

1. The brief's headline question for this lab. In packet 2, the ACK field reads 2712847317, which is the client's ISN plus one. What does that +1 tell you about the payload size of packet 1 (the SYN)? (Hint: ACK numbers point at "the next byte expected". If the SYN packet carried zero application bytes but the ACK still advances by 1, what does that say about how SYN itself participates in the byte stream?)



2. If the SYN-ACK is lost in transit, what happens next? Walk through the retransmission timing. (Hint: the client is in SYN_SENT waiting for the SYN-ACK. The server is in SYN_RCVD holding a half-open entry. One side will time out and retry. Which side, on what timer, and for how many retries?)



3. Why does the server acknowledge the client's SEQ in the same packet as its own SYN, rather than sending two separate packets (one ACK, then one SYN)? (Hint: TCP could in principle have a four-way handshake (SYN, ACK, SYN, ACK). Why is the three-way version preferred? Think about latency and the "half-open connection" terminology.)



4. Table B row 3 ("after packet 2") shows the state asymmetry explicitly: the client is in ESTABLISHED but the server is still in SYN_RCVD. When is the handshake "done" from the client's view versus the server's view? (Hint: the asymmetry lasts exactly one round-trip. What event closes the gap, and what would happen to the server if that event never arrived?)



5. The static sequence diagram from Week 6 Figure 6.1 is the same three-packet exchange as this replay. Name one specific observation the replay surfaced that the static diagram could not. (Hint: a static diagram has to show all three packets at once, with all state labels visible. The replay shows them one at a time, with the previous state still visible from before the click. A good answer names a specific dynamic property: the timing of a state transition, the direction of a transition, the moment an asymmetry appears, or the byte-level hex pattern that the +1 arithmetic produces.)




Tutor Hint Surface

If you get stuck on a step, the academy tutor at /tutor/ knows the context of this replay. Ask the tutor:

The tutor is a calibration aid, not a substitute for stepping through the replay yourself.

Submission Checklist

Pass/Fail Self-Evidence (Tier 1 of the rubric)

Every gate must be checked.

If any gate is unchecked, do not submit yet.

Common Pitfalls

The five most common first-attempt failures:

  1. Stepped before predicting. Tables A, B, C lose their calibration value once predictions are back-filled. If you stepped first, redo with a sibling fixture (any other TCP capture in pcap-tools) where the ISN values are different but the +1 arithmetic is the same.
  2. Confused tcp.flags hex. SYN alone = 0x002; ACK alone = 0x010; SYN+ACK together = 0x012. The bit positions are SYN at bit 1 and ACK at bit 4. A SYN+ACK packet is not 0x020 or 0x011; it is 0x012.
  3. Treated the server as ESTABLISHED after step 2. The asymmetry is the whole point of this exercise. The server transitions to ESTABLISHED only after step 3 (when it receives the ACK). The replay panel shows this; Table B confirms it.
  4. Misread big-endian on the wire. The hex pane shows a1 b2 c3 d4 for the client ISN; this is the four bytes in network byte order (big-endian). The decimal value 2712847316 is what the protocol-tree pane parses. Both representations describe the same number.
  5. Skipped the callout text. Table D forces a re-read of the first sentence of each callout. The reflection prompts assume the student has read all three; if you skipped them, Reflections 1, 3, and 4 will feel harder than they should.

Forward Pointer

Lab 6-1 (TCP three-way handshake; manual table-fill) uses the same fixture. Lab 6-1 asks you to find the field values without callouts; today's worksheet is the calibration that makes that exercise quick. After today, Lab 6-1 should take less than 30 minutes.

Lab 6-2 (TCP connection teardown) covers the FIN-WAIT / TIME-WAIT / CLOSE-WAIT states that this replay deliberately omits (the handshake is just the opening; teardown is its own arc). Lab 6-2 uses a different capture; the state-machine reading skill you built today carries forward.

Week 7 (TCP II: sliding windows and flow control) uses the MSS and window-size fields you observed in Tables E and (implicitly) in the per-packet detail panes. The 1460-byte MSS and the 64240 / 65535 windows are the load values that drive every later TCP scenario.

NET-101 capstone (Network Snapshot report) asks you to write a one-page protocol analysis of a real capture you collect on your own machine. The skill of stepping through a capture one packet at a time with state-machine awareness is the foundation of that report.

Beyond NET-101: the same step-through-with-state pattern transfers to:


LAB WORKSHEET COMPLETE - TCP Three-Way Handshake Replay Workout v1.0; Tier-1-graded worksheet-completion; YAML frontmatter (12 fields incl grading_disposition: Tier-1 worksheet-completion. every prediction row in Tables A through C filled BEFORE the corresponding observation row; Tables D and E filled accurately against the replay panel; all 5 reflection prompts answered) + 5 Bloom-ordered LOs tied to NET-101 Week 6 §2 sequence-number arithmetic + §3 three-way handshake + §5 state machine + replay-vs-static-diagram distinction + 6-item Equipment Checklist (incl pcap-tools URL + fixture identity + Week 6 prose re-read + Figure 6.1 visible + paper-notebook-for-prediction discipline + Lab 5 PASS gate) + 6-stage / 15-step Procedure (load pcap-tools + pick fundamentals-tcp-3way fixture + confirm replay panel mounts -> predict flag sets / states / arithmetic for all 3 packets BEFORE stepping -> step through SYN -> step through SYN-ACK -> step through ACK -> reach summary screen -> verify arithmetic by hand including hex byte-level confirmation -> replay backward / reset to see edge affordances -> reflect) + 5 Data Tables (A: seq/ack arithmetic predict-then-verify with hand-computed +1 verification rows / B: client+server state pairs predict-then-verify with state-asymmetry one-sentence observation / C: TCP flag sets predict-then-verify with hex value column / D: callout-text reproduction first-sentence transcription / E: summary-screen 5-row reproduction) + 5 Reflection Prompts (the +1 in SYN-ACK ACK tells you what about SYN payload size + retransmission timing if SYN-ACK is lost + why ACK + own SYN combined in one packet instead of four-way + when is handshake done from client vs server view asymmetry one-round-trip apart + the brief's headline what-did-you-see-with-replay-not-with-static-diagram) + Tutor Hint Surface section (3 example questions the tutor knows context for) + Submission Checklist (6 items) + Pass/Fail Self-Evidence (5 Tier-1 gates) + Common Pitfalls (5 numbered incl tcp.flags hex confusion + treating server as ESTABLISHED prematurely + big-endian wire format misread) + Forward Pointer to Lab 6-1 (manual table-fill uses same fixture; today is calibration) + Lab 6-2 (teardown; different capture; state-machine skill transfers) + Week 7 (MSS + windows drive every later scenario) + NET-101 capstone (Network Snapshot uses step-through-with-state skill) + PEN-101 + WIR-101 + RE-101 SB6141 firmware + SEC-101 Lab 6 STRIDE transfers; references the interactive lab spec at courses/net-101/labs/lab-tcp-handshake-replay.md (engineering commit 2f085e4; hand-back 436813c); fixture identity net-101-fund-tcp-3way per manifest v6; tutor overlay at pcap-tools/backend/tutor/prompts/overlays/tcp-3way-replay-context.md is the hint-surface anchor; static-diagram counterpart at assets/diagrams/net-101-tcp-handshake.svg (visual-learner memo §3 #2); editor-guide-clean: 0 em-dashes, 0 phrase-blacklist hits per spec.