## 4 Known Number of Processes Multichannel Naming with Beeps  
In this section, the MCBN algorithm is described for assigning unique names to all processes when they communicate in multiple channels with beeps and the number of processes is known. The algorithm is a Las Vegas algorithm, which is guaranteed to terminate, and on termination all processes are assigned unique names with no errors. In the MCBN algorithm, the problem of assigning unique names to all processes is divided into two sub-problems: assigning unique names to each group individually, and forming a consecutive set of unique names. Therefore, the MCBN algorithm consists of two main parts, see Figure 2. In the first part, all processes in all channels execute the Single Group Beep Naming (SGBN) algorithm to assign unique names for each group individually, see Figure 3. The SGBN algorithm is designed based on the algorithm Beep-Naming-LV, which was developed in [20] for assigning unique names to all processes in a single channel. When the SGBN algorithm terminates successfully for group \(j\), all processes that are members of group \(j\) are assigned unique names in the range \((1,n_{j})\). Next, how the SGBN algorithm assigns unique names to all processes is described in detail. The pseudocode for the algorithm is shown in Algorithm 1. In the beginning, a process randomly chooses its round, say \(r\), uniformly at random from the range \((1,an\log n)\), where \(n\) is the number of processes and \(\alpha\) is an arbitrary value greater than or equal to 1. Each process keeps track of the round number through an internal variable _round_ initialized to 0, which is incremented by 1 for every elapsed round. Therefore, when the value of _round_ matches the selected random round \(r\), the process transmits a beep on its assigned channel. Because all channels have no collision detection, a beep that is heard on the channel during round \(j\) may come from one or more transmitting processes in the same  
Figure 3: How names are assigned in the first part of the MCBN and the UMCBN algorithms. Figure 2: Flow chart of the two parts in the MCBN algorithm. round. Therefore, any beep heard in the round loop must be verified for the collision of two or more processes, so that a unique name is assigned to a single process. ```
repeat /* algorithm repeat loop */ \(j\leftarrow\) current group number \(n\leftarrow\)number of processes in the group \(round\gets 0\) \(FB\leftarrow\varnothing\) \(c_{\text{p}}\gets 1\) \(rangeEnd\leftarrow\mathit{an}\log n\) \(name_{\text{p}}\leftarrow\varnothing\) \(r_{\text{p}}\leftarrow\)random\((1,rangeEnd)\) repeat /* round loop */ if\(r_{\text{p}}=t\)then  beep /* round ended */ \(round\gets round+1\); \(FB\gets getChannelFeedback(j)\) if feedback is a beep then /* start of collision-checking segment */ \(collision\gets false\) for\(i\gets 1\)to\(\alpha\log n\)do ifCheck_Collision()then \(collision\gets true\) if\(collision=false\)then \(c_{\text{p}}\gets c_{\text{p}}+1\) \(name_{\text{p}}\gets c_{\text{p}}\) else \(r_{\text{p}}\leftarrow\)random\((round,rangeEnd)\) /* end of segment */ until\(round=\mathit{an}\log n\) until\(c_{\text{p}}=n\)
```  
**Algorithm 1**Single Group Beep Naming  
The Check-Collision procedure in Algorithm 2 verifies whether one or more processes have chosen the same round. Thus, all processes enter a collision-checking segment in which the counting of the round is temporarily paused. In the collision-checking segment, all processes that have chosen the same round participate in the execution of the Check-Collision procedure, which is executed \(\alpha\log n\) times, where \(n\) is the number of processes in the current group. Each call to the Check-Collision procedure consists of two rounds. The Check-Collision procedure begins by using a random coin flip method, which determines whether the process beeps in the first or the second round. The process continues listening to the channel on both rounds.