您的位置:首页 > 理论基础 > 计算机网络

SDN,网络

2015-10-07 09:53 756 查看
python pox.py openflow.of_01 --address=192.168.1.28 py

python pox.py openflow.of_01 --address=192.168.1.28 py packet_in

from pox.lib.addresses import IPAddr

from pox.lib.addresses import EthAddr

import random

import pox.openflow.libopenflow_01 as of

core.openflow.connections.keys()

52235814755L

193864321579124L

--

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=2

msg.actions.append(of.ofp_action_output(port=1))

core.openflow.connections[193864321579124L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=1

msg.actions.append(of.ofp_action_output(port=2))

core.openflow.connections[193864321579124L].send(msg)

这两个ping转发可以通,静态ARP,ping本地交换机不通。

root@ubuntu:~# ovs-ofctl dump-flows br0

NXST_FLOW reply (xid=0x4):

 cookie=0x0, duration=221.778s, table=0, n_packets=64, n_bytes=6039, idle_age=22, priority=20,in_port=1 actions=output:2

 cookie=0x0, duration=221.795s, table=0, n_packets=180, n_bytes=20939, idle_age=24, priority=20,in_port=2 actions=output:1

root@ubuntu:~# 

root@ubuntu:~# ovs-dpctl dump-flows system@ovs-system (没有数据,很快就过期)

skb_priority(0),in_port(2),eth(src=00:1d:0f:22:cc:f3,dst=14:e6:e4:2e:73:48),eth_type(0x0800),ipv4(src=192.168.169.200/255.255.255.255,dst=192.168.169.1/255.255.255.255,proto=1/0xff,tos=0/0,ttl=64/0,frag=no/0xff),icmp(type=8,code=0), packets:73, bytes:5402,
used:0.492s, actions:3

skb_priority(0),in_port(3),eth(src=14:e6:e4:2e:73:48,dst=00:1d:0f:22:cc:f3),eth_type(0x0800),ipv4(src=192.168.169.1/255.255.255.255,dst=192.168.169.200/255.255.255.255,proto=1/0xff,tos=0/0,ttl=64/0,frag=no/0xff),icmp(type=0,code=0), packets:73, bytes:5402,
used:0.492s, actions:2

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=1))

core.openflow.connections[52235814755L].send(msg)



msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=1

msg.match.nw_proto=1

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=3))

core.openflow.connections[193864321579124L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=3

msg.match.nw_proto=1

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=1))

core.openflow.connections[193864321579124L].send(msg)



msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=3

msg.match.dl_type = 0x0806

msg.actions.append(of.ofp_action_output(port=1))

core.openflow.connections[193864321579124L].send(msg)

msg.priority=20

msg.match.in_port=1

msg.match.dl_type = 0x0806

msg.actions.append(of.ofp_action_output(port=3))

core.openflow.connections[193864321579124L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=1

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=3))

core.openflow.connections[193864321579124L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=3

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=1))

core.openflow.connections[193864321579124L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=1

msg.match.nw_proto=6

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=3))

core.openflow.connections[193864321579124L].send(msg)



msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=3

msg.match.nw_proto=6

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=1))

core.openflow.connections[193864321579124L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=1

msg.match.nw_proto=17

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=3))

core.openflow.connections[193864321579124L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=20

msg.match.in_port=3

msg.match.nw_proto=17

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=1))

core.openflow.connections[193864321579124L].send(msg)

root@ubuntu:~# ovs-ofctl dump-flows br0

NXST_FLOW reply (xid=0x4):

 cookie=0x0, duration=28.938s, table=0, n_packets=1, n_bytes=60, idle_age=24, priority=20,arp,in_port=1 actions=output:2

 cookie=0x0, duration=28.943s, table=0, n_packets=1, n_bytes=60, idle_age=24, priority=20,arp,in_port=2 actions=output:1

 cookie=0x0, duration=28.962s, table=0, n_packets=0, n_bytes=0, idle_age=28, priority=20,ip,in_port=1 actions=output:2

 cookie=0x0, duration=28.962s, table=0, n_packets=0, n_bytes=0, idle_age=28, priority=20,ip,in_port=2 actions=output:1

root@ubuntu:~# 

root@ubuntu:~# 

root@ubuntu:~# ovs-dpctl dump-flows system@ovs-system

skb_priority(0),in_port(3),eth(src=14:e6:e4:2e:73:48,dst=01:00:5e:7f:ff:fa),eth_type(0x0800),ipv4(src=192.168.169.1/255.255.255.255,dst=239.255.255.250/255.255.255.255,proto=17/0xff,tos=0/0,ttl=4/0,frag=no/0xff),udp(src=1025,dst=1900), packets:13, bytes:4690,
used:0.709s, actions:2

skb_priority(0),in_port(3),eth(src=00:19:e0:76:8c:3f,dst=33:33:00:01:00:02),eth_type(0x86dd),ipv6(src=fe80::a0f4:6601:b22c:79aa/::,dst=ff02::1:2/::,label=0/0,proto=17/0xff,tclass=0/0,hlimit=1/0,frag=no/0xff),udp(src=546,dst=547), packets:0, bytes:0, used:never,
actions:userspace(pid=4294963174,slow_path(controller))

skb_priority(0),in_port(3),eth(src=14:e6:e4:2e:73:48,dst=00:1d:0f:22:cc:f3),eth_type(0x0800),ipv4(src=192.168.169.1/255.255.255.255,dst=192.168.169.200/255.255.255.255,proto=1/0xff,tos=0/0,ttl=64/0,frag=no/0xff),icmp(type=0,code=0), packets:24, bytes:1776,
used:0.001s, actions:2

skb_priority(0),in_port(2),eth(src=00:1d:0f:22:cc:f3,dst=14:e6:e4:2e:73:48),eth_type(0x0800),ipv4(src=192.168.169.200/255.255.255.255,dst=192.168.169.1/255.255.255.255,proto=1/0xff,tos=0/0,ttl=64/0,frag=no/0xff),icmp(type=8,code=0), packets:24, bytes:1776,
used:0.001s, actions:3

root@ubuntu:~# 

这两个ping转发可以通,动态ARP,ping本地交换机不通。

--

msg=of.ofp_flow_mod()

msg.priority=30

msg.match.in_port=1

msg.match.dl_type = 0x0800

msg.actions.append(of.ofp_action_output(port=0xfffa))

core.openflow.connections[52235814755L].send(msg)

msg=of.ofp_flow_mod()

msg.priority=30

msg.match.in_port=1

msg.match.dl_type = 0x0800

msg.match.tcp_src=6633

msg.actions.append(of.ofp_action_output(port=0xfffa))

core.openflow.connections[52235814755L].send(msg)

--

clear flows

msg.in_port=of.OFPP_NONE

msg.in_port=1

msg=of.ofp_flow_mod(command=3)

core.openflow.connections[52235814755L].send(msg)

--

ovs-vsctl set-controller br0 tcp:192.168.0.10:6633

sudo ./tcpdump -s0 -i eth0 port 6633 

sudo ./tcpdump -s0 -i eth0 port 6633 -w of.pcap -c 2000

--
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sdn