# Cyber5 Gym: An Integrated Framework for 5G Cybersecurity Training
## 4 Cyber5 Gym Architecture
```
Input:num_ue_containers,gNB_services,UE_Services,host_nodes,port_number Output:Establish5 GNetwork in All Hosts
1 ProcedureManage5 GNetworkServices:
2 forusername,host_node inhost_nodesdo
3 ExecuteSSHCommands(username,host_node,port_number);
4
5 end
6 FunctionExecuteSSHCommands(username,host_node,port_number):
7 RestartContainer(\"5G_RAN\",host_node);
8 fori inrange1 tonum_ue_containersdo
9 container_name \(\leftarrow\) \"5G_UE\" + i;
10 RestartContainer(container_name,host_node);
11 ExecuteService(container_name,gNB_Services);
12 ExecuteService(container_name,UE_Services);
13
14 end
15 Wait for all services to start;
16 fori inrange1 tonum_ue_containersdo
17 container_name \(\leftarrow\) \"5G_UE\" + i;
18 CheckIPStatus(container_name,host_node);
19
20 end
21 FunctionRestartContainer(container,host_node):
22 Execute \"docker restart \" \"container\" on \"host_node\";
23 Log restart status;
24 FunctionExecuteService(container,command):
25 Execute command in container;
26 Log execution status;
27 FunctionCheckIPStatus(container,host_node):
28 Check IP configuration status in container;
29 Log IP status;
```  
**Algorithm 1**5G Network Management Script using Master Server  
```
Input:num_ue_containers Output:ConfigureTrained Host and Establish5G Network
1 ProcedureDeployAndConfigure5 GSystem:
2 UpdateSystem();
3 InstallDockerComponents();
4 fori\(\gets\) 1 tonum_ue_containersdo
5 imageName \(\leftarrow\) \"ueimage\" + i + \".tar\";
6 LoadDockerImage(image_and_compose_directory,imageName);
7
8 end for
9 DockerComposeUp(image_and_compose_directory);
10 ExecuteInContainer(\"5G_UE_Attacker\",\"Install5 GReplayFuzzer\");
11 ExecuteInContainer(\"5G_UE_Attacker\",\"ConFigure5 GReplayFuzzer\");
12 fori\(\gets\) 1 tonum_ue_containersdo
13
14 ModifyIMSINumbers(\"UE\" + i);
15
16 end for
17
18 return
```  
**Algorithm 2**Trained Host Setup Script for 5G Network Establishment  
The Cyber5 Gym framework is designed to cater to a diverse clientele, encompassing cybersecurity professionals, network engineers, and students specializing in network security. The system's adaptability allows it to serve not only as a training platform for individual learners but also as a collaborative environment for team-based cybersecurityexercises. This inclusive approach ensures that a broad spectrum of users, from beginners to advanced practitioners, can benefit from the realistic emulation of 5G network scenarios and cybersecurity threats. The Cyber5 Gym provides such environment where actors work collaboratively to create a realistic training environment, emulating 5G network and cybersecurity incidents to provide a comprehensive learning experience for the trainees, including a number of benefits as follows:  
1. **Scalability:** The Cyber5 Gym, with its flexible container orchestration platform, dynamically adjusts to varying demands. This allows cyber range environments to seamlessly adapt to changes in the number of trainees, the number of UE devices, or workloads, with minimal manual intervention. Additionally, we have tested its scalability, successfully accommodating up to 100 users in simulations conducted within individual Docker containers, demonstrating the flexibility and suitability of our system for a dynamic number of trainees. 2. **Automation:** Leveraging Docker and shell scripts, the system centralizes control at the master for automating critical cyber range operations. This includes deploying and scaling trainee environments in alignment with the number of UEs, orchestrating 5G network emulations across all trainee modules, and systematically executing attack scenarios and countermeasures. This centralized automation approach streamlines the management process, ensuring a consistent and efficient execution of complex 5G network training exercises. 3. **Reproducibility:** The integration of open source tools in Cyber5 Gym addresses a key challenge in virtual 5G cybersecurity research: the reproducibility of methodologies and outcomes.