pack and unpack packet data like python struct module.