Faucet y mininet
Información extraída de Faucet in a Virtual Infrastructure. He probado el siguiente escenario utilizando Faucet y mininet, donde se muestran las máquinas, switches y puertos de los números de puerto de los switches para cada enlace:
h11 h12
\ /
\ /
(1)\ /(1)
+------+ (3) Trunk (3) +------+
| s1 |---------------------------| s2 |
+------+ +------+
(2)/ \(2)
/ \
/ \
h21 h22
Donde s1 y s2 son switches openFlow. Las máquinas tendrán la siguiente configuración: Máquina | dirEthernet | dirIP --------|-------------|------- h11 |00:00:00:00:00:01| 10.0.0.1 h12 |00:00:00:00:00:02| 10.0.0.2 h21 |00:00:00:00:00:03| 10.0.0.3 h22 |00:00:00:00:00:04| 10.0.0.4
Se ha configurado Faucet con las siguientes VLANS:
- VLAN 10: pertenecen h11 y h12
- VLAN 20: pertenecen h21 y h22
VLAN 10 VLAN 20
(1) (3) (3) (1) (2) (3) (3) (2)
h11 ------ s1 --------- s2 ------- h12 h21 ------ s1 --------- s1 ------ h22
Instalación y activación de virtual environment:
sudo apt install python-virtualenv
cd ~/ofworkspace
virtualenv venv
. ./venv/bin/activate
Una vez activado el entorno virtual, el prompt ha cambiado, colocando como prefijo (venv)
, por ejemplo:
- Antes de activar el entorno:
eva@sdnlab:~/ofworkspace$
- Después de activar el entorno:
(venv) eva@sdnlab:~/ofworkspace$
Dentro del entorno virtual, instalar Faucet:
git clone -b v1_2 https://github.com/REANNZ/faucet
cd faucet
python setup.py develop
Crear directorios para los ficheros de configuración y logs:
mkdir -p venv/var/log/ryu/faucet
mkdir -p venv/etc/ryu/faucet
Crear la configuración de faucet para el comportamiento de s1
y s2
, en el fichero venv/etc/ryu/faucet/faucet.yaml
con el siguiente contenido:
---
version: 2
dps:
s1:
description: s1
dp_id: 0x0000000000000001
interfaces:
1: # -> s1 <---> h11
description: Connection s1 to h11
native_vlan: 10
2: # -> s1 <---> h21
description: Connection s1 to h21
native_vlan: 20
3: # -> s1 <---> s2
description: Connection s1 to s2
tagged_vlans: [10, 20]
s2:
description: s2
dp_id: 0x0000000000000002
interfaces:
1: # -> s2 <---> h12
description: Connection s2 to h12
native_vlan: 10
2: # -> s2 <---> h22
description: Connection s2 to h22
native_vlan: 20
3: # -> s2 <---> s1
description: Connection s2 to s1
tagged_vlans: [10, 20]
vlans:
10:
name: VLAN10
20:
name: VLAN20
Para crear una topología de switches y máquinas como la descrita en mininet, se necesita una configuración como la siguiente, por ejemplo, en el archivo ~/ofworkspace/mininet-topologies/twoVlansBasic.py
:
"""
Notacion: hij: host j de la VLAN i
h11 h12
\ /
s1 -------------s2
/ \
h21 h22
"""
from mininet.topo import Topo
class TwoVlansBasicTopo( Topo ):
"2 vlans topology with 4 hosts and 2 switch"
def build( self ):
s1 = self.addSwitch( 's1', dpid='1' )
s2 = self.addSwitch( 's2', dpid='2' )
h11 = self.addHost( 'h11' )
self.addLink( s1, h11, port1=1, port2=1 )
h21 = self.addHost( 'h21' )
self.addLink( s1, h21 , port1=2, port2=1 )
h12 = self.addHost( 'h12' )
self.addLink( s2, h12, port1=1, port2=1 )
h22 = self.addHost( 'h22' )
self.addLink( s2, h22, port1=2, port2=1 )
self.addLink( s1, s2, port1=3, port2=3)
# Allows the file to be imported using `mn --custom <filename> --topo dcconfig`
topos = {
'dcconfig': TwoVlansBasicTopo
}
Ya tenemos preparada la configuración de la topología en mininet y del comportamiento de los switches en Faucet. Arrancamos el controlador y la topología en mininet:
Para arrancar Faucet, activando el API REST:
cd ~/ofworkspace . ./venv/bin/activate ryu-manager faucet/src/ryu_faucet/org/onfsdn/faucet/faucet.py ryu.app.ofctl_rest
Para arrancar ese escenario en mininet:
cd ~/ofworkspace/mininet-topologies sudo mn --custom datacenterConfigurable.py --topo dcconfig --mac --controller remote
Si desde mininet ejecutamos un ping entre todas las máquinas, sólo deberían ser alcanzables aquéllas que pertenecen a la misma VLAN, es decir h11 y h12 en la VLAN 10 y h21 con h22 en la VLAN 20.
eva@sdnlab:~/ofworkspace/mininet-topologies$ sudo mn --custom twoVlansBasic.py --topo dcconfig --mac --controller remote
*** Creating network
*** Adding controller
Connecting to remote controller at 127.0.0.1:6653
*** Adding hosts:
h11 h12 h21 h22
*** Adding switches:
s1 s2
*** Adding links:
(s1, h11) (s1, h21) (s1, s2) (s2, h12) (s2, h22)
*** Configuring hosts
h11 h12 h21 h22
*** Starting controller
c0
*** Starting 2 switches
s1 s2 ...
*** Starting CLI:
mininet> pingall
*** Ping: testing ping reachability
h11 -> h12 X X
h12 -> h11 X X
h21 -> X X h22
h22 -> X X h21
*** Results: 66% dropped (4/12 received)
mininet>
Los flujos instalados en s1 después de haber ejecutado el ping son:
- Tabla 0
Table | Priority | dl_dst | dl_src | dl_vlan | dl_type | in_port | actions | meaning |
---|---|---|---|---|---|---|---|---|
0 | 9099 | 01:80:c2:00:00:00 | None (DROP) | Descartar paquetes | ||||
0 | 9099 | 01:00:0c:cc:cc:cd | None (DROP) | Descartar paquetes | ||||
0 | 9099 | 35020 | None (DROP) | Descartar paquetes | ||||
0 | 9099 | ff:ff:ff:ff:ff:ff | None (DROP) | Descartar paquetes | ||||
0 | 9001 | 0e:00:00:00:00:01 | None (DROP) | Descartar paquetes | ||||
0 | 9000 | 1 | PUSH_VLAN:33024 vlanid=4106 GOTO_TABLE=2 | Tráfico recibido por puerto 1 (desde h11) se le añade etiqueta 10 y se reenvía a tabla=2 | ||||
0 | 9000 | 2 | PUSH_VLAN:33024 vlanid=4116 GOTO_TABLE=2 | Tráfico recibido por puerto 2 (desde h21) se le añade etiqueta 20 y se reenvía a tabla=2 | ||||
0 | 9000 | 10 | 3 | GOTO_TABLE=2 | Tráfico recibido por puerto 3 (desde s2) con etiqueta 10 se reenvía a tabla=2 | |||
0 | 9000 | 20 | 3 | GOTO_TABLE=2 | Tráfico recibido por puerto 3 (desde s2) con etiqueta 20 se reenvía a tabla=2 | |||
0 | 0 | None (DROP) |
- Tabla 1
Table | Priority | dl_dst | dl_src | dl_vlan | dl_type | in_port | actions | meaning |
---|---|---|---|---|---|---|---|---|
1 | 0 | None (DROP) |
- Tabla 2
Table | Priority | dl_dst | dl_src | dl_vlan | dl_type | in_port | actions | meaning |
---|---|---|---|---|---|---|---|---|
2 | 9098 | 00:00:00:00:00:00:04 | 20 | 3 | GOTO_TABLE=5 | Tráfico de h22 con etiqueta 20 recibido en puerto 3 se reenvía a tabla=5 | ||
2 | 9098 | 00:00:00:00:00:00:03 | 20 | 2 | GOTO_TABLE=5 | Tráfico de h21 con etiqueta 20 recibido en puerto 2 se reenvía a tabla=5 | ||
2 | 9098 | 00:00:00:00:00:00:01 | 10 | 1 | GOTO_TABLE=5 | Tráfico de h11 con etiqueta 10 recibido en puerto 1 se reenvía a tabla=5 | ||
2 | 9098 | 00:00:00:00:00:00:02 | 10 | 3 | GOTO_TABLE=5 | Tráfico de h12 con etiqueta 10 recibido en puerto 3 se reenvía a tabla=5 | ||
2 | 9000 | OUTPUT:CONTROLLER, GOTO_TABLE=5 | ||||||
2 | 0 | None (DROP) |
- Tabla 3
Table | Priority | dl_dst | dl_src | dl_vlan | dl_type | in_port | actions | meaning |
---|---|---|---|---|---|---|---|---|
3 | 0 | None (DROP) |
- Tabla 4
Table | Priority | dl_dst | dl_src | dl_vlan | dl_type | in_port | actions | meaning |
---|---|---|---|---|---|---|---|---|
4 | 0 | None (DROP) |
- Tabla 5
Table | Priority | dl_dst | dl_src | dl_vlan | dl_type | in_port | actions | meaning |
---|---|---|---|---|---|---|---|---|
5 | 9099 | 00:00:00:00:00:04 | 20 | OUTPUT:3 | Tráfico hacia h22 con etiqueta 20 se envía por puerto=3 | |||
5 | 9099 | 00:00:00:00:00:03 | 20 | POP_VLAN, OUTPUT:2 | Tráfico hacia h21 se elimina etiqueta 20 y se envía por puerto=2 | |||
5 | 9099 | 00:00:00:00:00:01 | 10 | POP_VLAN, OUTPUT:1 | Tráfico hacia h11 se elimina etiqueta 10 y se envía por puerto=1 | |||
5 | 9099 | 00:00:00:00:00:02 | 10 | OUTPUT:3 | Tráfico hacia h12 con etiqueta 10 se envía por puerto=3 | |||
5 | 9000 | GOTO_TABLE=6 | Tráfico sin etiqueta se envía a tabla=6 | |||||
5 | 0 | None (DROP) |
- Tabla 6
Table | Priority | dl_dst | dl_src | dl_vlan | dl_type | in_port | actions | meaning |
---|---|---|---|---|---|---|---|---|
6 | 9008 | ff:ff:ff:ff:ff:ff | 10 | 3 | POP_VLAN, OUTPUT:1 | |||
6 | 9008 | ff:ff:ff:ff:ff:ff | 10 | 1 | POP_VLAN, OUTPUT:3 | |||
6 | 9008 | ff:ff:ff:ff:ff:ff | 20 | 3 | POP_VLAN, OUTPUT:2 | |||
6 | 9008 | ff:ff:ff:ff:ff:ff | 20 | 2 | POP_VLAN, OUTPUT:3 | |||
6 | 9006 | 33:33:00:00:00:00/ff:ff:00:00:00:00 | 10 | 3 | POP_VLAN, OUTPUT:1 | |||
6 | 9006 | 33:33:00:00:00:00/ff:ff:00:00:00:00 | 10 | 1 | POP_VLAN, OUTPUT:3 | |||
6 | 9006 | 33:33:00:00:00:00/ff:ff:00:00:00:00 | 20 | 3 | POP_VLAN, OUTPUT:2 | |||
6 | 9006 | 33:33:00:00:00:00/ff:ff:00:00:00:00 | 20 | 2 | POP_VLAN, OUTPUT:3 | |||
6 | 9004 | 01:00:5e:00:00:00/ff:ff:ff:00:00:00 | 10 | 3 | POP_VLAN, OUTPUT:1 | |||
6 | 9004 | 01:00:5e:00:00:00/ff:ff:ff:00:00:00 | 10 | 1 | POP_VLAN, OUTPUT:3 | |||
6 | 9004 | 01:00:5e:00:00:00/ff:ff:ff:00:00:00 | 20 | 3 | POP_VLAN, OUTPUT:2 | |||
6 | 9004 | 01:00:5e:00:00:00/ff:ff:ff:00:00:00 | 20 | 2 | POP_VLAN, OUTPUT:3 | |||
6 | 9002 | 01:80:c2:00:00:00/ff:ff:ff:00:00:00 | 10 | 3 | POP_VLAN, OUTPUT:1 | |||
6 | 9002 | 01:80:c2:00:00:00/ff:ff:ff:00:00:00 | 10 | 1 | POP_VLAN, OUTPUT:3 | |||
6 | 9002 | 01:80:c2:00:00:00/ff:ff:ff:00:00:00 | 20 | 3 | POP_VLAN, OUTPUT:2 | |||
6 | 9002 | 01:80:c2:00:00:00/ff:ff:ff:00:00:00 | 20 | 2 | POP_VLAN, OUTPUT:3 | |||
6 | 9000 | 10 | 3 | POP_VLAN, OUTPUT:1 | Tráfico recibido en puerto 3 se elimina etiqueta 10 se envía por puerto 1 | |||
6 | 9000 | 10 | 1 | POP_VLAN, OUTPUT:3 | Tráfico recibido en puerto 1 se elimina etiqueta 10 se envía por puerto 1 | |||
6 | 9000 | 20 | 3 | POP_VLAN, OUTPUT:2 | Tráfico recibido en puerto 3 se elimina etiqueta 20 se envía por puerto 2 | |||
6 | 9000 | 20 | 2 | POP_VLAN, OUTPUT:3 | Tráfico recibido en puerto 2 se elimina etiqueta 20 se envía por puerto 3 | |||
6 | 0 | None (DROP) |