Skip to content

Deploying Open5gs and observe network traffic through Wireshark

Notifications You must be signed in to change notification settings

chmodshubham/Open5GS-Deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 

Repository files navigation

Open5GS-Deployment

Reference

  1. Github Repository
  2. Reference1
  3. Reference2

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 with the other VM.

  • First we deploy Open5gs 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 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 dashboard :

IMSI: 901700000000001
Subscriber Key: 465B5CE8B199B49FAA5F0A2EE238A6BC
USIM Type: OPc
Operator Key: E8ED289DEBA952E4283B54E88E6183CA

  • Or only type IMSI Number, rest will filled up automatically.

Install UERANSIM

  • On a new terminal, logged in to the UERANSIM VM and run 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 the amfConfigs 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 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 [email protected]:/home/UERANSIM/file.pcap /home/shubham/file.pcap
  • After sometime, 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 the in wireshark. You can see the flow of data packets and protocols used.

About

Deploying Open5gs and observe network traffic through Wireshark

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published