aligungr / UERANSIM

Open source 5G UE and RAN (gNodeB) implementation.
GNU General Public License v3.0
793 stars 322 forks source link

HOW TO CONNECT MY DHT11 temperature and humidity sensor to Free5GC using UERANSIM #363

Closed Nawi98 closed 3 years ago

Nawi98 commented 3 years ago

Hello Sir @aligungr hope you're doing well. First of all congrats for the quality of your work and thanks for your reactivity when it comes to answers. I am working on 5G SA(Standalone) and my aim is to retrieve the data from my DHT11 sensor via the 5G network, in order to view them on my graphical interface(I am deploying an end-to-end solution). I am using the Free5GC docker image (see https://hub.docker.com/r/free5gc/amf). The issue is that I don't find out how to substitute the UE with my sensor on the UERANSIM Here is the architecture of my solution. Best regards. PoC's architecture

infinitydon commented 3 years ago

I think you will have to find a way to install UERANSIM UE in your embedded device (maybe raspberry PI + Arduino) and initiate the connection from there to the UERANSIM gnb.

Nawi98 commented 3 years ago

Hello @infinitydon ,I appreciate the time u've taken to give me an answer. I really do I will try to do so and I ll give you a feedback. I am just wondering if the UERANSIM is able to get data from the Rapsberry PI's input values?

infinitydon commented 3 years ago

What I think you should do is to run your IOT protocol over the ueransim interface, so ueransim does not need to read input values (that should be taken care of by your IOT program)..

For example you can use the nr-binder to run commands over the ueransim interface, you can check the usage documentation:

https://github.com/aligungr/UERANSIM/wiki/Usage#using-the-tun-via-nr-binder

Another example is if your IOT uses HTTP to transfer the values, then you can use curl to send it over the ueransim interface:

./nr-binder 10.45.0.2 curl google.com

I believe the mosquito protocol should also work like this.

Nawi98 commented 3 years ago

Okay I feel you far better now.

Thanks a lot.

My IoT protocol is MQTT( its architecture is MQTT client (here UERANSIM) + Broker(here my Mosquitto) + MQTT subscriber(Here Node-RED) ). I just hope that MQTT is handled by ./nr-binder I attached a file that fits with what u've adviced me to do(could u correct me please if it doesn't match with ur sayings).

I am checking ur solution and then I'll tell u.

Thanks again. RAN part

infinitydon commented 3 years ago

Yes, that fits what I was describing, even if nr-binder does not support MQTT, you can initiate the MQTT using the uesimtun0 interface e.g sudo curl --interface uesimtun0 google.com

Nawi98 commented 3 years ago

Hello hope u re doing well.

### I've done several researches to find out a way to install UERANSIM UE on my raspberry PI but I couldn't, if ever u ve found smthing please let me now Sir.

In addition once my data are sent though the free5GC , how will I retrieve them on my Broker(here Mosquitto) instead of "throwing" it into the internet?

Here is a link where u ll find out the essentials/features when it comes to MQTT https://www.hivemq.com/mqtt-essentials/. Thanks again for ur help.

infinitydon commented 3 years ago

Hi @Nawi98 - I decided to try to set this up using MQTT protocol, so basically below is the flow:

mosquitto_pub ---> uesimtun0 (10.45.0.2) ---> ueransim-gnb---->open5gs-5gcore-upf----->ThingsBoard Container (172.21.0.113)

The command I used to send the mqtt traffic over the ueransim interface is:

root@49b632b982a1:/UERANSIM/build# mosquitto_pub -A "10.45.0.2" -d -q 1 -h "172.21.0.113" -p "1883" -t "v1/devices/me/telemetry" -u "A1_TEST_TOKEN" -m {"temperature":25}
Client mosqpub|113-49b632b982a sending CONNECT
Client mosqpub|113-49b632b982a received CONNACK
Client mosqpub|113-49b632b982a sending PUBLISH (d0, q1, r0, m1, 'v1/devices/me/telemetry', ... (16 bytes))
Client mosqpub|113-49b632b982a received PUBACK (Mid: 1)
Client mosqpub|113-49b632b982a sending DISCONNECT

So using _mosquittopub client, you can specify which IP you want to initiate the mqtt operation which in this case is 10.45.0.2 (the IP ueransin UE got from the 5g core).

root@49b632b982a1:/UERANSIM/build# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: uesimtun0: <POINTOPOINT,PROMISC,NOTRAILERS,UP,LOWER_UP> mtu 1400 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none
    inet 10.45.0.2/32 scope global uesimtun0
       valid_lft forever preferred_lft forever
37900: eth0@if37901: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:15:00:70 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.21.0.112/24 brd 172.21.0.255 scope global eth0

As for ueransim installation on raspberry PI, since it is based on ARM architecture then you should not have any issues compiling/building it, I have tested this using a ARM based system and the build was successful. Have you tried the installation guide in the wiki yet?

infinitydon commented 3 years ago

If you are interested this is the docker-compose manifest I used:

https://bitbucket.org/infinitydon/open5gs-5gcore-ueransim-iot-docker-compose

infinitydon commented 3 years ago

Hi,

I suggest you try this first, if you encounter any issues, then we can assist you. You can use any thingsboard container image, just edit the docker-compose file.

Also I am using open5gs because that's what I am used to, free5gc will still work but you will need to modify the docker-compose file.

Whatever protocol you are using as long as it is TCP/IP, it should work.

Nawi98 commented 3 years ago

Hello

Okay I am on it.

Thanks again.

Good bye

Nawi98 commented 3 years ago

Have done several researches on the http2 error cause and I had tested the solutions proposed but it didn't resolve the issue. My question is: Like my containers run, so does the WebUI it that compulsory that my NRF runs also(since the main 5G core functions are AMF,AUSF,UPF,SMF,UDM). If not I'll move on and get into UERANSIM installation. Thx Sir for ur reactivity. Best regards.

infinitydon commented 3 years ago

NRF is important, that is where the service discovery takes place, the NRF issue has to be sorted first before you proceed.

For the protocol error, make sure you are using the same SBI scheme across all your config:

image

Nawi98 commented 3 years ago

Hi nrfD Most of the yaml files have that SBI scheme , some others don't have a SBI scheme and finally the udrcfg1.yaml and the udrcfgb.yaml are empty. Since I've followed step by step the installation guide, don't get what went wrong. I'll continue the researches to fix it.If it still occurs,I ll move on and use the https://bitbucket.org/infinitydon/open5gs-5gcore-ueransim-iot-docker-compose (maybe is it less problematic)... If it can help I'm using a VM based on Ubuntu 18.04.

Nawi98 commented 3 years ago

Hello I finally fixed the nrf issue : I've created a new 20.04 based-on virtual machine. itWorked

And execute the following commands s Thx again for ur help Sir.

Unfortunately got now these issues : upf2 | 2021-07-25T01:10:48Z [ERRO][UPF][Util] gtp5g device named upfgtp created fail upf2 | 2021-07-25T01:10:48Z [ERRO][UPF][Util] Gtp5gDeviceAdd failed

upfb | 2021-07-25T01:10:45Z [ERRO][UPF][Util] gtp5g device named upfgtp created fail upfb | 2021-07-25T01:10:45Z [ERRO][UPF][Util] Gtp5gDeviceAdd failed upfb | 2021-07-25T01:11:09Z [INFO][UPF][Util] [PFCP] Handle PFCP association setup request upfb | 2021-07-25T01:11:09Z [INFO][UPF][Util] [PFCP] Association Setup Response

infinitydon commented 3 years ago

Please https://github.com/free5gc/free5gc/wiki/Installation#a-prerequisites for the kernel requirement that is needed by the UPF

Nawi98 commented 3 years ago

Hello Sir hope u're doing good.

May I see ur open5gs-gnb.yaml and open5gs-ue.yaml files please .

Best regards.

infinitydon commented 3 years ago

They are in the same repo I shared earlier:

https://bitbucket.org/infinitydon/open5gs-5gcore-ueransim-iot-docker-compose/src/master/config/

image

Nawi98 commented 3 years ago

Hello hope u're doing well. I'm experimenting issues when I ran the docker-compose command after I followed the https://bitbucket.org/infinitydon/open5gs-5gcore-ueransim-iot-docker-compose/src/master/'s ReadMe. I am pretty sure that my configurations aren't okay May u tell me where I am wrong please (I mean is there missing commands?). I ran these ones trying to follow the ReadMe:

mkdir -p ~/.mytb-data && sudo chown -R 799:799 ~/.mytb-data mkdir -p ~/.mytb-logs && sudo chown -R 799:799 ~/.mytb-logs git clone https://bitbucket.org/infinitydon/open5gs-5gcore-ueransim-iot-docker-compose.git docker-compose build docker-compose up

Best regards.

infinitydon commented 3 years ago

@Nawi98 - You can chat me up on linkedin (https://www.linkedin.com/in/christopher-gbenga-adigun-731b8115/), we can have a call to check this together.

Nawi98 commented 3 years ago

Hello hope u 're doing good Sorry for the delay just saw the message. It's okay for me. My linkedin profile is on https://www.linkedin.com/in/aminata-willane-9819961a1/ and I just wrote u a message on Linkedin to get connect to ur profile. Could u please check it. Regards.

Nawi98 commented 3 years ago

Hello @infinitydon. First of all I ll never thank u enough for ur help. The flow is : uesimtun0 (10.45.0.2) ---> ueransim-gnb---->open5gs-5gcore-upf----->ThingsBoard Container (172.21.0.113) Stack used : -a Raspberry PI model B 8 GB

-a Raspberry PI imager (https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi#2-prepare-the-sd-card) so that u'll be able to boot ur OS on the SD card(used 20.04.3 LTS ubuntu server 64 bits)

-a Virtual Box VM running on Ubuntu server 20.04 LTS

-this docker compose for the core network : https://bitbucket.org/infinitydon/open5gs-5gcore-ueransim-iot-docker-compose/src/master/

-the UERANSIM software(installation part) : https://github.com/aligungr/UERANSIM/wiki/Installation

To build up that project here are the main steps followed :

  1. SSH connexion between the Raspberry PI and the physical desktop

  2. wifi interface configuration so that u'll have internet to compile the UERANSIM on ur Raspberry PI (https://linuxconfig.org/ubuntu-20-04-connect-to-wifi-from-command-line)

  3. run these 2 commands : sudo docker volume create --name=mytb-data sudo docker volume create --name=mytb-logs 4.when it comes to the docker-compose on the upf, add that advertise line

    upf

    here the IP address is my VM's IP address

  4. in the gnb confiration file change the ngapIP, gtpIP into ur Raspberry address and ur amfConfigs address into ur VM IP address

  5. create subscriber into the webUI interface with the same attributes in the UE configuration file of ur Raspberry(IMSI,key,op)

  6. for the Thingboard part u can access to it via 172.21.0.9090 then please use that link : https://thingsboard.io/docs/samples/raspberry/temperature/ here isthe lines I changed in the python code (THINGSBOARD_HOST = '172.21.0.113' ACCESS_TOKEN = 'ur access token' Uesimtun0 = 'ur uesimtun0 IP address mine was 10.45.0.2' ) In json.file(when importing the Dasboard in thingsboard just change ur device ID)

Thx again Sir.