安装Open5GS

Open5GS core结构如图所示:

image-20240710013125947

Next time we will complement the explanations of each component.

Install Open5GS with a Package Manager

Here we should import the public key used by the package management system.

1
2
3
$ sudo apt update
$ sudo apt install gnupg
$ curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor

Then we will create the list file /etc/apt/sources.list.d/mongodb-org-6.0.list for your version of Ubuntu.

Universally we use Ubuntu 22.04

1
$ echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

Then the most important step is to install the Mongodb database.

1
2
3
4
$ sudo apt update
$ sudo apt install -y mongodb-org
$ sudo systemctl start mongod (if '/usr/bin/mongod' is not running)
$ sudo systemctl enable mongod (ensure to automatically start it on system boot)

If you are using an arm-based machine, like ubuntu22.04 on raspberry 4B or a virtual machine, there will be a question that it will exhibit a “core-dumped” error, which is due to the need of specific architecture, so we recommend https://github.com/themattman/mongodb-raspberrypi-binaries, providing a viable version.

Using its steps, we will also encounter questions like

1
./mongod: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory

But in ubuntu 22.04, libssl1.1 is not supported anymore, so we will try to install this old version, through

wget http://ports.ubuntu.com/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_arm64.deb

thensudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_arm64.deb.Finally we can check the installation,

1
dpkg -l | grep libssl

And run the mongod through

1
./mongod --dbpath /data/db/test_db --fork --logpath /data/db/test_db/mongod.log --port 28080

./mongod: This starts the MongoDB server. It assumes that the mongod executable is located in the current directory.

--dbpath /data/db/test_db: Specifies the directory where the database files will be stored. In this case, it is set to /data/db/test_db, which means all data will be stored in this directory.

--fork: This option runs the MongoDB server as a background process. This is commonly used in production environments.

--logpath /data/db/test_db/mongod.log: Specifies the path to the log file where the MongoDB server will write its logs. Here, it is set to /data/db/test_db/mongod.log.

--port 28080: Specifies the port on which the MongoDB server will listen. The default port is 27017, but in this case, it has been changed to 28080.

Then

1
./mongo --port 28080 # run queries!

It opens the shell where you can run queries.

Note: mongo is the client and mongod is the server!

We can see the printed content

1
2
3
4
MongoDB shell version v7.0.11
connecting to: mongodb://127.0.0.1:28080/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("55db08cc-67c4-4f50-8e70-b4fc53df6f4c") }
MongoDB server version: 7.0.11

and

1
2
3
4
This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
2024-07-10T01:28:29.389+08:00: Soft rlimits for open file descriptors too low
2024-07-10T01:28:29.389+08:00: currentValue: 1024
2024-07-10T01:28:29.389+08:00: recommendedMinimum: 64000

So if we want to access this server, we should bind the external ip address, or just —bind_ip_all.

Then for convenience, we write this service into a system service file, using vim /etc/systemd/system/mongod.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target

[Service]
User=用户名
Group=用户名
ExecStart=/home/用户名/mdb-binaries/mongod --dbpath /data/db/test_db --logpath /data/db/test_db/mongod.log --port 28080 --bind_ip_all
PIDFile=/var/run/mongodb/mongod.pid
Restart=on-failure
ExecReload=/bin/kill -HUP $MAINPID
LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
LimitNOFILE=64000
LimitNPROC=64000
LimitMEMLOCK=infinity
TasksMax=infinity
TasksAccounting=false

[Install]
WantedBy=multi-user.target

Then we should create he PIDFile and give it the right.

1
2
sudo mkdir -p /run/mongodb
sudo chown yourusername:yourusername /run/mongodb

Finally

1
sudo systemctl daemon-reload

run

1
sudo systemctl start mongod

check

1
sudo systemctl status mongod

then add to the start item, when the computer starts, the service will run.

1
sudo systemctl enable mongod

Install the webUI of Open5GS

1
2
3
4
5
6
7
8
9
10
11
12
13
# Download and import the Nodesource GPG key
$ sudo apt update
$ sudo apt install -y ca-certificates curl gnupg
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg

# Create deb repository
$ NODE_MAJOR=20
$ echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list

# Run Update and Install
$ sudo apt update
$ sudo apt install nodejs -y

Run these commands and then install the webUI through

1
curl -fsSL https://open5gs.org/open5gs/assets/webui/install | sudo -E bash -

Finally we will get the default username and passwd, accessing http://localhost:9999

Or we can correct the /usr/lib/node_modules/open5gs/server/index.jsand listen to 0.0.0.0substituting localhost

1
Username:admin, Password:1423

Simulation of Open5GS

User device:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
sudo ./srsue ue_zmq.conf
[sudo] password for meteorshower:
Active RF plugins: libsrsran_rf_uhd.so libsrsran_rf_zmq.so
Inactive RF plugins:
Reading configuration file ue_zmq.conf...
srsLog error - Unable to create log file "/tmp/ue.log": Permission denied

Built in Release mode using commit ec29b0c1f on branch master.

Opening 1 channels in RF device=zmq with args=tx_port=tcp://127.0.0.1:2001,rx_port=tcp://127.0.0.1:2000,base_srate=23.04e6
Supported RF device list: UHD zmq file
CHx base_srate=23.04e6
Current sample rate is 1.92 MHz with a base rate of 23.04 MHz (x12 decimation)
CH0 rx_port=tcp://127.0.0.1:2000
CH0 tx_port=tcp://127.0.0.1:2001
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Waiting PHY to initialize ...
done!
Attaching UE...
Random Access Transmission: prach_occasion=0, preamble_index=0, ra-rnti=0x39, tti=5134
Random Access Complete. c-rnti=0x4601, ta=0
RRC Connected
PDU Session Establishment successful. IP: 10.45.0.2
RRC NR reconfiguration successful.

gNB:

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo ./gnb -c ./gnb_zmq.yaml 

--== srsRAN gNB (commit 4cf7513e9) ==--


The PRACH detector will not meet the performance requirements with the configuration {Format 0, ZCZ 0, SCS 1.25kHz, Rx ports 1}.
Lower PHY in executor blocking mode.
N2: Connection to AMF on 127.0.0.5:38412 completed
Cell pci=1, bw=20 MHz, 1T1R, dl_arfcn=368500 (n3), dl_freq=1842.5 MHz, dl_ssb_arfcn=368410, ul_freq=1747.5 MHz

Available radio types: uhd and zmq.
==== gNB started ===
Type <h> to view help