Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to setup/configure GW interface #296

Open
hududed opened this issue Apr 1, 2024 · 30 comments
Open

Failed to setup/configure GW interface #296

hududed opened this issue Apr 1, 2024 · 30 comments

Comments

@hududed
Copy link

hududed commented Apr 1, 2024

Awhile back you helped me setup 5GC gnb and ue on a single host machine:

# 5G Core Network
docker compose -f sa-deploy.yaml up

# srsRAN ZMQ gNB (RF simulated)
docker compose -f srsgnb_zmq.yaml up -d && docker container attach srsgnb_zmq

# srsRAN ZMQ 5G UE (RF simulated)
docker compose -f srsue_5g_zmq.yaml up -d && docker container attach srsue_5g_zmq

That works and I can ping both in from the srsGNB to srsue containers and vice versa

However, I noticed the GW interface failing:

Opening 1 channels in RF device=zmq with args=tx_port=tcp://172.22.0.34:2001,rx_port=tcp://172.22.0.37:2000,id=ue,base_srate=23.04e6
Supported RF device list: UHD soapy bladeRF zmq file
CHx base_srate=23.04e6
CHx id=ue
Current sample rate is 1.92 MHz with a base rate of 23.04 MHz (x12 decimation)
CH0 rx_port=tcp://172.22.0.37:2000
CH0 tx_port=tcp://172.22.0.34:2001
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Waiting PHY to initialize ... done!
Attaching UE...
Random Access Transmission: prach_occasion=0, preamble_index=0, ra-rnti=0x39, tti=334
Random Access Complete.     c-rnti=0x4601, ta=0
RRC Connected
Failed to setup/configure GW interface
RRC NR reconfiguration successful.

in the ue_5g_zmq.conf, I set the GW as so:

[gw]
netns = ue1 
ip_devname = tun_srsue
ip_netmask = 255.255.255.0

My end goal is to experiment configuring single/multi UE (with gnuradio), and collecting IQ data - and I assume I need the GW interface for this.

@herlesupreeth
Copy link
Owner

hmm..I think you setting the following in ue_5g_zmq.conf is the issue. Maybe the container does not have permission to add network namespace. But may I know why you want to configure namespace? IMO, you dont need it since UE is running in a separate container its already under separate namespace

[gw]
netns = ue1 
ip_devname = tun_srsue
ip_netmask = 255.255.255.0

@hududed
Copy link
Author

hududed commented Apr 3, 2024

Hm, I was trying to relate this back to the srsRAN_Project. But ultimately I want to just generate data with different parameters e.g. channel bandwidth, SNR, modulation schemes, subcarrier spacing - is this something that's do-able with with the srsRAN UE GNB setup?

@herlesupreeth
Copy link
Owner

But ultimately I want to just generate data with different parameters e.g. channel bandwidth, SNR, modulation schemes, subcarrier spacing

Generating traffic with different channel bandwidth, SNR, modulation schemes is possible but not different subcarrier spacing because srsRAN UE does not support anything other than 15Khz SCS.

@hududed
Copy link
Author

hududed commented Apr 4, 2024

would you happen to know or can recommend any tutorials on that generating IQ traffic with those parameters using srsRAN? Sorry a bit off-topic but I am fairly new to the space.

@herlesupreeth
Copy link
Owner

Well, you can use typically iperf tool to generate traffic end-to-end i.e. run iperf server/client at UE and viceversa in UPF iperf client/server.

For changes in parameters you can change in the configuration file which are present in respective folders in this repo

@hududed
Copy link
Author

hududed commented Apr 5, 2024

That works for the network traffic - but my bad, I meant recording the spectrum IQ data transmitted. I've used in the past gnuradio to visualize and record this. But not sure if this would work over docker.

# ue_5g_zmq.conf
device_args = tx_port=tcp://SRS_UE_IP:2001,rx_port=tcp://SRS_GNB_IP:2000,id=ue,base_srate=23.04e6

# gnb_zmq.conf
device_args = fail_on_disconnect=true,tx_port=tcp://SRS_ENB_IP:2000,rx_port=tcp://SRS_UE_IP:2001,id=enb,base_srate=23.04e6

Is there a way to expose this so that gnuradio can access them?
Also, I can create a separate issue as this is not related to the current one

@herlesupreeth
Copy link
Owner

I meant recording the spectrum IQ data transmitted

Hmm, its possible. IP and ports you give in the ue_5g_zmq.conf and gnb_zmq.conf should be the ZMQ ports opened in Gnuradio and ensure connection is complete.

I havent experimented what mentioned above but I have used Gnuradio to test SINR ramping of srsRAN_Project gNB with Amarisoft UE using a Gnuradio to vary SINR etc

@hududed
Copy link
Author

hududed commented Apr 11, 2024

@herlesupreeth

version: "3"
services:
  srsgnb_zmq:
    image: docker_srsran
    container_name: srsgnb_zmq
    stdin_open: true
    tty: true
    privileged: true
    volumes:
      - ./srsran:/mnt/srsran
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    environment:
      - COMPONENT_NAME=gnb_zmq
    ports:
      - "38412:38412/sctp"
      - "2152:2152/udp"
      - "2000:2000/tcp"
      - "2001:2001/tcp"
    networks:
      default:
        ipv4_address: ${SRS_GNB_IP}
networks:
  default:
    external:
      name: docker_open5gs_default

If I understand it right I have to change from expose to ports in order to expose it to the host so I changed that above.
However, now gnb doesnt connect.

❯ docker compose -f srsgnb_zmq.yaml up -d && docker container attach srsgnb_zmq
WARN[0000] networks.default: external.name is deprecated. Please set name and external: true 
WARN[0000] Found orphan containers ([srsue_5g_zmq upf smf amf nssf bsf ausf udm udr pcf webui scp nrf mongo metrics]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. 
[+] Running 1/1
 ✔ Container srsgnb_zmq  Started                                                                                                                                                         0.0s 

The PRACH detector will not meet the performance requirements with the configuration {Format 0, ZCZ 0, SCS 1.25kHz, Rx ports 1}.
2024-04-11T19:19:47.586625 [GNB     ] [W] Could not check scaling governor. filename=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor error="No such file or directory"
2024-04-11T19:19:47.586639 [GNB     ] [W] Could not check DRM KMS polling. filename=/sys/module/drm_kms_helper/parameters/poll error="No such file or directory"
Lower PHY in executor blocking mode.

--== srsRAN gNB (commit 55c984b55) ==--

Connecting to AMF on 172.22.0.10:38412
Failed to connect SCTP socket to 172.22.0.10:38412. error="Connection timed out" timeout=1362ms
srsGNB ERROR: Failed to create SCTP gateway.

Sorry, google gives me conflicting answers e.g. sctp ports are not handled by docker. How would one configure the ports in AMF, GNB and UE? My understanding is that AMF should open ports (not expose) 38412 sctp, GNB should expose 38412 and open ports 2000 & 2001, while UE expose ports 2000 & 2001 - is this roughly right?

@herlesupreeth
Copy link
Owner

If you are running srsgnb_zmq and open5gs in same machine then dont publish the SCTP ports and UDP ports

i.e. expose only the ports you want for gnuradio

ports:
      - "2000:2000/tcp"
      - "2001:2001/tcp"

Here is the laymen terms explanation of using expose or ports. You use expose if you want those ports to be use by another service running on the same machine and you use ports when you want another service running on another machine to see those ports.

So just exposing of SCTP and UDP ports between gNB and AMF/UPF is just fine since you are running both in same machine.

If you plan to run gnuradio also in same machine then expose is just fine no need to use ports for those ZMQ ports

@hududed
Copy link
Author

hududed commented Apr 15, 2024

So you mean leave it as it is expose? Cant seem access with gnuradio. This is with RRC established:

image

Could you check if my inputs (IP, ports) are correct?

@herlesupreeth
Copy link
Owner

herlesupreeth commented Apr 17, 2024

Hey,

I havent experimented what mentioned above but I have used Gnuradio to test SINR ramping of srsRAN_Project gNB with Amarisoft UE using a Gnuradio to vary SINR etc

Here are the configurations I used to have ZMQ in between gNB and UE

At gNB

device_args: tx_port=tcp://172.22.0.1:5000,rx_port=tcp://172.22.0.1:6001

At UE

device_args = tx_port=tcp://SRS_UE_IP:6000,rx_port=tcp://SRS_GNB_IP:5001,id=ue,base_srate=23.04e6

And, in GNURadio python script I had the following lines to interconnect them

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_req_source_3_0 = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://{ue_ip}:6000', 100, False, -1)
        self.zeromq_req_source_3_0.set_block_alias("UE TX")
        self.zeromq_req_source_3 = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://{gnb_ip}:5000', 100, False, -1)
        self.zeromq_req_source_3.set_block_alias("gNB TX")
        self.zeromq_rep_sink_0_0 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://{gnb_ip}:6001', 100, False, -1)
        self.zeromq_rep_sink_0_0.set_block_alias("gNB RX")
        self.zeromq_rep_sink_0 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://{ue_ip}:5001', 100, False, -1)
        self.zeromq_rep_sink_0.set_block_alias("UE RX")
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, math.pow(10.0,(-12.0-self.snr)/20.0), 42)

Then, while testing the sequence of bring up is as follows: (this sequence is very important)

  1. First start the GNURadio
  2. Then gNB and lastly UE

@hududed
Copy link
Author

hududed commented Apr 17, 2024

So I made those changes to the yaml, and changed to expose:

    # gnb
    expose:
      - "38412/sctp"
      - "2152/udp"
      - "5000/tcp" # tx
      - "5001/tcp" # rx
      
    # ue
    expose:
      - "6000/tcp" # rx
      - "6001/tcp" # tx

But now it just gets stuck (without even running gnuradio)

❯ docker compose -f srsue_5g_zmq.yaml up -d && docker container attach srsue_5g_zmq
WARN[0000] networks.default: external.name is deprecated. Please set name and external: true 
WARN[0000] Found orphan containers ([srsgnb_zmq upf smf amf nssf udr pcf udm ausf bsf webui nrf metrics scp mongo]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. 
[+] Running 1/1
 ✔ Container srsue_5g_zmq  Started                                                                                                                                                0.4s 
Active RF plugins: libsrsran_rf_uhd.so libsrsran_rf_soapy.so libsrsran_rf_blade.so libsrsran_rf_zmq.so
Inactive RF plugins: 
Couldn't open , trying /root/.config/srsran/ue.conf
Couldn't open /root/.config/srsran/ue.conf either, trying /etc/srsran/ue.conf
Reading configuration file /etc/srsran/ue.conf...

Built in Release mode using commit 4eb990c9c on branch HEAD.

Opening 1 channels in RF device=zmq with args=tx_port=tcp://172.22.0.34:6000,rx_port=tcp://172.22.0.37:5001,id=ue,base_srate=23.04e6
Supported RF device list: UHD soapy bladeRF zmq file
CHx base_srate=23.04e6
CHx id=ue
Current sample rate is 1.92 MHz with a base rate of 23.04 MHz (x12 decimation)
CH0 rx_port=tcp://172.22.0.37:5001
CH0 tx_port=tcp://172.22.0.34:6000
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Waiting PHY to initialize ... done!
Attaching UE...

@herlesupreeth
Copy link
Owner

hmm.. it could be a NATing issue of docker network. Please try the following

At gNB

device_args: tx_port=tcp://172.22.0.1:5000,rx_port=tcp://*:6001

At UE

device_args = tx_port=tcp://SRS_UE_IP:6000,rx_port=tcp://*:5001,id=ue,base_srate=23.04e6

And, in GNURadio python script I had the following lines to interconnect them

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_req_source_3_0 = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://*:6000', 100, False, -1)
        self.zeromq_req_source_3_0.set_block_alias("UE TX")
        self.zeromq_req_source_3 = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://*:5000', 100, False, -1)
        self.zeromq_req_source_3.set_block_alias("gNB TX")
        self.zeromq_rep_sink_0_0 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://{gnb_ip}:6001', 100, False, -1)
        self.zeromq_rep_sink_0_0.set_block_alias("gNB RX")
        self.zeromq_rep_sink_0 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://{ue_ip}:5001', 100, False, -1)
        self.zeromq_rep_sink_0.set_block_alias("UE RX")
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, math.pow(10.0,(-12.0-self.snr)

@hududed
Copy link
Author

hududed commented Apr 18, 2024

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_req_source_1 = zeromq.req_source(gr.sizeof_gr_complex, 1, 'tcp://*:6000', 100, False, -1)
        self.zeromq_req_source_1.set_block_alias("UE TX")
        self.zeromq_req_source_0 = zeromq.req_source(gr.sizeof_gr_complex, 1, 'tcp://*:5000', 100, False, -1)
        self.zeromq_req_source_0.set_block_alias("gNB TX")
        self.zeromq_rep_sink_1 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, 'tcp://172.22.0.34:5001', 100, False, -1)
        self.zeromq_rep_sink_1.set_block_alias("UE RX")
        self.zeromq_rep_sink_0 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, 'tcp://172.22.0.37:6001', 100, False, -1)
        self.zeromq_rep_sink_0.set_block_alias("gNB RX")
Traceback (most recent call last):
  File "/home/hud/docker_open5gs/untitled.py", line 219, in <module>
    main()
  File "/home/hud/docker_open5gs/untitled.py", line 197, in main
    tb = top_block_cls()
  File "/home/hud/docker_open5gs/untitled.py", line 82, in __init__
    self.zeromq_req_source_1 = zeromq.req_source(gr.sizeof_gr_complex, 1, 'tcp://*:6000', 100, False, -1)
RuntimeError: Invalid argument

Cant run the gnuradio with this. Should Rx or Tx be * ?

@hududed
Copy link
Author

hududed commented Apr 18, 2024

gnuradio does run when I make TX * :

device_args = fail_on_disconnect=true,tx_port=tcp://*:5000,rx_port=tcp://SRS_UE_IP:6001
device_args = tx_port=tcp://*:6000,rx_port=tcp://172.22.0.1:5001,id=ue,base_srate=23.04e6
        self.zeromq_req_source_1 = zeromq.req_source(gr.sizeof_gr_complex, 1, 'tcp://172.22.0.34:6000', 100, False, -1)
        self.zeromq_req_source_1.set_block_alias("UE TX")
        self.zeromq_req_source_0 = zeromq.req_source(gr.sizeof_gr_complex, 1, 'tcp://172.22.0.37:5000', 100, False, -1)
        self.zeromq_req_source_0.set_block_alias("gNB TX")
        self.zeromq_rep_sink_1 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, 'tcp://*:5001', 100, False, -1)
        self.zeromq_rep_sink_1.set_block_alias("UE RX")
        self.zeromq_rep_sink_0 = zeromq.rep_sink(gr.sizeof_gr_complex, 1, 'tcp://*:6001', 100, False, -1)

But gets stuck at attaching again:

Opening 1 channels in RF device=zmq with args=tx_port=tcp://*:6000,rx_port=tcp://172.22.0.1:5001,id=ue,base_srate=23.04e6
Supported RF device list: UHD soapy bladeRF zmq file
CHx base_srate=23.04e6
CHx id=ue
Current sample rate is 1.92 MHz with a base rate of 23.04 MHz (x12 decimation)
CH0 rx_port=tcp://172.22.0.1:5001
CH0 tx_port=tcp://*:6000
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Waiting PHY to initialize ... done!
Attaching UE...

@herlesupreeth
Copy link
Owner

sorry, my understanding was wrong. I tested it on my end with the below diff and UE attached with GNUradio in between them

diff --git a/srsgnb_zmq.yaml b/srsgnb_zmq.yaml
index 0da47a9..2399f0e 100644
--- a/srsgnb_zmq.yaml
+++ b/srsgnb_zmq.yaml
@@ -17,8 +17,8 @@ services:
     expose:
       - "38412/sctp"
       - "2152/udp"
-      - "2000/tcp"
-      - "2001/tcp"
+      - "5000/tcp"
+      - "6001/tcp"
     networks:
       default:
         ipv4_address: ${SRS_GNB_IP}
diff --git a/srslte/ue_5g_zmq.conf b/srslte/ue_5g_zmq.conf
index 6ad33dc..c74b4fb 100644
--- a/srslte/ue_5g_zmq.conf
+++ b/srslte/ue_5g_zmq.conf
@@ -43,7 +43,7 @@ srate = 23.04e6
 
 # Example for ZMQ-based operation with TCP transport for I/Q samples
 device_name = zmq
-device_args = tx_port=tcp://SRS_UE_IP:2001,rx_port=tcp://SRS_GNB_IP:2000,id=ue,base_srate=23.04e6
+device_args = tx_port=tcp://*:6000,rx_port=tcp://172.22.0.1:5001,id=ue,base_srate=23.04e6
 
 #####################################################################
 # EUTRA RAT configuration
diff --git a/srsran/gnb_zmq.yml b/srsran/gnb_zmq.yml
index 1107d7f..670f6dd 100644
--- a/srsran/gnb_zmq.yml
+++ b/srsran/gnb_zmq.yml
@@ -4,7 +4,7 @@ amf:
 
 ru_sdr:
   device_driver: zmq                                                                          # The RF driver name.
-  device_args: tx_port=tcp://SRS_GNB_IP:2000,rx_port=tcp://SRS_UE_IP:2001,base_srate=23.04e6  # Optionally pass arguments to the selected RF driver.
+  device_args: tx_port=tcp://*:5000,rx_port=tcp://172.22.0.1:6001,base_srate=23.04e6  # Optionally pass arguments to the selected RF driver.
   srate: 23.04                                                                                # RF sample rate might need to be adjusted according to selected bandwidth.
   tx_gain: 75                                                                                 # Transmit gain of the RF might need to adjusted to the given situation.
   rx_gain: 75                                                                                 # Receive gain of the RF might need to adjusted to the given situation.
diff --git a/srsue_5g_zmq.yaml b/srsue_5g_zmq.yaml
index 75a23c7..fb402f9 100644
--- a/srsue_5g_zmq.yaml
+++ b/srsue_5g_zmq.yaml
@@ -17,8 +17,8 @@ services:
     environment:
       - COMPONENT_NAME=ue_5g_zmq
     expose:
-      - "2000/tcp"
-      - "2001/tcp"
+      - "6000/tcp"
+      - "5001/tcp"
     networks:
       default:
         ipv4_address: ${SRS_UE_IP}

And, in Gnuradio the following

        ##################################################
        # Blocks
        ##################################################
        self.zmq_source_ue_tx = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://{ue_ip}:6000', 100, False, -1)
        self.zmq_source_ue_tx.set_block_alias("UE TX")
        self.zmq_source_gnb_tx = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://{gnb_ip}:5000', 100, False, -1)
        self.zmq_source_gnb_tx.set_block_alias("gNB TX")
        self.zmq_sink_gnb_rx = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://*:6001', 100, False, -1)
        self.zmq_sink_gnb_rx.set_block_alias("gNB RX")
        self.zmq_sink_ue_rx = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://*:5001', 100, False, -1)
        self.zmq_sink_ue_rx.set_block_alias("UE RX")

@hududed
Copy link
Author

hududed commented Apr 22, 2024

Oh, you made changes in srsran/gnb_zmq.yaml but didn't change anything in the srslte/gnb_zmq.conf file?

@herlesupreeth
Copy link
Owner

srslte/gnb_zmq.conf is no not used at all for quite some time. For 5G RAN I completely use srsRAN_Project and not srsRAN_4G.

@hududed
Copy link
Author

hududed commented Apr 22, 2024

Ok - I got hopeful because I thought my error was not updating srsran/gnb_zmq.yaml, but I've left srslte/gnb_zmq.conf untouched, updated srsran/gnb_zmq.yaml and all that was mentioned above. I started gnuradio first, then core, then gnb and then UE but it is still stuck at attaching UE.

I am sure you must be extremely busy but is it possible to jump on a quick call and see what I am doing wrong?

@herlesupreeth
Copy link
Owner

hmm, here is the python function to initialize gnuradio flowgraph

    def __init__(self, ue_ip, gnb_ip, initial_snr_db=50):
        gr.top_block.__init__(self, "Testin with Gnuradio", catch_exceptions=True)

        ##################################################
        # Variables
        ##################################################
        self.snr_ul = initial_snr_db
        self.snr_dl = initial_snr_db

        ##################################################
        # Blocks
        ##################################################
        self.zmq_source_ue_tx = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://{ue_ip}:6000', 100, False, -1)
        self.zmq_source_ue_tx.set_block_alias("UE TX")
        self.zmq_source_gnb_tx = zeromq.req_source(gr.sizeof_gr_complex, 1, f'tcp://{gnb_ip}:5000', 100, False, -1)
        self.zmq_source_gnb_tx.set_block_alias("gNB TX")
        self.zmq_sink_gnb_rx = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://*:6001', 100, False, -1)
        self.zmq_sink_gnb_rx.set_block_alias("gNB RX")
        self.zmq_sink_ue_rx = zeromq.rep_sink(gr.sizeof_gr_complex, 1, f'tcp://*:5001', 100, False, -1)
        self.zmq_sink_ue_rx.set_block_alias("UE RX")
        self.add_block_ul = blocks.add_vcc(1)
        self.add_block_dl = blocks.add_vcc(1)
        self.awgn_source_ul = analog.noise_source_c(analog.GR_GAUSSIAN, math.pow(10.0,(-12.0-self.snr_ul)/20.0), 42)
        self.awgn_source_dl = analog.noise_source_c(analog.GR_GAUSSIAN, math.pow(10.0,(-12.0-self.snr_dl)/20.0), 42)


        ##################################################
        # Connections
        ##################################################
        # Connect UE --> gNB (UL)
        self.connect((self.awgn_source_ul, 0), (self.add_block_ul, 0))
        self.connect((self.add_block_ul, 0), (self.zmq_sink_gnb_rx, 0))
        self.connect((self.zmq_source_ue_tx, 0), (self.add_block_ul, 1))
        # Connect gNB --> UE (DL)
        self.connect((self.awgn_source_dl, 0), (self.add_block_dl, 0))
        self.connect((self.zmq_source_gnb_tx, 0), (self.add_block_dl, 1))
        self.connect((self.add_block_dl, 0), (self.zmq_sink_ue_rx, 0))

I am sure you must be extremely busy but is it possible to jump on a quick call and see what I am doing wrong?

sorry, I dont do calls

@hududed
Copy link
Author

hududed commented Apr 23, 2024

Thanks for that but the problem occurs even without gnuradio. I think I will try to reinstall everything, docker included. Can you confirm the steps - in particular do you make those diff changes above before building?

git clone https://github.com/herlesupreeth/docker_open5gs
cd docker_open5gs/base
docker build --no-cache --force-rm -t docker_open5gs .
# install 4G 5G with diff changes or as-is?
cd ../srslte
docker build --no-cache --force-rm -t docker_srslte .
cd ../srsran
docker build --no-cache --force-rm -t docker_srsran .

@herlesupreeth
Copy link
Owner

The above diff does not require rebuilding of images. Just re-running gNB and UE should be fine

but the problem occurs even without gnuradio

This is normal. UE wont connect to gNB without the gnuradio since there is no link. gnuradio is the connecting entity which completes the RF, in turn allowing UE to connect gNB

@hududed
Copy link
Author

hududed commented Apr 25, 2024

from dotenv import load_dotenv
from gnuradio import blocks, zeromq, analog, gr
import math
import os

load_dotenv()


class GNUflow(gr.top_block):  # Replace with your actual class name
    def __init__(self, ue_ip, gnb_ip, initial_snr_db=50):
        gr.top_block.__init__(self, "Testin with Gnuradio")

        ##################################################
        # Variables
        ##################################################
        self.snr_ul = initial_snr_db
        self.snr_dl = initial_snr_db

        ##################################################
        # Blocks
        ##################################################
        self.zmq_source_ue_tx = zeromq.req_source(
            gr.sizeof_gr_complex, 1, f"tcp://{ue_ip}:6000", 100, False, -1
        )
        self.zmq_source_ue_tx.set_block_alias("UE TX")
        self.zmq_source_gnb_tx = zeromq.req_source(
            gr.sizeof_gr_complex, 1, f"tcp://{gnb_ip}:5000", 100, False, -1
        )
        self.zmq_source_gnb_tx.set_block_alias("gNB TX")
        self.zmq_sink_gnb_rx = zeromq.rep_sink(
            gr.sizeof_gr_complex, 1, "tcp://*:5001", 100, False, -1
        )
        self.zmq_sink_gnb_rx.set_block_alias("gNB RX")
        self.zmq_sink_ue_rx = zeromq.rep_sink(
            gr.sizeof_gr_complex, 1, "tcp://*:6001", 100, False, -1
        )
        self.zmq_sink_ue_rx.set_block_alias("UE RX")
        self.add_block_ul = blocks.add_vcc(1)
        self.add_block_dl = blocks.add_vcc(1)
        self.awgn_source_ul = analog.noise_source_c(
            analog.GR_GAUSSIAN, math.pow(10.0, (-12.0 - self.snr_ul) / 20.0), 42
        )
        self.awgn_source_dl = analog.noise_source_c(
            analog.GR_GAUSSIAN, math.pow(10.0, (-12.0 - self.snr_dl) / 20.0), 42
        )

        ##################################################
        # Connections
        ##################################################
        # Connect UE --> gNB (UL)
        self.connect((self.awgn_source_ul, 0), (self.add_block_ul, 0))
        self.connect((self.add_block_ul, 0), (self.zmq_sink_gnb_rx, 0))
        self.connect((self.zmq_source_ue_tx, 0), (self.add_block_ul, 1))
        # Connect gNB --> UE (DL)
        self.connect((self.awgn_source_dl, 0), (self.add_block_dl, 0))
        self.connect((self.zmq_source_gnb_tx, 0), (self.add_block_dl, 1))
        self.connect((self.add_block_dl, 0), (self.zmq_sink_ue_rx, 0))

        print("Radio blocks connected")


if __name__ == "__main__":
    ue_ip = os.getenv("SRS_UE_IP")
    gnb_ip = os.getenv("SRS_GNB_IP")

    tb = GNUflow(ue_ip, gnb_ip)
    tb.run()

Great point. So gnuradio is needed to broker UE to gNB and vice versa - Yeah I have followed all diffs, and ran the python above as you have, still stuck attaching. I have no more ideas why this is not working. Is it possible I need to add ip route to 172.22.0.1 or something?

Alternatively, is it possible to run gnuradio within the docker and capture that way? If so, I assume gnuradio should run in both gnb and ue containers?

@herlesupreeth
Copy link
Owner

Here you go, I have corrected your gnuradio script. I was running the script on the host machine (not inside docker)

gnu_test.zip

image

@hududed
Copy link
Author

hududed commented Apr 30, 2024

Still stuck. I was trying to at least see the logs but its weird that UE logs didnt show anything - is that supposed to happen?

❯ docker exec -it srsue_5g_zmq tail -f /mnt/srslte/ue.log
❯ docker exec -it srsgnb_zmq tail -f /mnt/srsran/gnb.log
2024-04-30T15:16:26.032719 [zmq:rx:0:0] [I] Waiting for reading samples. Completed 0 of 11520 samples.
2024-04-30T15:16:26.906903 [zmq:tx:0:0] [I] Waiting for request.
2024-04-30T15:16:26.906918 [zmq:rx:0:0] [I] Waiting for data.
2024-04-30T15:16:27.033704 [zmq:rx:0:0] [I] Waiting for reading samples. Completed 0 of 11520 samples.
2024-04-30T15:16:27.906906 [zmq:tx:0:0] [I] Waiting for request.
2024-04-30T15:16:27.906920 [zmq:rx:0:0] [I] Waiting for data.
2024-04-30T15:16:28.033709 [zmq:rx:0:0] [I] Waiting for reading samples. Completed 0 of 11520 samples.
2024-04-30T15:16:28.906908 [zmq:tx:0:0] [I] Waiting for request.
2024-04-30T15:16:28.906922 [zmq:rx:0:0] [I] Waiting for data.
2024-04-30T15:16:29.033713 [zmq:rx:0:0] [I] Waiting for reading samples. Completed 0 of 11520 sampl

Could you commit your changes to the docker and share them with me?

Otherwise - is it possible to compile your version of open5gs, srsgnb and srsue all locally? Have you done this before? It seems like a lot of configs to change for core.

EDIT: Could you check if the subscriber registration is correct ?
Screenshot 2024-05-01 001157

@herlesupreeth
Copy link
Owner

Still stuck. I was trying to at least see the logs but its weird that UE logs didnt show anything - is that supposed to happen?

hmm, doesnt make any sense. I tried it on my own machine with that diff applied and python script running on host machine and it worked

Could you commit your changes to the docker and share them with me?

just do git apply patch.diff

Otherwise - is it possible to compile your version of open5gs, srsgnb and srsue all locally? Have you done this before? It seems like a lot of configs to change for core.

If you want to use your own version of open5gs, srsgnb and srsue just change the git commit hash in the Dockerfile in respective folder and re-compile. Its as easy as that :)

EDIT: Could you check if the subscriber registration is correct ?

Its wrong. It should be set as OP and NOT OPc in the webui

@hududed
Copy link
Author

hududed commented May 3, 2024

well, was hoping setting OP would've solved it but it didnt. Not giving up yet, please bear with me.

I went down the route of manually compiling open5gs according to the tutorial with srsRAN_Project and srsRAN_4G also compiled locally - out of the box, got RRC configured with traces on both gnb and ue, and ping also works.

❯ sudo ip netns exec ue1 ip route add default via 10.45.1.1 dev tun_srsue
❯ sudo ip addr add 10.45.1.1/24 dev ogstun # this was important
❯ sudo ip netns exec ue1 ping 10.45.1.1 -c4
PING 10.45.1.1 (10.45.1.1) 56(84) bytes of data.
64 bytes from 10.45.1.1: icmp_seq=1 ttl=64 time=32.7 ms
64 bytes from 10.45.1.1: icmp_seq=2 ttl=64 time=25.3 ms
64 bytes from 10.45.1.1: icmp_seq=3 ttl=64 time=35.0 ms
64 bytes from 10.45.1.1: icmp_seq=4 ttl=64 time=24.6 ms

--- 10.45.1.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms

# gnb
          |--------------------DL---------------------|-------------------UL------------------------------
 pci rnti | cqi  ri  mcs  brate   ok  nok  (%)  dl_bs | pusch  mcs  brate   ok  nok  (%)    bsr    ta  phr
   1 4601 |  15   1   26    608    1    0   0%      0 |  65.5   28   7.2k    3    0   0%      0   0us  n/a
   1 4601 |  15   1   26    608    1    0   0%      0 |  65.5   28   5.8k    2    0   0%      0   0us  n/a
   1 4601 |  15   1   26    608    1    0   0%      0 |  65.5   28   7.2k    3    0   0%      0   0us  n/a
   1 4601 |  15   1   26    608    1    0   0%      0 |  65.5   28   7.2k    3    0   0%      0   0us  n/a
   1 4601 |  15   1    0      0    0    0   0%      0 |   n/a    0      0    0    0   0%      0   0us  n/a
   1 4601 |  15   1    0      0    0    0   0%      0 |   n/a    0      0    0    0   0%      0   0us  n/a
   1 4601 |  15   1    0      0    0    0   0%      0 |   n/a    0      0    0    0   0%      0   0us  n/a
   1 4601 |  15   1    0      0    0    0   0%      0 |   n/a    0      0    0    0   0%      0   0us  n/a
   1 4601 |  15   1    0      0    0    0   0%      0 |   n/a    0      0    0    0   0%      0   0us  n/a
   1 4601 |  15   1    0      0    0    0   0%      0 |   n/a    0      0    0    0   0%      0   0us  n/a
   1 4601 |  15   1    0      0    0    0   0%      0 |   n/a    0      0    0    0   0%      0   0us  n/a
   
# ue
   ---------Signal-----------|-----------------DL-----------------|-----------UL-----------
rat  pci  rsrp   pl   cfo | mcs  snr  iter  brate  bler  ta_us | mcs   buff  brate  bler
 nr    1    44    0 -393n |   0  118   0.0    0.0    0%    0.0 |   0    0.0    0.0    0%
 nr    1    44    0 -1.5u |   0   67   0.0    0.0    0%    0.0 |   0    0.0    0.0    0%
 nr    1    44    0  7.5u |   0  n/a   0.0    0.0    0%    0.0 |   0    0.0    0.0    0%
 nr    1    44    0  3.2u |  26  n/a   1.0    645    0%    0.0 |  27    0.0   7.7k    0%
 nr    1    44    0  4.4u |  26   70   1.0    639    0%    0.0 |  27    0.0   6.1k    0%
 nr    1    44    0  7.2u |  26  118   1.0    639    0%    0.0 |  27    0.0   7.6k    0%
 nr    1    44    0  6.7u |  26  n/a   1.0    639    0%    0.0 |  27    0.0   7.6k    0%
 nr    1    44    0  2.1u |   0   67   0.0    0.0    0%    0.0 |   0    0.0    0.0    0%
 nr    1    44    0  1.3u |   0  n/a   0.0    0.0    0%    0.0 |   0    0.0    0.0    0%
 nr    1    44    0  4.4u |   0   70   0.0    0.0    0%    0.0 |   0    0.0    0.0    0%
 nr    1    44    0  1.2u |   0  118   0.0    0.0    0%    0.0 |   0    0.0    0.0    0%
   

I didnt change IPs in all the open5gs parts, just the plmn, tac according to the gnb_zmq.yaml in srsRAN_Project.

❯ grep "address: 127.0.0" /etc/open5gs/*
/etc/open5gs/amf.yaml:      - address: 127.0.0.5
/etc/open5gs/amf.yaml:      - address: 127.0.0.5
/etc/open5gs/amf.yaml:      - address: 127.0.0.5
/etc/open5gs/ausf.yaml:      - address: 127.0.0.11
/etc/open5gs/bsf.yaml:      - address: 127.0.0.15
/etc/open5gs/mme.yaml:      - address: 127.0.0.2
/etc/open5gs/mme.yaml:      - address: 127.0.0.2
/etc/open5gs/mme.yaml:        - address: 127.0.0.3
/etc/open5gs/mme.yaml:        - address: 127.0.0.4
/etc/open5gs/mme.yaml:      - address: 127.0.0.2
/etc/open5gs/nrf.yaml:      - address: 127.0.0.10
/etc/open5gs/nssf.yaml:      - address: 127.0.0.14
/etc/open5gs/pcf.yaml:      - address: 127.0.0.13
/etc/open5gs/pcf.yaml:      - address: 127.0.0.13
/etc/open5gs/scp.yaml:      - address: 127.0.0.22
/etc/open5gs/sgwc.yaml:      - address: 127.0.0.3
/etc/open5gs/sgwc.yaml:      - address: 127.0.0.3
/etc/open5gs/sgwc.yaml:        - address: 127.0.0.6
/etc/open5gs/sgwu.yaml:      - address: 127.0.0.6
/etc/open5gs/sgwu.yaml:      - address: 127.0.0.6
/etc/open5gs/smf.yaml:      - address: 127.0.0.4
/etc/open5gs/smf.yaml:      - address: 127.0.0.4
/etc/open5gs/smf.yaml:        - address: 127.0.0.7
/etc/open5gs/smf.yaml:      - address: 127.0.0.4
/etc/open5gs/smf.yaml:      - address: 127.0.0.4
/etc/open5gs/smf.yaml:      - address: 127.0.0.4
/etc/open5gs/udm.yaml:      - address: 127.0.0.12
/etc/open5gs/udr.yaml:      - address: 127.0.0.20
/etc/open5gs/upf.yaml:      - address: 127.0.0.7
/etc/open5gs/upf.yaml:        - address: 127.0.0.4
/etc/open5gs/upf.yaml:      - address: 127.0.0.7
/etc/open5gs/upf.yaml:      - address: 127.0.0.7

Now I updated the gnb_zmq.yaml following your diffs but to localhost:

amf:
  addr: 127.0.0.5 # The address or hostname of the AMF.
  bind_addr: 127.0.0.5 # A local IP that the gNB binds to for traffic from the AMF.

ru_sdr:
  device_driver: zmq # The RF driver name.
  # device_args: tx_port=tcp://127.0.0.1:2000,rx_port=tcp://127.0.0.1:2001,base_srate=23.04e6 # Optionally pass arguments to the selected RF driver.
  device_args: tx_port=tcp://*:5000,rx_port=tcp://127.0.0.1:6001,base_srate=23.04e6 # Optionally pass arguments to the selected RF driver.
  srate: 23.04 # RF sample rate might need to be adjusted according to selected bandwidth.
  tx_gain: 75 # Transmit gain of the RF might need to adjusted to the given situation.
  rx_gain: 75 # Receive gain of the RF might need to adjusted to the given situation.
...

ue_zmq.conf, also to localhost:

device_name = zmq
#device_args = tx_port=tcp://127.0.0.1:2001,rx_port=tcp://127.0.0.1:2000,base_srate=23.04e6
device_args = tx_port=tcp://*:6000,rx_port=tcp://127.0.0.1:5001,base_srate=23.04e6

Ran the gnuradio, then core, updated the subscriber in webui according to srsran config, then gnb then ue:

❯ sudo gnb -c gnb_zmq.yaml

The PRACH detector will not meet the performance requirements with the configuration {Format 0, ZCZ 0, SCS 1.25kHz, Rx ports 1}.
Lower PHY in executor blocking mode.

--== srsRAN gNB (commit 2f90c8b60) ==--

Connecting to AMF on 127.0.0.5:38412
Available radio types: uhd and zmq.
Cell pci=1, bw=20 MHz, dl_arfcn=368500 (n3), dl_freq=1842.5 MHz, dl_ssb_arfcn=368410, ul_freq=1747.5 MHz

==== gNodeB started ===
Type <t> to view trace

❯ sudo srsue ue_zmq.conf
Active RF plugins: libsrsran_rf_zmq.so
Inactive RF plugins: 
Reading configuration file ue_zmq.conf...

Built in Release mode using commit ec29b0c1f on branch master.

Opening 1 channels in RF device=zmq with args=tx_port=tcp://*:6000,rx_port=tcp://127.0.0.1:5001,base_srate=23.04e6
Supported RF device list: zmq file
CHx base_srate=23.04e6
Current sample rate is 1.92 MHz with a base rate of 23.04 MHz (x12 decimation)
CH0 rx_port=tcp://127.0.0.1:5001
CH0 tx_port=tcp://*:6000
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Current sample rate is 23.04 MHz with a base rate of 23.04 MHz (x1 decimation)
Waiting PHY to initialize ... done!
Attaching UE...

But it's still stuck at UE .. how would this setup go if everything is on localhost?

@herlesupreeth
Copy link
Owner

Ran the gnuradio, then core, updated the subscriber in webui according to srsran config, then gnb then ue:

what IPs did you pass when you ran it?

I would suggest the following

in gNB config file

ru_sdr:
  device_driver: zmq # The RF driver name.
  # device_args: tx_port=tcp://127.0.0.1:2000,rx_port=tcp://127.0.0.1:2001,base_srate=23.04e6 # Optionally pass arguments to the selected RF driver.
  device_args: tx_port=tcp://127.0.0.1:5000,rx_port=tcp://127.0.0.1:6001,base_srate=23.04e6 # Optionally pass arguments to the selected RF driver.
  srate: 23.04 # RF sample rate might need to be adjusted according to selected bandwidth.
  tx_gain: 75 # Transmit gain of the RF might need to adjusted to the given situation.
  rx_gain: 75 # Receive gain of the RF might need to adjusted to the given situation.

in ue config file

device_name = zmq
#device_args = tx_port=tcp://127.0.0.1:2001,rx_port=tcp://127.0.0.1:2000,base_srate=23.04e6
device_args = tx_port=tcp://127.0.0.1:6000,rx_port=tcp://127.0.0.1:5001,base_srate=23.04e6

then in the gnuradio script hardcode both gnb_ip and ue_ip as 127.0.0.1

@hududed
Copy link
Author

hududed commented May 9, 2024

@herlesupreeth sorry for the delay. the changes actually worked! Thank you so much for your help!

But I was hoping to recreate gnu-test.py with the gnuradio GUI (for visualization purposes) but it failed and not sure why. I guess I'll capture the IQ data and visualize it separately. Before I close this issue - any recommendations on how to best capture data / visualization?

@herlesupreeth
Copy link
Owner

Before I close this issue - any recommendations on how to best capture data / visualization

No idea. Sorry cant be of much help. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants