├── config ├── onoscfg-meter.json ├── netcfg-dbuf.json ├── pfcp-agent.json ├── netcfg-up4.json └── netcfg-leafspine.json ├── img ├── redundancy.png ├── topo-leafspine.png └── exercise-1-wireshark.png ├── .gitignore ├── util ├── pfcpctl ├── mn-cmd ├── onos-cmd ├── mn-pcap └── p4rt-sh ├── .reuse └── dep5 ├── EXERCISE-2.md ├── mininet ├── entrypoint.sh ├── Dockerfile ├── send-udp.py ├── host-cmd ├── recv-gtp.py ├── topo-leafspine.py └── mn_lib.py ├── .github └── workflows │ └── reuse.yml ├── .env ├── docker-compose.yml ├── Makefile ├── README.md ├── solution └── mininet │ └── netcfg-leafspine.json ├── LICENSES └── Apache-2.0.txt └── EXERCISE-1.md /config/onoscfg-meter.json: -------------------------------------------------------------------------------- 1 | {"userDefinedIndex":"true"} 2 | -------------------------------------------------------------------------------- /img/redundancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opennetworkinglab/sdfabric-tutorial/HEAD/img/redundancy.png -------------------------------------------------------------------------------- /img/topo-leafspine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opennetworkinglab/sdfabric-tutorial/HEAD/img/topo-leafspine.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | .idea 5 | -------------------------------------------------------------------------------- /img/exercise-1-wireshark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opennetworkinglab/sdfabric-tutorial/HEAD/img/exercise-1-wireshark.png -------------------------------------------------------------------------------- /util/pfcpctl: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | docker exec smf-sim pfcpctl $@ 6 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | 3 | Files: *.json img/*.png 4 | Copyright: 2022-present Intel Corporation 5 | License: Apache-2.0 -------------------------------------------------------------------------------- /EXERCISE-2.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Exercise 2: P4-UPF 7 | 8 | This exercise is still work in progress. -------------------------------------------------------------------------------- /mininet/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | mv /usr/sbin/tcpdump /usr/bin/tcpdump 6 | 7 | python "${MN_SCRIPT}" 8 | -------------------------------------------------------------------------------- /config/netcfg-dbuf.json: -------------------------------------------------------------------------------- 1 | { 2 | "apps": { 3 | "org.omecproject.up4": { 4 | "dbuf": { 5 | "serviceAddr": "mininet:10000", 6 | "dataplaneAddr": "140.0.99.1:2152" 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /util/mn-cmd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | if [ -z $1 ]; then 6 | echo "usage: $0 host cmd [args...]" 7 | exit 1 8 | fi 9 | 10 | docker exec -it mininet /mininet/host-cmd $@ 11 | -------------------------------------------------------------------------------- /config/pfcp-agent.json: -------------------------------------------------------------------------------- 1 | { 2 | "enable_p4rt": true, 3 | "log_level": "info", 4 | "cpiface": { 5 | "ue_ip_pool": "192.168.0.0/16" 6 | }, 7 | "p4rtciface": { 8 | "p4rtc_server": "onos1", 9 | "p4rtc_port": "51001", 10 | "access_ip": "172.16.1.254/32", 11 | "slice_id": 0, 12 | "default_tc": 0 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.github/workflows/reuse.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2022-present Open Networking Foundation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | --- 5 | name: REUSE 6 | 7 | on: 8 | push: 9 | branches: [main] 10 | pull_request: 11 | branches: [main] 12 | 13 | jobs: 14 | license-check: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: reuse lint 19 | uses: fsfe/reuse-action@v1 20 | -------------------------------------------------------------------------------- /util/onos-cmd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | if [ -z $1 ]; then 6 | echo "usage: $0 cmd [args...]" 7 | exit 1 8 | fi 9 | 10 | # Use sshpass to skip the password prompt 11 | docker run -it --rm --network host ictu/sshpass \ 12 | -procks ssh -o "UserKnownHostsFile=/dev/null" \ 13 | -o "StrictHostKeyChecking=no" -o LogLevel=ERROR -p 8101 onos@localhost "$@" 14 | -------------------------------------------------------------------------------- /mininet/Dockerfile: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # Regular mn-stratum with dbuf binary and scapy. 5 | 6 | ARG DBUF_IMAGE 7 | ARG MN_STRATUM_IMAGE 8 | 9 | FROM $DBUF_IMAGE as dbuf 10 | RUN mkdir /output 11 | RUN cp $(which dbuf) /output/dbuf 12 | 13 | FROM $MN_STRATUM_IMAGE 14 | COPY --from=dbuf /output/dbuf /usr/local/bin 15 | 16 | RUN install_packages python3 python3-pip python3-setuptools 17 | RUN pip3 install wheel 18 | RUN pip3 install scapy==2.4.4 19 | 20 | ENV PATH=/up4/bin:${PATH} -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # Docker images for SD-Fabric v1.1.1 5 | PFCP_AGENT_IMAGE=omecproject/upf-epc-pfcpiface:master-2f04e3a 6 | ONOS_IMAGE=opennetworking/sdfabric-onos:master-2022-05-13 7 | PFCPSIM_IMAGE=opennetworking/pfcpsim:64474e9 8 | DBUF_IMAGE=opennetworking/dbuf:1.0.0 9 | MN_STRATUM_IMAGE=opennetworking/mn-stratum:latest@sha256:5f53ea1c5784ca89753e7a23ae64d52fe39371f9e0ac218883bc28864c37e373 10 | 11 | # Other env variables 12 | ONOS_APPS=gui2,drivers.bmv2,lldpprovider,hostprovider,org.stratumproject.fabric-tna,segmentrouting,netcfghostprovider,org.omecproject.up4 13 | JAVA_DEBUG_PORT=0.0.0.0:5005 14 | -------------------------------------------------------------------------------- /util/mn-pcap: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 6 | 7 | if [ -z $1 ]; then 8 | echo "usage: $0 host" 9 | exit 1 10 | fi 11 | 12 | iface=$1-eth0 13 | file=${iface}.pcap 14 | 15 | set -e 16 | 17 | echo "*** Starting tcpdump on ${iface}... Ctrl-c to stop capture" 18 | echo "*** Pcap file will be written in ./tmp/${file}" 19 | docker exec -it mininet /mininet/host-cmd $1 tcpdump -i $1-eth0 -w /tmp/"${file}" 20 | 21 | if [ -x "$(command -v wireshark)" ]; then 22 | echo "*** Opening wireshark... Ctrl-c to quit" 23 | wireshark "${DIR}/../tmp/${file}" 24 | fi 25 | -------------------------------------------------------------------------------- /config/netcfg-up4.json: -------------------------------------------------------------------------------- 1 | { 2 | "ports": { 3 | "device:leaf1/7": { 4 | "interfaces": [ 5 | { 6 | "name": "leaf1-7-gnb", 7 | "ips": [ 8 | "172.16.1.254/24" 9 | ], 10 | "vlan-untagged": 100 11 | } 12 | ] 13 | } 14 | }, 15 | "hosts": { 16 | "00:00:00:00:00:99/None": { 17 | "basic": { 18 | "name": "gNodeB", 19 | "locType": "grid", 20 | "gridX": 250, 21 | "gridY": 600 22 | } 23 | } 24 | }, 25 | "apps": { 26 | "org.omecproject.up4": { 27 | "up4": { 28 | "devices": [ 29 | "device:leaf1", 30 | "device:leaf2" 31 | ], 32 | "pscEncapEnabled": true 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /mininet/send-udp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # Script used in Exercise 8. 6 | # Send downlink packets to UE address. 7 | import argparse 8 | 9 | from scapy.layers.inet import IP, UDP 10 | from scapy.sendrecv import send 11 | 12 | RATE = 5 # packets per second 13 | PAYLOAD = ' '.join(['P4 is great!'] * 50) 14 | 15 | parser = argparse.ArgumentParser(description='Send UDP packets to the given IPv4 address') 16 | parser.add_argument('ipv4_dst', type=str, help="Destination IPv4 address") 17 | args = parser.parse_args() 18 | 19 | print("Sending %d UDP packets per second to %s..." % (RATE, args.ipv4_dst)) 20 | 21 | pkt = IP(dst=args.ipv4_dst) / UDP(sport=80, dport=400) / PAYLOAD 22 | send(pkt, inter=1.0 / RATE, loop=True, verbose=True) 23 | -------------------------------------------------------------------------------- /mininet/host-cmd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # Attach to a Mininet host and run a command 6 | 7 | if [ -z $1 ]; then 8 | echo "usage: $0 host cmd [args...]" 9 | exit 1 10 | else 11 | host=$1 12 | fi 13 | 14 | pid=`ps ax | grep "mininet:$host$" | grep bash | grep -v mnexec | awk '{print $1};'` 15 | 16 | if echo $pid | grep -q ' '; then 17 | echo "Error: found multiple mininet:$host processes" 18 | exit 2 19 | fi 20 | 21 | if [ "$pid" == "" ]; then 22 | echo "Could not find Mininet host $host" 23 | exit 3 24 | fi 25 | 26 | if [ -z $2 ]; then 27 | cmd='bash' 28 | else 29 | shift 30 | cmd=$* 31 | fi 32 | 33 | cgroup=/sys/fs/cgroup/cpu/$host 34 | if [ -d "$cgroup" ]; then 35 | cg="-g $host" 36 | fi 37 | 38 | # Check whether host should be running in a chroot dir 39 | rootdir="/var/run/mn/$host/root" 40 | if [ -d $rootdir -a -x $rootdir/bin/bash ]; then 41 | cmd="'cd `pwd`; exec $cmd'" 42 | cmd="chroot $rootdir /bin/bash -c $cmd" 43 | fi 44 | 45 | mnexec $cg -a $pid hostname $host 46 | cmd="exec mnexec $cg -a $pid $cmd" 47 | eval $cmd -------------------------------------------------------------------------------- /mininet/recv-gtp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | # Script used in Exercise 3 that sniffs packets and prints on screen whether 6 | # they are GTP encapsulated or not. 7 | 8 | import signal 9 | import sys 10 | 11 | from scapy.layers.inet import IP 12 | from scapy.contrib import gtp 13 | from scapy.sendrecv import sniff 14 | 15 | pkt_count = 0 16 | 17 | 18 | def handle_pkt(pkt, ex): 19 | global pkt_count 20 | pkt_count = pkt_count + 1 21 | if gtp.GTP_U_Header in pkt: 22 | is_gtp_encap = True 23 | else: 24 | is_gtp_encap = False 25 | 26 | print("[%d] %d bytes: %s -> %s, is_gtp_encap=%s\n\t%s" % ( 27 | pkt_count, len(pkt), pkt[IP].src, pkt[IP].dst, 28 | is_gtp_encap, pkt.summary())) 29 | 30 | if is_gtp_encap and ex: 31 | exit() 32 | 33 | 34 | print("Will print a line for each UDP packet received...") 35 | 36 | 37 | def handle_timeout(signum, frame): 38 | print("Timeout! Did not receive any GTP packet") 39 | exit(1) 40 | 41 | 42 | exitOnSuccess = False 43 | if len(sys.argv) > 1 and sys.argv[1] == "-e": 44 | # wait max 10 seconds or exit 45 | signal.signal(signal.SIGALRM, handle_timeout) 46 | signal.alarm(10) 47 | exitOnSuccess = True 48 | 49 | sniff(count=0, store=False, filter="udp", 50 | prn=lambda x: handle_pkt(x, exitOnSuccess)) 51 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | services: 6 | mininet: 7 | build: 8 | context: mininet 9 | args: 10 | - DBUF_IMAGE=${DBUF_IMAGE} 11 | - MN_STRATUM_IMAGE=${MN_STRATUM_IMAGE} 12 | platform: linux/amd64 13 | hostname: mininet 14 | container_name: mininet 15 | privileged: true 16 | tty: true 17 | stdin_open: true 18 | entrypoint: "/mininet/entrypoint.sh" 19 | volumes: 20 | - ./tmp:/tmp 21 | - ./topo:/topo 22 | - ./bin:/up4/bin 23 | - ./tmp/pcaps:/pcaps 24 | - ./mininet:/mininet 25 | expose: 26 | - 50001 # leaf1 27 | - 50002 # leaf2 28 | - 50003 # spine1 29 | - 50004 # spine2 30 | environment: 31 | - MN_SCRIPT=/mininet/topo-${TOPO}.py 32 | onos1: 33 | # Tost image comes with latest trellis apps 34 | image: ${ONOS_IMAGE} 35 | platform: linux/amd64 36 | hostname: onos1 37 | container_name: onos1 38 | ports: 39 | - "8181:8181" # HTTP 40 | - "8101:8101" # SSH (CLI) 41 | - "51001:51001" # UP4 app's P4Runtime server 42 | - "5005:5005" # Java debugger 43 | volumes: 44 | - ./tmp/onos1:/root/onos/apache-karaf-4.2.14/data/tmp 45 | env_file: 46 | - .env # Includes ONOS_APPS 47 | entrypoint: "./bin/onos-service" 48 | command: [ "debug" ] 49 | 50 | # P4-UPF services 51 | pfcp-agent: 52 | profiles: 53 | - upf 54 | image: ${PFCP_AGENT_IMAGE} 55 | platform: linux/amd64 56 | hostname: pfcp-agent 57 | container_name: pfcp-agent 58 | tty: true 59 | stdin_open: true 60 | volumes: 61 | - ./tmp:/tmp 62 | - ./config/pfcp-agent.json:/config.json 63 | entrypoint: "/bin/pfcpiface" 64 | command: [ "-config", "/config.json" ] 65 | working_dir: /bin/ 66 | expose: 67 | - 8805 # PFCP 68 | ports: 69 | - "8080:8080" # HTTP: REST API for slice meter configuration 70 | smf-sim: 71 | profiles: 72 | - upf 73 | image: ${PFCPSIM_IMAGE} 74 | platform: linux/amd64 75 | hostname: smf-sim 76 | container_name: smf-sim 77 | tty: true 78 | volumes: 79 | - ./tmp:/tmp 80 | - ./topo:/topo 81 | - ./bin:/up4/bin 82 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) 5 | CURRENT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) 6 | 7 | # TODO: add other topos 8 | # oneswitch, leafpair, leafspine 9 | export TOPO ?= leafspine 10 | 11 | 12 | ONOS_URL := http://localhost:8181/onos 13 | ONOS_CURL := curl --fail -sSL --user onos:rocks --noproxy localhost 14 | 15 | .PHONY: $(SCENARIOS) 16 | 17 | start: ./tmp 18 | $(info *** Starting ONOS and mininet...) 19 | docker compose up -d 20 | 21 | start-upf: ./tmp 22 | $(info *** Starting UPF containers...) 23 | docker compose --profile upf up -d 24 | 25 | stop: 26 | $(info *** Stopping all containers...) 27 | docker compose down -t0 --remove-orphans 28 | 29 | restart: reset start 30 | 31 | mn-cli: 32 | $(info *** Attaching to Mininet CLI...) 33 | $(info *** To detach press Ctrl-D (Mininet will keep running)) 34 | -@docker attach --detach-keys "ctrl-d" mininet || echo "*** Detached from Mininet CLI" 35 | 36 | mn-log: 37 | docker logs -f mininet 38 | 39 | onos-cli: 40 | ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -o LogLevel=ERROR -p 8101 onos@localhost 41 | 42 | onos-log: 43 | docker compose logs -f onos1 44 | 45 | onos-ui: 46 | open http://localhost:8181/onos/ui 47 | 48 | pfcp-log: 49 | docker compose logs -f pfcp-agent 50 | 51 | netcfg: NETCFG_JSON := ./config/netcfg-${TOPO}.json 52 | netcfg: _netcfg 53 | 54 | netcfg-up4: NETCFG_JSON := ./config/netcfg-up4.json 55 | netcfg-up4: _netcfg 56 | 57 | _netcfg: 58 | $(info *** Pushing ${NETCFG_JSON} to ONOS...) 59 | ${ONOS_CURL} -X POST -H 'Content-Type:application/json' \ 60 | ${ONOS_URL}/v1/network/configuration -d@${NETCFG_JSON} 61 | @echo 62 | 63 | # Create ./tmp before Docker does so it doesn't have root owner. 64 | ./tmp: 65 | @mkdir -p ./tmp 66 | 67 | deps: pull build 68 | 69 | pull: 70 | docker compose pull 71 | 72 | build: 73 | docker compose build --pull 74 | 75 | reset: 76 | -docker compose down -t0 --remove-orphans 77 | # -make fix-permissions 78 | # TODO: make it work without sudo 79 | -sudo rm -rf ./tmp 80 | 81 | smf-sim: 82 | docker compose exec smf-sim /up4/bin/smf-sim.py pfcp-agent \ 83 | --pcap-file /tmp/smf-sim.pcap -vvv 84 | 85 | up4-p4rt-sh: 86 | docker compose exec p4rt \ 87 | python3 -m p4runtime_sh \ 88 | --grpc-addr onos1:51001 \ 89 | --device-id 1 --election-id 0,1 90 | -------------------------------------------------------------------------------- /mininet/topo-leafspine.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | import argparse 7 | 8 | from mininet.cli import CLI 9 | from mininet.log import setLogLevel 10 | from mininet.net import Mininet 11 | from mininet.topo import Topo 12 | from stratum import StratumBmv2Switch 13 | 14 | from mn_lib import IPv4Host 15 | from mn_lib import TaggedIPv4Host 16 | 17 | CPU_PORT = 255 18 | 19 | 20 | class TutorialTopo(Topo): 21 | """2x2 fabric topology with IPv4 hosts""" 22 | 23 | def __init__(self, *args, **kwargs): 24 | Topo.__init__(self, *args, **kwargs) 25 | 26 | # Leaves 27 | # gRPC port 50001 28 | leaf1 = self.addSwitch('leaf1', cls=StratumBmv2Switch, cpuport=CPU_PORT) 29 | # gRPC port 50002 30 | leaf2 = self.addSwitch('leaf2', cls=StratumBmv2Switch, cpuport=CPU_PORT) 31 | 32 | # Spines 33 | # gRPC port 50003 34 | spine1 = self.addSwitch('spine1', cls=StratumBmv2Switch, cpuport=CPU_PORT) 35 | # gRPC port 50004 36 | spine2 = self.addSwitch('spine2', cls=StratumBmv2Switch, cpuport=CPU_PORT) 37 | 38 | # Switch Links 39 | self.addLink(spine1, leaf1) 40 | self.addLink(spine1, leaf2) 41 | self.addLink(spine2, leaf1) 42 | self.addLink(spine2, leaf2) 43 | 44 | # IPv4 hosts attached to leaf 1 45 | h1a = self.addHost('h1a', cls=IPv4Host, mac="00:00:00:00:00:1A", 46 | ip='172.16.1.1/24', gw='172.16.1.254') 47 | h1b = self.addHost('h1b', cls=IPv4Host, mac="00:00:00:00:00:1B", 48 | ip='172.16.1.2/24', gw='172.16.1.254') 49 | h1c = self.addHost('h1c', cls=TaggedIPv4Host, mac="00:00:00:00:00:1C", 50 | ip='172.16.1.3/24', gw='172.16.1.254', vlan=100) 51 | h2 = self.addHost('h2', cls=TaggedIPv4Host, mac="00:00:00:00:00:20", 52 | ip='172.16.2.1/24', gw='172.16.2.254', vlan=200) 53 | self.addLink(h1a, leaf1) # port 3 54 | self.addLink(h1b, leaf1) # port 4 55 | self.addLink(h1c, leaf1) # port 5 56 | self.addLink(h2, leaf1) # port 6 57 | 58 | # IPv4 hosts attached to leaf 2 59 | h3 = self.addHost('h3', cls=TaggedIPv4Host, mac="00:00:00:00:00:30", 60 | ip='172.16.3.1/24', gw='172.16.3.254', vlan=300) 61 | h4 = self.addHost('h4', cls=IPv4Host, mac="00:00:00:00:00:40", 62 | ip='172.16.4.1/24', gw='172.16.4.254') 63 | self.addLink(h3, leaf2) # port 3 64 | self.addLink(h4, leaf2) # port 4 65 | 66 | # Emulated gNodeB (5G base station) attached to leaf 1 67 | gnb = self.addHost('gnb', cls=IPv4Host, mac='00:00:00:00:99:00', 68 | ip='172.16.1.99/24', gw='172.16.1.254') 69 | self.addLink(gnb, leaf1) # port 7 70 | 71 | 72 | def main(): 73 | net = Mininet(topo=TutorialTopo(), controller=None) 74 | net.start() 75 | CLI(net) 76 | net.stop() 77 | print '#' * 80 78 | print 'ATTENTION: Mininet was stopped! Perhaps accidentally?' 79 | print 'No worries, it will restart automatically in a few seconds...' 80 | print 'To access again the Mininet CLI, use `make mn-cli`' 81 | print 'To detach from the CLI (without stopping), press Ctrl-D' 82 | print 'To permanently quit Mininet, use `make stop`' 83 | print '#' * 80 84 | 85 | 86 | if __name__ == "__main__": 87 | parser = argparse.ArgumentParser( 88 | description='Mininet topology script for 2x2 fabric with stratum_bmv2 and IPv4 hosts') 89 | args = parser.parse_args() 90 | setLogLevel('info') 91 | 92 | main() 93 | -------------------------------------------------------------------------------- /util/p4rt-sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | """ 6 | P4Runtime shell docker wrapper 7 | From: https://github.com/p4lang/p4runtime-shell/blob/master/p4runtime-sh-docker 8 | """ 9 | 10 | import argparse 11 | from collections import namedtuple 12 | import logging 13 | import os.path 14 | import sys 15 | import tempfile 16 | import shutil 17 | import subprocess 18 | 19 | DOCKER_IMAGE = 'p4lang/p4runtime-sh:latest@sha256:33310ea54685570eb5a700d2136431a44d75c8aec6b61fe8e15ab76824160cc2' 20 | TMP_DIR = os.path.dirname(os.path.abspath(__file__)) + '/.pipe_cfg' 21 | 22 | 23 | def main(): 24 | FwdPipeConfig = namedtuple('FwdPipeConfig', ['p4info', 'bin']) 25 | 26 | def pipe_config(arg): 27 | try: 28 | paths = FwdPipeConfig(*[x for x in arg.split(',')]) 29 | if len(paths) != 2: 30 | raise argparse.ArgumentError 31 | return paths 32 | except Exception: 33 | raise argparse.ArgumentError( 34 | "Invalid pipeline config, expected ,") 35 | 36 | parser = argparse.ArgumentParser(description='P4Runtime shell docker wrapper', add_help=False) 37 | parser.add_argument('--grpc-addr', 38 | help='P4Runtime gRPC server address', 39 | metavar=':', 40 | type=str, action='store', default="localhost:51001") 41 | parser.add_argument('--config', 42 | help='If you want the shell to push a pipeline config to the server first', 43 | metavar=',', 44 | type=pipe_config, action='store', default=None) 45 | parser.add_argument('-v', '--verbose', help='Increase output verbosity', 46 | action='store_true') 47 | args, unknown_args = parser.parse_known_args() 48 | 49 | docker_args = [] 50 | new_args = [] 51 | 52 | if args.verbose: 53 | logging.basicConfig(level=logging.DEBUG) 54 | new_args.append('--verbose') 55 | 56 | if args.grpc_addr is not None: 57 | print("*** Connecting to P4Runtime server at {} ...".format(args.grpc_addr)) 58 | new_args.extend(["--grpc-addr", args.grpc_addr]) 59 | 60 | if args.config is not None: 61 | if not os.path.isfile(args.config.p4info): 62 | logging.critical("'{}' is not a valid file".format(args.config.p4info)) 63 | sys.exit(1) 64 | if not os.path.isfile(args.config.bin): 65 | logging.critical("'{}' is not a valid file".format(args.config.bin)) 66 | sys.exit(1) 67 | 68 | mount_path = "/fwd_pipe_config" 69 | fname_p4info = "p4info.pb.txt" 70 | fname_bin = "config.bin" 71 | 72 | os.mkdir(TMP_DIR) 73 | logging.debug( 74 | "Created temporary directory '{}', it will be mounted in the docker as '{}'".format( 75 | TMP_DIR, mount_path)) 76 | shutil.copy(args.config.p4info, os.path.join(TMP_DIR, fname_p4info)) 77 | shutil.copy(args.config.bin, os.path.join(TMP_DIR, fname_bin)) 78 | 79 | docker_args.extend(["-v", "{}:{}".format(TMP_DIR, mount_path)]) 80 | new_args.extend(["--config", "{},{}".format( 81 | os.path.join(mount_path, fname_p4info), os.path.join(mount_path, fname_bin))]) 82 | 83 | cmd = ["docker", "run", "-ti", "--network", "host"] 84 | cmd.extend(docker_args) 85 | cmd.append(DOCKER_IMAGE) 86 | cmd.extend(new_args) 87 | cmd.extend(unknown_args) 88 | logging.debug("Running cmd: {}".format(" ".join(cmd))) 89 | 90 | subprocess.run(cmd) 91 | 92 | if args.config is not None: 93 | logging.debug("Cleaning up...") 94 | try: 95 | shutil.rmtree(TMP_DIR) 96 | except Exception: 97 | logging.error("Error when removing temporary directory '{}'".format(TMP_DIR)) 98 | 99 | 100 | if __name__ == '__main__': 101 | main() 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # SD-Fabric Tutorial 7 | 8 | Welcome to the SD-Fabric tutorial! 9 | 10 | SD-Fabric is an open source programmable network fabric tailored for 11 | 5G-connected edge clouds, with a focus on enterprise and Industry 4.0 use cases. 12 | 13 | This repository contains instructions to learn how to use and develop SD-Fabric. 14 | Before starting, we suggest familiarizing with the SD-Fabric architecture and 15 | features using the official SD-Fabric documentation website at 16 | . 17 | 18 | In this tutorial, we provide scripts to easily bring up an SD-Fabric environment 19 | in a laptop (or server), including ONOS, emulated Stratum switches, and other 20 | SD-Fabric components. We also provide hands-on exercises that show how to set up 21 | SD-Fabric, use advanced features like the 5G P4-UPF, In-band Network Telemetry, 22 | and more. 23 | 24 | ## System requirements 25 | 26 | All exercises can be executed by installing the following dependencies: 27 | 28 | * Docker v1.13.0+ (with docker-compose) 29 | * make 30 | * Python 3 31 | * Bash-like Unix shell 32 | * Wireshark (optional) 33 | 34 | We recommend running the exercises on a machine with at least 4 GB of RAM and 4 35 | core CPU. For a smooth experience, we recommend running on a system that has at 36 | least the double of resources. 37 | 38 | **Note for macOS users**: if you are using Docker Desktop for Mac, make sure to 39 | adjust the CPU and memory assignments for your Docker VM. 40 | We don't support M1 Mac yet since there is a known connectivity issue. 41 | 42 | **Note for Windows users**: all scripts have been tested on macOS and Ubuntu. 43 | Although we think they should work on Windows, we have not tested it. 44 | 45 | ## Get this repo and download dependencies 46 | 47 | To work on the exercises you will need to clone this repo and download dependencies: 48 | 49 | git clone https://github.com/opennetworkinglab/sdfabric-tutorial 50 | cd sdfabric-tutorial 51 | make deps 52 | 53 | The last command will download all necessary Docker images allowing you to work 54 | off-line. If you are doing this tutorial at an event, we recommend running this 55 | step ahead of the tutorial, with a reliable Internet connection. 56 | 57 | ## Repo structure 58 | 59 | This repo is structured as follows: 60 | 61 | - `config/` Configuration files for various sub-components 62 | - `mininet/` Mininet script to emulate a 2x2 leaf-spine fabric topology of 63 | `stratum_bmv2` devices 64 | - `solution/` Solutions for the exercises 65 | - `util/` Utility scripts 66 | 67 | ## Tutorial commands 68 | 69 | To facilitate working on the exercises, we provide a set of make-based commands 70 | to control the different aspects of the tutorial. Commands will be introduced in 71 | the exercises, here's a quick reference: 72 | 73 | | Make command | Description | 74 | |------------------|---------------------------------------------------------| 75 | | `make deps` | Pull and build all required dependencies | 76 | | `make start` | Start Mininet and ONOS containers | 77 | | `make start-upf` | Start PFCP Agent and other UPF containers | 78 | | `make stop` | Stop all containers | 79 | | `make restart` | Restart containers clearing any previous state | 80 | | `make reset` | Reset the tutorial environment | 81 | | `make onos-cli` | Access the ONOS CLI (password: `rocks`, Ctrl-D to exit) | 82 | | `make onos-log` | Show the ONOS log | 83 | | `make mn-cli` | Access the Mininet CLI (Ctrl-D to exit) | 84 | | `make mn-log` | Show the Mininet log (i.e., the CLI output) | 85 | | `make mn-pcap` | Dump packet on a particular Mininet host | 86 | | `make netcfg` | Push netcfg.json file (network config) to ONOS | 87 | 88 | ## Exercises 89 | 90 | Click on the exercise name to see the instructions: 91 | 92 | 1. [Basic configuration](./EXERCISE-1.md) 93 | 2. [P4-UPF](./EXERCISE-2.md) 94 | 95 | We plan to add more exercises in the future. Make sure to watch this repo to be 96 | informed of any update. Planned additions: 97 | 98 | * In-band Network Telemetry (INT) 99 | * Extending SD-Fabric 100 | * Slicing & QoS 101 | * Advanced Connectivity 102 | 103 | ## Solutions 104 | 105 | You can find solutions for each exercise in the [solution](solution) directory. 106 | Feel free to compare your solution to the reference one whenever you feel stuck. 107 | -------------------------------------------------------------------------------- /config/netcfg-leafspine.json: -------------------------------------------------------------------------------- 1 | { 2 | "devices": { 3 | "device:leaf1": { 4 | "basic": { 5 | "name": "leaf1", 6 | "managementAddress": "grpc://mininet:50001?device_id=1", 7 | "driver": "stratum-bmv2", 8 | "pipeconf": "org.stratumproject.fabric-upf.bmv2", 9 | "locType": "grid", 10 | "gridX": 200, 11 | "gridY": 600 12 | }, 13 | "segmentrouting": { 14 | "ipv4NodeSid": 101, 15 | "ipv4Loopback": "192.168.1.1", 16 | "routerMac": "00:AA:00:00:00:01", 17 | "isEdgeRouter": true, 18 | "adjacencySids": [] 19 | } 20 | }, 21 | "device:leaf2": { 22 | "basic": { 23 | "name": "leaf2", 24 | "managementAddress": "grpc://mininet:50002?device_id=1", 25 | "driver": "stratum-bmv2", 26 | "pipeconf": "org.stratumproject.fabric-upf.bmv2", 27 | "locType": "grid", 28 | "gridX": 800, 29 | "gridY": 600 30 | }, 31 | "segmentrouting": { 32 | "ipv4NodeSid": 102, 33 | "ipv4Loopback": "192.168.1.2", 34 | "routerMac": "00:AA:00:00:00:02", 35 | "isEdgeRouter": true, 36 | "adjacencySids": [] 37 | } 38 | }, 39 | "device:spine1": { 40 | "basic": { 41 | "name": "spine1", 42 | "managementAddress": "grpc://mininet:50003?device_id=1", 43 | "driver": "stratum-bmv2", 44 | "pipeconf": "org.stratumproject.fabric.bmv2", 45 | "locType": "grid", 46 | "gridX": 400, 47 | "gridY": 400 48 | }, 49 | "segmentrouting": { 50 | "ipv4NodeSid": 201, 51 | "ipv4Loopback": "192.168.2.1", 52 | "routerMac": "00:BB:00:00:00:01", 53 | "isEdgeRouter": false, 54 | "adjacencySids": [] 55 | } 56 | }, 57 | "device:spine2": { 58 | "basic": { 59 | "name": "spine2", 60 | "managementAddress": "grpc://mininet:50004?device_id=1", 61 | "driver": "stratum-bmv2", 62 | "pipeconf": "org.stratumproject.fabric.bmv2", 63 | "locType": "grid", 64 | "gridX": 600, 65 | "gridY": 400 66 | }, 67 | "segmentrouting": { 68 | "ipv4NodeSid": 202, 69 | "ipv4Loopback": "192.168.2.2", 70 | "routerMac": "00:BB:00:00:00:02", 71 | "isEdgeRouter": false, 72 | "adjacencySids": [] 73 | } 74 | } 75 | }, 76 | "ports": { 77 | "device:leaf1/3": { 78 | "interfaces": [ 79 | { 80 | "name": "leaf1-3", 81 | "ips": [ 82 | "172.16.1.254/24" 83 | ], 84 | "vlan-untagged": 100 85 | } 86 | ] 87 | }, 88 | "device:leaf1/4": { 89 | "interfaces": [ 90 | { 91 | "name": "leaf1-4", 92 | "ips": [ 93 | "172.16.1.254/24" 94 | ], 95 | "vlan-untagged": 100 96 | } 97 | ] 98 | }, 99 | "device:leaf1/5": { 100 | "interfaces": [ 101 | { 102 | "name": "leaf1-5", 103 | "ips": [ 104 | "172.16.1.254/24" 105 | ], 106 | "vlan-tagged": [ 107 | 100 108 | ] 109 | } 110 | ] 111 | }, 112 | "device:leaf1/6": { 113 | "interfaces": [ 114 | { 115 | "name": "leaf1-6", 116 | "ips": [ 117 | "172.16.2.254/24" 118 | ], 119 | "vlan-tagged": [ 120 | 200 121 | ] 122 | } 123 | ] 124 | } 125 | }, 126 | "hosts": { 127 | "00:00:00:00:00:1A/None": { 128 | "basic": { 129 | "name": "h1a", 130 | "locType": "grid", 131 | "gridX": 100, 132 | "gridY": 700 133 | } 134 | }, 135 | "00:00:00:00:00:1B/None": { 136 | "basic": { 137 | "name": "h1b", 138 | "locType": "grid", 139 | "gridX": 100, 140 | "gridY": 800 141 | } 142 | }, 143 | "00:00:00:00:00:1C/100": { 144 | "basic": { 145 | "name": "h1c", 146 | "locType": "grid", 147 | "gridX": 250, 148 | "gridY": 800 149 | } 150 | }, 151 | "00:00:00:00:00:20/200": { 152 | "basic": { 153 | "name": "h2", 154 | "locType": "grid", 155 | "gridX": 400, 156 | "gridY": 700 157 | } 158 | }, 159 | "00:00:00:00:00:30/300": { 160 | "basic": { 161 | "name": "h3", 162 | "locType": "grid", 163 | "gridX": 750, 164 | "gridY": 700 165 | } 166 | }, 167 | "00:00:00:00:00:40/None": { 168 | "basic": { 169 | "name": "h4", 170 | "locType": "grid", 171 | "gridX": 850, 172 | "gridY": 700 173 | } 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /solution/mininet/netcfg-leafspine.json: -------------------------------------------------------------------------------- 1 | { 2 | "devices": { 3 | "device:leaf1": { 4 | "basic": { 5 | "name": "leaf1", 6 | "managementAddress": "grpc://mininet:50001?device_id=1", 7 | "driver": "stratum-bmv2", 8 | "pipeconf": "org.stratumproject.fabric-upf.bmv2", 9 | "locType": "grid", 10 | "gridX": 200, 11 | "gridY": 600 12 | }, 13 | "segmentrouting": { 14 | "ipv4NodeSid": 101, 15 | "ipv4Loopback": "192.168.1.1", 16 | "routerMac": "00:AA:00:00:00:01", 17 | "isEdgeRouter": true, 18 | "adjacencySids": [] 19 | } 20 | }, 21 | "device:leaf2": { 22 | "basic": { 23 | "name": "leaf2", 24 | "managementAddress": "grpc://mininet:50002?device_id=1", 25 | "driver": "stratum-bmv2", 26 | "pipeconf": "org.stratumproject.fabric-upf.bmv2", 27 | "locType": "grid", 28 | "gridX": 800, 29 | "gridY": 600 30 | }, 31 | "segmentrouting": { 32 | "ipv4NodeSid": 102, 33 | "ipv4Loopback": "192.168.1.2", 34 | "routerMac": "00:AA:00:00:00:02", 35 | "isEdgeRouter": true, 36 | "adjacencySids": [] 37 | } 38 | }, 39 | "device:spine1": { 40 | "basic": { 41 | "name": "spine1", 42 | "managementAddress": "grpc://mininet:50003?device_id=1", 43 | "driver": "stratum-bmv2", 44 | "pipeconf": "org.stratumproject.fabric.bmv2", 45 | "locType": "grid", 46 | "gridX": 400, 47 | "gridY": 400 48 | }, 49 | "segmentrouting": { 50 | "ipv4NodeSid": 201, 51 | "ipv4Loopback": "192.168.2.1", 52 | "routerMac": "00:BB:00:00:00:01", 53 | "isEdgeRouter": false, 54 | "adjacencySids": [] 55 | } 56 | }, 57 | "device:spine2": { 58 | "basic": { 59 | "name": "spine2", 60 | "managementAddress": "grpc://mininet:50004?device_id=1", 61 | "driver": "stratum-bmv2", 62 | "pipeconf": "org.stratumproject.fabric.bmv2", 63 | "locType": "grid", 64 | "gridX": 600, 65 | "gridY": 400 66 | }, 67 | "segmentrouting": { 68 | "ipv4NodeSid": 202, 69 | "ipv4Loopback": "192.168.2.2", 70 | "routerMac": "00:BB:00:00:00:02", 71 | "isEdgeRouter": false, 72 | "adjacencySids": [] 73 | } 74 | } 75 | }, 76 | "ports": { 77 | "device:leaf1/3": { 78 | "interfaces": [ 79 | { 80 | "name": "leaf1-3", 81 | "ips": [ 82 | "172.16.1.254/24" 83 | ], 84 | "vlan-untagged": 100 85 | } 86 | ] 87 | }, 88 | "device:leaf1/4": { 89 | "interfaces": [ 90 | { 91 | "name": "leaf1-4", 92 | "ips": [ 93 | "172.16.1.254/24" 94 | ], 95 | "vlan-untagged": 100 96 | } 97 | ] 98 | }, 99 | "device:leaf1/5": { 100 | "interfaces": [ 101 | { 102 | "name": "leaf1-5", 103 | "ips": [ 104 | "172.16.1.254/24" 105 | ], 106 | "vlan-tagged": [ 107 | 100 108 | ] 109 | } 110 | ] 111 | }, 112 | "device:leaf1/6": { 113 | "interfaces": [ 114 | { 115 | "name": "leaf1-6", 116 | "ips": [ 117 | "172.16.2.254/24" 118 | ], 119 | "vlan-tagged": [ 120 | 200 121 | ] 122 | } 123 | ] 124 | }, 125 | "device:leaf2/3": { 126 | "interfaces": [ 127 | { 128 | "name": "leaf2-3", 129 | "ips": [ 130 | "172.16.3.254/24" 131 | ], 132 | "vlan-tagged": [ 133 | 300 134 | ] 135 | } 136 | ] 137 | }, 138 | "device:leaf2/4": { 139 | "interfaces": [ 140 | { 141 | "name": "leaf2-4", 142 | "ips": [ 143 | "172.16.4.254/24" 144 | ], 145 | "vlan-untagged": 400 146 | } 147 | ] 148 | } 149 | }, 150 | "hosts": { 151 | "00:00:00:00:00:1A/None": { 152 | "basic": { 153 | "name": "h1a", 154 | "locType": "grid", 155 | "gridX": 100, 156 | "gridY": 700 157 | } 158 | }, 159 | "00:00:00:00:00:1B/None": { 160 | "basic": { 161 | "name": "h1b", 162 | "locType": "grid", 163 | "gridX": 100, 164 | "gridY": 800 165 | } 166 | }, 167 | "00:00:00:00:00:1C/100": { 168 | "basic": { 169 | "name": "h1c", 170 | "locType": "grid", 171 | "gridX": 250, 172 | "gridY": 800 173 | } 174 | }, 175 | "00:00:00:00:00:20/200": { 176 | "basic": { 177 | "name": "h2", 178 | "locType": "grid", 179 | "gridX": 400, 180 | "gridY": 700 181 | } 182 | }, 183 | "00:00:00:00:00:30/300": { 184 | "basic": { 185 | "name": "h3", 186 | "locType": "grid", 187 | "gridX": 750, 188 | "gridY": 700 189 | } 190 | }, 191 | "00:00:00:00:00:40/None": { 192 | "basic": { 193 | "name": "h4", 194 | "locType": "grid", 195 | "gridX": 850, 196 | "gridY": 700 197 | } 198 | } 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /mininet/mn_lib.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2022-present Intel Corporation 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | from mininet.node import Host, Node 5 | import socket 6 | import struct 7 | 8 | DBUF_DROP_TIMEOUT_SEC = "30s" 9 | DBUF_NUM_QUEUES = 10 10 | DBUF_MAX_PKTS_PER_QUEUE = 16 11 | 12 | 13 | def ip2long(ip): 14 | """ 15 | Convert an IP string to long 16 | """ 17 | packedIP = socket.inet_aton(ip) 18 | return struct.unpack("!L", packedIP)[0] 19 | 20 | 21 | class IPv4Host(Host): 22 | """Host that can be configured with an IPv4 gateway (default route). 23 | """ 24 | 25 | def config(self, mac=None, ip=None, defaultRoute=None, lo='up', gw=None, **_params): 26 | super(IPv4Host, self).config(mac, ip, defaultRoute, lo, **_params) 27 | self.cmd('ip -4 addr flush dev %s' % self.defaultIntf()) 28 | self.cmd('ip -6 addr flush dev %s' % self.defaultIntf()) 29 | self.cmd('sysctl -w net.ipv4.ip_forward=0') 30 | self.cmd('ip -4 link set up %s' % self.defaultIntf()) 31 | self.cmd('ip -4 addr add %s dev %s' % (ip, self.defaultIntf())) 32 | if gw: 33 | self.cmd('ip -4 route add default via %s' % gw) 34 | # Disable offload 35 | for attr in ["rx", "tx", "sg"]: 36 | cmd = "/sbin/ethtool --offload %s %s off" % (self.defaultIntf(), attr) 37 | self.cmd(cmd) 38 | 39 | def updateIP(): 40 | return ip.split('/')[0] 41 | 42 | self.defaultIntf().updateIP = updateIP 43 | 44 | 45 | class TaggedIPv4Host(Host): 46 | """VLAN-tagged host that can be configured with an IPv4 gateway 47 | (default route). 48 | """ 49 | vlanIntf = None 50 | 51 | def config(self, mac=None, ip=None, defaultRoute=None, lo='up', gw=None, 52 | vlan=None, **_params): 53 | super(TaggedIPv4Host, self).config(mac, ip, defaultRoute, lo, **_params) 54 | self.vlanIntf = "%s.%s" % (self.defaultIntf(), vlan) 55 | # Replace default interface with a tagged one 56 | self.cmd('ip -4 addr flush dev %s' % self.defaultIntf()) 57 | self.cmd('ip -6 addr flush dev %s' % self.defaultIntf()) 58 | self.cmd('ip -4 link add link %s name %s type vlan id %s' % ( 59 | self.defaultIntf(), self.vlanIntf, vlan)) 60 | self.cmd('ip -4 link set up %s' % self.vlanIntf) 61 | self.cmd('ip -4 addr add %s dev %s' % (ip, self.vlanIntf)) 62 | if gw: 63 | self.cmd('ip -4 route add default via %s' % gw) 64 | 65 | self.defaultIntf().name = self.vlanIntf 66 | self.nameToIntf[self.vlanIntf] = self.defaultIntf() 67 | 68 | # Disable offload 69 | for attr in ["rx", "tx", "sg"]: 70 | cmd = "/sbin/ethtool --offload %s %s off" % ( 71 | self.defaultIntf(), attr) 72 | self.cmd(cmd) 73 | 74 | def updateIP(): 75 | return ip.split('/')[0] 76 | 77 | self.defaultIntf().updateIP = updateIP 78 | 79 | def terminate(self): 80 | self.cmd('ip -4 link remove link %s' % self.vlanIntf) 81 | super(TaggedIPv4Host, self).terminate() 82 | 83 | class DbufHost(IPv4Host): 84 | 85 | def __init__(self, name, inNamespace=False, **params): 86 | super(DbufHost, self).__init__(name, inNamespace, **params) 87 | 88 | def config(self, drainIp=None, drainMac=None, **_params): 89 | super(DbufHost, self).config(**_params) 90 | self.setDrainIpAndMac(self.defaultIntf(), drainIp, drainMac) 91 | self.startDbuf() 92 | 93 | def startDbuf(self): 94 | args = map(str, [ 95 | "-max_queues", 96 | DBUF_NUM_QUEUES, 97 | "-max_packet_slots_per_queue", 98 | DBUF_MAX_PKTS_PER_QUEUE, 99 | "-queue_drop_timeout", 100 | DBUF_DROP_TIMEOUT_SEC, 101 | ]) 102 | # Send to background 103 | cmd = '/usr/local/bin/dbuf %s > /tmp/dbuf_%s.log 2>&1 &' \ 104 | % (" ".join(args), self.name) 105 | print(cmd) 106 | self.cmd(cmd) 107 | 108 | def setDrainIpAndMac(self, intf, drainIp=None, drainMac=None): 109 | if drainIp: 110 | self.setHostRoute(drainIp, intf) 111 | if drainMac: 112 | self.setARP(drainIp, drainMac) 113 | 114 | 115 | class DualHomedIpv4Host(Host): 116 | """A dual homed host that can be configured with an IPv4 gateway (default route). 117 | """ 118 | 119 | def __init__(self, name, **kwargs): 120 | super(DualHomedIpv4Host, self).__init__(name, **kwargs) 121 | self.bond0 = None 122 | 123 | def config(self, ip=None, gw=None, **kwargs): 124 | super(DualHomedIpv4Host, self).config(**kwargs) 125 | intf0 = self.intfs[0].name 126 | intf1 = self.intfs[1].name 127 | self.bond0 = "%s-bond0" % self.name 128 | self.cmd('modprobe bonding') 129 | self.cmd('ip link add %s type bond miimon 100 mode balance-xor xmit_hash_policy layer2+3' % 130 | self.bond0) 131 | self.cmd('ip link set %s down' % intf0) 132 | self.cmd('ip link set %s down' % intf1) 133 | self.cmd('ip link set %s master %s' % (intf0, self.bond0)) 134 | self.cmd('ip link set %s master %s' % (intf1, self.bond0)) 135 | self.cmd('ip addr flush dev %s' % intf0) 136 | self.cmd('ip addr flush dev %s' % intf1) 137 | self.cmd('ip link set %s up' % self.bond0) 138 | 139 | self.cmd('sysctl -w net.ipv4.ip_forward=0') 140 | self.cmd('ip -4 addr add %s dev %s' % (ip, self.bond0)) 141 | if gw: 142 | self.cmd('ip -4 route add default via %s' % gw) 143 | # Disable offload 144 | for attr in ["rx", "tx", "sg"]: 145 | cmd = "/sbin/ethtool --offload %s %s off" % (self.defaultIntf(), attr) 146 | self.cmd(cmd) 147 | 148 | def terminate(self, **kwargs): 149 | self.cmd('ip link set %s down' % self.bond0) 150 | self.cmd('ip link delete %s' % self.bond0) 151 | super(DualHomedIpv4Host, self).terminate() 152 | 153 | 154 | class DualHomedDbufHost(DualHomedIpv4Host, DbufHost): 155 | 156 | def __init__(self, name, inNamespace=False, **params): 157 | super(DualHomedDbufHost, self).__init__(name, inNamespace=inNamespace, **params) 158 | 159 | def config(self, drainIp=None, drainMac=None, **_params): 160 | super(DualHomedDbufHost, self).config(**_params) 161 | self.setDrainIpAndMac(self.bond0, drainIp, drainMac) 162 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /EXERCISE-1.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | # Exercise 1: Basic configuration 7 | 8 | The goal of this exercise is to learn how to set up and configure an emulated 9 | SD-Fabric environment with a simple 2x2 topology. 10 | 11 | ## Background 12 | 13 | SD-Fabric has a set of built-in ONOS applications that provide the control plane 14 | for an IP fabric based on MPLS segment-routing. That is, 15 | SD-Fabric uses MPLS labels to forward packets between 16 | leaf switches and across the spines. 17 | 18 | SD-Fabric apps are deployed in Tier-1 carrier networks, and for this reason they 19 | are deemed production-grade. These apps provide an extensive feature set such 20 | as: 21 | 22 | * Carrier-oriented networking capabilities: from basic L2 and L3 forwarding, to 23 | multicast, integration with external control planes such 24 | as BGP, OSPF, DHCP relay, etc. 25 | * Fault-tolerance and high-availability: as SD-Fabric is designed to take full 26 | advantage of the ONOS distributed core, e.g., to withstand controller 27 | failures. It also provides dataplane-level resiliency against link failures 28 | and switch failures (with paired leaves and dual-homed hosts). See figure 29 | below. 30 | * Single-pane-of-glass monitoring and troubleshooting 31 | 32 | ![sdfabric-redundancy](img/redundancy.png) 33 | 34 | SD-Fabric is made of several apps running on top of ONOS, the main one is 35 | `segmentrouting`, and its implementation can be found in the ONOS source tree: 36 | [trellis-control] (open on GitHub) 37 | 38 | `segmentrouting` abstracts the leaf and spine switches to make the fabric appear 39 | as "one big IP router", such that operators can program them using APIs similar 40 | to that of a traditional router (e.g. to configure VLANs, subnets, routes, etc.) 41 | The app listens to operator-provided configuration, as well as topology events, 42 | to program the switches with the necessary forwarding rules. Because of this 43 | "one big IP router" abstraction, operators can independently scale the topology 44 | to add more capacity or ports by adding more leaves and spines. 45 | 46 | `segmentrouting` and other SD-Fabric apps use the ONOS Flow Objective API, which 47 | allow them to be pipeline-agnostic. As a matter of fact, SD-Fabric was initially 48 | designed to work with fixed-function switches exposing an OpenFlow agent (such 49 | as Broadcom Tomahawk, Trident2, and Qumran via the OF-DPA pipeline). However, in 50 | recent years, support for P4 programmable switches was enabled without changing 51 | the SD-Fabric apps, but instead providing a special ONOS pipeconf that brings in a 52 | P4 program complemented by a set of drivers that among other things are 53 | responsible for translating flow objectives to the P4 program-specific tables. 54 | 55 | This P4 program is named `fabric_v1model.p4`. Its implementation along with the 56 | corresponding pipeconf drivers can be found in the fabric-tna repository: 57 | [fabric-tna] (open on GitHub). 58 | This pipeconf currently works on the `stratum_bmv2` software switch. 59 | There is another P4 program named `fabric_tna.p4` that 60 | works on Intel Barefoot Tofino-based switches. 61 | 62 | We will come back to the details of `fabric_v1model.p4` in the next lab, for now, let's 63 | keep in mind that instead of building our own custom pipeconf, we will use the 64 | default one comes with SD-Fabric. 65 | 66 | The goal of the exercise is to learn the SD-Fabric basics by writing a 67 | configuration in the form of a netcfg JSON file to set up bridging and 68 | IPv4 routing of traffic between hosts. 69 | 70 | For a gentle overview of SD-Fabric, please check the online book 71 | "Software-Defined Networks: A Systems Approach": 72 | 73 | 74 | Finally, the official SD-Fabric documentation is also available online: 75 | 76 | 77 | ### Topology 78 | 79 | We will use the topology shown in the following diagram. 80 | The topology file is located under 81 | [mininet/topo-leafspine.py][topo-leafspine.py]. While the SD-Fabric apps support IPv6, the P4 82 | program does not, yet. Development of IPv6 support in `fabric_v1model.p4` is work in 83 | progress. 84 | 85 | ![topo-leafspine](img/topo-leafspine.png) 86 | 87 | The Mininet script [topo-leafspine.py] used here defines 4 IPv4 subnets: 88 | 89 | * `172.16.1.0/24` with 3 hosts connected to `leaf1` (`h1a`, `h1b`, and `h1c`) 90 | * `172.16.2.0/24` with 1 hosts connected to `leaf1` (`h2`) 91 | * `172.16.3.0/24` with 1 hosts connected to `leaf2` (`h3`) 92 | * `172.16.4.0/24` with 1 hosts connected to `leaf2` (`h4`) 93 | 94 | ### VLAN tagged vs. untagged ports 95 | 96 | As usually done in a traditional router, different subnets are associated to 97 | different VLANs. For this reason, SD-Fabric allows configuring ports with 98 | different VLANs, either untagged or tagged. 99 | 100 | An **untagged** port expects packets to be received and sent **without** a VLAN 101 | tag, but internally, the switch processes all packets as belonging to a given 102 | pre-configured VLAN ID. Similarly, when transmitting packets, the VLAN tag is 103 | removed. 104 | 105 | For **tagged** ports, packets are expected to be received **with** a VLAN tag 106 | that has ID that belongs to a pre-configured set of known ones. Packets received 107 | untagged or with an unknown VLAN ID, are dropped. 108 | 109 | In our topology, we want the following VLAN configuration: 110 | 111 | * `leaf1` port `3` and `4`: VLAN `100` untagged (host `h1a` and `h1b`) 112 | * `leaf1` port `5`: VLAN `100` tagged (`h1c`) 113 | * `leaf1` port `6`: VLAN `200` tagged (`h2`) 114 | * `leaf2` port `3`: VLAN `300` tagged (`h3`) 115 | * `leaf2` port `4`: VLAN `400` untagged (`h4`) 116 | 117 | In the Mininet script [topo-leafspine.py], we use different host Python classes to 118 | create untagged and tagged hosts. 119 | 120 | For example, for `h1a` attached to untagged port `leaf1-3`, we use the 121 | `IPv4Host` class: 122 | ``` 123 | # Excerpt from mininet/topo-leafspine.py 124 | h1a = self.addHost('h1a', cls=IPv4Host, mac="00:00:00:00:00:1A", 125 | ip='172.16.1.1/24', gw='172.16.1.254') 126 | ``` 127 | 128 | For `h2`, which instead is attached to tagged port `leaf1-6`, we use the 129 | `TaggedIPv4Host` class: 130 | 131 | ``` 132 | h2 = self.addHost('h2', cls=TaggedIPv4Host, mac="00:00:00:00:00:20", 133 | ip='172.16.2.1/24', gw='172.16.2.254', vlan=200) 134 | ``` 135 | 136 | In the same Python file, you can find the implementation for both classes. For 137 | `TaggedIPv4Host` we use standard Linux commands to create a VLAN tagged 138 | interface. 139 | 140 | ### Configuration via netcfg 141 | 142 | The JSON file in [config/netcfg-leafspine.json][netcfg-leafspine.json] includes the necessary 143 | configuration for ONOS and the SD-Fabric apps to program switches to forward 144 | traffic between hosts of the topology described above. 145 | 146 | Take a look at the network config ([netcfg-leafspine.json]) 147 | and try answering the following questions: 148 | 149 | * What is the pipeconf ID used for all 4 switches? 150 | Are the leaves using the same pipeconf as the spines? 151 | * Look at the `"interfaces"` config blocks, 152 | how many tagged ports and untagged ports are there? 153 | * Why do the untagged interfaces have only one VLAN ID value, 154 | while the tagged ones can take many (JSON array)? 155 | * How many L2 bridging domains are there? 156 | * Is the `interfaces` block provided for all host-facing ports? Which ports are 157 | missing and which hosts are attached to those ports? 158 | 159 | 160 | ## 1. Restart ONOS and Mininet with the IPv4 topology 161 | 162 | Since we want to use a new topology with IPv4 hosts, we need to reset the 163 | current environment: 164 | 165 | $ make reset 166 | 167 | This command will stop ONOS and Mininet and remove any state associated with 168 | them. 169 | 170 | Re-start ONOS and Mininet: 171 | 172 | $ make start 173 | 174 | Wait about 1 minute before proceeding with the next steps. This will 175 | give ONOS time to start all of its subsystems. 176 | 177 | ## 2. Load fabric pipeconf and segmentrouting 178 | 179 | Open up the ONOS CLI (`make onos-cli`) and verify the system is ready. 180 | #### Verify apps 181 | 182 | Verify that all apps have been activated successfully: 183 | 184 | onos@root > apps -s -a 185 | * 3 org.onosproject.route-service 2.5.8.SNAPSHOT Route Service Server 186 | * 5 org.onosproject.protocols.grpc 2.5.8.SNAPSHOT gRPC Protocol Subsystem 187 | * 6 org.onosproject.protocols.gnmi 2.5.8.SNAPSHOT gNMI Protocol Subsystem 188 | * 7 org.onosproject.generaldeviceprovider 2.5.8.SNAPSHOT General Device Provider 189 | * 8 org.onosproject.protocols.gnoi 2.5.8.SNAPSHOT gNOI Protocol Subsystem 190 | * 9 org.onosproject.drivers.gnoi 2.5.8.SNAPSHOT gNOI Drivers 191 | * 10 org.onosproject.protocols.p4runtime 2.5.8.SNAPSHOT P4Runtime Protocol Subsystem 192 | * 11 org.onosproject.p4runtime 2.5.8.SNAPSHOT P4Runtime Provider 193 | * 12 org.onosproject.drivers 2.5.8.SNAPSHOT Default Drivers 194 | * 13 org.onosproject.drivers.p4runtime 2.5.8.SNAPSHOT P4Runtime Drivers 195 | * 14 org.onosproject.pipelines.basic 2.5.8.SNAPSHOT Basic Pipelines 196 | * 17 org.onosproject.hostprovider 2.5.8.SNAPSHOT Host Location Provider 197 | * 19 org.onosproject.drivers.gnmi 2.5.8.SNAPSHOT gNMI Drivers 198 | * 20 org.onosproject.drivers.stratum 2.5.8.SNAPSHOT Stratum Drivers 199 | * 22 org.onosproject.drivers.bmv2 2.5.8.SNAPSHOT BMv2 Drivers 200 | * 23 org.onosproject.lldpprovider 2.5.8.SNAPSHOT LLDP Link Provider 201 | * 24 org.onosproject.portloadbalancer 2.5.8.SNAPSHOT Port Load Balance Service 202 | * 27 org.onosproject.netcfghostprovider 2.5.8.SNAPSHOT Network Config Host Provider 203 | * 29 org.onosproject.gui2 2.5.8.SNAPSHOT ONOS GUI2 204 | * 30 org.onosproject.mcast 2.5.8.SNAPSHOT Multicast traffic control 205 | * 32 org.stratumproject.fabric-tna 1.2.0.SNAPSHOT Fabric-TNA Pipeconf 206 | * 33 org.onosproject.segmentrouting 3.3.0.SNAPSHOT Trellis Control App 207 | * 34 org.omecproject.up4 1.2.0.SNAPSHOT UP4 208 | 209 | Verify that you have the above 23 apps active in your ONOS instance. If you are 210 | wondering why so many apps, remember from EXERCISE 1 that the ONOS container in 211 | [docker-compose.yml] is configured to pass the environment variable `ONOS_APPS` 212 | which defines built-in apps to load during startup. 213 | 214 | In our case this variable has value: 215 | 216 | ONOS_APPS=gui2,drivers.bmv2,lldpprovider,hostprovider,org.stratumproject.fabric-tna,segmentrouting,netcfghostprovider,org.omecproject.up4 217 | 218 | Moreover, `segmentrouting` requires other apps as dependencies, such as 219 | `route-service`, `mcast`, and `portloadbalancer`. The combination of all these 220 | apps (and others that we do not need in this exercise) is what makes SD-Fabric. 221 | 222 | #### Verify pipeconfs 223 | 224 | Verify that the `fabric.bmv2` pipeconfs have been registered successfully: 225 | 226 | onos@root > pipeconfs | grep bmv2 227 | id=org.stratumproject.fabric-upf.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner, UpfProgrammable], extensions=[P4_INFO_TEXT, BMV2_JSON] 228 | id=org.stratumproject.fabric-int.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner, IntProgrammable], extensions=[P4_INFO_TEXT, BMV2_JSON] 229 | id=org.stratumproject.fabric-upf-int.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner, IntProgrammable, UpfProgrammable], extensions=[P4_INFO_TEXT, BMV2_JSON] 230 | id=org.stratumproject.fabric.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner], extensions=[P4_INFO_TEXT, BMV2_JSON] 231 | 232 | Wondering why so many pipeconfs? `fabric_v1model.p4` comes in different "profiles", used 233 | to enable different dataplane features in the pipeline. We'll come back 234 | to the differences between different profiles in the next exercise, for now 235 | let's make sure `org.stratumproject.fabric.bmv2` and `org.stratumproject.fabric-upf.bmv2` are loaded. 236 | These are the pipeconfs we need to program all four switches, as specified in 237 | [netcfg-leafspine.json]. 238 | 239 | #### Verify reconciliation frequency 240 | 241 | Run the following commands in the ONOS CLI: 242 | 243 | onos> cfg get org.onosproject.net.flow.impl.FlowRuleManager fallbackFlowPollFrequency 244 | onos> cfg get org.onosproject.net.group.impl.GroupManager fallbackGroupPollFrequency 245 | 246 | This command gets the ONOS component config value of the period (in seconds) between 247 | reconciliation checks. Reconciliation is used to verify that switches have the 248 | expected forwarding state and to correct any inconsistencies, i.e., writing any 249 | pending flow rule and group. When running ONOS and the emulated switches in the 250 | same machine (especially those with low CPU/memory), it might happen that 251 | P4Runtime write requests time out because the system is overloaded. 252 | 253 | The default reconciliation period is 30 seconds, but SD-Fabric has customized the value to 4 254 | seconds for flow rules, and 3 seconds for groups. 255 | 256 | ## 3. Push netcfg-leafspine.json to ONOS 257 | 258 | On a terminal window, type: 259 | 260 | $ make netcfg 261 | 262 | This command will push [netcfg-leafspine.json] to ONOS, 263 | triggering discovery and configuration of the 4 switches. Moreover, since the 264 | file specifies a `segmentrouting` config block for each switch, this will 265 | instruct the `segmentrouting` app in ONOS to take control of all of them, i.e., 266 | the app will start generating flow objectives that will be translated into flow 267 | rules for the `fabric_v1model.p4` pipeline. 268 | 269 | Check the ONOS log (`make onos-log`). You should see numerous messages from 270 | components such as `TopologyHandler`, `LinkHandler`, `SegmentRoutingManager`, 271 | etc., signaling that switches have been discovered and programmed. 272 | 273 | You should also see warning messages such as: 274 | 275 | ``` 276 | [ForwardingObjectiveTranslator] Cannot translate DefaultForwardingObjective: unsupported forwarding function type 'org.stratumproject.fabric.tna.behaviour.pipeliner.ForwardingFunctionType@52b0744f... 277 | ``` 278 | 279 | This is normal, as not all SD-Fabric features are supported in `fabric_v1model.p4`. One of 280 | such feature is [pseudo-wire] (L2 tunneling across the L3 fabric). You can 281 | ignore that. 282 | 283 | This error is generated by the Pipeliner driver behavior of the `fabric.bmv2` 284 | pipeconf, which recognizes that the given flow objective cannot be translated. 285 | 286 | #### Check configuration in ONOS 287 | 288 | Verify that all interfaces have been configured successfully: 289 | 290 | onos> interfaces 291 | leaf1-3: port=device:leaf1/3 ips=[172.16.1.254/24] mac=00:AA:00:00:00:01 vlanUntagged=100 292 | leaf1-4: port=device:leaf1/4 ips=[172.16.1.254/24] mac=00:AA:00:00:00:01 vlanUntagged=100 293 | leaf1-5: port=device:leaf1/5 ips=[172.16.1.254/24] mac=00:AA:00:00:00:01 vlanTagged=[100] 294 | leaf1-6: port=device:leaf1/6 ips=[172.16.2.254/24] mac=00:AA:00:00:00:01 vlanTagged=[200] 295 | 296 | You should see four interfaces in total (for all host-facing ports of `leaf1`), 297 | configured as in the [netcfg-leafspine.json] file. You will have to add the 298 | configuration for `leaf2`'s ports later in this exercise. 299 | 300 | A similar output can be obtained by using a `segmentrouting`-specific command: 301 | 302 | onos> sr-device-subnets 303 | device:leaf1 304 | 172.16.1.0/24 305 | 172.16.2.0/24 306 | device:spine1 307 | device:spine2 308 | device:leaf2 309 | 310 | This command lists all device-subnet mapping known to `segmentrouting`. For a 311 | list of other available sr-specific commands, type `sr-` and press 312 | tab (as for command auto-completion). 313 | 314 | Another interesting command is `sr-ecmp-spg`, which lists all computed ECMP 315 | shortest-path graphs: 316 | 317 | onos> sr-ecmp-spg 318 | Root Device: device:leaf1 ECMP Paths: 319 | Paths from device:leaf1 to device:spine1 320 | == : device:leaf1/[leaf1-eth1](1) -> device:spine1/[spine1-eth1](1) 321 | Paths from device:leaf1 to device:spine2 322 | == : device:leaf1/[leaf1-eth2](2) -> device:spine2/[spine2-eth1](1) 323 | Paths from device:leaf1 to device:leaf2 324 | == : device:leaf1/[leaf1-eth1](1) -> device:spine1/[spine1-eth1](1) : device:spine1/[spine1-eth2](2) -> device:leaf2/[leaf2-eth1](1) 325 | == : device:leaf1/[leaf1-eth2](2) -> device:spine2/[spine2-eth1](1) : device:spine2/[spine2-eth2](2) -> device:leaf2/[leaf2-eth2](2) 326 | 327 | Root Device: device:spine1 ECMP Paths: 328 | Paths from device:spine1 to device:leaf1 329 | == : device:spine1/[spine1-eth1](1) -> device:leaf1/[leaf1-eth1](1) 330 | Paths from device:spine1 to device:spine2 331 | == : device:spine1/[spine1-eth2](2) -> device:leaf2/[leaf2-eth1](1) : device:leaf2/[leaf2-eth2](2) -> device:spine2/[spine2-eth2](2) 332 | == : device:spine1/[spine1-eth1](1) -> device:leaf1/[leaf1-eth1](1) : device:leaf1/[leaf1-eth2](2) -> device:spine2/[spine2-eth1](1) 333 | Paths from device:spine1 to device:leaf2 334 | == : device:spine1/[spine1-eth2](2) -> device:leaf2/[leaf2-eth1](1) 335 | 336 | Root Device: device:spine2 ECMP Paths: 337 | Paths from device:spine2 to device:leaf1 338 | == : device:spine2/[spine2-eth1](1) -> device:leaf1/[leaf1-eth2](2) 339 | Paths from device:spine2 to device:spine1 340 | == : device:spine2/[spine2-eth1](1) -> device:leaf1/[leaf1-eth2](2) : device:leaf1/[leaf1-eth1](1) -> device:spine1/[spine1-eth1](1) 341 | == : device:spine2/[spine2-eth2](2) -> device:leaf2/[leaf2-eth2](2) : device:leaf2/[leaf2-eth1](1) -> device:spine1/[spine1-eth2](2) 342 | Paths from device:spine2 to device:leaf2 343 | == : device:spine2/[spine2-eth2](2) -> device:leaf2/[leaf2-eth2](2) 344 | 345 | Root Device: device:leaf2 ECMP Paths: 346 | Paths from device:leaf2 to device:leaf1 347 | == : device:leaf2/[leaf2-eth1](1) -> device:spine1/[spine1-eth2](2) : device:spine1/[spine1-eth1](1) -> device:leaf1/[leaf1-eth1](1) 348 | == : device:leaf2/[leaf2-eth2](2) -> device:spine2/[spine2-eth2](2) : device:spine2/[spine2-eth1](1) -> device:leaf1/[leaf1-eth2](2) 349 | Paths from device:leaf2 to device:spine1 350 | == : device:leaf2/[leaf2-eth1](1) -> device:spine1/[spine1-eth2](2) 351 | Paths from device:leaf2 to device:spine2 352 | == : device:leaf2/[leaf2-eth2](2) -> device:spine2/[spine2-eth2](2) 353 | 354 | These graphs are used by `segmentrouting` to program flow rules and groups 355 | (action selectors) in `fabric.p4`, needed to load balance traffic across 356 | multiple spines/paths. 357 | 358 | Verify that no hosts have been discovered so far: 359 | 360 | onos> hosts 361 | 362 | You should get an empty output. 363 | 364 | Verify that all initial flows and groups have be programmed successfully: 365 | 366 | onos> flows -c added 367 | deviceId=device:leaf1, flowRuleCount=80 368 | deviceId=device:spine1, flowRuleCount=42 369 | deviceId=device:spine2, flowRuleCount=42 370 | deviceId=device:leaf2, flowRuleCount=54 371 | onos> groups -c added 372 | deviceId=device:leaf1, groupCount=5 373 | deviceId=device:leaf2, groupCount=3 374 | deviceId=device:spine1, groupCount=5 375 | deviceId=device:spine2, groupCount=5 376 | 377 | You should see the same `flowRuleCount` and `groupCount` in your 378 | output. To dump the whole set of flow rules and groups, remove the 379 | `-c` argument from the command. `added` is used to filter only 380 | entities that are known to have been written to the switch (i.e., the 381 | P4Runtime Write RPC was successful.) 382 | 383 | ## 4. Connectivity test 384 | 385 | #### Same-subnet hosts (bridging) 386 | 387 | Open up the Mininet CLI (`make mn-cli`). Start by pinging `h1a` and `h1c`, 388 | which are both on the same subnet (VLAN `100` 172.16.1.0/24): 389 | 390 | mininet> h1a ping h1c 391 | PING 172.16.1.3 (172.16.1.3) 56(84) bytes of data. 392 | 64 bytes from 172.16.1.3: icmp_seq=1 ttl=63 time=13.7 ms 393 | 64 bytes from 172.16.1.3: icmp_seq=2 ttl=63 time=3.63 ms 394 | 64 bytes from 172.16.1.3: icmp_seq=3 ttl=63 time=3.52 ms 395 | ... 396 | 397 | Ping should work. Check the ONOS log, you should see an output similar to that 398 | of exercises 4-5. 399 | 400 | [HostHandler] Host 00:00:00:00:00:1A/None is added at [device:leaf1/3] 401 | [HostHandler] Populating bridging entry for host 00:00:00:00:00:1A/None at device:leaf1:3 402 | [HostHandler] Populating routing rule for 172.16.1.1 at device:leaf1/3 403 | [HostHandler] Host 00:00:00:00:00:1C/100 is added at [device:leaf1/5] 404 | [HostHandler] Populating bridging entry for host 00:00:00:00:00:1C/100 at device:leaf1:5 405 | [HostHandler] Populating routing rule for 172.16.1.3 at device:leaf1/5 406 | 407 | That's because `segmentrouting` operates in a way that is similar to the custom 408 | app of previous exercises. Hosts are discovered by the built-in service 409 | `hostprovider` intercepting packets such as ARP or NDP. For hosts in the same 410 | subnet, to support ARP resolution, multicast (ALL) groups are used to replicate 411 | ARP requests to all ports belonging to the same VLAN. `segmentrouting` listens 412 | for host events, when a new one is discovered, it installs the necessary 413 | bridging and routing rules. 414 | 415 | #### Hosts on different subnets (routing) 416 | 417 | On the Mininet prompt, start a ping to `h2` from any host in the subnet with 418 | VLAN `100`, for example, from `h1a`: 419 | 420 | mininet> h1a ping h2 421 | 422 | The **ping should NOT work**, and the reason is that the location of `h2` is not 423 | known to ONOS, yet. Usually, SD-Fabric is used in networks where hosts use DHCP 424 | for addressing. In such setup, we could use the DHCP relay app in ONOS to learn 425 | host locations and addresses when the hosts request an IP address via DHCP. 426 | However, in this simpler topology, we need to manually trigger `h2` to generate 427 | some packets to be discovered by ONOS. 428 | 429 | When using `segmentrouting`, the easiest way to have ONOS discover an host, is 430 | to ping the gateway address that we configured in [netcfg-leafspine.json], or that you 431 | can derive from the ONOS CLI (`onos> interfaces`): 432 | 433 | mininet> h2 ping 172.16.2.254 434 | PING 172.16.2.254 (172.16.2.254) 56(84) bytes of data. 435 | 64 bytes from 172.16.2.254: icmp_seq=1 ttl=64 time=28.9 ms 436 | 64 bytes from 172.16.2.254: icmp_seq=2 ttl=64 time=12.6 ms 437 | 64 bytes from 172.16.2.254: icmp_seq=3 ttl=64 time=15.2 ms 438 | ... 439 | 440 | Ping is working, and ONOS should have discovered `h2` by now. But, who is 441 | replying to our pings? 442 | 443 | If you check the ARP table for h2: 444 | 445 | mininet> h2 arp 446 | Address HWtype HWaddress Flags Mask Iface 447 | 172.16.2.254 ether 00:aa:00:00:00:01 C h2-eth0.200 448 | 449 | You should recognize MAC address `00:aa:00:00:00:01` as the one associated with 450 | `leaf1` in [netcfg-leafspine.json]. That's it, the `segmentrouting` app in ONOS is 451 | replying to our ICMP echo request (ping) packets! Ping requests are intercepted 452 | by means of P4Runtime packet-in, while replies are generated and injected via 453 | P4Runtime packet-out. This is equivalent to pinging the interface of a 454 | traditional router. 455 | 456 | At this point, ping from `h1a` to `h2` should work: 457 | 458 | mininet> h1a ping h2 459 | PING 172.16.2.1 (172.16.2.1) 56(84) bytes of data. 460 | 64 bytes from 172.16.2.1: icmp_seq=1 ttl=63 time=6.23 ms 461 | 64 bytes from 172.16.2.1: icmp_seq=2 ttl=63 time=3.81 ms 462 | 64 bytes from 172.16.2.1: icmp_seq=3 ttl=63 time=3.84 ms 463 | ... 464 | 465 | Moreover, you can check that all hosts pinged so far have been discovered by 466 | ONOS: 467 | 468 | onos> hosts -s 469 | id=00:00:00:00:00:1A/None, mac=00:00:00:00:00:1A, locations=[device:leaf1/3], vlan=None, ip(s)=[172.16.1.1] 470 | id=00:00:00:00:00:1C/100, mac=00:00:00:00:00:1C, locations=[device:leaf1/5], vlan=100, ip(s)=[172.16.1.3] 471 | id=00:00:00:00:00:20/200, mac=00:00:00:00:00:20, locations=[device:leaf1/6], vlan=200, ip(s)=[172.16.2.1] 472 | 473 | ## 5. Dump packets to see VLAN tags (optional) 474 | 475 | TODO: detailed instructions for this step are still a work-in-progress. 476 | 477 | If you feel adventurous, start a ping between any two hosts, and use the tool 478 | [util/mn-pcap](util/mn-pcap) to dump packets to a PCAP file. After dumping 479 | packets, the tool tries to open the pcap file on wireshark (if installed). 480 | 481 | For example, to dump packets out of the `h2` main interface: 482 | 483 | $ util/mn-pcap h2 484 | 485 | You should notice that packets going in to and out from h2 are tagged with VLAN 200. 486 | ![exercise-2-wireshark](img/exercise-1-wireshark.png) 487 | 488 | ## 6. Add missing interface config 489 | 490 | Start a ping from `h3` to any other host, for example `h2`: 491 | 492 | mininet> h3 ping h2 493 | ... 494 | 495 | It should NOT work. Can you explain why? 496 | 497 | Let's check the ONOS log (`make onos-log`). You should see the following 498 | messages: 499 | 500 | ... 501 | INFO [HostHandler] Host 00:00:00:00:00:30/None is added at [device:leaf2/3] 502 | INFO [HostHandler] Populating bridging entry for host 00:00:00:00:00:30/None at device:leaf2:3 503 | WARN [RoutingRulePopulator] Untagged host 00:00:00:00:00:30/None is not allowed on device:leaf2/3 without untagged or nativevlan config 504 | WARN [RoutingRulePopulator] Fail to build fwd obj for host 00:00:00:00:00:30/None. Abort. 505 | INFO [HostHandler] 172.16.3.1 is not included in the subnet config of device:leaf2/3. Ignored. 506 | 507 | 508 | `h3` is discovered because ONOS intercepted the ARP request to resolve `h3`'s 509 | gateway IP address (`172.16.3.254`), but the rest of the programming fails 510 | because we have not provided a valid SD-Fabric configuration for the switch port 511 | facing `h3` (`leaf2/3`). Indeed, if you look at [netcfg-leafspine.json] you will notice 512 | that the `"ports"` section includes a config block for all `leaf1` host-facing 513 | ports, but it does NOT provide any for `leaf2`. 514 | 515 | As a matter of fact, if you try to start a ping from `h4` (attached to `leaf2`), 516 | that should NOT work as well. 517 | 518 | It is your task to modify the [netcfg-leafspine.json] to add the necessary config 519 | blocks to enable connectivity for `h3` and `h4`: 520 | 521 | 1. Open up [netcfg-leafspine.json]. 522 | 2. Look for the `"ports"` section. 523 | 3. Provide a config for ports `device:leaf2/3` and `device:leaf2/4`. When doing 524 | so, look at the config for other ports as a reference, but make sure to 525 | provide the right IPv4 gateway address, subnet, and VLAN configuration 526 | described at the beginning of this document. 527 | 4. When done, push the updated file to ONOS using `make netcfg`. 528 | 5. Verify that the two new interface configs show up when using the ONOS 529 | CLI (`onos> interfaces`). 530 | 6. If you don't see the new interfaces in the ONOS CLI, verify the ONOS log 531 | (`make onos-log`) for any possible error, and eventually go back to step 3. 532 | 7. If you struggle to make it work, a solution is available in the 533 | `solution/mininet` directory. 534 | 535 | Let's try to ping the corresponding gateway address from `h3` and `h4`: 536 | 537 | mininet> h3 ping 172.16.3.254 538 | PING 172.16.3.254 (172.16.3.254) 56(84) bytes of data. 539 | 64 bytes from 172.16.3.254: icmp_seq=1 ttl=64 time=66.5 ms 540 | 64 bytes from 172.16.3.254: icmp_seq=2 ttl=64 time=19.1 ms 541 | 64 bytes from 172.16.3.254: icmp_seq=3 ttl=64 time=27.5 ms 542 | ... 543 | 544 | mininet> h4 ping 172.16.4.254 545 | PING 172.16.4.254 (172.16.4.254) 56(84) bytes of data. 546 | 64 bytes from 172.16.4.254: icmp_seq=1 ttl=64 time=45.2 ms 547 | 64 bytes from 172.16.4.254: icmp_seq=2 ttl=64 time=12.7 ms 548 | 64 bytes from 172.16.4.254: icmp_seq=3 ttl=64 time=22.0 ms 549 | ... 550 | 551 | At this point, ping between all hosts should work except `gnb`, 552 | which is a mobile component that we are going to set up in the next exercise. 553 | You can try that using the special `pingall` command in the Mininet CLI: 554 | 555 | mininet> pingall 556 | *** Ping: testing ping reachability 557 | gnb -> X X X X X X 558 | h1a -> X h1b h1c h2 h3 h4 559 | h1b -> X h1a h1c h2 h3 h4 560 | h1c -> X h1a h1b h2 h3 h4 561 | h2 -> X h1a h1b h1c h3 h4 562 | h3 -> X h1a h1b h1c h2 h4 563 | h4 -> X h1a h1b h1c h2 h3 564 | *** Results: 28% dropped (30/42 received) 565 | 566 | ## Congratulations! 567 | 568 | You have completed the seventh exercise! You were able to use ONOS built-in 569 | SD-Fabric apps such as `segmentrouting` and the `fabric.bmv2` pipeconf to configure 570 | forwarding in a 2x2 leaf-spine fabric of IPv4 hosts. 571 | 572 | [topo-leafspine.py]: mininet/topo-leafspine.py 573 | [netcfg-leafspine.json]: config/netcfg-leafspine.json 574 | [docker-compose.yml]: docker-compose.yml 575 | [pseudo-wire]: https://en.wikipedia.org/wiki/Pseudo-wire 576 | [trellis-control]: https://github.com/opennetworkinglab/trellis-control/tree/3.2.0 577 | [fabric-tna]: https://github.com/stratum/fabric-tna 578 | 582 | 583 | # Exercise 2: Basic configuration 584 | 585 | The goal of this exercise is to learn how to set up and configure an emulated 586 | SD-Fabric environment with a simple 2x2 topology. 587 | 588 | ## Background 589 | 590 | SD-Fabric has a set of built-in ONOS applications that provide the control plane 591 | for an IP fabric based on MPLS segment-routing. That is, 592 | SD-Fabric uses MPLS labels to forward packets between 593 | leaf switches and across the spines. 594 | 595 | SD-Fabric apps are deployed in Tier-1 carrier networks, and for this reason they 596 | are deemed production-grade. These apps provide an extensive feature set such 597 | as: 598 | 599 | * Carrier-oriented networking capabilities: from basic L2 and L3 forwarding, to 600 | multicast, integration with external control planes such 601 | as BGP, OSPF, DHCP relay, etc. 602 | * Fault-tolerance and high-availability: as SD-Fabric is designed to take full 603 | advantage of the ONOS distributed core, e.g., to withstand controller 604 | failures. It also provides dataplane-level resiliency against link failures 605 | and switch failures (with paired leaves and dual-homed hosts). See figure 606 | below. 607 | * Single-pane-of-glass monitoring and troubleshooting 608 | 609 | ![sdfabric-redundancy](img/redundancy.png) 610 | 611 | SD-Fabric is made of several apps running on top of ONOS, the main one is 612 | `segmentrouting`, and its implementation can be found in the ONOS source tree: 613 | [trellis-control] (open on GitHub) 614 | 615 | `segmentrouting` abstracts the leaf and spine switches to make the fabric appear 616 | as "one big IP router", such that operators can program them using APIs similar 617 | to that of a traditional router (e.g. to configure VLANs, subnets, routes, etc.) 618 | The app listens to operator-provided configuration, as well as topology events, 619 | to program the switches with the necessary forwarding rules. Because of this 620 | "one big IP router" abstraction, operators can independently scale the topology 621 | to add more capacity or ports by adding more leaves and spines. 622 | 623 | `segmentrouting` and other SD-Fabric apps use the ONOS Flow Objective API, which 624 | allow them to be pipeline-agnostic. As a matter of fact, SD-Fabric was initially 625 | designed to work with fixed-function switches exposing an OpenFlow agent (such 626 | as Broadcom Tomahawk, Trident2, and Qumran via the OF-DPA pipeline). However, in 627 | recent years, support for P4 programmable switches was enabled without changing 628 | the SD-Fabric apps, but instead providing a special ONOS pipeconf that brings in a 629 | P4 program complemented by a set of drivers that among other things are 630 | responsible for translating flow objectives to the P4 program-specific tables. 631 | 632 | This P4 program is named `fabric_v1model.p4`. It's implementation along with the 633 | corresponding pipeconf drivers can be found in the fabric-tna repository: 634 | [fabric-tna] (open on GitHub). 635 | This pipeconf currently works on the `stratum_bmv2` software switch. 636 | There is another P4 program named `fabric_tna.p4` that 637 | works on Intel Barefoot Tofino-based switches. 638 | 639 | We will come back to the details of `fabric_v1model.p4` in the next lab, for now, let's 640 | keep in mind that instead of building our own custom pipeconf, we will use the 641 | default one comes with SD-Fabric. 642 | 643 | The goal of the exercise is to learn the SD-Fabric basics by writing a 644 | configuration in the form of a netcfg JSON file to set up bridging and 645 | IPv4 routing of traffic between hosts. 646 | 647 | For a gentle overview of SD-Fabric, please check the online book 648 | "Software-Defined Networks: A Systems Approach": 649 | 650 | 651 | Finally, the official SD-Fabric documentation is also available online: 652 | 653 | 654 | ### Topology 655 | 656 | We will use the topology shown in the following diagram. 657 | The topology file is located under 658 | [mininet/topo-leafspine.py][topo-leafspine.py]. While the SD-Fabric apps support IPv6, the P4 659 | program does not, yet. Development of IPv6 support in `fabric_v1model.p4` is work in 660 | progress. 661 | 662 | ![topo-leafspine](img/topo-leafspine.png) 663 | 664 | The Mininet script [topo-leafspine.py] used here defines 4 IPv4 subnets: 665 | 666 | * `172.16.1.0/24` with 3 hosts connected to `leaf1` (`h1a`, `h1b`, and `h1c`) 667 | * `172.16.2.0/24` with 1 hosts connected to `leaf1` (`h2`) 668 | * `172.16.3.0/24` with 1 hosts connected to `leaf2` (`h3`) 669 | * `172.16.4.0/24` with 1 hosts connected to `leaf2` (`h4`) 670 | 671 | ### VLAN tagged vs. untagged ports 672 | 673 | As usually done in a traditional router, different subnets are associated to 674 | different VLANs. For this reason, SD-Fabric allows configuring ports with 675 | different VLANs, either untagged or tagged. 676 | 677 | An **untagged** port expects packets to be received and sent **without** a VLAN 678 | tag, but internally, the switch processes all packets as belonging to a given 679 | pre-configured VLAN ID. Similarly, when transmitting packets, the VLAN tag is 680 | removed. 681 | 682 | For **tagged** ports, packets are expected to be received **with** a VLAN tag 683 | that has ID that belongs to a pre-configured set of known ones. Packets received 684 | untagged or with an unknown VLAN ID, are dropped. 685 | 686 | In our topology, we want the following VLAN configuration: 687 | 688 | * `leaf1` port `3` and `4`: VLAN `100` untagged (host `h1a` and `h1b`) 689 | * `leaf1` port `5`: VLAN `100` tagged (`h1c`) 690 | * `leaf1` port `6`: VLAN `200` tagged (`h2`) 691 | * `leaf2` port `3`: VLAN `300` tagged (`h3`) 692 | * `leaf2` port `4`: VLAN `400` untagged (`h4`) 693 | 694 | In the Mininet script [topo-leafspine.py], we use different host Python classes to 695 | create untagged and tagged hosts. 696 | 697 | For example, for `h1a` attached to untagged port `leaf1-3`, we use the 698 | `IPv4Host` class: 699 | ``` 700 | # Excerpt from mininet/topo-leafspine.py 701 | h1a = self.addHost('h1a', cls=IPv4Host, mac="00:00:00:00:00:1A", 702 | ip='172.16.1.1/24', gw='172.16.1.254') 703 | ``` 704 | 705 | For `h2`, which instead is attached to tagged port `leaf1-6`, we use the 706 | `TaggedIPv4Host` class: 707 | 708 | ``` 709 | h2 = self.addHost('h2', cls=TaggedIPv4Host, mac="00:00:00:00:00:20", 710 | ip='172.16.2.1/24', gw='172.16.2.254', vlan=200) 711 | ``` 712 | 713 | In the same Python file, you can find the implementation for both classes. For 714 | `TaggedIPv4Host` we use standard Linux commands to create a VLAN tagged 715 | interface. 716 | 717 | ### Configuration via netcfg 718 | 719 | The JSON file in [config/netcfg-leafspine.json][netcfg-leafspine.json] includes the necessary 720 | configuration for ONOS and the SD-Fabric apps to program switches to forward 721 | traffic between hosts of the topology described above. 722 | 723 | Take a look at the network config ([netcfg-leafspine.json]) 724 | and try answering the following questions: 725 | 726 | * What is the pipeconf ID used for all 4 switches? 727 | Are the leaves using the same pipeconf as the spines? 728 | * Look at the `"interfaces"` config blocks, 729 | how many tagged ports and untagged ports are there? 730 | * Why do the untagged interfaces have only one VLAN ID value, 731 | while the tagged ones can take many (JSON array)? 732 | * How many L2 bridging domains are there? 733 | * Is the `interfaces` block provided for all host-facing ports? Which ports are 734 | missing and which hosts are attached to those ports? 735 | 736 | 737 | ## 1. Restart ONOS and Mininet with the IPv4 topology 738 | 739 | Since we want to use a new topology with IPv4 hosts, we need to reset the 740 | current environment: 741 | 742 | $ make reset 743 | 744 | This command will stop ONOS and Mininet and remove any state associated with 745 | them. 746 | 747 | Re-start ONOS and Mininet: 748 | 749 | $ make start 750 | 751 | Wait about 1 minute before proceeding with the next steps. This will 752 | give ONOS time to start all of its subsystems. 753 | 754 | ## 2. Load fabric pipeconf and segmentrouting 755 | 756 | Open up the ONOS CLI (`make onos-cli`) and verify the system is ready. 757 | #### Verify apps 758 | 759 | Verify that all apps have been activated successfully: 760 | 761 | onos@root > apps -s -a 762 | * 3 org.onosproject.route-service 2.5.8.SNAPSHOT Route Service Server 763 | * 5 org.onosproject.protocols.grpc 2.5.8.SNAPSHOT gRPC Protocol Subsystem 764 | * 6 org.onosproject.protocols.gnmi 2.5.8.SNAPSHOT gNMI Protocol Subsystem 765 | * 7 org.onosproject.generaldeviceprovider 2.5.8.SNAPSHOT General Device Provider 766 | * 8 org.onosproject.protocols.gnoi 2.5.8.SNAPSHOT gNOI Protocol Subsystem 767 | * 9 org.onosproject.drivers.gnoi 2.5.8.SNAPSHOT gNOI Drivers 768 | * 10 org.onosproject.protocols.p4runtime 2.5.8.SNAPSHOT P4Runtime Protocol Subsystem 769 | * 11 org.onosproject.p4runtime 2.5.8.SNAPSHOT P4Runtime Provider 770 | * 12 org.onosproject.drivers 2.5.8.SNAPSHOT Default Drivers 771 | * 13 org.onosproject.drivers.p4runtime 2.5.8.SNAPSHOT P4Runtime Drivers 772 | * 14 org.onosproject.pipelines.basic 2.5.8.SNAPSHOT Basic Pipelines 773 | * 17 org.onosproject.hostprovider 2.5.8.SNAPSHOT Host Location Provider 774 | * 19 org.onosproject.drivers.gnmi 2.5.8.SNAPSHOT gNMI Drivers 775 | * 20 org.onosproject.drivers.stratum 2.5.8.SNAPSHOT Stratum Drivers 776 | * 22 org.onosproject.drivers.bmv2 2.5.8.SNAPSHOT BMv2 Drivers 777 | * 23 org.onosproject.lldpprovider 2.5.8.SNAPSHOT LLDP Link Provider 778 | * 24 org.onosproject.portloadbalancer 2.5.8.SNAPSHOT Port Load Balance Service 779 | * 27 org.onosproject.netcfghostprovider 2.5.8.SNAPSHOT Network Config Host Provider 780 | * 29 org.onosproject.gui2 2.5.8.SNAPSHOT ONOS GUI2 781 | * 30 org.onosproject.mcast 2.5.8.SNAPSHOT Multicast traffic control 782 | * 32 org.stratumproject.fabric-tna 1.2.0.SNAPSHOT Fabric-TNA Pipeconf 783 | * 33 org.onosproject.segmentrouting 3.3.0.SNAPSHOT Trellis Control App 784 | * 34 org.omecproject.up4 1.2.0.SNAPSHOT UP4 785 | 786 | Verify that you have the above 23 apps active in your ONOS instance. If you are 787 | wondering why so many apps, remember from EXERCISE 1 that the ONOS container in 788 | [docker-compose.yml] is configured to pass the environment variable `ONOS_APPS` 789 | which defines built-in apps to load during startup. 790 | 791 | In our case this variable has value: 792 | 793 | ONOS_APPS=gui2,drivers.bmv2,lldpprovider,hostprovider,org.stratumproject.fabric-tna,segmentrouting,netcfghostprovider,org.omecproject.up4 794 | 795 | Moreover, `segmentrouting` requires other apps as dependencies, such as 796 | `route-service`, `mcast`, and `portloadbalancer`. The combination of all these 797 | apps (and others that we do not need in this exercise) is what makes SD-Fabric. 798 | 799 | #### Verify pipeconfs 800 | 801 | Verify that the `fabric.bmv2` pipeconfs have been registered successfully: 802 | 803 | onos@root > pipeconfs | grep bmv2 804 | id=org.stratumproject.fabric-upf.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner, UpfProgrammable], extensions=[P4_INFO_TEXT, BMV2_JSON] 805 | id=org.stratumproject.fabric-int.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner, IntProgrammable], extensions=[P4_INFO_TEXT, BMV2_JSON] 806 | id=org.stratumproject.fabric-upf-int.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner, IntProgrammable, UpfProgrammable], extensions=[P4_INFO_TEXT, BMV2_JSON] 807 | id=org.stratumproject.fabric.bmv2, behaviors=[PiPipelineInterpreter, Pipeliner], extensions=[P4_INFO_TEXT, BMV2_JSON] 808 | 809 | Wondering why so many pipeconfs? `fabric_v1model.p4` comes in different "profiles", used 810 | to enable different dataplane features in the pipeline. We'll come back 811 | to the differences between different profiles in the next exercise, for now 812 | let's make sure `org.stratumproject.fabric.bmv2` and `org.stratumproject.fabric-upf.bmv2` are loaded. 813 | These are the pipeconfs we need to program all four switches, as specified in 814 | [netcfg-leafspine.json]. 815 | 816 | #### Verify reconciliation frequency 817 | 818 | Run the following commands in the ONOS CLI: 819 | 820 | onos> cfg get org.onosproject.net.flow.impl.FlowRuleManager fallbackFlowPollFrequency 821 | onos> cfg get org.onosproject.net.group.impl.GroupManager fallbackGroupPollFrequency 822 | 823 | This command gets the ONOS component config value of the period (in seconds) between 824 | reconciliation checks. Reconciliation is used to verify that switches have the 825 | expected forwarding state and to correct any inconsistencies, i.e., writing any 826 | pending flow rule and group. When running ONOS and the emulated switches in the 827 | same machine (especially those with low CPU/memory), it might happen that 828 | P4Runtime write requests time out because the system is overloaded. 829 | 830 | The default reconciliation period is 30 seconds, but SD-Fabric has customized the value to 4 831 | seconds for flow rules, and 3 seconds for groups. 832 | 833 | ## 3. Push netcfg-leafspine.json to ONOS 834 | 835 | On a terminal window, type: 836 | 837 | $ make netcfg 838 | 839 | This command will push [netcfg-leafspine.json] to ONOS, 840 | triggering discovery and configuration of the 4 switches. Moreover, since the 841 | file specifies a `segmentrouting` config block for each switch, this will 842 | instruct the `segmentrouting` app in ONOS to take control of all of them, i.e., 843 | the app will start generating flow objectives that will be translated into flow 844 | rules for the `fabric_v1model.p4` pipeline. 845 | 846 | Check the ONOS log (`make onos-log`). You should see numerous messages from 847 | components such as `TopologyHandler`, `LinkHandler`, `SegmentRoutingManager`, 848 | etc., signaling that switches have been discovered and programmed. 849 | 850 | You should also see warning messages such as: 851 | 852 | ``` 853 | [ForwardingObjectiveTranslator] Cannot translate DefaultForwardingObjective: unsupported forwarding function type 'org.stratumproject.fabric.tna.behaviour.pipeliner.ForwardingFunctionType@52b0744f... 854 | ``` 855 | 856 | This is normal, as not all SD-Fabric features are supported in `fabric_v1model.p4`. One of 857 | such feature is [pseudo-wire] (L2 tunneling across the L3 fabric). You can 858 | ignore that. 859 | 860 | This error is generated by the Pipeliner driver behavior of the `fabric.bmv2` 861 | pipeconf, which recognizes that the given flow objective cannot be translated. 862 | 863 | #### Check configuration in ONOS 864 | 865 | Verify that all interfaces have been configured successfully: 866 | 867 | onos> interfaces 868 | leaf1-3: port=device:leaf1/3 ips=[172.16.1.254/24] mac=00:AA:00:00:00:01 vlanUntagged=100 869 | leaf1-4: port=device:leaf1/4 ips=[172.16.1.254/24] mac=00:AA:00:00:00:01 vlanUntagged=100 870 | leaf1-5: port=device:leaf1/5 ips=[172.16.1.254/24] mac=00:AA:00:00:00:01 vlanTagged=[100] 871 | leaf1-6: port=device:leaf1/6 ips=[172.16.2.254/24] mac=00:AA:00:00:00:01 vlanTagged=[200] 872 | 873 | You should see four interfaces in total (for all host-facing ports of `leaf1`), 874 | configured as in the [netcfg-leafspine.json] file. You will have to add the 875 | configuration for `leaf2`'s ports later in this exercise. 876 | 877 | A similar output can be obtained by using a `segmentrouting`-specific command: 878 | 879 | onos> sr-device-subnets 880 | device:leaf1 881 | 172.16.1.0/24 882 | 172.16.2.0/24 883 | device:spine1 884 | device:spine2 885 | device:leaf2 886 | 887 | This command lists all device-subnet mapping known to `segmentrouting`. For a 888 | list of other available sr-specific commands, type `sr-` and press 889 | tab (as for command auto-completion). 890 | 891 | Another interesting command is `sr-ecmp-spg`, which lists all computed ECMP 892 | shortest-path graphs: 893 | 894 | onos> sr-ecmp-spg 895 | Root Device: device:leaf1 ECMP Paths: 896 | Paths from device:leaf1 to device:spine1 897 | == : device:leaf1/[leaf1-eth1](1) -> device:spine1/[spine1-eth1](1) 898 | Paths from device:leaf1 to device:spine2 899 | == : device:leaf1/[leaf1-eth2](2) -> device:spine2/[spine2-eth1](1) 900 | Paths from device:leaf1 to device:leaf2 901 | == : device:leaf1/[leaf1-eth1](1) -> device:spine1/[spine1-eth1](1) : device:spine1/[spine1-eth2](2) -> device:leaf2/[leaf2-eth1](1) 902 | == : device:leaf1/[leaf1-eth2](2) -> device:spine2/[spine2-eth1](1) : device:spine2/[spine2-eth2](2) -> device:leaf2/[leaf2-eth2](2) 903 | 904 | Root Device: device:spine1 ECMP Paths: 905 | Paths from device:spine1 to device:leaf1 906 | == : device:spine1/[spine1-eth1](1) -> device:leaf1/[leaf1-eth1](1) 907 | Paths from device:spine1 to device:spine2 908 | == : device:spine1/[spine1-eth2](2) -> device:leaf2/[leaf2-eth1](1) : device:leaf2/[leaf2-eth2](2) -> device:spine2/[spine2-eth2](2) 909 | == : device:spine1/[spine1-eth1](1) -> device:leaf1/[leaf1-eth1](1) : device:leaf1/[leaf1-eth2](2) -> device:spine2/[spine2-eth1](1) 910 | Paths from device:spine1 to device:leaf2 911 | == : device:spine1/[spine1-eth2](2) -> device:leaf2/[leaf2-eth1](1) 912 | 913 | Root Device: device:spine2 ECMP Paths: 914 | Paths from device:spine2 to device:leaf1 915 | == : device:spine2/[spine2-eth1](1) -> device:leaf1/[leaf1-eth2](2) 916 | Paths from device:spine2 to device:spine1 917 | == : device:spine2/[spine2-eth1](1) -> device:leaf1/[leaf1-eth2](2) : device:leaf1/[leaf1-eth1](1) -> device:spine1/[spine1-eth1](1) 918 | == : device:spine2/[spine2-eth2](2) -> device:leaf2/[leaf2-eth2](2) : device:leaf2/[leaf2-eth1](1) -> device:spine1/[spine1-eth2](2) 919 | Paths from device:spine2 to device:leaf2 920 | == : device:spine2/[spine2-eth2](2) -> device:leaf2/[leaf2-eth2](2) 921 | 922 | Root Device: device:leaf2 ECMP Paths: 923 | Paths from device:leaf2 to device:leaf1 924 | == : device:leaf2/[leaf2-eth1](1) -> device:spine1/[spine1-eth2](2) : device:spine1/[spine1-eth1](1) -> device:leaf1/[leaf1-eth1](1) 925 | == : device:leaf2/[leaf2-eth2](2) -> device:spine2/[spine2-eth2](2) : device:spine2/[spine2-eth1](1) -> device:leaf1/[leaf1-eth2](2) 926 | Paths from device:leaf2 to device:spine1 927 | == : device:leaf2/[leaf2-eth1](1) -> device:spine1/[spine1-eth2](2) 928 | Paths from device:leaf2 to device:spine2 929 | == : device:leaf2/[leaf2-eth2](2) -> device:spine2/[spine2-eth2](2) 930 | 931 | These graphs are used by `segmentrouting` to program flow rules and groups 932 | (action selectors) in `fabric.p4`, needed to load balance traffic across 933 | multiple spines/paths. 934 | 935 | Verify that no hosts have been discovered so far: 936 | 937 | onos> hosts 938 | 939 | You should get an empty output. 940 | 941 | Verify that all initial flows and groups have be programmed successfully: 942 | 943 | onos> flows -c added 944 | deviceId=device:leaf1, flowRuleCount=80 945 | deviceId=device:spine1, flowRuleCount=42 946 | deviceId=device:spine2, flowRuleCount=42 947 | deviceId=device:leaf2, flowRuleCount=54 948 | onos> groups -c added 949 | deviceId=device:leaf1, groupCount=5 950 | deviceId=device:leaf2, groupCount=3 951 | deviceId=device:spine1, groupCount=5 952 | deviceId=device:spine2, groupCount=5 953 | 954 | You should see the same `flowRuleCount` and `groupCount` in your 955 | output. To dump the whole set of flow rules and groups, remove the 956 | `-c` argument from the command. `added` is used to filter only 957 | entities that are known to have been written to the switch (i.e., the 958 | P4Runtime Write RPC was successful.) 959 | 960 | ## 4. Connectivity test 961 | 962 | #### Same-subnet hosts (bridging) 963 | 964 | Open up the Mininet CLI (`make mn-cli`). Start by pinging `h1a` and `h1c`, 965 | which are both on the same subnet (VLAN `100` 172.16.1.0/24): 966 | 967 | mininet> h1a ping h1c 968 | PING 172.16.1.3 (172.16.1.3) 56(84) bytes of data. 969 | 64 bytes from 172.16.1.3: icmp_seq=1 ttl=63 time=13.7 ms 970 | 64 bytes from 172.16.1.3: icmp_seq=2 ttl=63 time=3.63 ms 971 | 64 bytes from 172.16.1.3: icmp_seq=3 ttl=63 time=3.52 ms 972 | ... 973 | 974 | Ping should work. Check the ONOS log, you should see an output similar to that 975 | of exercises 4-5. 976 | 977 | [HostHandler] Host 00:00:00:00:00:1A/None is added at [device:leaf1/3] 978 | [HostHandler] Populating bridging entry for host 00:00:00:00:00:1A/None at device:leaf1:3 979 | [HostHandler] Populating routing rule for 172.16.1.1 at device:leaf1/3 980 | [HostHandler] Host 00:00:00:00:00:1C/100 is added at [device:leaf1/5] 981 | [HostHandler] Populating bridging entry for host 00:00:00:00:00:1C/100 at device:leaf1:5 982 | [HostHandler] Populating routing rule for 172.16.1.3 at device:leaf1/5 983 | 984 | That's because `segmentrouting` operates in a way that is similar to the custom 985 | app of previous exercises. Hosts are discovered by the built-in service 986 | `hostprovider` intercepting packets such as ARP or NDP. For hosts in the same 987 | subnet, to support ARP resolution, multicast (ALL) groups are used to replicate 988 | ARP requests to all ports belonging to the same VLAN. `segmentrouting` listens 989 | for host events, when a new one is discovered, it installs the necessary 990 | bridging and routing rules. 991 | 992 | #### Hosts on different subnets (routing) 993 | 994 | On the Mininet prompt, start a ping to `h2` from any host in the subnet with 995 | VLAN `100`, for example, from `h1a`: 996 | 997 | mininet> h1a ping h2 998 | 999 | The **ping should NOT work**, and the reason is that the location of `h2` is not 1000 | known to ONOS, yet. Usually, SD-Fabric is used in networks where hosts use DHCP 1001 | for addressing. In such setup, we could use the DHCP relay app in ONOS to learn 1002 | host locations and addresses when the hosts request an IP address via DHCP. 1003 | However, in this simpler topology, we need to manually trigger `h2` to generate 1004 | some packets to be discovered by ONOS. 1005 | 1006 | When using `segmentrouting`, the easiest way to have ONOS discover an host, is 1007 | to ping the gateway address that we configured in [netcfg-leafspine.json], or that you 1008 | can derive from the ONOS CLI (`onos> interfaces`): 1009 | 1010 | mininet> h2 ping 172.16.2.254 1011 | PING 172.16.2.254 (172.16.2.254) 56(84) bytes of data. 1012 | 64 bytes from 172.16.2.254: icmp_seq=1 ttl=64 time=28.9 ms 1013 | 64 bytes from 172.16.2.254: icmp_seq=2 ttl=64 time=12.6 ms 1014 | 64 bytes from 172.16.2.254: icmp_seq=3 ttl=64 time=15.2 ms 1015 | ... 1016 | 1017 | Ping is working, and ONOS should have discovered `h2` by now. But, who is 1018 | replying to our pings? 1019 | 1020 | If you check the ARP table for h2: 1021 | 1022 | mininet> h2 arp 1023 | Address HWtype HWaddress Flags Mask Iface 1024 | 172.16.2.254 ether 00:aa:00:00:00:01 C h2-eth0.200 1025 | 1026 | You should recognize MAC address `00:aa:00:00:00:01` as the one associated with 1027 | `leaf1` in [netcfg-leafspine.json]. That's it, the `segmentrouting` app in ONOS is 1028 | replying to our ICMP echo request (ping) packets! Ping requests are intercepted 1029 | by means of P4Runtime packet-in, while replies are generated and injected via 1030 | P4Runtime packet-out. This is equivalent to pinging the interface of a 1031 | traditional router. 1032 | 1033 | At this point, ping from `h1a` to `h2` should work: 1034 | 1035 | mininet> h1a ping h2 1036 | PING 172.16.2.1 (172.16.2.1) 56(84) bytes of data. 1037 | 64 bytes from 172.16.2.1: icmp_seq=1 ttl=63 time=6.23 ms 1038 | 64 bytes from 172.16.2.1: icmp_seq=2 ttl=63 time=3.81 ms 1039 | 64 bytes from 172.16.2.1: icmp_seq=3 ttl=63 time=3.84 ms 1040 | ... 1041 | 1042 | Moreover, you can check that all hosts pinged so far have been discovered by 1043 | ONOS: 1044 | 1045 | onos> hosts -s 1046 | id=00:00:00:00:00:1A/None, mac=00:00:00:00:00:1A, locations=[device:leaf1/3], vlan=None, ip(s)=[172.16.1.1] 1047 | id=00:00:00:00:00:1C/100, mac=00:00:00:00:00:1C, locations=[device:leaf1/5], vlan=100, ip(s)=[172.16.1.3] 1048 | id=00:00:00:00:00:20/200, mac=00:00:00:00:00:20, locations=[device:leaf1/6], vlan=200, ip(s)=[172.16.2.1] 1049 | 1050 | ## 5. Dump packets to see VLAN tags (optional) 1051 | 1052 | TODO: detailed instructions for this step are still a work-in-progress. 1053 | 1054 | If you feel adventurous, start a ping between any two hosts, and use the tool 1055 | [util/mn-pcap](util/mn-pcap) to dump packets to a PCAP file. After dumping 1056 | packets, the tool tries to open the pcap file on wireshark (if installed). 1057 | 1058 | For example, to dump packets out of the `h2` main interface: 1059 | 1060 | $ util/mn-pcap h2 1061 | 1062 | You should notice that packets going in to and out from h2 are tagged with VLAN 200. 1063 | ![exercise-2-wireshark](img/exercise-2-wireshark.png) 1064 | 1065 | ## 6. Add missing interface config 1066 | 1067 | Start a ping from `h3` to any other host, for example `h2`: 1068 | 1069 | mininet> h3 ping h2 1070 | ... 1071 | 1072 | It should NOT work. Can you explain why? 1073 | 1074 | Let's check the ONOS log (`make onos-log`). You should see the following 1075 | messages: 1076 | 1077 | ... 1078 | INFO [HostHandler] Host 00:00:00:00:00:30/None is added at [device:leaf2/3] 1079 | INFO [HostHandler] Populating bridging entry for host 00:00:00:00:00:30/None at device:leaf2:3 1080 | WARN [RoutingRulePopulator] Untagged host 00:00:00:00:00:30/None is not allowed on device:leaf2/3 without untagged or nativevlan config 1081 | WARN [RoutingRulePopulator] Fail to build fwd obj for host 00:00:00:00:00:30/None. Abort. 1082 | INFO [HostHandler] 172.16.3.1 is not included in the subnet config of device:leaf2/3. Ignored. 1083 | 1084 | 1085 | `h3` is discovered because ONOS intercepted the ARP request to resolve `h3`'s 1086 | gateway IP address (`172.16.3.254`), but the rest of the programming fails 1087 | because we have not provided a valid SD-Fabric configuration for the switch port 1088 | facing `h3` (`leaf2/3`). Indeed, if you look at [netcfg-leafspine.json] you will notice 1089 | that the `"ports"` section includes a config block for all `leaf1` host-facing 1090 | ports, but it does NOT provide any for `leaf2`. 1091 | 1092 | As a matter of fact, if you try to start a ping from `h4` (attached to `leaf2`), 1093 | that should NOT work as well. 1094 | 1095 | It is your task to modify the [netcfg-leafspine.json] to add the necessary config 1096 | blocks to enable connectivity for `h3` and `h4`: 1097 | 1098 | 1. Open up [netcfg-leafspine.json]. 1099 | 2. Look for the `"ports"` section. 1100 | 3. Provide a config for ports `device:leaf2/3` and `device:leaf2/4`. When doing 1101 | so, look at the config for other ports as a reference, but make sure to 1102 | provide the right IPv4 gateway address, subnet, and VLAN configuration 1103 | described at the beginning of this document. 1104 | 4. When done, push the updated file to ONOS using `make netcfg`. 1105 | 5. Verify that the two new interface configs show up when using the ONOS 1106 | CLI (`onos> interfaces`). 1107 | 6. If you don't see the new interfaces in the ONOS CLI, verify the ONOS log 1108 | (`make onos-log`) for any possible error, and eventually go back to step 3. 1109 | 7. If you struggle to make it work, a solution is available in the 1110 | `solution/mininet` directory. 1111 | 1112 | Let's try to ping the corresponding gateway address from `h3` and `h4`: 1113 | 1114 | mininet> h3 ping 172.16.3.254 1115 | PING 172.16.3.254 (172.16.3.254) 56(84) bytes of data. 1116 | 64 bytes from 172.16.3.254: icmp_seq=1 ttl=64 time=66.5 ms 1117 | 64 bytes from 172.16.3.254: icmp_seq=2 ttl=64 time=19.1 ms 1118 | 64 bytes from 172.16.3.254: icmp_seq=3 ttl=64 time=27.5 ms 1119 | ... 1120 | 1121 | mininet> h4 ping 172.16.4.254 1122 | PING 172.16.4.254 (172.16.4.254) 56(84) bytes of data. 1123 | 64 bytes from 172.16.4.254: icmp_seq=1 ttl=64 time=45.2 ms 1124 | 64 bytes from 172.16.4.254: icmp_seq=2 ttl=64 time=12.7 ms 1125 | 64 bytes from 172.16.4.254: icmp_seq=3 ttl=64 time=22.0 ms 1126 | ... 1127 | 1128 | At this point, ping between all hosts should work except `gnb`, 1129 | which is a mobile component that we are going to set up in the next exercise. 1130 | You can try that using the special `pingall` command in the Mininet CLI: 1131 | 1132 | mininet> pingall 1133 | *** Ping: testing ping reachability 1134 | gnb -> X X X X X X 1135 | h1a -> X h1b h1c h2 h3 h4 1136 | h1b -> X h1a h1c h2 h3 h4 1137 | h1c -> X h1a h1b h2 h3 h4 1138 | h2 -> X h1a h1b h1c h3 h4 1139 | h3 -> X h1a h1b h1c h2 h4 1140 | h4 -> X h1a h1b h1c h2 h3 1141 | *** Results: 28% dropped (30/42 received) 1142 | 1143 | ## Congratulations! 1144 | 1145 | You have completed the seventh exercise! You were able to use ONOS built-in 1146 | SD-Fabric apps such as `segmentrouting` and the `fabric.bmv2` pipeconf to configure 1147 | forwarding in a 2x2 leaf-spine fabric of IPv4 hosts. 1148 | 1149 | [topo-leafspine.py]: mininet/topo-leafspine.py 1150 | [netcfg-leafspine.json]: config/netcfg-leafspine.json 1151 | [docker-compose.yml]: docker-compose.yml 1152 | [pseudo-wire]: https://en.wikipedia.org/wiki/Pseudo-wire 1153 | [trellis-control]: https://github.com/opennetworkinglab/trellis-control/tree/3.2.0 1154 | [fabric-tna]: https://github.com/stratum/fabric-tna 1155 | --------------------------------------------------------------------------------