p4lang / tutorials Goto Github PK
View Code? Open in Web Editor NEWP4 language tutorials
License: Apache License 2.0
P4 language tutorials
License: Apache License 2.0
Hello,
I'm tring the demo named mri
in the branch P4D2
, and noticed that the table swid
missed the declaration of NoAction
. See mri.p4/#L184. It will raise the error like this:
Entering build directory.
Extracting package.
Reading package manifest.
> p4c-bm2-ss --p4v 16 "mri.p4" -o "mri.p4.json"
mri.p4(188): error: NoAction not present in action list
default_action = NoAction();
^^^^^^^^
Compile failed.
It should be like this:
table swid {
actions = { add_swid; NoAction; }
default_action = NoAction();
}
By the way, I noticed that you are still working on the p4v1.2 specification and p4c
compiler. Thank you for this great work!
Best regards,
Chen.
I'm trying to run the l3 forwarding p4 app and when i launch ./run.sh i get:
Entering build directory.
Extracting package.
Reading package manifest.
p4c-bm2-ss --p4v 16 "ipv4_forward.p4" -o "ipv4_forward.p4.json"
sh: 1: p4c-bm2-ss: not found
Compile failed.
I can't seem to figure out how to fix this, I found p4c-bm2-ss in the p4c compiler as a backend tool, but I'm not using it, should i be? In other words i'm using the bmv2 and the p4c-bmv2 and getting this message
...
Reading package manifest.
> p4c-bm2-ss --p4v 16 "mri.p4" -o "mri.p4.json"
mri.p4(115): warning: parse_ipv4_option: implicit transition to `reject'
state parse_ipv4_option {
^^^^^^^^^^^^^^^^^
mri.p4(124): warning: parse_mri: implicit transition to `reject'
state parse_mri {
^^^^^^^^^
mri.p4(135): warning: parse_swid: implicit transition to `reject'
state parse_swid {
^^^^^^^^^^
mri.p4(201): warning: Table swid is not used; removing <--- table gets removed
table swid {
^^^^
...
Due to this, later when the swid table gets programmed, it's not available and addition of entry fails.
....
Control utility for runtime P4 table manipulation
RuntimeCmd: Setting default action of ipv4_lpm
action: drop
runtime data:
RuntimeCmd: Error: Invalid table name (swid) <---- failure here
RuntimeCmd: Adding entry to lpm match table ipv4_lpm
...
I just set up a VM for these tutorials. While executing run.sh for the "basic" exercise, I get the following error:
basic.p4(160): error: main: Cannot unify parameter hdr with hdr because they have different directions
) main;
^^^^
basic.p4(65)
control MyVerifyChecksum(in headers hdr, input metadata mets) {
^^^
/usr/local/share/p4c/p4include/v1model.p4(197)
control VerifyChecksum<H, M>(inout H hdr,
^^^
Compile failed.
Upon a web search, I did see that this issue was raised ~3 weeks back, and was supposedly fixed. However, I still get this error on a fresh install. Any thoughts on how to fix it?
Thanks,
Shyam
Hi,
I'm trying to run copy_to_cpu example. However, I get the following error while running either 'udo python send.py' or 'udo python receive.py' commands:
socket.error: [Errno 19] No such device
Any idea?
Want to know how to implement multicast in P4 switch. I have read the p4-spec, and it seems that clone_egress_pkt_to_egress can be used, but not recommended. However there's no use case for that action, and I'm confused about the two arguments(clone_spec, field_list) it takes. How to determine the egress specification with clone_spec ?
Hi,I want to get the topology of the switchs.Which command can I use?Thanks.
Hi everybody,
Please I want count number of SYN request sending by each host on network for this end I create a counter as bellow:
counter ip_src_counter {
type: packets;
static: count_table;
instance_count: 1024;
}
//with action
action count_action(idx) {
count(ip_src_counter, idx);
}
// Here I specify (IPsrc and IPdst, srcPort, TCP_SYNfalgs
//Please I want to know if it s the correct way to specify TCP_SYN_flag field (as bellow tcp.tcpFlags1 : exact;)on p4 and how can I also specify TCP_ACK_flag field sending by source if I want to do
table count_table {
reads {
ipv4.srcAddr : ternary;
ipv4.dstAddr : exact;
tcp.srcPort : ternary;
tcp.tcpFlags1 : exact;
}
actions {
count_action;
_drop;
}
size : 1024;
}
I generate traffic between hosts then I try to read counter for each host It gives 0 packets
please find attached p4 program
Counter_SYN_paquet.txt
In the arp example.
https://github.com/p4lang/tutorials/tree/master/P4D2_2017/exercises/arp
The description says:
An action (named ipv4_forward) to store information in the metadata structure, rather than immediately writing to the packet header.
A table (named ipv4_lpm) that will match on the destination IP address and invoke the ipv4_forward action.
But actually the action for ipv4_lpm should be set_dst_info
in simple_router.config:
table_add ipv4_lpm set_dst_info 10.0.1.10/24 => 00:00:01:00:00:01 00:00:02:00:00:02 1
Hi,
I think there is a small copy-paste bug at line 57 in P4D2_2017_Spring/utils/mininet/apptopo.py
delay_key = ''.join(sorted([host_name, sw]))
should be
delay_key = ''.join(sorted([sw1, sw2]))
Hope it helps!
Hi, all.
Happy to see that the P4D2_2017 have been published today. But I found a problem(or a bug?) which makes me puzzled as I tried the exercise named mri
.
Ubuntu 14.04, 64bit
Already install the bmv2, p4c-bm, p4c, mininet etc.
1.First fullfill the env.sh
with my environment settings.
2.Fllow the steps below:
$ cd P4D2_2017/exercises/mri
// I use the solution in my first attempt:
$ mv mri.p4 oldmri.p4
$ cp -r solution/mri.p4 ./
$ ./run.sh
The step ./run.sh
raised the error OSError: [Errno 2] No such file or directory
:
Entering build directory.
Extracting package.
Reading package manifest.
> p4c-bm2-ss --p4v 16 "mri.p4" -o "mri.p4.json"
*** Log directory /home/wasdns/tutorials/P4D2_2017/exercises/mri/build/logs
*** Pcap directory /home/wasdns/tutorials/P4D2_2017/exercises/mri/build
> python2 "/home/wasdns/tutorials/P4D2_2017/utils/mininet/multi_switch_mininet.py" --log-dir "/home/wasdns/tutorials/P4D2_2017/exercises/mri/build/logs" --manifest "./p4app.json" --target "multiswitch" --auto-control-plane --behavioral-exe "simple_switch" --json "mri.p4.json" --cli-message "mininet_message.txt"
*** Creating network
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1 s2 s3
*** Adding links:
Traceback (most recent call last):
File "/home/wasdns/tutorials/P4D2_2017/utils/mininet/multi_switch_mininet.py", line 242, in <module>
main()
File "/home/wasdns/tutorials/P4D2_2017/utils/mininet/multi_switch_mininet.py", line 145, in main
controller = None)
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 164, in __init__
self.build()
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 357, in build
self.buildFromTopo( self.topo )
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 344, in buildFromTopo
self.addLink( src, dst, srcPort, dstPort, **params )
File "/usr/lib/python2.7/dist-packages/mininet/net.py", line 287, in addLink
return cls( node1, node2, **defaults )
File "/usr/lib/python2.7/dist-packages/mininet/link.py", line 400, in __init__
params2=params)
File "/usr/lib/python2.7/dist-packages/mininet/link.py", line 350, in __init__
self.makeIntfPair( intfName1, intfName2 )
File "/usr/lib/python2.7/dist-packages/mininet/link.py", line 381, in makeIntfPair
makeIntfPair( intf1, intf2 )
File "/usr/lib/python2.7/dist-packages/mininet/util.py", line 154, in makeIntfPair
quietRun( 'ip link del ' + intf1 )
File "/usr/lib/python2.7/dist-packages/mininet/util.py", line 117, in quietRun
return errRun( cmd, stderr=STDOUT, **kwargs )[ 0 ]
File "/usr/lib/python2.7/dist-packages/mininet/util.py", line 77, in errRun
popen = Popen( cmd, stdout=PIPE, stderr=stderr, shell=shell )
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
After the attempt to fix this problem, I found a question that is most similar to my situation:
But the solution is useless to me. The problem is still remained.
Could you give me some instructions on how to deal with it? Thanks a lot!
As I understand, the features like broadcast, obtaining buffer queue size and registers for storing global data are architecture specific.
Right now I am still learning how to make p4 work with mininet and bmv2 simple switch as given in the tutorials.
Do we have any way to do broadcast, obtain buffer queue size (individual for each port or combined, whatever way is the implementation) and store global variables (do not change with packet) in the simple switch?
It might be out of scope here because it is related to mininet, let me know if its possible to run separate p4 file in each mininet switch. The way it is set right now /tutorials/P4D2_2017/utils/mininet/* is to pass P4switch object to mininet.
I have filled in command.txt by using the example of flowlet_switching/commands.txt and h3 will show nothing when I send message "Hello" from h1. I have typed "./receive.py" in h3 and "./send.py h1 h3" in h1. Can someone help me about that?
By the way, when I typed ".receive.py" in h3 it said "No route found for IPv6 destination ::(no default route?)", does this matter with my problem?
Kind Regards
For some reason I want to parse TCP Options using p4 , but it seems that there is no such a helpful code to reference in this repository and P4 spc.
Could you please give me some advise how to parse TCP Options using p4?
Thanks. John.
Hi. Recently, I am trying the example named source_routing in tutorial/SIGCOMM2015/.
I just followed README. And installed some tools like thrift. I list some version INFO below:
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
Python 2.7.6
Thrift version 1.0.0-dev
And the directory:
bmv2:/home/wasdns/bmv2
p4c-bm:/home/wasdns/p4c-bmv2
tutorial:/home/wasdns/tutorials
Then I used the solution provided.
I copyed the env.sh to the directory /tutorial/SIGCOMM2015/source_routing
:
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# ---------------- EDIT THIS ------------------
BMV2_PATH=/home/wasdns/bmv2
# e.g. BMV2_PATH=$THIS_DIR/../bmv2
P4C_BM_PATH=/home/wasdns/p4c-bmv2
# e.g P4C_BM_PATH=$THIS_DIR/../p4c-bm
# ---------------- END ------------------
The run_demo.sh I used:
#!/bin/bash
# Copyright 2013-present Barefoot Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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=$BMV2_PATH/targets/simple_switch/simple_switch
CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py
$P4C_BM_SCRIPT p4src/source_routing.p4 --json source_routing.json
# This gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
--behavioral-exe $SWITCH_PATH \
--json source_routing.json \
--cli $CLI_PATH
The commands.txt:
table_set_default ecmp_group _drop
table_set_default ecmp_nhop _drop
table_set_default forward _drop
table_set_default send_frame _drop
table_add ecmp_group set_ecmp_select 10.0.0.1/32 => 0 2
table_add ecmp_nhop set_nhop 0 => 10.0.1.1 1
table_add ecmp_nhop set_nhop 1 => 10.0.2.1 2
table_add forward set_dmac 10.0.1.1 => 00:04:00:00:00:00
table_add forward set_dmac 10.0.2.1 => 00:04:00:00:00:01
table_add send_frame rewrite_mac 1 => 00:aa:bb:00:00:00
table_add send_frame rewrite_mac 2 => 00:aa:bb:00:00:01
The I run ./run_demo.py
, and it started:
root@ubuntu:/home/wasdns/tutorials/SIGCOMM_2015/source_routing# ./run_demo.sh
parsing successful
semantic checking successful
Header type standard_metadata_t not byte-aligned, adding padding
Generating json output to /home/wasdns/tutorials/SIGCOMM_2015/source_routing/source_routing.json
*** Creating network
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1 s2 s3
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (s1, s2) (s1, s3) (s2, s3)
*** Configuring hosts
h1 h2 h3
*** Starting controller
*** Starting 3 switches
s1 Starting P4 switch s1
/home/wasdns/bmv2/targets/simple_switch/simple_switch -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 source_routing.json
switch has been started
s2 Starting P4 switch s2
/home/wasdns/bmv2/targets/simple_switch/simple_switch -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 source_routing.json
switch has been started
s3 Starting P4 switch s3
/home/wasdns/bmv2/targets/simple_switch/simple_switch -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 source_routing.json
switch has been started
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/home/wasdns/bmv2/tools/runtime_CLI.py --json source_routing.json --thrift-port 22222
Control utility for runtime P4 table manipulation
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd:
/home/wasdns/bmv2/tools/runtime_CLI.py --json source_routing.json --thrift-port 22223
Control utility for runtime P4 table manipulation
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd:
/home/wasdns/bmv2/tools/runtime_CLI.py --json source_routing.json --thrift-port 22224
Control utility for runtime P4 table manipulation
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (ecmp_group)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (ecmp_nhop)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (forward)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd: Error: Invalid table name (send_frame)
RuntimeCmd:
Ready !
*** Starting CLI:
mininet>
Then I tried h1 ping h3
, it failed.
I'm puzzled...How can I solved this problem?
Thank you very much!
Chen.
Hi Antonin,
file register.p4
line 68, 69
modify_field_rng_uniform(meta.register_tmp, 100, 200);
register_write(my_register, register_idx, meta.register_tmp);
Could you please refer to some doc where I find what these functions are doing. Intuitively I can understand , but which parameter is getting written where is somewhat obscure to me.
Also I have seen these command used through cli at runtime to update the switch tables:
table_set_default m_table m_action
table_add m_table m_action aa:bb:cc:dd:ee:ff => 0
what does that do exactly. Again if there is any quick readme on that please share.
Hi, I want to know how to print the byte representation of the packet at xterm. I can read that through the pcap file, just like this: 00 00 00 00 00 00 00 00 68 65 6c 6c 6f ........hello. I try to read middle bytes(bold) by doing this in the receive.py:
pkt = str(pkt) // pkt is the packet from network
number = struct.unpack("<L", pkt[4:8])[0] // get the middle bytes
print('number: %s' %number)
I can get a really large integer, like 10063296, but when I check the pcap file, I see this:
00 00 00 00 00 00 00 06 68 65 6c 6c 6f ........hello.
So I don't get the same number as in pcap file, can't figure out why.
I have created a very simple topo(h1-s1-h2) based on source_routing, and changed the related files. It passed the compiler, but when I tried the command: h1 ping -c4 h2 in the mininet CLI, there were 100% paket loss. I have checked the s1-eth1.pcap and I can see the packet, while nothing in the s1-eth2.pcap. Maybe there's something wrong in the soft switch, but I can't figure it out. So please help me. The p4 code is below:
p4src
header_type sequencer_head_t {
fields {
preamble: 64;
serial_number: 32;
}
}
header sequencer_head_t sequencer_head;
header_type ingress_metadata_t {
fields {
serial_number : 32;
}
}
metadata ingress_metadata_t ingress_data;
register serial_number {
width : 32;
instance_count : 1;
}
parser start {
return select(current(0, 64)) {
0: parse_head;
default: ingress;
}
}
parser parse_head {
extract(sequencer_head);
return ingress;
}
action route() {
register_read(ingress_data.serial_number, serial_number, 0);
modify_field(sequencer_head.serial_number, ingress_data.serial_number);
add_to_field(ingress_data.serial_number, 1);
register_write(serial_number, 0, ingress_data.serial_number);
}
table route_pkt {
actions {
route;
}
}
control ingress {
apply(route_pkt);
}
control egress {
// leave empty
}
commands.txt
table_set_default route_pkt route
run_demo.sh
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=$BMV2_PATH/targets/simple_switch/simple_switch
CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py
$P4C_BM_SCRIPT p4src/sequencer.p4 --json sequencer.json
sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py
--behavioral-exe $SWITCH_PATH
--json sequencer.json
--cli $CLI_PATH
P4D2_2017_Fall/P4_tutorial_labs.pdf
has information on the signature of hash()
that should be copied into load_balancing.p4
.ecmp_base
and ecmp_count
are needed in load_balancing p4
. (Otherwise, I wouldn't know to use them for base
and max
in the call to hash()
.)Hash<bit<14>>(HashAlgorithm_t.CRC16) h;
meta.ecmp_select =
h.get_hash({hdr.ipv4.srcAddr, hdr.ipv4.dstAddr,
hdr.ipv4.protocol, hdr.tcp.srcPort, hdr.tcp.dstPort});
Resulting error:
syntax error, unexpected IDENTIFIER, expecting ;
Hash<bit<14>>(HashAlgorithm_t.CRC16) h
^
The script "sudo $SWITCH_PATH resubmit.json
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8
--nanolog ipc:///tmp/bm-0-log.ipc --log-console
--pcap &" in run_switch.sh add 5 interfaces into the P4 switch.
But the test script in send_and_receive.py uses the veth1 and veth7 to send and receive packets respectively...It does work, and the P4 consle echos right information. But, in fact veth1 and veth7 are not added to the p4 switch...
I have try to use other virtual ethernet interfaces to send packets which is not added to the P4 switch...It still works.
Is there some problem?
It seems that the solution provided for the MRI exercise doesn't cover all the details. For example, it's necessary to update totalLen
in the IP header anytime the size of packet changes.
Thus, the add_mri_option()
action should be something like:
@name("add_mri_option") action add_mri_option() {
hdr.ipv4_option.setValid();
hdr.ipv4_option.copyFlag = 1;
hdr.ipv4_option.optClass = 2;
hdr.ipv4_option.option = IPV4_OPTION_MRI;
hdr.ipv4_option.optionLength = 4;
hdr.mri.setValid();
hdr.mri.count = 0;
hdr.ipv4.ihl = hdr.ipv4.ihl + 1;
hdr.ipv4.totalLen = hdr.ipv4.totalLen + 4;
}
The ASCII of '|' should be 0x7c, not 0x7e.
Just a small thing, but obviously he will wait a '~' to do the OR as it is
I have set up the necessary software and environment for Exercise 1 : Source Routing, but I face some problems when I want to run it:
The shell reports:
Command '['/home/jy/tutorials/./bmv2/tools/runtime_CLI.py', '--json', 'source_routing.json', '--thrift-port', '22222']' returned non-zero exit status 1
Could not connect to thrift client on port 22222
Make sure the switch is running and that you have the right port
And when one host sends a packet, the other cannot receive.
Since basic.p4
is a first look at a P4 program, I think more comments would be nice. For example, it would be helpful to have a comment on ipv4_forward()
saying that the dstAddr
and port
arguments (1) are provided as action data when the control plane fills out the ipv4_lpm
table, and (2) indicate the Ethernet destination and port number on which the packet should be forwarded.
Updated bmv2 to the latest version, and thread through flag to change output log directory for simple_switch (currently, it defaults to /tmp).
I see that every SIGCOMM repo has a tutorial, and there are some overlapping examples. Trying to figure out where to start exactly, thanks very much.
Hello,
I have a problem with the heavy_hitter example. When I run ./run_demo.sh the switch s1 can not be setup correctly with the following message:
*** Starting 1 switches s1 Starting P4 switch s1. /home/simon/Documents/p4/tutorials/../bmv2/targets/simple_switch/simple_switch -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 heavy_hitter.json P4 switch s1 did not start correctly.
Everything should be setup right, because it already worked last week with the 2015 tutorial "source routing"
Thanks for your help.
Hi,
VM was copied from USB during P4 Developer Day 2017, so it should be good.
My problem is the solution doesn't run. After examining the logs, the LPM lookup
resulted in a miss (used the correct ipv4.dstAddr). The table for S1 was populated
during runtime. However, for all the switches, there were errors similar to:
No handlers could be found for logger "thrift.transport.TSlocket"
Could not connect to thrift client on port 909x (x = 0-2)
right after all the table_adds. Search for similar problems only pointed to
a previous deprecation issue, but this should all be the latest. Could there
be some other problems (setup) with VirtualBox I'm using?
Thanks for any pointers. BTW, solution for other exercises don't run
either, so it's probably my setup instead of the code itself. Sorry for
the submission here, if this is the wrong place.
James
Logs below:
~/p4/tutorials/P4D2_2017/exercises/ipv4_forward$ ./run.sh
tar: build: file changed as we read it
Entering build directory.
Extracting package.
Reading package manifest.
> p4c-bm2-ss --p4v 16 "ipv4_forward.p4" -o "ipv4_forward.p4.json"
sh: 1: p4c-bm2-ss: not found
Compile failed.
In the proposed solution for the flowlet switching tutorial
(simple_router.p4 in https://github.com/p4lang/tutorials/blob/master/SIGCOMM_2015/flowlet_switching/solution.tar.gz)
The timestamp is defined as 32 bits in the metadata ingress_metadata_t (fields flowlet_lasttime and flow_ipg) and in the register flowlet_lasttime, but I think should be 48 bits. In fact in the intrinsic.p4 file the timestamp is defined as 48 bits (correct according to https://github.com/p4lang/tutorials/blob/master/SIGCOMM_2016/p4-tutorial-slides.pdf).
In the action lookup_flowlet_map() the call to
modify_field_with_hash_based_offset()
has FLOWLET_MAP_SIZE (=13) as size value, but I think it should be 2^13=8192.
The P4_14 document says:
modify_field_with_hash_based_offset(dest, base, field_list_calc, size)
...
size (VAL) The size of the hash value range. Must be larger than 0.
...
The hash value is used to generate a value between base and (base + size - 1) by calculating (base + (hash_value % size)).
so size should be the max value that the result can have +1, not the number of bits.
Hello,
I m woking in heavy_hitter project (example 1) I download the project then I try to compile the p4 code and run the switch and the mininet instance, while running ./run_demo.sh and I get
I try to make that manually
But the ping don't pass
Please how can I resolve the problem
When I run run_demo.sh in p4v1_1 simple router folder, it gives me "You requested P4 v1.1 but the corresponding p4-hlir package does not seem to be installed". I am pretty sure I have installed p4-hlir because I have successfully setup.py in p4-hlir folder. Can someone help me with that?
Here is the full output error message when I run run_demo.sh:
You requested P4 v1.1 but the corresponding p4-hlir package does not seem to be installed
*** Creating network
*** Adding hosts:
h1 h2
*** Adding switches:
Invalid JSON file.
Hi,
I try to perform manually the project heavy_hitter and exactly ''counter_example''
https://github.com/p4lang/tutorials/tree/master/SIGCOMM_2016/heavy_hitter/counter_example
on simple router.
I compile heavy_hitter.P4 to have json file : **OK**
When I type the following commande:
sudo python 1sw_demo.py --behavioral-exe ../targets/simple_router/simple_router --json ../targets/simple_router/heavy_hitter.json
It gives me an error '' p4 switch s1 did not started correctly "
Please What is the problem exactly
Hello, is there anyone have the problem as the follow?
Could not find declaration for update_checksum
update_checksum(
^^^^^^^^^^^^
Compile failed
Since P4D2_2017 seemed to provide an environment to run P4-16 programs, I've been trying the examples in P4D2_2017 with native installation of the required software, but I can't get the solutions to run.
P4 switch s1 did not start correctly.Check the switch log file.
The log file reads:
Unknown primitive action: assign
My own code ran well (sort of, see below) until I modified a (previously empty) TopIngress like this:
control TopIngress(inout Parsed_packet p, inout Metadata m,
inout standard_metadata_t standard_metadata) {
apply {
standard_metadata.egress_spec = 3 - standard_metadata.ingress_port;
}
}
I previously encountered problems running my program when using varbits (see the end of this message) and subparsers (in this case, it complained about unknown primitive assign_header
).
I've tried replacing the code with a table that matches on the ingress_port and sets the egress_port since that approach is closer to P4-14, but it still yields the same error.
The error logged with varbits was:
simple_switch: P4Objects.cpp:449: int bm::P4Objects::init_objects(std::istream*, bm::LookupStructureFactory*, int, size_t, std::shared_ptrbm::TransportIface, const std::set<std::pair<std::__cxx11::basic_string, std::__cxx11::basic_string > >&, const bm::P4Objects::ForceArith&): Assertion `cfg_header_type.isMember("length_exp")' failed.
Calling target program-options parser
Just want to know if p4 register is working well for now.
Hello,
I try to perform heavy_hitter project for that
I download "Tutorials" directory and sub-directories and docs
I cloned bmv2 and p4c-bmv2 in the "tutorials" directory
git clone https://github.com/p4lang/behavioral-model.git bmv2
git clone https://github.com/p4lang/p4c-bm.git p4c-bmv2
this is env.sh that I use
env.sh.txt
In SIGCOM_2016/heavy_hitter project I try to compile the p4src/heavy_hitter.p4 code and run the switch and the mininet instance, while running ./run_demo.sh and I get
It can't open file 'topo.py': [Errno 2] No such file or directory
Even though the path of topo.py is alredy defined in run_demo.sh as bellow
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
--behavioral-exe $SWITCH_PATH \
--json heavy_hitter.json \
--cli $CLI_PATH
Thank you for your interest and help
I'm stuck while trying to run source_routing tutorial from SIGCOMM_2015. All examples are running on Mininet-VM based on Ubuntu 14.04 LTS.
First, i cloned and installed bmv2 and p4c-bmv2 with all dependencies. env.sh
file looks like this:
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# ---------------- EDIT THIS ------------------
BMV2_PATH=/home/mininet/mgr/bmv2
# e.g. BMV2_PATH=$THIS_DIR/../bmv2
P4C_BM_PATH=/home/mininet/mgr/p4c-bm
# e.g P4C_BM_PATH=$THIS_DIR/../p4c-bm
# ---------------- END ------------------
and placed in source_routing directory.
I'm using Barefoot provided solution (source_routing.p4
and commands.txt
) from solution.tar.gz
file.
Then, with veth_setup.sh
from /bmv2/tools/
i create virtual ports.
#!/bin/bash
for idx in 0 1 2 3 4 5 6 7 8; do
intf0="veth$(($idx*2))"
intf1="veth$(($idx*2+1))"
if ! ip link show $intf0 &> /dev/null; then
ip link add name $intf0 type veth peer name $intf1
ip link set dev $intf0 up
ip link set dev $intf1 up
fi
done
Next, I run the script run_demo.sh
which looks :
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $THIS_DIR/env.sh
P4C_BM_SCRIPT=/home/mininet/mgr/p4c-bm/p4c_bm/__main__.py
SWITCH_PATH=$BMV2_PATH/targets/simple_switch/simple_switch
CLI_PATH=$BMV2_PATH/targets/simple_switch/simple_switch_CLI
$P4C_BM_SCRIPT p4src/source_routing.p4 --json source_routing.json
# This gives libtool the opportunity to "warm-up"
sudo $SWITCH_PATH >/dev/null 2>&1
sudo PYTHONPATH=$PYTHONPATH:$BMV2_PATH/mininet/ python topo.py \
--behavioral-exe $SWITCH_PATH \
--json source_routing.json \
--cli $CLI_PATH
I also tried runtime_CLI.py
from /bmv2/tools
and /p4factory/submodules/bm/tools
- same effect.
Script creates topology succesfully but it cant connect to any port.
parsing successful
semantic checking successful
Header type standard_metadata_t not byte-aligned, adding padding
Generating json output to /home/mininet/mgr/tutorials/SIGCOMM_2015/source_routing/source_routing.json
*** Creating network
*** Adding hosts:
h1 h2 h3
*** Adding switches:
s1 s2 s3
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (s1, s2) (s1, s3) (s2, s3)
*** Configuring hosts
h1 h2 h3
*** Starting controller
*** Starting 3 switches
s1 Starting P4 switch s1
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch --name s1 --dpid 0000000000000001 -i s1-eth1 -i s1-eth2 -i s1-eth3 --listener 127.0.0.1:11111 --pd-server 127.0.0.1:22222
switch has been started
s2 Starting P4 switch s2
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch --name s2 --dpid 0000000000000002 -i s2-eth1 -i s2-eth2 -i s2-eth3 --listener 127.0.0.1:11111 --pd-server 127.0.0.1:22223
switch has been started
s3 Starting P4 switch s3
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch --name s3 --dpid 0000000000000003 -i s3-eth1 -i s3-eth2 -i s3-eth3 --listener 127.0.0.1:11111 --pd-server 127.0.0.1:22224
switch has been started
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/sbin/ethtool --offload eth0 rx off
/sbin/ethtool --offload eth0 tx off
/sbin/ethtool --offload eth0 sg off
disable ipv6
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI --json source_routing.json --thrift-port 22222
No handlers could be found for logger "thrift.transport.TSocket"
Command '['/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI', '--json', 'source_routing.json', '--thrift-port', '22222']' returned non-zero exit status 1
Could not connect to thrift client on port 22222
Make sure the switch is running and that you have the right port
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI --json source_routing.json --thrift-port 22223
No handlers could be found for logger "thrift.transport.TSocket"
Command '['/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI', '--json', 'source_routing.json', '--thrift-port', '22223']' returned non-zero exit status 1
Could not connect to thrift client on port 22223
Make sure the switch is running and that you have the right port
/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI --json source_routing.json --thrift-port 22224
No handlers could be found for logger "thrift.transport.TSocket"
Command '['/home/mininet/mgr/bmv2/targets/simple_switch/simple_switch_CLI', '--json', 'source_routing.json', '--thrift-port', '22224']' returned non-zero exit status 1
Could not connect to thrift client on port 22224
Make sure the switch is running and that you have the right port
Ready !
*** Starting CLI:
mininet>
My Thrift version is 0.9.2
.
I realize, it gives same outcome with:
https://github.com/p4lang/behavioral-model#integrating-with-mininet
and flowlet_switching
example
No handlers could be found for logger "thrift.transport.TSocket"
Could not connect to thrift client on port 9090
Make sure the switch is running and that you have the right port
even, they both work fine before.
How can I solve this problem? Thanks for commitment!
Step 2, item 5 of tutorials/P4D2_2017_Fall/exercises/basic/README.md
is a TODO that appears to be done already in tutorials/P4D2_2017_Fall/exercises/basic/basic.p4
:85–101.
I use v1model (v1model.p4) to build the program. When I tried to instantiate extern registers at the top-level of my program and read register values at one of actions, I got error:
P4 switch s1 did not start correctly.Check the switch log file.
S1 log:
terminate called after throwing an instance of 'std::out_of_range'
what(): _Map_base::at
Calling target program-options parser
After I changed to declare registers in the ingress control block, I can run my program.
I don't find in P4_16 spec that forbids us to declare extern objects in the top-level.
Hi,
I followed the officiel tutorial '' https://github.com/p4lang/behavioral-model '' for installing P4/BMv2 on Ubuntu 14.04.5 LTS (desktop )
1, I installed the dependecies needed using the install_deps.sh script.
2, I try to install the thrift and nanomsg from the /travis source
./install-nanomsg.sh
./install-thrift.sh
./install-nnpy.sh
Then I get this message
When I try with sudo it give me " commande not found "
PLease your help
The end of Step 1 in P4D2_2017_Fall/exercises/source_routing/README.md
refers to a build/logs/s1.log
, but this file does not exist, even after running the example program.
I am trying to run the solution of mri. hosts fail to ping each other. switch log says condition hd4.ipv4.isValid() is false. What could be the issue?
'tutorials/env.sh' file is incorrect:
P4C_BM_PATH=$THIS_DIR/../p4c-bmv2
This string points to non-existent directory.
Looks like p4c-bmv2 was merged with p4c-bm, however, examples were not updated
In the meter , while running the command " ./run_switch.sh " it shows up the error " Error when requesting config md5 sum from switch" the thirft server is running properly and displays the message READY. While I am running my python file using command " sudo python send_and_receive.py 1", I am not getting the desired output. Instead of sending two packet it is sending just one packets. Moreover when I change the veth pairs the output the output changes to two receive packets and one send packets. Can any one help in figuring out where the problem lies.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.