Skip to main content
DARKPC.NET

Distinguish TCP Delay From Retransmissions in Wireshark

Capture a deliberately slow loopback response and compare quiet time in a TCP stream with Wireshark's retransmission analysis.

Difficulty Intermediate

Prerequisites

Use Python 3, curl and Wireshark on an isolated Kali training machine you control. Capture only your own synthetic traffic on the loopback interface. Use your distribution's documented capture permissions and run the GUI as your ordinary user. If capture is unavailable, use the Python and curl outputs as a transport-free starting point and resolve permissions separately.

Start a local test service

Run this from a new practice directory. It listens solely on loopback and returns a fixed string after a deliberate delay. It serves no local files.

python3 - <<'PYTHON'
from http.server import BaseHTTPRequestHandler, HTTPServer
from time import sleep

class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        sleep(2)
        body = b"practice response\n"
        self.send_response(200)
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)

HTTPServer(("127.0.0.1", 8090), Handler).serve_forever()
PYTHON

Capture and measure

Start a capture on the loopback interface with capture filter tcp port 8090. In another terminal run the request, then stop the capture. Use Ctrl+C in the server terminal when finished.

curl --noproxy '*' --silent --show-error --output /dev/null \
    --write-out 'connect=%{time_connect} start-transfer=%{time_starttransfer}\n' \
    http://127.0.0.1:8090/

Compare connection establishment with time to first response byte. Expect the second measurement to include roughly two seconds of application delay on an unbusy system. In Wireshark identify the stream number from a packet detail and filter with tcp.stream == 0 if the number is zero. Compare the time of the request and the first server payload. Open Statistics → TCP Stream Graphs → Time Sequence (Stevens) with a packet from the stream selected to inspect sequence progress. Try the display filter tcp.analysis.retransmission and note whether any packets match.

Interpret and verify

A quiet gap can occur while the application prepares its response. Retransmission flags are heuristics that depend on where you captured traffic, the packets present and their order. Treat repeated sequence ranges, acknowledgements and capture drops as evidence to check before drawing a conclusion. An empty retransmission filter does not rule out loss outside the capture's observation window.

Troubleshooting and practice

If the port is occupied, select another high port and change all three references in the server, filter and URL. If no packets appear, check that you selected loopback and started capture before curl. Repeat with sleep(0) and compare both measurements. Store only synthetic captures for this exercise. Real captures may contain confidential data even when the main payload is encrypted.

References and related reading