|
Slick Sim 0.10.1
Exchange simulator that shadows real venues for risk-free strategy testing
|
Reads UDP payloads, in capture order, out of one pcap or pcapng file. More...
#include <md_feed/pcap_reader.hpp>
Public Member Functions | |
| PcapReader (const std::string &path) | |
| Opens path. Throws std::runtime_error when it cannot be opened or read as a capture. | |
| PcapReader (const PcapReader &)=delete | |
| PcapReader & | operator= (const PcapReader &)=delete |
| bool | next (PcapPacket &out) |
| Reads the next UDP datagram. | |
| const std::string & | error () const |
| Empty after a clean end of file; otherwise what stopped the read, for example a capture truncated mid-packet. | |
| const std::string & | path () const |
| uint64_t | truncated () const noexcept |
| Frames skipped so far for being cut short or malformed - not those that are simply not UDP (IGMP, ARP, fragments of other protocols). | |
Reads UDP payloads, in capture order, out of one pcap or pcapng file.
.zst and .gz files are decompressed as they are read, so a multi-gigabyte day file is never held in memory or on disk. That stream cannot be seeked: reaching a timestamp means reading up to it.
Classic pcap (micro or nanosecond, either byte order) and pcapng (any byte order and timestamp resolution, several interfaces) are read here, without libpcap, and reported in nanoseconds. Ethernet (with 802.1Q tags) and raw IP link types are understood. Frames that are not whole IPv4 UDP datagrams (IGMP, fragments, other protocols) are skipped.
Not thread-safe; one thread owns a reader.
Definition at line 258 of file pcap_reader.hpp.
|
inlineexplicit |
Opens path. Throws std::runtime_error when it cannot be opened or read as a capture.
Definition at line 261 of file pcap_reader.hpp.
References path().
Referenced by PcapReader(), and operator=().
|
delete |
References PcapReader().
|
inlinenodiscard |
Empty after a clean end of file; otherwise what stopped the read, for example a capture truncated mid-packet.
Definition at line 299 of file pcap_reader.hpp.
|
inline |
Reads the next UDP datagram.
False at the end of the file; error() says whether that was a clean end.
Definition at line 290 of file pcap_reader.hpp.
|
delete |
References PcapReader().
|
inlinenodiscard |
Definition at line 300 of file pcap_reader.hpp.
Referenced by PcapReader().
|
inlinenodiscardnoexcept |
Frames skipped so far for being cut short or malformed - not those that are simply not UDP (IGMP, ARP, fragments of other protocols).
Definition at line 303 of file pcap_reader.hpp.