基于OpenFlow协议的分流聚合基础应用笔记实验一:一对多实验将1个10G端口的流量镜像至5个端口的配置如下。同样配置方法可应用于更多的端口。注:Pica8交换机同时支持传统的2-3层协议和OpenFlow协议,本实验中交换机均配置为OpenFlow模式;首先我们创建一个新的Bridgebr0,并将端口1-6添加到br0;#AddBridgebr0-forPCAPReplication-1stPort###############################te-1/1/1isinputte-1/1/2,te-1/1/3,te-1/1/4,te-1/1/5,te-1/1/6areoutput#-------------------------------------------------------------------------------------$VSCTLadd-brbr0--setbridgebr0datapath_type=pica8other-config=datapath-id=100$VSCTLadd-portbr0te-1/1/1--setinterfacete-1/1/1type=pica8$VSCTLadd-portbr0te-1/1/2--setinterfacete-1/1/2type=pica8$VSCTLadd-portbr0te-1/1/3--setinterfacete-1/1/3type=pica8$VSCTLadd-portbr0te-1/1/4--setinterfacete-1/1/4type=pica8$VSCTLadd-portbr0te-1/1/5--setinterfacete-1/1/5type=pica8$VSCTLadd-portbr0te-1/1/6--setinterfacete-1/1/6type=pica8然后我们移除默认的流保证各端口按照新的指令工作;最后我们将镜像流量出端口的ingress流量全部丢弃;#RemoveDefaultFlow(nottreatingthisasHUB!)ovs-ofctldel-flowsbr0#Addreplicationflow1-2,3,4,5,6ovs-ofctladd-flowbr0in_port=1,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=output:2,3,4,5,6最后我们将镜像流量出端口的ingress流量全部丢弃;#Dropingresstrafficfrommirrorportsovs-ofctladd-flowbr0in_port=2,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=dropovs-ofctladd-flowbr0in_port=3,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=dropovs-ofctladd-flowbr0in_port=4,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=dropovs-ofctladd-flowbr0in_port=5,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=dropovs-ofctladd-flowbr0in_port=6,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=drop实验二:TapAggregation实验在实验一的基础上我们将四个端口的流量bridge到一起,并且mirror至其他端口;idgebr20-forTAPSpan-1stPort########################################################################################Bridged:te-1/1/21,te-1/1/22,te-1/1/23,te-1/1/24#Output:te-1/1/25,te-1/1/26,te-1/1/27,te-1/1/28#-------------------------------------------------------------------------------------$VSCTLadd-brbr20--setbridgebr20datapath_type=pica8other-config=datapath-id=120$VSCTLadd-portbr20te-1/1/21--setinterfacete-1/1/21type=pica8$VSCTLadd-portbr20te-1/1/22--setinterfacete-1/1/22type=pica8$VSCTLadd-portbr20te-1/1/23--setinterfacete-1/1/23type=pica8$VSCTLadd-portbr20te-1/1/24--setinterfacete-1/1/24type=pica8$VSCTLadd-portbr20te-1/1/25--setinterfacete-1/1/25type=pica8$VSCTLadd-portbr20te-1/1/26--setinterfacete-1/1/26type=pica8$VSCTLadd-portbr20te-1/1/27--setinterfacete-1/1/27type=pica8$VSCTLadd-portbr20te-1/1/28--setinterfacete-1/1/28type=pica8#RemoveDefaultFlow(nottreatingthisasHUB!)ovs-ofctldel-flowsbr20#Addreplicationflowfromeachbridgedporttoeachoftheotherportsinthegroupovs-ofctladd-flowbr20in_port=21,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=output:22,23,24,25,26,27,28ovs-ofctladd-flowbr20in_port=22,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=output:21,23,24,25,26,27,28ovs-ofctladd-flowbr20in_port=23,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=output:21,22,24,25,26,27,28ovs-ofctladd-flowbr20in_port=24,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=output:21,22,23,25,26,27,28#Dropingresstrafficfrommirrorportsovs-ofctladd-flowbr20in_port=25,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=dropovs-ofctladd-flowbr20in_port=26,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=dropovs-ofctladd-flowbr20in_port=27,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=dropovs-ofctladd-flowbr20in_port=28,dl_dst=*,dl_src=*,dl_type=*,dl_vlan_pcp=*,dl_vlan=*,actions=drop【编辑推荐】1.Openflow交换机的应用模式探讨2.OpenFlow的前世今生