Tutorial Mininet
Tutorial Mininet
Tutorial Mininet
Introducción
http://mirror.pop-rs.rnp.br/openflow/vm-mininetut.ova
• En el LAB-Universidad de Cuenca
Acender a la carpeta
\\172.16.48.2\install-arq\CursoOpenflow\
USUARIO: Administrador
CONTRASENHA: Dfeuc2012
X11
• Si esta ejecutando la machina virtual en
Windows o Linux necesita instalar el X11 o otro
X-Manager
O…
Vá al menú File, y
seleccionar la
opción import y en
el menu seguiente,
seleccionar la
imagen .ova
descargada, y
selecione next.
Vm-mininet
Selecione a opção
import e espere até
que a importação
seja concluida.
Si quiera ponga
más memoria RAM
Configuraciones iniciales
Virtual Box:
Antes de poner en marcha la máquina
Configuraciones iniciales
• Inicie la VM
Hx → Host
Sx → Switch
Cx → Controller
$ → comando en shell
# → comandos como root
Mininet> → comandos dentro de mininet
Utilizando Mininet
$Sudo mn
Inicia mininet con una topología
default con 1 switch, 1
controlador y 2 hosts.
Single
Linear
Tree
Sudo ~/mininet/examples/miniedit.py
Aplicaciones gráficas
Sudo ~/mininet/examples/consoles.py
Switch
User space
Switch implementado en
userspace, pasa entre el modo
usuario y el kernel a cada salto.
switch
Openvswitch:
Para ejecutarlo:
$./nox_core -v -i ptcp: “porta” “nome_do_modelo”
elif dpid == 4:
if ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.9':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'] }
actions = [[openflow.OFPAT_OUTPUT, [0, 5]]]
if ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.7':
flow = { NW_DST : extract_flow(packet)['nw_dst'] }
actions = [[openflow.OFPAT_OUTPUT, [0, 3]]]
Código usado
} se switch = 4 {
se ip_destino = 10.0.0.9, out_port = 5
se ip origem 10.0.0.9 {
se ip_destino = 10.0.0.7,entonces out_port = 3
se ip_destino = 10.0.0.8,entonces out_port = 4
se ip_destino = 10.0.0.5,entonces out_port = 1
se ip_destino = 10.0.0.6,entonces out_port = 2
if ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.8':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'] }
actions = [[openflow.OFPAT_OUTPUT, [0, 4]]]
if ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.5':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'] }
actions = [[openflow.OFPAT_OUTPUT, [0, 1]]]
if ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.6':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'] }
actions = [[openflow.OFPAT_OUTPUT, [0, 2]]]
Código usado
se in_port = 1 e ip_destino = 10.0.0.7,entonces out_port = 3
se in_port = 3 e ip_destino = 10.0.0.5,entonces out_port = 1
se in_port = 2 e ip_destino = 10.0.0.8,entonces out_port = 4
se in_port = 4 e ip_destino = 10.0.0.6,entonces out_port = 2
caso contrario envía un paquete para todas las puertas
retorna da funcion
}
instala los flujos elif inport == 1 and ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.7':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'], core.IN_PORT : 1 }
actions = [[openflow.OFPAT_OUTPUT, [0, 3]]]
elif inport == 3 and ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.5':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'], core.IN_PORT : 3 }
actions = [[openflow.OFPAT_OUTPUT, [0, 1]]]
elif inport == 2 and ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.8':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'], core.IN_PORT : 2 }
actions = [[openflow.OFPAT_OUTPUT, [0, 4]]]
elif inport == 4 and ip_to_str(extract_flow(packet)['nw_dst']) == '10.0.0.6':
flow = { core.NW_DST : extract_flow(packet)['nw_dst'], core.IN_PORT : 4 }
actions = [[openflow.OFPAT_OUTPUT, [0, 2]]]
Código usado
se in_port = 1 e ip_destino = 10.0.0.7,entonces out_port = 3
se in_port = 3 e ip_destino = 10.0.0.5,entonces out_port = 1
se in_port = 2 e ip_destino = 10.0.0.8,entonces out_port = 4
se in_port = 4 e ip_destino = 10.0.0.6,entonces out_port = 2
caso contrario envía un paquete para todas las puertas
retorna de la función
}
instala los flujos
else
inst.send_openflow(dpid, bufid, buf, openflow.OFPP_FLOOD, inport)
return
inst.install_datapath_flow(dpid, flow, CACHE_TIMEOUT,
openflow.OFP_FLOW_PERMANENT, actions,
bufid, prioridade,
inport, buf)
Fluxos dpctl
s1 dpctl add-flow tcp:127.0.0.1:6634 in_port=1,priority=1,idle_timeout=0,actions=output:3
s1 dpctl add-flow tcp:127.0.0.1:6634 in_port=3,priority=1,idle_timeout=0,actions=output:1
s1 dpctl add-flow tcp:127.0.0.1:6634 in_port=2,priority=1,idle_timeout=0,actions=output:4
s1 dpctl add-flow tcp:127.0.0.1:6634 in_port=4,priority=1,idle_timeout=0,actions=output:2
s2 dpctl add-flow tcp:127.0.0.1:6635 in_port=1,priority=1,idle_timeout=0,actions=output:2
s2 dpctl add-flow tcp:127.0.0.1:6635 in_port=2,priority=1,idle_timeout=0,actions=output:1
s3 dpctl add-flow tcp:127.0.0.1:6636 in_port=1,priority=1,idle_timeout=0,actions=output:2
s3 dpctl add-flow tcp:127.0.0.1:6636 in_port=2,priority=1,idle_timeout=0,actions=output:1
s4 dpctl add-flow tcp:127.0.0.1:6637 ip,nw_dst=10.0.0.9,priority=10,idle_timeout=0,actions=output:5
s4 dpctl add-flow tcp:127.0.0.1:6637
in_port=1,idle_timeout=1200,priority=1,idle_timeout=0,actions=output:3
s4 dpctl add-flow tcp:127.0.0.1:6637
in_port=3,idle_timeout=1200,priority=1,idle_timeout=0,actions=output:1
s4 dpctl add-flow tcp:127.0.0.1:6637 in_port=2,idle_timeout=0,priority=1,actions=output:4
s4 dpctl add-flow tcp:127.0.0.1:6637 in_port=4,idle_timeout=0,priority=1,actions=output:2
s4 dpctl add-flow tcp:127.0.0.1:6637
ip,nw_src=10.0.0.9,nw_dst=10.0.0.5,priority=10,idle_timeout=0,actions=output:1
s4 dpctl add-flow tcp:127.0.0.1:6637
ip,nw_src=10.0.0.9,nw_dst=10.0.0.6,priority=10,idle_timeout=0,actions=output:2
s4 dpctl add-flow tcp:127.0.0.1:6637
ip,nw_src=10.0.0.9,nw_dst=10.0.0.7,priority=10,idle_timeout=0,actions=output:3
s4 dpctl add-flow tcp:127.0.0.1:6637
ip,nw_src=10.0.0.9,nw_dst=10.0.0.8,priority=10,idle_timeout=0,actions=output:4
Exercício
http://yuba.stanford.edu/foswiki/bin/view/
OpenFlow/Mininet
http://www.openflow.org/wk/index.php/
OpenFlow_Tutorial
Dudas?