天天看點

OAI 4G搭建(一):總體流程設定低延遲時間核心設定最大CPU效率下載下傳修改配置檔案編譯運作補充

我的機器版本号ubuntu 18.04

設定低延遲時間核心

Linux提供了五種核心類型,我們希望系統盡可能的實時,同時又不會降低太多的性能(實時性越高,性能,功耗等的損失越大)。這種情況下,我們可以嘗試使用低延時核心。OAI要求使用低延遲時間核心.

首先使用下列指令安裝:

sudo apt-get install linux-lowlatency
           
sudo apt-get install linux-image-`uname -r | cut -d- -f1-2`-lowlatency
           
sudo apt-get install linux-headers-`uname -r | cut -d- -f1-2`-lowlatency
           

重新開機加載核心:

sudo reboot
           

重新開機後進入grub2選擇頁的時候選下面的進階啟動選項

進去後選新裝上的 -lowlatency 核心啟動即可

檢視安裝核心:

uname -a
           

顯示結果為下面内容,則成功:

Linux alice 5.4.0-65-lowlatency #73~18.04.1-Ubuntu SMP PREEMPT Tue Jan 19 09:45:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

設定最大CPU效率

OAI要求移除BIOS(睡眠狀态,尤其是C狀态)和CPU頻率縮放(Intel SpeedStep)的功率管理特征,以保證OAI運作在最大CPU時鐘,處在performance模式,并且關閉p-state驅動.

首先添加GRUB_CMDLINE_LINUX_DEFAULT=“quiet intel_pstate=disable”:

nano /etc/default/grub
           
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_pstate=disable"
           

将 Governor設定為performance:

sudo apt-get install cpufrequtils
           

如果沒有cpufrequtils檔案,則先建立一個

sudo echo GOVERNOR="performance"  >  /etc/default/cpufrequtils
           

維持設定

sudo update-rc.d ondemand disable 
           

出現錯誤

update-rc.d: error: cannot find a LSB script for ondemand

則使用下面的代碼

sudo /etc/init.d/cpufrequtils restart
           
systemd reboot
           
sudo /etc/init.d/cpufrequtils restart
           

最後檢查CPU核心:

sudo cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
           

如果顯示performance則設定成功

以上設定也可以在BIOS界面進行.

下載下傳

(問題解決見OAI 4G搭建(二):git clone遇到的問題)

克隆倉庫

git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
           

修改配置檔案

基站

gedit ~/openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
           

查找:

plmn_list = ( { mcc = 110; mnc =01; mnc_length = 2; } );  
           

mcc和mnc改成自己的設定,mme的IP位址改成自己搭建的mme的位址

// MME parameters:
    mme_ip_address      = ( { ipv4       = "192.168.61.4";
                              ipv6       = "192:168:30::17";
                              active     = "yes";
                              preference = "ipv4";
                            }
                          );

    enable_measurement_reports = "no";
           

eNB的位址改成本機位址

NETWORK_INTERFACES :
   {
       ENB_INTERFACE_NAME_FOR_S1_MME            = "wlp0s20f3";
       ENB_IPV4_ADDRESS_FOR_S1_MME              = "10.128.220.209/18";
       ENB_INTERFACE_NAME_FOR_S1U               = "wlp0s20f3";
       ENB_IPV4_ADDRESS_FOR_S1U                 = "10.128.220.209/18";
       ENB_PORT_FOR_S1U                         = 2152; # Spec 2152

       ENB_IPV4_ADDRESS_FOR_X2C                 = "10.128.220.209/18";
       ENB_PORT_FOR_X2C                         = 36422; # Spec 36422
   }; 
   
           

UE

gedit ~/openairinterface5g/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf
           

修改USIM相關設定

UE0:
{
    USER: {
        IMEI="356113022094149";
        MANUFACTURER="EURECOM";
        MODEL="LTE Android PC";
        PIN="0000";
    };

    SIM: {
        MSIN="9876543210";  # IMSI=MCC+MNC+MSIN,根據HSS中存儲的IMSI修改
        USIM_API_K="11111111111111111111111111111111"; # 根據HSS中存儲的ki修改
        OPC="f47f37e4719a9c379e3447f089b1f10a"; # 根據HSS中儲存的OP和ki進行計算,得到OPC
    };

    # Home PLMN Selector with Access Technology
    HPLMN= "11001"; # Home PLMN=MCC+MNC,mcc和mnc改成自己的設定

    # User controlled PLMN Selector with Access Technology
    UCPLMN_LIST = ();

    # Operator PLMN List
    OPLMN_LIST = ("11001", "20810", "20811", "20813", "20893", "310280", "310028");

    # Operator controlled PLMN Selector with Access Technology
    OCPLMN_LIST = ("22210", "21401", "21406", "26202", "26204");

    # Forbidden plmns
    FPLMN_LIST = ();

    # List of Equivalent HPLMNs
#TODO: UE does not connect if set, to be fixed in the UE
#    EHPLMN_LIST= ("20811", "20813");
    EHPLMN_LIST= ();
};
           

編譯

cd openairinterface5g
           

設定環境變量

source oaienv
           
cd cmake_targets
           

編譯(問題解決見OAI 4G搭建(三): 編譯遇到的問題)

安裝依賴庫

./build_oai -I  --install-system-files
           

編譯

./build_oai --eNB --UE -x  -w USRP
           

參數說明:

  • -I: installs required packages.安裝ASN1和uhd驅動等,安裝好後再次編譯時可以不加該參數。
  • –eNB: installs eNB, i.e., lte-softmodem.後面編譯成UE這裡改成–UE即可.
  • -x: adds a software oscilloscope feature to the produced binaries.軟體示波器.
  • –install-system-files: installs OAI required files in Linux system.
  • -w: adds the hardware support, which is USRP in our case.
  • –phy_simulators: Makes the unitary tests Layer 1 simulators
  • –core_simulators: Makes the core security features unitary simulators

運作

基站

首先連接配接好USRP

設定環境

source oaienv
           

進入build目錄下

cd ~/openairinterface5g/cmake_targets/lte_build_oai/build
           

啟動基站

sudo -E ./lte-softmodem -O ~/openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf -d 
           

UE

設定環境

source oaienv
           

進入build目錄下

cd ~/openairinterface5g/cmake_targets/lte_build_oai/build
           

配置

../../nas_sim_tools/build/conf2uedata -c ~/openairinterface5g/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o .
           

啟動

sudo -E ./lte-uesoftmodem -C 2685000000 -r 50 --ue-rxgain 125 --basicsim
           

-r 25:基站配置檔案的N_RB_DL

-C 2685000000:基站配置檔案的下行頻率downlink_frequency

–ue-rxgain 125 :UARP的發射信号增益

補充

  1. ubuntu更換源
sudo gedit /etc/apt/sources.list
           

内容換成阿裡源

#  阿裡鏡像源

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

           

然後更新并更新

sudo apt-get update 
           
sudo apt-get upgrade
           
  1. 安裝git
sudo apt-get install git
           
  1. 設定靜态IP

    關機後再次打開,IP位址改變了,需要重新修改EPC和eNB的配置檔案,很麻煩,于是設定了靜态IP

    首先檢視本機網卡名、IP位址和子網路遮罩,記錄下來

ifconfig
           

檢視本機gateway位址,記錄下來

route -n
           

在/etc/netplan目錄下,更改檔案*.yaml

network:
  ethernets:
    wlp0s20f3:
      dhcp4: no
      addresses: [10.128.220.209/18]
      gateway4: 10.128.192.1
      nameservers:
        addresses: [114.114.114.114]
  version: 2
  renderer: NetworkManager
           

dhcp4: yes 代表DHCP自動擷取IP,将其改為no

然後應用修改

sudo netplan apply
           
OAI