# srsRAN 4G (with 5G SA/NSA).
## Installation of srsRAN
* https://docs.srsran.com/projects/4g/en/latest/general/source/1_installation.html
## 5G srs COTS UE.
* https://docs.srsran.com/projects/4g/en/latest/app_notes/source/5g_sa_COTS/source/index.html
#### Setup the Open5GS:
* Create the virtual machine and setup the Open5GS (https://open5gs.org/open5gs/docs/guide/01-quickstart/). Or else use the existing Open5Gs VM from the lab and run it.
* get webUI on https://localhost:3000 with `admin` and `1432` as username and password.
* The two important configuration files are `amf.yaml` and `mme.yaml`. find them in `/etc/open5gs/`
* Some Condifuration needs at the Open5GS
* make the following changes:
In /etc/open5gs/ :
Upf.yaml -> gtpu: - addr: change to the the IP address of the mobile core machine
Amf.yaml -> ngap: - addr: change to the the IP address of the mobile core machine
Also in the gnb_rf_n310_fdd_n3_20mhz.yml file, the addr: mobile core ip, bind_addr: gnb IP
* Changed the ip address in mme.yaml for s1ap to the ip address of the mobile core system.
* Changed the ip address in sgwu.yaml for gtpu to the ip address of the mobile core system.
* Inserted the commands of IP forwarding and NAT rules in the mobile core VM:
* **To enable forwarding and add the NAT rule**
Enable IPv4/IPv6 Forwarding
`$ sudo sysctl -w net.ipv4.ip_forward=1`
`$ sudo sysctl -w net.ipv6.conf.all.forwarding=1`
* **Add NAT Rule**
`$ sudo iptables -t nat -A POSTROUTING -s 10.45.0.0/16 ! -o ogstun -j MASQUERADE`
$ `sudo ip6tables -t nat -A POSTROUTING -s 2001:db8:cafe::/48 ! -o ogstun -j MASQUERADE`
Configure the firewall correctly. Some operating systems (Ubuntu) by default enable firewall rules to block traffic.
`$ sudo ufw status`
Status: active
`$ sudo ufw disable`
Firewall stopped and disabled on system startup
`$ sudo ufw status`
Status: inactive
* Mostafa Document: https://hackmd.io/@mostafa-kishani/srsRAN
## Running srsRAN
* change the `enb.conf.example` file `srsRAN_4G/srsenb` as follows:
mme_addr = 192.168.27.191
#mme_addrs is the ip address of the OpenGIS system.
gtp_bind_addr = 192.168.27.149
#gtp is srsRAn system IP
s1c_bind_addr = 192.168.27.149
* **Running srsRAN** `srsenb enb.conf` or `srsenb enb.conf.example` from the
* Add `lte_sample_rates=true` at the end of `enb config file`.
-----
### For srsRAN4G 5G NSA COTS UE setup.
* The following configuration files has to be changed as mentioned in the https://docs.srsran.com/projects/4g/en/latest/app_notes/source/5g_nsa_cots/source/index.html
* enb.conf
* rr.conf
* epc.conf
* user_db.csv
* Al though the above file configurations are given with the modifications as per enabling 5G NSA. The following changes required to work for the `epc.conf` and `enb.conf`
* For `enb.conf` in addition to the changes mentioned in the above link.The follwing has to be worked
* `mme_add` should be as `mme_addr=127.0.1.1`. This was observed from the log (enb.log) files where mme is trying to establish connection to s1 through this ip.
* For `epc.conf`:
* similarly, match the `mme_bind_address` to the `mme_addr` as mentioned in `enb.conf`. So the `mme_bind_address=127.0.1.1`
* `gtpu_bind_addr = ` assign *Machine IP address*
While running the srcepc, there is a chance that port `36412` is already in use, or it many not be properly closed. Kill this `sudo netstat -lpn | grep :36412` to find PId and then kill via `kill -9 PID`.
`
#### Modem Configuration Information:
* https://www.waveshare.com/wiki/SIM8200EA-M2_5G_HAT#Testing_with_AT_command