packet encoding and decoding library