---
# System prepended metadata

title: 國防 Final Demo Setup(Still editing)

---

# 國防 Final Demo Setup(Still editing)

## EdgeNode
### Service Ports
- Openflow: 6653
- Web UI: 7000
- Video Server: 8000
- Flask API: 8080
- ONOS UI: 8181
- Text Server: 9000

### Setup Steps
1. Start database(MySQL & Redis) and dhcp server
```bash=
cd ~/mosaic/edge-node
docker-compose up
```

2. Deploy services on K8S, including
- SDN Controller (ONOS)
- Reverse Proxy (for HTTPS connection)
- Web UI
- Flask
- Video Server
- Text Server
```bash=
cd ~/mosaic/edge-node/k8s-files
microk8s.kubectl apply -k .
```

3. Connect SDN switch to controller
To check the status of the switch
URL: http://172.18.2.1:8181/onos/ui
User: onos
Password: rocks
To connect switch to controller:
```bash=
ssh rootFLC@192.168.100.238
# Password: root5638889
ssh swc
ovs-vsctl set-controller eth1 tcp:172.18.1.1:6653
```

4. Install ONOS application
```bash=
# Check the pod name
microk8s.kubectl get po

# Execute the ONOS pod
microk8s.kubectl exec -it $ONOS_POD_NAME bash

# Install application
cd ~/worker-app
onos-app localhost install! target/worker-app-1.0-SNAPSHOT.oar

# Uninstall application
onos-app localhost uninstall nycu.nems.worker

# Compile application
cd ~/worker-app
mvn clean install -Dmaven.test.skip=true
```

### Some commands
```bash=
# Deploy & delete using kustomization
microk8s.kubectl apply -k .
microk8s.kubectl delete -k .
# Deploy & delete an object
microk8s.kubectl apply -f $FILE_PATH
microk8s.kubectl delete [svc|deploy] $NAME
# Show pods or services
microk8s.kubectl get [po|svc]
# Show everything
microk8s.kubectl get all
# Check log of a pod
microk8s.kubectl logs $POD_NAME
# Execute in a pod
microk8s.kubectl exec -it $POD_NAME bash
```

## UPF Setting
Start the VM on gNB and run "sudo ./setup.sh"
```bash=
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -I FORWARD 1 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -s 10.60.0.0/16 -o enp0s3 -j SNAT --to 172.18.2.201
sudo iptables -t nat -A PREROUTING -d 172.18.2.201/32 -j DNAT --to 10.60.0.1
sudo ip a add 172.18.2.201/24 dev enp0s3
```
Then run UPF
```bash=
cd free5gc/NFs/upf/build
bin/free5gc-upfd
```
If encounter gtp5g module problem, install module and run UPF again.
```bash=
cd ~/gtp5g
make
sudo make install
```

## 5GC Setting
Run core network:
```bash=
cd ~/free5gc
sudo ./run_cplane.sh
```
If encounter any problem:
```bash=
cd ~/free5gc
sudo ./force_kill.sh
```

## gNB Setting
OAI setup reference:
https://hackmd.io/li9sepD2TCWZ9vYIpyICTQ
```bash=
cd ~/openairinterface5g/cmake_targets/ran_build/build/
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf -E --sa
```

## UE Setting
#### NOTE: Make sure Wi-Fi is off!!
```bash=
cd ~/quectel-CM
sudo ./quectel-CM -s internet 0
```
