zeromq recorder and replayer
Before build recorder/replayer, you need zmq and spdlog firstly.
refer to cppzmq
refer to spdlog
cmake -DCMAKE_INSTALL_PREFIX="./install" -S . -B build
cmake --build build -j4
cmake --install build
One DataPacket = Header + Body
Field | timestamp | ip | port | topic_len | data_len |
---|---|---|---|---|---|
Type | u32 | u32 | u16 | u16 | u16 |
Size | 4 | 4 | 2 | 2 | 2 |
Field | topic | data |
---|---|---|
Type | char* | u8[] |
Size | topic_len | data_len |
void usage() {
printf("usage: zmq_recorder [options]\n");
printf("options:\n");
printf(" --mode mode for recorder, [sub: default|rcv]\n");
printf(" --src src ip for sender, default 127.0.0.1\n");
printf(" --port src port for sender, default 9090\n");
printf(" --topic set topic filter string for sub mode, default empty string\n");
}
Update: You can also use --port "8001|8002|8003" to listen several ports.
void usage() {
printf("usage: zmq_replayer [options]\n");
printf("options:\n");
printf(" --file src file for replay, default zmq.bin\n");
printf(" --mode mode for replayer, [pub: default|req]\n");
}