# Tres ISP de una misma ciudad con un solo proveedor de tránsito, lejos: 40 ms en cada
# sentido por enlace, como el cable a Miami de la semana 1. Hay también un IXP en la
# ciudad (el switch ix), pero al comienzo nadie tiene sesiones por ahí.
#
#                     t  AS 64710
#                   / | \
#         40 ms   /   |   \   40 ms
#              isp1  isp2  isp3     AS 64701, 64702, 64703
#              | \   | \   | \
#             h1  \  h2 \  h3 \
#                  \------+-----\----- ix (10.208.100.0/24)
name: w07-ixp
mgmt:
  network: redes-w07-ixp
  ipv4-subnet: 172.90.7.64/26
  ipv6-subnet: 3fff:172:90:7:1::/80
topology:
  defaults:
    kind: linux
    image: redes-router
  nodes:
    t:
      binds: [t/frr.conf:/etc/frr/frr.conf:ro]
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - tc qdisc add dev eth1 root netem delay 40ms
        - tc qdisc add dev eth2 root netem delay 40ms
        - tc qdisc add dev eth3 root netem delay 40ms
    isp1:
      binds: [isp1/frr.conf:/etc/frr/frr.conf:ro]
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - tc qdisc add dev eth2 root netem delay 40ms
    h1:
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - ip addr add 100.64.71.10/24 dev eth1
        - ip route add default via 100.64.71.1
    isp2:
      binds: [isp2/frr.conf:/etc/frr/frr.conf:ro]
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - tc qdisc add dev eth2 root netem delay 40ms
    h2:
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - ip addr add 100.64.72.10/24 dev eth1
        - ip route add default via 100.64.72.1
    isp3:
      binds: [isp3/frr.conf:/etc/frr/frr.conf:ro]
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - tc qdisc add dev eth2 root netem delay 40ms
    h3:
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - ip addr add 100.64.73.10/24 dev eth1
        - ip route add default via 100.64.73.1
    # El IXP es un switch: un dominio de broadcast compartido, nada más.
    ix:
      exec:
        - ip route del default
        - sysctl -w net.ipv6.conf.all.disable_ipv6=1
        - ip link add br0 type bridge
        - ip link set eth1 master br0
        - ip link set eth2 master br0
        - ip link set eth3 master br0
        - ip link set br0 up
  # Containerlab usa MTU 9500 por defecto; aquí queremos el valor de Ethernet.
  links:
    - {endpoints: ["h1:eth1", "isp1:eth1"], mtu: 1500}
    - {endpoints: ["h2:eth1", "isp2:eth1"], mtu: 1500}
    - {endpoints: ["h3:eth1", "isp3:eth1"], mtu: 1500}
    - {endpoints: ["isp1:eth2", "t:eth1"], mtu: 1500}
    - {endpoints: ["isp2:eth2", "t:eth2"], mtu: 1500}
    - {endpoints: ["isp3:eth2", "t:eth3"], mtu: 1500}
    - {endpoints: ["isp1:eth3", "ix:eth1"], mtu: 1500}
    - {endpoints: ["isp2:eth3", "ix:eth2"], mtu: 1500}
    - {endpoints: ["isp3:eth3", "ix:eth3"], mtu: 1500}
