ITCHCPP 1.6.0
High-Performance NASDAQ TotalView-ITCH 5.0 Parser & Market-Data Platform
Loading...
Searching...
No Matches
pcap.hpp
Go to the documentation of this file.
1#pragma once
2
13
14#include <cstddef>
15#include <cstdint>
16#include <optional>
17#include <span>
18#include <string>
19#include <vector>
20
21#include "itch/parser.hpp"
23
24namespace itch::transport {
25
40 public:
46 explicit PcapReader(MessageCallback callback);
47
53 auto read(std::span<const std::byte> capture) -> bool;
54
60 auto read_file(const std::string& path) -> bool;
61
66 auto set_udp_port_filter(std::uint16_t port) -> void { m_port_filter = port; }
67
69 auto clear_udp_port_filter() noexcept -> void { m_port_filter = std::nullopt; }
70
73 [[nodiscard]] auto mold_decoder() noexcept -> MoldUdp64Decoder& { return m_mold; }
76 [[nodiscard]] auto mold_decoder() const noexcept -> const MoldUdp64Decoder& { return m_mold; }
77
81 [[nodiscard]] auto udp_datagrams() const noexcept -> std::uint64_t { return m_udp_datagrams; }
82
85 [[nodiscard]] auto messages_decoded() const noexcept -> std::uint64_t {
86 return m_mold.messages_decoded();
87 }
88
89 private:
97 auto read_classic_pcap(std::span<const std::byte> capture, bool swapped) -> bool;
98
104 auto read_pcapng(std::span<const std::byte> capture) -> bool;
105
113 auto handle_frame(std::span<const std::byte> frame, std::uint32_t link_type) -> void;
114
121 [[nodiscard]] auto extract_udp_payload(std::span<const std::byte> network
122 ) const -> std::optional<std::span<const std::byte>>;
123
124 MoldUdp64Decoder m_mold;
125 std::optional<std::uint16_t> m_port_filter {};
126 std::uint64_t m_udp_datagrams {0};
127};
128
129} // namespace itch::transport
Decodes MoldUDP64 datagrams and forwards the contained ITCH messages.
Definition moldudp64.hpp:71
auto messages_decoded() const noexcept -> std::uint64_t
Total number of ITCH messages decoded from all datagrams.
Replays ITCH market data straight from a captured network trace.
Definition pcap.hpp:39
auto messages_decoded() const noexcept -> std::uint64_t
Total ITCH messages decoded across the whole capture.
Definition pcap.hpp:85
auto udp_datagrams() const noexcept -> std::uint64_t
Number of UDP datagrams extracted and handed to the MoldUDP64 decoder.
Definition pcap.hpp:81
auto clear_udp_port_filter() noexcept -> void
Clears any destination-port filter previously installed.
Definition pcap.hpp:69
auto read_file(const std::string &path) -> bool
Reads and decodes a capture file from disk.
Definition pcap.cpp:106
auto mold_decoder() noexcept -> MoldUdp64Decoder &
The embedded MoldUDP64 decoder (sequence tracking lives here).
Definition pcap.hpp:73
auto set_udp_port_filter(std::uint16_t port) -> void
Restricts decoding to UDP datagrams sent to this destination port.
Definition pcap.hpp:66
auto read(std::span< const std::byte > capture) -> bool
Decodes an in-memory capture buffer.
Definition pcap.cpp:87
auto mold_decoder() const noexcept -> const MoldUdp64Decoder &
The embedded MoldUDP64 decoder (sequence tracking lives here).
Definition pcap.hpp:76
Decoder for NASDAQ's MoldUDP64 UDP multicast market-data framing.
std::function< void(const Message &)> MessageCallback
The signature for the callback function used in streaming parse methods.
Definition parser.hpp:40
Public parsing interface for NASDAQ TotalView-ITCH 5.0 feeds, plus the low-level byte-unpacking utili...