def arp_forwarding(self, domain, msg, arp_pkt): datapath = msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser arp_src_ip = arp_pkt.src_ip arp_dst_ip = arp_pkt.dst_ip domain_id = self.get_host_location(arp_dst_ip) if domain_id: # build packet_out pkt and put it into sbp, send to domain domain = self.domains[domain_id] out = utils._build_packet_out(datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, ofproto.OFPP_LOCAL, msg.data) out.serialize() sbp_pkt = domain.oxproto_parser.OXPSBP(domain, data=out.buf) domain.send_msg(sbp_pkt) else: # access info is not existed. send to all UNknow access port for domain in self.domains.values(): out = utils._build_packet_out(datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, ofproto.OFPP_LOCAL, msg.data) out.serialize() sbp_pkt = domain.oxproto_parser.OXPSBP(domain, data=out.buf) domain.send_msg(sbp_pkt)
def arp_forwarding(self, domain, msg, arp_pkt): datapath = msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser arp_src_ip = arp_pkt.src_ip arp_dst_ip = arp_pkt.dst_ip domain_id = self.get_host_location(arp_dst_ip) if domain_id: # build packet_out pkt and put it into sbp, send to domain domain = self.domains[domain_id] out = utils._build_packet_out( datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, ofproto.OFPP_LOCAL, msg.data ) out.serialize() sbp_pkt = domain.oxproto_parser.OXPSBP(domain, data=out.buf) domain.send_msg(sbp_pkt) else: # access info is not existed. send to all UNknow access port for domain in self.domains.values(): out = utils._build_packet_out( datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, ofproto.OFPP_LOCAL, msg.data ) out.serialize() sbp_pkt = domain.oxproto_parser.OXPSBP(domain, data=out.buf) domain.send_msg(sbp_pkt)
def arp_forwarding(self, msg, src_ip, dst_ip): datapath = msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser # dst in other domain, send to super and return. if dst_ip in self.outer_hosts: if isinstance(msg, parser.OFPPacketIn): self.network_aware.raise_sbp_packet_in_event( msg, ofproto_v1_3.OFPP_LOCAL, msg.data) return # host in domain. result = self.get_host_location(dst_ip) if result: # host record in access table. datapath_dst, out_port = result[0], result[1] datapath = self.datapaths[datapath_dst] out = utils._build_packet_out(datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, out_port, msg.data) datapath.send_msg(out) else: self.flood(msg) # we can not send arp to super every time. if isinstance(msg, parser.OFPPacketIn): self.network_aware.raise_sbp_packet_in_event( msg, ofproto_v1_3.OFPP_LOCAL, msg.data) # packet_out from super, record src. if isinstance(msg, parser.OFPPacketOut): for sw in self.access_table: if src_ip in self.access_table[sw]: return self.outer_hosts.add(src_ip)
def sbp_packet_out_handler(self, ev): msg = ev.msg domain = ev.domain pkt = packet.Packet(msg.data) arp_pkt = pkt.get_protocol(arp.arp) ip_pkt = pkt.get_protocol(ipv4.ipv4) eth_type = pkt.get_protocols(ethernet.ethernet)[0].ethertype if msg.actions[0].port == ofproto_v1_3.OFPP_LOCAL: if isinstance(arp_pkt, arp.arp): self.router.arp_forwarding(msg, arp_pkt.src_ip, arp_pkt.dst_ip) #save msg.data for flow_mod. elif isinstance(ip_pkt, ipv4.ipv4): self.buffer[(eth_type, ip_pkt.src, ip_pkt.dst)] = msg.data else: # packet_out to datapath:port. vport = msg.actions[0].port dpid, port = self.network.vport[vport] datapath = self.router.datapaths[dpid] ofproto = datapath.ofproto out = utils._build_packet_out(datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, port, msg.data) #save msg.data for flow_mod. if isinstance(ip_pkt, ipv4.ipv4): self.buffer[(eth_type, ip_pkt.src, ip_pkt.dst)] = msg.data datapath.send_msg(out)
def flood(self, msg): datapath = msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser for dpid in self.access_ports: for port in self.access_ports[dpid]: if (dpid, port) not in self.access_table.keys(): datapath = self.datapaths[dpid] out = utils._build_packet_out( datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, port, msg.data) datapath.send_msg(out)
def flood(self, msg): datapath = msg.datapath ofproto = datapath.ofproto parser = datapath.ofproto_parser for dpid in self.access_ports: for port in self.access_ports[dpid]: if (dpid, port) not in self.access_table.keys(): datapath = self.datapaths[dpid] out = utils._build_packet_out(datapath, ofproto.OFP_NO_BUFFER, ofproto.OFPP_CONTROLLER, port, msg.data) datapath.send_msg(out)