p4lang / p4runtime-shell

An interactive Python shell for P4Runtime
Apache License 2.0
79 stars 40 forks source link

how to run #37

Closed P4-WCZ closed 4 years ago

P4-WCZ commented 4 years ago

Hello, I'm a newer. Excuse me, is this project installed on the P4 switch? Can I install it on Ubuntu? How can I install it if it runs on the P4 switch? I can't install it according to your README.I don't quite understand

P4-WCZ commented 4 years ago

.README says i can download the Docker image (~200MB) and use it. where the docker image? thanks!

antoninbas commented 4 years ago

The image is hosted on Dockerhub as p4lang/p4runtime-sh.

You can "download" it explicitly using docker pull p4lang/p4runtime-sh but when you run the shell with docker run, it will be pulled first if it is not found locally.

As described in the README, my recommend way of running the shell is by using the p4runtime-sh-docker script included in this repository. It will take care of pulling & running the docker image for you.

The following should work (of course you can also clone the entire git repository):

wget https://raw.githubusercontent.com/p4lang/p4runtime-shell/master/p4runtime-sh-docker
chmod +x p4runtime-sh-docker
./p4runtime-sh-docker <required args>

See README for required arguments and usage information.

P4-WCZ commented 4 years ago

Hello, thank you very much for your reply. I understand a part. But I am using the command line to connect to the P4 switch (not VM), prompting me to report an error. I didn't understand this error, you can help me take a look.First, I follow these commands.

Then i follow the command below:

second,9090 is the PD-API rpc server port of the P4 switch,Is this port the runtime-sh remote access switch port?

P4-WCZ commented 4 years ago

hello,I will add one more question。third,--config In P4 switch(not VM),p4c compiler compiles .p4 file and generate this file?i can't find it Or do I need to use the scp command to download the p4 file from the P4 switch to the VM, and compile the p4 file with p4c in the vm to generate p4info.txt? thanks:)

antoninbas commented 4 years ago

Correct port

There is no right answer here:

In any case, P4Runtime has nothing to do with the PD API. They are really two somewhat orthogonal APIs. The PD API RPC service is built with Apache Thrift, while the P4Runtime RPC service is built with gRPC.

So you may want to try port 50051, but if it doesn't work you will need to provide more information. If you are using a commercial P4 switch (e.g. from Barefoot / Intel), you will need to reach out to them directly.

P4Info

I do not fully understand the question. As per the P4Runtime specification, we require 2 artifacts to push a P4 pipeline to the switch:

P4-WCZ commented 4 years ago

wonderful! thank you very much. And i mentioned the P4 commercial switch before. You suggest that I contact the company.Excuse me, Do you know how to start the P4runtime server for the P4 commercial switch? I have also contacted domestic agents, but they have not responded to me.

antoninbas commented 4 years ago

If you are using Tofino, I believe there is some available customer documentation. That is all I can say.

P4-WCZ commented 4 years ago

Hello, excuse me.When I execute the script, [sudo] ./p4runtime-sh-docker --grpc-addr : \ --device-id 0 --election-id 0,1 --config p4info,out.bin it throws an error :

error when setting config P4runtime rpc error (UNAVALIABLE): socket closed StreamChannel error closing stream

Do you know what caused this?Thank you!

P4-WCZ commented 4 years ago

Hello, I see the python source code of the p4runtime-sh-docker script. Are the file attributes set in lines 67-69?

_mount_path = "/fwd_pipe_config" fname_p4info = "p4info.pb.txt" fnamebin = "config.bin"

If I want to use the file in my own path, do I need to modify the 67-69 lines of the script file?

antoninbas commented 4 years ago

The command you provide to run p4runtime-sh-docker does not seem to be complete. You didn't include the IP / port information. When running this script, make sure you take into account this information from the README:

If you are using the Docker image to run p4runtime-shell and you are trying to connect to a P4Runtime server running natively on the same system and listening on the localhost interface, you will not be able to connect to the server using --grpc-addr localhost: or --grpc-addr 127.0.0.1:. Instead, you should have your P4Runtime server listen on all interfaces (0.0.0.0) and you will need to use the IP address assigned to the Docker bridge (docker0 by default) or the IP address assigned to the local network management interface (e.g. eth0).

I don't understand the question in your second comment: https://github.com/p4lang/p4runtime-shell/issues/37#issuecomment-661129874. The script p4runtime-sh-docker lets you provide you own files as commend line arguments. Then it will take care of mounting the files inside the docker container.

In the future, please consider opening a new issue when you need help. Also try to include more information about what you are trying to do and what you have attempted so far. If you run into a problem, try to reproduce using bmv2 + p4runtime-shell and let us know the steps required to reproduce.