implement protocol encode and decode
implement protocol encode and decode