调试prplmesh指南

前提:安装ubuntu虚拟机

本文使用的linux发行版本:Ubuntu 20.04.6 LTS

1 安装依赖

安装相关依赖包

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install vim git unzip curl binutils cmake gcc bison curl flex gcovr binutils autoconf autogen libtool psmisc ebtables iproute2
sudo apt-get install libjson-c-dev libncurses-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev libssl-dev pkg-config
sudo apt-get install libevent-dev libyajl-dev libreadline-dev lua5.1 liblua5.1-0-dev  bridge-utils net-tools uuid-runtime
sudo apt-get install python3 python3-yaml python python-yaml clang-format ninja-build build-essential

2 下载、编译、安装prplmesh

下载prplmesh

git clone https://gitlab.com/prpl-foundation/prplmesh/prplMesh.git && cd prplMesh

编译prplmesh

sudo cmake -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../build/install -H. -B../build -G Ninja

编译完成后提示如下

-- /home/shan/Documents/build/common/beerocks/bcl
Preparing bcl for the linux platform
Preparing btl for the linux platform
-- Inherited /home/shan/Documents/prplMesh/framework/tlvf/tlvf.py ...
-- Running /usr/bin/python3;/home/shan/Documents/prplMesh/framework/tlvf/tlvf.py;/home/shan/Documents/prplMesh/common/beerocks/tlvf/src;/home/shan/Documents/prplMesh/common/beerocks/tlvf/yaml;/home/shan/Documents/prplMesh/common/beerocks/tlvf/AutoGenerated;-c;/home/shan/Documents/prplMesh/common/beerocks/tlvf/tlvf_conf.yaml --print-dependencies...
-- Generating Beerocks TLVF files...
Preparing beerocks_agent for the linux platform
Preparing beerocks_fronthaul for the linux platform
Preparing bml for the linux platform
Preparing beerocks_cli for the linux platform
Preparing beerocks_controller for the linux platform
-- Configuring done (9.8s)
-- Generating done (0.1s)
-- Build files have been written to: /home/shan/Documents/build

如果提示出现错误,则删除googletest相关文件后再次编译

sudo rm -rf ../build/googletest-*
sudo cmake -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../build/install -H. -B../build -G Ninja

安装prplmesh

sudo ninja -C ../build install

进入script目录

cd ../build/install/scripts

启动prplmesh,默认启动controller+agent模式

sudo ./prplmesh_utils.sh start

一共3种模式,其它启动模式如下

1、agent模式

sudo sed -i 's/PRPLMESH_MODE="CA"/PRPLMESH_MODE="A"/' ./prplmesh_utils.sh && sudo ./prplmesh_utils.sh start

2、controller模式

sudo sed -i 's/PRPLMESH_MODE="CA"/PRPLMESH_MODE="C"/' ./prplmesh_utils.sh && sudo ./prplmesh_utils.sh start

3、controller+agent模式

sudo sed -i 's/PRPLMESH_MODE="CA"/PRPLMESH_MODE="CA"/' ./prplmesh_utils.sh && sudo ./prplmesh_utils.sh start

启动后有提示如下:

start
./prplmesh_utils.sh: start
prplmesh_framework_init - starting ieee1905_transport process...
IEEE1905 Transport Process Start
prplmesh_agent_start - start beerocks_agent process...
19:14:57 logger.cpp[144]: Configuration file does not exist
 
Beerocks Agent Process Start
2023-09-13 19:14:57,312 ERROR [default] cfg_get_hostap_iface: unknown iface index: 2
2023-09-13 19:14:57,312 ERROR [default] cfg_get_all_prplmesh_wifi_interfaces: failed to get wifi interface for agent2
2023-09-13 19:14:57,312 ERROR [default] cfg_get_hostap_iface: unknown iface index: 3
2023-09-13 19:14:57,312 ERROR [default] cfg_get_all_prplmesh_wifi_interfaces: failed to get wifi interface for agent3
INFO: No radio interfaces are available

说明:
prplmesh编译完成后
1、在build/install/bin下有5个可执行文件

beerocks_agent  beerocks_cli  beerocks_controller  beerocks_fronthaul  ieee1905_transport

2、在build/install/config下有3个配置文件

beerocks_agent.conf  beerocks_controller.conf  framework_logging.conf

3、在build/install/lib下有13个动态依赖库

bcl、bml、bpl、btl、btlvf、bwl、elpp、ieee1905_transport_lib、ieee1905_transport_messages、mapfcommon、nbapi、prplmesh_hostapd、tlvf

4、根据prplMesh/documentation/prplMesh-infra-agent.pptx,agent涉及的lib库有

bcl、tlvf(tfl)、btl、bwl、bpl(pal)

5、除了控制台的调试信息外,在/tmp/beerocks/logs下还有prplmesh运行的日志记录
6、在/tmp/beerocks下有一个Unix domain socket文件,名为uds_broker

3 调试代码

修改代码进入prplMesh目录,运行

sudo ninja -C ../build install && cd ../build/install/scripts/
sudo sed -i 's/PRPLMESH_MODE="CA"/PRPLMESH_MODE="A"/' ./prplmesh_utils.sh && sudo ./prplmesh_utils.sh start

可以在prplMesh目录下建立一个shell脚本,修改代码后一键编译运行

path=$(pwd)
sudo ninja -C ../build install && cd ../build/install/scripts/
sudo sed -i 's/PRPLMESH_MODE="CA"/PRPLMESH_MODE="A"/' ./prplmesh_utils.sh && sudo ./prplmesh_utils.sh start
cd ${path}

运行:

source ./start.sh

查看prplmesh运行日志

cd /tmp/beerocks/logs

4 设置虚拟无线网卡(可选)

如果没有外接usb无线网卡,可通过mac80211_hwsim模拟网卡

modprobe mac80211_hwsim
sudo iw phy0 interface add wlan0 type station
sudo iw phy1 interface add wlan1 type station
sudo iw phy2 interface add wlan2 type station
sudo ip link set wlan0 up
sudo ip link set wlan1 up
sudo ip link set wlan2 up
sudo brctl addbr br-lan

5 修改无线网卡的名称(可选)

如果插入外接usb无线网卡后,输入ifconfig或ip link显示的网卡名不是wlan0,而是类似wlxc01c302fef5d这样的名称,可以使用如下命令修改

sudo vim /etc/default/grub

将其中的GRUB_CMDLINE_LINUX的值设置为net.ifnames=0 biosdevname=0

RUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

然后更新grub并重启

sudo update-grub
reboot

再次输入ifconfg,可以看到网卡名称已改变

wlan0: flags=4099  mtu 1500
        ether c0:1c:30:2f:ef:5d  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

你可能感兴趣的:(linux,openwrt,路由器)