---
# System prepended metadata

title: OAI Core-gNB-virtual UE deployment and E2E connection

---

# OAI Core-gNB-virtual UE deployment and E2E connection

:::info
## :dart: **Objective**: Make E2E connection.
:::


### :small_blue_diamond:**OS Information:**


![image](https://hackmd.io/_uploads/rk3eNhS86.png)


:::info
## :book: Architectural Implementation:
:::

![5gCN_gnbsim](https://hackmd.io/_uploads/H14lvjNUp.jpg)


:bookmark: **Reference**:
The necessary resources for this build are listed below.

| Author    | Context                    | Link                                                                 |
| --------- | -------------------------- | -------------------------------------------------------------------- |
|   Open OAI |   Build gNB and UE    | [OAI_gNB](https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/doc/NR_SA_Tutorial_COTS_UE.md#3-oai-gnb) |



:::success
 **OAI CN5G pre-requisites**
:::
:dart: Goal: Install Pre-requisties

:::info
**Step 1**- Installing Docker
:::
 :eye: **Note**- Add the GPG key from Docker to ensure the downloads are valid, and then install the package. To ensure the latest version.
 
 **1.1-** Update your existing list of packages:
 
      $ sudo apt update
 
 **1.2 -** install a few prerequisite packages which let apt use packages over HTTPS:
 
     $ sudo apt install apt-transport-https ca-certificates curl software-properties-common
 
**1.3-** Add the GPG key for the official Docker repository to your 
 system:
 
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

**1.4** Add the Docker repository to APT sources:

    $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

 This will also update our package database with the Docker packages from the newly added repo.
 
 **1.5** Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
 
     $ apt-cache policy docker-ce
     
docker-ce: Installed: (none) 
Candidate: 5:24.07.1-0ubuntu-focal 
Version table: 5:24.07.1-0ubuntu-focal 500 500
https://download.docker.com/linux/ubuntu focal/stable amd64 Packages

**1.6** Finally, install Docker:

    $ sudo apt install docker-ce
    
**1.7** process enabled to start on boot. Check that it’s running:
    
    $ sudo systemctl status docker
:::info
**Step 2**-  Installing Docker Compose
:::

**2.1** Download

    $ mkdir -p ~/.docker/cli-plugins/
    $ curl SL https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose
    
**2.2**  Set the correct permissions so that the docker compose command is executable:

    $ chmod +x ~/.docker/cli-plugins/docker-compose
    
**2.3** Verify that the installation was successful, you can run:

     $ docker compose version
:::danger
    Docker version v2.3.3
:::

:::info
**Step 3** — Install
:::
**3.1** Download

    $ git clone https://github.com/abhic137/OAI-5G-GNBSIM-SPGWU.git

**3.2** Change directory and docker compose

    $ cd OAI-5G-GNBSIM-SPGWU/5gcwithgnbsim
    $ sudo docker compose -f docker-compose-basic-nrf.yaml up -d
    
:::info
**Step 4-** Getting a gnbsim docker image
:::

    $ cd
    $ git clone https://gitlab.eurecom.fr/kharade/gnbsim.git
    $ cd gnbsim
    $ docker build --tag gnbsim:latest --target gnbsim --file docker/Dockerfile.ubuntu.22.04 .
    
    
:::danger
## :key: Configuration parameters docker-compose-gnbsim
:::

:::spoiler :eye: Expand to see.
```diff
version: '3.8'
services:
    gnbsim:
        container_name: gnbsim
        image: gnbsim:latest
        privileged: true
        environment:
            - MCC=208
            - MNC=95
            - GNBID=1
            - TAC=0x00a000
            - SST=222
            - SD=00007b
            - PagingDRX=v32
            - RANUENGAPID=0
            - IMEISV=35609204079514
            - MSIN=0000000031
            - RoutingIndicator=1234
            - ProtectionScheme=null
            - KEY=0C0A34601D4F07677303652C0462535B
            - OPc=63bfa50ee6523365ff14c1f45f88737d
            - DNN=default
            - URL=http://www.asnt.org:8080/
            - NRCellID=1
            - USE_FQDN=no
            - NGAPPeerAddr=192.168.70.132
            - GTPuLocalAddr=192.168.70.156
            - GTPuIFname=eth0
        networks:
            public_net:
                ipv4_address: 192.168.70.156
        healthcheck:
            test: /bin/bash -c "ip address show dev gtp-gnb"
            interval: 10s
            timeout: 5s
            retries: 5
    gnbsim2:
        container_name: gnbsim2
        image: gnbsim:latest
        privileged: true
        environment:
            - MCC=208
            - MNC=95
            - GNBID=2
            - TAC=0x00a000
            - SST=222
            - SD=00007b
            - PagingDRX=v32
            - RANUENGAPID=0
            - IMEISV=35609204079514
            - MSIN=0000000032
            - RoutingIndicator=1234
            - ProtectionScheme=null
            - KEY=0C0A34601D4F07677303652C0462535B
            - OPc=63bfa50ee6523365ff14c1f45f88737d
            - DNN=default
            - URL=http://www.asnt.org:8080/
            - NRCellID=1
            - USE_FQDN=no
            - NGAPPeerAddr=192.168.70.132
            - GTPuLocalAddr=192.168.70.157
            - GTPuIFname=eth0
        networks:
            public_net:
                ipv4_address: 192.168.70.157
        healthcheck:
            test: /bin/bash -c "ip address show dev gtp-gnb"
            interval: 10s
            timeout: 5s
            retries: 5
    gnbsim3:
        container_name: gnbsim3
        image: gnbsim:latest
        privileged: true
        environment:
            - MCC=208
            - MNC=95
            - GNBID=3
            - TAC=0x00a000
            - SST=222
            - SD=00007b
            - PagingDRX=v32
            - RANUENGAPID=0
            - IMEISV=35609204079514
            - MSIN=0000000033
            - RoutingIndicator=1234
            - ProtectionScheme=null
            - KEY=0C0A34601D4F07677303652C0462535B
            - OPc=63bfa50ee6523365ff14c1f45f88737d
            - DNN=default
            - URL=http://www.asnt.org:8080/
            - NRCellID=1
            - USE_FQDN=no
            - NGAPPeerAddr=192.168.70.132
            - GTPuLocalAddr=192.168.70.158
            - GTPuIFname=eth0
        networks:
            public_net:
                ipv4_address: 192.168.70.158
        healthcheck:
            test: /bin/bash -c "ip address show dev gtp-gnb"
            interval: 10s
            timeout: 5s
            retries: 5
    gnbsim4:
        container_name: gnbsim4
        image: gnbsim:latest
        privileged: true
        environment:
            - MCC=208
            - MNC=95
            - GNBID=4
            - TAC=0x00a000
            - SST=222
            - SD=00007b
            - PagingDRX=v32
            - RANUENGAPID=0
            - IMEISV=35609204079514
            - MSIN=0000000034
            - RoutingIndicator=1234
            - ProtectionScheme=null
            - KEY=0C0A34601D4F07677303652C0462535B
            - OPc=63bfa50ee6523365ff14c1f45f88737d
            - DNN=default
            - URL=http://www.asnt.org:8080/
            - NRCellID=1
            - USE_FQDN=no
            - NGAPPeerAddr=192.168.70.132
            - GTPuLocalAddr=192.168.70.159
            - GTPuIFname=eth0
        networks:
            public_net:
                ipv4_address: 192.168.70.159
        healthcheck:
            test: /bin/bash -c "ip address show dev gtp-gnb"
            interval: 10s
            timeout: 5s
            retries: 5
    gnbsim5:
        container_name: gnbsim5
        image: gnbsim:latest
        privileged: true
        environment:
            - MCC=208
            - MNC=95
            - GNBID=5
            - TAC=0x00a000
            - SST=222
            - SD=00007b
            - PagingDRX=v32
            - RANUENGAPID=0
            - IMEISV=35609204079514
            - MSIN=0000000035
            - RoutingIndicator=1234
            - ProtectionScheme=null
            - KEY=0C0A34601D4F07677303652C0462535B
            - OPc=63bfa50ee6523365ff14c1f45f88737d
            - DNN=default
            - URL=http://www.asnt.org:8080/
            - NRCellID=1
            - USE_FQDN=no
            - NGAPPeerAddr=192.168.70.132
            - GTPuLocalAddr=192.168.70.160
            - GTPuIFname=eth0
        networks:
            public_net:
                ipv4_address: 192.168.70.160
        healthcheck:
            test: /bin/bash -c "ip address show dev gtp-gnb"
            interval: 10s
            timeout: 5s
            retries: 5
## This version of gnbsim connects with AMF using, AMF FQDN not with AMF ip-addres (which is good for container world)
    gnbsim-fqdn:
        container_name: gnbsim-fqdn
        image: gnbsim:latest
        privileged: true
        environment:
            - MCC=208
            - MNC=95
            - GNBID=5
            - TAC=0x00a000
            - SST=222
            - SD=00007b
            - PagingDRX=v32
            - RANUENGAPID=0
            - IMEISV=35609204079514
            - MSIN=0000000035
            - RoutingIndicator=1234
            - ProtectionScheme=null
            - KEY=0C0A34601D4F07677303652C0462535B
            - OPc=63bfa50ee6523365ff14c1f45f88737d
            - DNN=default
            - URL=http://www.asnt.org:8080/
            - NRCellID=1
            - USE_FQDN=yes
            - AMF_FQDN=amf.oai-5gc.eur
            - GTPuIFname=eth0
        networks:
            public_net:
        healthcheck:
            test: /bin/bash -c "ip address show dev gtp-gnb"
            interval: 10s
            timeout: 5s
            retries: 5
networks:
    public_net:
        external:
            name: demo-oai-public-net
```

:::
                       
                                                             

:::info
**Step 5** - Running the core
:::

    $ cd OAI-5G-GNBSIM-SPGWU/5gcwithgnbsim
    $ sudo docker compose -f docker-compose-basic-nrf.yaml up -d
    $ sudo docker ps -a
    $ sudo docker logs --follow oai-amf

![image](https://hackmd.io/_uploads/BJi6qjS86.png)

:::info
**Step 6** - Running the gNB
:::

    $ cd OAI-5G-GNBSIM-SPGWU/5gcwithgnbsim
    $ sudo docker compose -f docker-compose-gnbsim.yaml up -d gnbsim
    $ sudo docker ps -a
![image](https://hackmd.io/_uploads/H11IhsH8p.png)


:::info
**Step 7** - Check if the UE got allocated an IP address.
:::

    $ docker logs gnbsim 2>&1 | grep "UE address:"

![image](https://hackmd.io/_uploads/HySmRiHL6.png)


:::info
**Step 8** - Ping test
:::
:bookmark: **8.1**  Here we ping UE from external DN container

    $ docker exec oai-ext-dn ping -c 3 12.1.1.2
    
![image](https://hackmd.io/_uploads/rk9fL6SL6.png)

    

:bookmark:  **8.2** Here we ping external DN from UE (gnbsim) container.

    $ gnbsim ping -c 3 -I 12.1.1.2 google.com
    
![image](https://hackmd.io/_uploads/SkX_IaSI6.png)



:construction: Progress...
 
 
##  Deployment
:::info
Install gNB

Test finished

- 
:::


    








