Service specification and protocol construction for a layered architecture