def install_routing_path(self, path, msg): """ Set the flow tables for the new routing path and forward the message """ if path != None: pck = packet.Packet(msg.data) eth = pck.get_protocol(ethernet.ethernet) src = eth.src dst = eth.dst # build match from msg match = CustomOFPMatch.build_from_msg(msg) print "DEBUG: build match from msg:/n", match # exclude in the loop the last node in the path because it is an host for i in range( len(path)-2, -1, -1 ): node = path[i] out_port = self.get_next_out_port(path, node) datapath = self.dp_ref_dict.get(node) actions = [parser13.OFPActionOutput(out_port)] of_func.ofAddFlow(datapath = datapath, match = match, actions = actions, idle_timeout = self.IDLE_TIME_OUT, buffer_id = msg.buffer_id)
def _init_switch_oftable(self, datapath): # drop arp requests to avoid arp storm match_arp_req = parser13.OFPMatch(eth_type = ETH_TYPE_ARP, arp_op = ARP_REQUEST) actions_arp_req = [] of_tb_func.ofAddFlow(datapath, match_arp_req, actions_arp_req) # forward arp replies to the controller match_arp_rep = parser13.OFPMatch(eth_type = ETH_TYPE_ARP, arp_op = ARP_REPLY) actions_arp_rep = [parser13.OFPActionOutput(ofproto13.OFPP_CONTROLLER, ofproto13.OFPCML_NO_BUFFER)] of_tb_func.ofAddFlow(datapath, match_arp_rep, actions_arp_rep)
def _init_switch_oftable(self, ev): datapath = ev.msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser # install table-miss flow entry # NO BUFFER option set match = parser.OFPMatch() actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER, ofproto.OFPCML_NO_BUFFER)] of_func.ofAddFlow(datapath, match, actions, priority = 0)
def setup_flowtable(self, ev): datapath = ev.msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser # install table-miss flow entry # NO BUFFER option set match = parser.OFPMatch() actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER)] #TODO set buffer on the switched priority = TABLE_MISS_PRIORITY of_func.ofAddFlow(datapath, match, actions, priority)
def broadcast_arp(self): switch_list = get_switch(self, None) # modify flows to drop temporarily arp request match = parser13.OFPMatch(eth_dst = BROADCAST_STR, eth_type = ETH_TYPE_ARP) actions = [] for switch in switch_list: of_func.ofAddFlow(switch.dp, match, actions, self.ARP_BROADCAST_PRIORITY) for switch in switch_list: of_func.ofPckOut(self.current_msg, ofproto13.OFPP_FLOOD) # del flows to drop arp request for switch in switch_list: of_func.ofDelFlow(switch.dp, match, self.ARP_BROADCAST_PRIORITY)