P 4 RUNTIME GRPC実験


参照ドキュメント:
PI/proto/demo_grpc/README.md
環境設定
今回の実験でgrpcサーバはポート8888でwebサービスを開始したが、私の実験はサーバ上のコンテナで実行され、ブラウザを使用できなかった.したがって、ここでは、コンテナにポートマッピングを追加し、18888を8888にマッピングする.
#       
docker stop p4-rt
#         
docker commit p4-rt p4-rt1
#      ,      p4-rt1
docker run -it --privileged --name p4-rt1 -p 18888:8888 -v /home/admin/p4-rt:/p4-rt -w /p4-rt p4-rt1 bash 

我々の実験プログラムをコンパイルする
#      http    
apt-get install libmicrohttpd-dev
cd PI/proto/demo_grpc/
./configure --with-proto --with-bmv2
make
make install
#   ,               。
controller         #grpc   ,      8888    web   。
pi_grpc_server     #bmv2 target grpc   
pi_server_dummy    #dummy target grpc   
test_perf

Makefileを表示します.amファイルは、これらのファイルの役割を知ることができます.
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4

AM_CPPFLAGS = \
-I$(top_srcdir)/../include \
-I$(top_srcdir)/frontend \
-I$(top_srcdir)/server \
-I$(top_builddir)/cpp_out \
-I$(top_builddir)/grpc_out \
-I$(top_srcdir)/p4info

AM_CXXFLAGS = -Wall -Werror -Wno-unused-command-line-argument

noinst_PROGRAMS = controller pi_server_dummy test_perf
#pi_server_dummy dummy target grpc   
pi_server_dummy_SOURCES = pi_server_main.cpp

test_perf_SOURCES = test_perf.cpp
#controller        web       grpc      
controller_SOURCES = \
simple_router_mgr.cpp \
simple_router_mgr.h \
web_server.cpp \
web_server.h \
app.cpp

COMMON_SERVER_LIBS = \
$(top_builddir)/server/libpigrpcserver.la \
$(top_builddir)/frontend/libpifeproto.la \
$(top_builddir)/libpiprotogrpc.la \
$(top_builddir)/libpiprotobuf.la \
$(top_builddir)/../src/libpiall.la

#pi_grpc_server bmv2 target grpc   
if WITH_BMV2
bin_PROGRAMS = pi_grpc_server

pi_grpc_server_SOURCES = pi_server_main.cpp

pi_grpc_server_LDADD = \
$(COMMON_SERVER_LIBS) \
$(top_builddir)/../targets/bmv2/libpi_bmv2.la \
-lthrift -lruntimestubs -lsimpleswitch_thrift
endif  # WITH_BMV2

pi_server_dummy_LDADD = \
$(COMMON_SERVER_LIBS) \
$(top_builddir)/../targets/dummy/libpi_dummy.la

test_perf_LDADD = \
$(top_builddir)/../src/libpip4info.la \
$(top_builddir)/libpiprotogrpc.la \
$(top_builddir)/libpiprotobuf.la \
$(top_builddir)/p4info/libpiconvertproto.la \
$(PROTOBUF_LIBS) $(GRPC_LIBS)

controller_LDADD = \
$(top_builddir)/../src/libpip4info.la \
$(top_builddir)/libpiprotogrpc.la \
$(top_builddir)/libpiprotobuf.la \
$(top_builddir)/p4info/libpiconvertproto.la \
-lmicrohttpd $(BOOST_SYSTEM_LIB) \
$(PROTOBUF_LIBS) $(GRPC_LIBS)

試験例の実行
PI/proto/demo_grpc/ディレクトリの下でテスト例を実行します.
#       md           :
ip link add name veth250 type veth peer name veth251
ip link set dev veth250 up
ip link set dev veth251 up
python 1sw_demo.py --cpu-port veth250
./pi_grpc_server
./controller -c simple_router.json -p simple_router.p4info.txt

コントローラが起動できず、エラーが発生しました.bmv 2モデルにはバグがあり、googleは所望の解決策を得られず、次にdummyモデルを実行することを求めた.
dummyモデル
#   console   
./pi_server_dummy
#     console   
./controller -c simple_router.json -p simple_router.p4info.txt
#  

Webによる転送データ面置換
物理サーバにアクセスできるデバイスでブラウザを開き、Webサーバにアクセスします:192.168.1.1:18888.次のページが表示されます.
置換するデータ面ファイルを選択しsubmitを実行
コンソールには次の出力が表示されます.
P4Runtime SetForwardingPipelineConfig
[P4Runtime] [warn] p4::tmp::P4DeviceConfig is deprecated
P4Runtime Write
updates {
  type: INSERT
  entity {
    table_entry {
      table_id: 33589124
      match {
        field_id: 1
        exact {
          value: "\000\000\000\000"
        }
      }
      action {
        action {
          action_id: 16784184
        }
      }
    }
  }
}
P4Runtime Write
updates {
  type: INSERT
  entity {
    table_entry {
      table_id: 33581985
      match {
        field_id: 1
        lpm {
          value: "
\000\000
" prefix_len: 32 } } action { action { action_id: 16812204 params { param_id: 1 value: "
\000\000
" } params { param_id: 2 value: "\000\001" } } } } } } P4Runtime Write updates { type: INSERT entity { table_entry { table_id: 33581985 match { field_id: 1 lpm { value: "
\000\001
" prefix_len: 32 } } action { action { action_id: 16812204 params { param_id: 1 value: "
\000\001
" } params { param_id: 2 value: "\000\002" } } } } } } P4Runtime Write updates { type: INSERT entity { table_entry { table_id: 33562826 match { field_id: 1 exact { value: "\000\001" } } action { action { action_id: 16813016 params { param_id: 1 value: "\000\252\273\000\000\000" } } } } } } P4Runtime Write updates { type: INSERT entity { table_entry { table_id: 33562826 match { field_id: 1 exact { value: "\000\002" } } action { action { action_id: 16813016 params { param_id: 1 value: "\000\252\273\000\000\001" } } } } } } P4Runtime SetForwardingPipelineConfig [P4Runtime] [warn] p4::tmp::P4DeviceConfig is deprecated