Lion Cipher Lab

Reassemble a TCP stream from a PCAP, from scratch

Why it matters

Every time you click Wireshark's "Follow TCP Stream" or run tcpflow, a pile of reassembly logic runs that you never see: TCP data does not arrive in order, segments get retransmitted, packets show up early and wait for a gap to fill, and the tool silently sorts all of it by sequence number to hand you clean bytes. If you only ever consume that output, you cannot answer the question that matters in an investigation -- can I trust this stream? -- because you do not know what the tool did to produce it. That gap is not academic: TCP reassembly ambiguity is a real evasion class. When two segments…

What you'll learn

Steps in this lab

  1. What you are about to build, and how to open a terminal
  2. The libpcap file format: a header, then records
  3. The three headers inside each frame: Ethernet, IPv4, TCP
  4. Write the script: build a scrambled capture, then parse it back
  5. Run it and read the measured payoff
  6. How the reassembly actually decided the order
  7. Named failure modes: overlap, missing SYN, and 2^32 wrap-around
  8. Why this, not Wireshark, tcpflow, or scapy -- and when NOT to do it by hand

Open the full interactive lab →