use uint64_t instead of int to avoid integer overflow on e.g. sum(msg_size)