The are 3 types of messages:
- election message - sent to announce election
- answer message - response to the election message
- coordinator message - sent to announce the identity of the elected leader
- Some process Pfinds that leader is not available (or coordinator is down).
- Pinitiates a new leader election by broadcasting election message.
- Each process replies with own UID
- If Pfinds a process with higher UID, it waits a bit and if there is no reply with higher UID, it will promote that host to leader.
- However, if Preceives a coordinator message with new leader, which UID is lower thanP's UID, it will initiate another election.
N^2 + N messages, as at any moment any process can try to start election, thus send election message, handle N answer messages and send coordinator message. As an optimization, the process can send messages to the processes with larger UID only, this will give us N^2 / 2 + N messages, which is better, but not ideal.
