Master the fundamental concepts of tcp/ip from scratch through this focused micro-challenge.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksTCP is connection-oriented. Before data flows to port 443, both sides complete a three-step dance. For example, a client with ISN 1000 connects to a server with ISN 5000:
1000, SYN flag set. State: CLOSED -> SYN_SENT5000, ACK=1001, SYN+ACK flags. State: LISTEN -> SYN_RECEIVED1001, ACK=5001, ACK flag only. Both sides reach ESTABLISHEDClient: CLOSED -> SYN_SENT -> ESTABLISHED
Server: CLOSED -> LISTEN -> SYN_RECEIVED -> ESTABLISHED
Each side picks a random 32-bit ISN. The ACK number always equals the peer's sequence plus one because the SYN itself consumes one sequence number.
The handshake confirms both sides can send and receive. A stale delayed SYN fails because the ACK number will not match any live connection. SYN flood attacks exploit the half-open SYN_RECEIVED state, which is why Linux ships SYN cookies as a defense.
This task asks you to simulate the handshake with printed segments and state transitions. The Linux kernel's tcp_v4_syn_recv() implements exactly this state machine, and nmap's SYN scan reads these same flag bytes without completing the handshake. Kevin Mitnick's 1994 ISN-prediction attack against Tsutomu Shimomura targeted the random sequence number chosen during step one of this exact exchange.
Simulate the TCP three-way handshake between a client with ISN 1000 and a server with ISN 5000. Each side acknowledges the other's SYN by sending its sequence number + 1, because a SYN consumes one sequence number. Print the step selected on stdin.
One word: syn, synack, ack or all. Anything else behaves like all.
Print exactly these lines for each mode:
all: the whole exchange, numbered, and the final state
cLoading…
syn: the client's first segment
cLoading…
The other steps print their line without the number: synack prints RECV SYN-ACK seq=5000 ack=1001 and ack prints SEND ACK ack=5001.
Input:
cLoading…
Output:
cLoading…
Hidden tests cover the SYN on its own and the full handshake.