# An Energy-Efficient Game-Theory-Based Spectrum Decision Scheme for Cognitive Radio Sensor Networks
## 3 Energy-Efficient Game-Theory-Based Spectrum Decision
### Coordination Mode (C Mode)
#### 3.2.2 Clustering Algorithm of C Mode: Residual-Energy-Based Clustering  
The EGSD scheme also includes a simple clustering algorithm, called residual-energy-based clustering because we favor the energy-efficient clustered topology over direct transmission. However, we avoid a sophisticated clustering algorithm despite its performance improvement because, in CRSNs, there are additional energy-consuming spectrum-related activities compared to traditional wireless sensor networks. We try to minimize energy consumption by proposing a simple clustering method.  
The clustering algorithm is triggered on the C mode only. Some parts of the clustering algorithm start before spectrum sensing, and the rest begin after spectrum sensing, as illustrated in Figure 2.  
Initially, all sensor nodes are in the class sensor nodes, \(class(S_{i})=(SN)\), \(\forall i\). The sensor nodes check the residual energy and set the maximum limit of the delay based on it. If the residual energy is high, then the maximum limit of the delay is low, and vice versa. The actual delay duration is set by following a uniform distribution with zero and the previously settled maximum limit. The sensor nodes go to sleep during this delay and wake up to perform FSS. The sensor node \(S_{i}\) listens on the \(C_{control}\) for CH beacons, creates a \(CH\_list=\{CH_{1},CH_{2},\ldots,CH_{r}\}_{i}\), and sorts the \(CH\_list\) based on the received signal strength indicator (RSSI) in a descending manner. Here, we would like to explain the reason for adapting a random delay: without a random delay, every sensor node would perform the same activity at the same time, which would result in no CH found when they try to find a CH because every sensor node is currently finding a CH. Later, when each of them decides to become a CH, probably no node is looking for a CH anymore because all of them have also become CHs.  
The sensor nodes try to join the CH on the top of the list first. The cluster registration method is as follows: the sensor node sends a join packet to the cluster head, and the cluster head replies with operating channel information. The sensor node checks whether the assigned operating channel is idle on its side (spectrum sensing result might be different spatially.) If the assigned operating channel is available, then the sensor node \(S_{i}\) becomes a CM of that CH, i.e., \(class(S_{i})=(CM)\), sets its operating channel as the assigned operating channel, and goes into sleep state until the end of the spectrum sensing module. If the assigned operating channel is not available, then the sensor node checks the CH list and tries the next CH on the list, given that the remaining time is sufficient. Otherwise, the sensor node becomes a CH, i.e., \(class(S_{i})=(CH)\). A sensor node also becomes a CH if it cannot find any CHs from the first time.  
When a sensor node becomes a CH, it selects one of its available channels as its operating channel randomly, transmits beacons on the \(C_{control}\), waits for any join packet, and responds to the join packet with information about its operating channel. The randomly selected operating channel is a temporary one because we have not proceeded to the spectrum decision module. We include the temporary operating channel as a basic requirement in that both parties (CH and CM) find the operating channel as a vacant channel. At this stage, the CH type is type 0 (zero), i.e., \(type(CH)_{i}=0\). (Explanations about CH type are in the next section.) The outcome of the clustering algorithm is that each sensor node has selected its class as either a CH or a CM.