├── .gitignore ├── 00-unit-labs ├── 0000-topology-B │ ├── Makefile │ ├── README.md │ ├── bin │ │ ├── bundle.bin │ │ ├── freertr.sh │ │ ├── hdlcInt.bin │ │ ├── mapInt.bin │ │ ├── modem.bin │ │ ├── pcapInt.bin │ │ ├── rawInt.bin │ │ ├── rtr.jar │ │ ├── rtr.rld │ │ ├── setup_core1.sh │ │ ├── setup_cpe1.sh │ │ ├── setup_cpe2.sh │ │ ├── setup_cpe3.sh │ │ ├── setup_p4-core1.sh │ │ ├── stdLin.bin │ │ ├── tapInt.bin │ │ ├── teardown_core1.sh │ │ ├── teardown_cpe1.sh │ │ ├── teardown_cpe2.sh │ │ ├── teardown_cpe3.sh │ │ ├── teardown_p4-core1.sh │ │ ├── ttyLin.bin │ │ └── vlan.bin │ └── run │ │ ├── core1 │ │ ├── core1-hw.txt │ │ └── core1-sw.txt │ │ ├── cpe1 │ │ ├── cpe1-hw.txt │ │ └── cpe1-sw.txt │ │ ├── cpe2 │ │ ├── cpe2-hw.txt │ │ └── cpe2-sw.txt │ │ └── cpe3 │ │ ├── cpe3-hw.txt │ │ └── cpe3-sw.txt ├── 0000-topology-C │ ├── Makefile │ ├── README.md │ ├── bin │ │ ├── bundle.bin │ │ ├── freertr.sh │ │ ├── hdlcInt.bin │ │ ├── mapInt.bin │ │ ├── modem.bin │ │ ├── pcapInt.bin │ │ ├── rawInt.bin │ │ ├── rtr.jar │ │ ├── rtr.rld │ │ ├── setup_core1.sh │ │ ├── setup_cpe1.sh │ │ ├── setup_cpe2.sh │ │ ├── setup_p4-core1.sh │ │ ├── stdLin.bin │ │ ├── tapInt.bin │ │ ├── teardown_core1.sh │ │ ├── teardown_cpe1.sh │ │ ├── teardown_cpe2.sh │ │ ├── teardown_p4-core1.sh │ │ ├── ttyLin.bin │ │ └── vlan.bin │ └── run │ │ ├── core1 │ │ ├── core1-hw.txt │ │ ├── core1-sw.txt │ │ └── eth0.pcap │ │ ├── cpe1 │ │ ├── cpe1-hw.txt │ │ └── cpe1-sw.txt │ │ └── cpe2 │ │ ├── cpe2-hw.txt │ │ └── cpe2-sw.txt ├── 0000-topology-D │ ├── Makefile │ ├── README.md │ ├── bin │ │ ├── bundle.bin │ │ ├── freertr.sh │ │ ├── hdlcInt.bin │ │ ├── mapInt.bin │ │ ├── modem.bin │ │ ├── pcapInt.bin │ │ ├── rawInt.bin │ │ ├── rtr.jar │ │ ├── rtr.rld │ │ ├── setup_core1.sh │ │ ├── setup_cpe1.sh │ │ ├── setup_cpe2.sh │ │ ├── setup_cpe3.sh │ │ ├── setup_cpe4.sh │ │ ├── setup_p4-core1.sh │ │ ├── stdLin.bin │ │ ├── tapInt.bin │ │ ├── teardown_core1.sh │ │ ├── teardown_cpe1.sh │ │ ├── teardown_cpe2.sh │ │ ├── teardown_cpe3.sh │ │ ├── teardown_cpe4.sh │ │ ├── teardown_p4-core1.sh │ │ ├── ttyLin.bin │ │ └── vlan.bin │ └── run │ │ ├── core1 │ │ ├── core1-hw.txt │ │ └── core1-sw.txt │ │ ├── cpe1 │ │ ├── cpe1-hw.txt │ │ └── cpe1-sw.txt │ │ ├── cpe2 │ │ ├── cpe2-hw.txt │ │ └── cpe2-sw.txt │ │ ├── cpe3 │ │ ├── cpe3-hw.txt │ │ └── cpe3-sw.txt │ │ └── cpe4 │ │ ├── cpe4-hw.txt │ │ └── cpe4-sw.txt ├── 0000-topology-VLAN │ ├── Makefile │ ├── README.md │ └── bin │ │ ├── setup_addressing.sh │ │ ├── setup_host.sh │ │ └── teardown_host.sh ├── 0000-topology │ ├── Makefile │ ├── README.md │ ├── bin │ │ ├── bundle.bin │ │ ├── freertr.sh │ │ ├── hdlcInt.bin │ │ ├── mapInt.bin │ │ ├── modem.bin │ │ ├── pcapInt.bin │ │ ├── rawInt.bin.in │ │ ├── rtr.jar │ │ ├── rtr.rld │ │ ├── setup_core1.sh │ │ ├── setup_cpe1.sh │ │ ├── setup_cpe2.sh │ │ ├── setup_p4-core1.sh │ │ ├── stdLin.bin │ │ ├── tapInt.bin │ │ ├── teardown_core1.sh │ │ ├── teardown_cpe1.sh │ │ ├── teardown_cpe2.sh │ │ ├── teardown_p4-core1.sh │ │ ├── ttyLin.bin │ │ └── vlan.bin │ └── run │ │ ├── core1 │ │ ├── core1-hw.txt │ │ └── core1-sw.txt │ │ ├── cpe1 │ │ ├── cpe1-hw.txt │ │ └── cpe1-sw.txt │ │ └── cpe2 │ │ ├── cpe2-hw.txt │ │ └── cpe2-sw.txt ├── 0001-unoptimized-ipv4-forwarding │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ └── p4-table.p4 │ │ ├── p4-core1-cli.txt │ │ └── unoptimized-ipv4-forwarding.p4 ├── 0002-static-routing-ipv4-forwarding │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ └── p4-table.p4 │ │ ├── p4-core1-cli.txt │ │ └── unoptimized-ipv4-forwarding.p4 ├── 0003-optimized-ipv4-forwarding │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ └── p4-table.p4 │ │ ├── optimized-ipv4-forwarding.p4 │ │ └── p4-core1-cli.txt ├── 0004-isis-operation │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ ├── isis-operation.p4 │ │ └── p4-core1-cli.txt ├── 0005-defauld-ldp-operation │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── defauld-ldp-operation.p4 │ │ ├── include │ │ ├── const.p4 │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ └── p4-core1-cli.txt ├── 0006-ipv4-isis-sr-operation │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── const.p4 │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ ├── ipv4-isis-sr-operation.p4 │ │ └── p4-core1-cli.txt ├── 0007-vpn-over-bgp-isis-sr-operation-core1-lsr │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── const.p4 │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ ├── p4-core1-cli.txt │ │ └── vpn-over-bgp-isis-sr-operation-core1-lsr.p4 ├── 0008-unoptimized-ipv6-forwarding │ └── p4src │ │ ├── Makefile │ │ ├── Makefile.local │ │ ├── README.md │ │ ├── include │ │ ├── ethernet.p4 │ │ ├── ethertype.p4 │ │ ├── headers.p4 │ │ ├── ip-protocol.p4 │ │ ├── ipv4.p4 │ │ ├── ipv6.p4 │ │ ├── l3_ipv6.p4 │ │ ├── p4-table.p4 │ │ ├── types.p4 │ │ └── validate_ipv6.p4 │ │ ├── tables.in │ │ └── unoptimized-ipv6-forwarding.p4 ├── 0008-vlan │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ ├── switch-commands.txt │ │ └── vlan-operation.p4 ├── 0009-vpn-over-bgp-isis-sr-operation-core1-ler │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ ├── const.p4 │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ ├── p4-core1-cli.txt │ │ ├── vpn-over-bgp-isis-sr-operation-core1-ler.p4 │ │ └── vpn-over-bgp-isis-sr-operation-core1-ler.p4.save ├── 0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working │ ├── build │ │ ├── vpn-over-bgp-isis-sr-operation-core1-ler.json │ │ ├── vpn-over-bgp-isis-sr-operation-core1-ler.p4i │ │ └── vpn-over-bgp-isis-sr-operation-core1-ler.txt │ ├── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── include │ │ │ ├── const.p4 │ │ │ ├── ethertype.p4 │ │ │ ├── ip-protocol.p4 │ │ │ ├── p4-switch-port.p4 │ │ │ └── p4-table.p4 │ │ ├── p4-core1-cli.txt │ │ ├── vpn-over-bgp-isis-sr-operation-core1-ler.p4 │ │ └── vpn-over-bgp-isis-sr-operation-core1-ler.p4.backup │ └── run │ │ └── log │ │ ├── p4-core1.1.txt │ │ ├── p4-core1.2.txt │ │ ├── p4-core1.3.txt │ │ ├── p4-core1.out │ │ └── p4-core1.txt ├── 0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing │ └── p4src │ │ ├── Makefile │ │ ├── README.md │ │ ├── algoritm.txt │ │ ├── forwarder.py │ │ ├── include │ │ ├── const.p4 │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ ├── p4-core1-cli.txt │ │ ├── p4runtime_lib │ │ ├── __init__.py │ │ ├── bmv2.py │ │ ├── convert.py │ │ ├── helper.py │ │ └── switch.py │ │ └── vpn-over-bgp-isis-sr-operation-core1-ler.p4 ├── 0100-mpls │ ├── Makefile │ ├── README.md │ ├── build.sh │ ├── clean.sh │ ├── mpls.p4 │ ├── p4_controller.py │ └── topology.json ├── 0101-rare-validated-design-bgp │ ├── Makefile │ ├── c1 │ │ ├── c1-hw.txt │ │ └── c1-sw.txt │ ├── c2 │ │ ├── c2-hw.txt │ │ └── c2-sw.txt │ ├── c3 │ │ ├── c3-hw.txt │ │ └── c3-sw.txt │ ├── c4 │ │ ├── c4-hw.txt │ │ └── c4-sw.txt │ ├── c5 │ │ ├── c5-hw.txt │ │ └── c5-sw.txt │ ├── c6 │ │ ├── c6-hw.txt │ │ └── c6-sw.txt │ ├── c7 │ │ ├── c7-hw.txt │ │ └── c7-sw.txt │ ├── c8 │ │ ├── c8-hw.txt │ │ └── c8-sw.txt │ ├── lib │ │ ├── rtr.err │ │ ├── rtr.jar │ │ └── rtr.rld │ ├── rr1 │ │ ├── rr1-hw.txt │ │ └── rr1-sw.txt │ └── rr2 │ │ ├── rr2-hw.txt │ │ └── rr2-sw.txt ├── 0666-simple-packet-inout │ ├── build │ │ ├── simple-packet-inout.json │ │ ├── simple-packet-inout.p4i │ │ └── simple-packet-inout.txt │ └── p4src │ │ ├── Makefile │ │ ├── include │ │ ├── const.p4 │ │ ├── ethertype.p4 │ │ ├── ip-protocol.p4 │ │ ├── p4-switch-port.p4 │ │ └── p4-table.p4 │ │ └── simple-packet-inout.p4 └── codex │ ├── README.md │ ├── enum.p4 │ ├── l2.p4 │ ├── l3.p4 │ ├── l4.p4 │ └── l567.p4 ├── 01-P-labs └── README.md ├── 02-PE-labs ├── 0000-topology-A │ ├── Makefile │ └── bin │ │ ├── bundle.bin │ │ ├── freertr.sh │ │ ├── hdlcInt.bin │ │ ├── mapInt.bin │ │ ├── modem.bin │ │ ├── pcapInt.bin │ │ ├── rawInt.bin │ │ ├── rtr.jar │ │ ├── rtr.rld │ │ ├── setup_core1.sh │ │ ├── setup_p4-core1.sh │ │ ├── setup_r1.sh │ │ ├── setup_r2.sh │ │ ├── setup_r3.sh │ │ ├── setup_r4.sh │ │ ├── stdLin.bin │ │ ├── tapInt.bin │ │ ├── teardown_core1.sh │ │ ├── teardown_p4-core1.sh │ │ ├── teardown_r1.sh │ │ ├── teardown_r2.sh │ │ ├── teardown_r3.sh │ │ ├── teardown_r4.sh │ │ ├── ttyLin.bin │ │ └── vlan.bin ├── 0000-topology-B │ ├── Makefile │ ├── README.md │ ├── bin │ ├── run │ │ ├── c1 │ │ │ ├── c1-hw.txt │ │ │ └── c1-sw.txt │ │ ├── c2 │ │ │ ├── c2-hw.txt │ │ │ └── c2-sw.txt │ │ ├── c3 │ │ │ ├── c3-hw.txt │ │ │ └── c3-sw.txt │ │ ├── c4 │ │ │ ├── c4-hw.txt │ │ │ └── c4-sw.txt │ │ ├── c5 │ │ │ ├── c5-hw.txt │ │ │ └── c5-sw.txt │ │ ├── c6 │ │ │ ├── c6-hw.txt │ │ │ └── c6-sw.txt │ │ ├── c7 │ │ │ ├── c7-hw.txt │ │ │ └── c7-sw.txt │ │ ├── c8 │ │ │ ├── c8-hw.txt │ │ │ └── c8-sw.txt │ │ ├── r10 │ │ │ ├── r10-hw.txt │ │ │ └── r10-sw.txt │ │ ├── r11 │ │ │ ├── r11-hw.txt │ │ │ └── r11-sw.txt │ │ ├── r12 │ │ │ ├── r12-hw.txt │ │ │ └── r12-sw.txt │ │ └── r9 │ │ │ ├── r9-hw.txt │ │ │ └── r9-sw.txt │ ├── topology.dia │ └── topology.png ├── 0001-vpn-over-bgp-isis-sr-operation │ ├── Makefile │ ├── README.md │ ├── bin │ └── run │ │ ├── core1 │ │ ├── core1-hw.txt │ │ └── core1-sw.txt │ │ ├── r1 │ │ ├── r1-hw.txt │ │ └── r1-sw.txt │ │ ├── r2 │ │ ├── r2-hw.txt │ │ └── r2-sw.txt │ │ ├── r3 │ │ ├── r3-hw.txt │ │ └── r3-sw.txt │ │ └── r4 │ │ ├── r4-hw.txt │ │ └── r4-sw.txt ├── 0002-vpn-over-bgp-ospf-sr-operation │ ├── Makefile │ ├── README.md │ ├── bin │ └── run │ │ ├── core1 │ │ ├── core1-hw.txt │ │ └── core1-sw.txt │ │ ├── r1 │ │ ├── r1-hw.txt │ │ └── r1-sw.txt │ │ ├── r2 │ │ ├── r2-hw.txt │ │ └── r2-sw.txt │ │ ├── r3 │ │ ├── r3-hw.txt │ │ └── r3-sw.txt │ │ └── r4 │ │ ├── r4-hw.txt │ │ └── r4-sw.txt ├── README.md ├── p4src │ ├── forwarder.py │ ├── include │ │ ├── cst_cpu_port.p4 │ │ ├── cst_ethertype.p4 │ │ ├── cst_ip_protocol.p4 │ │ ├── cst_table_size.p4 │ │ ├── def_types.p4 │ │ ├── eg_ctl.p4 │ │ ├── eg_ctl_acl_out.p4 │ │ ├── eg_ctl_compute_checksum.p4 │ │ ├── eg_ctl_dprs.p4 │ │ ├── eg_ctl_hairpin.p4 │ │ ├── eg_ctl_mcast.p4 │ │ ├── eg_ctl_nexthop.p4 │ │ ├── eg_ctl_outport.p4 │ │ ├── eg_ctl_qos_out.p4 │ │ ├── eg_ctl_sgt.p4 │ │ ├── eg_ctl_vlan_out.p4 │ │ ├── hdr_amt.p4 │ │ ├── hdr_arp.p4 │ │ ├── hdr_bier.p4 │ │ ├── hdr_cpu.p4 │ │ ├── hdr_etherip.p4 │ │ ├── hdr_ethernet.p4 │ │ ├── hdr_gre.p4 │ │ ├── hdr_gtp.p4 │ │ ├── hdr_ig_headers.p4 │ │ ├── hdr_ipv4.p4 │ │ ├── hdr_ipv6.p4 │ │ ├── hdr_l2tp.p4 │ │ ├── hdr_l3tp.p4 │ │ ├── hdr_llc.p4 │ │ ├── hdr_mpls.p4 │ │ ├── hdr_nsh.p4 │ │ ├── hdr_polka.p4 │ │ ├── hdr_pppbr.p4 │ │ ├── hdr_pppoe.p4 │ │ ├── hdr_recir_headers.p4 │ │ ├── hdr_sgt.p4 │ │ ├── hdr_tcp.p4 │ │ ├── hdr_tmux.p4 │ │ ├── hdr_udp.p4 │ │ ├── hdr_vlan.p4 │ │ ├── hdr_vxlan.p4 │ │ ├── ig_ctl.p4 │ │ ├── ig_ctl_acl_in.p4 │ │ ├── ig_ctl_acl_out.p4 │ │ ├── ig_ctl_arp.p4 │ │ ├── ig_ctl_bridge.p4 │ │ ├── ig_ctl_bundle.p4 │ │ ├── ig_ctl_copp.p4 │ │ ├── ig_ctl_flowspec.p4 │ │ ├── ig_ctl_frag.p4 │ │ ├── ig_ctl_ipv4.p4 │ │ ├── ig_ctl_ipv4b.p4 │ │ ├── ig_ctl_ipv4c.p4 │ │ ├── ig_ctl_ipv6.p4 │ │ ├── ig_ctl_ipv6b.p4 │ │ ├── ig_ctl_ipv6c.p4 │ │ ├── ig_ctl_llc.p4 │ │ ├── ig_ctl_mcast.p4 │ │ ├── ig_ctl_mpls.p4 │ │ ├── ig_ctl_nat.p4 │ │ ├── ig_ctl_nsh.p4 │ │ ├── ig_ctl_outport.p4 │ │ ├── ig_ctl_pbr.p4 │ │ ├── ig_ctl_polka.p4 │ │ ├── ig_ctl_pppoe.p4 │ │ ├── ig_ctl_qos_in.p4 │ │ ├── ig_ctl_qos_out.p4 │ │ ├── ig_ctl_rewrites.p4 │ │ ├── ig_ctl_sgt.p4 │ │ ├── ig_ctl_tunnel.p4 │ │ ├── ig_ctl_verify_checksum.p4 │ │ ├── ig_ctl_vlan_in.p4 │ │ ├── ig_ctl_vrf.p4 │ │ ├── ig_prs_main.p4 │ │ └── mtd_ig_metadata.p4 │ ├── p4runtime_lib │ │ ├── __init__.py │ │ ├── bmv2.py │ │ ├── convert.py │ │ ├── error_utils.py │ │ ├── helper.py │ │ ├── simple_controller.py │ │ └── switch.py │ └── router.p4 ├── update-jar.sh └── update-src.sh ├── README.md ├── nixos ├── Makefile ├── RARE-env.nix ├── README.md ├── overlays-compat │ └── overlays.nix └── overlays │ ├── PI │ └── default.nix │ ├── bmv2 │ └── default.nix │ ├── overlays.nix │ ├── p4c │ └── default.nix │ └── p4runtime │ └── default.nix ├── resources ├── 0000-topology-mono-cpu-port.png ├── 0000-topology-vlan.png ├── 0000-topology.png ├── 0100-mpls.png ├── coming-soon.png ├── rare-partners.md └── rare-partners.png └── utils ├── Makefile ├── monitor.py ├── netstat.py ├── p4_mininet.py ├── p4runtime_lib ├── __init__.py ├── bmv2.py ├── convert.py ├── helper.py ├── simple_controller.py └── switch.py ├── pktgen ├── receiver.py └── sender.py ├── run_exercise.py └── tutor_controller.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[oc] 2 | ._* 3 | .DS_Store 4 | *.log 5 | *~ 6 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/Makefile: -------------------------------------------------------------------------------- 1 | BASE_DIR=$(PWD) 2 | BIN_DIR=$(BASE_DIR)/bin 3 | 4 | all: 5 | sudo $(BIN_DIR)/setup_cpe1.sh 6 | sudo $(BIN_DIR)/setup_cpe2.sh 7 | sudo $(BIN_DIR)/setup_core1.sh 8 | sudo $(BIN_DIR)/setup_cpe3.sh 9 | 10 | clean: 11 | -sudo pkill -9 rawInt.bin 12 | -sudo pkill -9 java 13 | -sudo $(BIN_DIR)/teardown_cpe1.sh 14 | -sudo $(BIN_DIR)/teardown_cpe2.sh 15 | -sudo $(BIN_DIR)/teardown_core1.sh 16 | -sudo $(BIN_DIR)/teardown_cpe3.sh 17 | #-sudo $(BIN_DIR)/teardown_p4-core1.sh 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/bundle.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/bundle.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/hdlcInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/hdlcInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/mapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/mapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/modem.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/modem.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/pcapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/pcapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/rawInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/rawInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/rtr.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/rtr.jar -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/rtr.rld: -------------------------------------------------------------------------------- 1 | code#8=exception 2 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/setup_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=core1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | FREERTR_ETH1="$FREERTR_HOSTNAME-eth1" 7 | 8 | ip netns add $FREERTR_HOSTNAME 9 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-cpu1 10 | ip link add $FREERTR_ETH1 type veth peer name p4-core1-cpu2 11 | 12 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 13 | ip link set $FREERTR_ETH1 netns $FREERTR_HOSTNAME 14 | 15 | ip link set dev p4-core1-cpu1 up 16 | ip link set dev p4-core1-cpu2 up 17 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 18 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH1 up 19 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 20 | 21 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22709/22710 $FREERTR_ETH1/22711/22712" -r "$FREERTR_HOSTNAME" 22 | 23 | 24 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/setup_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp1 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip link set dev p4-core1-dp1 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 13 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 14 | 15 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22705/22706" -r "$FREERTR_HOSTNAME" 16 | 17 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/setup_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe2 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | FREERTR_ETH1="$FREERTR_HOSTNAME-eth1" 7 | 8 | ip netns add $FREERTR_HOSTNAME 9 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp2 10 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 11 | 12 | ip link add $FREERTR_ETH1 type veth peer name cpe3-eth0 13 | ip link set $FREERTR_ETH1 netns $FREERTR_HOSTNAME 14 | 15 | ip link set dev p4-core1-dp2 up 16 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 17 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH1 up 18 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 19 | 20 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22707/22708 $FREERTR_ETH1/22713/22714" -r "$FREERTR_HOSTNAME" 21 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/setup_cpe3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe3 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name cpe2-eth1 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 13 | 14 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22715/22716" -r "$FREERTR_HOSTNAME" 15 | 16 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/setup_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Example of simple_switch with ipv4.json 4 | # sudo simple_switch --log-console -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 --thrift-port 9090 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 ipv4.json 5 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/stdLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/stdLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/tapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/tapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/teardown_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec core1 ip link set core1-eth0 down 4 | ip netns exec core1 ip link set core1-eth1 down 5 | ip netns exec core1 ip link set core1-eth0 netns 1 6 | ip netns exec core1 ip link set core1-eth1 netns 1 7 | ip link delete dev core1-eth0 8 | ip link delete dev core1-eth1 9 | 10 | ip netns delete core1 11 | 12 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/teardown_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe1 ip link set cpe1-eth0 down 4 | ip netns exec cpe1 ip link set cpe1-eth0 netns 1 5 | ip link del dev cpe1-eth0 6 | 7 | ip netns delete cpe1 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/teardown_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe2 ip link set cpe2-eth0 down 4 | ip netns exec cpe2 ip link set cpe2-eth0 netns 1 5 | ip link delete dev cpe2-eth0 6 | 7 | ip netns exec cpe2 ip link set cpe2-eth1 down 8 | ip netns exec cpe2 ip link set cpe2-eth1 netns 1 9 | ip link delete dev cpe2-eth1 10 | 11 | ip netns delete cpe2 12 | 13 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/teardown_cpe3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe3 ip link set cpe3-eth0 down 4 | ip netns exec cpe3 ip link set cpe3-eth0 netns 1 5 | ip link delete dev cpe3-eth0 6 | 7 | ip netns delete cpe3 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/teardown_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip link delete dev p4-core1-dp1 4 | ip link delete dev p4-core1-dp2 5 | ip link delete dev p4-core1-cpu1 6 | ip link delete dev p4-core1-cpu2 7 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/ttyLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/ttyLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/bin/vlan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-B/bin/vlan.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/run/core1/core1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth 0000.0A00.01FE 127.0.0.1 22710 127.0.0.1 22709 4 | int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | !tcp2vrf 8080 v1 80 8 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/run/cpe1/cpe1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0101 127.0.0.1 22706 127.0.0.1 22705 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/run/cpe1/cpe1-sw.txt: -------------------------------------------------------------------------------- 1 | hostname cpe1 2 | buggy 3 | ! 4 | logging buffered debug 10240 5 | logging file debug cpe1.log 6 | ! 7 | vrf definition c1 8 | rd 1:2 9 | rt-import 1:2 10 | rt-export 1:2 11 | exit 12 | ! 13 | vrf definition v1 14 | exit 15 | ! 16 | interface loopback0 17 | no description 18 | vrf forwarding c1 19 | ipv4 address 10.1.1.1 255.255.255.255 20 | no shutdown 21 | no log-link-change 22 | exit 23 | ! 24 | interface loopback2 25 | no description 26 | vrf forwarding c1 27 | ipv4 address 10.10.10.1 255.255.255.0 28 | no shutdown 29 | no log-link-change 30 | exit 31 | ! 32 | interface ethernet0 33 | no description 34 | macaddr 0000.0a00.0101 35 | vrf forwarding c1 36 | ipv4 address 10.0.1.1 255.255.255.0 37 | ipv4 host-static 10.0.1.254 0000.0a00.01fe 38 | no shutdown 39 | no log-link-change 40 | exit 41 | ! 42 | ! 43 | ipv4 route c1 0.0.0.0 0.0.0.0 10.0.1.254 44 | ! 45 | ! 46 | ! 47 | ! 48 | ! 49 | ! 50 | ! 51 | ! 52 | ! 53 | ! 54 | ! 55 | ! 56 | ! 57 | ! 58 | ! 59 | ! 60 | ! 61 | ! 62 | ! 63 | ! 64 | ! 65 | ! 66 | ! 67 | ! 68 | ! 69 | alias test bash description 70 | alias test bash parameter optional 71 | ! 72 | server telnet tel 73 | security protocol telnet 74 | exec width 130 75 | exec height 25 76 | no login authentication 77 | vrf v1 78 | exit 79 | ! 80 | client name-server 8.8.8.8 81 | client config-save 82 | client time-zone CET 83 | ! 84 | end 85 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/run/cpe2/cpe2-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 61000 62000 3 | int eth0 eth 0000.0A00.0202 127.0.0.1 22708 127.0.0.1 22707 4 | int eth1 eth 0000.0A00.1702 127.0.0.1 22714 127.0.0.1 22713 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | !tcp2vrf 8080 v1 80 8 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/run/cpe2/cpe2-sw.txt: -------------------------------------------------------------------------------- 1 | hostname cpe2 2 | buggy 3 | ! 4 | logging buffered debug 10240 5 | logging file debug cpe2.log 6 | ! 7 | vrf definition v1 8 | rd 1:1 9 | rt-import 1:1 10 | rt-export 1:1 11 | label-mode per-prefix 12 | exit 13 | ! 14 | router isis4 1 15 | vrf v1 16 | net-id 49.0001.0000.0a02.0202.00 17 | traffeng-id :: 18 | is-type level1 19 | segrout 10 20 | level1 segrout 21 | exit 22 | ! 23 | interface loopback0 24 | no description 25 | macaddr 0000.0a02.0202 26 | vrf forwarding v1 27 | ipv4 address 10.2.2.2 255.255.255.255 28 | router isis4 1 enable 29 | router isis4 1 circuit level1 30 | router isis4 1 segrout index 2 31 | router isis4 1 segrout node 32 | no shutdown 33 | no log-link-change 34 | exit 35 | ! 36 | interface loopback1 37 | no description 38 | vrf forwarding v1 39 | ipv4 address 2.2.2.2 255.255.255.0 40 | router isis4 1 enable 41 | router isis4 1 passive 42 | router isis4 1 circuit level1 43 | no shutdown 44 | no log-link-change 45 | exit 46 | ! 47 | interface ethernet0 48 | no description 49 | macaddr 0000.0a00.0202 50 | vrf forwarding v1 51 | ipv4 address 10.0.2.2 255.255.255.0 52 | ipv4 host-static 10.0.2.254 0000.0a00.02fe 53 | mpls enable 54 | router isis4 1 enable 55 | router isis4 1 circuit level1 56 | no shutdown 57 | no log-link-change 58 | exit 59 | ! 60 | interface ethernet1 61 | no description 62 | macaddr 0000.0a00.1703 63 | vrf forwarding v1 64 | ipv4 address 10.0.23.2 255.255.255.0 65 | mpls enable 66 | router isis4 1 enable 67 | router isis4 1 circuit level1 68 | no shutdown 69 | no log-link-change 70 | exit 71 | ! 72 | ! 73 | ! 74 | ! 75 | ! 76 | ! 77 | ! 78 | ! 79 | ! 80 | ! 81 | ! 82 | ! 83 | ! 84 | ! 85 | alias test bash description 86 | alias test bash parameter optional 87 | ! 88 | server telnet tel 89 | security protocol telnet 90 | exec width 130 91 | exec height 25 92 | no login authentication 93 | vrf v1 94 | exit 95 | ! 96 | client name-server 8.8.8.8 97 | client config-save 98 | client time-zone CET 99 | ! 100 | end 101 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-B/run/cpe3/cpe3-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.1703 127.0.0.1 22716 127.0.0.1 22715 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/Makefile: -------------------------------------------------------------------------------- 1 | BASE_DIR=$(PWD) 2 | BIN_DIR=$(BASE_DIR)/bin 3 | 4 | all: 5 | sudo $(BIN_DIR)/setup_cpe1.sh 6 | sudo $(BIN_DIR)/setup_cpe2.sh 7 | sudo $(BIN_DIR)/setup_core1.sh 8 | 9 | clean: 10 | sudo pkill -9 rawInt.bin 11 | sudo pkill -9 java 12 | sudo $(BIN_DIR)/teardown_cpe1.sh 13 | sudo $(BIN_DIR)/teardown_cpe2.sh 14 | sudo $(BIN_DIR)/teardown_core1.sh 15 | #sudo $(BIN_DIR)/teardown_p4-core1.sh 16 | 17 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/bundle.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/bundle.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/hdlcInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/hdlcInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/mapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/mapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/modem.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/modem.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/pcapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/pcapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/rawInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/rawInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/rtr.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/rtr.jar -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/rtr.rld: -------------------------------------------------------------------------------- 1 | code#8=exception 2 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/setup_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=core1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | #FREERTR_ETH1="$FREERTR_HOSTNAME-eth1" 7 | 8 | ip netns add $FREERTR_HOSTNAME 9 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-cpu1 10 | #ip link add $FREERTR_ETH1 type veth peer name p4-core1-cpu2 11 | 12 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 13 | #ip link set $FREERTR_ETH1 netns $FREERTR_HOSTNAME 14 | 15 | ip link set dev p4-core1-cpu1 up 16 | #ip link set dev p4-core1-cpu2 up 17 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 18 | #ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH1 up 19 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 20 | 21 | #ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22709/22710 $FREERTR_ETH1/22711/22712" -r "$FREERTR_HOSTNAME" 22 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22709/22710" -r "$FREERTR_HOSTNAME" 23 | 24 | 25 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/setup_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp1 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip link set dev p4-core1-dp1 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 13 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 14 | 15 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22705/22706" -r "$FREERTR_HOSTNAME" 16 | 17 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/setup_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe2 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp2 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip link set dev p4-core1-dp2 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 13 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 14 | 15 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22707/22708" -r "$FREERTR_HOSTNAME" 16 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/setup_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Example of simple_switch with ipv4.json 4 | # sudo simple_switch --log-console -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 --thrift-port 9090 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 ipv4.json 5 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/stdLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/stdLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/tapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/tapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/teardown_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec core1 ip link set core1-eth0 down 4 | #ip netns exec core1 ip link set core1-eth1 down 5 | ip netns exec core1 ip link set core1-eth0 netns 1 6 | #ip netns exec core1 ip link set core1-eth1 netns 1 7 | ip link delete dev core1-eth0 8 | #ip link delete dev core1-eth1 9 | 10 | ip netns delete core1 11 | 12 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/teardown_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe1 ip link set cpe1-eth0 down 4 | ip netns exec cpe1 ip link set cpe1-eth0 netns 1 5 | ip link del dev cpe1-eth0 6 | 7 | ip netns delete cpe1 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/teardown_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe2 ip link set cpe2-eth0 down 4 | ip netns exec cpe2 ip link set cpe2-eth0 netns 1 5 | ip link delete dev cpe2-eth0 6 | 7 | ip netns delete cpe2 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/teardown_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip link delete dev p4-core1-dp1 4 | ip link delete dev p4-core1-dp2 5 | ip link delete dev p4-core1-cpu1 6 | #ip link delete dev p4-core1-cpu2 7 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/ttyLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/ttyLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/bin/vlan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/bin/vlan.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/run/core1/core1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth 0000.0A00.0040 127.0.0.1 22710 127.0.0.1 22709 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | tcp2vrf 9080 v1 9080 8 | !tcp2vrf 8080 v1 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/run/core1/eth0.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-C/run/core1/eth0.pcap -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/run/cpe1/cpe1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0101 127.0.0.1 22706 127.0.0.1 22705 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-C/run/cpe2/cpe2-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 61000 62000 3 | int eth0 eth 0000.0A00.0202 127.0.0.1 22708 127.0.0.1 22707 4 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/Makefile: -------------------------------------------------------------------------------- 1 | BASE_DIR=$(PWD) 2 | BIN_DIR=$(BASE_DIR)/bin 3 | 4 | all: 5 | sudo $(BIN_DIR)/setup_cpe1.sh 6 | sudo $(BIN_DIR)/setup_cpe2.sh 7 | sudo $(BIN_DIR)/setup_core1.sh 8 | sudo $(BIN_DIR)/setup_cpe3.sh 9 | sudo $(BIN_DIR)/setup_cpe4.sh 10 | 11 | clean: 12 | -sudo pkill -9 rawInt.bin 13 | -sudo pkill -9 java 14 | -sudo $(BIN_DIR)/teardown_cpe1.sh 15 | -sudo $(BIN_DIR)/teardown_cpe2.sh 16 | -sudo $(BIN_DIR)/teardown_core1.sh 17 | -sudo $(BIN_DIR)/teardown_cpe3.sh 18 | -sudo $(BIN_DIR)/teardown_cpe4.sh 19 | #-sudo $(BIN_DIR)/teardown_p4-core1.sh 20 | 21 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/bundle.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/bundle.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/hdlcInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/hdlcInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/mapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/mapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/modem.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/modem.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/pcapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/pcapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/rawInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/rawInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/rtr.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/rtr.jar -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/rtr.rld: -------------------------------------------------------------------------------- 1 | code#8=exception 2 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/setup_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=core1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | FREERTR_GRPC="$FREERTR_HOSTNAME-grpc" 7 | 8 | ip netns add $FREERTR_HOSTNAME 9 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-cpu1 10 | ip link add $FREERTR_GRPC type veth peer name p4-core1-grpc 11 | 12 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 13 | ip link set $FREERTR_GRPC netns $FREERTR_HOSTNAME 14 | 15 | ip link set dev p4-core1-cpu1 up 16 | ip link set dev p4-core1-grpc up 17 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 18 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_GRPC up 19 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 20 | 21 | ip netns exec $FREERTR_HOSTNAME ip addr add 10.10.10.227/24 dev $FREERTR_GRPC 22 | ip addr add 10.10.10.1/24 dev p4-core1-grpc 23 | 24 | 25 | #ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22709/22710 $FREERTR_ETH1/22711/22712" -r "$FREERTR_HOSTNAME" 26 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22709/22710" -r "$FREERTR_HOSTNAME" 27 | 28 | 29 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/setup_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp1 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip link set dev p4-core1-dp1 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 13 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 14 | 15 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22705/22706" -r "$FREERTR_HOSTNAME" 16 | 17 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/setup_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe2 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | FREERTR_ETH1="$FREERTR_HOSTNAME-eth1" 7 | 8 | ip netns add $FREERTR_HOSTNAME 9 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp2 10 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 11 | 12 | ip link add $FREERTR_ETH1 type veth peer name cpe3-eth0 13 | ip link set $FREERTR_ETH1 netns $FREERTR_HOSTNAME 14 | 15 | ip link set dev p4-core1-dp2 up 16 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 17 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH1 up 18 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 19 | 20 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22707/22708 $FREERTR_ETH1/22713/22714" -r "$FREERTR_HOSTNAME" 21 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/setup_cpe3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe3 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name cpe2-eth1 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 13 | 14 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22715/22716" -r "$FREERTR_HOSTNAME" 15 | 16 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/setup_cpe4.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe4 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp4 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip link set dev p4-core1-dp4 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 13 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 14 | 15 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22715/22716" -r "$FREERTR_HOSTNAME" 16 | 17 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/setup_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Example of simple_switch with ipv4.json 4 | # sudo simple_switch --log-console -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 --thrift-port 9090 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 ipv4.json 5 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/stdLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/stdLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/tapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/tapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/teardown_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec core1 ip link set core1-eth0 down 4 | ip netns exec core1 ip link set core1-grpc down 5 | ip netns exec core1 ip link set core1-eth0 netns 1 6 | ip netns exec core1 ip link set core1-grpc netns 1 7 | ip link delete dev core1-eth0 8 | ip link delete dev core1-grpc 9 | 10 | ip netns delete core1 11 | 12 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/teardown_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe1 ip link set cpe1-eth0 down 4 | ip netns exec cpe1 ip link set cpe1-eth0 netns 1 5 | ip link del dev cpe1-eth0 6 | 7 | ip netns delete cpe1 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/teardown_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe2 ip link set cpe2-eth0 down 4 | ip netns exec cpe2 ip link set cpe2-eth0 netns 1 5 | ip link delete dev cpe2-eth0 6 | 7 | ip netns exec cpe2 ip link set cpe2-eth1 down 8 | ip netns exec cpe2 ip link set cpe2-eth1 netns 1 9 | ip link delete dev cpe2-eth1 10 | 11 | ip netns delete cpe2 12 | 13 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/teardown_cpe3.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe3 ip link set cpe3-eth0 down 4 | ip netns exec cpe3 ip link set cpe3-eth0 netns 1 5 | ip link delete dev cpe3-eth0 6 | 7 | ip netns delete cpe3 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/teardown_cpe4.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe1 ip link set cpe4-eth0 down 4 | ip netns exec cpe1 ip link set cpe4-eth0 netns 1 5 | ip link del dev cpe4-eth0 6 | 7 | ip netns delete cpe4 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/teardown_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip link delete dev p4-core1-dp1 4 | ip link delete dev p4-core1-dp2 5 | ip link delete dev p4-core1-cpu1 6 | ip link delete dev p4-core1-grpc 7 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/ttyLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/ttyLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/bin/vlan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology-D/bin/vlan.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/core1/core1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth 0000.0A00.0040 127.0.0.1 22710 127.0.0.1 22709 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | tcp2vrf 9080 v1 9080 8 | !tcp2vrf 8080 v1 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/cpe1/cpe1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0101 127.0.0.1 22706 127.0.0.1 22705 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/cpe1/cpe1-sw.txt: -------------------------------------------------------------------------------- 1 | hostname cpe1 2 | buggy 3 | ! 4 | logging buffered debug 10240 5 | logging file debug cpe1.log 6 | ! 7 | vrf definition c1 8 | rd 1:2 9 | rt-import 1:2 10 | rt-export 1:2 11 | exit 12 | ! 13 | vrf definition v1 14 | exit 15 | ! 16 | interface loopback0 17 | no description 18 | vrf forwarding c1 19 | ipv4 address 10.1.1.1 255.255.255.255 20 | no shutdown 21 | no log-link-change 22 | exit 23 | ! 24 | interface loopback2 25 | no description 26 | vrf forwarding c1 27 | ipv4 address 10.10.10.1 255.255.255.0 28 | no shutdown 29 | no log-link-change 30 | exit 31 | ! 32 | interface ethernet0 33 | no description 34 | macaddr 0000.0a00.0101 35 | vrf forwarding c1 36 | ipv4 address 10.0.1.1 255.255.255.0 37 | ipv4 host-static 10.0.1.254 0000.0a00.01fe 38 | no shutdown 39 | no log-link-change 40 | exit 41 | ! 42 | ! 43 | ipv4 route c1 0.0.0.0 0.0.0.0 10.0.1.254 44 | ! 45 | ! 46 | ! 47 | ! 48 | ! 49 | ! 50 | ! 51 | ! 52 | ! 53 | ! 54 | ! 55 | ! 56 | ! 57 | ! 58 | ! 59 | ! 60 | ! 61 | ! 62 | ! 63 | ! 64 | ! 65 | ! 66 | ! 67 | ! 68 | ! 69 | alias test bash description 70 | alias test bash parameter optional 71 | ! 72 | server telnet tel 73 | security protocol telnet 74 | exec width 130 75 | exec height 25 76 | no exec authorization 77 | no login authentication 78 | vrf v1 79 | exit 80 | ! 81 | client name-server 8.8.8.8 82 | client config-save 83 | client time-zone CET 84 | ! 85 | end 86 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/cpe2/cpe2-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 61000 62000 3 | int eth0 eth 0000.0A00.0202 127.0.0.1 22708 127.0.0.1 22707 4 | int eth1 eth 0000.0A00.1702 127.0.0.1 22714 127.0.0.1 22713 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | !tcp2vrf 8080 v1 80 8 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/cpe2/cpe2-sw.txt: -------------------------------------------------------------------------------- 1 | hostname cpe2 2 | buggy 3 | ! 4 | logging buffered debug 10240 5 | logging file debug cpe2.log 6 | ! 7 | vrf definition v1 8 | rd 1:1 9 | rt-import 1:1 10 | rt-export 1:1 11 | label-mode per-prefix 12 | exit 13 | ! 14 | router isis4 1 15 | vrf v1 16 | net-id 49.0001.0000.0a02.0202.00 17 | traffeng-id :: 18 | is-type level1 19 | segrout 10 20 | level1 segrout 21 | exit 22 | ! 23 | interface loopback0 24 | no description 25 | macaddr 0000.0a02.0202 26 | vrf forwarding v1 27 | ipv4 address 10.2.2.2 255.255.255.255 28 | router isis4 1 enable 29 | router isis4 1 circuit level1 30 | router isis4 1 segrout index 2 31 | router isis4 1 segrout node 32 | no shutdown 33 | no log-link-change 34 | exit 35 | ! 36 | interface loopback1 37 | no description 38 | vrf forwarding v1 39 | ipv4 address 2.2.2.2 255.255.255.0 40 | router isis4 1 enable 41 | router isis4 1 passive 42 | router isis4 1 circuit level1 43 | no shutdown 44 | no log-link-change 45 | exit 46 | ! 47 | interface ethernet0 48 | no description 49 | macaddr 0000.0a00.0202 50 | vrf forwarding v1 51 | ipv4 address 10.0.2.2 255.255.255.0 52 | ipv4 host-static 10.0.2.254 0000.0a00.02fe 53 | mpls enable 54 | router isis4 1 enable 55 | router isis4 1 circuit level1 56 | no shutdown 57 | no log-link-change 58 | exit 59 | ! 60 | interface ethernet1 61 | no description 62 | macaddr 0000.0a00.1703 63 | vrf forwarding v1 64 | ipv4 address 10.0.23.2 255.255.255.0 65 | mpls enable 66 | router isis4 1 enable 67 | router isis4 1 circuit level1 68 | no shutdown 69 | no log-link-change 70 | exit 71 | ! 72 | ! 73 | ! 74 | ! 75 | ! 76 | ! 77 | ! 78 | ! 79 | ! 80 | ! 81 | ! 82 | ! 83 | ! 84 | ! 85 | alias test bash description 86 | alias test bash parameter optional 87 | ! 88 | server telnet tel 89 | security protocol telnet 90 | exec width 130 91 | exec height 25 92 | no exec authorization 93 | no login authentication 94 | vrf v1 95 | exit 96 | ! 97 | client name-server 8.8.8.8 98 | client config-save 99 | client time-zone CET 100 | ! 101 | end 102 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/cpe3/cpe3-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.1703 127.0.0.1 22716 127.0.0.1 22715 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/cpe4/cpe4-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0404 127.0.0.1 22716 127.0.0.1 22715 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-D/run/cpe4/cpe4-sw.txt: -------------------------------------------------------------------------------- 1 | hostname cpe4 2 | buggy 3 | ! 4 | logging buffered debug 10240 5 | logging file debug cpe4.log 6 | ! 7 | vrf definition c1 8 | rd 1:2 9 | rt-import 1:2 10 | rt-export 1:2 11 | exit 12 | ! 13 | vrf definition v1 14 | exit 15 | ! 16 | interface loopback0 17 | no description 18 | vrf forwarding c1 19 | ipv4 address 10.4.4.4 255.255.255.255 20 | no shutdown 21 | no log-link-change 22 | exit 23 | ! 24 | interface loopback2 25 | no description 26 | vrf forwarding c1 27 | ipv4 address 10.10.10.4 255.255.255.0 28 | no shutdown 29 | no log-link-change 30 | exit 31 | ! 32 | interface ethernet0 33 | no description 34 | macaddr 0000.0a00.0404 35 | vrf forwarding v1 36 | ipv4 address 10.0.4.4 255.255.255.0 37 | no shutdown 38 | no log-link-change 39 | exit 40 | ! 41 | ! 42 | ! 43 | ! 44 | ! 45 | ! 46 | ! 47 | ! 48 | ! 49 | ! 50 | ! 51 | ! 52 | ! 53 | ! 54 | ! 55 | ! 56 | ! 57 | ! 58 | ! 59 | ! 60 | ! 61 | ! 62 | ! 63 | ! 64 | ! 65 | ! 66 | ! 67 | alias test bash description 68 | alias test bash parameter optional 69 | ! 70 | server telnet tel 71 | security protocol telnet 72 | exec width 130 73 | exec height 25 74 | no exec authorization 75 | no login authentication 76 | vrf v1 77 | exit 78 | ! 79 | client name-server 8.8.8.8 80 | client config-save 81 | client time-zone CET 82 | ! 83 | end 84 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-VLAN/Makefile: -------------------------------------------------------------------------------- 1 | BASE_DIR=$(PWD) 2 | BIN_DIR=$(BASE_DIR)/bin 3 | all: 4 | sudo $(BIN_DIR)/setup_host.sh "host1" "p4-core1-dp1" 5 | sudo $(BIN_DIR)/setup_host.sh "host2" "p4-core1-dp2" 6 | sudo $(BIN_DIR)/setup_host.sh "host3" "p4-core1-dp3" 7 | sudo $(BIN_DIR)/setup_host.sh "host4" "p4-core1-dp4" 8 | 9 | sudo $(BIN_DIR)/setup_addressing.sh "host1" "192.168.69.1/24" 10 | sudo $(BIN_DIR)/setup_addressing.sh "host2" "192.168.69.2/24" "102" 11 | sudo $(BIN_DIR)/setup_addressing.sh "host3" "192.168.69.3/24" "103" 12 | sudo $(BIN_DIR)/setup_addressing.sh "host4" "192.168.69.4/24" "104" 13 | clean: 14 | sudo $(BIN_DIR)/teardown_host.sh "host1" 15 | sudo $(BIN_DIR)/teardown_host.sh "host2" 16 | sudo $(BIN_DIR)/teardown_host.sh "host3" 17 | sudo $(BIN_DIR)/teardown_host.sh "host4" 18 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-VLAN/README.md: -------------------------------------------------------------------------------- 1 | # Lab topology 2 | 3 | ![Lab diagram](../../resources/0000-topology-vlan.png) 4 | 5 | 6 | # Unit test topology 7 | The topology depicted in the diagram above is intended for showcasing the multicasting capabilities while performing different operations on each output port of a group. 8 | 9 | ## Components: 10 | - `P4`: Is the P4 switch running BMV2. 11 | - `HostX`: Is a host which can be configured with or without vlan tagging 12 | 13 | ## Sample configuration 14 | Sample configuration configures each host in the same IPv4 network and sets different vlan for each of them: 15 | - `Host1`: IP: 192.168.69.1/24 NO-tag 16 | - `Host2`: IP: 192.168.69.2/24 VLAN: 102 17 | - `Host3`: IP: 192.168.69.3/24 VLAN: 103 18 | - `Host4`: IP: 192.168.69.4/24 VLAN: 104 19 | 20 | # Run topology 21 | ``` 22 | git clone https://github.com/frederic-loui/RARE.git 23 | cd RARE/00-unit-labs/0000-topology-vlan 24 | make 25 | ``` 26 | 27 | # Clean topology 28 | ``` 29 | make clean 30 | ``` 31 | 32 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-VLAN/bin/setup_addressing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOSTNAME=$1 4 | ETH0="$HOSTNAME-eth0" 5 | IPADDRESS=$2 6 | if [ $# -gt 2 ] 7 | then 8 | VLAN=$3 9 | ETH0VLAN="$HOSTNAME-eth0.$VLAN" 10 | ip netns exec $HOSTNAME ip link add link $ETH0 name $ETH0VLAN type vlan id $VLAN 11 | ip netns exec $HOSTNAME ip addr add $IPADDRESS dev $ETH0VLAN 12 | ip netns exec $HOSTNAME ip link set dev $ETH0VLAN up 13 | else 14 | ip netns exec $HOSTNAME ip addr add $IPADDRESS dev $ETH0 15 | ip netns exec $HOSTNAME ip link set dev $ETH0 up 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-VLAN/bin/setup_host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOSTNAME=$1 4 | ETH0="$HOSTNAME-eth0" 5 | CORELINK=$2 6 | 7 | ip netns add $HOSTNAME 8 | ip link add $ETH0 type veth peer name $CORELINK 9 | ip link set $ETH0 netns $HOSTNAME 10 | 11 | ip link set dev $CORELINK up 12 | ip netns exec $HOSTNAME ip link set dev $ETH0 up 13 | ip netns exec $HOSTNAME ip link set dev lo up 14 | 15 | 16 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology-VLAN/bin/teardown_host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | HOSTNAME=$1 4 | ETH0="$HOSTNAME-eth0" 5 | 6 | ip netns exec $HOSTNAME ip link set $ETH0 down 7 | ip netns exec $HOSTNAME ip link set $ETH0 netns 1 8 | ip link del dev $ETH0 9 | 10 | ip netns delete $HOSTNAME 11 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/Makefile: -------------------------------------------------------------------------------- 1 | BASE_DIR=$(PWD) 2 | BIN_DIR=$(BASE_DIR)/bin 3 | 4 | .DEFAULT_GOAL = all 5 | 6 | $(BIN_DIR)/rawInt.bin: $(BIN_DIR)/rawInt.bin.in 7 | set -e; \ 8 | . /etc/os-release; \ 9 | cp $? $@; \ 10 | if [ $$ID = "nixos" ]; then \ 11 | glibc=$$(nix-instantiate --eval -E 'with import {}; toString glibc' | sed -e "s/\"//g"); \ 12 | nix-shell -p patchelf -p glibc --run "patchelf --set-interpreter $$glibc/lib/ld-linux-* $@"; \ 13 | fi 14 | 15 | all: $(BIN_DIR)/rawInt.bin 16 | sudo $(BIN_DIR)/setup_cpe1.sh 17 | sudo $(BIN_DIR)/setup_cpe2.sh 18 | sudo $(BIN_DIR)/setup_core1.sh 19 | 20 | clean: 21 | sudo pkill -9 rawInt.bin 22 | sudo pkill -9 java 23 | sudo $(BIN_DIR)/teardown_cpe1.sh 24 | sudo $(BIN_DIR)/teardown_cpe2.sh 25 | sudo $(BIN_DIR)/teardown_core1.sh 26 | #sudo $(BIN_DIR)/teardown_p4-core1.sh 27 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/bundle.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/bundle.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/hdlcInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/hdlcInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/mapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/mapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/modem.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/modem.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/pcapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/pcapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/rawInt.bin.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/rawInt.bin.in -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/rtr.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/rtr.jar -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/rtr.rld: -------------------------------------------------------------------------------- 1 | code#8=exception 2 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/setup_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=core1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | FREERTR_ETH1="$FREERTR_HOSTNAME-eth1" 7 | 8 | ip netns add $FREERTR_HOSTNAME 9 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-cpu1 10 | ip link add $FREERTR_ETH1 type veth peer name p4-core1-cpu2 11 | 12 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 13 | ip link set $FREERTR_ETH1 netns $FREERTR_HOSTNAME 14 | 15 | ip link set dev p4-core1-cpu1 up 16 | ip link set dev p4-core1-cpu2 up 17 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 18 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH1 up 19 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 20 | 21 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22709/22710 $FREERTR_ETH1/22711/22712" -r "$FREERTR_HOSTNAME" 22 | 23 | 24 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/setup_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe1 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp1 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip link set dev p4-core1-dp1 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 13 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 14 | 15 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22705/22706" -r "$FREERTR_HOSTNAME" 16 | 17 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/setup_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=cpe2 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | 7 | ip netns add $FREERTR_HOSTNAME 8 | ip link add $FREERTR_ETH0 type veth peer name p4-core1-dp2 9 | ip link set $FREERTR_ETH0 netns $FREERTR_HOSTNAME 10 | 11 | ip link set dev p4-core1-dp2 up 12 | ip netns exec $FREERTR_HOSTNAME ip link set dev $FREERTR_ETH0 up 13 | ip netns exec $FREERTR_HOSTNAME ip link set dev lo up 14 | 15 | ip netns exec $FREERTR_HOSTNAME $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22707/22708" -r "$FREERTR_HOSTNAME" 16 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/setup_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Example of simple_switch with ipv4.json 4 | # sudo simple_switch --log-console -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 --thrift-port 9090 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 ipv4.json 5 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/stdLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/stdLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/tapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/tapInt.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/teardown_core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec core1 ip link set core1-eth0 down 4 | ip netns exec core1 ip link set core1-eth1 down 5 | ip netns exec core1 ip link set core1-eth0 netns 1 6 | ip netns exec core1 ip link set core1-eth1 netns 1 7 | ip link delete dev core1-eth0 8 | ip link delete dev core1-eth1 9 | 10 | ip netns delete core1 11 | 12 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/teardown_cpe1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe1 ip link set cpe1-eth0 down 4 | ip netns exec cpe1 ip link set cpe1-eth0 netns 1 5 | ip link del dev cpe1-eth0 6 | 7 | ip netns delete cpe1 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/teardown_cpe2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip netns exec cpe2 ip link set cpe2-eth0 down 4 | ip netns exec cpe2 ip link set cpe2-eth0 netns 1 5 | ip link delete dev cpe2-eth0 6 | 7 | ip netns delete cpe2 8 | 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/teardown_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip link delete dev p4-core1-dp1 4 | ip link delete dev p4-core1-dp2 5 | ip link delete dev p4-core1-cpu1 6 | ip link delete dev p4-core1-cpu2 7 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/ttyLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/ttyLin.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/bin/vlan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0000-topology/bin/vlan.bin -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/run/core1/core1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth 0000.0A00.01FE 127.0.0.1 22710 127.0.0.1 22709 4 | int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | !tcp2vrf 8080 v1 80 8 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 9 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/run/cpe1/cpe1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0101 127.0.0.1 22706 127.0.0.1 22705 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0000-topology/run/cpe2/cpe2-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 61000 62000 3 | int eth0 eth 0000.0A00.0202 127.0.0.1 22708 127.0.0.1 22707 4 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 5 | tcp2vrf 2323 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /00-unit-labs/0001-unoptimized-ipv4-forwarding/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = unoptimized-ipv4-forwarding.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0001-unoptimized-ipv4-forwarding/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0001-unoptimized-ipv4-forwarding/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0001-unoptimized-ipv4-forwarding/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | # tbl_ipv4_fib_host default behavior should be set by the P4 program 2 | # entry corresponding to 10.0.1.254 reachability 3 | table_add tbl_ipv4_fib_host act_ipv4_fib_hit 10.0.1.254 => 00:00:0a:00:01:fe 255 4 | # entry corresponding to 10.0.1.254 reachability 5 | table_add tbl_ipv4_fib_host act_ipv4_fib_hit 10.0.1.1 => 00:00:0a:00:01:01 1 6 | 7 | 8 | -------------------------------------------------------------------------------- /00-unit-labs/0002-static-routing-ipv4-forwarding/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = unoptimized-ipv4-forwarding.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0002-static-routing-ipv4-forwarding/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0002-static-routing-ipv4-forwarding/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0002-static-routing-ipv4-forwarding/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | # tbl_ipv4_fib_host 2 | # tbl_ipv4_fib_host default behavior should be set by the P4 program 3 | # entry corresponding to 10.0.1.254 reachability 4 | table_add tbl_ipv4_fib_host act_ipv4_fib_hit 10.0.1.254 => 00:00:0a:00:01:fe 255 5 | # entry corresponding to 10.0.1.254 reachability 6 | table_add tbl_ipv4_fib_host act_ipv4_fib_hit 10.0.1.1 => 00:00:0a:00:01:01 1 7 | # entry corresponding to 10.254.254.254/32 8 | table_add tbl_ipv4_fib_host act_ipv4_fib_hit 10.254.254.254 => 00:00:0a:00:01:fe 255 9 | 10 | # tbl_ipv4_fib_lpm 11 | table_add tbl_ipv4_fib_lpm act_ipv4_fib_hit 2.2.2.0/24 => 00:00:0a:00:02:02 2 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /00-unit-labs/0003-optimized-ipv4-forwarding/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = optimized-ipv4-forwarding.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0003-optimized-ipv4-forwarding/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0003-optimized-ipv4-forwarding/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0004-isis-operation/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = isis-operation.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0004-isis-operation/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0004-isis-operation/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0004-isis-operation/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0005-defauld-ldp-operation/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = defauld-ldp-operation.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0005-defauld-ldp-operation/p4src/include/const.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/const.p4 -------------------------------------------------------------------------------- /00-unit-labs/0005-defauld-ldp-operation/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0005-defauld-ldp-operation/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0005-defauld-ldp-operation/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0005-defauld-ldp-operation/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | table_add tbl_nexthop act_cpl_opr_fib_hit 1 3 => 1 2 | table_add tbl_nexthop act_cpl_opr_fib_hit 2 3 => 2 3 | table_add tbl_nexthop act_cpl_opr_fib_hit 255 3 => 255 4 | table_add tbl_nexthop act_cpl_opr_fib_hit 254 3 => 254 5 | 6 | table_add tbl_nexthop act_ipv4_fib_hit 1 0 => 00:00:0a:00:01:01 1 7 | table_add tbl_nexthop act_ipv4_fib_hit 255 0 => 00:00:0a:00:01:fe 255 8 | 9 | table_add tbl_nexthop act_ipv4_fib_hit 254 0 => 00:00:0a:00:02:fe 254 10 | table_add tbl_nexthop act_ipv4_fib_hit 2 0 => 00:00:0a:00:02:02 2 11 | 12 | 13 | table_add tbl_rmac_fib act_rmac_set_nexthop 09:00:2b:00:00:05 => 14 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:15 => 15 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:14 => 16 | 17 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.1.1.1 => 1 18 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.1 => 1 19 | 20 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.254.254.254 => 255 21 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.254 => 255 22 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.254 => 254 23 | 24 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.2.2.2 => 2 25 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.2 => 2 26 | 27 | 28 | 29 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 1.1.1.0/24 => 1 30 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 2.2.2.0/24 => 2 31 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 6.6.6.0/24 => 255 32 | 33 | 34 | table_add tbl_ipv4_fib_host act_ipv4_cpl_set_nexthop 224.0.0.2 => 35 | 36 | 37 | # After that you need to check LDP bindings at cpe1, cpe2 but most of all core1 38 | # show ipv4 ldp v1 database 39 | # And write the corresponding rules as per the README 40 | -------------------------------------------------------------------------------- /00-unit-labs/0006-ipv4-isis-sr-operation/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = ipv4-isis-sr-operation.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0006-ipv4-isis-sr-operation/p4src/include/const.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/const.p4 -------------------------------------------------------------------------------- /00-unit-labs/0006-ipv4-isis-sr-operation/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0006-ipv4-isis-sr-operation/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0006-ipv4-isis-sr-operation/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0006-ipv4-isis-sr-operation/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | table_add tbl_nexthop act_cpl_opr_fib_hit 1 3 => 1 2 | table_add tbl_nexthop act_cpl_opr_fib_hit 2 3 => 2 3 | table_add tbl_nexthop act_cpl_opr_fib_hit 255 3 => 255 4 | table_add tbl_nexthop act_cpl_opr_fib_hit 254 3 => 254 5 | 6 | table_add tbl_nexthop act_ipv4_fib_hit 1 0 => 00:00:0a:00:01:01 1 7 | table_add tbl_nexthop act_ipv4_fib_hit 255 0 => 00:00:0a:00:01:fe 255 8 | 9 | table_add tbl_nexthop act_ipv4_fib_hit 254 0 => 00:00:0a:00:02:fe 254 10 | table_add tbl_nexthop act_ipv4_fib_hit 2 0 => 00:00:0a:00:02:02 2 11 | 12 | 13 | table_add tbl_rmac_fib act_rmac_set_nexthop 09:00:2b:00:00:05 => 14 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:15 => 15 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:14 => 16 | 17 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.1.1.1 => 1 18 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.1 => 1 19 | 20 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.254.254.254 => 255 21 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.254 => 255 22 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.254 => 254 23 | 24 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.2.2.2 => 2 25 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.2 => 2 26 | 27 | 28 | 29 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 1.1.1.0/24 => 1 30 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 2.2.2.0/24 => 2 31 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 6.6.6.0/24 => 255 32 | 33 | 34 | # no more LDP 35 | #table_add tbl_ipv4_fib_host act_ipv4_cpl_set_nexthop 224.0.0.2 => 36 | 37 | 38 | # After that you need to check LDP bindings at cpe1, cpe2 but most of all core1 39 | # show ipv4 ldp v1 database 40 | # And write the corresponding rules as per the README 41 | 42 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 662376 => 662376 1 43 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972512 => 972512 255 44 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 930982 => 930982 2 45 | 46 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972513 => 930982 2 47 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972511 => 662376 1 48 | 49 | -------------------------------------------------------------------------------- /00-unit-labs/0007-vpn-over-bgp-isis-sr-operation-core1-lsr/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = vpn-over-bgp-isis-sr-operation-core1-lsr.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0007-vpn-over-bgp-isis-sr-operation-core1-lsr/p4src/include/const.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/const.p4 -------------------------------------------------------------------------------- /00-unit-labs/0007-vpn-over-bgp-isis-sr-operation-core1-lsr/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0007-vpn-over-bgp-isis-sr-operation-core1-lsr/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0007-vpn-over-bgp-isis-sr-operation-core1-lsr/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0007-vpn-over-bgp-isis-sr-operation-core1-lsr/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | table_add tbl_nexthop act_cpl_opr_fib_hit 1 3 => 1 2 | table_add tbl_nexthop act_cpl_opr_fib_hit 2 3 => 2 3 | table_add tbl_nexthop act_cpl_opr_fib_hit 255 3 => 255 4 | table_add tbl_nexthop act_cpl_opr_fib_hit 254 3 => 254 5 | 6 | table_add tbl_nexthop act_ipv4_fib_hit 1 0 => 00:00:0a:00:01:01 1 7 | table_add tbl_nexthop act_ipv4_fib_hit 255 0 => 00:00:0a:00:01:fe 255 8 | 9 | table_add tbl_nexthop act_ipv4_fib_hit 254 0 => 00:00:0a:00:02:fe 254 10 | table_add tbl_nexthop act_ipv4_fib_hit 2 0 => 00:00:0a:00:02:02 2 11 | 12 | 13 | table_add tbl_rmac_fib act_rmac_set_nexthop 09:00:2b:00:00:05 => 14 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:15 => 15 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:14 => 16 | 17 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.1.1.1 => 1 18 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.1 => 1 19 | 20 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.254.254.254 => 255 21 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.254 => 255 22 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.254 => 254 23 | 24 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.2.2.2 => 2 25 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.2 => 2 26 | 27 | 28 | 29 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 1.1.1.0/24 => 1 30 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 2.2.2.0/24 => 2 31 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 6.6.6.0/24 => 255 32 | 33 | 34 | # no more LDP 35 | #table_add tbl_ipv4_fib_host act_ipv4_cpl_set_nexthop 224.0.0.2 => 36 | 37 | 38 | # After that you need to check LDP bindings at cpe1, cpe2 but most of all core1 39 | # show ipv4 ldp v1 database 40 | # And write the corresponding rules as per the README 41 | 42 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 662376 => 662376 1 43 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972512 => 972512 255 44 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 930982 => 930982 2 45 | 46 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972513 => 930982 2 47 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972511 => 662376 1 48 | 49 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/Makefile: -------------------------------------------------------------------------------- 1 | include ./Makefile.local 2 | BUILD_DIR = ../build 3 | RUN_DIR = ../run 4 | LOG_DIR = $(RUN_DIR)/log 5 | LOG_FILE = p4-core1 6 | P4C = p4c 7 | BMV2_SWITCH_EXE = simple_switch 8 | BMV2_SWITCH_CLI = $(BMV2_SWITCH_EXE)_CLI 9 | 10 | source := $(wildcard *.p4) 11 | json_outfile := $(source:.p4=.json) 12 | p4info_outfile := $(source:.p4=.txt) 13 | 14 | compiled_json := $(BUILD_DIR)/$(json_outfile) 15 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 16 | 17 | # Set BMV2_SWITCH_EXE to override the BMv2 target 18 | #ifdef BMV2_SWITCH_EXE 19 | # run_args += -b $(BMV2_SWITCH_EXE) 20 | #endif 21 | 22 | all: run 23 | 24 | run: build 25 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 26 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 27 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 28 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 29 | 30 | build: dirs 31 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 32 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 33 | 34 | clean: 35 | -sudo pkill -9 simple_switch 36 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 37 | 38 | dirs: 39 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 40 | 41 | tables: tables.in 42 | $(BMV2_SWITCH_CLI) --thrift-port 9090 <$? 43 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/Makefile.local: -------------------------------------------------------------------------------- 1 | ## Set to the name of the test-specific p4 program, e.g. 2 | ## P4_PROGRAM = optimized-ipv4-forwarding.p4 3 | P4_PROGRAM = unoptimized-ipv6-forwarding.p4 4 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/include/ethernet.p4: -------------------------------------------------------------------------------- 1 | #ifndef _ETHERNET_P4_ 2 | #define _ETHERNET_P4_ 3 | 4 | #include 5 | 6 | /* 7 | * Ethernet header: as a header type, order matters 8 | */ 9 | header ethernet_t { 10 | mac_addr_t dst_mac_addr; 11 | mac_addr_t src_mac_addr; 12 | bit<16> ethertype; 13 | } 14 | 15 | #endif // _ETHERNET_P4_ 16 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/include/headers.p4: -------------------------------------------------------------------------------- 1 | #ifndef _HEADERS_P4_ 2 | #define _HEADERS_P4_ 3 | 4 | #include 5 | #include 6 | 7 | struct headers { 8 | ethernet_t ethernet; 9 | ipv6_t ipv6; 10 | } 11 | 12 | #endif // _HEADERS_P4_ 13 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/include/ipv4.p4: -------------------------------------------------------------------------------- 1 | #ifndef _IPV4_P4_ 2 | #define _IPV4_P4_ 3 | 4 | #include 5 | 6 | /* 7 | * IPv4 header: as a header type, order matters 8 | */ 9 | header ipv4_t { 10 | bit<4> version; 11 | bit<4> ihl; 12 | bit<8> diffserv; 13 | bit<16> total_len; 14 | bit<16> identification; 15 | bit<3> flags; 16 | bit<13> frag_offset; 17 | bit<8> ttl; 18 | bit<8> protocol; 19 | bit<16> hdr_checksum; 20 | ipv4_addr_t src_ipv4_addr; 21 | ipv4_addr_t dst_ipv4_addr; 22 | } 23 | 24 | #endif // _IPV4_P4_ 25 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/include/ipv6.p4: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _IPV6_P4_ 3 | #define _IPV6_P4_ 4 | 5 | #include 6 | 7 | /* 8 | * IPv6 header: as a header type 9 | */ 10 | header ipv6_t { 11 | bit<4> version; 12 | bit<8> traffic_class; 13 | bit<20> flow_label; 14 | bit<16> payload_len; 15 | bit<8> next_hdr; 16 | bit<8> hop_limit; 17 | ipv6_addr_t src_ipv6_addr; 18 | ipv6_addr_t dst_ipv6_addr; 19 | } 20 | 21 | #endif // _IPV6_P4_ 22 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/include/types.p4: -------------------------------------------------------------------------------- 1 | #ifndef _TYPES_P4_ 2 | #define _TYPES_P4_ 3 | 4 | /* 5 | * egress_spec port encoded using 9 bits 6 | */ 7 | typedef bit<9> egress_spec_t; 8 | 9 | /* 10 | * HW MAC address encoded using 48 bits 11 | */ 12 | typedef bit<48> mac_addr_t; 13 | 14 | /* 15 | * IPv4 address encoded using 32 bits 16 | */ 17 | typedef bit<32> ipv4_addr_t; 18 | 19 | /* 20 | * IPv6 address encoded using 128 bits 21 | */ 22 | typedef bit<128> ipv6_addr_t; 23 | 24 | #endif // _TYPES_P4_ 25 | -------------------------------------------------------------------------------- /00-unit-labs/0008-unoptimized-ipv6-forwarding/p4src/include/validate_ipv6.p4: -------------------------------------------------------------------------------- 1 | /* Validate an IPv6 packet, currently only the hop_limit. Maybe also 2 | check for multicast in the source address, for example */ 3 | 4 | #ifndef _VALIDATE_IPV6_P4_ 5 | #define _VALIDATE_IPV6_P4_ 6 | 7 | #include 8 | #include 9 | 10 | control ctl_validate_ipv6(inout headers hdr, 11 | inout standard_metadata_t standard_metadata) { 12 | action malformed() { 13 | mark_to_drop(standard_metadata); 14 | } 15 | 16 | table tbl_validate_ipv6 { 17 | key = { 18 | hdr.ipv6.hop_limit: exact; 19 | } 20 | actions = { 21 | malformed; 22 | NoAction; 23 | } 24 | const default_action = NoAction; 25 | const entries = { 26 | ( 0 ) : malformed(); 27 | } 28 | } 29 | 30 | apply { 31 | tbl_validate_ipv6.apply(); 32 | } 33 | } 34 | 35 | #endif // _VALIDATE_IPV6_P4_ 36 | -------------------------------------------------------------------------------- /00-unit-labs/0008-vlan/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = vlan-operation.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | # Set DEBUGGER to enable DEBUG on the switch 22 | #ifdef DEBUGGER 23 | DEBUGGER = --debugger 24 | #endif 25 | 26 | all: run 27 | 28 | run: build 29 | sudo $(BMV2_SWITCH_EXE) $(DEBUGGER) --log-file $(LOG_DIR)/$(LOG_FILE) \ 30 | --log-flush \ 31 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 32 | -i 3@p4-core1-dp3 -i 4@p4-core1-dp4 \ 33 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 34 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 35 | 36 | build: dirs 37 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 38 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 39 | 40 | clean: 41 | -sudo pkill -9 simple_switch 42 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 43 | 44 | dirs: 45 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 46 | 47 | -------------------------------------------------------------------------------- /00-unit-labs/0008-vlan/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0008-vlan/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0008-vlan/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0008-vlan/p4src/switch-commands.txt: -------------------------------------------------------------------------------- 1 | mc_node_create 100 1 2 3 4 2 | mc_mgrp_create 100 3 | mc_node_associate 100 0 4 | mirroring_add_mc 100 100 5 | table_add ctl_ingress.tbl_vlan_match ctl_ingress.act_vlan_hit 1 0 0 => 100 6 | table_add ctl_ingress.tbl_vlan_match ctl_ingress.act_vlan_hit 2 1 102 => 100 7 | table_add ctl_ingress.tbl_vlan_match ctl_ingress.act_vlan_hit 3 1 103 => 100 8 | table_add ctl_ingress.tbl_vlan_match ctl_ingress.act_vlan_hit 4 1 104 => 100 9 | 10 | table_add ctl_egress.tbl_vlan_out ctl_egress.egress_no_tag 100 1 => 11 | table_add ctl_egress.tbl_vlan_out ctl_egress.egress_push_tag 100 2 => 102 12 | table_add ctl_egress.tbl_vlan_out ctl_egress.egress_push_tag 100 3 => 103 13 | table_add ctl_egress.tbl_vlan_out ctl_egress.egress_push_tag 100 4 => 104 14 | -------------------------------------------------------------------------------- /00-unit-labs/0009-vpn-over-bgp-isis-sr-operation-core1-ler/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = vpn-over-bgp-isis-sr-operation-core1-ler.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0009-vpn-over-bgp-isis-sr-operation-core1-ler/p4src/include/const.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/const.p4 -------------------------------------------------------------------------------- /00-unit-labs/0009-vpn-over-bgp-isis-sr-operation-core1-ler/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0009-vpn-over-bgp-isis-sr-operation-core1-ler/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0009-vpn-over-bgp-isis-sr-operation-core1-ler/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0009-vpn-over-bgp-isis-sr-operation-core1-ler/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | table_add tbl_nexthop act_cpl_opr_fib_hit 1 3 => 1 2 | table_add tbl_nexthop act_cpl_opr_fib_hit 2 3 => 2 3 | table_add tbl_nexthop act_cpl_opr_fib_hit 255 3 => 255 4 | table_add tbl_nexthop act_cpl_opr_fib_hit 254 3 => 254 5 | 6 | table_add tbl_nexthop act_ipv4_fib_hit 1 0 => 00:00:0a:00:01:01 1 7 | table_add tbl_nexthop act_ipv4_fib_hit 255 0 => 00:00:0a:00:01:fe 255 8 | 9 | table_add tbl_nexthop act_ipv4_fib_hit 254 0 => 00:00:0a:00:02:fe 254 10 | table_add tbl_nexthop act_ipv4_fib_hit 2 0 => 00:00:0a:00:02:02 2 11 | 12 | 13 | table_add tbl_rmac_fib act_rmac_set_nexthop 09:00:2b:00:00:05 => 14 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:15 => 15 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:14 => 16 | 17 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.1.1.1 => 1 18 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.1 => 1 19 | 20 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.254.254.254 => 255 21 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.254 => 255 22 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.254 => 254 23 | 24 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.2.2.2 => 2 25 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.2 => 2 26 | 27 | 28 | 29 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 1.1.1.0/24 => 1 30 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 2.2.2.0/24 => 2 31 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 6.6.6.0/24 => 255 32 | 33 | 34 | # no more LDP 35 | #table_add tbl_ipv4_fib_host act_ipv4_cpl_set_nexthop 224.0.0.2 => 36 | 37 | 38 | # After that you need to check LDP bindings at cpe1, cpe2 but most of all core1 39 | # show ipv4 ldp v1 database 40 | # And write the corresponding rules as per the README 41 | 42 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 662376 => 662376 1 43 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972512 => 972512 255 44 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 930982 => 930982 2 45 | 46 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972513 => 930982 2 47 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972511 => 662376 1 48 | 49 | -------------------------------------------------------------------------------- /00-unit-labs/0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = vpn-over-bgp-isis-sr-operation-core1-ler.p4 7 | BMV2_SWITCH_EXE = simple_switch 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 28 | 29 | build: dirs 30 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 31 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 32 | 33 | clean: 34 | -sudo pkill -9 simple_switch 35 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 39 | 40 | -------------------------------------------------------------------------------- /00-unit-labs/0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working/p4src/include/const.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/const.p4 -------------------------------------------------------------------------------- /00-unit-labs/0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | table_add tbl_nexthop act_cpl_opr_fib_hit 1 3 => 1 2 | table_add tbl_nexthop act_cpl_opr_fib_hit 2 3 => 2 3 | table_add tbl_nexthop act_cpl_opr_fib_hit 255 3 => 255 4 | table_add tbl_nexthop act_cpl_opr_fib_hit 254 3 => 254 5 | 6 | table_add tbl_nexthop act_ipv4_fib_hit 1 0 => 00:00:0a:00:01:01 1 7 | table_add tbl_nexthop act_ipv4_fib_hit 255 0 => 00:00:0a:00:01:fe 255 8 | 9 | table_add tbl_nexthop act_ipv4_fib_hit 254 0 => 00:00:0a:00:02:fe 254 10 | table_add tbl_nexthop act_ipv4_fib_hit 2 0 => 00:00:0a:00:02:02 2 11 | 12 | 13 | table_add tbl_rmac_fib act_rmac_set_nexthop 09:00:2b:00:00:05 => 14 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:15 => 15 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:14 => 16 | 17 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.1.1.1 => 1 18 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.1 => 1 19 | 20 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.254.254.254 => 255 21 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.1.254 => 255 22 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.254 => 254 23 | 24 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.2.2.2 => 2 25 | table_add tbl_ipv4_fib_host act_ipv4_set_nexthop 10.0.2.2 => 2 26 | 27 | 28 | 29 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 1.1.1.0/24 => 1 30 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 2.2.2.0/24 => 2 31 | table_add tbl_ipv4_fib_lpm act_ipv4_set_nexthop 6.6.6.0/24 => 255 32 | 33 | 34 | # no more LDP 35 | #table_add tbl_ipv4_fib_host act_ipv4_cpl_set_nexthop 224.0.0.2 => 36 | 37 | 38 | # After that you need to check LDP bindings at cpe1, cpe2 but most of all core1 39 | # show ipv4 ldp v1 database 40 | # And write the corresponding rules as per the README 41 | 42 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 662376 => 662376 1 43 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972512 => 972512 255 44 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 930982 => 930982 2 45 | 46 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972513 => 930982 2 47 | #table_add tbl_mpls_fib act_mpls_swap_set_nexthop 972511 => 662376 1 48 | 49 | -------------------------------------------------------------------------------- /00-unit-labs/0050-vpn-over-bgp-isis-sr-operation-core1-ler-not-working/run/log/p4-core1.out: -------------------------------------------------------------------------------- 1 | Calling target program-options parser 2 | Adding interface p4-core1-dp1 as port 1 3 | Adding interface p4-core1-dp2 as port 2 4 | Adding interface p4-core1-cpu2 as port 254 5 | Adding interface p4-core1-cpu1 as port 255 6 | -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = vpn-over-bgp-isis-sr-operation-core1-ler.p4 7 | BMV2_SWITCH_EXE = simple_switch_grpc 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 -i 4@p4-core1-dp4 \ 26 | -i 64@p4-core1-cpu1 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) \ 28 | -- --grpc-server-addr 127.0.0.1:50051 > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 29 | ping -c 3 10.10.10.227 30 | # ./forwarder.py > $(LOG_DIR)/forwarder.log 2>&1 & 31 | 32 | build: dirs 33 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 34 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 35 | 36 | clean: 37 | -sudo pkill -9 $(BMV2_SWITCH_EXE) 38 | -sudo pkill -9 python2 39 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 40 | 41 | dirs: 42 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 43 | 44 | -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/algoritm.txt: -------------------------------------------------------------------------------- 1 | 2 | ping core1 (10.0.1.254) --> cpe3 (10.10.30.3) working 3 | ping cpe3 (10.10.30.3) --> core1 (10.0.1.254) not working 4 | 5 | so it decapsulates everything immediately in the table action. tbl_mpls_fib, 6 | 7 | instead: 8 | - it should set a metadata flag - 9 | - && check this flag value in the main loop 10 | - && decapsulate mpls headers only if CPU_PORT is NOT the target. 11 | 12 | tbl_mpls_svc_type (value of mpls[1] the packet) key: => param#1:[] {4,6,2} 13 | 14 | tbl_mpls_fib => swap, decap, 15 | 16 | ingress packet 17 | 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/include/const.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/const.p4 -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/p4-core1-cli.txt: -------------------------------------------------------------------------------- 1 | table_add tbl_nexthop act_cpl_opr_fib_hit 1 3 => 1 2 | table_add tbl_nexthop act_cpl_opr_fib_hit 2 3 => 2 3 | table_add tbl_nexthop act_cpl_opr_fib_hit 4 3 => 4 4 | table_add tbl_nexthop act_cpl_opr_fib_hit 64 3 => 64 5 | table_add tbl_nexthop act_cpl_opr_fib_hit 1 0 => 1 6 | table_add tbl_nexthop act_cpl_opr_fib_hit 2 0 => 2 7 | table_add tbl_nexthop act_cpl_opr_fib_hit 4 0 => 4 8 | table_add tbl_nexthop act_cpl_opr_fib_hit 64 0 => 64 9 | 10 | table_add tbl_rmac_fib act_rmac_set_nexthop 09:00:2b:00:00:05 => 11 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:15 => 12 | table_add tbl_rmac_fib act_rmac_set_nexthop 01:80:c2:00:00:14 => 13 | table_add tbl_rmac_fib act_rmac_set_nexthop ff:ff:ff:ff:ff:ff => 14 | -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/p4runtime_lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/p4runtime_lib/__init__.py -------------------------------------------------------------------------------- /00-unit-labs/0051-vpn-over-bgp-isis-sr-operation-core1-ler-packetin-packetout_testing/p4src/p4runtime_lib/bmv2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017-present Open Networking Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | from switch import SwitchConnection 16 | from p4.tmp import p4config_pb2 17 | 18 | 19 | def buildDeviceConfig(bmv2_json_file_path=None): 20 | "Builds the device config for BMv2" 21 | device_config = p4config_pb2.P4DeviceConfig() 22 | device_config.reassign = True 23 | with open(bmv2_json_file_path) as f: 24 | device_config.device_data = f.read() 25 | return device_config 26 | 27 | 28 | class Bmv2SwitchConnection(SwitchConnection): 29 | def buildDeviceConfig(self, **kwargs): 30 | return buildDeviceConfig(**kwargs) 31 | -------------------------------------------------------------------------------- /00-unit-labs/0100-mpls/Makefile: -------------------------------------------------------------------------------- 1 | 2 | BUILD_DIR = build 3 | PCAP_DIR = pcaps 4 | LOG_DIR = logs 5 | 6 | TOPO = topology.json 7 | 8 | P4C = p4c 9 | RUN_SCRIPT = p4_controller.py 10 | 11 | source := $(wildcard *.p4) 12 | json_outfile := $(source:.p4=.json) 13 | p4info_outfile := $(source:.p4=.txt) 14 | 15 | compiled_json := $(BUILD_DIR)/$(json_outfile) 16 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 17 | 18 | # Define NO_P4 to start BMv2 without a program 19 | ifndef NO_P4 20 | run_args += -j $(compiled_json) 21 | endif 22 | 23 | # Set BMV2_SWITCH_EXE to override the BMv2 target 24 | ifdef BMV2_SWITCH_EXE 25 | run_args += -b $(BMV2_SWITCH_EXE) 26 | endif 27 | 28 | all: run 29 | 30 | run: mpls.p4 31 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 32 | -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) mpls.p4 33 | 34 | controller: p4_controller.py 35 | sudo python $(RUN_SCRIPT) \ 36 | --p4info $(compiled_p4info) \ 37 | --bmv2-json $(compiled_json) 38 | 39 | stop: 40 | -sudo mn -c 41 | 42 | clean: stop 43 | -rm -f *.pcap 44 | -rm -rf $(BUILD_DIR) $(PCAP_DIR) $(LOG_DIR) 45 | 46 | -------------------------------------------------------------------------------- /00-unit-labs/0100-mpls/README.md: -------------------------------------------------------------------------------- 1 | # Lab diagram 2 | 3 | ![Lab diagram](https://github.com/frederic-loui/RARE/raw/master/resources/0100-mpls.png) 4 | 5 | # TL;DR 6 | 7 | ``` 8 | # Build topology & compile p4 program 9 | ./build.sh 10 | ``` 11 | 12 | ``` 13 | # check h1 cannot ping h4 nd vice-versa (no table rules yet ;-) ) 14 | 15 | # [h1-->h4] 16 | mininet> h1 ping h4 17 | PING 10.0.4.4 (10.0.4.4) 56(84) bytes of data. 18 | ^C 19 | --- 10.0.4.4 ping statistics --- 20 | 12 packets transmitted, 0 received, 100% packet loss, time 11087ms 21 | 22 | # [h4-->h1] 23 | mininet> h4 ping h1 24 | PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data. 25 | ^C 26 | --- 10.0.1.1 ping statistics --- 27 | 8 packets transmitted, 0 received, 100% packet loss, time 7056ms 28 | ``` 29 | 30 | ``` 31 | # Launch p4runtime controller and inject rules 32 | make controller 33 | ``` 34 | 35 | ``` 36 | # relaunch ping from [h1-->h4] and [h4 --> h1] 37 | mininet> h1 ping -c 5 h4 38 | PING 10.0.4.4 (10.0.4.4) 56(84) bytes of data. 39 | 64 bytes from 10.0.4.4: icmp_seq=1 ttl=64 time=15.4 ms 40 | 64 bytes from 10.0.4.4: icmp_seq=2 ttl=64 time=11.9 ms 41 | 64 bytes from 10.0.4.4: icmp_seq=3 ttl=64 time=12.0 ms 42 | 64 bytes from 10.0.4.4: icmp_seq=4 ttl=64 time=12.0 ms 43 | 64 bytes from 10.0.4.4: icmp_seq=5 ttl=64 time=12.1 ms 44 | 45 | --- 10.0.4.4 ping statistics --- 46 | 5 packets transmitted, 5 received, 0% packet loss, time 4004ms 47 | rtt min/avg/max/mdev = 11.956/12.730/15.484/1.378 ms 48 | mininet> h4 ping -c 5 h1 49 | PING 10.0.1.1 (10.0.1.1) 56(84) bytes of data. 50 | 64 bytes from 10.0.1.1: icmp_seq=1 ttl=64 time=11.1 ms 51 | 64 bytes from 10.0.1.1: icmp_seq=2 ttl=64 time=11.4 ms 52 | 64 bytes from 10.0.1.1: icmp_seq=3 ttl=64 time=11.3 ms 53 | 64 bytes from 10.0.1.1: icmp_seq=4 ttl=64 time=11.6 ms 54 | 64 bytes from 10.0.1.1: icmp_seq=5 ttl=64 time=10.6 ms 55 | 56 | --- 10.0.1.1 ping statistics --- 57 | 5 packets transmitted, 5 received, 0% packet loss, time 4005ms 58 | rtt min/avg/max/mdev = 10.674/11.263/11.699/0.353 ms 59 | mininet> 60 | ``` 61 | 62 | ``` 63 | # Last but not least ! Clean lab 64 | # otherwise it will conflict with other examples 65 | ./clean.sh 66 | 67 | ``` 68 | -------------------------------------------------------------------------------- /00-unit-labs/0100-mpls/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BUILD_DIR=build 4 | 5 | # Step 1: Create *.json and *.p4info 6 | make 7 | 8 | # Step 2: Launch run_exercice.py 9 | # using topology.json, p4 switch config (make output file) 10 | # and bmv2 target to launch 11 | # - topology.json 12 | # - *.json 13 | # - "simple_switch_grpc" 14 | sudo python ../../utils/run_exercise.py \ 15 | --topo topology.json \ 16 | --switch_json build/mpls.json \ 17 | --behavioral-exe simple_switch_grpc \ 18 | --host_mode 6 19 | -------------------------------------------------------------------------------- /00-unit-labs/0100-mpls/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # need to sudo as we are cleaning also veth created via build.sh 4 | sudo make clean 5 | -------------------------------------------------------------------------------- /00-unit-labs/0100-mpls/topology.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosts": [ 3 | "h1", 4 | "h2", 5 | "h3", 6 | "h4" 7 | ], 8 | "switches": { 9 | "s1": {}, 10 | "s2": {}, 11 | "s3": {}, 12 | "s4": {} 13 | }, 14 | "links": [ 15 | ["h1","s1"], 16 | ["h2","s2"], 17 | ["h3","s3"], 18 | ["h4","s4"], 19 | ["s1","s2"], 20 | ["s1","s2"], 21 | ["s2","s3"], 22 | ["s3","s4"], 23 | ["s3","s4"], 24 | ["s4","s1"] 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /00-unit-labs/0101-rare-validated-design-bgp/Makefile: -------------------------------------------------------------------------------- 1 | BASE_DIR=$(PWD) 2 | 3 | all: 4 | -java -jar $(BASE_DIR)/lib/rtr.jar routers $(BASE_DIR)/c1/c1-hw.txt $(BASE_DIR)/c1/c1-sw.txt :DatagramSocket.java:244/java.net.DatagramSocket.:DatagramSocket.java:301/java.net.DatagramSocket.:DatagramSocket.java:273/ifc.ifcUdpInt.:ifcUdpInt.java:86/cfg.cfgInit.executeHWcommands:cfgInit.java:400/cfg.cfgInit.doInit:cfgInit.java:689/cfg.cfgInit.doMain:cfgInit.java:893/router.main:router.java:17/ 2 | -------------------------------------------------------------------------------- /00-unit-labs/0101-rare-validated-design-bgp/rr1/rr1-hw.txt: -------------------------------------------------------------------------------- 1 | int eth1 eth 0000.aaaa.1111 127.0.0.1 10102 127.0.0.1 10101 2 | int eth2 eth 0000.aaaa.2222 127.0.0.1 10402 127.0.0.1 10401 3 | tcp2vrf 10010 v1 23 4 | -------------------------------------------------------------------------------- /00-unit-labs/0101-rare-validated-design-bgp/rr2/rr2-hw.txt: -------------------------------------------------------------------------------- 1 | int eth1 eth 0000.bbbb.1111 127.0.0.1 11202 127.0.0.1 11201 2 | int eth2 eth 0000.bbbb.2222 127.0.0.1 11302 127.0.0.1 11301 3 | tcp2vrf 10011 v1 23 4 | -------------------------------------------------------------------------------- /00-unit-labs/0666-simple-packet-inout/build/simple-packet-inout.txt: -------------------------------------------------------------------------------- 1 | pkg_info { 2 | arch: "v1model" 3 | } 4 | -------------------------------------------------------------------------------- /00-unit-labs/0666-simple-packet-inout/p4src/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = ../build 2 | RUN_DIR = ../run 3 | LOG_DIR = $(RUN_DIR)/log 4 | LOG_FILE = p4-core1 5 | P4C = p4c 6 | P4_PROGRAM = simple-packet-inout.p4 7 | BMV2_SWITCH_EXE = simple_switch_grpc 8 | 9 | source := $(wildcard *.p4) 10 | json_outfile := $(source:.p4=.json) 11 | p4info_outfile := $(source:.p4=.txt) 12 | 13 | compiled_json := $(BUILD_DIR)/$(json_outfile) 14 | compiled_p4info := $(BUILD_DIR)/$(p4info_outfile) 15 | 16 | # Set BMV2_SWITCH_EXE to override the BMv2 target 17 | #ifdef BMV2_SWITCH_EXE 18 | # run_args += -b $(BMV2_SWITCH_EXE) 19 | #endif 20 | 21 | all: run 22 | 23 | run: build 24 | sudo $(BMV2_SWITCH_EXE) --log-file $(LOG_DIR)/$(LOG_FILE) \ 25 | -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 \ 26 | -i 64@p4-core1-cpu1 \ 27 | --thrift-port 9090 --nanolog ipc://$(RUN_DIR)/bm-0-log.ipc --device-id 0 $(compiled_json) \ 28 | -- --grpc-server-addr 66.66.66.1:50051 > $(LOG_DIR)/$(LOG_FILE).out 2>&1 & 29 | 30 | build: dirs 31 | $(P4C) --std p4-16 --target bmv2 --arch v1model \ 32 | -I ./ -o $(BUILD_DIR) --p4runtime-files $(compiled_p4info) $(P4_PROGRAM) 33 | 34 | clean: 35 | -sudo pkill -9 $(BMV2_SWITCH_EXE) 36 | -rm -rf $(BUILD_DIR) $(LOG_DIR) $(RUN_DIR) 37 | 38 | dirs: 39 | mkdir -p $(BUILD_DIR) $(LOG_DIR) 40 | 41 | -------------------------------------------------------------------------------- /00-unit-labs/0666-simple-packet-inout/p4src/include/const.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/const.p4 -------------------------------------------------------------------------------- /00-unit-labs/0666-simple-packet-inout/p4src/include/ethertype.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ethertype.p4 -------------------------------------------------------------------------------- /00-unit-labs/0666-simple-packet-inout/p4src/include/ip-protocol.p4: -------------------------------------------------------------------------------- 1 | ../../../../include/ip-protocol.p4 -------------------------------------------------------------------------------- /00-unit-labs/0666-simple-packet-inout/p4src/include/p4-switch-port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GÉANT RARE project 3 | * 4 | * Licensed under the Apache License, VersiOn 2.0 (the "License"); 5 | * yOu may nOt use this file except in cOmpliance with the License. 6 | * YOu may Obtain a cOpy Of the License at 7 | * 8 | * http://www.apache.Org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law Or agreed tO in writing, sOftware 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express Or implied. 13 | * See the License fOr the specific language gOverning permissiOns and 14 | * limitatiOns under the License. 15 | */ 16 | 17 | #define CPU_PORT_OFFSET 256 18 | 19 | -------------------------------------------------------------------------------- /00-unit-labs/codex/enum.p4: -------------------------------------------------------------------------------- 1 | /** 2 | * Define EtherType and IP protocol number 3 | * CONTRIBUTOR: Kevin Cyu (https://github.com/kevinbird61) 4 | */ 5 | 6 | 7 | /* EtherType (https://en.wikipedia.org/wiki/EtherType) */ 8 | const bit<16> TYPE_IPV4 = 0x0800; // Internet Protocol version 4 (IPv4) 9 | const bit<16> TYPE_ARP = 0x0806; // Address Resolution Protocol (ARP) 10 | const bit<16> TYPE_VLAN = 0x8100; // VLAN-tagged frame (IEEE 802.1Q) 11 | const bit<16> TYPE_IPV6 = 0x86DD; // Internet Protocol version 6 (IPv6) 12 | const bit<16> TYPE_MPLS_uni = 0x8847; // MPLS unicast 13 | const bit<16> TYPE_MPLS_mul = 0x8848; // MPLS multicast 14 | 15 | /* IP protocol number (https://en.wikipedia.org/wiki/List_of_IP_protocol_numbers) */ 16 | const bit<8> PROTO_ICMP = 1; // Internet Control Message Protocol (ICMP) 17 | const bit<8> PROTO_IPV4 = 4; // IPv4 Encapsulation 18 | const bit<8> PROTO_TCP = 6; // Transmission Control Protocol (TCP) 19 | const bit<8> PROTO_UDP = 17; // User Datagram Protocol (UDP) 20 | const bit<8> PROTO_IPV6 = 41; // IPv6 Encapsulation 21 | 22 | // INT 23 | const bit<6> DSCP_INT = 0x17; 24 | 25 | // INT Header type - destination and hop-by-hop 26 | const bit<8> INT_TYPE_DST = 0x1; 27 | const bit<8> INT_TYPE_HOP = 0x2; 28 | -------------------------------------------------------------------------------- /00-unit-labs/codex/l2.p4: -------------------------------------------------------------------------------- 1 | /** 2 | * Define protocols in OSI layer 2 3 | * CONTRIBUTOR: Kevin Cyu (https://github.com/kevinbird61) 4 | */ 5 | 6 | 7 | /* Ethernet */ 8 | header ethernet_t { 9 | bit<48> dstAddr; // Destination MAC Address 10 | bit<48> srcAddr; // Source MAC Address 11 | bit<16> etherType; // EtherType 12 | } 13 | 14 | /* IEEE 802.1Q - VLAN-tagged frame */ 15 | header vlan_t { 16 | bit<48> dstAddr; // Destination MAC Address 17 | bit<48> srcAddr; // Source MAC Address 18 | bit<16> tpid; // Tag Protocol Identifier (TPID) 19 | bit<3> pcp; // Priority Code Point (PCP) 20 | bit<1> dei; // Drop Eligible Indicator (DEI) 21 | bit<12> vid; // VLAN Identifier (VID) 22 | bit<16> etherType; // EtherType 23 | } 24 | -------------------------------------------------------------------------------- /00-unit-labs/codex/l4.p4: -------------------------------------------------------------------------------- 1 | /** 2 | * Define protocols in OSI layer 4 3 | * CONTRIBUTOR: Kevin Cyu (https://github.com/kevinbird61) 4 | */ 5 | 6 | 7 | /* Transmission Control Protocol (TCP) */ 8 | header tcp_t { 9 | bit<16> srcPort; // Source Port Number 10 | bit<16> dstPort; // Destination Port Number 11 | bit<32> seq; // Sequence Number (SEQ) 12 | bit<32> ack; // Acknowledgment Number (ACK) 13 | bit<4> dataOffset; // Data Offset 14 | bit<4> rsvd; // Reserved 15 | bit<8> flags; // Flags 16 | bit<16> window; // Window Size 17 | bit<16> checksum; // Checksum 18 | bit<16> urgentPtr; // Urgent Pointer 19 | } 20 | 21 | /* User Datagram Protocol (UDP) */ 22 | header udp_t { 23 | bit<16> srcPort; // Source Port Number 24 | bit<16> dstPort; // Destination Port Number 25 | bit<16> len; // Length 26 | bit<16> checksum; // Checksum 27 | } 28 | 29 | /* Virtual Extensible LAN (VXLAN) */ 30 | header vxlan_t { 31 | bit<8> vxflags; // VXLAN Flags 32 | bit<24> rsvd1; // Reserved 33 | bit<24> vni; // VXLAN NI (VNI) 34 | bit<8> rsvd2; // Reserved 35 | } 36 | -------------------------------------------------------------------------------- /00-unit-labs/codex/l567.p4: -------------------------------------------------------------------------------- 1 | /* 2 | Layer 5,6,7 protocol 3 | */ 4 | 5 | // SIP Header Format 6 | header sip_t { 7 | bit<4> version; 8 | bit<28> flowLabel; 9 | bit<16> payloadLen; 10 | bit<8> payloadType; 11 | bit<8> hopLimit; 12 | bit<32> srcAddr; 13 | bit<32> dstAddr; 14 | } 15 | -------------------------------------------------------------------------------- /01-P-labs/README.md: -------------------------------------------------------------------------------- 1 | # Work in progress 2 | ![Comming soon](https://github.com/frederic-loui/RARE/blob/master/resources/coming-soon.png) 3 | 4 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/Makefile: -------------------------------------------------------------------------------- 1 | BASE_DIR=$(PWD) 2 | BIN_DIR=$(BASE_DIR)/bin 3 | 4 | all: 5 | echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 6 | echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6 7 | sudo $(BIN_DIR)/setup_r1.sh 8 | sudo $(BIN_DIR)/setup_r2.sh 9 | sudo $(BIN_DIR)/setup_core1.sh 10 | sudo $(BIN_DIR)/setup_r3.sh 11 | sudo $(BIN_DIR)/setup_r4.sh 12 | 13 | clean: 14 | -sudo pkill -9 pcapInt.bin 15 | -sudo pkill -9 java 16 | -sudo $(BIN_DIR)/teardown_r1.sh 17 | -sudo $(BIN_DIR)/teardown_r2.sh 18 | -sudo $(BIN_DIR)/teardown_core1.sh 19 | -sudo $(BIN_DIR)/teardown_r3.sh 20 | -sudo $(BIN_DIR)/teardown_r4.sh 21 | #-sudo $(BIN_DIR)/teardown_p4-core1.sh 22 | 23 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/bundle.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/bundle.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/hdlcInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/hdlcInt.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/mapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/mapInt.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/modem.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/modem.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/pcapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/pcapInt.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/rawInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/rawInt.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/rtr.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/rtr.jar -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/rtr.rld: -------------------------------------------------------------------------------- 1 | code#3=user requested 2 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/setup_core1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=core1 5 | FREERTR_ETH0="veth251" 6 | FREERTR_GRPC="$FREERTR_HOSTNAME-grpc" 7 | P4_SWITCH_CPU="veth250" 8 | P4_SWITCH_GRPC="p4-$FREERTR_GRPC" 9 | 10 | ip link add $FREERTR_ETH0 type veth peer name $P4_SWITCH_CPU 11 | ip link add $FREERTR_GRPC type veth peer name $P4_SWITCH_GRPC 12 | 13 | ip link set dev $P4_SWITCH_CPU up 14 | ip link set dev $P4_SWITCH_GRPC up 15 | ip link set dev $FREERTR_ETH0 up 16 | ip link set dev $FREERTR_GRPC up 17 | 18 | ip addr add 10.10.10.227/24 dev $P4_SWITCH_GRPC 19 | 20 | $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22709/22710" -r "$FREERTR_HOSTNAME" 21 | 22 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/setup_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Example of simple_switch with ipv4.json 4 | # sudo simple_switch --log-console -i 1@p4-core1-dp1 -i 2@p4-core1-dp2 -i 255@p4-core1-cpu1 -i 254@p4-core1-cpu2 --thrift-port 9090 --nanolog ipc:///tmp/bm-0-log.ipc --device-id 0 ipv4.json 5 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/setup_r1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=r1 5 | FREERTR_ETH0="veth1" 6 | P4_SWITCH_DP1="veth0" 7 | 8 | ip link add $FREERTR_ETH0 type veth peer name $P4_SWITCH_DP1 9 | 10 | ip link set dev $P4_SWITCH_DP1 up 11 | ip link set dev $FREERTR_ETH0 up 12 | 13 | $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22705/22706" -r "$FREERTR_HOSTNAME" 14 | 15 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/setup_r2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=r2 5 | FREERTR_ETH0="veth3" 6 | FREERTR_ETH1="$FREERTR_HOSTNAME-eth1" 7 | P4_SWITCH_DP2="veth2" 8 | R3_INTF="r3-eth0" 9 | 10 | ip link add $FREERTR_ETH0 type veth peer name $P4_SWITCH_DP2 11 | ip link add $FREERTR_ETH1 type veth peer name $R3_INTF 12 | 13 | ip link set dev $P4_SWITCH_DP2 up 14 | ip link set dev $FREERTR_ETH0 up 15 | ip link set dev $FREERTR_ETH1 up 16 | 17 | $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22707/22708 $FREERTR_ETH1/22713/22714" -r "$FREERTR_HOSTNAME" 18 | 19 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/setup_r3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=r3 5 | FREERTR_ETH0="$FREERTR_HOSTNAME-eth0" 6 | R2_INTF="r2-eth1" 7 | 8 | ip link add $FREERTR_ETH0 type veth peer name $R2_INTF 9 | ip link set dev $FREERTR_ETH0 up 10 | 11 | $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22715/22716" -r "$FREERTR_HOSTNAME" 12 | 13 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/setup_r4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FREERTR_HOME=$(pwd) 4 | FREERTR_HOSTNAME=r4 5 | FREERTR_ETH0="veth5" 6 | P4_SWITCH_DP4="veth4" 7 | 8 | ip link add $FREERTR_ETH0 type veth peer name $P4_SWITCH_DP4 9 | 10 | ip link set dev $P4_SWITCH_DP4 up 11 | ip link set dev $FREERTR_ETH0 up 12 | 13 | $FREERTR_HOME/bin/freertr.sh -i "$FREERTR_ETH0/22717/22718" -r "$FREERTR_HOSTNAME" 14 | 15 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/stdLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/stdLin.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/tapInt.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/tapInt.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/teardown_core1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ip link set veth251 down 4 | ip link set core1-grpc down 5 | ip link delete dev veth251 6 | ip link delete dev core1-grpc 7 | 8 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/teardown_p4-core1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ip link delete dev p4-core1-dp1 4 | ip link delete dev p4-core1-dp2 5 | ip link delete dev p4-core1-cpu1 6 | ip link delete dev p4-core1-grpc 7 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/teardown_r1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ip link set veth1 down 4 | ip link del dev veth1 5 | 6 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/teardown_r2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ip link set veth3 down 4 | ip link delete dev veth3 5 | 6 | ip link set r2-eth1 down 7 | ip link delete dev r2-eth1 8 | 9 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/teardown_r3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ip link set r3-eth0 down 4 | ip link delete dev r3-eth0 5 | 6 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/teardown_r4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ip link set veth5 down 4 | ip link del dev veth5 5 | 6 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/ttyLin.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/ttyLin.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-A/bin/vlan.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-A/bin/vlan.bin -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/README.md: -------------------------------------------------------------------------------- 1 | # Work in progress 2 | ![Comming soon](https://github.com/frederic-loui/RARE/blob/master/resources/coming-soon.png) 3 | 4 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/bin: -------------------------------------------------------------------------------- 1 | ../0000-topology-A/bin/ -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c1/c1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11011 127.0.0.1 11012 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1001 v1 23 7 | tcp2vrf 2001 v1 22 8 | tcp2vrf 9081 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c2/c2-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11021 127.0.0.1 11022 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1002 v1 23 7 | tcp2vrf 2002 v1 22 8 | tcp2vrf 9082 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c3/c3-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11031 127.0.0.1 11032 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1003 v1 23 7 | tcp2vrf 2003 v1 22 8 | tcp2vrf 9083 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c4/c4-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11041 127.0.0.1 11042 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1004 v1 23 7 | tcp2vrf 2004 v1 22 8 | tcp2vrf 9084 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c5/c5-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11051 127.0.0.1 11052 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1005 v1 23 7 | tcp2vrf 2005 v1 22 8 | tcp2vrf 9085 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c6/c6-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11061 127.0.0.1 11062 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1006 v1 23 7 | tcp2vrf 2006 v1 22 8 | tcp2vrf 9086 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c7/c7-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11071 127.0.0.1 11072 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1007 v1 23 7 | tcp2vrf 2007 v1 22 8 | tcp2vrf 9087 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/c8/c8-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11081 127.0.0.1 11082 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1008 v1 23 7 | tcp2vrf 2008 v1 22 8 | tcp2vrf 9088 v1 9080 9 | !tcp2vrf 8080 v1 80 10 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 11 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/r10/r10-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11101 127.0.0.1 11102 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1010 v2 23 7 | tcp2vrf 2010 v2 22 8 | !tcp2vrf 8080 v2 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/r11/r11-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11111 127.0.0.1 11112 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1011 v2 23 7 | tcp2vrf 2011 v2 22 8 | !tcp2vrf 8080 v2 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/r12/r12-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11121 127.0.0.1 11122 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1012 v2 23 7 | tcp2vrf 2012 v2 22 8 | !tcp2vrf 8080 v2 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/run/r9/r9-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth - 127.0.0.1 11091 127.0.0.1 11092 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1009 v1 23 7 | tcp2vrf 2009 v1 22 8 | !tcp2vrf 8080 v1 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/topology.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-B/topology.dia -------------------------------------------------------------------------------- /02-PE-labs/0000-topology-B/topology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/0000-topology-B/topology.png -------------------------------------------------------------------------------- /02-PE-labs/0001-vpn-over-bgp-isis-sr-operation/Makefile: -------------------------------------------------------------------------------- 1 | ../0000-topology-A/Makefile -------------------------------------------------------------------------------- /02-PE-labs/0001-vpn-over-bgp-isis-sr-operation/bin: -------------------------------------------------------------------------------- 1 | ../0000-topology-A/bin/ -------------------------------------------------------------------------------- /02-PE-labs/0001-vpn-over-bgp-isis-sr-operation/run/core1/core1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth 0000.0A00.0040 127.0.0.1 22710 127.0.0.1 22709 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | tcp2vrf 9080 v1 9080 8 | !tcp2vrf 8080 v1 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /02-PE-labs/0001-vpn-over-bgp-isis-sr-operation/run/r1/r1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0101 127.0.0.1 22706 127.0.0.1 22705 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 1001 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /02-PE-labs/0001-vpn-over-bgp-isis-sr-operation/run/r2/r2-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 61000 62000 3 | int eth0 eth 0000.0A00.0202 127.0.0.1 22708 127.0.0.1 22707 4 | int eth1 eth 0000.0A00.1702 127.0.0.1 22714 127.0.0.1 22713 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1002 v1 23 7 | !tcp2vrf 8080 v1 80 8 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 9 | -------------------------------------------------------------------------------- /02-PE-labs/0001-vpn-over-bgp-isis-sr-operation/run/r3/r3-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.1703 127.0.0.1 22716 127.0.0.1 22715 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 1003 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /02-PE-labs/0001-vpn-over-bgp-isis-sr-operation/run/r4/r4-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0404 127.0.0.1 22718 127.0.0.1 22717 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 1004 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /02-PE-labs/0002-vpn-over-bgp-ospf-sr-operation/Makefile: -------------------------------------------------------------------------------- 1 | ../0000-topology-A/Makefile -------------------------------------------------------------------------------- /02-PE-labs/0002-vpn-over-bgp-ospf-sr-operation/bin: -------------------------------------------------------------------------------- 1 | ../0000-topology-A/bin/ -------------------------------------------------------------------------------- /02-PE-labs/0002-vpn-over-bgp-ospf-sr-operation/run/core1/core1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 63000 64000 3 | int eth0 eth 0000.0A00.0040 127.0.0.1 22710 127.0.0.1 22709 4 | !int eth1 eth 0000.0A00.02FE 127.0.0.1 22712 127.0.0.1 22711 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 2323 v1 23 7 | tcp2vrf 9080 v1 9080 8 | !tcp2vrf 8080 v1 80 9 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 10 | -------------------------------------------------------------------------------- /02-PE-labs/0002-vpn-over-bgp-ospf-sr-operation/run/r1/r1-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0101 127.0.0.1 22706 127.0.0.1 22705 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 1001 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /02-PE-labs/0002-vpn-over-bgp-ospf-sr-operation/run/r2/r2-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 61000 62000 3 | int eth0 eth 0000.0A00.0202 127.0.0.1 22708 127.0.0.1 22707 4 | int eth1 eth 0000.0A00.1702 127.0.0.1 22714 127.0.0.1 22713 5 | !line tty1 127.0.0.1 21003 127.0.0.1 21003 6 | tcp2vrf 1002 v1 23 7 | !tcp2vrf 8080 v1 80 8 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 9 | -------------------------------------------------------------------------------- /02-PE-labs/0002-vpn-over-bgp-ospf-sr-operation/run/r3/r3-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.1703 127.0.0.1 22716 127.0.0.1 22715 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 1003 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /02-PE-labs/0002-vpn-over-bgp-ospf-sr-operation/run/r4/r4-hw.txt: -------------------------------------------------------------------------------- 1 | hwid emu 2 | port 60000 61000 3 | int eth0 eth 0000.0A00.0404 127.0.0.1 22718 127.0.0.1 22717 4 | !line tty1 127.0.0.1 21001 127.0.0.1 21002 5 | tcp2vrf 1004 v1 23 6 | !tcp2vrf 8080 v1 80 7 | def alias test bash command attach shell1 socat - exec:sh,ctty,pty,stderr 8 | -------------------------------------------------------------------------------- /02-PE-labs/README.md: -------------------------------------------------------------------------------- 1 | # Work in progress 2 | ![Comming soon](https://github.com/frederic-loui/RARE/blob/master/resources/coming-soon.png) 3 | 4 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/cst_cpu_port.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _CPU_PORT_P4_ 18 | #define _CPU_PORT_P4_ 19 | 20 | #define CPU_PORT 64 21 | 22 | #endif // _CPU_PORT_P4_ 23 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/cst_ethertype.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // source here: 18 | // https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml 19 | 20 | #ifndef _ETHERTYPE_P4_ 21 | #define _ETHERTYPE_P4_ 22 | 23 | const bit<16> ETHERTYPE_IPV4 = 0x0800; 24 | const bit<16> ETHERTYPE_ARP = 0x0806; 25 | const bit<16> ETHERTYPE_VLAN = 0x8100; 26 | const bit<16> ETHERTYPE_IPV6 = 0x86dd; 27 | const bit<16> ETHERTYPE_NSH = 0x894f; 28 | const bit<16> ETHERTYPE_POLKA = 0x8842; 29 | const bit<16> ETHERTYPE_MPLS_UCAST = 0x8847; 30 | const bit<16> ETHERTYPE_MPLS_MCAST = 0x8848; 31 | const bit<16> ETHERTYPE_LACP = 0x8809; 32 | const bit<16> ETHERTYPE_LLDP = 0x88cc; 33 | const bit<16> ETHERTYPE_PPPOE_CTRL = 0x8863; 34 | const bit<16> ETHERTYPE_PPPOE_DATA = 0x8864; 35 | const bit<16> ETHERTYPE_ROUTEDMAC = 0x6558; 36 | const bit<16> ETHERTYPE_SGT = 0x8909; 37 | const bit<16> PPPTYPE_IPV4 = 0x0021; 38 | const bit<16> PPPTYPE_IPV6 = 0x0057; 39 | const bit<16> PPPTYPE_MPLS_UCAST = 0x0281; 40 | const bit<16> PPPTYPE_ROUTEDMAC = 0x0031; 41 | const bit<16> PPPTYPE_SGT = 0x004a; 42 | const bit<16> PPPTYPE_NSH = 0x004b; 43 | 44 | #endif // _ETHERTYPE_P4_ 45 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/def_types.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _TYPES_P4_ 18 | #define _TYPES_P4_ 19 | 20 | typedef bit<16> ethertype_t; 21 | typedef bit<48> mac_addr_t; 22 | typedef bit<20> label_t; 23 | typedef bit<128> polka_route_t; 24 | typedef bit<32> ipv4_addr_t; 25 | typedef bit<128> ipv6_addr_t; 26 | typedef bit<16> layer4_port_t; 27 | typedef bit<12> vlan_id_t; 28 | typedef bit<16> switch_vrf_t; 29 | typedef bit<9> PortId_t; 30 | typedef bit<16> NextHopId_t; 31 | typedef bit<10> SubIntId_t; 32 | #define MAX_PORT 1023 33 | 34 | #endif // _TYPES_P4_ 35 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/eg_ctl_dprs.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EG_DEPARSER_P4_ 18 | #define _EG_DEPARSER_P4_ 19 | 20 | control eg_ctl_dprs(packet_out pkt, 21 | in headers hdr) { 22 | apply { 23 | /* 24 | * parsed headers that have been modified 25 | * in ctl_ingress and ctl_egress 26 | * have to be added again into the pkt. 27 | * for emission in the wire 28 | */ 29 | pkt.emit(hdr); 30 | } 31 | } 32 | 33 | #endif // _EG_DEPARSER_P4_ 34 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/eg_ctl_hairpin.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EG_CTL_HAIRPIN_P4_ 18 | #define _EG_CTL_HAIRPIN_P4_ 19 | 20 | control EgressControlHairpin(inout headers hdr, 21 | inout ingress_metadata_t eg_md, 22 | inout standard_metadata_t eg_intr_md) { 23 | 24 | 25 | action act_set_recir(SubIntId_t port) { 26 | eg_intr_md.egress_spec = (PortId_t)port; 27 | eg_md.need_recir = 2; 28 | hdr.cpu.setValid(); 29 | hdr.cpu.port = port; 30 | } 31 | 32 | table tbl_hairpin { 33 | key = { 34 | eg_md.outport_id: 35 | exact; 36 | } 37 | actions = { 38 | act_set_recir; 39 | @defaultonly NoAction; 40 | } 41 | size = BUNDLE_TABLE_SIZE; 42 | const default_action = NoAction(); 43 | } 44 | 45 | apply { 46 | tbl_hairpin.apply(); 47 | } 48 | } 49 | 50 | #endif // _EG_CTL_HAIRPIN_P4_ 51 | 52 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/eg_ctl_outport.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EG_CTL_OUTPORT_P4_ 18 | #define _EG_CTL_OUTPORT_P4_ 19 | 20 | control EgressControlOutPort(inout headers hdr, 21 | inout ingress_metadata_t eg_md, 22 | inout standard_metadata_t eg_intr_md) { 23 | 24 | 25 | action act_set_port_nexthop(SubIntId_t subif) { 26 | eg_md.aclport_id = subif; 27 | } 28 | 29 | 30 | table tbl_nexthop { 31 | key = { 32 | eg_md.nexthop_id: 33 | exact; 34 | } 35 | actions = { 36 | act_set_port_nexthop; 37 | @defaultonly NoAction; 38 | } 39 | size = NEXTHOP_TABLE_SIZE; 40 | default_action = NoAction(); 41 | } 42 | 43 | 44 | 45 | apply { 46 | 47 | tbl_nexthop.apply(); 48 | 49 | } 50 | } 51 | 52 | #endif // _EG_CTL_OUTPORT_P4_ 53 | 54 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/eg_ctl_sgt.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EG_CTL_SGT_P4_ 18 | #define _EG_CTL_SGT_P4_ 19 | 20 | control EgressControlSgt(inout headers hdr, 21 | inout ingress_metadata_t eg_md, 22 | inout standard_metadata_t eg_intr_md) { 23 | 24 | counter((MAX_PORT+1), CounterType.packets_and_bytes) stats; 25 | 26 | 27 | action act_need_tag() { 28 | eg_md.vlan_size = eg_md.vlan_size - 8; 29 | hdr.sgt.setValid(); 30 | hdr.sgt.version = 1; 31 | hdr.sgt.length = 1; 32 | hdr.sgt.options = 1; 33 | hdr.sgt.groupid = eg_md.sec_grp_id; 34 | hdr.sgt.ethertype = eg_md.ethertype; 35 | eg_md.ethertype = ETHERTYPE_SGT; 36 | } 37 | 38 | action act_noned_tag() { 39 | } 40 | 41 | 42 | table tbl_sgt_out { 43 | key = { 44 | eg_md.aclport_id: 45 | exact; 46 | } 47 | actions = { 48 | act_need_tag; 49 | act_noned_tag; 50 | } 51 | size = VLAN_TABLE_SIZE; 52 | default_action = act_noned_tag(); 53 | } 54 | 55 | apply { 56 | tbl_sgt_out.apply(); 57 | stats.count((bit<32>)eg_md.target_id); 58 | } 59 | } 60 | 61 | #endif // _EG_CTL_SGT_P4_ 62 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_amt.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _AMT_P4_ 18 | #define _AMT_P4_ 19 | 20 | header amt_t { 21 | bit<4> ver; 22 | bit<4> type; 23 | bit<8> reserved; 24 | } 25 | 26 | #endif // _AMT_P4_ 27 | 28 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_arp.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ARP_P4_ 18 | #define _ARP_P4_ 19 | 20 | /* 21 | * ICMP header: as a header type, order matters 22 | */ 23 | header arp_t { 24 | bit<16> hrd; 25 | bit<16> pro; 26 | bit<8> hln; 27 | bit<8> pln; 28 | bit<16> op; 29 | mac_addr_t sha; 30 | ipv4_addr_t tpa; 31 | mac_addr_t tha; 32 | ipv4_addr_t spa; 33 | } 34 | 35 | #endif // _ARP_P4_ 36 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_bier.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _BIER_P4_ 18 | #define _BIER_P4_ 19 | 20 | header bier_t { 21 | bit<8> idver; 22 | bit<4> bsl; 23 | bit<20> entropy; 24 | bit<2> oam; 25 | bit<2> reserved; 26 | bit<6> dscp; 27 | bit<6> proto; 28 | bit<16> bfir; 29 | bit<32> bs0; 30 | bit<32> bs1; 31 | bit<32> bs2; 32 | bit<32> bs3; 33 | bit<32> bs4; 34 | bit<32> bs5; 35 | bit<32> bs6; 36 | bit<32> bs7; 37 | } 38 | 39 | #endif // _BIER_P4_ 40 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_cpu.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _CPU_P4_ 18 | #define _CPU_P4_ 19 | 20 | header cpu_header_t { 21 | bit<16> _padding2; 22 | bit<6> _padding1; 23 | SubIntId_t port; 24 | } 25 | 26 | #endif // _CPU_P4_ 27 | 28 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_etherip.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ETHERIP_P4_ 18 | #define _ETHERIP_P4_ 19 | 20 | header etherip_t { 21 | bit<16> version; 22 | } 23 | 24 | #endif // _ETHERIP_P4_ 25 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_ethernet.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _ETHERNET_P4_ 18 | #define _ETHERNET_P4_ 19 | 20 | /* 21 | * Ethernet header: as a header type, order matters 22 | */ 23 | header ethernet_t { 24 | mac_addr_t dst_mac_addr; 25 | mac_addr_t src_mac_addr; 26 | ethertype_t ethertype; 27 | } 28 | 29 | #endif // _ETHERNET_P4_ 30 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_gre.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _GRE_P4_ 18 | #define _GRE_P4_ 19 | 20 | header gre_t { 21 | bit<16> flags; 22 | bit<16> gretyp; 23 | } 24 | 25 | #endif // _GRE_P4_ 26 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_gtp.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _GTP_P4_ 18 | #define _GTP_P4_ 19 | 20 | header gtp_t { 21 | bit<8> flag; 22 | bit<8> type; 23 | bit<16> length; 24 | bit<32> teid; 25 | } 26 | 27 | #endif // _GTP_P4_ 28 | 29 | 30 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_ig_headers.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _HEADERS_P4_ 18 | #define _HEADERS_P4_ 19 | 20 | struct headers { 21 | cpu_header_t cpu; 22 | ethernet_t ethernet; 23 | vlan_t vlan; 24 | vlan_t vlanq; 25 | pppoe_t pppoeC; 26 | pppoe_t pppoeD; 27 | pppbr_t pppoeB; 28 | ethernet_t eth6; 29 | ipv4_t ipv4d; 30 | ipv6_t ipv6d; 31 | l3tp_t l3tp2; 32 | gre_t gre2; 33 | tmux_t tmux2; 34 | etherip_t etherip2; 35 | udp_t udp2; 36 | vxlan_t vxlan2; 37 | mpls_t mpls90; 38 | mpls_t mpls91; 39 | ethernet_t eth9; 40 | l2tp_t l2tp2; 41 | amt_t amt2; 42 | gtp_t gtp2; 43 | pppbr_t pppbr; 44 | ethernet_t eth4; 45 | polka_t polka; 46 | sgt_t sgt; 47 | nsh_t nsh; 48 | mpls_t mpls0; 49 | mpls_t mpls1; 50 | bier_t bier; 51 | mpls_t mpls8; 52 | ipv4_t ipv4c; 53 | ipv6_t ipv6c; 54 | ethernet_t eth2; 55 | vlan_t vlan2; 56 | arp_t arp; 57 | llc_t llc; 58 | ipv4_t ipv4; 59 | ipv6_t ipv6; 60 | ethernet_t eth3; 61 | ipv4_t ipv4b; 62 | ipv6_t ipv6b; 63 | l3tp_t l3tp; 64 | gre_t gre; 65 | tmux_t tmux; 66 | etherip_t etherip; 67 | udp_t udp; 68 | l2tp_t l2tp; 69 | amt_t amt; 70 | gtp_t gtp; 71 | vxlan_t vxlan; 72 | tcp_t tcp; 73 | pppbr_t l2tpbr; 74 | ethernet_t eth5; 75 | } 76 | 77 | #endif // _HEADERS_P4_ 78 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_ipv4.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IPV4_P4_ 18 | #define _IPV4_P4_ 19 | 20 | header ipv4_t { 21 | bit<4> version; 22 | bit<4> ihl; 23 | bit<8> diffserv; 24 | bit<16> total_len; 25 | bit<16> identification; 26 | bit<3> flags; 27 | bit<13> frag_offset; 28 | bit<8> ttl; 29 | bit<8> protocol; 30 | bit<16> hdr_checksum; 31 | ipv4_addr_t src_addr; 32 | ipv4_addr_t dst_addr; 33 | } 34 | 35 | #endif // _IPV4_P4_ 36 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_ipv6.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IPV6_P4_ 18 | #define _IPV6_P4_ 19 | 20 | header ipv6_t { 21 | bit<4> version; 22 | bit<8> traffic_class; 23 | bit<20> flow_label; 24 | bit<16> payload_len; 25 | bit<8> next_hdr; 26 | bit<8> hop_limit; 27 | bit<128> src_addr; 28 | bit<128> dst_addr; 29 | } 30 | 31 | #endif // _IPV6_P4_ 32 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_l2tp.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _L2TP_P4_ 18 | #define _L2TP_P4_ 19 | 20 | header l2tp_t { 21 | bit<16> flags; 22 | bit<32> tidsid; 23 | bit<16> offset; 24 | bit<16> pppflags; 25 | bit<16> ppptyp; 26 | } 27 | 28 | #endif // _L2TP_P4_ 29 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_l3tp.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _L3TP_P4_ 18 | #define _L3TP_P4_ 19 | 20 | header l3tp_t { 21 | bit<32> tidsid; 22 | bit<16> ppptyp; 23 | } 24 | 25 | #endif // _L3TP_P4_ 26 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_llc.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LLC_P4_ 18 | #define _LLC_P4_ 19 | 20 | header llc_t { 21 | bit<8> dsap; 22 | bit<8> ssap; 23 | bit<8> control_; 24 | } 25 | 26 | #endif // _LLC_P4_ 27 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_mpls.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MPLS_P4_ 18 | #define _MPLS_P4_ 19 | 20 | header mpls_t { 21 | label_t label; 22 | bit<3> exp; 23 | bit<1> bos; 24 | bit<8> ttl; 25 | } 26 | 27 | #endif // _MPLS_P4_ 28 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_nsh.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _NSH_P4_ 18 | #define _NSH_P4_ 19 | 20 | header nsh_t { 21 | bit<2> version; 22 | bit<1> oam; 23 | bit<1> res1; 24 | bit<6> ttl; 25 | bit<6> length; 26 | bit<4> res2; 27 | bit<4> md_type; 28 | bit<8> next_proto; 29 | bit<24> sp; 30 | bit<8> si; 31 | } 32 | 33 | #endif // _NSH_P4_ 34 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_polka.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021-present Universidade Federal do Espirito Santo (UFES) and 3 | * Instituto Federal do Espirito Santo (IFES) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed On an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef _POLKA_P4_ 19 | #define _POLKA_P4_ 20 | 21 | header polka_t { 22 | bit<8> version; 23 | bit<8> ttl; 24 | bit<16> proto; 25 | polka_route_t routeid; 26 | } 27 | 28 | #endif // _POLKA_P4_ 29 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_pppbr.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _PPPBR_P4_ 18 | #define _PPPBR_P4_ 19 | 20 | header pppbr_t { 21 | bit<16> flags; 22 | } 23 | 24 | #endif // _PPPBR_P4_ 25 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_pppoe.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _PPPOE_P4_ 18 | #define _PPPOE_P4_ 19 | 20 | header pppoe_t { 21 | bit<4> ver; 22 | bit<4> type; 23 | bit<8> code; 24 | bit<16> session; 25 | bit<16> length; 26 | bit<16> ppptyp; 27 | } 28 | 29 | #endif // _PPPOE_P4_ 30 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_recir_headers.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _RECIR_HEADERS_P4_ 18 | #define _RECIR_HEADERS_P4_ 19 | 20 | struct recir_headers_t { 21 | } 22 | 23 | #endif // _RECIR_HEADERS_P4_ 24 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_sgt.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SGT_P4_ 18 | #define _SGT_P4_ 19 | 20 | header sgt_t { 21 | bit<8> version; 22 | bit<8> length; 23 | bit<16> options; 24 | bit<16> groupid; 25 | ethertype_t ethertype; 26 | } 27 | 28 | #endif // _SGT_P4_ 29 | 30 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_tcp.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _TCP_P4_ 18 | #define _TCP_P4_ 19 | 20 | header tcp_t { 21 | layer4_port_t src_port; 22 | layer4_port_t dst_port; 23 | bit<32> seq_no; 24 | bit<32> ack_no; 25 | bit<4> data_offset; 26 | bit<4> res; 27 | bit<8> flags; 28 | bit<16> window; 29 | bit<16> checksum; 30 | bit<16> urgent_ptr; 31 | } 32 | 33 | #endif // _TCP_P4_ 34 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_tmux.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _TMUX_P4_ 18 | #define _TMUX_P4_ 19 | 20 | header tmux_t { 21 | bit<16> length; 22 | bit<8> proto; 23 | bit<8> chksum; 24 | } 25 | 26 | #endif // _TMUX_P4_ 27 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_udp.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _UDP_P4_ 18 | #define _UDP_P4_ 19 | 20 | header udp_t { 21 | layer4_port_t src_port; 22 | layer4_port_t dst_port; 23 | bit<16> length; 24 | bit<16> checksum; 25 | } 26 | 27 | #endif // _UDP_P4_ 28 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_vlan.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _VLAN_P4_ 18 | #define _VLAN_P4_ 19 | 20 | /* 21 | * VLAN header: as a header type, order matters 22 | */ 23 | header vlan_t { 24 | bit<3> pcp; 25 | bit<1> cfi; 26 | vlan_id_t vid; 27 | ethertype_t ethertype; 28 | } 29 | 30 | #endif // _VLAN_P4_ 31 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/hdr_vxlan.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _VXLAN_P4_ 18 | #define _VXLAN_P4_ 19 | 20 | header vxlan_t { 21 | bit<16> flags; 22 | bit<16> policy; 23 | bit<24> instance; 24 | bit<8> reserved; 25 | } 26 | 27 | #endif // _VXLAN_P4_ 28 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/ig_ctl_arp.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IG_CTL_ARP_P4_ 18 | #define _IG_CTL_ARP_P4_ 19 | 20 | control IngressControlARP(inout headers hdr, 21 | inout ingress_metadata_t ig_md, 22 | inout standard_metadata_t ig_intr_md) { 23 | 24 | action send_to_cpu() { 25 | /* 26 | * Prepend cpu header to pkt sent to controller 27 | * by calling setValid() so it is tekne into account by deparser 28 | */ 29 | ig_md.nexthop_id = CPU_PORT; 30 | } 31 | 32 | apply { 33 | /* 34 | * It is a dataplane packet 35 | */ 36 | if (ig_md.arp_valid==1) { 37 | send_to_cpu(); 38 | } 39 | } 40 | 41 | } 42 | 43 | #endif // _IG_CTL_ARP_P4_ 44 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/ig_ctl_bundle.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IG_CTL_BUNDLE_P4_ 18 | #define _IG_CTL_BUNDLE_P4_ 19 | 20 | control IngressControlBundle(inout headers hdr, 21 | inout ingress_metadata_t ig_md, 22 | inout standard_metadata_t ig_intr_md) { 23 | 24 | action act_set_hash(PortId_t port) { 25 | ig_intr_md.egress_spec = port; 26 | ig_md.vlan_size = 0; 27 | ig_md.need_recir = 0; 28 | } 29 | 30 | action act_set_port() { 31 | ig_intr_md.egress_spec = (PortId_t)ig_md.outport_id; 32 | ig_md.vlan_size = 0; 33 | ig_md.need_recir = 0; 34 | } 35 | 36 | action act_set_recir(SubIntId_t port) { 37 | ig_intr_md.egress_spec = (PortId_t)port; 38 | ig_md.vlan_size = 4; 39 | ig_md.need_recir = 2; 40 | hdr.cpu.setValid(); 41 | hdr.cpu.port = port; 42 | } 43 | 44 | table tbl_bundle { 45 | key = { 46 | ig_md.outport_id: 47 | exact; 48 | ig_md.hash_id: 49 | exact; 50 | } 51 | actions = { 52 | act_set_port; 53 | act_set_hash; 54 | act_set_recir; 55 | } 56 | size = BUNDLE_TABLE_SIZE; 57 | default_action = act_set_port(); 58 | } 59 | 60 | apply { 61 | bit<16> tmp = ig_md.layer4_srcprt ^ ig_md.layer4_dstprt; 62 | tmp = (tmp >> 8) ^ (tmp & 0xff); 63 | tmp = (tmp >> 4) ^ (tmp & 0xf); 64 | ig_md.hash_id = (bit<4>)tmp; 65 | tbl_bundle.apply(); 66 | } 67 | } 68 | 69 | #endif // _IG_CTL_BUNDLE_P4_ 70 | 71 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/ig_ctl_frag.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IG_CTL_FRAG_P4_ 18 | #define _IG_CTL_FRAG_P4_ 19 | 20 | control IngressControlFrag(inout headers hdr, 21 | inout ingress_metadata_t ig_md, 22 | inout standard_metadata_t ig_intr_md) { 23 | 24 | 25 | apply { 26 | ig_md.layer3_frag = 0; 27 | if (hdr.ipv4.isValid()) { 28 | if ((hdr.ipv4.flags&1) != 0) ig_md.layer3_frag = 1; 29 | if (hdr.ipv4.frag_offset != 0) ig_md.layer3_frag = 1; 30 | } 31 | if (hdr.ipv6.isValid()) { 32 | if (hdr.ipv6.next_hdr == IP_PROTOCOL_IPV6_FRAG) ig_md.layer3_frag = 1; 33 | } 34 | if (hdr.ipv4b.isValid()) { 35 | if ((hdr.ipv4b.flags&1) != 0) ig_md.layer3_frag = 1; 36 | if (hdr.ipv4b.frag_offset != 0) ig_md.layer3_frag = 1; 37 | } 38 | if (hdr.ipv6b.isValid()) { 39 | if (hdr.ipv6b.next_hdr == IP_PROTOCOL_IPV6_FRAG) ig_md.layer3_frag = 1; 40 | } 41 | } 42 | 43 | } 44 | 45 | #endif // _IG_CTL_FRAG_P4_ 46 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/ig_ctl_llc.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IG_CTL_LLC_P4_ 18 | #define _IG_CTL_LLC_P4_ 19 | 20 | control IngressControlLLC(inout headers hdr, 21 | inout ingress_metadata_t ig_md, 22 | inout standard_metadata_t ig_intr_md) { 23 | 24 | action send_to_cpu() { 25 | /* 26 | * Prepend cpu header to pkt sent to controller 27 | * by calling setValid() so it is tekne into account by deparser 28 | */ 29 | ig_md.nexthop_id = CPU_PORT; 30 | } 31 | 32 | apply { 33 | /* 34 | * It is a dataplane packet 35 | */ 36 | if (ig_md.llc_valid==1) { 37 | send_to_cpu(); 38 | } 39 | } 40 | 41 | } 42 | 43 | #endif // _IG_CTL_LLC_P4_ 44 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/ig_ctl_polka.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present Universidade Federal do Espirito Santo (UFES) and 3 | * Instituto Federal do Espirito Santo (IFES) 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed On an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef _IG_CTL_POLKA_P4_ 19 | #define _IG_CTL_POLKA_P4_ 20 | 21 | control IngressControlPOLKA(inout headers hdr, 22 | inout ingress_metadata_t ig_md, 23 | inout standard_metadata_t ig_intr_md) { 24 | 25 | direct_counter(CounterType.packets_and_bytes) stats; 26 | 27 | action act_forward(NextHopId_t nexthop_id) { 28 | ig_md.nexthop_id = nexthop_id; 29 | ig_md.ipv4_valid = 0; 30 | ig_md.ipv6_valid = 0; 31 | ig_md.mpls0_valid = 0; 32 | ig_md.mpls1_valid = 0; 33 | } 34 | 35 | action act_route() { 36 | ig_md.polka_remove = 1; 37 | ig_md.ethertype = hdr.polka.proto; 38 | } 39 | 40 | table tbl_polka { 41 | key = { 42 | ig_md.vrf: 43 | exact; 44 | ig_md.polka_next: 45 | exact; 46 | } 47 | actions = { 48 | act_forward; 49 | act_route; 50 | NoAction; 51 | } 52 | size = POLKA_TABLE_SIZE; 53 | default_action = NoAction(); 54 | counters = stats; 55 | } 56 | 57 | apply { 58 | if (ig_md.polka_valid == 1) { 59 | bit<112> ndata = (bit<112>) (hdr.polka.routeid >> 16); 60 | bit<16> diff = (bit<16>) hdr.polka.routeid; 61 | bit<16> nres = 0; 62 | hash(nres, HashAlgorithm.crc16, 16w0, { ndata }, 16w65535); 63 | ig_md.polka_next = nres ^ diff; 64 | tbl_polka.apply(); 65 | } 66 | } 67 | } 68 | 69 | #endif // _IG_CTL_POLKA_P4_ 70 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/ig_ctl_verify_checksum.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IG_CTL_VERIFY_CHECKSUM_P4_ 18 | #define _IG_CTL_VERIFY_CHECKSUM_P4_ 19 | 20 | control ig_ctl_verify_checksum(inout headers hdr, inout ingress_metadata_t ig_md) { 21 | apply { 22 | } 23 | } 24 | 25 | #endif // _IG_CTL_VERIFY_CHECKSUM_P4_ 26 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/ig_ctl_vlan_in.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _IG_CTL_VLAN_IN_P4_ 18 | #define _IG_CTL_VLAN_IN_P4_ 19 | 20 | control IngressControlVlanIn(inout headers hdr, 21 | inout ingress_metadata_t ig_md, 22 | in standard_metadata_t ig_intr_md) { 23 | 24 | counter((MAX_PORT+1), CounterType.packets_and_bytes) stats; 25 | 26 | action act_set_vlan_iface(SubIntId_t src) { 27 | ig_md.source_id = src; 28 | ig_md.ethertype = hdr.vlan.ethertype; 29 | ig_md.vlan_size = ig_md.vlan_size + 4; 30 | } 31 | 32 | action act_set_qinq_iface(SubIntId_t src) { 33 | ig_md.source_id = src; 34 | ig_md.ethertype = hdr.vlanq.ethertype; 35 | ig_md.vlan_size = ig_md.vlan_size + 8; 36 | } 37 | 38 | action act_set_def_iface() { 39 | ig_md.source_id = ig_md.ingress_id; 40 | ig_md.ethertype = hdr.ethernet.ethertype; 41 | } 42 | 43 | table tbl_vlan_in { 44 | key = { 45 | ig_md.ingress_id: 46 | exact; 47 | hdr.vlan.vid: 48 | exact; 49 | hdr.vlanq.vid: 50 | exact; 51 | } 52 | actions = { 53 | act_set_vlan_iface; 54 | act_set_qinq_iface; 55 | act_set_def_iface; 56 | } 57 | size = VLAN_TABLE_SIZE; 58 | default_action = act_set_def_iface(); 59 | } 60 | 61 | apply { 62 | tbl_vlan_in.apply(); 63 | stats.count((bit<32>)ig_md.source_id); 64 | } 65 | } 66 | 67 | #endif // _IG_CTL_VLAN_IN_P4_ 68 | 69 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/include/mtd_ig_metadata.p4: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-present GEANT RARE project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed On an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INGRESS_METADATA_P4_ 18 | #define _INGRESS_METADATA_P4_ 19 | 20 | /* 21 | * User defined metadata type 22 | */ 23 | struct ingress_metadata_t { 24 | SubIntId_t ingress_id; 25 | SubIntId_t source_id; 26 | SubIntId_t target_id; 27 | SubIntId_t aclport_id; 28 | NextHopId_t nexthop_id; 29 | SubIntId_t outport_id; 30 | SubIntId_t bridge_id; 31 | SubIntId_t bridge_src; 32 | SubIntId_t bridge_trg; 33 | SubIntId_t meter_id; 34 | bit<32> meter_res; 35 | @field_list(1) 36 | bit<4> hash_id; 37 | ethertype_t ethertype; 38 | switch_vrf_t vrf; 39 | bit<16> polka_next; 40 | bit<2> dropping; 41 | bit<1> punting; 42 | bit<1> natted; 43 | bit<2> need_recir; 44 | bit<1> need_clone; 45 | bit<16> clone_session; 46 | bit<3> mpls_op_type; 47 | bit<3> srv_op_type; 48 | bit<3> amt_type; 49 | bit<3> gtp_type; 50 | bit<16> vlan_size; 51 | bit<1> sgt_remove; 52 | bit<1> polka_remove; 53 | bit<1> nsh_remove; 54 | bit<1> mpls0_remove; 55 | bit<1> mpls1_remove; 56 | bit<1> pppoe_ctrl_valid; 57 | bit<1> pppoe_data_valid; 58 | bit<1> sgt_valid; 59 | bit<1> polka_valid; 60 | bit<1> nsh_valid; 61 | bit<1> mpls0_valid; 62 | bit<1> mpls1_valid; 63 | bit<1> llc_valid; 64 | bit<1> arp_valid; 65 | bit<1> ipv4_valid; 66 | bit<1> ipv6_valid; 67 | bit<1> layer3_frag; 68 | layer4_port_t layer4_srcprt; 69 | layer4_port_t layer4_dstprt; 70 | bit<16> sec_grp_id; 71 | bit<16> layer4_length; 72 | } 73 | 74 | #endif // _INGRESS_METADATA_P4_ 75 | -------------------------------------------------------------------------------- /02-PE-labs/p4src/p4runtime_lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/02-PE-labs/p4src/p4runtime_lib/__init__.py -------------------------------------------------------------------------------- /02-PE-labs/p4src/p4runtime_lib/bmv2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017-present Open Networking Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | from .switch import SwitchConnection 16 | from p4.tmp import p4config_pb2 17 | 18 | 19 | def buildDeviceConfig(bmv2_json_file_path=None): 20 | "Builds the device config for BMv2" 21 | device_config = p4config_pb2.P4DeviceConfig() 22 | device_config.reassign = True 23 | with open(bmv2_json_file_path) as f: 24 | device_config.device_data = f.read().encode('utf-8') 25 | return device_config 26 | 27 | 28 | class Bmv2SwitchConnection(SwitchConnection): 29 | def buildDeviceConfig(self, **kwargs): 30 | return buildDeviceConfig(**kwargs) 31 | -------------------------------------------------------------------------------- /02-PE-labs/update-jar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | wget src.freertr.org/src/rtr.jar 3 | mv rtr.jar 0000-topology-A/bin/ 4 | git add . 5 | git commit -m "updating jar" 6 | git push 7 | -------------------------------------------------------------------------------- /02-PE-labs/update-src.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | wget src.freertr.org/rtr.zip 3 | mkdir a 4 | unzip -d a/ rtr.zip 5 | rm rtr.zip 6 | mv a/misc/p4bmv2/forwarder.py p4src/ 7 | mv a/misc/p4bmv2/router.p4 p4src/ 8 | mv a/misc/p4bmv2/include/* p4src/include/ 9 | mv a/misc/p4bmv2/p4runtime_lib/* p4src/p4runtime_lib/ 10 | rm -Rf a 11 | git add . 12 | git commit -m "updating p4 sources" 13 | git push 14 | -------------------------------------------------------------------------------- /nixos/Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL = none 2 | 3 | none: 4 | 5 | install-nix-overlays-nixos: 6 | cp -r overlays* /etc/nixos 7 | 8 | install-nix-overlays-nixpkgs: 9 | mkdir -p $(HOME)/.config/nixpkgs 10 | cp -r overlays/* $(HOME)/.config/nixpkgs 11 | -------------------------------------------------------------------------------- /nixos/RARE-env.nix: -------------------------------------------------------------------------------- 1 | with import {}; 2 | 3 | stdenv.mkDerivation rec { 4 | name = "RARE-nix-environment"; 5 | buildInputs = [ 6 | bmv2 p4c dpkg ethtool gcc gnumake telnet killall jre patchelf 7 | ]; 8 | } 9 | -------------------------------------------------------------------------------- /nixos/overlays-compat/overlays.nix: -------------------------------------------------------------------------------- 1 | self: super: 2 | with super.lib; 3 | let 4 | # Using the nixos plumbing that's used to evaluate the config... 5 | eval = import ; 6 | # Evaluate the config, 7 | paths = (eval {modules = [(import )];}) 8 | # then get the `nixpkgs.overlays` option. 9 | .config.nixpkgs.overlays 10 | ; 11 | in 12 | foldl' (flip extends) (_: super) paths self 13 | -------------------------------------------------------------------------------- /nixos/overlays/PI/default.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchFromGitHub, autoreconfHook, pkg-config, 2 | python27, judy, protobuf3_6, boost, zlib, grpc, thrift }: 3 | 4 | stdenv.mkDerivation rec { 5 | name = "PI-${version}"; 6 | version = "41358da"; 7 | 8 | src = fetchFromGitHub { 9 | owner = "p4lang"; 10 | repo = "PI"; 11 | rev = "${version}"; 12 | fetchSubmodules = true; 13 | sha256 = "19s39yw8cl0ja0ghq780v721br42p0mx8rf94xl11bs31c6ijavd"; 14 | }; 15 | 16 | buildInputs = [ autoreconfHook python27 judy protobuf3_6 pkg-config 17 | boost zlib grpc thrift ]; 18 | 19 | configureFlags = [ 20 | "--with-boost=${boost}" 21 | "--with-proto" 22 | "--without-internal-rpc" 23 | "--without-cli" 24 | "--without-bmv2" 25 | "--without-sysrepo" 26 | ]; 27 | 28 | doCheck = true; 29 | ## Auto-detection of the check target fails ("make -n check" 30 | ## terminates with an error) 31 | checkTarget = "check"; 32 | } 33 | -------------------------------------------------------------------------------- /nixos/overlays/p4c/default.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchFromGitHub, cmake, pkgconfig, python27, flex, bison, 2 | protobuf3_6, boost, gmp, doxygen, llvm, 3 | gmock, clang, libpcap, libelf, iproute, 4 | nettools, python27Packages, bmv2, thrift, boehmgc, 5 | pythonPackages }: 6 | 7 | stdenv.mkDerivation rec { 8 | name = "p4c-${version}"; 9 | version = "d4714270"; 10 | 11 | src = fetchFromGitHub { 12 | owner = "p4lang"; 13 | repo = "p4c"; 14 | rev = "d47142709a6c1f9ceb3f7a779cc5c220f0712f05"; 15 | fetchSubmodules = true; 16 | sha256 = "0a93lqld4l6dvb41f258zkqxrf241q165v1sw4h1433a0w14h7n3"; 17 | }; 18 | 19 | nativeBuildInputs = [ cmake ]; 20 | buildInputs = [ pkgconfig python27 flex bison protobuf3_6 boost gmp doxygen llvm gmock 21 | clang libpcap libelf iproute nettools iproute bmv2 thrift boehmgc ] 22 | ++ (with pythonPackages; [ ipaddr ply scapy ]); 23 | 24 | cmakeFlags = [ 25 | ]; 26 | 27 | preConfigure = '' 28 | cmakeFlagsArray=( 29 | $cmakeFlagsArray 30 | "-DCMAKE_INSTALL_PREFIX=$out" 31 | ) 32 | ''; 33 | 34 | doCheck = true; 35 | 36 | preCheck = '' 37 | patchShebangs . 38 | patchShebangs ../backends 39 | patchShebangs ../test 40 | patchShebangs ../tools 41 | _cwd=$(pwd) 42 | cd ../backends/ebpf/runtime 43 | echo "override CFLAGS += -fno-stack-protector" >kernel.mk.new 44 | cat kernel.mk >>kernel.mk.new 45 | mv kernel.mk.new kernel.mk 46 | cd $_cwd 47 | ''; 48 | } 49 | -------------------------------------------------------------------------------- /nixos/overlays/p4runtime/default.nix: -------------------------------------------------------------------------------- 1 | { stdenv, fetchFromGitHub, protobuf, which, git, grpc, writeText, bash }: 2 | 3 | stdenv.mkDerivation rec { 4 | name = "p4runtime-${version}"; 5 | version = "1.0.0"; 6 | 7 | src = fetchFromGitHub { 8 | owner = "p4lang"; 9 | repo = "p4runtime"; 10 | rev = "v${version}"; 11 | sha256 = "0vqmj17sgfjjppygw44vgl2limqj0rbfpfhhw6rwhc2w94xrac7i"; 12 | }; 13 | 14 | googleapis = fetchFromGitHub { 15 | owner = "googleapis"; 16 | repo = "googleapis"; 17 | rev = "common-protos-1_3_1"; 18 | sha256 = "1br13nv5higsad5509sp6nsgz2bgjdpi1l7bk579d2ngkbfn73sh"; 19 | }; 20 | 21 | patch = writeText "p4runtime-compile-patch" '' 22 | --- orig/CI/compile_protos.sh 1970-01-01 00:00:01.000000000 +0000 23 | +++ source/CI/compile_protos.sh 2019-08-21 12:32:27.741970829 +0000 24 | @@ -33,12 +33,6 @@ 25 | THIS_DIR=$(cd "$( dirname "$${BASH_SOURCE[0]}" )" && pwd) 26 | PROTO_DIR=$THIS_DIR/../proto 27 | 28 | -tmpdir=$(mktemp -d) 29 | -pushd $tmpdir > /dev/null 30 | -git clone --depth 1 https://github.com/googleapis/googleapis.git 31 | -popd > /dev/null 32 | -GOOGLE_PROTO_DIR=$tmpdir/googleapis 33 | - 34 | PROTOS="\ 35 | $PROTO_DIR/p4/v1/p4data.proto \ 36 | $PROTO_DIR/p4/v1/p4runtime.proto \ 37 | ''; 38 | 39 | buildInputs = [ protobuf which git googleapis grpc ]; 40 | 41 | patches = [ patch ]; 42 | 43 | phases = [ "unpackPhase" "patchPhase" "buildPhase" ]; 44 | 45 | GOOGLE_PROTO_DIR = "${googleapis}"; 46 | buildPhase = '' 47 | substituteInPlace CI/compile_protos.sh --replace '#!/usr/bin/env bash' ${bash}/bin/bash 48 | CI/compile_protos.sh $out 49 | mkdir $out/source 50 | cp -r ${src}/* $out/source 51 | ''; 52 | } 53 | -------------------------------------------------------------------------------- /resources/0000-topology-mono-cpu-port.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/resources/0000-topology-mono-cpu-port.png -------------------------------------------------------------------------------- /resources/0000-topology-vlan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/resources/0000-topology-vlan.png -------------------------------------------------------------------------------- /resources/0000-topology.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/resources/0000-topology.png -------------------------------------------------------------------------------- /resources/0100-mpls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/resources/0100-mpls.png -------------------------------------------------------------------------------- /resources/coming-soon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/resources/coming-soon.png -------------------------------------------------------------------------------- /resources/rare-partners.md: -------------------------------------------------------------------------------- 1 | # RARE project partners 2 | ![RARE project partners](https://github.com/frederic-loui/RARE/blob/master/resources/rare-partners.png) 3 | -------------------------------------------------------------------------------- /resources/rare-partners.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/resources/rare-partners.png -------------------------------------------------------------------------------- /utils/Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR = build 2 | PCAP_DIR = pcaps 3 | LOG_DIR = logs 4 | 5 | TOPO = topology.json 6 | P4C = p4c-bm2-ss 7 | RUN_SCRIPT = ../../utils/run_exercise.py 8 | 9 | source := $(wildcard *.p4) 10 | outfile := $(source:.p4=.json) 11 | 12 | compiled_json := $(BUILD_DIR)/$(outfile) 13 | 14 | # Define NO_P4 to start BMv2 without a program 15 | ifndef NO_P4 16 | run_args += -j $(compiled_json) 17 | endif 18 | 19 | # Set BMV2_SWITCH_EXE to override the BMv2 target 20 | ifdef BMV2_SWITCH_EXE 21 | run_args += -b $(BMV2_SWITCH_EXE) 22 | endif 23 | 24 | all: run 25 | 26 | run: build 27 | sudo python $(RUN_SCRIPT) -t $(TOPO) $(run_args) 28 | 29 | stop: 30 | sudo mn -c 31 | 32 | build: dirs $(compiled_json) 33 | 34 | $(BUILD_DIR)/%.json: %.p4 35 | $(P4C) --p4v 16 $(P4C_ARGS) -o $@ $< 36 | 37 | dirs: 38 | mkdir -p $(BUILD_DIR) $(PCAP_DIR) $(LOG_DIR) 39 | 40 | clean: stop 41 | rm -f *.pcap 42 | rm -rf $(BUILD_DIR) $(PCAP_DIR) $(LOG_DIR) 43 | 44 | -------------------------------------------------------------------------------- /utils/netstat.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017-present Open Networking Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | import psutil 17 | def check_listening_on_port(port): 18 | for c in psutil.net_connections(kind='inet'): 19 | if c.status == 'LISTEN' and c.laddr[1] == port: 20 | return True 21 | return False 22 | -------------------------------------------------------------------------------- /utils/p4runtime_lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rare-freertr/RARE-bmv2/36474e92a4e97e8aabf8f4f70a0adef469236269/utils/p4runtime_lib/__init__.py -------------------------------------------------------------------------------- /utils/p4runtime_lib/bmv2.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017-present Open Networking Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | from switch import SwitchConnection 16 | from p4.tmp import p4config_pb2 17 | 18 | 19 | def buildDeviceConfig(bmv2_json_file_path=None): 20 | "Builds the device config for BMv2" 21 | device_config = p4config_pb2.P4DeviceConfig() 22 | device_config.reassign = True 23 | with open(bmv2_json_file_path) as f: 24 | device_config.device_data = f.read() 25 | return device_config 26 | 27 | 28 | class Bmv2SwitchConnection(SwitchConnection): 29 | def buildDeviceConfig(self, **kwargs): 30 | return buildDeviceConfig(**kwargs) 31 | -------------------------------------------------------------------------------- /utils/pktgen/receiver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys, struct, os 3 | 4 | from scapy.all import sniff, sendp, hexdump, get_if_list, get_if_hwaddr 5 | from scapy.all import Packet, IPOption 6 | from scapy.all import ShortField, IntField, LongField, BitField, FieldListField, FieldLenField 7 | from scapy.all import IP, TCP, UDP, Raw 8 | 9 | from scapy.layers.inet import _IPOption_HDR 10 | 11 | def get_if(): 12 | iface=None 13 | for i in get_if_list(): 14 | if "eth0" in i: 15 | iface=i 16 | break; 17 | if not iface: 18 | print "Cannot find eth0 interface" 19 | exit(1) 20 | return iface 21 | 22 | def handle_pkt(pkt): 23 | pkt.show2() 24 | sys.stdout.flush() 25 | 26 | def main(): 27 | ifaces = filter(lambda i: 'eth' in i, os.listdir('/sys/class/net')) 28 | iface = ifaces[0] 29 | 30 | print "sniffing on %s" % iface 31 | 32 | sys.stdout.flush() 33 | 34 | sniff(iface=iface, prn=lambda x: handle_pkt(x)) 35 | 36 | if __name__ == '__main__': 37 | main() --------------------------------------------------------------------------------