Giter Club home page Giter Club logo

p4-utils's People

Contributors

benature avatar dependabot[bot] avatar edgar-costa avatar fschleiss avatar jurijnota avatar lluki avatar notspecial avatar romeier avatar tschet1 avatar umakantkulkarni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

p4-utils's Issues

Problem with the “sudo p4run --config p4app.json” command regarding ping between hosts

I'm new to P4 and I'm trying to run the Mininet-PINT repository, dependent on p4utils, in which the network topology in mininet is built and initialized through the command “sudo p4run --config p4app.json”, but I noticed that when the topology is initialized it is not possible to execute the “ping” command between two hosts, but only between a host and a switch or between two switches.

I would like to know how to fix this problem, because creating a simple topology using the “sudo mn” command, ping works normally for both cases and I believe that perhaps this is the problem I am having when running the repository because the recipient hosts do not receive the packets sent by the sending host.

Why SimpleSwitchP4RuntimeAPI doesn't support reading and writing register?

I'm a beginner to P4 and I'm trying to write a program whose the controller plane needs to get access to registers which are defined in data plane with P4 language. I've tried to use SimpleSwitchP4RuntimeAPI to achieve this function. However, it appeared to me that SimpleSwitchP4RuntimeAPI support getting access to table, counter and meter, except register. I'm confused why SimpleSwitchP4RuntimeAPI is designed like this? If I want to achieve controlling registers in control plane, must I use SimpleSwitchThriftAPI? Is there any way else for I can do?

protobuf requires Python '>=3.7' but the running Python is 3.6.9

I want to install p4-utils in my own ubuntu18.04, but

user@v:~/p4-tools/p4-utils$ sudo ./install.sh
The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Obtaining file:///home/user/p4-tools/p4-utils
Collecting googleapis-common-protos>=1.52 (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4f/35/ebcc4d2ca9cf895547576e17b8c41172d19473b0c4b24f6f6c273849e00b/googleapis_common_protos-1.56.2-py2.py3-none-any.whl (211kB)
    100% |████████████████████████████████| 215kB 3.5MB/s 
Collecting grpcio>=1.17.2 (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/dd/d8eda79197a1275e06621850775c7bbf34a141ff92553754dde4e87d7551/grpcio-1.46.3.tar.gz (21.8MB)
    100% |████████████████████████████████| 21.9MB 70kB/s 
Requirement already satisfied: ipaddr in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: ipaddress in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: networkx in /home/user/.local/lib/python3.6/site-packages (from p4utils==0.2)
Collecting p4runtime (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d7/78/7823db0b5716c6040733e537ed8afe4d821b66928c0746d5e7098fcfe388/p4runtime-1.3.0-0-py3-none-any.whl
Collecting protobuf>=3.6.1 (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6c/be/4e32d02bf08b8f76bf6e59f2a531690c1e4264530404501f3489ca975d9a/protobuf-4.21.0-py2.py3-none-any.whl (164kB)
    100% |████████████████████████████████| 174kB 1.9MB/s 
protobuf requires Python '>=3.7' but the running Python is 3.6.9
user@v:~/p4-tools/p4-utils$ python -V
Python 3.6.9
user@v:~/p4-tools/p4-utils$ pip -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

The p4-utils folder is copied from provided VM, the git log is commit 3e5a3600736831ec717f4637a4eb75c3b3b19755.

p4@ict-networks-010-000-002-015:~/p4-tools/p4-utils$ sudo ./install.sh
The directory '/home/p4/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/p4/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Obtaining file:///home/p4/p4-tools/p4-utils
Requirement already satisfied: googleapis-common-protos>=1.52 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: grpcio>=1.17.2 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: ipaddr in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: ipaddress in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: networkx in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: p4runtime in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: psutil in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: scapy==2.4.4 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from p4utils==0.2)
Requirement already satisfied: six>=1.5.2 in /usr/local/lib/python3.6/dist-packages/six-1.16.0-py3.6.egg (from grpcio>=1.17.2->p4utils==0.2)
Requirement already satisfied: decorator<5,>=4.3 in /usr/local/lib/python3.6/dist-packages (from networkx->p4utils==0.2)
Installing collected packages: p4utils
  Found existing installation: p4utils 0.2
    Can't uninstall 'p4utils'. No files were found to uninstall.
  Running setup.py develop for p4utils
Successfully installed p4utils
p4@ict-networks-010-000-002-015:~/p4-tools/p4-utils$ pip -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
p4@ict-networks-010-000-002-015:~/p4-tools/p4-utils$ python -V
Python 3.6.9

I tried in VM but it success, the python version and pip version is the same. I wonder how the protobuf is installed in VM?

Send packet from controller and set egress port to controller

Is there a network interface between the controller and the switch to send and receive packets?

I can potentially send the packet by sending packet to one of the switch interfaces, for example: s1-eth1.

But is there a way set egress_port to <controller_port> such that I receive the packet at the controller?

No module named 'mininet' Issue

Hello all,
I have installed P4-utils and P4 from scratch on my ubuntu 20.04 server from scratch using the following command:
curl -sSL https://raw.githubusercontent.com/nsg-ethz/p4-utils/master/install-tools/install-p4-dev.sh | bash

However when I try to run any P4 code, it gives the following error:

from mininet.clean import cleanup, sh
ModuleNotFoundError: No module named 'mininet'

Is it the issue of ubuntu version since the installation script is only tested on ubuntu 18.04.4? Can someone help?

Thank you!

How to clone packets more than once back to back?

Can we not use clone3 twice to clone packet two times and send it to controller?

When I use clone3 twice then only second clone is reached the controller and the sniff function calls the recv_msg_cpu once.

here is my controller code to sniff packet from cpu port the recv_msg_cpu() function is used to handle the packets

def run_cpu_port_loop(self):
        cpu_port_intf = str(self.topo.get_cpu_port_intf(self.sw_name).replace("eth0", "eth1"))
        sniff(iface=cpu_port_intf, prn=self.recv_msg_cpu)

also in the p4 code

if(send_to_all.apply().hit){
    meta.CLONE_ETHER_TYPE = DELETE_MC_ETHER_TYPE;
    clone3(CloneType.I2E, 100, meta);
}
meta.CLONE_ETHER_TYPE = CACHE_ETHER_TYPE;
clone3(CloneType.I2E, 100, meta);

And rest I am handling in control egress

No module sswitch_runtime

Hi @edgar-costa :

p4utils/utils/sswitch_thrift_API.py has the import code:
from sswitch_runtime import SimpleSwitch
from sswitch_runtime.ttypes import *
However, 'sswitch_runtime' cannot be found.
Where is the sswitch_runtime module?

ImportError: No module named bmpy_utils

I had installed bmv2, however when I run the exercise "11-Packet-Loss-Detection" with command "sudo python2 packet-loss-controller.py --option run", I met the following error:
Traceback (most recent call last):
File "packet-loss-controller.py", line 2, in
from p4utils.utils.sswitch_API import *
File "/home/ylj/xjy/p4/p4-utils/p4utils/utils/sswitch_API.py", line 25, in
import p4utils.utils.runtime_API as runtime_API
File "/home/ylj/xjy/p4/p4-utils/p4utils/utils/runtime_API.py", line 31, in
import bmpy_utils as utils
ImportError: No module named bmpy_utils

Using @controller_header

I want to implement packet in and packet out method but how can I use @controller_header annotations in the controller. Also how to call bmv2 set queue rate command from p4 utils?

Disabling the switch log files not possible

If the logging function of P4 switches is disabled in the configuration file, starting the P4 application is not possible.

Reproduce

  • In configuration file p4app.json, set "enable_log": true,.
  • Try to start p4run.py

Error Output

*** Adding switches:
Traceback (most recent call last):
  File "./../p4-utils/p4utils/p4run.py", line 494, in <module>
    app.run_app()
  File "./../p4-utils/p4utils/p4run.py", line 231, in run_app
    self.create_network()
  File "./../p4-utils/p4utils/p4run.py", line 277, in create_network
    controller=None)
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/mininetlib/p4net.py", line 9, in __init__
    super(P4Mininet, self).__init__(*args, **kwargs)
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 174, in __init__
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/mininetlib/p4net.py", line 13, in build
    super(P4Mininet, self).build()
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 502, in build
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 483, in buildFromTopo
  File "build/bdist.linux-x86_64/egg/mininet/net.py", line 260, in addSwitch
  File "./../p4-utils/p4utils/p4run.py", line 69, in __init__
    P4Switch.__init__(self, *opts, **kwargs)
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/mininetlib/p4_mininet.py", line 92, in __init__
    self.output = open(self.log_file, 'w')
IOError: [Errno 2] No such file or directory: u'/home/user/p4/data_plane_driven_network_convergence/code/p4/log/s1.log'

Does P4Utils Support IPv6 ?

Hi everyone:

I want to do something about SRv6, specifically using BMV2 to implement SRv6, but I found that the function net.setIntfIp() cannot set the IPv6 address for host. How should I solve it?

Thank you very much!

here is my code:

#! /usr/bin/python3


net = NetworkAPI()

# Network general options
net.setLogLevel('info')
net.enableCli()

# Network definition
net.addSwitch("s1")
net.addHost('h1')
net.addHost('h2')

net.addLink('h1', 's1', port2=1)
net.addLink('s1', 'h2', port1=2)

net.setIntfIp("h1", "s1", "2001:db00::0/24")
# Assignment strategy
# net.l2()

# Nodes general options
net.enableLogAll()

# Start the network
net.startNetwork()

And Here is the output after sudo python3 network:

.......
Topology saved to disk!
Programming switches...
Switches programmed correctly!
Programming hosts...

Traceback (most recent call last):
  File "network.py", line 39, in <module>
    net.startNetwork()
  File "/home/ubuntu/p4-tools/p4-utils/p4utils/mininetlib/network_API.py", line 1135, in startNetwork
    self.program_hosts()
  File "/home/ubuntu/p4-tools/p4-utils/p4utils/mininetlib/network_API.py", line 341, in program_hosts
    '{}/{}'.format(intf1.ip, intf1.prefixLen))
  File "/usr/lib/python3.6/ipaddress.py", line 119, in ip_interface
    address)
ValueError: 'None/24' does not appear to be an IPv4 or IPv6 interface

Is the preconfigured p4-utils-vm only has a tty shell when start it?

I use qemu-img to convert p4-utils-vm.qcow2 to VDI format (for virtual box), but when I start the vm, there is only a tty shell, no ubuntu desktop. I want to confirm it. Or maybe the convert is wrong somewhere. Thanks.

Also, if I use qemu-system-**.exe to start this preconfigured vm, are there any recommended commands parameters to start the preconfigured vm? Is there a command example? Thanks.

Frequent re-compiling

I have noticed the following issues when using p4run:

  1. The P4 program is re-compiled every time p4run is executed, even when the file has not changed.
  2. When executing p4switch_reboot in the mininet console, the P4 program is always re-compiled on the first reboot, even when the file has not changed. On all following reboots, it is correctly not re-compiled.

I saw that you do attempt to limit re-compiling by checking if the files have been modified: https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/mininetlib/cli.py#L128
However, this apparently only kicks in after the first re-compiling.

I think it would make p4run faster and more convenient to use if this could be improved.

CLI option 'p4switches_reboot' failes if 'cli_input' not given in config

When cli_input is not defined in p4app.json for a switch, the Mininet CLI fails to reboot the switches.

How to reproduce:

  • add a switch to p4app.json for which you do not specify the optional cli_input
  • run
  • in the Mininet CLI, try to use p4switches_reboot

Error Log

Stopping P4 switch s5.
Starting P4 switch s5.
simple_switch -i 1@s5-eth1 -i 2@s5-eth2 -i 3@s5-eth3 --thrift-port 9094 --nanolog ipc:///tmp/bm-4-log.ipc --device-id 4 p4src/main.json --log-console >/home/user/p4/data_plane_driven_network_convergence/code/v4/p4/log/s5.log
P4 switch s5 has been started.
Traceback (most recent call last):
  File "/usr/local/bin/p4run", line 11, in <module>
    load_entry_point('p4utils', 'console_scripts', 'p4run')()
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/p4run.py", line 489, in main
    app.run_app()
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/p4run.py", line 225, in run_app
    self.do_net_cli()
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/p4run.py", line 371, in do_net_cli
    P4CLI(self.net, conf_file=self.conf_file)
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/mininetlib/cli.py", line 21, in __init__
    CLI.__init__(self, *args, **kwargs)
  File "build/bdist.linux-x86_64/egg/mininet/cli.py", line 68, in __init__
  File "build/bdist.linux-x86_64/egg/mininet/cli.py", line 103, in run
  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 "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/mininetlib/cli.py", line 176, in do_p4switches_reboot
    self.do_p4switch_start(line=line)
  File "/home/user/p4/data_plane_driven_network_convergence/code/p4-utils/p4utils/mininetlib/cli.py", line 151, in do_p4switch_start
    commands_path = switch_conf['cli_input']
KeyError: 'cli_input'

How to run multiple controllers

I want to run multiple controllers for same switch. such that one controllers will be embedded onto the switch and one will be in a remote location.

Installing issue

Hi,

I am trying to install p4-utils on ubuntu 22.04. I am using the new install script. It is installed successfully. When I try to write a controller, I am importing the following module:
from p4utils.utils.sswitch_thrift_API import SimpleSwitchThriftAPI

which is giving me the following error:
Traceback (most recent call last):
File "/home/mohamad/testbed-P4-emulator/controllers/ciena-controller.py", line 2, in
from p4utils.utils.sswitch_thrift_API import SimpleSwitchThriftAPI
File "/home/mohamad/p4-tools/p4-utils/p4utils/utils/sswitch_thrift_API.py", line 34, in
from sswitch_runtime import SimpleSwitch
ModuleNotFoundError: No module named 'sswitch_runtime'

so inside the sswitch_thrift_API.py there is the following imports:
from sswitch_runtime import SimpleSwitch
from sswitch_runtime.ttypes import *

so sswitch_runtime cannot be found, what can be the problem?

thank you

a table without keys

I have a table without keys, and I try to down some entries for it through sswitch_thrift_API.SimpleSwitchThriftAPI.table_add.Unfortunately, thrift_API.SwitchInfo.load_json_str could not load the table. Could you give me some advice? Thanks a lot!

Mininet CLI doesn't reboot all switches

When there are more than 5 switches (I'm not sure if this is a real limit or just happens in my case) in p4app.json, the Mininet CLI fails to reboot all switches.

It just reboots switch s1 to s5. Further switches are not started.

p4switch_reboot s7, however, works.

How to reproduce:

  • run a topology with more than 5 switches
  • in the Mininet CLI, try to use p4switches_reboot

P4run is not using 2.7 by default

After installing p4-utils, I tried to run the example using p4run. However, it seems that it is using python3 instead of python2 and the default is python 2.7.

Traceback (most recent call last):
  File "/usr/local/bin/p4run", line 11, in <module>
    load_entry_point('p4utils', 'console_scripts', 'p4run')()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 487, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2728, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2346, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2352, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "~/utils/p4utils/p4run.py", line 155
    print ' '.join(items)
            ^
SyntaxError: invalid syntax
python --version 
Python 2.7.12

How can I force p4run to use python2.7 instead of python3.5 ?

Adding commands at host

How can we add commands at host like mentioned in P4 language official tutorials? here

Thank you

why is the preconfigured VMs not available now?

I find the installation part provides preconfigured VMs, however, the linked page says preconfigured VMs not available. Where can we get these preconfigured VMs? Or do we have to build one VM manually if I want to use P4-Utils?

'TableEntry' object has no attribute 'metadata'

when I used SimpleSwitchP4RuntimeAPI.table_add() to insert some entries, an exception occurred in the p4runtime_API api.py _EntityBase._write() and said TableEntry object has no attribute metadata. The program is roughly the same as p4-learning/exercises/08-Simple_Routing/p4runtime/solution/routing-controller.py. The tables show below:

table ipv4_lpm {
    key = {
        hdr.ipv4.dstAddr: lpm;
    }
    actions = {
        ipv4_forward;
        drop;
        NoAction;
    }
    size = 1024;
    default_action = drop();
}
table l2_exact_table {
    key = {
        hdr.ethernet.dstAddr: exact;
    }
    actions = {
        set_egress_port;
        send_to_CPU;
        drop;
        NoAction;
    }
    default_action = NoAction;
}

i wonder what the metadata means. I find it in the class TableEntry . could someone help me? thanks a lot.

Graceful shutdown when stopping with Ctrl+C

When running a mininet without a cli (net.disableCli()) and hitting Ctrl-C, I get the following trace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1653, in wrapper
    return fun(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 480, in wrapper
    raise raise_from(err, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 478, in wrapper
    return fun(self)
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1695, in _parse_stat_file
    data = bcat("%s/%s/stat" % (self._procfs_path, self.pid))
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 813, in bcat
    return cat(fname, fallback=fallback, _open=open_binary)
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 801, in cat
    with _open(fname) as f:
  File "/usr/local/lib/python3.8/dist-packages/psutil/_common.py", line 765, in open_binary
    return open(fname, "rb", buffering=FILE_READ_BUFFER_SIZE)
FileNotFoundError: [Errno 2] No such file or directory: '/proc/2442/stat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/psutil/__init__.py", line 361, in _init
    self.create_time()
  File "/usr/local/lib/python3.8/dist-packages/psutil/__init__.py", line 719, in create_time
    self._create_time = self._proc.create_time()
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1653, in wrapper
    return fun(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1863, in create_time
    ctime = float(self._parse_stat_file()['create_time'])
  File "/usr/local/lib/python3.8/dist-packages/psutil/_pslinux.py", line 1660, in wrapper
    raise NoSuchProcess(self.pid, self._name)
psutil.NoSuchProcess: process no longer exists (pid=2442)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "network.py", line 187, in <module>
    net.stopNetwork()
  File "/home/p4/p4-tools/p4-utils/p4utils/mininetlib/network_API.py", line 1160, in stopNetwork
    self.stop_exec_scripts()
  File "/home/p4/p4-tools/p4-utils/p4utils/mininetlib/network_API.py", line 1154, in stop_exec_scripts
    kill_proc_tree(pid)
  File "/home/p4/p4-tools/p4-utils/p4utils/utils/helper.py", line 481, in kill_proc_tree
    parent = psutil.Process(pid)
  File "/usr/local/lib/python3.8/dist-packages/psutil/__init__.py", line 332, in __init__
    self._init(pid)
  File "/usr/local/lib/python3.8/dist-packages/psutil/__init__.py", line 373, in _init
    raise NoSuchProcess(pid, msg='process PID not found')
psutil.NoSuchProcess: process PID not found (pid=2442)

The error comes from the following lines:

def kill_proc_tree(pid, sig=signal.SIGKILL, include_parent=True,
timeout=None, on_terminate=None):
"""Kills a process tree (including children).
Args:
pid (int) : PID of the parent process
sig (int) : signal used to kill the tree
include_parent (bool) : whether to kill the parent process or not
timeout (int or float) : time to wait for a process to terminate
on_terminate (types.FunctionType): callback function executed as soon as a child terminates.
Returns:
tuple: ``(gone, still_alive)``.
"""
assert pid != os.getpid(), "won't kill myself"
parent = psutil.Process(pid)
children = parent.children(recursive=True)
if include_parent:

An approach to fix this problem is to check whether the process actually exists:

    try:
        parent = psutil.Process(pid)
    except psutil.NoSuchProcess:
        return (None, None)

However, I'm not sure what should be returned in case that there is no process; returning (None, None) is most probably not the best way to do it.

bw (bandwidth) config in p4app.json does not take effect

Hi, all.

In p4app.json I set bw as 1, referring to the document.

[
    "s7",
    "s8",
    {
        "bw": 1
    }
],

However, I test the bandwidth with iperf but get

mininet> iperf s8 s7
*** Iperf: testing TCP bandwidth between s8 and s7 
[            Level 25] newfn: *** Iperf: testing TCP bandwidth between s8 and s7 
 
*** Results: ['19.7 Gbits/sec', '19.7 Gbits/sec']
[            Level 25] newfn: *** Results: ['19.7 Gbits/sec', '19.7 Gbits/sec']

with printNetInfo command, it shows that the bw of link between s8 and s7 is indeed set as 1

s8(thirft->9098, cpu_port->None)
----------------------------------------------------------------------------------------------------------------
port            intf     node                  mac               ip       bw   weight    delay     loss    queue
   1         s8-eth1       h8    00:01:0a:08:08:02         10.8.8.1     None        1     None     None     None
   2         s8-eth2       s7    d6:c3:90:80:f2:2a         20.7.8.2        1        1     None     None     None
   3         s8-eth3       s9    f6:80:27:c8:a8:2e         20.8.9.1        1        1     None     None     None
   4         s8-eth4       s0    ca:0e:f8:2a:83:2b        20.11.8.2     None        1     None     None     None
----------------------------------------------------------------------------------------------------------------

According to the document, what I expected is 1Mbps bandwidth, but gets around 20Gbps.

p4run problem

Hey everyone,
I just used copy my p4app.json to the p4run folder and use these commands:
p4run
sudo p4run
sudo p4run --config p4app.json
But all of these commands gives me the feedback:

Traceback (most recent call last):
File "/usr/local/bin/p4run", line 11, in
load_entry_point('p4utils', 'console_scripts', 'p4run')()
File "/home/zwl/p4-utils/p4utils/p4run.py", line 736, in main
app = AppRunner(args.config,
File "/home/zwl/p4-utils/p4utils/p4run.py", line 308, in init
mininet = load_custom_object(mininet_module)
File "/home/zwl/p4-utils/p4utils/utils/helper.py", line 321, in load_custom_object
module = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'p4utils.mininetlib.p4net'

I tried many ways but no one works.
I even uninstall p4utils and install again in my VM but it still goes wrong.
can anyone help me please...

Hardware Interface

Hi, in Mininet there there is a way to be able to bind an interface of a switch from the virtual network to a hardware interface on the machine that runs it by using the "Intf" class from "link.py" .

I have not been able to replicate this using P4-utils due to the fact that i have not been able to locate where P4-utils stores the "Node" objects that are created.

I have also not been able to tell if these objects are created in the first place or if they are managed in other ways.

I would appreciate if you can let me know if you are aware of any way to achieve the mininet to outside connection in some way using P4-utils.

Thank you.

Problems encountered when using the p4run command

`root@ubuntu:/home/p4/program/idtra_v0.1# p4run
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 584, in _build_master
ws.require(requires)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 792, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (protobuf 3.18.3 (/usr/local/lib/python3.8/dist-packages), Requirement.parse('protobuf!=3.20.0,!=3.20.1,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5'), {'googleapis-common-protos'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/p4run", line 6, in
from pkg_resources import load_entry_point
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3254, in
def _initialize_master_working_set():
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3237, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3266, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 586, in _build_master
return cls._build_from_requirements(requires)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 599, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 792, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (protobuf 3.18.3 (/usr/local/lib/python3.8/dist-packages), Requirement.parse('protobuf!=3.20.0,!=3.20.1,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.19.5'), {'googleapis-common-protos'})`

When I use p4run to execute my p4 program, the system gives the above error and my protoc version is 3.6.1. can I find an older version of p4-utils to use the p4run command? Will it affect my p4 environment if I use the upgrade protobuf approach?

CLI: Exit p4switch_start method if switch already running

If the P4 switch is already running, an error message is correctly issued. The issue is nevertheless, that the method is not exited at this stage which leads to an unsuccessful reload which stops the CLI.

Reproduce

  • Start a P4 switch that is already running

Error Output

mininet> p4switch_start s4
P4 Switch already running, stop first: p4switch_stop s4 
File includes/headers16.p4 does not exist 
../p4src/main.p4 p4src/main.json False False
Starting P4 switch s4.
simple_switch -i 1@s4-eth1 -i 2@s4-eth2 -i 3@s4-eth3 --pcap --thrift-port 9093 --nanolog ipc:///tmp/bm-3-log.ipc --device-id 3 p4src/main.json --log-console
P4 switch s4 did not start correctly.Check the switch log file.

Changing compiler from p4app.json

I'm not sure this is a true issue, but as long as there's no documentation online I'd rather try to ask it to you. I need to compile using p4c-bm2-ss compiler to use my custom externs. I was capable of doing it with a previous version of p4utils (the one in the p4lang pre-built vm) by setting the "compiler" field in p4app.json file. But now that the "compiler_module" field should be filled, I'm not so sure I can force the usage of that compiler as no python class has been implemented for it in p4utils/utils/compiler subfolder.

Thank you in advance.

Read and write to registers

Hello,

I just want to ask if P4-UTILS supports reading and writing to registers. I highly appreciate your help.

Thank you.

register cell size

When I used registers to store data, I found that the value read was -1 when the register cell size was defined to be 72 bits, but this did not happen with 64 bits. I found in the p4 learning tutorial that the maximum register cell size is defined as 64 bits. Does this mean trying to define the size of register cells to be 64 bits or less when using registers.

How to update link delay & routing tables during runtime

I am using P4Utils to create a network topology where there are multiple (3) paths between 2 hosts. I would like to send packets to compute the fastest path and update the forwarding tables given to each switch during runtime.

The network topology is made using the p4utils.mininetlib.network_API module.

To do this I am struggling to figure out how to perform two functions:

  1. Change link delay between two switches during runtime:
    I am setting the link delay using the setDelay() function when creating the network. Is there a way to change the delay of a link during runtime?

  2. Update routing tables during runtime:
    The original routing table rules for each switch are defined in a sN-commands.txt file which I am feeding to each switch with net.setP4CliInput('sN', 'sN-commands.txt'). Is it possible to either, alter the text file during runtime to change the rules, or give the switch a new set of command for a different file during runtime?

Edit: A previous version asked about updating link bandwidth, this has been changed to ask about link delay.

multiple mac error

I am trying to add ip and mac manually but it gives me the following error. Can someone please indicate the mistake?
"hosts": { "h1": {"ip":"10.0.1.1", "mac":"00:00:00:34:00:54" }, "h2": { } }
image

How to add --custom to start the mininet

P4-Utils is a great tool to help me to start P4. And now I want to add the SFlow to monitor the flow and the mininet. So I must modify the args of the start mininet. I read the P4-Utils codes, but I don't know how to alter the args to do this. At first, I read the /p4utils/p4run.py and found that there was something written in the p4app.json. So I want to look for help to add the --custom sflow.py to the args when start the mininet.

Problem with switch_thrift_API.py file

I'm trying to run a project using p4-utils. But when I call SimpleSwitchThriftAPI() in the connect_to_switches() function, I find that I always get an exception error at the load_json_config() function in the thrift_API.py. The connect_to_switches() function like this:
def connect_to_switches(self):
for p4switch in self.topo.get_p4switches():
thrift_port = self.topo.get_thrift_port(p4switch)
self.controllers[p4switch] = SimpleSwitchThriftAPI(thrift_port)

Table entry timeout

I know that with p4-utils and its runtimeAPI, tables can support timeouts with support_timeout: true.
However I can only set the timeouts using the CLI features.

Is there any way to define the timeout period with a python controller and how can I intercept these packets at the controller?
I have been working with P4-utils but I think I might have to go with other repos that support P4Runtime.

Tofino Example: no bf_swithcd for one of the switches

Hello everyone,
I have been trying to run the tofino example (https://github.com/nsg-ethz/p4-utils/tree/master/examples/tofino). Although, every time I set up the network, I can run run_bfshell.sh for only one of the switches (either s1 or s2). It looks like that bf_switchd is not running at all on the specific switch.
Screenshot from 2023-06-26 10-23-11
Screenshot from 2023-06-26 10-23-24
Is it possible that happens because of the fact that BF Runtime Server is using the same port (50051) every time it's being started?
SDE Version: 9.11.0
Thank you in advance.

Excel

Switch does not have cpu port

I run Mininet with p4-utils. However, when configuring the P4Switch, the shell says that "switch 1 has no cpu port". The result is that I cannot use "mirror" primitive in my experiment. Anyone can help? Thanks.

Bvm2 switch on p4util topo cannot ping between hosts

I have downloaded the qemu vm , after creating a simple network.py file just like in the docs and making a very simple p4 program that just routes icmp traffic, no hosts can be reached when doing pingall command as well as h1 to h2 etc.

I have tried many ways but nothing works, the P4 program is working because it is from the solutions section (basic.p4) of the p4 langs tutorial repo, so i have a feeling its to do with the switch itself.

network.py:

from p4utils.mininetlib.network_API import NetworkAPI
net = NetworkAPI()

net.setLogLevel('info')

net.addP4Switch('s1')
net.addHost('h1')
net.addHost('h2')
net.addHost('h3')
net.addHost('h4')

net.setP4Source('s1','basic.p4')

net.addLink('s1', 'h1')
net.addLink('s1', 'h2')
net.addLink('s1', 'h3')
net.addLink('s1', 'h4')

net.setIntfPort('s1', 'h1', 1) # Set the number of the port on s1 facing h1
net.setIntfPort('h1', 's1', 0) # Set the number of the port on h1 facing s1
net.setIntfPort('s1', 'h2', 2) # Set the number of the port on s1 facing h2
net.setIntfPort('h2', 's1', 0) # Set the number of the port on h2 facing s1
net.setIntfPort('s1', 'h3', 3) # Set the number of the port on s1 facing h3
net.setIntfPort('h3', 's1', 0) # Set the number of the port on h3 facing s1
net.setIntfPort('s1', 'h4', 4) # Set the number of the port on s1 facing h4
net.setIntfPort('h4', 's1', 0) # Set the number of the port on h4 facing s1

net.setBwAll(100)
net.l2()

net.enablePcapDumpAll()
net.enableLogAll()

net.enableCli()
net.startNetwork()

basic.p4 file can be found at solutions in the basic section of the p4langs tutorial https://github.com/p4lang/tutorials/blob/master/exercises/basic/solution/basic.p4

'MininetLogger' object has no attribute 'ch'

hello,I install p4-utils and run it in p4-learning,but error occur,here is image ,can you help me?thanks
wcc@ubuntu:/p4/p4-learning/exercises/01-Reflector$ p4run
Traceback (most recent call last):
File "/usr/local/bin/p4run", line 11, in
load_entry_point('p4utils', 'console_scripts', 'p4run')()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2693, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2324, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2330, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/home/wcc/p4/p4-utils/p4utils/p4run.py", line 33, in
from p4utils.utils.helper import *
File "/home/wcc/p4/p4-utils/p4utils/utils/helper.py", line 21, in
from p4utils.mininetlib.log import info, output, error, warning, debug
File "/home/wcc/p4/p4-utils/p4utils/mininetlib/log.py", line 92, in
lg.ch.setFormatter( formatter )
AttributeError: 'MininetLogger' object has no attribute 'ch'
wcc@ubuntu:
/p4/p4-learning/exercises/01-Reflector$

Username and password for pre-installed VM

Hi author,
thank you for providing the pre-installed VM.
I have opened it, but it seems to use the username and password.
I can not find the relevant information in the documentation.
Can you help me, please?
image

ModuleNotFoundError: No module named 'p4utils.mininetlib.p4net'

Hi all,

My environment is Ubuntu 18.04 and my GCC version is 7.5. I have installed all the dependencies using the script provided and run install.sh. When I tired to start p4run, this error occurs.

Traceback (most recent call last):
File "/usr/local/bin/p4run", line 11, in
load_entry_point('p4utils', 'console_scripts', 'p4run')()
File "/home/ubuntu/p4-utils/p4utils/p4run.py", line 739, in main
verbosity=args.verbosity)
File "/home/ubuntu/p4-utils/p4utils/p4run.py", line 308, in init
mininet = load_custom_object(mininet_module)
File "/home/ubuntu/p4-utils/p4utils/utils/helper.py", line 321, in load_custom_object
module = importlib.import_module(module_name)
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'p4utils.mininetlib.p4net'

Does anyone know how to fix this?

Thank you so much!

Bittorent recognition from packet payload

Hello, i am trying to recognize whether the incoming packet belongs to a bittorrent activity. What i've done so far is to create a copy of the packet to CPU and from there try to inspect inside the packet payload for traces of bittorrent activity and change the priority channel, is it possible that it can somehow workout?
Secondly, i am trying also to add NAT services on my network for some internet connection, but i haven't found the way to do it yet, is there a way to do it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.