最近在研究 P4 語言以及他的用法,以下是簡易安裝 P4 環境的方法:
環境:
- Ubuntu 14.04 LTS
設定方式
下載 p4 整套 source code:
git clone git@github.com:p4lang/p4factory.git
安裝 git submodules
cd p4factory
git submodule update –init –recursive註:此安裝步驟需先在 github 上設定好 ssh key
安裝所有的相依套件:
./install_deps.sh
因為 p4 模擬的 switch 會需要用到 veth,所以要先設定 veth:
sudo ./tools/veth_setup.sh
設定好每一個 submodule 的 Makefile:
./autogen.sh
./configure完成環境設定
要驗證開發環境有沒有設定好,只需要進入其中一個 target 並編譯即可:
cd targets/basic_routing
make bm
sudo ./behavioral-model
啟動後如下:
No PD RPC server address specified, using 127.0.0.1:9090
No listener specified, switch will run in standalone mode
P4 Program: basic_routing
Starting RPC server on port 9090
跟 OpenFlow Switch 不同的是,他們是被動的,也就是說,他們不會主動連線到任何的 Control plane,而是由 Control plane 連線到他們上面,並且下 Entry。
You need to execute always sudo to run ./behavioral-model the following comand : sudo ./tools/veth_setup.sh
你好,我在运行 sudo ./behavioral-model的时候得到的结果是
y@y-Lenovo:~/p4factory/targets/basic_routing$ sudo ./behavioral-model
[sudo] y 的密码:
No PD RPC server address specified, using 127.0.0.1:9090
No listener specified, switch will run in standalone mode
P4 Program: basic_routing
Starting RPC server on port 9090
bmi_port_interface_add(port_mgr, veth_name, n_veth, pcap_filename): ERROR -1 at main.c:434y@y-Lenovo:~/p4factory/targets/basic_routing$
请问这是什么原因?谢谢
@heyu 您好
很抱歉這麼晚回應
如同 @Juan 說明,在執行 bmv1 之前必須要先手動新增好 veth
若要動態新增 veth ,建議您使用 bmv2 比較簡單