## 5 Proposed Protocol  
### Message Flow of the Proposed Protocol  
Figure 6 shows the proposed protocol's message flow. It involves eight message types. They are the **adv**, the **join_req**, the **CK_req**, the **CK_rep**, the **sched_seed_permut**, the **pattern_code**, the **selected_nodes** and the **data** messages. This message flow is presented without any cryptographic function being involved.  
The various symbols denote:  
\(H\), \(A_{t}\), \(BS\) : A CH, an ordinary node, and BS, respectively;  
\(\mathcal{G}\): The set of all nodes in the network;  
\(\Rightarrow\), \(\rightarrow\): Broadcast and unicast transmissions, respectively;  
\(id_{X}\): The ID of node \(X\);  
**adv**, **join_req**, **CK_req**, **CK_rep**, **sched_seed_permut**, **pattern_code**, **selected_nodes**, **data**, **sched**: String identifiers for message types;  
\((id_{X},t_{X})\): A node id \(X\) and its time slot \(t_{X}\) in its cluster's TDMA schedule;  
\(d_{X}\): Sensor measurement of node \(X\);  
\(mapping\_permutation\): NOVSH-BH mapping permutation;  
\(seed\): Pattern seed;  
\(pattern\_code_{X}\), \(timestamp_{X}\): The pattern code and timestamp of node \(X\);  
Figure 6: Message flow of the proposed protocol.  
\(X_{selected}\), \(X_{de-selected}\): The selected set of node that has unique pattern codes and unselected ones, respectively.  
Like the LEACH protocol, the proposed protocol works in rounds. Every round has two phases, the setup phase and the steady-state phase. Setup phase is the phase where the cluster formation is done. At the beginning of that phase, every node that wants to become the CH in the coming round broadcasts an advertisement message, the **adv**, containing its id. Upon receiving an **adv** message, a node that wants to join the cluster sends back the join request message, **join_req**, to the corresponding CH. Having listed all joining nodes, a CH then sends a request, the **CK_req** message, to the BS asking for a cluster key for its cluster. In reply, the BS broadcasts the **CK_rep** message containing the cluster key and the id of the CH so that the nodes that belong to that CH can take this message. After that, the CH broadcasts the **sched_seed_permut** message within its own cluster. The message includes the TDMA schedule, the pattern seed and the mapping permutation.  
In the steady-state phase, at first every node in a cluster, according its timeslot, sends a **pattern_code** message to the CH. The **pattern_code** message contains the ids of the sending node and the CH, the representative data of sensor reading and the timestamp of the sensor reading. After collecting all the pattern codes of its cluster, the CH then compares those pattern codes and selects the unique ones. Later on the CH broadcasts the **selected_nodes** message containing the list of nodes having the unique pattern codes to its cluster. Then the selected nodes send the **data** message to the CH. The **data** message contains the ids of the sending node and the CH and the actual sensor reading. Finally, the CH forwards all the collected data to the BS as the **data** message.  
As we can see from steps 3 and 5, there are two types of message which are broadcasted within a certain cluster, the **sched_seed_permut** and the **selected_nodes** message. These broadcast messages need a group key or cluster key to secure them. Therefore we introduce two messages, the cluster key request **CK_req** and the cluster key reply **CK_rep**.