## 5 Simulation  
The simulation, conducted using the Events Simulation Software Platform (ESSP), begins with creating the foundational elements of the system: game and fog clusters, along with corresponding servers for each type. Each server has a maximum capacity load and is associated with one or more clusters where clients can be assigned. Clusters represent geographical locations where game or fog resources are distributed. Once servers and clusters are established, locations are generated for a specific number of clients who will interact with the system. Initially, these clients are randomly assigned to a server, each with a gameplay plan defining actions like connecting, disconnecting, moving, or staying on the same server. During execution, events are simulated for each client based on their gameplay plan. These events include connecting to a server, disconnecting, moving to another cluster, or remaining in place. When a client connects, the load balancer determines the best available server to handle the request, considering the server's current capacity and geographic distance to the client. As simulation events progress, relevant data such as server load at specific time intervals and client-experienced latency are recorded. This allows for a detailed performance analysis of the system, including evaluating average latency, server load, and the effectiveness of the load balancer in evenly distributing requests. At the simulation's conclusion, these data are collected and analyzed to glean insights into the overall system performance. This includes comparing average latency with and without load balancing, as well as monitoring server load over time. These results provide a deep understanding of how the system operates under simulated conditions and can guide decisions to enhance its real-world design and efficiency. **Simulation Infrastructure**  
* A total of 8 conventional servers implemented, each with the capacity to handle up to 150 users simultaneously, giving a total capacity of 1200 users on servers alone. * A total of 4 fog nodes used for additional support, each with a capacity for 50 users. These nodes help offload processing from the main servers, adding 200 additional users to the total capacity, reaching 1400 simultaneous users. * The conventional servers and fog nodes are distributed in a hybrid cloud and fog architecture, where fog nodes are invoked when servers reach their maximum capacity. * **Geographical Distribution:*
* Servers and fog nodes are strategically placed near users to minimize latency, following the principle of edge computing. * The location of both servers and users was randomly generated within a specific coordinate range (\(-\)0.1 to 0.1) to simulate a distributed network. * Latency between servers and users is a key factor, determined based on the geographical distance between them. * **Simulation Duration and Dynamics:*
* The simulation covered a period of 10 min or 600 s, modeling 1300 active users interacting with the simulated infrastructure. * Each user followed a game action plan, including events such as connections, disconnections, and migrations between servers. * **User Behavior Patterns:*
* Users were assigned different interaction plans in the game, where
* 60% of the actions were attempts to connect to servers. * 30% of the actions represented disconnections from servers. * 5% of the actions consisted of server migrations (users moving from one server to another). * 5% of the actions reflected staying on the same server. * These behaviors are designed to simulate a high-interaction and variable load environment. * Four distinct scenarios were implemented:
* Without load balancing: Where users connect to servers without any active mechanism to redistribute the load when a server is overloaded. * With dynamic load balancing: Where a load balancing algorithm dynamically distributes user requests between servers and fog nodes, preventing any server from becoming saturated.