Protocol specification and code