\hideLIPIcs\ccsdesc

Theory of computation Distributed algorithms \ccsdescTheory of computation Distributed computing models \ccsdescNetworks Network reliability \ccsdescNetworks Ring networks \CopyrightFabian Frei, Ran Gelles, Ahmed Ghazy, Alexandre Nolin CISPA Helmholtz Center for Information Security, [email protected]://orcid.org/0000-0002-1368-3205 Bar-Ilan University, [email protected]://orcid.org/0000-0003-3615-3239Partially supported by a grant from the United States-Israel Binational Science Foundation (BSF), Jerusalem, Israel, Grant No. 2020277. He would also like to thank the CISPA Helmholtz Center for Information Security for hosting him while part of this research was done. CISPA Helmholtz Center for Information Security, [email protected]://orcid.org/0009-0009-7414-5871 CISPA Helmholtz Center for Information Security, [email protected]://orcid.org/0000-0002-3952-0586

Content-Oblivious Leader Election on Rings

Fabian Frei    Ran Gelles    Ahmed Ghazy    Alexandre Nolin
Abstract

In content-oblivious computation, n𝑛nitalic_n nodes wish to compute a given task over an asynchronous network that suffers from an extremely harsh type of noise, which corrupts the content of all messages across all channels. In a recent work, Censor-Hillel, Cohen, Gelles, and Sela (Distributed Computing, 2023) showed how to perform arbitrary computations in a content-oblivious way in 2-edge connected networks but only if the network has a distinguished node (called root) to initiate the computation.

Our goal is to remove this assumption, which was conjectured to be necessary. Achieving this goal essentially reduces to performing a content-oblivious leader election since an elected leader can then serve as the root required to perform arbitrary content-oblivious computations. We focus on ring networks, which are the simplest 2-edge connected graphs. On oriented rings, we obtain a leader election algorithm with message complexity O(n𝖨𝖣max)𝑂𝑛subscript𝖨𝖣O(n\cdot\mathsf{ID}_{\max})italic_O ( italic_n ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT ), where 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT is the maximal assigned ID. As it turns out, this dependency on 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT is inherent: we show a lower bound of Ω(nlog(𝖨𝖣max/n))Ω𝑛subscript𝖨𝖣𝑛\Omega(n\log(\mathsf{ID}_{\max}/n))roman_Ω ( italic_n roman_log ( sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT / italic_n ) ) messages for content-oblivious leader election algorithms. We also extend our results to non-oriented rings, where nodes cannot tell which channel leads to which neighbor. In this case, however, the algorithm does not terminate but only reaches quiescence.

keywords:
Fully Defective Networks, Noise Resilience, Leader Election, Ring Networks, Quiescent Computations

1 Introduction

The field of distributed computing is rich with models hel** us understand different types of architectures and computational hardness by making different kinds of assumptions about how computations are carried out. A recent work by Censor-Hillel, Cohen, Gelles, and Sela [8] introduced a particularly weak computational model coined fully defective networks. This model considers an asynchronous network in which messages may be fully corrupted and thus not carry any information beyond their sheer existence. Algorithms designed for this model cannot rely in any way on possible contents of messages, and thus are named content-oblivious. Instead of relying on the content of messages or on their time of arrival (since arbitrary delays may occur in asynchronous networks), such algorithms depend solely on the order in which messages arrive from different neighbors.

The aforementioned work by Censor-Hillel et al. [8] showed that any computation possible in the asynchronous setting with reliable content-carrying messages can be simulated in the fully defective setting under two assumptions: that the network is 2-edge connected and that there is a distinguished leader (which they call the root node) in the network. While the same paper showed 2-edge connectivity to be essential for any kind of nontrivial computation in fully defective networks, the question of the necessity of a pre-existing leader was not settled. Censor-Hillel et al. conjectured that general computations in fully defective networks do indeed require the existence of such a pre-elected leader.

In this paper, we disprove this conjecture, at least for the most fundamental type of 2-edge connected topologies, namely, rings. We design a content-oblivious algorithm that successfully performs a leader election in oriented rings.

Theorem 1.1.

There is a quiescently terminating content-oblivious algorithm of message complexity n(2𝖨𝖣max+1)𝑛2subscript𝖨𝖣1n(2\cdot\mathsf{ID}_{\max}+1)italic_n ( 2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ) that elects a leader in oriented rings of n𝑛nitalic_n nodes with unique IDs.

Here, 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT denotes the maximal ID assigned to a node in the network, and quiescent termination refers to the valuable property of our algorithm that nodes do not receive messages after termination. We discuss quiescent computations and the issue of composability in more detail in Section 1.1.

We further extend our result to the case where the ring is non-oriented, albeit under a weaker definition of computation. Instead of termination, we only require stabilization, which means that every node eventually settles on a decision (to be or not to be a leader, in our case) that is never revised again. However, the nodes might not know whether they have achieved their stable output already and remain ready to receive and potentially send messages forever. This potential is not actualized for a quiescently stabilizing algorithm, where all messaging activity ceases after finite time. Our algorithm not only elects a leader in such a manner but also orients the ring.

Theorem 1.2.

There is a quiescently stabilizing content-oblivious algorithm of message complexity n(2𝖨𝖣max+1)𝑛2subscript𝖨𝖣1n(2\cdot\mathsf{ID}_{\max}+1)italic_n ( 2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ) that elects a leader and orients a non-oriented ring of n𝑛nitalic_n nodes with unique IDs.

Both of our leader election algorithms, for oriented and non-oriented rings, have message complexity O(n𝖨𝖣max)𝑂𝑛subscript𝖨𝖣O(n\cdot\mathsf{ID}_{\max})italic_O ( italic_n ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT ). The term 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT is not very common in message complexities of algorithms.111Some algorithms depend on the IDs assigned to nodes. However, it is common for the complexity analysis to assume that all IDs are of length O(logn)𝑂𝑛O(\log n)italic_O ( roman_log italic_n ) bits, making the dependence on the IDs implicit. Somewhat surprisingly, our analysis shows that this term is inherent to content-oblivious algorithms. We prove the following lower bound.

Theorem 1.3.

Any deterministic terminating content-oblivious algorithm for leader election in rings with unique IDs sends at least nlog(𝖨𝖣max/n)𝑛subscript𝖨𝖣𝑛n\lfloor\log(\mathsf{ID}_{\max}/n)\rflooritalic_n ⌊ roman_log ( sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT / italic_n ) ⌋ messages.

Note that this Ω(nlog(𝖨𝖣max/n))Ω𝑛subscript𝖨𝖣𝑛\Omega(n\log(\mathsf{ID}_{\max}/n))roman_Ω ( italic_n roman_log ( sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT / italic_n ) ) lower bound implies that the number of messages in a ring of size n𝑛nitalic_n is unbounded— we can always increase the message complexity by assigning larger IDs, even when n𝑛nitalic_n is a small constant.

1.1 Quiescence and Composability

As mentioned above, we concatenate our content-oblivious leader election algorithm (Theorem 1.1) with the root-dependent universal content-oblivious algorithm [8, Thm. 1] to obtain the following powerful corollary.

Corollary 1.4.

Assuming unique IDs, any asynchronous algorithm on rings can be simulated in a fully defective oriented ring.

However, some subtleties arise when concatenating algorithms in the content-oblivious setting. With reliable message content, each message could be tagged, indicating the algorithm it belongs to. However, when concatenating content-oblivious algorithms, messages sent by the first algorithm may be mistaken for ones sent by the second algorithm, and vice versa.

To make this composition work, we require two properties: (1) termination, i.e., nodes should have a distinct point in time where they end the first algorithm and switch to the second one, and (2) message-algorithm attribution, i.e., while a node executes an algorithm, it only ever receives messages generated by nodes while they were executing the same algorithm.

Our algorithm for oriented rings (Theorem 1.1) achieves correct message-algorithm attribution (when composed with the scheme of [8]) by combining two mechanisms. First, it features a quiescent termination. In particular, any node terminates eventually, and at that time no messages are in delivery towards that node anymore, nor will any message be sent to that node after its termination. Secondly, the nodes terminate in order, so that the leader is the last to terminate. This makes our algorithm easy to compose with the algorithm of [8], by replacing the act of termination with the act of switching to the second algorithm. The leader, which is the last to terminate the first algorithm, is the node that initiates the computation of the scheme in [8] (i.e., it acts as the root), and at the time it sends its first message, we are guaranteed that all other nodes have already switched to that algorithm.

As a matter of fact, quiescent termination could be relaxed when composing general algorithms: If we have a bound r𝑟ritalic_r on the number of messages of the first algorithm that might reach a node after it transitions to the second algorithm, we could still concatenate any algorithm in an altered form where nodes send r+1𝑟1r+1italic_r + 1 copies of each message, and process arriving messages in groups of r+1𝑟1r+1italic_r + 1 messages as well. However, this clearly leads to an undesired r𝑟ritalic_r-fold increase in the message complexity of the composed algorithm.

On the other hand, our algorithm for non-oriented rings (Theorem 1.2) does not terminate and cannot be composed with other algorithms. As mentioned above, we only require the algorithm to reach quiescence in this case.

1.2 Related Work

Leader election is a fundamental task that has been studied by the distributed computing community since the 1970s. Simple leader election algorithms for asynchronous rings were proposed by Le Lann [26] and by Chang and Roberts [10]. These algorithms employ O(n2)𝑂superscript𝑛2O(n^{2})italic_O ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) messages to ensure that all nodes yield to the node with the maximal ID, which becomes the leader. Later work [24, 14, 27] improved this down to O(nlogn)𝑂𝑛𝑛O(n\log n)italic_O ( italic_n roman_log italic_n ) messages. This complexity is tight in asynchronous rings [7, 21]. In synchronous rings, leader election can be performed by communicating only O(n)𝑂𝑛O(n)italic_O ( italic_n ) messages [21, 17].

For the case of anonymous rings, i.e., with identical nodes without IDs, Angluin [2] proved that symmetry cannot be broken, and thus no leader election algorithm exists. Attiya, Snir, and Warmuth [5] examined anonymous asynchronous rings further and characterized computable tasks. In particular, they showed that many tasks, including ring orientation, require communicating Ω(n2)Ωsuperscript𝑛2\Omega(n^{2})roman_Ω ( italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) messages. Attiya and Snir [4] gave tight bounds on the complexities of randomized algorithms. Relaxed notions of ring orientation were given by Attiya, Snir, and Warmuth [5], where the orientation is either consistent with all nodes or alternating between any two neighbors, and by Syrotiuk and Pachel [29], where nodes determine whether a majority agrees on the same orientation or not. Orienting a ring and leader election when n𝑛nitalic_n is known to the nodes is presented by Flocchini et al. [19].

The question of termination in anonymous rings was explored by Itai and Rodeh [25], who discovered that a network cannot compute its size n𝑛nitalic_n by a terminating algorithm. As a consequence, a leader election algorithm that terminates is impossible, too, since it is trivial to learn n𝑛nitalic_n once a leader is given. On the other hand, if the nodes know n𝑛nitalic_n or even an upper bound on n𝑛nitalic_n, a randomized leader election algorithm that terminates exists [25]. Afek and Matias [1] give various leader election algorithms that trade off knowledge, termination, and number of sent messages.

Censor-Hillel, Gelles, and Haeupler [9] designed a content-oblivious BFS algorithm as a pre-processing step for their distributed interactive coding scheme [22]. Building on that idea, Censor-Hillel et al. [8] introduced the concept of content-oblivious computation and proved that general computations are only possible over 2-edge connected networks. They designed a compiler that converts any asynchronous algorithm into a content-oblivious one, assuming a pre-existing leader. They also gave explicit algorithms for content-oblivious DFS, ear decomposition, and (generalized) Hamiltonian cycle construction.

Computation with fully corrupted messages has been comparatively more studied in the synchronous setting, where the presence or absence of a message in a given round can still be used to send one bit of information [28]. A notable example is the Bee** model, introduced by Cornejo and Kuhn [11], in which each message sent by a node is received by all its neighbors, and nodes can only distinguish between receiving no message and receiving at least one message. Among other problems, leader election has been studied in this setting in a sequence of works [23, 20, 15, 12]. Similar to the fully defective setting, compilers were devised for transforming algorithms with stronger communication primitives into algorithms for the Bee** model [16, 3, 13].

1.3 Organization

Section 2 formally introduces the content-oblivious setting and some other notions and notations. In Section 3 we give our leader election algorithm in oriented rings, deferring some proofs to Appendix A. Section 4 discusses non-oriented rings. Our lower bound on the number of messages sent by a content-oblivious leader election algorithm is presented in Section 5. In Appendix B we discuss anonymous rings and design a randomized quiescently stabilizing algorithm with a high probability of success for both electing a leader and orienting a non-oriented ring. Section 6 concludes our work with a brief summary and suggests a few follow-up questions.

2 Preliminaries

Notations.

For an integer n𝑛nitalic_n, we denote the set {1,2,,n}12𝑛\{1,2,\ldots,n\}{ 1 , 2 , … , italic_n } by [n]delimited-[]𝑛[n][ italic_n ]. All logarithms are binary. For a variable 𝑣𝑎𝑟𝑣𝑎𝑟\mathit{var}italic_var and a node v𝑣vitalic_v, we let 𝑣𝑎𝑟[v]𝑣𝑎𝑟delimited-[]𝑣\mathit{var}[v]italic_var [ italic_v ] denote the value the variable 𝑣𝑎𝑟𝑣𝑎𝑟\mathit{var}italic_var holds at the node v𝑣vitalic_v. By the term with high probability we mean a probability of at least 1nO(1)1superscript𝑛𝑂11-n^{-O(1)}1 - italic_n start_POSTSUPERSCRIPT - italic_O ( 1 ) end_POSTSUPERSCRIPT.

The content-oblivious computation model.

Consider a distributed network G=(V,E)𝐺𝑉𝐸G=(V,E)italic_G = ( italic_V , italic_E ) with n=|V|𝑛𝑉n=|V|italic_n = | italic_V | nodes. We usually assume that each node vV𝑣𝑉v\in Vitalic_v ∈ italic_V is assigned a unique ID (unless otherwise stated), usually denoted by 𝖨𝖣vsubscript𝖨𝖣𝑣\mathsf{ID}_{v}\in\mathbb{N}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT ∈ blackboard_N. We denote the largest ID assigned to a node in the network by 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, that is, 𝖨𝖣max:=maxvV𝖨𝖣vassignsubscript𝖨𝖣subscript𝑣𝑉subscript𝖨𝖣𝑣\mathsf{ID}_{\max}:=\max_{v\in V}{\mathsf{ID}_{v}}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT := roman_max start_POSTSUBSCRIPT italic_v ∈ italic_V end_POSTSUBSCRIPT sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, and by \ellroman_ℓ the node possessing this ID. Apart from the IDs, the nodes are identical. Algorithms are uniform by default, i.e., the nodes neither know the size of the network n𝑛nitalic_n nor any bound on it; for non-uniform algorithms, the nodes may be equipped with such knowledge.

In this paper, we consider rings, i.e., connected graphs where all nodes have degree 2. Neighboring nodes communicate by sending messages to each other. We assume that all messages are subject to corruption: the content of any message is completely erased by noise, resulting in an empty message of length 0, which we call a pulse. Computations that ignore any potential content of a message and thus work only with pulses are called content-oblivious.

Further, the network is asynchronous: the time it takes a pulse to travel through a channel and arrive at its end is unpredictable; the delays are unbounded but always finite. Pulses cannot be dropped or injected by the channel. In such an asynchronous network, the nodes possess neither a common clock nor any notion of time, and they are assumed to be event-driven. This means that a node may act once right in the beginning of the computation and from then on only upon receiving a pulse. As a function of its own ID, the previously received pulses, and possibly its own source of randomness, it can then change its state and, for each connected channel, send any number of pulses. Most of our algorithms are deterministic, except for the ones in Appendix B, where we consider a special case where nodes do not have IDs and use randomness in order to generate them. We say that an algorithm terminates (sometimes also referred to as process termination, explicit termination, or termination detection in the literature) if for each node there is a time at which it has decided on an output and entered a terminating state. Once in a terminating state, a node ignores all incoming pulses and does not send any new ones. We say that an algorithm has quiescent termination if at the time the last node terminates it is guaranteed that no pulses are still in transit. An algorithm’s message complexity is the total number of messages (pulses) it sends during a worst-case computation until all nodes have terminated or until the network has reached quiescence.

Ring’s orientation.

In a ring, each node communicates with its two neighbors via Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT. Consider a pulse re-sent from Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT by every node receiving it. If such a pulse passes through all edges (i.e., is never reflected by a node with misaligned ports), we call the ring oriented and the pulse clockwise (𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW). Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT of each node is then called its 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW port, leading to its 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW neighbor. Counterclockwise (𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW) is defined analogously via Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT. Note that 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW pulses are sent from 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW ports but arrive at 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW ports, and vice versa.

However, rings may not be oriented to begin with. In a non-oriented ring, there is no guarantee that Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT of a node are aligned with a clockwise or counterclockwise walk on the ring. See Fig. 1 for a demonstration. Algorithms for non-oriented rings must work correctly for all assignments of the nodes’ ports. In this case the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW/𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW direction is local per node, and we will use the notion of Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT to avoid confusion.

Refer to caption

  Refer to caption

Figure 1: An oriented ring (left) and a non-oriented one (right).

3 Leader Election in an Oriented Ring

In this section, we consider the problem of electing a leader in an oriented ring of size unknown to the nodes. Recall that in the leader election task, nodes are required to terminate with an output: 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader or 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader, where a single node V𝑉\ell\in Vroman_ℓ ∈ italic_V outputs 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader, while all other nodes must output 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader. We design an algorithm to elect a leader that features quiescent termination and prove the following. See 1.1

For the algorithms in this section, we will use the following methods for sending and receiving pulses. The method send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) sends one pulse over the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel. The method recv𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) checks whether pulses are waiting in the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW incoming queue. If no pulse is in the queue, the method returns 0. Otherwise, it consumes a single pulse from the queue and returns 1. The methods send𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW()()( ) and recv𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW()()( ) are the analogous 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW versions. Moreover, for each node v𝑣vitalic_v, we introduce counters ρ𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT and σ𝖼𝗐subscript𝜎𝖼𝗐\sigma_{\mathsf{cw}}italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT for the total number of received and sent 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW pulses, respectively. Likewise, we introduce ρ𝖼𝖼𝗐subscript𝜌𝖼𝖼𝗐\rho_{\mathsf{ccw}}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT and σ𝖼𝖼𝗐subscript𝜎𝖼𝖼𝗐\sigma_{\mathsf{ccw}}italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT for 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulses. We assume each of the four methods above updates those counters with every received or sent pulse. More precisely, every node v𝑣vitalic_v has variables ρ𝖼𝗐[v]subscript𝜌𝖼𝗐delimited-[]𝑣\rho_{\mathsf{cw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] and σ𝖼𝗐[v]subscript𝜎𝖼𝗐delimited-[]𝑣\sigma_{\mathsf{cw}}[v]italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] initially set to 00. Every time recv𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) processes a pulse from the queue of incoming pulses or send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) sends a pulse, the counters increase according to ρ𝖼𝗐[v]ρ𝖼𝗐[v]+1subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣1\rho_{\mathsf{cw}}[v]\leftarrow\rho_{\mathsf{cw}}[v]+1italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ← italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] + 1 and σ𝖼𝗐[v]σ𝖼𝗐[v]+1subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝗐delimited-[]𝑣1\sigma_{\mathsf{cw}}[v]\leftarrow\sigma_{\mathsf{cw}}[v]+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ← italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] + 1, respectively.

3.1 Warm-up: Leader Election Without Termination

To demonstrate some of the main ideas of our algorithm, let us begin with a simple quiescently stabilizing algorithm that uses only clockwise pulses and elects a leader in an oriented ring. We emphasize that this algorithm is non-terminating. In this algorithm (see Algorithm 1), each node starts by sending one pulse and then relays every received pulse in the same direction, except for the single time when the number of received pulses reaches its own ID. In this event, the node does not relay this one pulse and assigns itself the state of 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader, at least temporarily. However, any pulses received after this are relayed again, and revert the node to being a 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader.

The main intuition behind this algorithm is that each node will eventually have sent and received exactly 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}{}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses: n𝑛nitalic_n pulses are being generated at the initialization, and these pulses keep circulating in the ring, increasing the counter of received pulses until some node has received as many pulses as its ID. At this point, the node removes one pulse, and we are left with n1𝑛1n-1italic_n - 1 pulses in circulation. Except for the node with 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, every node will receive more pulses than its ID, ensuring it eventually becomes a follower. This continues until all nodes, except the one with 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, have removed a single pulse from the circulation and declared themselves followers. The last remaining pulse keeps circulating until all nodes have received exactly 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses. As soon as the last node receives its 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT-th pulse, it sets itself as a leader and removes the last remaining pulse. Since the network no longer contains any pulse, which we call quiescence, the states of the event-driven nodes remain unchanged as well. Note, however, that nodes do not terminate since they do not know whether the ring has achieved this quiescent state or not, i.e., whether some pulses are still in transit.

Algorithm 1 Quiescently Stabilizing Leader Election for Node v𝑣vitalic_v
1:send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( )
2:while true do
3:     if recv𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) returns 1 then
4:         if ρ𝖼𝗐=𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT then
5:              state𝖫𝖾𝖺𝖽𝖾𝗋state𝖫𝖾𝖺𝖽𝖾𝗋\textit{state}\leftarrow\mathsf{Leader}state ← sansserif_Leader
6:         else\triangleright v𝑣vitalic_v acts as a relay unless ρ𝖼𝗐=𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT
7:              state𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋state𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\textit{state}\leftarrow\mathsf{Non\textsf{-}Leader}state ← sansserif_Non - sansserif_Leader
8:              send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( )               

Even though Algorithm 1 does not terminate, analyzing it will help us design our terminating leader election algorithm (Algorithm 2) later on. We begin by proving some key invariants of Algorithm 1, which are also used to show its correctness.

Lemma 3.1.

For every node v𝑣vitalic_v running Algorithm 1, the following invariants hold at the end of each iteration of the main loop:

  1. 1.

    If ρ𝖼𝗐<𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, then σ𝖼𝗐=ρ𝖼𝗐+1subscript𝜎𝖼𝗐subscript𝜌𝖼𝗐1\sigma_{\mathsf{cw}}=\rho_{\mathsf{cw}}+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT + 1, i.e., v𝑣vitalic_v has sent exactly one pulse more than it has received.

  2. 2.

    If ρ𝖼𝗐𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, then σ𝖼𝗐=ρ𝖼𝗐subscript𝜎𝖼𝗐subscript𝜌𝖼𝗐\sigma_{\mathsf{cw}}=\rho_{\mathsf{cw}}italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT, i.e., v𝑣vitalic_v has sent exactly as many pulses as it has received.

Proof 3.2.

Fix an arbitrary node vV𝑣𝑉v\in Vitalic_v ∈ italic_V. For a variable var𝑣𝑎𝑟varitalic_v italic_a italic_r and i𝑖i\in\mathbb{N}italic_i ∈ blackboard_N, we write var(i)𝑣𝑎𝑟𝑖var(i)italic_v italic_a italic_r ( italic_i ) to denote the value of var𝑣𝑎𝑟varitalic_v italic_a italic_r for this node v𝑣vitalic_v at the end of the i𝑖iitalic_i-th iteration. We also use var(0)𝑣𝑎𝑟0var(0)italic_v italic_a italic_r ( 0 ) to denote the initial value of var𝑣𝑎𝑟varitalic_v italic_a italic_r before the first iteration. We prove the statement by induction over i𝑖iitalic_i. Before the first iteration, exactly one initial pulse is sent, and σ𝖼𝗐(0)=1subscript𝜎𝖼𝗐01\sigma_{\mathsf{cw}}(0)=1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( 0 ) = 1. Due to ρ𝖼𝗐(0)=0<𝖨𝖣vsubscript𝜌𝖼𝗐00subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}(0)=0<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( 0 ) = 0 < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, (2) is vacuously true, and (1) holds too since σ𝖼𝗐(0)=1=ρ𝖼𝗐(0)+1subscript𝜎𝖼𝗐01subscript𝜌𝖼𝗐01\sigma_{\mathsf{cw}}(0)=1=\rho_{\mathsf{cw}}(0)+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( 0 ) = 1 = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( 0 ) + 1, proving the induction basis.

Assume now that the invariants hold true at the beginning of some iteration i1𝑖1i\geq 1italic_i ≥ 1 or, equivalently, at the end of iteration i1𝑖1i-1italic_i - 1. We proceed to show that they hold at the end of iteration i𝑖iitalic_i again. If no pulse is received during iteration i𝑖iitalic_i, then the variables in question remain unchanged, and the invariants still hold after the iteration. If a pulse is received, however, there are three cases:

  1. 1.

    If ρ𝖼𝗐(i1)<𝖨𝖣v1subscript𝜌𝖼𝗐𝑖1subscript𝖨𝖣𝑣1\rho_{\mathsf{cw}}({i-1})<\mathsf{ID}_{v}-1italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT - 1, then ρ𝖼𝗐(i)=ρ𝖼𝗐(i1)+1<𝖨𝖣vsubscript𝜌𝖼𝗐𝑖subscript𝜌𝖼𝗐𝑖11subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}(i)=\rho_{\mathsf{cw}}(i-1)+1<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) + 1 < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, and we need to prove the first invariant for iteration i𝑖iitalic_i. Since the condition on 4 is not met, a pulse is sent, and we get σ𝖼𝗐(i)=σ𝖼𝗐(i1)+1=ρ𝖼𝗐(i1)+2=ρ𝖼𝗐(i)+1subscript𝜎𝖼𝗐𝑖subscript𝜎𝖼𝗐𝑖11subscript𝜌𝖼𝗐𝑖12subscript𝜌𝖼𝗐𝑖1\sigma_{\mathsf{cw}}(i)=\sigma_{\mathsf{cw}}(i-1)+1=\rho_{\mathsf{cw}}(i-1)+2=% \rho_{\mathsf{cw}}(i)+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) + 1 = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) + 2 = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) + 1, where the second equality follows from the first invariant for iteration i1𝑖1i-1italic_i - 1. Thus, the invariants still hold.

  2. 2.

    If ρ𝖼𝗐(i1)=𝖨𝖣v1subscript𝜌𝖼𝗐𝑖1subscript𝖨𝖣𝑣1\rho_{\mathsf{cw}}({i-1})=\mathsf{ID}_{v}-1italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT - 1, then ρ𝖼𝗐(i)=𝖨𝖣vsubscript𝜌𝖼𝗐𝑖subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}({i})=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. Thus, in iteration i𝑖iitalic_i, by the condition on 4, no pulses are sent, so σ𝖼𝗐(i)=σ𝖼𝗐(i1)=ρ𝖼𝗐(i1)+1=ρ𝖼𝗐(i)subscript𝜎𝖼𝗐𝑖subscript𝜎𝖼𝗐𝑖1subscript𝜌𝖼𝗐𝑖11subscript𝜌𝖼𝗐𝑖\sigma_{\mathsf{cw}}({i})=\sigma_{\mathsf{cw}}({i-1})=\rho_{\mathsf{cw}}(i-1)+% 1=\rho_{\mathsf{cw}}(i)italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) + 1 = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ), where the second equality is due to the first invariant for iteration i1𝑖1i-1italic_i - 1. Thus, we have σ𝖼𝗐(i)=ρ𝖼𝗐(i)subscript𝜎𝖼𝗐𝑖subscript𝜌𝖼𝗐𝑖\sigma_{\mathsf{cw}}({i})=\rho_{\mathsf{cw}}({i})italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) and ρ𝖼𝗐(i)𝖨𝖣vsubscript𝜌𝖼𝗐𝑖subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}({i})\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, and the invariants hold.

  3. 3.

    If ρ𝖼𝗐(i1)>𝖨𝖣v1subscript𝜌𝖼𝗐𝑖1subscript𝖨𝖣𝑣1\rho_{\mathsf{cw}}({i-1})>\mathsf{ID}_{v}-1italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) > sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT - 1, we have ρ𝖼𝗐(i)>𝖨𝖣vsubscript𝜌𝖼𝗐𝑖subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}(i)>\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) > sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. The condition on 4 is not met in iteration i𝑖iitalic_i, and a pulse is relayed. We thus have σ𝖼𝗐(i)=σ𝖼𝗐(i1)+1=ρ𝖼𝗐(i1)+1=ρ𝖼𝗐(i)subscript𝜎𝖼𝗐𝑖subscript𝜎𝖼𝗐𝑖11subscript𝜌𝖼𝗐𝑖11subscript𝜌𝖼𝗐𝑖\sigma_{\mathsf{cw}}(i)=\sigma_{\mathsf{cw}}(i-1)+1=\rho_{\mathsf{cw}}(i-1)+1=% \rho_{\mathsf{cw}}(i)italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ) = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) + 1 = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i - 1 ) + 1 = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ( italic_i ), with the second equality again due to the second invariant for iteration i1𝑖1i-1italic_i - 1.

Lemma 3.3.

Let \ellroman_ℓ be the node with 𝖨𝖣=𝖨𝖣maxsubscript𝖨𝖣subscript𝖨𝖣\mathsf{ID}_{\ell}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. If ρ𝖼𝗐[]𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]\geq\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT at some point, then ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds for every node v𝑣vitalic_v at this point. That is, \ellroman_ℓ is the last node to satisfy ρ𝖼𝗐[]𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]\geq\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT.

Proof 3.4.

Consider the iteration where ρ𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT holds. Assume towards contradiction that the statement does not hold, and let xkVsubscript𝑥𝑘𝑉x_{k}\in Vitalic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ∈ italic_V be the closest predecessor222i.e., along the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW path of the network. of \ellroman_ℓ for which ρ𝖼𝗐[xk]<𝖨𝖣xksubscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑘subscript𝖨𝖣subscript𝑥𝑘\rho_{\mathsf{cw}}[x_{k}]<\mathsf{ID}_{x_{k}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] < sansserif_ID start_POSTSUBSCRIPT italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT. By Item 1, σ𝖼𝗐[xk]=ρ𝖼𝗐[xk]+1subscript𝜎𝖼𝗐delimited-[]subscript𝑥𝑘subscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑘1\sigma_{\mathsf{cw}}[x_{k}]=\rho_{\mathsf{cw}}[x_{k}]+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] + 1. Denoting the intermediate nodes by x1,,xk1subscript𝑥1subscript𝑥𝑘1x_{1},\ldots,x_{k-1}italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_x start_POSTSUBSCRIPT italic_k - 1 end_POSTSUBSCRIPT, by Item 2, we have σ𝖼𝗐[xi]=ρ𝖼𝗐[xi]subscript𝜎𝖼𝗐delimited-[]subscript𝑥𝑖subscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖\sigma_{\mathsf{cw}}[x_{i}]=\rho_{\mathsf{cw}}[x_{i}]italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] for all i[k1]𝑖delimited-[]𝑘1i\in[k-1]italic_i ∈ [ italic_k - 1 ].

As the number of pulses sent by a node upper bounds the number of pulses its neighbor has received, we have the following inequality.

ρ𝖼𝗐[]σ𝖼𝗐[x1]=ρ𝖼𝗐[x1]σ𝖼𝗐[xk]=ρ𝖼𝗐[xk]+1.subscript𝜌𝖼𝗐delimited-[]subscript𝜎𝖼𝗐delimited-[]subscript𝑥1subscript𝜌𝖼𝗐delimited-[]subscript𝑥1subscript𝜎𝖼𝗐delimited-[]subscript𝑥𝑘subscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑘1\rho_{\mathsf{cw}}[\ell]\leq\sigma_{\mathsf{cw}}[x_{1}]=\rho_{\mathsf{cw}}[x_{% 1}]\leq\dots\leq\sigma_{\mathsf{cw}}[x_{k}]=\rho_{\mathsf{cw}}[x_{k}]+1.italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] ≤ italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ] ≤ ⋯ ≤ italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] + 1 .

Since ρ𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT and ρ𝖼𝗐[xk]<𝖨𝖣xksubscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑘subscript𝖨𝖣subscript𝑥𝑘\rho_{\mathsf{cw}}[x_{k}]<\mathsf{ID}_{x_{k}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] < sansserif_ID start_POSTSUBSCRIPT italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT, the above inequality implies 𝖨𝖣𝖨𝖣xksubscript𝖨𝖣subscript𝖨𝖣subscript𝑥𝑘\mathsf{ID}_{\ell}\leq\mathsf{ID}_{x_{k}}sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT ≤ sansserif_ID start_POSTSUBSCRIPT italic_x start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT, which is a contradiction due to the uniqueness of the largest ID and 𝖨𝖣=𝖨𝖣maxsubscript𝖨𝖣subscript𝖨𝖣\mathsf{ID}_{\ell}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Therefore, \ellroman_ℓ is the last node meeting the condition with ρ𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT.

We now show that quiescence has been reached when ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds for all nodes.

Lemma 3.5.

If ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds at every node v𝑣vitalic_v, then the network is in quiescence.

Proof 3.6.

By Item 2, we get that σ𝖼𝗐[v]=ρ𝖼𝗐[v]subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\sigma_{\mathsf{cw}}[v]=\rho_{\mathsf{cw}}[v]italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] holds for all v𝑣vitalic_v; hence, the total number of sent pulses is equal to the total number of received pulses. In particular, no pulses are in transit (sent but not received).

In fact, the converse is also true; that is, a necessary condition for quiescence is that ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds at every node v𝑣vitalic_v and becomes a relay.

Lemma 3.7.

If the network is in quiescence, then ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds at every node v𝑣vitalic_v.

Proof 3.8.

If there is quiescence, then vσ𝖼𝗐[v]=vρ𝖼𝗐[v]subscript𝑣subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\sum_{v}{\sigma_{\mathsf{cw}}[v]}=\sum_{v}{\rho_{\mathsf{cw}}[v]}∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = ∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ].

By Lemma 3.1, every node v𝑣vitalic_v has σ𝖼𝗐[v]ρ𝖼𝗐[v]subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\sigma_{\mathsf{cw}}[v]\geq\rho_{\mathsf{cw}}[v]italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ]. Assuming there is some bad node b𝑏bitalic_b with ρ𝖼𝗐[b]<𝖨𝖣bsubscript𝜌𝖼𝗐delimited-[]𝑏subscript𝖨𝖣𝑏\rho_{\mathsf{cw}}[b]<\mathsf{ID}_{b}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] < sansserif_ID start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT, then by Item 1, σ𝖼𝗐[b]=ρ𝖼𝗐[b]+1subscript𝜎𝖼𝗐delimited-[]𝑏subscript𝜌𝖼𝗐delimited-[]𝑏1\sigma_{\mathsf{cw}}[b]=\rho_{\mathsf{cw}}[b]+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] + 1. Therefore, vσ𝖼𝗐[v]=vbσ𝖼𝗐[v]+σ𝖼𝗐[b]vρ𝖼𝗐[v]+1subscript𝑣subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝑣𝑏subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝗐delimited-[]𝑏subscript𝑣subscript𝜌𝖼𝗐delimited-[]𝑣1\sum_{v}{\sigma_{\mathsf{cw}}[v]}=\sum_{v\neq b}{\sigma_{\mathsf{cw}}[v]}+% \sigma_{\mathsf{cw}}[b]\geq\sum_{v}{\rho_{\mathsf{cw}}[v]}+1∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = ∑ start_POSTSUBSCRIPT italic_v ≠ italic_b end_POSTSUBSCRIPT italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] + italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] ≥ ∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] + 1, so this cannot occur.

Corollary 3.9.

There is quiescence at some point of time if and only if each node v𝑣vitalic_v has ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT at that point of time.

Proof 3.10.

The corollary follows directly from Lemmas 3.5 and 3.7.

Another equivalent statement to the ones in Corollary 3.9 is that every node has sent and received exactly 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses.

Lemma 3.11.

In any execution of Algorithm 1, at any point of time, the following statements are equivalent:

  1. 1.

    The network is in quiescence,

  2. 2.

    v:ρ𝖼𝗐[v]𝖨𝖣v:for-all𝑣subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\forall{v}:\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}∀ italic_v : italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, and

  3. 3.

    v:ρ𝖼𝗐[v]=σ𝖼𝗐[v]=𝖨𝖣max:for-all𝑣subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\forall{v}:\rho_{\mathsf{cw}}[v]=\sigma_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}∀ italic_v : italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT.

Proof 3.12.

The first two statements are equivalent by Corollary 3.9.

Now, assuming ρ𝖼𝗐[v]=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT holds for every v𝑣vitalic_v, then so does ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. Conversely, assume v:ρ𝖼𝗐[v]𝖨𝖣v:for-all𝑣subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\forall{v}:\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}∀ italic_v : italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. By Lemma 3.3, the node \ellroman_ℓ with the largest ID is the last to satisfy that inequality. After the iteration where this occurs for the first time, we have

ρ𝖼𝗐[]=𝖨𝖣=𝖨𝖣max.subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\mathsf{ID}_{\ell}=\mathsf{ID}_{\max}.italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT .

By the first equivalence, there is quiescence, and no more pulses are sent or received. Any pulses that have been sent by a node u𝑢uitalic_u have been received by its neighbor v𝑣vitalic_v, that is, over all 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW edges (u,v)𝑢𝑣(u,v)( italic_u , italic_v ), it holds that σ𝖼𝗐[u]=ρ𝖼𝗐[v].subscript𝜎𝖼𝗐delimited-[]𝑢subscript𝜌𝖼𝗐delimited-[]𝑣.\sigma_{\mathsf{cw}}[u]=\rho_{\mathsf{cw}}[v]\text{.}italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] .

Also, by Item 2, every node v𝑣vitalic_v has σ𝖼𝗐[v]=ρ𝖼𝗐[v].subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣.\sigma_{\mathsf{cw}}[v]=\rho_{\mathsf{cw}}[v]\text{.}italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] . As the network forms a ring, combining those equations yields that ρ𝖼𝗐[v]=σ𝖼𝗐[v]=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]=\sigma_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT holds for every v𝑣vitalic_v.

Given the above properties, we are ready to prove that certain interesting events occur in every execution of Algorithm 1.

First, we show that the inequality ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT is eventually satisfied by every v𝑣vitalic_v. Due to the equivalences given by Lemma 3.11, this leads to a setting where quiescence is achieved, and every node has sent and received exactly 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses.

Lemma 3.13.

In any execution of Algorithm 1, for every node v𝑣vitalic_v, there is some iteration, where ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds.

Proof 3.14.

Let us track the evolution through time of B𝐵Bitalic_B, the set of nodes that have not met the condition yet; that is, at every point of time, for all bB𝑏𝐵b\in Bitalic_b ∈ italic_B, ρ𝖼𝗐[b]<𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑏subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[b]<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT.

Initially, B𝐵Bitalic_B contains all nodes, each of which are removed upon meeting the condition. Since a removed node never enters B𝐵Bitalic_B again, |B|𝐵|B|| italic_B | is monotonically decreasing.

Consider the point of time where |B|𝐵|B|| italic_B | reaches a minimum, so B𝐵Bitalic_B remains fixed. If |B|=0𝐵0|B|=0| italic_B | = 0, then there is nothing to prove, so assume |B|>0𝐵0|B|>0| italic_B | > 0. At that time, maintain values Δb:=𝖨𝖣bρ𝖼𝗐[b]>0assignsubscriptΔ𝑏subscript𝖨𝖣𝑏subscript𝜌𝖼𝗐delimited-[]𝑏0\Delta_{b}:=\mathsf{ID}_{b}-\rho_{\mathsf{cw}}[b]>0roman_Δ start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT := sansserif_ID start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT - italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] > 0 for every bB𝑏𝐵b\in Bitalic_b ∈ italic_B.

By Item 1, for all bB𝑏𝐵b\in Bitalic_b ∈ italic_B, we have that σ𝖼𝗐[b]=ρ𝖼𝗐[b]+1subscript𝜎𝖼𝗐delimited-[]𝑏subscript𝜌𝖼𝗐delimited-[]𝑏1\sigma_{\mathsf{cw}}[b]=\rho_{\mathsf{cw}}[b]+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] + 1 always holds. Also, from that point on, for every vB𝑣𝐵v\notin Bitalic_v ∉ italic_B, we have σ𝖼𝗐[v]=ρ𝖼𝗐[v]subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\sigma_{\mathsf{cw}}[v]=\rho_{\mathsf{cw}}[v]italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] by Item 2.

The number of pulses in transit333Including pulses that are in some node’s queue, but were not processed yet. at any given time is the difference between the total number of sent and received pulses across all nodes. Therefore, since vσ𝖼𝗐[v]=vρ𝖼𝗐[v]+|B|subscript𝑣subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝑣subscript𝜌𝖼𝗐delimited-[]𝑣𝐵\sum_{v}{\sigma_{\mathsf{cw}}[v]}=\sum_{v}{\rho_{\mathsf{cw}}[v]}+|B|∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = ∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] + | italic_B |, there are still |B|𝐵|B|| italic_B | pulses in the network. Since the nodes outside B𝐵Bitalic_B act as relays, they maintain the number of pulses in transit and, in particular, never remove a pulse from the network. Eventually, some node bB𝑏𝐵b\in Bitalic_b ∈ italic_B must receive a pulse, which decreases the difference ΔbsubscriptΔ𝑏\Delta_{b}roman_Δ start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT by one. If Δb=0subscriptΔ𝑏0\Delta_{b}=0roman_Δ start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT = 0, then b𝑏bitalic_b is removed from B𝐵Bitalic_B, and |B|𝐵|B|| italic_B | decreases beyond its minimum, a contradiction. Otherwise, b𝑏bitalic_b forwards a pulse and the number of pulses in transit remains |B|𝐵|B|| italic_B |, so we can re-apply this argument. At some point, ΔbsubscriptΔ𝑏\Delta_{b}roman_Δ start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT reaches 00 for some bB𝑏𝐵b\in Bitalic_b ∈ italic_B. Thus, ρ𝖼𝗐[b]𝖨𝖣bsubscript𝜌𝖼𝗐delimited-[]𝑏subscript𝖨𝖣𝑏\rho_{\mathsf{cw}}[b]\geq\mathsf{ID}_{b}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_b ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_b end_POSTSUBSCRIPT holds for b𝑏bitalic_b, and b𝑏bitalic_b is removed from B𝐵Bitalic_B, again, a contradiction.

A result of Lemma 3.13, is that, eventually, all nodes send and receive exactly 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses, and no further activity occurs on the network.

Corollary 3.15.

In any execution of Algorithm 1, at some point, every node has sent and received exactly 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses, and the network reached quiescence.

Proof 3.16.

By Lemma 3.13, there is an iteration, after which ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds for all nodes v𝑣vitalic_v. The statement then follows directly from Lemma 3.11.

We also have the following trivial upper bound as a direct corollary.

Corollary 3.17.

In any execution of Algorithm 1, for every node v𝑣vitalic_v, at every point of time ρ𝖼𝗐[v]𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]\leq\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≤ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT.

Proof 3.18.

Immediate from Corollary 3.15 and the monotonicity of ρ𝖼𝗐[v]subscript𝜌𝖼𝗐delimited-[]𝑣\rho_{\mathsf{cw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ], which is initially 00.

3.2 Leader Election With Quiescent Termination

Although Algorithm 1 is a quiescently stabilizing algorithm for leader election, more ideas are needed in order to achieve this with quiescent termination. The main idea is to utilize the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel to notify all nodes when the leader is elected. The immediate approach would be to leverage the event ρ𝖼𝗐[v]=𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, which signifies the successful election once it happens at the node with maximal ID. However, this is impossible, since the same event also occurs for every other node before the election process has finished.

To be able to detect termination, we require an event that occurs uniquely for the leader, and never for other nodes. If we managed to run Algorithm 1 over the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel after a full execution of the same algorithm over the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel, then, by symmetry, all nodes would eventually receive 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT many 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulses. In this scenario, the event ρ𝖼𝗐[v]=𝖨𝖣v=ρ𝖼𝖼𝗐[v]subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{v}=\rho_{\mathsf{ccw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] would, in fact, be unique to the node with the largest ID. Indeed, an initial full execution of Algorithm 1 over the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel guarantees that all other nodes have ρ𝖼𝗐[v]>𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]>\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] > sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT prior to exchanging 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulses, so the above event occurs uniquely at the leader and could be used as the trigger for termination.

The main remaining difficulty is that we cannot start the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW algorithm after the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW one is done since neither the leader nor any other node can infer that the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW algorithm has stabilized purely from the number of 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW pulses received. We overcome this obstacle by running both algorithms in parallel, ensuring that the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW one lags behind the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW one. By subtly prioritizing the execution of the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW algorithm over that of the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW one, we enforce that once ρ𝖼𝖼𝗐[v]=𝖨𝖣vsubscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{ccw}}[v]=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT occurs for some 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader node, we already have ρ𝖼𝗐[v]>𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]>\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] > sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. Then, the only node v𝑣vitalic_v satisfying ρ𝖼𝗐[v]=𝖨𝖣v=ρ𝖼𝖼𝗐[v]subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{v}=\rho_{\mathsf{ccw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] is the elected leader. It is the uniqueness of all IDs, crucially including 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, that enables this approach.

Algorithm 2 Quiescently Terminating Leader Election for Node v𝑣vitalic_v
1:send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( )
2:repeat
3:     if recv𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) returns 1 then \triangleright Run Algorithm 1 over the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel
4:         if ρ𝖼𝗐=𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT then
5:              state𝖫𝖾𝖺𝖽𝖾𝗋state𝖫𝖾𝖺𝖽𝖾𝗋\textit{state}\leftarrow\mathsf{Leader}state ← sansserif_Leader
6:         else
7:              state𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋state𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\textit{state}\leftarrow\mathsf{Non\textsf{-}Leader}state ← sansserif_Non - sansserif_Leader
8:              send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( )               
9:
10:     if ρ𝖼𝗐𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT then \triangleright Run Algorithm 1 over the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel, once ρ𝖼𝗐𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT
11:         if σ𝖼𝖼𝗐=0subscript𝜎𝖼𝖼𝗐0\sigma_{\mathsf{ccw}}=0italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT = 0 then send𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW()()( )  end if
12:         if recv𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW()()( ) returns 1 then
13:              if ρ𝖼𝖼𝗐=𝖨𝖣vsubscript𝜌𝖼𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{ccw}}=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT then
14:                  pass
15:              else
16:                  send𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW()()( )                             
17:
18:     if ρ𝖼𝗐=𝖨𝖣v=ρ𝖼𝖼𝗐subscript𝜌𝖼𝗐subscript𝖨𝖣𝑣subscript𝜌𝖼𝖼𝗐\rho_{\mathsf{cw}}=\mathsf{ID}_{v}=\rho_{\mathsf{ccw}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT then \triangleright Initiate a termination pulse
19:         send𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW()()( )
20:         while recv𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW()()( ) returns 0 do
21:              pass \triangleright Wait for return of termination pulse               
22:until ρ𝖼𝖼𝗐>ρ𝖼𝗐subscript𝜌𝖼𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{ccw}}>\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT > italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT
23:output state

The complete algorithm with quiescent termination is given in Algorithm 2. It is composed of two instances of Algorithm 1: one over the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel (3 to 8) and one over the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel (10 to 16). The 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW instance starts, as before, upon initialization, while the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW instance starts at node v𝑣vitalic_v once it reaches the ρ𝖼𝗐[v]=𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT event in the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW instance. This guarantees that the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW instance lags behind the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW one. Finally, 18 to 21 identify the event ρ𝖼𝗐[v]=𝖨𝖣v=ρ𝖼𝖼𝗐[v]subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{v}=\rho_{\mathsf{ccw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] that uniquely occurs at the leader. At that point of time, all the nodes have ρ𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT and ρ𝖼𝖼𝗐subscript𝜌𝖼𝖼𝗐\rho_{\mathsf{ccw}}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT set to 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, and the leader is the last node for which this event occurs. This triggers the termination process: the leader sends a single 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulse. Any node receiving this extra pulse sees, for the first time, ρ𝖼𝖼𝗐>ρ𝖼𝗐subscript𝜌𝖼𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{ccw}}>\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT > italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT, forwards the pulse and terminates (22). The extra pulse is forwarded until it returns to the leader, causing it to terminate without forwarding the pulse. The analysis of Algorithm 2 is deferred to Appendix A due to the space constraints.

4 Leader Election in Non-Oriented Rings

A natural follow-up question to the above leader election algorithm in oriented rings is whether the same holds for non-oriented rings. In this setting, nodes do not possess a predefined 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel and 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel anymore. Instead, they have two ports, Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT and Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT, connecting them to their two neighbors in an arbitrary order.

The straightforward approach would be to first orient the ring with a quiescently terminating algorithm and then use our leader election algorithm from Section 3. Since a ring orientation is easily computable once a leader has been elected with quiescent termination, orientation and leader election are essentially equivalent tasks from the perspective of quiescently terminating algorithms.

In this section, we instead present a quiescently stabilizing algorithm for non-oriented rings, which both elects a leader and orients the ring. Recall that the difference from quiescent termination is that the nodes do not need to terminate explicitly; it suffices for all pulse activity to cease with the correctly computed output still present. Recall our main theorem for this part.

See 1.2

We emphasize again that this algorithm does not terminate in the usual sense. Instead, its success is defined as reaching quiescence while guaranteeing that at that time only a single node has set its internal state to 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader, while all other nodes have set their state to 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader. Additionally, we require that nodes achieve a consistent ring orientation as follows: each node has to label exactly one of its two ports as the port leading to the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW neighbor such that starting at some node and repeatedly moving to node connected to 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW port lets us pass through all edges in the ring.

For ease of exposure, we first present an algorithm of slightly worse complexity but whose analysis is almost fully captured by results from earlier sections. We then improve its complexity by proving an additional property about Algorithm 1, our main building block for our algorithm for non-oriented rings (Algorithm 3). Namely, we show that executing Algorithm 1 on a ring with non-unique IDs essentially achieves the same guarantees as when used on a ring with unique IDs (Lemma 4.3). This observation allows us to halve the complexity of Algorithm 3, as we shall see, and also has implications for solving the same tasks on anonymous rings with access to randomness. As this extension to anonymous rings is a minor effort and follows from standard techniques, we defer it to Appendix B.

Algorithm overview.

At a high level, Algorithm 3 consists of two parallels executions of Algorithm 1, each one using each channel in the ring in a single direction. For an intuition of how that is possible, consider a setting where the network has a single pulse in transit. Suppose that all nodes execute the same algorithm that sends a pulse on Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT whenever one is received on Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, and vice versa. Forwarding the pulse in this manner has it travel the entire ring, since every time a pulse is received by a given node v𝑣vitalic_v from one of its neighbors, it is sent to its other neighbor. If adding another pulse going in the other direction to the network, the two pulses independently travel around the ring in opposite directions. The nodes can thus effectively run two algorithms in parallel without them interfering with one another, as long as one only works with clockwise pulses and the other with counterclockwise pulses. As Algorithm 1 only uses pulses going in one direction, it satisfies this requirement. The major caveat is that the nodes cannot be certain which of the two algorithms they execute is working with clockwise pulses and which is working with counterclockwise pulses.

Our algorithm has essentially two parts: one in which the node reacts to pulses and possibly forwards them (Lines 5 to 7), and one in which it computes its output depending on the number of pulses it received from each port (Lines 8 to 16). From the point of view of analyzing how many pulses are eventually sent in the network, only the first part is relevant. It is the part that simulates two executions of Algorithm 1. For the nodes to settle on a consistent orientation of the ring in the second part, we break symmetry between the two options by having strictly more pulses sent in one orientation of the ring than in the other.

We distinguish the two parallel executions of Algorithm 1 by having each node v𝑣vitalic_v pick two distinct virtual IDs for itself, 𝖨𝖣v0superscriptsubscript𝖨𝖣𝑣0\mathsf{ID}_{v}^{\mathrm{0}}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 0 end_POSTSUPERSCRIPT and 𝖨𝖣v1superscriptsubscript𝖨𝖣𝑣1\mathsf{ID}_{v}^{\mathrm{1}}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 1 end_POSTSUPERSCRIPT (2). 𝖨𝖣v(1)superscriptsubscript𝖨𝖣𝑣1\mathsf{ID}_{v}^{(1)}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 1 ) end_POSTSUPERSCRIPT affects how v𝑣vitalic_v behaves regarding pulses received from its Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, and symmetrically for 𝖨𝖣v(0)superscriptsubscript𝖨𝖣𝑣0\mathsf{ID}_{v}^{(0)}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 0 ) end_POSTSUPERSCRIPT and Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT. While nodes do not know which of their two virtual IDs is used in the clockwise or counterclockwise execution of Algorithm 1, they use a distinct ID in both executions. Eventually, in each direction, the number of pulses received by each node stabilizes to the largest ID in that direction. The choice of IDs ensures that the two parallel executions have distinct largest IDs, so eventually all nodes see strictly more pulses being sent in one direction than the other. This allows nodes to agree on a common orientation of the ring, and elect as leader the node who was the source of the largest ID.

The nodes use the following methods for sending and receiving pulses. Let i{0,1}𝑖01i\in\{0,1\}italic_i ∈ { 0 , 1 }.

  1. 1.

    sendPortisubscriptPort𝑖\mathrm{Port}_{i}roman_Port start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT()()( ): sends a pulse through PortisubscriptPort𝑖\mathrm{Port}_{i}roman_Port start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT,

  2. 2.

    recvPortisubscriptPort𝑖\mathrm{Port}_{i}roman_Port start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT()()( ): check whether a pulse is waiting in the incoming queue of PortisubscriptPort𝑖\mathrm{Port}_{i}roman_Port start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT. If not, return 0. Otherwise, consume a single pulse from the queue and return 1.

Algorithm 3 Quiescently Stabilizing Leader Election on Non-Oriented Rings for Node v𝑣vitalic_v
1:for i{0,1}𝑖01i\in\{0,1\}italic_i ∈ { 0 , 1 } do
2:     𝖨𝖣v(i)2𝖨𝖣v1+isuperscriptsubscript𝖨𝖣𝑣𝑖2subscript𝖨𝖣𝑣1𝑖\mathsf{ID}_{v}^{(i)}\leftarrow 2\cdot\mathsf{ID}_{v}-1+isansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( italic_i ) end_POSTSUPERSCRIPT ← 2 ⋅ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT - 1 + italic_i
3:     sendPortisubscriptPort𝑖\mathrm{Port}_{i}roman_Port start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT()()( )
4:while true do
5:     for i{0,1}𝑖01i\in\{0,1\}italic_i ∈ { 0 , 1 } do
6:         if recvPort1isubscriptPort1𝑖\mathrm{Port}_{1-i}roman_Port start_POSTSUBSCRIPT 1 - italic_i end_POSTSUBSCRIPT()()( ) returns 1 and ρ1i𝖨𝖣v(i)subscript𝜌1𝑖superscriptsubscript𝖨𝖣𝑣𝑖{\rho}_{1-i}\neq\mathsf{ID}_{v}^{(i)}italic_ρ start_POSTSUBSCRIPT 1 - italic_i end_POSTSUBSCRIPT ≠ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( italic_i ) end_POSTSUPERSCRIPT then
7:              sendPortisubscriptPort𝑖\mathrm{Port}_{i}roman_Port start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT()()( ) \triangleright Pulses received at one port are sent forward at the opposite one               
8:     if max(ρ0,ρ1)𝖨𝖣v(1)subscript𝜌0subscript𝜌1superscriptsubscript𝖨𝖣𝑣1\max({\rho}_{0},{\rho}_{1})\geq\mathsf{ID}_{v}^{(1)}roman_max ( italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 1 ) end_POSTSUPERSCRIPT then
9:         if  ρ0=𝖨𝖣v(1)subscript𝜌0superscriptsubscript𝖨𝖣𝑣1{\rho}_{0}=\mathsf{ID}_{v}^{(1)}italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 1 ) end_POSTSUPERSCRIPT and ρ1<𝖨𝖣v(1)subscript𝜌1superscriptsubscript𝖨𝖣𝑣1{\rho}_{1}<\mathsf{ID}_{v}^{(1)}italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 1 ) end_POSTSUPERSCRIPT then
10:              state \leftarrow 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader
11:         else
12:              state \leftarrow 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader          
13:         if ρ0>ρ1subscript𝜌0subscript𝜌1{\rho}_{0}>{\rho}_{1}italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT > italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT then
14:              name Port0𝖢𝖢𝖶subscriptPort0𝖢𝖢𝖶\mathrm{Port}_{0}\coloneqq\mathsf{CCW}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ≔ sansserif_CCW and Port1𝖢𝖶subscriptPort1𝖢𝖶\mathrm{Port}_{1}\coloneqq\mathsf{CW}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ≔ sansserif_CW \triangleright I.e., Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT connects the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW neighbor
15:         else
16:              name Port0𝖢𝖶subscriptPort0𝖢𝖶\mathrm{Port}_{0}\coloneqq\mathsf{CW}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT ≔ sansserif_CW and Port1𝖢𝖢𝖶subscriptPort1𝖢𝖢𝖶\mathrm{Port}_{1}\coloneqq\mathsf{CCW}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ≔ sansserif_CCW               
Proposition 4.1.

Algorithm 3 elects a leader and consistently orients the ring in n(4𝖨𝖣max1)𝑛4subscript𝖨𝖣1n(4\cdot\mathsf{ID}_{\max}-1)italic_n ( 4 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT - 1 ) pulses. It achieves quiescence but does not terminate.

Proof 4.2.

Consider \ellroman_ℓ, the node of largest ID. We define as clockwise the direction of a pulse sent from \ellroman_ℓ’s Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT and forwarded by all other nodes (i.e., sent from PortisubscriptPort𝑖\mathrm{Port}_{i}roman_Port start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT after arriving at Port1isubscriptPort1𝑖\mathrm{Port}_{1-i}roman_Port start_POSTSUBSCRIPT 1 - italic_i end_POSTSUBSCRIPT). We call the ports sending such a pulse clockwise, and those receiving it counterclockwise. We show the our algorithm elects \ellroman_ℓ as a leader and all nodes declare the correct port as clockwise.

We show that the network eventually achieves quiescence and all nodes receive the same number of clockwise and counterclockwise pulses. Let us argue this for clockwise pulses; the property for counterclockwise pulses will follow by symmetry. For every node v𝑣vitalic_v whose Port1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT connects it to its clockwise neighbor, let us rename sendPort1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT()()( ) to send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) and recvPort0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT()()( ) to recv𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) in its code. Let us also define 𝖨𝖣vcw=𝖨𝖣v1superscriptsubscript𝖨𝖣𝑣cwsuperscriptsubscript𝖨𝖣𝑣1\mathsf{ID}_{v}^{\mathrm{cw}}=\mathsf{ID}_{v}^{\mathrm{1}}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_cw end_POSTSUPERSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 1 end_POSTSUPERSCRIPT for such nodes. For the other nodes, which are connected to their clockwise neighbors through Port0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT, rename sendPort0subscriptPort0\mathrm{Port}_{0}roman_Port start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT()()( ) to send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) and recvPort1subscriptPort1\mathrm{Port}_{1}roman_Port start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT()()( ) to recv𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) in their code, and let 𝖨𝖣vcw=𝖨𝖣v0superscriptsubscript𝖨𝖣𝑣cwsuperscriptsubscript𝖨𝖣𝑣0\mathsf{ID}_{v}^{\mathrm{cw}}=\mathsf{ID}_{v}^{\mathrm{0}}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_cw end_POSTSUPERSCRIPT = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT 0 end_POSTSUPERSCRIPT. We emphasize that this renaming is done purely for our analysis and is not an operation performed by the nodes, which are oblivious to what the clockwise direction is. Consider an execution of Algorithm 3. Whenever the scheduler delivers a clockwise pulse, this pulse is read by a recv𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) method, and if forwarded (which depends on 𝖨𝖣vcwsuperscriptsubscript𝖨𝖣𝑣cw\mathsf{ID}_{v}^{\mathrm{cw}}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_cw end_POSTSUPERSCRIPT), it is re-sent by a send𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW()()( ) method, according to our renaming. Other methods are never activated by clockwise pulses and never emit a clockwise pulse. As such, Algorithm 3 executes the exact same code on clockwise pulses as Algorithm 1 and thus has the same guarantees as Algorithm 1 regarding clockwise pulses. By Corollary 3.15, this means that we achieve quiescence for clockwise pulses, with all nodes eventually having sent and received exactly the same number maxv𝖨𝖣vcwsubscript𝑣superscriptsubscript𝖨𝖣𝑣cw\max_{v}\mathsf{ID}_{v}^{\mathrm{cw}}roman_max start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_cw end_POSTSUPERSCRIPT of clockwise pulses. The same holds symmetrically for maxv𝖨𝖣vccwsubscript𝑣superscriptsubscript𝖨𝖣𝑣ccw\max_{v}\mathsf{ID}_{v}^{\mathrm{ccw}}roman_max start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_ccw end_POSTSUPERSCRIPT pulses counterclockwise pulses per node, where 𝖨𝖣vccwsuperscriptsubscript𝖨𝖣𝑣ccw\mathsf{ID}_{v}^{\mathrm{ccw}}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_ccw end_POSTSUPERSCRIPT is defined similarly to 𝖨𝖣vcwsuperscriptsubscript𝖨𝖣𝑣cw\mathsf{ID}_{v}^{\mathrm{cw}}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_cw end_POSTSUPERSCRIPT.

Since \ellroman_ℓ picks as identifiers 2𝖨𝖣max2subscript𝖨𝖣2\cdot\mathsf{ID}_{\max}2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT and 2𝖨𝖣max12subscript𝖨𝖣12\cdot\mathsf{ID}_{\max}-12 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT - 1 for the two directions, we have maxv𝖨𝖣vcw=2𝖨𝖣maxsubscript𝑣superscriptsubscript𝖨𝖣𝑣cw2subscript𝖨𝖣\max_{v}\mathsf{ID}_{v}^{\mathrm{cw}}=2\cdot\mathsf{ID}_{\max}roman_max start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_cw end_POSTSUPERSCRIPT = 2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT and maxv𝖨𝖣vccw=2𝖨𝖣max1subscript𝑣superscriptsubscript𝖨𝖣𝑣ccw2subscript𝖨𝖣1\max_{v}\mathsf{ID}_{v}^{\mathrm{ccw}}=2\cdot\mathsf{ID}_{\max}-1roman_max start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_ccw end_POSTSUPERSCRIPT = 2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT - 1. Hence, all nodes have sent and received 2𝖨𝖣max2subscript𝖨𝖣2\cdot\mathsf{ID}_{\max}2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT clockwise pulses and 2𝖨𝖣max12subscript𝖨𝖣12\cdot\mathsf{ID}_{\max}-12 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT - 1 counterclockwise pulses. This yields a bound of n(4𝖨𝖣max1)𝑛4subscript𝖨𝖣1n(4\cdot\mathsf{ID}_{\max}-1)italic_n ( 4 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT - 1 ) pulses, ensuring a consistent orientation according to the test on 13.

Improving the message complexity.

We now show how to improve the complexity of Algorithm 3 to n(2𝖨𝖣max+1)𝑛2subscript𝖨𝖣1n(2\cdot\mathsf{ID}_{\max}+1)italic_n ( 2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ). Since nodes send pulses according to their IDs, 2 effectively doubles the number of pulses sent by the algorithm. To avoid this doubling, one can generate the two IDs in a different manner; for instance, 𝖨𝖣v(1)𝖨𝖣v+1superscriptsubscript𝖨𝖣𝑣1subscript𝖨𝖣𝑣1\mathsf{ID}_{v}^{(1)}\leftarrow\mathsf{ID}_{v}+1sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 1 ) end_POSTSUPERSCRIPT ← sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT + 1, and 𝖨𝖣v(0)𝖨𝖣vsuperscriptsubscript𝖨𝖣𝑣0subscript𝖨𝖣𝑣\mathsf{ID}_{v}^{(0)}\leftarrow\mathsf{ID}_{v}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 0 ) end_POSTSUPERSCRIPT ← sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. However, this leads to assigning the same ID to multiple nodes. We argue that Algorithm 3 works correctly even when IDs are not unique as long as the largest clockwise and counterclockwise IDs are different. To that goal, we need to re-analyze Algorithm 1 in such case, which we do in the next two technical lemmas.

Lemma 4.3.

Corollary 3.15 still holds if nodes run Algorithm 1 with non-unique IDs. This includes the case in which multiple nodes v𝑣vitalic_v have 𝖨𝖣v=𝖨𝖣maxsubscript𝖨𝖣𝑣subscript𝖨𝖣\mathsf{ID}_{v}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT.

Note that Lemma 4.3 is about Algorithm 1, the implicit main subroutine of Algorithm 3, not Algorithm 3 itself. Most elements of the proof of Corollary 3.15 make no reference to the node of largest 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_ID. Most importantly, the invariants of Lemma 3.1 (that σ𝖼𝗐[v]=ρ𝖼𝗐[v]+1subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣1\sigma_{\mathsf{cw}}[v]=\rho_{\mathsf{cw}}[v]+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] + 1 while ρ𝖼𝗐[v]<𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, and σ𝖼𝗐[v]=ρ𝖼𝗐[v]subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\sigma_{\mathsf{cw}}[v]=\rho_{\mathsf{cw}}[v]italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] once ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT) are consequences of how each node reacts to the pulses it receives, and changing the distribution of 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_IDs does not change that. Lemma 3.3, however, makes an explicit reference to a node of largest 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_ID, which requires us to change the argument somewhat. Lemma 4.4, which we shall now prove, generalizes Lemma 3.3 to the setting with non-unique 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_IDs.

Lemma 4.4.

Consider the set of nodes of largest 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_ID, Vmax={v:𝖨𝖣v=𝖨𝖣max}subscript𝑉conditional-set𝑣subscript𝖨𝖣𝑣subscript𝖨𝖣V_{\max}=\{v:\mathsf{ID}_{v}=\mathsf{ID}_{\max}\}italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT = { italic_v : sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT }. In Algorithm 1, if ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT for all vVmax𝑣subscript𝑉v\in V_{\max}italic_v ∈ italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT at some point, then ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds for every node v𝑣vitalic_v at this point. That is, one of the nodes in Vmaxsubscript𝑉V_{\max}italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT is the last node to satisfy ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT.

Proof 4.5.

Let m=|Vmax|𝑚subscript𝑉m=\lvert V_{\max}\rvertitalic_m = | italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT | be the number of nodes that hold 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Denote these nodes v1,,vmsubscript𝑣1subscript𝑣𝑚v_{1},\ldots,v_{m}italic_v start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_v start_POSTSUBSCRIPT italic_m end_POSTSUBSCRIPT, ordered clockwise from an arbitrary one of them. Let us identify vm+1=v1subscript𝑣𝑚1subscript𝑣1v_{m+1}=v_{1}italic_v start_POSTSUBSCRIPT italic_m + 1 end_POSTSUBSCRIPT = italic_v start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT for ease of notation. For each i[m]𝑖delimited-[]𝑚i\in[m]italic_i ∈ [ italic_m ], let ki{0,,n1}subscript𝑘𝑖0𝑛1k_{i}\in\{0,\ldots,n-1\}italic_k start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ∈ { 0 , … , italic_n - 1 } be the number of consecutive nodes with 𝖨𝖣v<𝖨𝖣maxsubscript𝖨𝖣𝑣subscript𝖨𝖣\mathsf{ID}_{v}<\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT < sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT preceding visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT in the ring. For each j[ki]𝑗delimited-[]subscript𝑘𝑖j\in[k_{i}]italic_j ∈ [ italic_k start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ], let xi,jsubscript𝑥𝑖𝑗x_{i,j}italic_x start_POSTSUBSCRIPT italic_i , italic_j end_POSTSUBSCRIPT be the node j𝑗jitalic_j counterclockwise hops from visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT in the ring. See Figure 2 for an illustration.

We show that if ρ𝖼𝗐[vi]𝖨𝖣visubscript𝜌𝖼𝗐delimited-[]subscript𝑣𝑖subscript𝖨𝖣subscript𝑣𝑖\rho_{\mathsf{cw}}[v_{i}]\geq\mathsf{ID}_{v_{i}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT end_POSTSUBSCRIPT holds at visubscript𝑣𝑖v_{i}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT, then it also holds at all xi,jsubscript𝑥𝑖𝑗x_{i,j}italic_x start_POSTSUBSCRIPT italic_i , italic_j end_POSTSUBSCRIPT, j[ki]𝑗delimited-[]subscript𝑘𝑖j\in[k_{i}]italic_j ∈ [ italic_k start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ]. Since every node vVmax𝑣subscript𝑉v\not\in V_{\max}italic_v ∉ italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT has a node of largest 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_ID in its clockwise direction later in the ring, this implies that when ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT holds at all viVmaxsubscript𝑣𝑖subscript𝑉v_{i}\in V_{\max}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ∈ italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, it also holds at every node vV𝑣𝑉v\in Vitalic_v ∈ italic_V.

Refer to caption
Figure 2: The naming of nodes between nodes of largest 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_ID in the proof of Lemma 4.4.

Consider viVmaxsubscript𝑣𝑖subscript𝑉v_{i}\in V_{\max}italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ∈ italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT s.t. ρ𝖼𝗐[vi]𝖨𝖣vi=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]subscript𝑣𝑖subscript𝖨𝖣subscript𝑣𝑖subscript𝖨𝖣\rho_{\mathsf{cw}}[v_{i}]\geq\mathsf{ID}_{v_{i}}=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Suppose ki>0subscript𝑘𝑖0k_{i}>0italic_k start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT > 0, as otherwise the result is trivial. Let xi,0=visubscript𝑥𝑖0subscript𝑣𝑖x_{i,0}=v_{i}italic_x start_POSTSUBSCRIPT italic_i , 0 end_POSTSUBSCRIPT = italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT. For each j[0,ki)𝑗0subscript𝑘𝑖j\in[0,k_{i})italic_j ∈ [ 0 , italic_k start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ), we show that ρ𝖼𝗐[xi,j]𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖𝑗subscript𝖨𝖣\rho_{\mathsf{cw}}[x_{i,j}]\geq\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT implies ρ𝖼𝗐[xi,j+1]𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖𝑗1subscript𝖨𝖣\rho_{\mathsf{cw}}[x_{i,j+1}]\geq\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j + 1 end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. As the base case ρ𝖼𝗐[xi,0]=ρ𝖼𝗐[vi]𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖0subscript𝜌𝖼𝗐delimited-[]subscript𝑣𝑖subscript𝖨𝖣\rho_{\mathsf{cw}}[x_{i,0}]=\rho_{\mathsf{cw}}[v_{i}]\geq\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , 0 end_POSTSUBSCRIPT ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT holds, we get our result by induction.

Let j[0,ki)𝑗0subscript𝑘𝑖j\in[0,k_{i})italic_j ∈ [ 0 , italic_k start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ) and suppose ρ𝖼𝗐[xi,j]𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖𝑗subscript𝖨𝖣\rho_{\mathsf{cw}}[x_{i,j}]\geq\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Since ρ𝖼𝗐[xi,j]σ𝖼𝗐[xi,j+1]subscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖𝑗subscript𝜎𝖼𝗐delimited-[]subscript𝑥𝑖𝑗1\rho_{\mathsf{cw}}[x_{i,j}]\leq\sigma_{\mathsf{cw}}[x_{i,j+1}]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j end_POSTSUBSCRIPT ] ≤ italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j + 1 end_POSTSUBSCRIPT ], we have that σ𝖼𝗐[xi,j+1]𝖨𝖣maxsubscript𝜎𝖼𝗐delimited-[]subscript𝑥𝑖𝑗1subscript𝖨𝖣\sigma_{\mathsf{cw}}[x_{i,j+1}]\geq\mathsf{ID}_{\max}italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j + 1 end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Since 𝖨𝖣max>𝖨𝖣xi,j+1subscript𝖨𝖣subscript𝖨𝖣subscript𝑥𝑖𝑗1\mathsf{ID}_{\max}>\mathsf{ID}_{x_{i,j+1}}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT > sansserif_ID start_POSTSUBSCRIPT italic_x start_POSTSUBSCRIPT italic_i , italic_j + 1 end_POSTSUBSCRIPT end_POSTSUBSCRIPT, by Lemma 3.1, it needs to hold that ρ𝖼𝗐[xi,j+1]=σ𝖼𝗐[xi,j+1]subscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖𝑗1subscript𝜎𝖼𝗐delimited-[]subscript𝑥𝑖𝑗1\rho_{\mathsf{cw}}[x_{i,j+1}]=\sigma_{\mathsf{cw}}[x_{i,j+1}]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j + 1 end_POSTSUBSCRIPT ] = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j + 1 end_POSTSUBSCRIPT ]. Therefore, ρ𝖼𝗐[xi,j+1]𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]subscript𝑥𝑖𝑗1subscript𝖨𝖣\rho_{\mathsf{cw}}[x_{i,j+1}]\geq\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_x start_POSTSUBSCRIPT italic_i , italic_j + 1 end_POSTSUBSCRIPT ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT.

Equipped with Lemma 4.4, the proof of Lemma 4.3 follows quite naturally.

Proof 4.6 (Proof of Lemma 4.3).

Let us review the proof of Corollary 3.15, and see which elements of it could be affected by multiple nodes having the same 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_ID. Let Vmax={v:𝖨𝖣v=𝖨𝖣max}subscript𝑉conditional-set𝑣subscript𝖨𝖣𝑣subscript𝖨𝖣V_{\max}=\{v:\mathsf{ID}_{v}=\mathsf{ID}_{\max}\}italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT = { italic_v : sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT } be the set of nodes of largest 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_ID.

As already stated, the invariants of Lemma 3.1 still hold, and arguments relying on Lemma 3.3 must be amended to rely on Lemma 4.4 instead. Lemmas 3.7, 3.5 and 3.9, about how the network is in quiescence if and only if each node v𝑣vitalic_v has received (and, by Lemma 3.1, also sent) at least 𝖨𝖣vsubscript𝖨𝖣𝑣\mathsf{ID}_{v}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT pulses, are immediate consequences of Lemma 3.1, and hence still hold.

We now get to Lemmas 3.11 and 3.13, which are two lemmas from which Corollary 3.15 follows most directly. Lemma 3.11 shows equivalences between three properties: quiescence, that ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT at each v𝑣vitalic_v, and that ρ𝖼𝗐[v]=σ𝖼𝗐[v]=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]=\sigma_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT at each v𝑣vitalic_v. Again, the arguments still hold if 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_IDs are not unique: the connection between quiescence and all nodes satisfying ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT was shown in Corollary 3.9; while some node vVmax𝑣subscript𝑉v\in V_{\max}italic_v ∈ italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT has received less than 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses, the network is not in quiescence; for all nodes in Vmaxsubscript𝑉V_{\max}italic_V start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT to have received 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses, other nodes in the network need to have sent this many pulses, which implies they have also received 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses.

Lemma 3.13 shows that the network cannot permanently remain in a state in which some nodes have ρ𝖼𝗐[v]<𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. The argument again does not rely on the uniqueness of the 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_IDs, and only uses that if some non-empty set B𝐵Bitalic_B of nodes satisfies ρ𝖼𝗐[v]<𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT for each vB𝑣𝐵v\in Bitalic_v ∈ italic_B, then since for those nodes σ𝖼𝗐[v]=ρ𝖼𝗐[v]+1subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣1\sigma_{\mathsf{cw}}[v]=\rho_{\mathsf{cw}}[v]+1italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] + 1 (Lemma 3.1) the network has pulses still in transit. These pulses must eventually reach nodes in B𝐵Bitalic_B, increase the number of received pulses ρ𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT of nodes in it, and eventually to the point that for a node in B𝐵Bitalic_B, ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT.

Put together, the whole argument still holds with non-unique 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_IDs.

The proof of our second main theorem is a corollary of the above.

Proof 4.7 (Proof of Theorem 1.2).

Let us modify Algorithm 3 as follows:

  • In 2, we set as 𝖨𝖣𝖨𝖣\mathsf{ID}sansserif_IDs 𝖨𝖣v(1)𝖨𝖣v+1superscriptsubscript𝖨𝖣𝑣1subscript𝖨𝖣𝑣1\mathsf{ID}_{v}^{(1)}\leftarrow\mathsf{ID}_{v}+1sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 1 ) end_POSTSUPERSCRIPT ← sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT + 1, and 𝖨𝖣v(0)𝖨𝖣vsuperscriptsubscript𝖨𝖣𝑣0subscript𝖨𝖣𝑣\mathsf{ID}_{v}^{(0)}\leftarrow\mathsf{ID}_{v}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT ( 0 ) end_POSTSUPERSCRIPT ← sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT.

Similar to the argument in the proof of Proposition 4.1, this amounts to running two parallel instances of Algorithm 1 over each channel. As in that proof, consider the maximal clockwise and counterclockwise IDs, maxv𝖨𝖣vcw=𝖨𝖣max+1subscript𝑣superscriptsubscript𝖨𝖣𝑣cwsubscript𝖨𝖣1\max_{v}\mathsf{ID}_{v}^{\mathrm{cw}}=\mathsf{ID}_{\max}+1roman_max start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_cw end_POSTSUPERSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 and maxv𝖨𝖣vccw=𝖨𝖣maxsubscript𝑣superscriptsubscript𝖨𝖣𝑣ccwsubscript𝖨𝖣\max_{v}\mathsf{ID}_{v}^{\mathrm{ccw}}=\mathsf{ID}_{\max}roman_max start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT start_POSTSUPERSCRIPT roman_ccw end_POSTSUPERSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. From Lemma 4.3, we know that the number of clockwise pulses sent and received by each node eventually stabilizes at 𝖨𝖣max+1subscript𝖨𝖣1\mathsf{ID}_{\max}+1sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1, and similarly stabilizes at 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT for the counterclockwise direction. This results in a single leader being elected and a consistent orientation as before. The upper bound of n(2𝖨𝖣max+1)𝑛2subscript𝖨𝖣1n(2\mathsf{ID}_{\max}+1)italic_n ( 2 sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ) follows from n(𝖨𝖣max+1)𝑛subscript𝖨𝖣1n(\mathsf{ID}_{\max}+1)italic_n ( sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ) pulses being exchanged in one direction, and n𝖨𝖣max𝑛subscript𝖨𝖣n\cdot\mathsf{ID}_{\max}italic_n ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT in the other.

5 Lower Bound On Message Complexity in Content-Oblivious Rings

In this section, we show that the dependency of the message complexity of our algorithms on 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT is natural and inevitable by providing a lower bound showing that the number of pulses sent increases indefinitely with the number of available IDs.

Theorem 5.1.

Let k𝑘kitalic_k and n𝑛nitalic_n be arbitrary positive integers, kn𝑘𝑛k\geq nitalic_k ≥ italic_n. If k𝑘kitalic_k distinct IDs are assignable to the n𝑛nitalic_n nodes of the ring, at least nlog(k/n)𝑛𝑘𝑛n\lfloor\log(k/n)\rflooritalic_n ⌊ roman_log ( italic_k / italic_n ) ⌋ pulses are sent by any leader election algorithm for some assignment of IDs. In particular, an unbounded number of pulses is sent for an infinite supply of IDs even on rings with just a single node.

The proof of this theorem makes use of the following definition.

Definition 5.2 (Solitude pattern).

Consider a ring with a single node (n=1𝑛1n=1italic_n = 1), and fix a specific algorithm. Assume a scheduler that delivers pulses one by one, kee** the order in which they were sent (breaking ties by prioritizing 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW pulses). Define the solitude pattern as the sequence of incoming pulses observed by the node, encoded as a binary string where 00 and 1111 encode 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW and 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulses, respectively. We denote the solitude pattern of a node with 𝖨𝖣=i𝖨𝖣𝑖\mathsf{ID}=isansserif_ID = italic_i by pisubscript𝑝𝑖p_{i}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT.

Besides this crucial definition, we make use of the following lemma telling us that each ID has its own, unique solitude pattern. Essentially, the proof relies on matching all possible pairs of IDs against each other in a ring of two nodes. If any two IDs had the same solitude pattern, they would send and receive pulses in this ring (n=2𝑛2n=2italic_n = 2) exactly as they would in solitude (n=1𝑛1n=1italic_n = 1). Thus, in one of these execution they give an invalid output.

Lemma 5.3.

For any uniform content-oblivious leader election algorithm, each solitude pattern is unique. In other words, for any pair of distinct IDs ij𝑖𝑗i\neq jitalic_i ≠ italic_j, we have pipjsubscript𝑝𝑖subscript𝑝𝑗p_{i}\neq p_{j}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ≠ italic_p start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT.

Proof 5.4.

Fix a content-oblivious leader election algorithm on uniform rings. Seeking contradiction, assume that two nodes with distinct IDs, ij𝑖𝑗i\neq jitalic_i ≠ italic_j, have the same solitude pattern, pi=pjsubscript𝑝𝑖subscript𝑝𝑗p_{i}=p_{j}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_p start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT. Note that each of these nodes outputs 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader when run in isolation (n=1𝑛1n=1italic_n = 1).

Consider a ring with n=2𝑛2n=2italic_n = 2 nodes, which are assigned the IDs i𝑖iitalic_i and j𝑗jitalic_j, respectively. Assume a scheduler behaving the same way as in the definition of a solitude pattern for each node individually. That is, pulses arrive one by one in the order they were sent out. Moreover, we assume that the same delay is applied to all pulses. Since the two nodes’ solitude patterns are identical, and the scheduler maintains order, each node will receive (and thus generate) exactly its solitude pattern. Indeed, since pi=pjsubscript𝑝𝑖subscript𝑝𝑗p_{i}=p_{j}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_p start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT, both nodes send their first pulse in the same direction, and hence both receive it from the same direction as they would when alone and then send their next pulse accordingly; thus both receive and send exactly the pattern pi=pjsubscript𝑝𝑖subscript𝑝𝑗p_{i}=p_{j}italic_p start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = italic_p start_POSTSUBSCRIPT italic_j end_POSTSUBSCRIPT. This means that both nodes output 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader as they must in their solitude situation. This contradicts the guarantees of the leader election task.

Having established that each ID has its own unique solitude pattern, a lower bound arises from properties of binary strings, namely the length required to avoid repeating patterns. We begin with the following simple property following from the pigeon-hole principle.

Lemma 5.5.

For any s,n1𝑠𝑛1s,n\geq 1italic_s , italic_n ≥ 1, any set of n2s𝑛superscript2𝑠n2^{s}italic_n 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT distinct binary strings contains n𝑛nitalic_n strings sharing a common prefix of length at least s𝑠sitalic_s.

Proof 5.6.

Let s𝑠sitalic_s and n𝑛nitalic_n be positive integers. There are only 2s1superscript2𝑠12^{s}-12 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT - 1 distinct binary strings shorter than s𝑠sitalic_s. Therefore, in a set of n2s𝑛superscript2𝑠n2^{s}italic_n 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT distinct binary strings at least n2s2s1=(n1)2s+1𝑛superscript2𝑠superscript2𝑠1𝑛1superscript2𝑠1n2^{s}-2^{s}-1=(n-1)2^{s}+1italic_n 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT - 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT - 1 = ( italic_n - 1 ) 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT + 1 of them have length at least s𝑠sitalic_s, implying that they contain a prefix string of length s𝑠sitalic_s. There are only 2ssuperscript2𝑠2^{s}2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT distinct binary prefixes of length s𝑠sitalic_s, thus the pigeon-hole principle implies that at least one prefix of length s𝑠sitalic_s is shared by at least ((n1)2s+1)/2s=n1+2s=n𝑛1superscript2𝑠1superscript2𝑠𝑛1superscript2𝑠𝑛\lceil((n-1)2^{s}+1)/2^{s}\rceil=\lceil n-1+2^{-s}\rceil=n⌈ ( ( italic_n - 1 ) 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT + 1 ) / 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT ⌉ = ⌈ italic_n - 1 + 2 start_POSTSUPERSCRIPT - italic_s end_POSTSUPERSCRIPT ⌉ = italic_n of the strings in the set.

After deducing another corollary, we are ready to prove the lower bound of Theorem 5.1.

Corollary 5.7.

For any integers kn1𝑘𝑛1k\geq n\geq 1italic_k ≥ italic_n ≥ 1, any set of k𝑘kitalic_k distinct binary strings contains n𝑛nitalic_n strings sharing a common prefix of length at least log(k/n)𝑘𝑛\lfloor\log(k/n)\rfloor⌊ roman_log ( italic_k / italic_n ) ⌋.

Proof 5.8.

Apply Lemma 5.5 with the given n𝑛nitalic_n and s=log(k/n)𝑠𝑘𝑛s=\lfloor\log(k/n)\rflooritalic_s = ⌊ roman_log ( italic_k / italic_n ) ⌋. Note that the given set is large enough since n2sn2log(k/n)=n(k/n)=k𝑛superscript2𝑠𝑛superscript2𝑘𝑛𝑛𝑘𝑛𝑘n2^{s}\leq n2^{\log(k/n)}=n(k/n)=kitalic_n 2 start_POSTSUPERSCRIPT italic_s end_POSTSUPERSCRIPT ≤ italic_n 2 start_POSTSUPERSCRIPT roman_log ( italic_k / italic_n ) end_POSTSUPERSCRIPT = italic_n ( italic_k / italic_n ) = italic_k.

Proof 5.9 (Proof of Theorem 5.1).

Assume that we have a uniform leader election algorithm, a ring with n𝑛nitalic_n nodes, and at least k𝑘kitalic_k assignable IDs for any positive integers kn𝑘𝑛k\geq nitalic_k ≥ italic_n. Due to Lemma 5.3 we know that each ID has its own unique solitude pattern, which is just a binary string. By Corollary 5.7, there are at least n𝑛nitalic_n IDs whose solitude patterns share a common prefix of length s=log(k/n)𝑠𝑘𝑛s=\lfloor\log(k/n)\rflooritalic_s = ⌊ roman_log ( italic_k / italic_n ) ⌋. Assume a scheduler that behaves as described in Lemma 5.3, for all n𝑛nitalic_n nodes. It follows that all nodes send and receive pulses in exactly the same way as in their respective solitude situations for the first log(k/n)𝑘𝑛\lfloor\log(k/n)\rfloor⌊ roman_log ( italic_k / italic_n ) ⌋ time steps, sending one pulse in each time step. Consequently, at least ns=nlog(k/n)𝑛𝑠𝑛𝑘𝑛n\cdot s=n\lfloor\log(k/n)\rflooritalic_n ⋅ italic_s = italic_n ⌊ roman_log ( italic_k / italic_n ) ⌋ pulses are sent in total, proving the first part of the theorem. The last statement in the theorem follows for an infinite set of assignable IDs because nlog(k/n)𝑛𝑘𝑛n\lfloor\log(k/n)\rflooritalic_n ⌊ roman_log ( italic_k / italic_n ) ⌋ grows indefinitely with increasing k𝑘kitalic_k, even for n=1𝑛1n=1italic_n = 1.

Theorem 1.3 is then an immediate corollary of the above since the number of distinct IDs is bounded by 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. This lower bound complements the upper bound of Theorem 1.1 and proves that the 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT term is not an artifact of our analysis or algorithm design but, rather, an inherent property of the problem in this setting.

6 Conclusion and Open Questions

As our main result, we have presented a quiescently terminating algorithm for leader election in oriented rings with unique IDs that communicates n(2𝖨𝖣max+1)𝑛2subscript𝖨𝖣1n(2\cdot\mathsf{ID}_{\max}+1)italic_n ( 2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ) pulses. This implies that any content-oblivious computation can be performed on rings without assuming a pre-existing leader. We have also provided a lower bound showing that the message complexity depending on 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT is not a fluke but inherent to the problem.

An immediate candidate for future work is to extend our results from rings to general networks, i.e., to design a content-oblivious leader election algorithm in arbitrary 2-edge connected networks or, alternatively, prove this task impossible. Considering non-oriented rings may be useful towards that goal since there is no sense of direction in general networks. Our content-oblivious leader election for non-oriented rings does not terminate, and we conjecture that this is inherent to the model. It remains as an open task for future work to prove this or find a terminating algorithm.

References

  • [1] Y. Afek and Y. Matias. Elections in anonymous networks. Information and Computation, 113(2):312–330, 1994.
  • [2] Dana Angluin. Local and global properties in networks of processors (extended abstract). In Proceedings of the Twelfth Annual ACM Symposium on Theory of Computing, STOC ’80, pages 82–93, New York, NY, USA, 1980. ACM.
  • [3] Yagel Ashkenazi, Ran Gelles, and Amir Leshem. Noisy bee** networks. Information and Computation, 289(A):104925, 2022.
  • [4] Hagit Attiya and Marc Snir. Better computing on the anonymous ring. Journal of Algorithms, 12(2):204–238, 1991.
  • [5] Hagit Attiya, Marc Snir, and Manfred K. Warmuth. Computing on an anonymous ring. J. ACM, 35(4):845–875, oct 1988.
  • [6] F Thomas Bruss and Colm Art O’cinneide. On the maximum and its uniqueness for geometric random samples. Journal of applied probability, 27(3):598–610, 1990.
  • [7] James E. Burns. A formal model for message passing systems. Technical report, Computer Science Dept., Indiana Univ., Bloomington, Ind., 1980. TR91.
  • [8] Keren Censor-Hillel, Shir Cohen, Ran Gelles, and Gal Sela. Distributed computations in fully-defective networks. Distributed Computing, 36(4):501–528, 2023.
  • [9] Keren Censor-Hillel, Ran Gelles, and Bernhard Haeupler. Making asynchronous distributed computations robust to noise. Distributed Computing, 32(5):405–421, Oct 2019.
  • [10] Ernest Chang and Rosemary Roberts. An improved algorithm for decentralized extrema-finding in circular configurations of processes. Commun. ACM, 22(5):281–283, may 1979.
  • [11] Alejandro Cornejo and Fabian Kuhn. Deploying wireless networks with beeps. In Distributed Computing, 24th International Symposium, DISC 2010, volume 6343 of LNCS, pages 148–162, 2010, Cambridge, MA, USA, September 13–15, 2010. Proceedings, 2010. Springer.
  • [12] Artur Czumaj and Peter Davies. Leader election in multi-hop radio networks. Theoretical Computer Science, 792:2–11, 2019.
  • [13] Peter Davies. Optimal message-passing with noisy beeps. In Proceedings of the 2023 ACM Symposium on Principles of Distributed Computing, PODC, pages 300–309, 2023, Orlando, FL, USA, June 19–23, 2023, 2023. ACM.
  • [14] Danny Dolev, Maria Klawe, and Michael Rodeh. An O(nlogn)𝑂𝑛𝑛O(n\log n)italic_O ( italic_n roman_log italic_n ) unidirectional distributed algorithm for extrema finding in a circle. Journal of Algorithms, 3(3):245–260, 1982.
  • [15] Fabien Dufoulon, Janna Burman, and Joffroy Beauquier. Bee** a deterministic time-optimal leader election. In 32nd International Symposium on Distributed Computing, DISC 2018, volume 121 of LIPIcs, pages 20:1–20:17, New Orleans, LA, USA, October 15–19, 2018, 2018. Schloss Dagstuhl – Leibniz-Zentrum für Informatik.
  • [16] Fabien Dufoulon, Janna Burman, and Joffroy Beauquier. Can uncoordinated beeps tell stories? In PODC ’20: ACM Symposium on Principles of Distributed Computing, pages 408–417, Virtual Event, Italy, August 3-=7, 2020, 2020. ACM.
  • [17] M. El-Ruby, J. Kenevan, R. Carlson, and K. Khalil. A linear algorithm for election in ring configuration networks. In Proceedings of the Twenty-Fourth Annual Hawaii International Conference on System Sciences, volume i, pages 117–123 vol.1, Los Alamitos, CA, USA, 1991. IEEE Computer Society.
  • [18] Michael Feldmann, Andreas Padalkin, Christian Scheideler, and Shlomi Dolev. Coordinating amoebots via reconfigurable circuits. Journal of Computational Biology, 29(4):317–343, 2022.
  • [19] Paola Flocchini, Evangelos Kranakis, Danny Krizanc, Flaminia L. Luccio, and Nicola Santoro. Sorting and election in anonymous asynchronous rings. Journal of Parallel and Distributed Computing, 64(2):254–265, 2004.
  • [20] Klaus-Tycho Förster, Jochen Seidel, and Roger Wattenhofer. Deterministic leader election in multi-hop bee** networks - (extended abstract). In Distributed Computing - 28th International Symposium, DISC’14, volume 8784 of LNCS, pages 212–226, 2014, Austin, TX, USA, October 12–15, 2014. Proceedings, 2014. Springer.
  • [21] Greg N. Frederickson and Nancy A. Lynch. Electing a leader in a synchronous ring. J. ACM, 34(1):98–115, jan 1987.
  • [22] Ran Gelles. Coding for interactive communication: A survey. Foundations and Trends® in Theoretical Computer Science, 13(1–2):1–157, 2017.
  • [23] Mohsen Ghaffari and Bernhard Haeupler. Near optimal leader election in multi-hop radio networks. In SODA’13, pages 748–766, New Orleans, Louisiana, USA, January 6–8, 2013, 2013. SIAM.
  • [24] D. S. Hirschberg and J. B. Sinclair. Decentralized extrema-finding in circular configurations of processors. Commun. ACM, 23(11):627–628, nov 1980.
  • [25] Alon Itai and Michael Rodeh. Symmetry breaking in distributed networks. Information and Computation, 88(1):60–87, 1990.
  • [26] Gérard Le Lann. Distributed systems - towards a formal approach. In Bruce Gilchrist, editor, Information Processing, Proceedings of the 7th IFIP Congress 1977, pages 155–160, Toronto, Canada, August 8–12, 1977, 1977. North-Holland.
  • [27] Gary L. Peterson. An O(nlogn)𝑂𝑛𝑛{O}(n\log n)italic_O ( italic_n roman_log italic_n ) unidirectional algorithm for the circular extrema problem. ACM Trans. Program. Lang. Syst., 4(4):758–762, oct 1982.
  • [28] Nicola Santoro and Peter Widmayer. Distributed function evaluation in the presence of transmission faults. In Tetsuo Asano, Toshihide Ibaraki, Hiroshi Imai, and Takao Nishizeki, editors, Algorithms, International Symposium SIGAL ’90, volume 450 of Lecture Notes in Computer Science, pages 358–367, Tokyo, Japan, August 16–18, 1990, 1990. Springer.
  • [29] Violet Syrotiuk and Jan Pachl. A distributed ring orientation algorithm. In International Workshop on Distributed Algorithms (WDAG’87), pages 332–336. Springer Berlin Heidelberg, 1988.

Appendix

Appendix A Deferred Proofs Regarding Achieving Quiescent Termination

In this section, we provide an analysis of Algorithm 2 showing that it satisfies the conditions of Theorem 1.1, proving the theorem.

See 1.1

We begin with the following lemma, which asserts certain conditions on the number of pulses received over each channel. The lemma suggests that the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW instance cannot advance beyond the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW instance. We use 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence to denote the less general state of quiescence with respect to the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel only, that is, the network is in 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence if it no longer contains 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW pulses. The network then reaches quiescence if both 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence and 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW-quiescence are achieved, where the latter is defined analogously.

Lemma A.1.

As long as 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence has not been reached, ρ𝖼𝖼𝗐[v]ρ𝖼𝗐[v]subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\rho_{\mathsf{ccw}}[v]\leq\rho_{\mathsf{cw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] ≤ italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] holds for every node v𝑣vitalic_v, with equality only when ρ𝖼𝗐[v]=0subscript𝜌𝖼𝗐delimited-[]𝑣0\rho_{\mathsf{cw}}[v]=0italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = 0.

Proof A.2.

First, note that if a node v𝑣vitalic_v has ρ𝖼𝗐[v]<𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]<\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, then it has not yet participated in the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW algorithm, and ρ𝖼𝖼𝗐[v]=0subscript𝜌𝖼𝖼𝗐delimited-[]𝑣0\rho_{\mathsf{ccw}}[v]=0italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = 0. Since ρ𝖼𝗐[v]0subscript𝜌𝖼𝗐delimited-[]𝑣0\rho_{\mathsf{cw}}[v]\geq 0italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ 0, the statement holds for v𝑣vitalic_v. Further, this is always the case at the node \ellroman_ℓ for which 𝖨𝖣=𝖨𝖣maxsubscript𝖨𝖣subscript𝖨𝖣\mathsf{ID}_{\ell}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Indeed, since Algorithm 2 consists of two independent instances of Algorithm 1, one over each channel, if we restrict the discussion to the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel, the execution of Algorithm 2 is identical to an execution of Algorithm 1, and we may invoke the properties proven in Section 3.1. Then, by Lemma 3.11, while 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence has not occurred, we have ρ𝖼𝗐[]<𝖨𝖣max=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]<\mathsf{ID}_{\max}=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] < sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT, and the statement holds for \ellroman_ℓ.

We next consider the other nodes and show the statement holds also when ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. Fix an arbitrary node v𝑣v\neq\ellitalic_v ≠ roman_ℓ with ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. By Item 2, ρ𝖼𝗐[v]=σ𝖼𝗐[v]subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝗐delimited-[]𝑣\rho_{\mathsf{cw}}[v]=\sigma_{\mathsf{cw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ]. Now, let u1,,uksubscript𝑢1subscript𝑢𝑘u_{1},\ldots,u_{k}italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_u start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT be 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW successors of v𝑣vitalic_v such that uksubscript𝑢𝑘u_{k}italic_u start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT is the closest node to v𝑣vitalic_v with ρ𝖼𝗐[uk]<𝖨𝖣uksubscript𝜌𝖼𝗐delimited-[]subscript𝑢𝑘subscript𝖨𝖣subscript𝑢𝑘\rho_{\mathsf{cw}}[u_{k}]<\mathsf{ID}_{u_{k}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] < sansserif_ID start_POSTSUBSCRIPT italic_u start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT end_POSTSUBSCRIPT. Since v𝑣v\neq\ellitalic_v ≠ roman_ℓ, such a node uksubscript𝑢𝑘u_{k}italic_u start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT exists.

Since ρ𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT is monotonically non-decreasing, once the condition ρ𝖼𝗐𝖨𝖣vsubscript𝜌𝖼𝗐subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT on 10 is met, it is always met for all future iterations. As 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulses are buffered, i.e., never lost, and because the nodes {v,u1,,uk1}𝑣subscript𝑢1subscript𝑢𝑘1\{v,u_{1},\ldots,u_{k-1}\}{ italic_v , italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_u start_POSTSUBSCRIPT italic_k - 1 end_POSTSUBSCRIPT } meet the condition on 10, they can be viewed as running Algorithm 1 over the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel. As such, all the properties proven in the previous section hold for the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW instance as well 444The only difference is that nodes start the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW instance in different times, while for the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW instance we assumed all nodes start at the same time. However, this is not an issue. Pulses on the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel remain in the queue of a node that has not started yet. That is, the situation is equivalent to the case where all the nodes start at a later time and pulses are being delayed accordingly., and we may apply Lemma 3.1 over the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel.

Consequently, σ𝖼𝖼𝗐[ui]ρ𝖼𝖼𝗐[ui]+1subscript𝜎𝖼𝖼𝗐delimited-[]subscript𝑢𝑖subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝑢𝑖1\sigma_{\mathsf{ccw}}[u_{i}]\leq\rho_{\mathsf{ccw}}[u_{i}]+1italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] ≤ italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] + 1 for i<k𝑖𝑘i<kitalic_i < italic_k. Moreover, ρ𝖼𝖼𝗐[ui]σ𝖼𝖼𝗐[ui+1]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝑢𝑖subscript𝜎𝖼𝖼𝗐delimited-[]subscript𝑢𝑖1\rho_{\mathsf{ccw}}[u_{i}]\leq\sigma_{\mathsf{ccw}}[u_{i+1}]italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] ≤ italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ] for i<k𝑖𝑘i<kitalic_i < italic_k, and ρ𝖼𝖼𝗐[v]σ𝖼𝖼𝗐[u1]subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝖼𝗐delimited-[]subscript𝑢1\rho_{\mathsf{ccw}}[v]\leq\sigma_{\mathsf{ccw}}[u_{1}]italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] ≤ italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ]. Combining these inequalities yields

ρ𝖼𝖼𝗐[v]σ𝖼𝖼𝗐[uk]+k1.subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝖼𝗐delimited-[]subscript𝑢𝑘𝑘1.\rho_{\mathsf{ccw}}[v]\leq\sigma_{\mathsf{ccw}}[u_{k}]+k-1\text{.}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] ≤ italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] + italic_k - 1 .

Since σ𝖼𝖼𝗐[uk]=0subscript𝜎𝖼𝖼𝗐delimited-[]subscript𝑢𝑘0\sigma_{\mathsf{ccw}}[u_{k}]=0italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_k end_POSTSUBSCRIPT ] = 0, we get ρ𝖼𝖼𝗐[v]k1subscript𝜌𝖼𝖼𝗐delimited-[]𝑣𝑘1\rho_{\mathsf{ccw}}[v]\leq k-1italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] ≤ italic_k - 1. Let u𝑢uitalic_u be the node with the largest ID out of {v,u1,,uk1}𝑣subscript𝑢1subscript𝑢𝑘1\{v,u_{1},\ldots,u_{k-1}\}{ italic_v , italic_u start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_u start_POSTSUBSCRIPT italic_k - 1 end_POSTSUBSCRIPT }. Since we have k𝑘kitalic_k nodes, at least one must have an ID at least k𝑘kitalic_k by the uniqueness of IDs, that is, 𝖨𝖣u>k1subscript𝖨𝖣𝑢𝑘1\mathsf{ID}_{u}>k-1sansserif_ID start_POSTSUBSCRIPT italic_u end_POSTSUBSCRIPT > italic_k - 1.

If u=v𝑢𝑣u=vitalic_u = italic_v, then we have ρ𝖼𝖼𝗐[v]<𝖨𝖣vρ𝖼𝗐[v]subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\rho_{\mathsf{ccw}}[v]<\mathsf{ID}_{v}\leq\rho_{\mathsf{cw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] < sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT ≤ italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ]. On the other hand, if uv𝑢𝑣u\neq vitalic_u ≠ italic_v, then u=uk𝑢subscript𝑢superscript𝑘u=u_{k^{\prime}}italic_u = italic_u start_POSTSUBSCRIPT italic_k start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT for some k<ksuperscript𝑘𝑘k^{\prime}<kitalic_k start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT < italic_k. Using ρ𝖼𝗐[ui+1]σ𝖼𝗐[ui]subscript𝜌𝖼𝗐delimited-[]subscript𝑢𝑖1subscript𝜎𝖼𝗐delimited-[]subscript𝑢𝑖\rho_{\mathsf{cw}}[u_{i+1}]\leq\sigma_{\mathsf{cw}}[u_{i}]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i + 1 end_POSTSUBSCRIPT ] ≤ italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] for i<k𝑖superscript𝑘i<k^{\prime}italic_i < italic_k start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT and σ𝖼𝗐[ui]=ρ𝖼𝗐[ui]subscript𝜎𝖼𝗐delimited-[]subscript𝑢𝑖subscript𝜌𝖼𝗐delimited-[]subscript𝑢𝑖\sigma_{\mathsf{cw}}[u_{i}]=\rho_{\mathsf{cw}}[u_{i}]italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ] yields

ρ𝖼𝖼𝗐[v]k1<𝖨𝖣ukρ𝖼𝗐[uk]σ𝖼𝗐[uk1]=ρ𝖼𝗐[uk1]σ𝖼𝗐[v]=ρ𝖼𝗐[v].subscript𝜌𝖼𝖼𝗐delimited-[]𝑣𝑘1subscript𝖨𝖣subscript𝑢superscript𝑘subscript𝜌𝖼𝗐delimited-[]subscript𝑢superscript𝑘subscript𝜎𝖼𝗐delimited-[]subscript𝑢superscript𝑘1subscript𝜌𝖼𝗐delimited-[]subscript𝑢superscript𝑘1subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\rho_{\mathsf{ccw}}[v]\leq k-1<\mathsf{ID}_{u_{k^{\prime}}}\leq\rho_{\mathsf{% cw}}[u_{k^{\prime}}]\leq\sigma_{\mathsf{cw}}[u_{k^{\prime}-1}]=\rho_{\mathsf{% cw}}[u_{k^{\prime}-1}]\leq\ldots\leq\sigma_{\mathsf{cw}}[v]=\rho_{\mathsf{cw}}% [v].italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] ≤ italic_k - 1 < sansserif_ID start_POSTSUBSCRIPT italic_u start_POSTSUBSCRIPT italic_k start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT end_POSTSUBSCRIPT ≤ italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_k start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT ] ≤ italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_k start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT - 1 end_POSTSUBSCRIPT ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_u start_POSTSUBSCRIPT italic_k start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT - 1 end_POSTSUBSCRIPT ] ≤ … ≤ italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] .

Therefore, in both cases we get ρ𝖼𝖼𝗐[v]<ρ𝖼𝗐[v]subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝗐delimited-[]𝑣\rho_{\mathsf{ccw}}[v]<\rho_{\mathsf{cw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] < italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ], which concludes the proof.

A direct implication of Lemma A.1 is that no node may terminate until the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW phase has concluded since no node may meet the termination condition on 22 and exit the loop.

Corollary A.3.

As long as 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence has not been reached, nodes do not terminate.

Proof A.4.

Initially, every node sends a 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW pulse. By Lemma A.1, until there is 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence, all nodes have ρ𝖼𝖼𝗐ρ𝖼𝗐subscript𝜌𝖼𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{ccw}}\leq\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT ≤ italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT and, hence, cannot terminate in 22.

Now we prove a set of necessary conditions that hold if some v𝑣vitalic_v meets ρ𝖼𝗐[v]=ρ𝖼𝖼𝗐[v]=𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]=\rho_{\mathsf{ccw}}[v]=\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. In particular, v𝑣vitalic_v is necessarily the node with the largest ID, every node is still awake with ρ𝖼𝗐=ρ𝖼𝖼𝗐subscript𝜌𝖼𝗐subscript𝜌𝖼𝖼𝗐\rho_{\mathsf{cw}}=\rho_{\mathsf{ccw}}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT, and there must be quiescence in the network over both channels.

Lemma A.5.

If the event ρ𝖼𝗐[]=ρ𝖼𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\rho_{\mathsf{ccw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT occurs for the first time at a node \ellroman_ℓ, then at that point of time:

  1. 1.

    the network has reached 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence,

  2. 2.

    𝖨𝖣=𝖨𝖣maxsubscript𝖨𝖣subscript𝖨𝖣\mathsf{ID}_{\ell}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT,

  3. 3.

    there are no 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulses in transit, i.e., vσ𝖼𝖼𝗐[v]=vρ𝖼𝖼𝗐[v]subscript𝑣subscript𝜎𝖼𝖼𝗐delimited-[]𝑣subscript𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣\sum_{v}{\sigma_{\mathsf{ccw}}[v]}=\sum_{v}{\rho_{\mathsf{ccw}}[v]}∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = ∑ start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ],

  4. 4.

    v:ρ𝖼𝗐[v]=ρ𝖼𝖼𝗐[v]=𝖨𝖣max:for-all𝑣subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\forall{v}:\rho_{\mathsf{cw}}[v]=\rho_{\mathsf{ccw}}[v]=\mathsf{ID}_{\max}∀ italic_v : italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, and

  5. 5.

    no node has terminated.

Proof A.6.

If there is no quiescence over the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW channel, then no node terminates by Corollary A.3. By Lemma A.1, ρ𝖼𝖼𝗐ρ𝖼𝗐subscript𝜌𝖼𝖼𝗐subscript𝜌𝖼𝗐\rho_{\mathsf{ccw}}\leq\rho_{\mathsf{cw}}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT ≤ italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT holds for all nodes with equality only when ρ𝖼𝖼𝗐=ρ𝖼𝗐=0subscript𝜌𝖼𝖼𝗐subscript𝜌𝖼𝗐0\rho_{\mathsf{ccw}}=\rho_{\mathsf{cw}}=0italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT = 0. Since 𝖨𝖣>0subscript𝖨𝖣0\mathsf{ID}_{\ell}>0sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT > 0, this proves the first implication.

By Lemma 3.11 (applied to the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW instance), 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence implies that all nodes v𝑣vitalic_v satisfy ρ𝖼𝗐[v]=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, and, in particular, due to the uniqueness of 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, only one node \ellroman_ℓ with 𝖨𝖣=𝖨𝖣maxsubscript𝖨𝖣subscript𝖨𝖣\mathsf{ID}_{\ell}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT satisfies ρ𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT at this point, which proves the second implication.

Again, by Lemma 3.11, 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence is equivalent to all nodes v𝑣vitalic_v satisfying ρ𝖼𝗐[v]𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]\geq\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] ≥ sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. Thus, all nodes satisfy the condition on 10 and partake in the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW instance. Now consider the point of time where ρ𝖼𝗐[]=ρ𝖼𝖼𝗐[]=𝖨𝖣=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\rho_{\mathsf{ccw}}[\ell]=\mathsf{ID}_{\ell}=\mathsf{% ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT holds for the first time. As \ellroman_ℓ has not yet executed 19, an execution of Algorithm 2 is identical to an execution of Algorithm 1 over the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel. By Lemma 3.3 (applied to the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW channel at that point of time), the node \ellroman_ℓ is the last node to meet ρ𝖼𝖼𝗐[]𝖨𝖣subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{ccw}}[\ell]\geq\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] ≥ sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT, which is equivalent to v:ρ𝖼𝖼𝗐[v]=σ𝖼𝖼𝗐[v]=𝖨𝖣max:for-all𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\forall{v}:\rho_{\mathsf{ccw}}[v]=\sigma_{\mathsf{ccw}}[v]=\mathsf{ID}_{\max}∀ italic_v : italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = italic_σ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT by Lemma 3.11, yielding the third implication.

By a symmetric argument for the 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW instance, we get v:ρ𝖼𝗐[v]=σ𝖼𝗐[v]=𝖨𝖣max:for-all𝑣subscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜎𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\forall{v}:\rho_{\mathsf{cw}}[v]=\sigma_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}∀ italic_v : italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_σ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, which proves the fourth implication.

Finally, as argued previously, no node terminates until 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence is achieved. Moreover, once there is 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence, then ρ𝖼𝗐[v]=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT remains to hold for all v𝑣vitalic_v by Lemma 3.11. As all nodes are partaking in the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW algorithm at this point, by Corollary 3.17 applied to the 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW instance, ρ𝖼𝖼𝗐[v]𝖨𝖣max=ρ𝖼𝗐[v]subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣subscript𝜌𝖼𝗐delimited-[]𝑣\rho_{\mathsf{ccw}}[v]\leq\mathsf{ID}_{\max}=\rho_{\mathsf{cw}}[v]italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] ≤ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] holds until the event ρ𝖼𝗐[]=ρ𝖼𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\rho_{\mathsf{ccw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT first occurs before \ellroman_ℓ executes 19, so no node has terminated, which concludes the proof.

We now show that the condition ρ𝖼𝗐[]=ρ𝖼𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\rho_{\mathsf{ccw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT in Lemma A.5 must be met at some point by a node \ellroman_ℓ possessing the largest ID, hence establishing the uniqueness of the event we use to drive termination.

Lemma A.7.

Let \ellroman_ℓ be the node with 𝖨𝖣=𝖨𝖣maxsubscript𝖨𝖣subscript𝖨𝖣\mathsf{ID}_{\ell}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Then there is an iteration where the event ρ𝖼𝗐[]=ρ𝖼𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\rho_{\mathsf{ccw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT occurs.

Proof A.8.

By Item 2, the event cannot occur at any other node v𝑣v\neq\ellitalic_v ≠ roman_ℓ. Assume arguably that \ellroman_ℓ never meets this condition, then all nodes are running exactly Algorithm 1 over both channels. Thus, eventually, by Corollary 3.15 applied to both instances, there is some point of time where every node has sent and received exactly 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT pulses over both channels. For node \ellroman_ℓ, we then have that ρ𝖼𝗐[]=ρ𝖼𝖼𝗐[]=𝖨𝖣max=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\rho_{\mathsf{ccw}}[\ell]=\mathsf{ID}_{\max}=\mathsf{% ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT occurs, a contradiction.

With the above, we can now conclude the proof of Theorem 1.1.

Proof A.9 (Proof of Theorem 1.1).

Assume an oriented ring of n𝑛nitalic_n nodes with unique IDs, where each node executes Algorithm 2. Let \ellroman_ℓ be the node with the largest ID. We claim that all nodes terminate at some point with exactly one node, \ellroman_ℓ, outputting 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader while all other nodes output 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader.

By Lemma A.7, \ellroman_ℓ meets the condition ρ𝖼𝗐[]=𝖨𝖣=ρ𝖼𝖼𝗐[]subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣subscript𝜌𝖼𝖼𝗐delimited-[]\rho_{\mathsf{cw}}[\ell]=\mathsf{ID}_{\ell}=\rho_{\mathsf{ccw}}[\ell]italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] at some iteration, and, due to Item 2, no other node does. Consider the first such iteration. By Item 5, no node has terminated prior to that. Additionally, ρ𝖼𝗐[v]=ρ𝖼𝖼𝗐[v]=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]=\rho_{\mathsf{ccw}}[v]=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT holds for all v𝑣vitalic_v due to Item 4. Thus, exactly one node, \ellroman_ℓ, still satisfies ρ𝖼𝗐[]=𝖨𝖣max=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝖨𝖣subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\mathsf{ID}_{\max}=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT and has a state of 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader while every other node v𝑣v\neq\ellitalic_v ≠ roman_ℓ has ρ𝖼𝗐[v]=𝖨𝖣max>𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}>\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT > sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT and a state of 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader. By Item 1, the network is in 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW-quiescence, and no more 𝖢𝖶𝖢𝖶\mathsf{CW}sansserif_CW pulses are sent or received, so those states are final.

It remains to show that all nodes terminate and that when they do so, the network is in quiescence (no pulses still in transit, i.e., a quiescent termination).

By Item 3, no 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulses are in transit when the event ρ𝖼𝗐[]=ρ𝖼𝖼𝗐[]=𝖨𝖣subscript𝜌𝖼𝗐delimited-[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝖨𝖣\rho_{\mathsf{cw}}[\ell]=\rho_{\mathsf{ccw}}[\ell]=\mathsf{ID}_{\ell}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] = sansserif_ID start_POSTSUBSCRIPT roman_ℓ end_POSTSUBSCRIPT occurs firstly. Once \ellroman_ℓ executes 19 during that iteration, there is exactly one 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulse in transit. Therefore, every node v𝑣v\neq\ellitalic_v ≠ roman_ℓ, having ρ𝖼𝗐[v]=ρ𝖼𝖼𝗐[v]=𝖨𝖣max>𝖨𝖣vsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣subscript𝖨𝖣𝑣\rho_{\mathsf{cw}}[v]=\rho_{\mathsf{ccw}}[v]=\mathsf{ID}_{\max}>\mathsf{ID}_{v}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT > sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, receives this 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulse, relays it, and then meets the termination condition on 22 and outputs 𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋𝖭𝗈𝗇-𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Non\textsf{-}Leader}sansserif_Non - sansserif_Leader correctly. Finally, due to 21, node \ellroman_ℓ has been waiting on a 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW pulse, which it then receives and consumes, reaching 𝖢𝖢𝖶𝖢𝖢𝖶\mathsf{CCW}sansserif_CCW-quiescence. The node \ellroman_ℓ then meets the condition ρ𝖼𝖼𝗐[]>ρ𝖼𝗐[]subscript𝜌𝖼𝖼𝗐delimited-[]subscript𝜌𝖼𝗐delimited-[]\rho_{\mathsf{ccw}}[\ell]>\rho_{\mathsf{cw}}[\ell]italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ roman_ℓ ] > italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ roman_ℓ ] and terminates with the correct output of 𝖫𝖾𝖺𝖽𝖾𝗋𝖫𝖾𝖺𝖽𝖾𝗋\mathsf{Leader}sansserif_Leader. As quiescence has been reached over both channels, the algorithm terminates quiescently and correctly elects a leader.

We finally describe the complexity of the algorithm. By termination, every node v𝑣vitalic_v in the algorithm has ρ𝖼𝗐[v]=𝖨𝖣maxsubscript𝜌𝖼𝗐delimited-[]𝑣subscript𝖨𝖣\rho_{\mathsf{cw}}[v]=\mathsf{ID}_{\max}italic_ρ start_POSTSUBSCRIPT sansserif_cw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT and ρ𝖼𝖼𝗐[v]=𝖨𝖣max+1subscript𝜌𝖼𝖼𝗐delimited-[]𝑣subscript𝖨𝖣1\rho_{\mathsf{ccw}}[v]=\mathsf{ID}_{\max}+1italic_ρ start_POSTSUBSCRIPT sansserif_ccw end_POSTSUBSCRIPT [ italic_v ] = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1. Consequently, the overall complexity is n(𝖨𝖣max+1)+n𝖨𝖣max=n(2𝖨𝖣max+1)𝑛subscript𝖨𝖣1𝑛subscript𝖨𝖣𝑛2subscript𝖨𝖣1n\cdot({\mathsf{ID}_{\max}+1})+n\cdot\mathsf{ID}_{\max}=n(2\cdot\mathsf{ID}_{% \max}+1)italic_n ⋅ ( sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ) + italic_n ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT = italic_n ( 2 ⋅ sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT + 1 ).

Appendix B Anonymous Rings

In this section, we consider the setting where a ring consists of n𝑛nitalic_n identical nodes, each with access to an independent source of randomness. We call such a ring anonymous. As is standard in the literature about randomized algorithms, we aim to solve our computational task with high probability, defined as bounding the probability of failure by an arbitrary inverse power of n𝑛nitalic_n, the size of the network. That is, we present an algorithm parameterized by a value c>0𝑐0c>0italic_c > 0, such that for any n𝑛nitalic_n, the algorithm correctly elects a leader in n𝑛nitalic_n-sized rings with probability at least 1O(nc)1𝑂superscript𝑛𝑐1-O(n^{-c})1 - italic_O ( italic_n start_POSTSUPERSCRIPT - italic_c end_POSTSUPERSCRIPT ). Our algorithm also correctly orients a non-oriented ring with high probability.

As alluded to in the main text, electing a leader with quiescent termination is impossible in the context of this section, even if we relax the objective to only succeed with some arbitrary small constant probability. This follows from the following negative result by Itai and Rodeh [25].

Corollary B.1 (Corollary of [25, Thm. 4.2]).

For any constant ε>0𝜀0\varepsilon>0italic_ε > 0, there is no quiescently terminating algorithm for electing a leader in the anonymous ring that succeeds with at least constant probability ε𝜀\varepsilonitalic_ε.

Proof B.2.

Itai and Rodeh show that no terminating algorithm can compute the number of nodes in an anonymous ring with any constant probability of success [25, Thm. 4.2]. As any algorithm in our setting also works in the setting considered in that prior work (in which messages carry content instead of being pulses), the impossibility result carries to our setting. As any algorithm for electing a leader with quiescent termination would allow us to count the number of nodes in the ring afterwards [8], leader election suffers from the same impossibility result.

Consequently, we only aim for a quiescently stabilizing algorithm.

As in Section 4, observe that despite assuming the uniqueness of all IDs in Section 3.1 to elect the node with the largest ID, the task remains well-defined even if only the largest ID is unique. Lemma 4.3 showed that on a ring with possibly non-unique IDs, Algorithm 1 elects as leader all nodes v𝑣vitalic_v such that 𝖨𝖣v=𝖨𝖣maxsubscript𝖨𝖣𝑣subscript𝖨𝖣\mathsf{ID}_{v}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. Hence, if a single node satisfies 𝖨𝖣v=𝖨𝖣maxsubscript𝖨𝖣𝑣subscript𝖨𝖣\mathsf{ID}_{v}=\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT, a single leader is elected. Algorithm 3 is simply two parallel executions of Algorithm 1. As we already showed in the proof of Theorem 1.2, those two parallel executions still yield the desired result as long as the maximal ID in the two executions is unique. Hence, providing an algorithm for sampling IDs with the guarantee that the maximal ID is unique with high probability is sufficient to obtain a variant of Theorem 1.2 for anonymous rings.

In what follows, we outline a process by which nodes can utilize their access to randomness to sample random IDs with the guarantee that, with high probability, the maximal ID is unique and of order nO(1)superscript𝑛𝑂1n^{O(1)}italic_n start_POSTSUPERSCRIPT italic_O ( 1 ) end_POSTSUPERSCRIPT. The algorithm terminates quiescently—in fact, it uses no communication—enabling composition: any algorithm can be performed afterwards with the sampled IDs. As a result, with high probability, the anonymous setting reduces to the one considered in Lemma 4.3. As explained previously, such an algorithm for sampling IDs immediately implies the following result.

Theorem B.3.

There is a content-oblivious algorithm of complexity nO(1)superscript𝑛𝑂1n^{O(1)}italic_n start_POSTSUPERSCRIPT italic_O ( 1 ) end_POSTSUPERSCRIPT that elects a leader and orients an anonymous ring of n𝑛nitalic_n nodes, each with access to its own source of randomness, with high probability. The algorithm reaches quiescence but does not terminate.

We now present the algorithm for sampling IDs guaranteeing a unique maximal ID with high probability; see Algorithm 4. At a high level, the algorithm has each node first sample the number of bits in its ID from a geometric distribution with parameter p=21/Θ(c)𝑝superscript21Θ𝑐p=2^{-1/\Theta(c)}italic_p = 2 start_POSTSUPERSCRIPT - 1 / roman_Θ ( italic_c ) end_POSTSUPERSCRIPT before sampling said bits uniformly at random. While each ID is of expected length Θ(c)Θ𝑐\Theta(c)roman_Θ ( italic_c ) and value 2Θ(c)superscript2Θ𝑐2^{\Theta(c)}2 start_POSTSUPERSCRIPT roman_Θ ( italic_c ) end_POSTSUPERSCRIPT at the end of this process, the maximal ID is of length Θ(c2logn)Θsuperscript𝑐2𝑛\Theta(c^{2}\log n)roman_Θ ( italic_c start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT roman_log italic_n ) and value nΘ(c2)superscript𝑛Θsuperscript𝑐2n^{\Theta(c^{2})}italic_n start_POSTSUPERSCRIPT roman_Θ ( italic_c start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) end_POSTSUPERSCRIPT, with high probability. See [6]. Intuitively, while sampling a large ID is an unlikely event, this unlikely event becomes more and more likely to occur somewhere in the network as the network grows. Similar ideas have previously appeared in the literature, e.g., in [1, 18]. While in other settings, as in [1], similar ID sampling algorithms may utilize message-passing to assign unique IDs, this is not an option in a content-oblivious setting. Fortunately, communication between nodes is not necessary in order to just achieve a unique maximal ID with high probability. Giving unique IDs to all nodes with quiescent termination is also impossible, even with just a small constant probability of success from the impossibility result of Itai and Rodeh [25] (see Corollary B.1). This is because unique IDs would allow us to run Algorithm 2 and elect a leader. In fact, most nodes have non-unique IDs after running Algorithm 4.

Algorithm 4 Message-Free Algorithm for Sampling an ID of Order nO(c2)superscript𝑛𝑂superscript𝑐2n^{O(c^{2})}italic_n start_POSTSUPERSCRIPT italic_O ( italic_c start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) end_POSTSUPERSCRIPT for Node v𝑣vitalic_v, c>0𝑐0c>0italic_c > 0
1:p21/(c+2)𝑝superscript21𝑐2p\leftarrow 2^{-1/(c+2)}italic_p ← 2 start_POSTSUPERSCRIPT - 1 / ( italic_c + 2 ) end_POSTSUPERSCRIPT
2:Sample BitCount Geo(1p)similar-toabsent𝐺𝑒𝑜1𝑝\sim Geo(1-p)∼ italic_G italic_e italic_o ( 1 - italic_p ), i.e., according to the geometric distribution with parameter 1p1𝑝1-p1 - italic_p
3:Sample 𝖨𝖣vsubscript𝖨𝖣𝑣\mathsf{ID}_{v}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT uniformly at random from {0,1}BitCountsuperscript01BitCount\{0,1\}^{\textit{BitCount}}{ 0 , 1 } start_POSTSUPERSCRIPT BitCount end_POSTSUPERSCRIPT
Lemma B.4.

For any constant c>0𝑐0c>0italic_c > 0, with high probability, running Algorithm 4 in an anonymous ring of n𝑛nitalic_n nodes assigns each one an ID of size nO(c2)superscript𝑛𝑂superscript𝑐2n^{O(c^{2})}italic_n start_POSTSUPERSCRIPT italic_O ( italic_c start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) end_POSTSUPERSCRIPT such that the maximal ID is attained uniquely by one node and is at least nΩ(c)superscript𝑛Ω𝑐n^{\Omega(c)}italic_n start_POSTSUPERSCRIPT roman_Ω ( italic_c ) end_POSTSUPERSCRIPT.

Proof B.5.

Let S1,,Snsubscript𝑆1subscript𝑆𝑛S_{1},\ldots,S_{n}italic_S start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT , … , italic_S start_POSTSUBSCRIPT italic_n end_POSTSUBSCRIPT be random variables associated to the the variable BitCount for each node after termination is reached across all nodes.

Observe that for all i[n]𝑖delimited-[]𝑛i\in[n]italic_i ∈ [ italic_n ] and x>0𝑥0x>0italic_x > 0, we have Pr[Si>x]=pxPrsubscript𝑆𝑖𝑥superscript𝑝𝑥\Pr[S_{i}>x]=p^{x}roman_Pr [ italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT > italic_x ] = italic_p start_POSTSUPERSCRIPT italic_x end_POSTSUPERSCRIPT.

Define the random variable M:=maxiSiassign𝑀subscript𝑖subscript𝑆𝑖M:=\max_{i}{S_{i}}italic_M := roman_max start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT, that is, M𝑀Mitalic_M is the length of the longest sampled ID. We first aim to show that M𝑀Mitalic_M exceeds L:=(c+2)lognclnn=Ω(clogn)assign𝐿𝑐2𝑛𝑐𝑛Ω𝑐𝑛L:=(c+2)\log{\frac{n}{c\ln{n}}}=\Omega(c\log{n})italic_L := ( italic_c + 2 ) roman_log divide start_ARG italic_n end_ARG start_ARG italic_c roman_ln italic_n end_ARG = roman_Ω ( italic_c roman_log italic_n ) with high probability.

Indeed, the complementary event ML𝑀𝐿M\leq Litalic_M ≤ italic_L has probability Pr[ML]=Pr[i[n],SiL]=(1Pr[Si>L])n=(1pL)nPr𝑀𝐿Prfor-all𝑖delimited-[]𝑛subscript𝑆𝑖𝐿superscript1Prsubscript𝑆𝑖𝐿𝑛superscript1superscript𝑝𝐿𝑛\Pr[M\leq L]=\Pr[\forall i\in[n],S_{i}\leq L]=(1-\Pr[S_{i}>L])^{n}=(1-p^{L})^{n}roman_Pr [ italic_M ≤ italic_L ] = roman_Pr [ ∀ italic_i ∈ [ italic_n ] , italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT ≤ italic_L ] = ( 1 - roman_Pr [ italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT > italic_L ] ) start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT = ( 1 - italic_p start_POSTSUPERSCRIPT italic_L end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT, where the second equality follows due to the independence between the variables Sisubscript𝑆𝑖S_{i}italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT.

By definition of p:=21/(c+2)assign𝑝superscript21𝑐2p:=2^{-1/(c+2)}italic_p := 2 start_POSTSUPERSCRIPT - 1 / ( italic_c + 2 ) end_POSTSUPERSCRIPT and the bound 1xex1𝑥superscript𝑒𝑥1-x\leq e^{-x}1 - italic_x ≤ italic_e start_POSTSUPERSCRIPT - italic_x end_POSTSUPERSCRIPT, we get

Pr[ML]=(1pL)nexp(pLn)exp(clnn)=nc.Pr𝑀𝐿superscript1superscript𝑝𝐿𝑛superscript𝑝𝐿𝑛𝑐𝑛superscript𝑛𝑐.\Pr[M\leq L]=(1-p^{L})^{n}\leq\exp(-p^{L}n)\leq\exp(-c\ln{n})=n^{-c}\text{.}roman_Pr [ italic_M ≤ italic_L ] = ( 1 - italic_p start_POSTSUPERSCRIPT italic_L end_POSTSUPERSCRIPT ) start_POSTSUPERSCRIPT italic_n end_POSTSUPERSCRIPT ≤ roman_exp ( - italic_p start_POSTSUPERSCRIPT italic_L end_POSTSUPERSCRIPT italic_n ) ≤ roman_exp ( - italic_c roman_ln italic_n ) = italic_n start_POSTSUPERSCRIPT - italic_c end_POSTSUPERSCRIPT .

Thus, with high probability, M>L=Ω(clogn)𝑀𝐿Ω𝑐𝑛M>L=\Omega(c\log{n})italic_M > italic_L = roman_Ω ( italic_c roman_log italic_n ). To see that the largest ID is unique with high probability, note that the probability of a collision on M𝑀Mitalic_M bits is at most (n2)2Mbinomial𝑛2superscript2𝑀{\binom{n}{2}}\cdot 2^{-M}( FRACOP start_ARG italic_n end_ARG start_ARG 2 end_ARG ) ⋅ 2 start_POSTSUPERSCRIPT - italic_M end_POSTSUPERSCRIPT, which, with high probability due inequality (B.5), is bounded by n222L=n22(nclnn)(c+2)=O(nc+ε)superscript𝑛22superscript2𝐿superscript𝑛22superscript𝑛𝑐𝑛𝑐2𝑂superscript𝑛𝑐𝜀\frac{n^{2}}{2}\cdot 2^{-L}=\frac{n^{2}}{2}\cdot(\frac{n}{c\ln{n}})^{-(c+2)}=O% (n^{-c+\varepsilon})divide start_ARG italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG start_ARG 2 end_ARG ⋅ 2 start_POSTSUPERSCRIPT - italic_L end_POSTSUPERSCRIPT = divide start_ARG italic_n start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT end_ARG start_ARG 2 end_ARG ⋅ ( divide start_ARG italic_n end_ARG start_ARG italic_c roman_ln italic_n end_ARG ) start_POSTSUPERSCRIPT - ( italic_c + 2 ) end_POSTSUPERSCRIPT = italic_O ( italic_n start_POSTSUPERSCRIPT - italic_c + italic_ε end_POSTSUPERSCRIPT ) for any small constant ε>0𝜀0\varepsilon>0italic_ε > 0.

Finally, we show that M=O(c2logn)𝑀𝑂superscript𝑐2𝑛M=O(c^{2}\log{n})italic_M = italic_O ( italic_c start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT roman_log italic_n ) with high probability. Letting U:=(c+1)(c+2)lognassign𝑈𝑐1𝑐2𝑛U:=(c+1)(c+2)\log{n}italic_U := ( italic_c + 1 ) ( italic_c + 2 ) roman_log italic_n, the probability of M𝑀Mitalic_M exceeding U𝑈Uitalic_U can be bound as follows:

Pr[M>U]=Pr[i[n],Si>U]pUn=n(c+1)n=nc,Pr𝑀𝑈Pr𝑖delimited-[]𝑛subscript𝑆𝑖𝑈superscript𝑝𝑈𝑛superscript𝑛𝑐1𝑛superscript𝑛𝑐,\Pr[M>U]=\Pr\left[\exists i\in[n],S_{i}>U\right]\leq p^{U}\cdot n=n^{-(c+1)}% \cdot n=n^{-c}\text{,}roman_Pr [ italic_M > italic_U ] = roman_Pr [ ∃ italic_i ∈ [ italic_n ] , italic_S start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT > italic_U ] ≤ italic_p start_POSTSUPERSCRIPT italic_U end_POSTSUPERSCRIPT ⋅ italic_n = italic_n start_POSTSUPERSCRIPT - ( italic_c + 1 ) end_POSTSUPERSCRIPT ⋅ italic_n = italic_n start_POSTSUPERSCRIPT - italic_c end_POSTSUPERSCRIPT ,

where the inequality follows from a union bound. Therefore, with probability at least 1nc1superscript𝑛𝑐1-n^{-c}1 - italic_n start_POSTSUPERSCRIPT - italic_c end_POSTSUPERSCRIPT, the sampled IDs are bounded by 2U=nO(c2)superscript2𝑈superscript𝑛𝑂superscript𝑐22^{U}=n^{O(c^{2})}2 start_POSTSUPERSCRIPT italic_U end_POSTSUPERSCRIPT = italic_n start_POSTSUPERSCRIPT italic_O ( italic_c start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ) end_POSTSUPERSCRIPT.

The proof of Theorem B.3 follows immediately from Lemma B.4.

Finally, we note that a slight modification of Algorithm 3 would also allow us to sample a unique ID for each node (Proposition B.6), with high probability. As a result, the three settings of (1) the anonymous ring, (2) the ring with a leader, and (3) the ring with unique IDs and an orientation, are crucially separated by the possibility of quiescent termination. Leader election, orienting the ring, and assigning unique IDs can all be computed in setting (1). However, they can only be done without termination, while in settings (2) and (3), the same tasks and more can be performed with quiescent termination.

Proposition B.6.

Let 𝖨𝖣vsubscript𝖨𝖣𝑣\mathsf{ID}_{v}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT be the ID sampled by nodes in Algorithm 4, before running Algorithm 3. Modify Algorithm 3 so that whenever a node receives a pulse, if min(ρ0,ρ1)>𝖨𝖣vsubscript𝜌0subscript𝜌1subscript𝖨𝖣𝑣\min({\rho}_{0},{\rho}_{1})>\mathsf{ID}_{v}roman_min ( italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) > sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT, node v𝑣vitalic_v updates its ID to a new ID sampled uniformly at random between 1111 and min(ρ0,ρ1)1subscript𝜌0subscript𝜌11\min({\rho}_{0},{\rho}_{1})-1roman_min ( italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) - 1. Then, with high probability, all nodes have distinct IDs when reaching quiescence.

Proof B.7.

First, remark that nodes always forward pulses once min(ρ0,ρ1)subscript𝜌0subscript𝜌1\min({\rho}_{0},{\rho}_{1})roman_min ( italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) has exceeded 𝖨𝖣vsubscript𝖨𝖣𝑣\mathsf{ID}_{v}sansserif_ID start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT. The way we update the ID keeps the ID below min(ρ0,ρ1)subscript𝜌0subscript𝜌1\min({\rho}_{0},{\rho}_{1})roman_min ( italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ), so this change does not change the behavior of nodes in the algorithm regarding how they send or receive pulses. It also does not affect the computation of the output.

Each node last resamples its ID when min(ρ0,ρ1)subscript𝜌0subscript𝜌1\min({\rho}_{0},{\rho}_{1})roman_min ( italic_ρ start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT , italic_ρ start_POSTSUBSCRIPT 1 end_POSTSUBSCRIPT ) reaches 𝖨𝖣maxsubscript𝖨𝖣\mathsf{ID}_{\max}sansserif_ID start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT. As the largest ID is at least nΩ(c)superscript𝑛Ω𝑐n^{\Omega(c)}italic_n start_POSTSUPERSCRIPT roman_Ω ( italic_c ) end_POSTSUPERSCRIPT with high probability, all nodes end up sampling their IDs in a sampling space of size at least nΩ(c)superscript𝑛Ω𝑐n^{\Omega(c)}italic_n start_POSTSUPERSCRIPT roman_Ω ( italic_c ) end_POSTSUPERSCRIPT. Therefore, the probability of a collision for the last sampled IDs is at most (n2)nΩ(c)=nΩ(c)binomial𝑛2superscript𝑛Ω𝑐superscript𝑛Ω𝑐\binom{n}{2}\cdot n^{-\Omega(c)}=n^{-\Omega(c)}( FRACOP start_ARG italic_n end_ARG start_ARG 2 end_ARG ) ⋅ italic_n start_POSTSUPERSCRIPT - roman_Ω ( italic_c ) end_POSTSUPERSCRIPT = italic_n start_POSTSUPERSCRIPT - roman_Ω ( italic_c ) end_POSTSUPERSCRIPT, i.e., there is no collision with high probability.