ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
itch::transport::PcapReader Class Reference

Replays ITCH market data straight from a captured network trace. More...

#include <pcap.hpp>

Public Member Functions

 PcapReader (MessageCallback callback)
 Constructs a reader that forwards each decoded ITCH message to callback.
 
auto read (std::span< const std::byte > capture) -> bool
 Decodes an in-memory capture buffer.
 
auto read_file (const std::string &path) -> bool
 Reads and decodes a capture file from disk.
 
auto set_udp_port_filter (std::uint16_t port) -> void
 Restricts decoding to UDP datagrams sent to this destination port.
 
auto clear_udp_port_filter () noexcept -> void
 Clears any destination-port filter previously installed.
 
auto mold_decoder () noexcept -> MoldUdp64Decoder &
 The embedded MoldUDP64 decoder (sequence tracking lives here).
 
auto mold_decoder () const noexcept -> const MoldUdp64Decoder &
 The embedded MoldUDP64 decoder (sequence tracking lives here).
 
auto udp_datagrams () const noexcept -> std::uint64_t
 Number of UDP datagrams extracted and handed to the MoldUDP64 decoder.
 
auto messages_decoded () const noexcept -> std::uint64_t
 Total ITCH messages decoded across the whole capture.
 

Detailed Description

Replays ITCH market data straight from a captured network trace.

Firms most often archive and share feeds as packet captures, so being able to consume a .pcap/.pcapng file directly removes the need to pre-strip the transport framing. The reader is implemented entirely in-house (no libpcap dependency): it understands the classic pcap and the pcapng container formats, walks the Ethernet / IPv4 / IPv6 / UDP layers of each captured frame, extracts the UDP payload, and feeds it through an embedded MoldUdp64Decoder, which in turn yields the decoded ITCH messages to the caller's callback.

Note
Only offline capture files are supported. Live capture would require a platform packet-capture library and is tracked as future work behind a separate build option.

Definition at line 39 of file pcap.hpp.

Constructor & Destructor Documentation

◆ PcapReader()

itch::transport::PcapReader::PcapReader ( MessageCallback  callback)
explicit

Constructs a reader that forwards each decoded ITCH message to callback.

Parameters
callbackInvoked with each ITCH message decoded from the capture.

Definition at line 85 of file pcap.cpp.

Member Function Documentation

◆ read()

auto itch::transport::PcapReader::read ( std::span< const std::byte >  capture) -> bool

Decodes an in-memory capture buffer.

Parameters
captureThe full contents of a .pcap or .pcapng file.
Returns
true if the buffer was a recognized capture format, false otherwise (in which case nothing was decoded).

Definition at line 87 of file pcap.cpp.

◆ read_file()

auto itch::transport::PcapReader::read_file ( const std::string &  path) -> bool

Reads and decodes a capture file from disk.

Parameters
pathFilesystem path to the .pcap or .pcapng file to read.
Returns
true on a recognized, readable file; false if the file cannot be opened or is not a capture.

Definition at line 106 of file pcap.cpp.

◆ set_udp_port_filter()

auto itch::transport::PcapReader::set_udp_port_filter ( std::uint16_t  port) -> void
inline

Restricts decoding to UDP datagrams sent to this destination port.

When unset, datagrams on any port are decoded.

Parameters
portThe destination UDP port to accept.

Definition at line 66 of file pcap.hpp.

◆ clear_udp_port_filter()

auto itch::transport::PcapReader::clear_udp_port_filter ( ) -> void
inlinenoexcept

Clears any destination-port filter previously installed.

Definition at line 69 of file pcap.hpp.

◆ mold_decoder() [1/2]

auto itch::transport::PcapReader::mold_decoder ( ) -> MoldUdp64Decoder&
inlinenoexcept

The embedded MoldUDP64 decoder (sequence tracking lives here).

Returns
Reference to the embedded MoldUdp64Decoder.

Definition at line 73 of file pcap.hpp.

◆ mold_decoder() [2/2]

auto itch::transport::PcapReader::mold_decoder ( ) const -> const MoldUdp64Decoder&
inlinenoexcept

The embedded MoldUDP64 decoder (sequence tracking lives here).

Returns
Const reference to the embedded MoldUdp64Decoder.

Definition at line 76 of file pcap.hpp.

◆ udp_datagrams()

auto itch::transport::PcapReader::udp_datagrams ( ) const -> std::uint64_t
inlinenoexcept

Number of UDP datagrams extracted and handed to the MoldUDP64 decoder.

Returns
The count of UDP datagrams processed so far.

Definition at line 81 of file pcap.hpp.

◆ messages_decoded()

auto itch::transport::PcapReader::messages_decoded ( ) const -> std::uint64_t
inlinenoexcept

Total ITCH messages decoded across the whole capture.

Returns
The total count of decoded ITCH messages.

Definition at line 85 of file pcap.hpp.

References itch::transport::MoldUdp64Decoder::messages_decoded().


The documentation for this class was generated from the following files: