# OAI Build and Exceute ###### tags: `Construction` ## OAI gNB/UE pre-requisites #### Basic requirement | OS/Kernel | Version | |:-------------------------- |:----------------------------------------| | Host operating system | Linux Ubuntu 18.04 or 20.04 or 22.04 | | Kernel | 4.15.0.142.lowlatency | ## Build OAI gNB/UE #### Clone and build the dependency for the first time ```sh # Clone OAI project in Develop Branch git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git -b develop cd openairinterface5g/ # Build ONLY FOR the FIRST time source oaienv cd cmake_targets export BUILD_UHD_FROM_SOURCE=Ture export UHD_VERSION=4.3.0.0-rc1 #(optional UHD_VERSION=4.4.0.0) ./build_oai -I -C -w USRP -c # Sometimes you will get error `no GPG public key or ppa public key XXXXXXXXX_Key` sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys XXXXXXXXX_Key ``` #### Build OAI gNB for USRP ```sh ./build_oai -w USRP --gNB ``` #### Build OAI nrUE for USRP ```sh ./build_oai -w USRP --nrUE ``` ```clike= int a = 0; ``` #### Build other libraries * Use `./build_oai help` to check what library you need. ```sh --build-lib <libraries> # Build optional shared library, <libraries> can be one or several of # telnetsrv # enbscope # uescope # nrscope # nrqtscope # ldpc_cuda # ldpc_t1 # websrv # oai_iqplayer # You can build the libraries you need separatedly. ./ build_oai --build-lib xxx -- build-lib yyy # OR just build all libraries ./build_oai --build-lib all ``` ## Run OAI gNB * Run OAI gNB with B210 ```sh cd ~/openairinterface5g cd cmake_targets/ran_build/build sudo ./nr-softmodem -O [where the config file is] --sa -E --gNBs.[0].min_rxtxtime 6 --nfapi 0 # 1 : PNF, 2 : VNF # --gNBs.[0].min_rxtxtime 6 --> To ensure that the rx tx time advance is 6 slots ``` * Optional: RUN OAI gNB with RF Simulator ```sh sudo RFSIMULATOR=server ./nr-softmodem --rfsim --sa -O [where the config file is] ``` * If you have 5G CN <font color=#FF0000> **!!! Check PLMN elements in config file to match with corresponding OAI CN !!!** </font> For example: ![](https://i.imgur.com/b3faHsP.png) ![](https://i.imgur.com/O5ACDSf.png) ## Run OAI UE #### Step 1 Only if you need to connect to 5G CN; or skip this step * Modify UE config file to match with the OAI CN database * There are two options to deploy it. 1. Modify UE's information to match the CN 2. Add UE's information into Database ```sh # UE Configuration <your oai directory>/openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf # Database (take oai_db2.sql for example) <your oai CN directory>/oai-cn5g-fed/docker-compose/oai_db2.sql ``` ![](https://i.imgur.com/TKchZD8.png) ``` uicc0 = { imsi = "208950000000031"; #SUPI key = "0C0A34601D4F07677303652C0462535B"; #secret key for imsi opc= "63bfa50ee6523365ff14c1f45f88737d"; #secret key for operator dnn= "oai"; nssai_sst=1; nssai_sd=1; } ``` #### Step 2: Run OAI UE with USRP B210 ```sh # Without 5G CN sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --sa -E --ue-fo-compensation # With 5G CN sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --sa -O [corresponding UE config file] -E # Optional With RF simulator sudo RFSIMULATOR=127.0.0.1 ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa --nokrnmod -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/ue.conf # -r: bandwidth in terms of RBs (default value 106) # -- numerology: numerology index (default value 1) # --band: NR band number (default value 78) # --C: downlink carrier frequency in Hz (default value 0) # --C0: uplink frequency offset for FDD in Hz (default value 0) # -s: SSB start subcarrier (default value 512) # --sa: Standalone mode # --ue-fo-compensation : frequency output conpensation ``` ## Installation ```shell= Install prerequisites A recent CMake (at least v3.15). On Ubuntu, you might want to use this PPA to install an up-to-date version. SWIG (at least v.4.0). We use SWIG as an interface generator to enable the multi-language feature (i.e., C/C++ and Python) for the xApps. Please, check your SWIG version (i.e, swig -version) and install it from scratch if necessary as described here: https://swig.org/svn.html or via the code below: $ git clone https://github.com/swig/swig.git $ cd swig $ ./autogen.sh $ ./configure --prefix=/usr/ $ make $ make install ``` ## Clone the FlexRIC project, build and install it. #### Step 1 ```shell= # i.e.: $ git clone https://gitlab.eurecom.fr/mosaic5g/flexric.git # i.e. git checkout v1.0.0 # There are rolling updates on `dev` branch that we consider unstable before releasing and tagging into master branch. # You can play with new features on dev branch checking it out with $git checkout dev instead of the command below $ git checkout <here put the release tag> ``` #### Step 2 ```shell= ## Build $ cd flexric && mkdir build && cd build && cmake .. && make ## Install You can install the Service Models (SM) in your computer via: $ sudo make install ``` ## Integration with OAI 4G/5G RAN #### Step 1 ```shell= $ git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git oai $ cd oai/ $ git checkout 2022.41 $ git am <pathtoflexricsrc>/flexric/multiRAT/oai/oai.patch -- whitespace=nowarn e.q. git am ../../../../flexric/multiRAT/oai/oai.patch --whitespace=nowarn $ source oaienv $ cd cmake_targets $ ./build_oai -I -w USRP -i #For OAI first time installation. it will install some dependencies $ ./build_oai --eNB --gNB -c -C -w USRP --ninja ``` #### Step 2 ```shell= Start some eNodeB/gNodeB Below an example with 5G or 4G OAI gNodeB/eNodeB # eNB $ cd oai/cmake_targets/ran_build/build $ sudo ./lte-softmodem -O path/to/flexric/multiRAT/oai/enb.band7.tm1.25PRB. usrpb210.replay.conf # gNB $ cd oai/cmake_targets/ran_build/build $ sudo ./nr-softmodem -O path/to/flexric/multiRAT/oai/gnb.sa.band78.fr1.106PRB.usrpb210.conf --sa -E -- continuous-tx ``` #### Step 3 ```shell= Start the nearRT-RIC $ ./build/examples/ric/nearRT-RIC Start different xApps e.g, start the monitoring xApp with build /examples/xApp/c/monitor /xapp_mac_rlc_pdcp_moni. The monitoring sequence diagram is represented below: ``` ![](https://hackmd.io/_uploads/rJkzwS0q2.png) ```shell= e.g, start the slicing control xApp via $ python3 build/examples/xApp/python3/xapp_slice_moni_ctrl.py. The controlling sequence diagram is represented below: ``` ![](https://hackmd.io/_uploads/H1ZOwBCc3.png) #### Step 3 ```shell= Start the nearRT-RIC $ ./build/examples/ric/nearRT-RIC Start different xApps e.g, start the monitoring xApp with build /examples/xApp/c/monitor /xapp_mac_rlc_pdcp_moni. The monitoring sequence diagram is represented below: ``` ## Example we will demonstrate the actual results of running the xApp, RIC ,emulator, or OAI gNB. We will describe some scenarios like following format (xApp, RIC, emulator). (xapp_gtp_moni, nearRT-RIC, emu_age) there is an xApp monitoring function that aims to monitor the gtp state of the gNB emulator. To begin, we need to start the nearRT-RIC process and then start the OAI gNB, which already has the Agent Library compiled. Upon starting up, the OAI gNB will try to send an E2 request message to nearRT-RIC to establish an SCTP connection. Next, we start the gtp monitoring xApp and wait for it to establish the SCTP connection to nearRT-RIC, which we refer to as E42 setup request. If the process completes without any errors, the xApp will start monitoring the gNB and send the subscription command. The gNB that receives the subscription will start indicating the relevant message to the xApp via the E2 Agent. If the gtp monitoring xApp stops, the result will be stored at the path: /tmp/. ```shell= # in the flexric folder # start up RIC $ cd /build/examples/ric/nearRT-RIC # start up emulator $ cd /build/examples/emulator/agent/emu_agent_gnb_cu #monitoring xApp $ cd /build/examples/xApp/c/monitor/xapp_gtp_moni ``` ![](https://hackmd.io/_uploads/rJpd22C93.png) (xapp_gtp_moni, nearRT-RIC, nr-softmodem) This scenario select OAI gNB to replace the emulator to demonstrate E2 interface between gNB and RIC can also be established. ```shell= # in the flexric folder # start up RIC $ cd /build/examples/ric/nearRT-RIC # OpenAirInterface gNB $ cd /build/examples/emulator/agent/emu_agent_gnb_cu #monitoring xApp $ cd /build/examples/xApp/c/monitor/xapp_gtp_moni ``` Start RIC ![](https://hackmd.io/_uploads/rJH5anR9h.png) Stop RIC ![](https://hackmd.io/_uploads/HJcipnR9n.png) ## MWNL Lab environment #### Run OAI gNB ![](https://hackmd.io/_uploads/SJaRo2Ac3.png) You can see the RNTI => 75ce ![](https://hackmd.io/_uploads/rkzSga0q3.png) ![](https://hackmd.io/_uploads/ry_lzaCq2.png) #### Run OAI UE ![](https://hackmd.io/_uploads/rJefrT0c3.png) ![](https://hackmd.io/_uploads/Sy_DraR92.png) ![](https://hackmd.io/_uploads/H1E_HTC9h.png)