encoding/decoding PDUs -> states