p4lang / p4factory

Compile P4 and run the P4 behavioral simulator
Apache License 2.0
174 stars 106 forks source link

No handlers could be found for logger "thrift.transport.TSocket" #180

Closed chenxiang2019 closed 7 years ago

chenxiang2019 commented 7 years ago

Hi all.

Recently, I created a new target in p4factory, using p4factory/tools/newtarget.py, and I wanted to run my own P4 code in software switch integrated with specific topo.py by using mininet.

Firstly, I implemented the command sudo make bm to generate the behavioral-model. And I used the script veth_setup.sh to creat virtual port.

Then, I run the script run_demo.sh, the content are showed below:

THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source $THIS_DIR/env.sh

P4C_BM_SCRIPT=$P4C_BM_PATH/p4c_bm/__main__.py

SWITCH_PATH=$THIS_DIR/behavioral-model

CLI_PATH=$THIS_DIR/runtime_CLI.py

$P4C_BM_SCRIPT p4src/demo.p4 --json demo.json

sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
    --behavioral-exe $SWITCH_PATH \
    --json demo.json \
    --cli $CLI_PATH \
    --mode l2

And it created virtual network successfully,

...
*** Starting 3 switches
s1 Starting P4 switch s1
/home/wasdns/p4factory/targets/demo/behavioral-model -i 1@s1-eth1 -i 2@s1-eth2 -i 3@s1-eth3 --pcap --thrift-port 22222 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 demo.json
switch has been started
s2 Starting P4 switch s2
/home/wasdns/p4factory/targets/demo/behavioral-model -i 1@s2-eth1 -i 2@s2-eth2 -i 3@s2-eth3 --pcap --thrift-port 22223 --nanolog ipc:///tmp/bm-1-log.ipc --device-id 1 demo.json
switch has been started
s3 Starting P4 switch s3
/home/wasdns/p4factory/targets/demo/behavioral-model -i 1@s3-eth1 -i 2@s3-eth2 -i 3@s3-eth3 --pcap --thrift-port 22224 --nanolog ipc:///tmp/bm-2-log.ipc --device-id 2 demo.json
switch has been started
...

but when I run ./runtime_CLI.py --thrift-port 22222, it reported error:

No handlers could be found for logger "thrift.transport.TSocket"
Could not connect to thrift client on port 22222
Make sure the switch is running and that you have the right port

My thrift version is 0.9.2, and it worked successfully when I tried the l2_switch target and the Tutorials.

How can I solved this problem? Thanks a lot for your kindness!

antoninbas commented 7 years ago

I am confused by why you are using p4factory for this. p4factory is pretty much deprecated at this stage for the bmv2 workflow, which is what you are using here. You actually seem to be following what the examples in the tutorials repo are doing (https://github.com/p4lang/tutorials). Could you give the output of sudo /home/wasdns/p4factory/targets/demo/behavioral-model demo.json? Based on the information you are giving, I am a little scared you are are trying to compile and run bmv1, as if it were bmv2...

chenxiang2019 commented 7 years ago

@antoninbas

The output showed below:

root@ubuntu:/home/wasdns/p4factory/targets/demo# sudo ./behavioral-model demo.json
No PD RPC server address specified, using 127.0.0.1:9090
No listener specified, switch will run in standalone mode

P4 Program:  demo

Starting RPC server on port 9090

I'm using the p4factory because it showed me the same excepetion when I used bmv2 before. When I saw the error information, I think it should be some problem with the software switch. In fact, the demo.p4 is the same with the l2_switch.p4 . I didn't change it yet. The target I used before was l2_switch.

chenxiang2019 commented 7 years ago

@antoninbas

My demo ran well with the target simple_switch, and I opened the runtime CLI successfully by using thrift port 22222. But another problem occured. When I using the command mc_mgrp_create 1, it showed that:

RuntimeCmd: mc_mgrp_create 1
Creating multicast group 1
Traceback (most recent call last):
  File "./runtime_CLI.py", line 2216, in <module>
    main()
  File "./runtime_CLI.py", line 2213, in main
    RuntimeAPI(args.pre, standard_client, mc_client).cmdloop()
  File "/usr/lib/python2.7/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "./runtime_CLI.py", line 587, in handle
    return f(*args, **kwargs)
  File "./runtime_CLI.py", line 1452, in do_mc_mgrp_create
    mgrp_hdl = self.mc_client.bm_mc_mgrp_create(0, mgrp)
  File "/usr/local/lib/python2.7/dist-packages/bm_runtime/simple_pre/SimplePre.py", line 103, in bm_mc_mgrp_create
    return self.recv_bm_mc_mgrp_create()
  File "/usr/local/lib/python2.7/dist-packages/bm_runtime/simple_pre/SimplePre.py", line 121, in recv_bm_mc_mgrp_create
    raise x
thrift.Thrift.TApplicationException: TMultiplexedProcessor: Unknown service: simple_pre

and cmd exit unexcepted.

Is there something wrong with my steps?

antoninbas commented 7 years ago

When running simple_switch, prefer the simple_switch CLI (https://github.com/p4lang/behavioral-model/blob/master/targets/simple_switch/sswitch_CLI). It gets installed as simple_switch_CLI when you run make install. Alternatively, you can keep using the basic runtime CLI here, but you need to pass --pre SimplePreLAG when starting it.

chenxiang2019 commented 7 years ago

@antoninbas

Thank you very much! But I still have a question.

As far as I know, the control plane in the target "l2_switch" using learn_client to receive the digest from the data plane, then generate flow entries to deploy to the switches in the data plane. Reference: How learn_client work with l2_switch in mininet?

But how can I use the learning engine for the switches in my specific virtual topo logic? In the other words, is there something like learn_client in simple_switch?

antoninbas commented 7 years ago

It should not be too hard to adapt the learn_client to work with your own P4 program (running in simple_switch), providing you are not doing anything to advanced. You will have to adapt the struct representing the learning sample and modify the table names if needed. You also need to provide the correct notification socket (https://github.com/p4lang/behavioral-model/blob/master/targets/l2_switch/learn_client/learn_client.cpp#L87) for each switch instance, so you may want to make it a command line argument for the learn_client executable and start a learn_client process for every switch in the topology. You could also modify learn_client in such a way that a unique instance can manage N switches, so whatever you prefer.

Note that the learn_client is an example which is not tied to a specific bmv2 architecture (i.e. it can work with simple_switch) but is tied to a specific P4 program (in this case l2_switch.p4). It therefore needs to be adapted to the P4 program you are running.

chenxiang2019 commented 7 years ago

@antoninbas

I see. Thanks a lot and happy Chinese new year!

whn0301 commented 5 years ago

@Wasdns 你好,请问一下问题解决了吗,用的什么办法,我也遇到了同样的问题