imr (Nasdaq TotalView-Itch MoldUDP64 Replay) is a C++23 library that replays TotalView-ITCH 5.0 files over MoldUDP64.
File format
This library works with files containing TotalView-ITCH 5.0 messages, each prefixed by a 16-bit big-endian value giving the length of the message that follows. This is the format used by official distribution sources such as emi.nasdaq.com.
Requirements
- Linux
g++ or clang++ version that supports C++23
- CMake >= 3.25
Usage
Add to executable with CMake
As a subdirectory:
add_subdirectory(nasdaq-moldudp64-feed-sim)
target_link_libraries(your_target PRIVATE imr::imr)
Or via FetchContent:
include(FetchContent)
FetchContent_Declare(imr GIT_REPOSITORY <repo-url> GIT_TAG <tag>)
FetchContent_MakeAvailable(imr)
target_link_libraries(your_target PRIVATE imr::imr)
Example
Link against imr::imr and include imr/server.h.
.
path =
"FILE.NADSAQ_ITCH50",
},
.packet_builder_cfg = {
.session = "123456789",
},
.downstream_feed_config = {
.mcast_group = "239.0.0.1",
.port = 3400,
},
.retransmission_feed_config = {
.address = "127.0.0.1",
.port = 3500,
},
};
try
{
server.start();
server.wait_for_downstream();
}
catch (const std::exception& ex)
{
std::println("{}", ex.what());
}
if (!res.has_value())
{
std::println(stderr, "{}", res.error());
}
A MoldUDP64 server that replays NASDAQ TotalView-ITCH 5.0 files.
Definition server.h:52
std::expected< std::unique_ptr< Server >, std::string > make_server(const Server::Config &cfg) noexcept
Allows you to construct server without try/catch block to handle configuration errors.
Aggregate for configuration of all server components.
Definition server.h:64
util::MemoryMappedFile::Config mapped_itch_file_cfg
Definition server.h:65
std::filesystem::path path
Path of the file to map.
Definition memory_mapped_file.h:26
See documentation for the full set of config options on each struct.
Log level
Set at configure time via -DIMR_LOG_LEVEL=N, compiled in as a preprocessor definition.
0=error
1=warn
2=info
3=debug
Levels above configured are compiled out (default 0).
Complimentary tools
<a href="https://man7.org/linux/man-pages/man8/tc-netem.8.html" ><tt>tc</tt></a>
Use the netem qdisc to inject artificial packet loss, delay, and reordering
Run the server and client on either side of the impaired link and confirm your client detects gaps and recovers via the retransmission feed.
Wireshark
Has built in dissectors for MoldUDP64 + TotalView-ITCH 5.0.
Building standalone
Build options (CMake top level)
| Option | Default | Description |
BUILD_UNIT_TESTS | OFF | Build unit tests |
BUILD_INTEGRATION_TESTS | OFF | Build integration tests |
BUILD_E2E_TESTS | OFF | Build end-to-end tests |
ENABLE_ASAN | OFF | Build with AddressSanitizer + UBSan |
ENABLE_TSAN | OFF | Build with ThreadSanitizer (mutually exclusive with ASan) |
DEBUG_NO_NETWORK | OFF | Disable network calls |
DEBUG_NO_SLEEP | OFF | Disable sleep calls |
Example, building with unit tests and ASan:
$ cmake -B build -DBUILD_UNIT_TESTS=ON -DENABLE_ASAN=ON
$ cmake --build build
$ ctest --test-dir build
There are CMake presets:
$ cmake --list-presets
Available configure presets:
"debug-gcc" - Debug (GCC)
"debug-clang" - Debug (Clang)
"release-gcc" - Release (GCC)
"release-clang" - Release (Clang)
"asan-gcc" - ASan (GCC)
"asan-clang" - ASan (Clang)
"tsan-gcc" - TSan (GCC)
"tsan-clang" - TSan (Clang)
License
MIT — see LICENSE for details.