PcapFileEx.Flows.HTTP2.Stream (pcap_file_ex v0.5.5)

View Source

Wrapper around HTTP2.Exchange with sequence number and playback timing.

Wraps the existing PcapFileEx.HTTP2.Exchange to add timeline ordering and playback timing metadata.

Fields

  • flow_seq - Index within the flow's stream list (0-based)
  • exchange - The underlying HTTP2.Exchange (uses DateTime internally)
  • start_timestamp - Converted from exchange.start_timestamp to Timestamp.t()
  • response_delay_ms - Delay between request headers and response headers (for playback)

Timestamp Conversion

The existing HTTP2.Exchange uses DateTime.t() internally. This wrapper converts timestamps to Timestamp.t() via Timestamp.from_datetime/1 for consistent nanosecond-precision handling across the Flows API.

Playback Timing

response_delay_ms is the full exchange duration in milliseconds:

  • Computed from exchange.start_timestamp to exchange.end_timestamp
  • 0 if either timestamp is not available

Note: This is the total exchange duration (request start → response complete), not time-to-first-byte (TTFB). For large response bodies, this over-estimates actual response latency. See Known Limitations in the Flows documentation.

Examples

# Access the underlying exchange
stream.exchange.request.method
stream.exchange.response.status

# Use for playback
Process.sleep(stream.response_delay_ms)
send_response(stream.exchange.response)

Summary

Functions

Creates a new Stream wrapper from an HTTP2.Exchange.

Types

t()

@type t() :: %PcapFileEx.Flows.HTTP2.Stream{
  exchange: PcapFileEx.HTTP2.Exchange.t(),
  flow_seq: non_neg_integer(),
  response_delay_ms: non_neg_integer(),
  start_timestamp: PcapFileEx.Timestamp.t()
}

Functions

from_exchange(flow_seq, exchange)

@spec from_exchange(non_neg_integer(), PcapFileEx.HTTP2.Exchange.t()) :: t()

Creates a new Stream wrapper from an HTTP2.Exchange.

Converts the DateTime timestamps to Timestamp and computes response_delay_ms.

Parameters

  • flow_seq - Index within the flow's stream list
  • exchange - The HTTP2.Exchange to wrap

Examples

stream = Stream.from_exchange(0, exchange)
stream.start_timestamp  # => %Timestamp{}
stream.response_delay_ms  # => 150 (ms)