Skip to content

Measure latency on connections that were already established - #38

Closed
git-hulk wants to merge 1 commit into
masterfrom
design-established-connections
Closed

Measure latency on connections that were already established#38
git-hulk wants to merge 1 commit into
masterfrom
design-established-connections

Conversation

@git-hulk

@git-hulk git-hulk commented Sep 2, 2026

Copy link
Copy Markdown
Owner

The server side of a connection was only ever learned from a captured
SYN, so a connection that existed before tcpkit started was invisible:
packet_direction returned -1 for every one of its packets and they were
dropped without being counted. That is the normal case for the tool's
own documented use, since redis and memcached clients hold pooled
connections open for the life of the process -- tcpkit -i eth0 tcp port 6379 -p redis against a busy server could sit there printing
nothing at all until a client happened to reconnect.

When neither end of a data-carrying packet is a known endpoint, take
the lower of the two ports to be the service: clients draw from the
ephemeral range above it. Unlike guessing from the direction of the
first packet, that holds whether a request or a response is seen first,
which matters because a capture starts mid-conversation. A captured
handshake still wins, and the guess is only made once per endpoint.

Replaying a capture with no handshake, whose first frame is a response
to a request that was never captured, went from no output to correctly
reporting the following request against 10.0.0.2:6379.

🤖 Generated with Claude Code

@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 060ee91 to 4395653 Compare September 2, 2026 11:45
@git-hulk
git-hulk force-pushed the design-established-connections branch from 6112af8 to 2f40818 Compare September 2, 2026 11:45
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 4395653 to 6682099 Compare September 2, 2026 11:46
@git-hulk
git-hulk force-pushed the design-established-connections branch from 2f40818 to b2ab59e Compare September 2, 2026 11:46
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 6682099 to 0f230db Compare September 2, 2026 11:47
@git-hulk
git-hulk force-pushed the design-established-connections branch from b2ab59e to 86e90ef Compare September 2, 2026 11:47
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 0f230db to 3f08850 Compare September 2, 2026 11:58
@git-hulk
git-hulk force-pushed the design-established-connections branch from 86e90ef to 429a565 Compare September 2, 2026 11:58
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 3f08850 to 32e3312 Compare September 2, 2026 12:15
@git-hulk
git-hulk force-pushed the design-established-connections branch from 429a565 to 72fa0d8 Compare September 2, 2026 12:15
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 32e3312 to 6aa59a2 Compare September 2, 2026 12:24
@git-hulk
git-hulk force-pushed the design-established-connections branch from 72fa0d8 to 21a0828 Compare September 2, 2026 12:24
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 6aa59a2 to 46b92a5 Compare September 2, 2026 12:26
@git-hulk
git-hulk force-pushed the design-established-connections branch from 21a0828 to da92808 Compare September 2, 2026 12:26
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 46b92a5 to 71b9cef Compare September 2, 2026 12:27
@git-hulk
git-hulk force-pushed the design-established-connections branch from da92808 to 1c27aee Compare September 2, 2026 12:27
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from 71b9cef to e97f1ea Compare September 2, 2026 12:28
@git-hulk
git-hulk force-pushed the design-established-connections branch from 1c27aee to b3b0c72 Compare September 2, 2026 12:28
@git-hulk
git-hulk force-pushed the design-single-pcap-handle branch from e97f1ea to d2a9484 Compare September 2, 2026 12:31
@git-hulk
git-hulk force-pushed the design-established-connections branch from b3b0c72 to 8584a14 Compare September 2, 2026 12:31
Base automatically changed from design-single-pcap-handle to master September 2, 2026 12:34
The server side of a connection was only ever learned from a captured
SYN, so a connection that existed before tcpkit started was invisible:
packet_direction returned -1 for every one of its packets and they were
dropped without being counted. That is the normal case for the tool's
own documented use, since redis and memcached clients hold pooled
connections open for the life of the process -- `tcpkit -i eth0 tcp
port 6379 -p redis` against a busy server could sit there printing
nothing at all until a client happened to reconnect.

When neither end of a data-carrying packet is a known endpoint, take
the lower of the two ports to be the service: clients draw from the
ephemeral range above it. Unlike guessing from the direction of the
first packet, that holds whether a request or a response is seen first,
which matters because a capture starts mid-conversation. A captured
handshake still wins, and the guess is only made once per endpoint.

Replaying a capture with no handshake, whose first frame is a response
to a request that was never captured, went from no output to correctly
reporting the following request against 10.0.0.2:6379.

Assistant By Opus 5

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@git-hulk
git-hulk force-pushed the design-established-connections branch from 8584a14 to 9406c9a Compare September 2, 2026 12:34
@git-hulk

git-hulk commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

Dropping this one without merging, at the author's request.

It added the fallback that guesses which side of a connection is the server when no TCP handshake was captured, so that latency is still reported for connections that were already established when tcpkit started.

PR #39 was stacked on top of this and has been rebased onto master, so it no longer carries this commit and can be reviewed on its own. Nothing merged to master depends on this change.

The design-established-connections branch is left in place, so this is straightforward to revisit if the approach is wanted later.

@git-hulk git-hulk closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant