How do I tell which router is the Leader in a Thread network? What happens if the Leader goes offline?
The first router that creates the network automatically becomes the leader. You can find the leader router ID in any of the periodic MLE Advertise messages.
If the leader goes offline, another router in the network will become a new leader. You won't know ahead of time which router will be the new leader as it happens in a self-organizing mesh. However, if you make a packet capture and see what happens when the leader goes offline, then you will observe the process step-by-step. After a while, the other routers in the network realize they cannot hear the leader. They first make an attempt to find a new router through which they can hear from the leader, and when that doesn't work, one or more routers would eventually try to form their own partitions and become the leader. See the partition id in the MLE advertisement event details. If more than one node tries to become leader around the same time, then the one with a higher partition number becomes the leader.
You can run a simple experiment with three REEDs (router eligible end devices) using SL-Thread stack to observe and verify this process.