Overall Deployment Structure
Setup VM
- Create 2 VMs for Open5gs and UERANSIM.
Check the IP of each VM and note it down.
## to check the IP address of VM ip a
Open the local terminal and connect to each VM at different windows.
## connect to the VM
ssh <VM-login-name>@<VM-ip>
- Make the IP address of each VM, static, to make it easier for users to find you via DNS.
cd /etc/netplan/
ls
sudo vim 00-installer-config.yaml
- Remove all context and paste the below context there.
## change ip address of 'addresses field' as preferred by you
network:
ethernets:
enp1s0:
addresses:
- 192.168.122.245/24
gateway4: 192.168.122.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
version: 2
sudo netplan apply
Now open another terminal and logged in to the same VM. Close the running terminal.
Do similar to the other VM.
First, we deploy Open5gs and then UERANSIM because we need Open5gs configuration in UERANSIM.
Install Open5GS
- Run the following commands in the Open5gs VM.
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:open5gs/latest
sudo apt update
sudo apt install open5gs
Update Configuration
- Update the
amf
configuration
sudo vim /etc/open5gs/amf.yaml
- Change the
ngap address
with your Open5gs IP.
sudo systemctl restart open5gs-amfd
- Update the
upf
configuration
sudo vim /etc/open5gs/upf.yaml
- Change the
gtpu address
with your Open5gs IP address and save it.
sudo systemctl restart open5gs-upfd
NAT(Network Address Translation) Port Forwarding
- To create a connection between 5G Core and Internet, we need to enable IP forwarding and add a NAT rule to the IP Tables.
## change eth0 with your ethernet interface
## to check your ethernet interface
ip a
## In my case it is enp1s0,
## en --> ethernet
## p1 --> bus number (1)
## s0 --> slot number (0)
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo systemctl stop ufw
sudo iptables -I FORWARD 1 -j ACCEPT
Access Open5gs Dashboard
sudo apt update
sudo apt install curl
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install nodejs
git clone https://github.com/open5gs/open5gs.git
cd open5gs/webui/
npm ci --no-optional && npm run build
npm run dev --host 0.0.0.0
- Run the below command to access the open5gs dashboard locally.
ssh -L localhost:3000:localhost:3000 <open5gs-VM-login-name>@<open5gs-ip>
Open any browser and search for this website:
http://localhost:3000
Login credentials :
username
- admin
password
- 1423
- Add new subscriber from the dashboard :
IMSI: 901700000000001
Subscriber Key: 465B5CE8B199B49FAA5F0A2EE238A6BC
USIM Type: OPc
Operator Key: E8ED289DEBA952E4283B54E88E6183CA
- Or only type the IMSI Number, and the rest will be filled up automatically.
Install UERANSIM
- On a new terminal, logged in to the UERANSIM VM and run the below commands.
sudo apt update
sudo apt upgrade -y
sudo apt install iproute2
sudo snap install cmake --classic
sudo apt install gcc
sudo apt install g++
sudo apt install libsctp-dev
## clone ueransim
git clone https://github.com/aligungr/UERANSIM
cd UERANSIM/
sudo apt install make
make
Setup gNB
- Update the
linkIp
,ngapIp
,gtpIp
field with UERANSIM IP and change theamfConfigs address
field with Open5gs IP and save it.
sudo vim config/open5gs-gnb.yaml
cd UERANSIM/
sudo ./build/nr-gnb -c config/open5gs-gnb.yaml
Setup UE
Now, open a new terminal and logged in to the UERANSIM VM.
Update the
gnbSearchList
with the IP address of the UERANSIM.
sudo vim UERANSIM/config/open5gs-ue.yaml
cd UERANSIM/
sudo ./build/nr-ue -c config/open5gs-ue.yaml
Wireshark
Keep the last 2 terminals running gNB and UE opened.
Open another terminal and logged in to the UERANSIM VM and run the below commands to store the data packets.
## change ip field with your UERANSIM IP.
## change the file name where you want to store packets.
sudo tcpdump host <ip> -i any -w <file-name>.pcap
- Open a new local terminal and run this command:
scp <UERANSIM-VMlogin-name>@<UERANSIM-ip>:<location_of_the_file_in_the_VM> <location_to_store_the_file_in_the_local_device>
## e.g. scp s2@192.168.5.182:/home/UERANSIM/file.pcap /home/shubham/file.pcap
After some time, stop the terminal running
sudo tcpdump host <ip> -i any -w <file-name>.pcap
command.The packets are stored in the pcap file. Open the file in Wireshark. You can see the flow of data packets and protocols used.