h1 ping h2
h3 能收到数据包
h1 ping h3
h2能收到数据包
h1 ping h2
h3 不能收到数据包h1 ping h3
h2 不能收到数据包from pox.core import core import pox.openflow.libopenflow_01 as of from pox.openflow.of_json import * class SendFlowInSingle3(object): def __init__ (self): core.openflow.addListeners(self) def _handle_ConnectionUp(self, event): msg = of.ofp_flow_mod() msg.priority = 1 msg.match.in_port = 1 msg.actions.append(of.ofp_action_output(port=2)) msg.actions.append(of.ofp_action_output(port=3)) event.connection.send(msg) msg = of.ofp_flow_mod() msg.priority = 1 msg.match.in_port = 2 msg.actions.append(of.ofp_action_output(port=1)) msg.actions.append(of.ofp_action_output(port=3)) event.connection.send(msg) msg = of.ofp_flow_mod() msg.priority = 1 msg.match.in_port = 3 msg.actions.append(of.ofp_action_output(port=1)) msg.actions.append(of.ofp_action_output(port=2)) event.connection.send(msg) def launch(): core.registerNew(SendFlowInSingle3)