Skip to content

Pi Setup

Israel Olaveson edited this page Feb 18, 2025 · 1 revision

Setup each of the Raspberry Pi's

You will want to follow this process to setup each Pi.

We used Ubuntu server 22.04 for Raspberry Pi for the OS so the setup instructions are specific for this OS.

General Pi Setup

Note: Commands to run are in bold

Setup Pi

Below are the steps for how we configured each Pi for both the Wi-Fi and 5g Pi's.

  1. Perform the following tasks on the Pi to be setup
    1. Setup network

      1. Edit the following file: /etc/netplan/50-cloud-init.yaml

                      eth0:
                            addresses:[(YOUR IP HERE)/24]
        

        Note: It is recommended to use 192.168.1.10(pi#) with the files server pi ending in 90, the core ending in 80, and the gnb ending in 70 as the naming convection for the IP addresses, however if you choose another naming convention that you will want to go through the code and make any necessary changes.

        1. sudo netplan --debug try (make sure the configuration is valid)
        2. sudo netplan generate
        3. sudo netplan apply
      2. Setup Hostname

        Run the Following commands

        1. sudo hostnamectl set-hostname pi#
        2. Edit the following file /etc/cloud/cloud.cfg and add this line of code to it:
        preserve_hostname: true
        
        1. Verify the change by running hostnamectl
      3. Setup Proxy Info

        1. Edit the following file: /etc/environment and add the following code:

          export http_proxy=http://127.0.0.1:3129
          
          export https_proxy=http://127.0.0.1:3129
          
        2. Run the command source /etc/environment

      4. check ssh service on the Pi

        1. sudo service ssh status
        2. If the service failed to start, try sudo ssh-keygen -A
        3. You may have to enable SSH in the firewall by running sudo ufw allow ssh
      5. Perform the following tasks from the Core

        1. Make sure the Core is connected to the internet
        2. Once you have setup all the Pi's, Copy files from host machine to the Pis
          1. Edit the file /home/ubuntu/ldrd/scripts/copy_scripts.sh and replace the IP addresses in HOSTS with your PI's IP Addresses

          2. Run the following command:

            /home/ubuntu/ldrd/scripts/copy_scripts.sh
            
        3. ssh to the pi from the Core by running
          1. service squid status (make sure the squid service is running)
          2. ssh -R 3129:localhost:3128 ubuntu@(PI ADDRESS)
          3. Install python packages dpkt, sys, and csv
    2. Do whatever you need to do that involves internet connection (install libraries, etc.)

      Note: If you have issues connecting to the internet when using snap run sudo snap set system proxy.http=(your proxy here) and sudo snap set system proxy.https=(your proxy here)

    3. Cleanup

      On the Pi comment out or delete the proxy lines added to /etc/environment/ and run source /etc/environment

    4. Setup tcpdump

      Run the following commands:

      $ sudo groupadd pcap 
      $ sudo usermod -a -G pcap ubuntu 
      $ sudo chgrp pcap /usr/bin/tcpdump 
      $ sudo chmod 750 /usr/bin/tcpdump 
      $ sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/tcpdump
      
    5. Copy SSH keys

      1. Disconnect from the existing ssh session and run the following commands
        1. ssh-copy-id ubuntu@192.168.1.###
        2. Try ssh ubuntu@192.168.1.### and make sure it connects without prompting for password

5G Pi Setup

File server Pi

It is crucial to add these specific firewall rules for the Pi that is acting as our file server.

  • Add the following code to iptables and save the rules to ensure that none of the UE Pis can connect directly to the file server Pi

    Note: You will need add this rule for each UE's IP address

    iptables -I INPUT -s (UE IP ADDRESS) -p tcp -j DROP
    iptables -I INPUT -s (UE IP ADDRESS) -p udp -j DROP
    

Install UE

  1. Clone UERANSIM repo

    cd ~
    git clone https://github.com/aligungr/UERANSIM
    
  2. Install Dependencies

    1. Run the following commands to make sure that you get all the dependencies and the correct versions installed

      sudo apt update
      sudo apt upgrade
      sudo apt install make
      sudo apt install gcc
      sudo apt install g++
      sudo apt install libsctp-dev lksctp-tools
      sudo apt install iproute2
      sudo snap install cmake --classic
      

      Note: It is critical that you run the last command exactly as shown since other installers install a different version by default, the other workaround this issue is to build cmake directly from sources.

  3. Building UERANSIM

    Building is very simple just run the following commands

    cd ~/UERANSIM
    make
    
  4. Configure UE

    Edit each file located /home/ubuntu/scripts/script_config/open5gs-ue(#).yaml (1-15) and set the ismi to the one specific for that pi and change the IP address as shown: (Each pi should have an imsi ending in its corresponding number for example pi1's imsi should end in 11, pi2's should end in 21, pi3's 31 etc.)

    # IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
    supi: 'imsi-9997000000000(pi#)1'
    
    # List of gNB IP addresses for Radio Link Simulation
    gnbSearchList:
      - (GNB IP HERE)
    
  5. Start the UE component

    Once you have changed the configuration files you can start the component by calling sudo /home/ubuntu/scripts/start_ue.sh but if you want to run it manually run the following command:

    sudo /home/ubuntu/UERANSIM/build/nr-ue -c /home/ubuntu/UERANSIM/config/open5gs-ue-main.yaml
    

    Note: To stop the UE run sudo /home/ubuntu/scripts/stop_ue.sh

  6. Troubleshooting tool

    The UE's have a built-in tool for monitoring and troubleshooting while the system is up.

    We provide nr-cli tool for both gNB and UEs.

    NOTE: UE and gNB have different CLI commands. For example, in gNB you can check the AMF connection status, or in UE you can trigger de-registration. More details are explained in the present document.

    Usage:

    nr-cli <node-name>
    

    Here you need to replace <node-name> with a UE or gNB name. For example:

    nr-cli imsi-001010000000001
    

    You can query the current UE and gNBs in the environment using:

    $ nr-cli --dump
    

    After running nr-cli <node-name> command, an interactive shell will be open if given node is present and running in the environment. You can now execute further commands for this node.

    To see available commands, use commands.

    For Example:

    user@pc:~/UERANSIM/build$ ./nr-cli UERANSIM-gnb-001-01-1
    --------------------------------------------------------------------------------------------
    $ commands
    amf-info | Show some status information about the given AMF
    amf-list | List all AMFs associated with the gNB
    info     | Show some information about the gNB
    status   | Show some status information about the gNB
    ue-count | Print the total number of UEs connected the this gNB
    ue-list  | List all UEs associated with the gNB
    --------------------------------------------------------------------------------------------
    

    You can further investigate usage and help information for sub-commands.

    For example:

    $ amf-info --help $ ue-list --version
    

    etc.

    You can also use -e/--exec option if you want to directly execute the command instead of using the interactive shell.

    For example:

    nr-cli imsi-001010000000001 --exec "status"
    

    For more details, run nr-cli --help

Clone this wiki locally