## 4 Satellite Self-Organizing Network Simulation Platform Based on OMNeT++
### Function Domain
#### 4.3.2 Cluster Maintenance  
After the initial cluster structure is established, due to the movement of the satellites, the relative positions of the nodes may change. These changes can affect the structure of the clusters, which may lead to network instability. Therefore, it is necessary to establish a cluster maintenance mechanism to maintain the relative stability of the clusters.  
The content of cluster maintenance mainly involves monitoring and responding to the behavior of nodes, such as leaving clusters, joining clusters, and damage. The satellite nodes in the network are divided into three types: cluster head nodes, member nodes, and isolated nodes. Different nodes perform different cluster maintenance methods to work together to complete the cluster maintenance. This process is deployed at network layer modules of satellite nodes.  
The specific cluster maintenance operations performed by nodes of different types are as follows:  
1. Cluster head node. The cluster head node maintenance process is shown in Figure 5a. The cluster maintenance of the cluster head is periodically triggered. By using the \"ScheduleAt()\" method in OMNeT++, the network layer module of the cluster head can send a message object to itself after a certain period. This method can be used to set a timer to periodically trigger cluster maintenance. After the cluster head triggers the cluster maintenance operation, it first broadcasts an \"isConnected\" message to the member nodes to confirm whether the member nodes are still within their connection range. If any node has left the cluster, the cluster head updates the local connection table and floods this new connection table. Meanwhile, the member with the highest connection degree (i.e., it has the most neighbors in the cluster) is elected as the sub-head, and a message is sent to this member to notify it of becoming the sub-head. When the cluster head is damaged due to certain circumstances, the sub-head can become the new cluster head to manage other member nodes. This can effectively avoid the direct demise of the cluster after the cluster head is damaged, thereby reducing the frequency of cluster structure changes and enhancing the stability of the network;
2. Member nodes. The cluster maintenance process of member nodes is shown in Figure 5b. A timer is also set within the member nodes. If a member node receives an \"isConnected\" message from the cluster head before the timer is up, it resets the timer and sends its own position information and node ID in a \"Reply\" message to the cluster head for updating the local connection table and for the next sub-head election. If the timer is up and the member node still has not received a message from the cluster head, it is considered that the node has left the communication range of the cluster head due to its movement. Therefore, the node changes its status to \"isolate\" and switches to performing the cluster maintenance methods of an isolated node;
3. Isolate nodes. The process for isolated nodes to join a cluster is shown in Figure 5c. An isolated node listens for broadcast messages from cluster heads. If it receives a broadcast message from a cluster head, it sends a network access request to the cluster head. Then, a timer starts counting. If the node receives a confirmation message from the cluster head before the timer is up, the node changes its state to \"member\". If the timer is up and the node still has not received a confirmation message from the cluster head, it continues to listen for cluster head broadcasts.  
Figure 5: Cluster maintenance process of different nodes. (**a**) Cluster maintenance process of cluster head. (**b**) Cluster maintenance process of member. (**c**) Cluster maintenance process of isolate node.