Distributed Elections using Logical Clocks (hints and tips)
Your example mostly needs the machines to agree on a "consensus" for which machine should be the leader. There are a lot of consensus protocols (proven to be correct). On top of consensus (with a proper failure detector) you can construct a "total ordering broadcast". I am no expert in this field so I can't recommend a particular paper but you can pick up one from this google search result
http://scholar.google.com/scholar?hl=en&amp;q=total+ordering+broadcast+consensus&amp;btnG=Search&amp;as_sdt=2000&amp;as_ylo=&amp;as_vis=0