Try   HackMD

Building Open5GS from Sources

tags: Open5gs

1. Getting MongoDB

$ sudo apt update $ sudo apt install mongodb $ sudo systemctl start mongodb $ sudo systemctl enable mongodb

2. Setting up TUN device

  • Create the TUN device with the interface name ogstun.
$ sudo ip tuntap add name ogstun mode tun $ sudo ip addr add 10.45.0.1/16 dev ogstun $ sudo ip addr add 2001:db8:cafe::1/48 dev ogstun $ sudo ip link set ogstun up

3. Building Open5GS

  • Install the dependencies for building the source code.
$ sudo apt install python3-pip python3-setuptools python3-wheel ninja-build build-essential flex bison git libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libidn11-dev libmongoc-dev libbson-dev libyaml-dev libnghttp2-dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev libtins-dev libtalloc-dev meson
  • Git clone.
$ git clone https://github.com/open5gs/open5gs
  • To compile with meson:
$ cd open5gs $ meson build --prefix=`pwd`/install $ ninja -C build

The test program has been run on [VirtualBox - CPU: 1, Memory: 4.00 GB]

  • Check whether the compilation is correct.
$ ./build/tests/attach/attach ## EPC Only $ ./build/tests/registration/registration ## 5G Core Only
  • Run all test programs as below.
$ cd build $ meson test -v
  • You need to perform the installation process.
$ cd build $ ninja install $ cd ../

Install the WebUI of Open5GS

  • Node.js is required to build WebUI of Open5GS
$ sudo apt install curl $ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - $ sudo apt install nodejs
  • Install the dependencies to run WebUI
$ cd webui $ npm ci --no-optional
  • The WebUI runs as an npm script.
$ npm run dev

Username : admin
Password : 1423

Connect UERANSIM

1. Configure Open5GS

  • Modify open5gs/install/etc/open5gs/amf.yaml to set the NGAP IP address, PLMN ID, TAC and NSSAI.

  • Modify open5gs/install/etc/open5gs/upf.yaml to set the GTP-U and PFCP IP address.

2. Running Open5GS

  • Running Open5GS method 1: 需開多個視窗每個NF分別執行
$ ./install/bin/open5gs-${nf}d
  • Running Open5GS method 2: 一次啟動5gc的部分
$ ./build/tests/app/5gc

注意:這裡執行的yaml檔為open5gs/build/configs/sample.yaml需修改這個yaml檔。

3. Turn on gNB and UE

  • Turn on gNB
$ cd ~/UERANSIM $ build/nr-gnb -c config/open5gs-gnb.yaml
  • Turn on UE
$ cd ~/UERANSIM $ sudo build/nr-ue -c config/open5gs-ue.yaml

4. Test ping

$ ping -I uesimtun0 google.com

Test

Compile code

  • To compile with meson:
$ ninja -C build
  • Check whether the compilation is correct.
$ cd build $ meson test -v
  • Install Open5GS and initialize configuration files.
$ rm -Rf ../install $ ninja install

Add printf

  • Add printf in ~/open5gs/src/amf/app.c

  • Result

Add function

  • Add function in ~/open5gs/src/amf/init.c

  • Call function in ~/open5gs/src/amf/app.c

  • Result