online posts 16
wireshark 101

task 6.2 · chapter 6 of 8: tcp · 15 min

Refused

objective

Tell a refused connection from a normal one: a SYN answered by a RST. Find it among three connections by its stream index.

you edit, in the labanswers/6.2.yml

open a file in VS Code: Ctrl+P (Cmd+P on a Mac), type its name, Enter

given
Capturemake capture AT=laptop:eth1 NAME=6.2 X=refused: port 80, then port 8080, then port 80 again
Filtertcp.flags.reset == 1
Your answersanswers/6.2.yml
new to this? step by stepbeginner
  1. make capture AT=laptop:eth1 NAME=6.2 X=refused, open it, filter tcp.flags.reset == 1.
  2. Read the RST: its source address and source port.
  3. Challenge: its tcp.stream index; then filter tcp.stream == <that> to see the whole connection.
  4. Fill in answers/6.2.yml, then make check T=6.2.

more in meet the lab

1 explain

No, straight away

Nothing listening

A server only accepts connections on the ports a program is listening on. web runs a web server on ports 80 and 443, and nothing on 8080. When a SYN arrives for a port nobody listens on, the server’s operating system answers at once with a RST (reset): no, and stop. The client gives up immediately; curl prints Connection refused.

That immediately matters. A refused connection is fast and clear: the server is there, the network works, the program isn’t. Compare that with a SYN that gets no answer at all (chapter 8): the client waits and tries again, for seconds, and you learn nothing until it gives up.

in one sentence SYN answered by RST means the host is there, but nothing listens on that port. SYN with no answer means something on the way dropped it.

Streams

A busy capture has many connections. Wireshark numbers them in the order it sees them, starting at 0, as tcp.stream. Filter tcp.stream == 1 and you see one connection and nothing else, from SYN to the end. That’s the quickest way to pull one conversation out of a crowd.

2 show

Two packets

The refused connection, in a capture like yours:

   22 0.878940500 192.168.1.175 → 192.168.2.10 TCP 74 60980 → 8080 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 ...
   23 0.879012584 192.168.2.10 → 192.168.1.175 TCP 54 8080 → 60980 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0

Two frames, and the connection’s over. The working connections before and after it each take a dozen or more.

3 follow along

Find the reset

  1. Capture three connections, the middle one to port 8080:

    run in the terminal
    make capture AT=laptop:eth1 NAME=6.2 X=refused
    

    The output shows curl’s three attempts; the middle one prints nothing.

  2. Open /captures/6.2.pcapng and filter the resets:

    tcp.flags.reset == 1
    
  3. Read the RST’s source address and its source port: the port that said no.

  4. Fill in the follow-along lines:

    editanswers/6.2.ymlCtrl+P → 6.2.yml
    refused_port: 8080
    rst_from: 192.168.2.10
    
4 challenge

Its stream

  • refused_stream: the refused connection’s tcp.stream index.

Then filter on that stream to see the whole of it, and on the streams either side to compare.

hint

Open the RST’s TCP layer: [Stream index: …] is near the top. Or add it as a column.

show the solutionanswers/6.2.yml

or pull it into your lab: make solve T=6.2, then git diff --staged shows what changed

refused_stream: 1

Stream 0 is the first page, stream 1 the refused attempt, stream 2 the page again. DNS lookups don’t count: they’re UDP, which has streams of its own (udp.stream).

5 check: run it, then prove it

$ make check T=6.2

when it's right, you'll see

╭─ task 6.2 · refused
│  ✓ captures/6.2.pcapng: taken on laptop:eth1, 40 frames
│  ✓ the port that refused the connection (follow along): 8080
│  ✓ who sent the reset (follow along): 192.168.2.10
│  ✓ the refused connection's stream index, tcp.stream (challenge): ...
╰─ 4/4 checks passed  verified