This project provides a framework for simulating UPF (User Plane Function) placement based on geographic coordinates and testing network performance through ping measurements.
├── main.py # Main entry point with combined functionality
├── utils/
│ ├── apply_distance.py # Contains functions for coordinate-based bandwidth limitation
│ └── ping_and_measure.py # Contains functions for UE authentication and ping testing
└── configurations/
└── uecfg*.yaml # UE and other container configuration files
- Configure network bandwidth limitations based on geographic distances between components
- Authenticate UEs (User Equipment) and perform ping measurements
- Save test results for analysis
- Python 3.8 or later
pip
(Python package manager)- Docker
- Docker SDK for Python (
pip install docker
) - free5gc docker compose on Ubuntu VM (check this)
- Clone the repository:
git clone https://github.com/minaiscoding/upf-placement-simulator cd upf-placement-simulator
- (Optional) Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # Linux/macOS
- Install dependencies:
pip install docker
- Run the simulation:
python main.py
The main script supports various command line arguments:
usage: main.py [-h] [--skip-distance] [-n NUM_UES] [-s PACKET_SIZE] [-c CONFIG_PREFIX] [-r] [-p PING_COUNT] [-i INTERVAL] [-q QOS] [--skip-ping]
Free5GC Network Testing Tool with Distance Simulation
optional arguments:
-h, --help show this help message and exit
--skip-distance Skip distance configuration
-n NUM_UES, --num_ues NUM_UES
Number of UEs to authenticate
-s PACKET_SIZE, --packet_size PACKET_SIZE
Ping packet size in bytes
-c CONFIG_PREFIX, --config_prefix CONFIG_PREFIX
Prefix for UE config files
-r, --restart Restart all UE processes
-p PING_COUNT, --ping_count PING_COUNT
Number of ping packets per interface
-i INTERVAL, --interval INTERVAL
Interval between pings in seconds
-q QOS, --qos QOS QoS value in hex format
--skip-ping Skip ping measurements
To contribute new features or modify existing ones, follow the Git workflow below.
- Pull the latest changes:
git checkout main git pull origin main
- Create a new feature branch:
git checkout -b feature/<short-description>
- Implement your feature.
Example locations for adding functionality:- Add new UPF logic in
utils/apply_distance.py
- Extend or improve ping measurements in
utils/ping_and_measure.py
- Modify orchestration flow in
main.py
- Add new UPF logic in
- Stage and commit your changes:
git add . git commit -m "Add <brief-description-of-change>"
- Push your feature branch:
git push origin feature/<short-description>
- Open a Pull Request (PR) on GitHub and tag reviewers.
All logic should be modular and located under the utils/
directory. Each file should contain clearly named functions that can be imported into main.py
.
To add a new analytics module:
- Create a new file:
utils/analytics.py
- Define your function:
def evaluate_performance(): # Implementation goes here pass
- Import and call it from
main.py
as needed.
Upon successful execution, the program will:
- Prompt for geographic coordinates
- Calculate and apply bandwidth limitations based on distances
- Authenticate the specified number of UEs
- Perform ping measurements
- Save results to
ping_result.txt
Example output:
=== Free5GC Network Testing Tool ===
=== Configuration des limitations de bande passante basées sur la distance ===
UE-RANSIM coordinates (from docker-compose-ulcl.yaml):
Latitude: 45.7640
Longitude: 4.8357
Veuillez entrer les coordonnées pour i-upf:
Latitude: 45.7641
Longitude: 4.8358
Veuillez entrer les coordonnées pour psa-upf:
Latitude: 45.7642
Longitude: 4.8359
Résultats calculés:
Distance ueransim → i-upf: 0.17 km
Bande passante estimée: 998.35 Mbps
Distance i-upf → psa-upf: 0.17 km
Bande passante estimée: 998.35 Mbps
Configuration des distances terminée avec succès.
=== Exécution des tests de ping ===
[INFO] Found UPF container 'psa-upf' with IP: 10.60.0.103
[INFO] Starting authentication for UE 1 using config/uecfg1.yaml
[INFO] Waiting for interface uesimtun0 to be created...
[SUCCESS] UE 1 authenticated successfully, interfaces created: uesimtun0
[INFO] Found 1 data interfaces: uesimtun0
[INFO] Waiting 3 seconds for network stability...
[INFO] Pinging 10.60.0.103 from interface uesimtun0 with packet size 8...
[✓] Interface uesimtun0: RTT=0.384ms, Loss=0%
[INFO] Results saved to ping_result.txt
[INFO] Cleaning up UE interfaces...
=== Traitement terminé ===