2019 SDN上机第2次作业
Part1. 创建拓扑
1. 利用mininet创建如下拓扑,要求拓扑支持OpenFlow 1.3协议,主机名、交换机名以及端口对应正确,请给出拓扑Mininet执行结果,展示端口连接情况
(1)建立拓扑
(2)使用net命令查看拓扑
(3)使用pingall命令测试所有节点连通性
Part2. 发流表
2. 直接在Open vSwitch下发流表,用vlan得到下列虚拟网段,请逐条说明所下发的流表含义
• h1 -- h4互通
• h2 -- h5互通
• h3 -- h6互通
• 其余主机不通
添加流表代码
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output:4
add-flow:添加流表
OpenFlow13:版本号 OpenFlow1.3
s1:交换机
priority=1:优先级
in_port=1:输入端口s1的1端口
actions:动作(push_vlan)
set_field:4096->vlan_vid(4096==0),Vlan 0 标签
output:输出端口为s1的4端口
去标签转发代码
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=0,actions=pop_vlan,output:1
(1)将主机1,2,3进入s1的包打上不同的vlan tag,转发端口4
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output:4
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097-\>vlan_vid,output:4
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098-\>vlan_vid,output:4
将进入s1端口4的包去除vlan tag, 并根据tag转发至主机1、2、3
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=0,actions=pop_vlan,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=1,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s1 priority=1,dl_vlan=2,actions=pop_vlan,output:3
(2)将主机4,5,6进入s2的包打上不同的vlan tag,转发端口4
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=1,actions=push_vlan:0x8100,set_field:4096-\>vlan_vid,output:4
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=2,actions=push_vlan:0x8100,set_field:4097-\>vlan_vid,output:4
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,in_port=3,actions=push_vlan:0x8100,set_field:4098-\>vlan_vid,output:4
将进入s2端口4的包去除vlan tag, 并根据tag转发至主机4、5、6
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=0,actions=pop_vlan,output:1
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=1,actions=pop_vlan,output:2
sudo ovs-ofctl -O OpenFlow13 add-flow s2 priority=1,dl_vlan=2,actions=pop_vlan,output:3
实验截图
Part3. 查看流表
3. 直接在Open vSwitch查看流表,提交OVS命令执行结果
交换机流表查看代码:
sudo ovs-ofctl -O OpenFlow13 dump-flows s1
sudo ovs-ofctl -O OpenFlow13 dump-flows s2
(1)交换机s1的流表查看
(2)交换机s2的流表查看
Part4. 连通性测试
4. 提交主机连通性测试结果,验证流表的有效性
Part5. Wireshark抓包
5. 利用Wireshark抓包,分析验证特定报文
(1)打开wireshark
sudo wireshark
(2)启动捕获,同时pingall
(3)添加过滤条件vlan,便可抓到802.1q帧