open5gs/docs/_docs/platform/05-macosx.md

142 lines
3.9 KiB
Markdown

---
title: Mac OS X
head_inline: "<style> .blue { color: blue; } </style>"
---
This guide is based on **macOS High Sierra 10.13.3**.
{: .blue}
### Installing Homebrew
---
```bash
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```
### Getting MongoDB
---
Install MongoDB with Package Manager.
```bash
$ brew install mongodb
```
Run MongoDB server.
```bash
$ mkdir -p ./data/db
$ mongod --dbpath ./data/db
```
### Setting up TUN device (No persistent after rebooting)
---
Install TUN/TAP driver
- You can download it from [http://tuntaposx.sourceforge.net/](http://tuntaposx.sourceforge.net/)
Configure the TUN device.
```bash
$ sudo ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.3 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.4 netmask 255.255.255.255
$ sudo ifconfig lo0 alias 127.0.0.5 netmask 255.255.255.255
```
Enable IP forwarding & Masquerading
```bash
$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo sh -c "echo 'nat on {en0} from 45.45.0.0/16 to any -> {en0}' > /etc/pf.anchors/org.nextepc"
$ sudo pfctl -e -f /etc/pf.anchors/org.nextepc
```
**Tip:** The script provided in [$GIT_REPO/support/network/restart.sh](https://github.com/{{ site.github_username }}/nextepc/blob/master/support/network/restart.sh) makes it easy to configure the TUN device as follows:
`$ sudo ./support/network/restart.sh`
{: .notice--info}
### Building NextEPC
---
Install the depedencies for building the source code.
```bash
$ brew install autoconf automake libtool gnu-sed mongo-c-driver libusrsctp gnutls libgcrypt libidn libyaml pkg-config
```
Git clone with `--recursive` option.
```bash
➜ open5gs git clone --recursive https://github.com/{{ site.github_username }}/nextepc
```
To compile with autotools:
```bash
➜ open5gs cd nextepc
➜ nextepc git:(master) ✗ autoreconf -iv
➜ nextepc git:(master) ✗ ./configure --prefix=`pwd`/install
➜ nextepc git:(master) ✗ make -j `nproc`
```
**Note:** On MAC OS X, the compilation check is not supported at this point.
{: .notice--danger}
You need to perform **the installation process**.
```bash
➜ nextepc git:(master) ✗ make install
```
Check whether the installation is correct.
**Note:** This should require *sudo* due to access `/dev/tun0`.
{: .notice--danger}
```bash
acetcom@nextepc:~/nextepc$ sudo ./test/testcomplex
s1setup_test : SUCCESS
attach_test : SUCCESS
volte_test : SUCCESS
handover_test : SUCCESS
All tests passed.
```
**Tip:** You can also check the result of `./test/testcomplex` with a tool that captures packets. If you are running `wireshark`, select the `loopback` interface and set FILTER to `s1ap || gtpv2 || diameter || gtp`. You can see the virtually created packets. [[testcomplex.pcapng]]({{ site.url }}{{ site.baseurl }}/assets/pcapng/testcomplex.pcapng)
{: .notice--info}
For developers, it provides `nextepc-epcd` daemon that includes both *MME*, *SGW*, *PGW*, *HSS*, and *PCRF*.
**Note:** This should require *sudo* due to access `/dev/tun0`.
{: .notice--danger}
```bash
acetcom@nextepc:~/nextepc$ sudo ./nextepc-epcd
04/06 23:13:03.367: [core] INFO: NextEPC daemon start (main.c:169)
PID[6404]: '/home/acetcom/Documents/git/open5gs/nextepc/install/var/run/nextepc-epcd/pid'
File Logging: '/home/acetcom/Documents/git/open5gs/nextepc/install/var/log/nextepc/nextepc.log'
MongoDB URI: 'mongodb://localhost/nextepc'
Configuration: '/home/acetcom/Documents/git/open5gs/nextepc/install/etc/nextepc/nextepc.conf'
04/06 23:13:03.369: [core] INFO: PCRF try to initialize (epc.c:37)
...
```
### Building WebUI of NextEPC
---
[Node.js](https://nodejs.org/) is required to build WebUI of NextEPC
```bash
$ brew install node
```
Install the dependencies to run WebUI
```bash
➜ nextepc git:(master)cd webui
➜ webui git:(master) ✗ npm install
```
The WebUI runs as an [npm](https://www.npmjs.com/) script.
```bash
➜ webui git:(master) ✗ npm run dev
```