def _send_arp_req(self, datapath): pkt = packet.Packet() pkt.add_protocol( ethernet.ethernet( ethertype = ETH_TYPE_ARP, src = BROADCAST_STR, dst = BROADCAST_STR) ) pkt.add_protocol( arp.arp( opcode = ARP_REQUEST, src_mac = '01:02:03:04:05:06', src_ip = '192.168.0.1', dst_mac = BROADCAST_STR, dst_ip = '255.255.255.255') ) of_tb_func.ofSendPck(datapath, pkt, ofproto13.OFPP_FLOOD)
def _probe_switch(self, ev): datapath = ev.switch.dp #datapath = ev.datapath #ofproto = datapath.ofproto #parser = datapath.ofproto_parser self.dp_dict[datapath.id] = datapath #self.setup_flowtable(datapath) for service in self.services_dict.values(): discovery_pkt = ServiceDiscoveryPacket.build_from_service(service) for i in range(0, self.NUM_PROB_PKT): of_func.ofSendPck(datapath, discovery_pkt, ofproto13.OFPP_FLOOD)
def build_arp_reply_from_req(self, arp_req): datapath = self.current_msg.datapath out_port = self.current_msg.match['in_port'] # ip and mac for arp reply sender_ip = arp_req.dst_ip target_ip = arp_req.src_ip target_mac = arp_req.src_mac sender_mac = self.arp_table[sender_ip] pkt = packet.Packet() pkt.add_protocol( ethernet.ethernet( ethertype = ETH_TYPE_ARP, src = sender_mac, dst = target_mac) ) pkt.add_protocol( arp.arp( opcode = ARP_REPLY, src_mac = sender_mac, src_ip = sender_ip, dst_mac = target_mac, dst_ip = target_ip) ) of_func.ofSendPck(datapath, pkt, out_port)