## 2 Materials and Methods
### System Description
#### 2.3.2 Server Socket  
The server socket plays a central role in the system as the main node for data aggregation and storage. It receives data from multiple client nodes and consolidates the sensor readings. One of the key features of the server socket is its implementation of the mimic broadcasting mechanism. This mechanism enables the server to seamlessly distribute the'start' message to all connected clients, allowing them to simultaneously begin collecting acceleration data from the ADXL345 sensor. It is noteworthy that the terms 'end node' and 'client' as well as 'gateway' and'server' are used interchangeably to refer to the same underlying concept. The former denotes the physical end node or physical gateway, while the latter represents the role of a client within the TCP/IP socket when connected to the server. Furthermore, it should be acknowledged that both the RPi4 and RPi0-2W can be accessed via Secure SHell (SSH), and in this research, they were controlled through SSH. Figure 2 illustrates the interaction between the server socket and multiple client sockets in the proposed system, showcasing the server-client communication utilizing mimic broadcasting to initiate all clients simultaneously. To begin, the server socket establishes the address and port configuration for incoming client connections and generates a dedicated socket exclusively responsible for handling these connections. Subsequently, once the server socket is bound to the designated address, it initiates the process of monitoring incoming connections. The listen() function is utilized in server implementations to enable the server to accept these connections. In this particular study, the backlog parameter, which determines the number of end nodes to be connected to the server, is obtained through user input. Subsequently, this quantity of end nodes is utilized as the backlog parameter in the listen() function. When a connection request is received, the server utilizes the accept() function to accept the connection and create a client socket for communication. The server then enters a loop to continuously listen for more connections, allowing it to handle multiple clients concurrently. Upon successful establishment of a connection from the individual client, the server-side interaction depicted in Figure 2 encompasses functionalities that align with the underlying operations of the server socket. The AF_INET address family is deliberately chosen to facilitate communication using the IPv4 protocol. Additionally, the SOCK_STREAM socket type is selected to establish a connection-oriented and reliable channel for seamless data transmission. Subsequently, the accept() function plays a pivotal role in establishing the connection between the server and the respective connected client. Subsequently, the server promptly transmits an acceptance message to the connected client, serving as an indication of successful communication initiation. This initial exchange of messages confirms the establishment of a reliable communication channel between the server and the client. Prior to our design program, the server actively retrieves the sensor name provided by each client, as denoted by the assignment statement (a) sensor_name = msg. This step assumes significance as it enables the server to associate the received data with specific clients, thereby facilitating accurate identification and differentiation of data sources. Simultaneously, the server undertakes the creation of dedicated CSV files for each connected client, as illustrated by the notation (b) sensor_name.csv. By utilizing the unique sensor name as a criterion for organizing the collected data, the server ensures the segregation and proper categorization of measurements originating from distinct clients. To handle the data from each end node individually, the server creates a new thread for each connected client, as illustrated by the description (c) a new thread is created.