Variable packet based communication protocol C++ class