Hi, Following is the code for ARP Reply. logger = logging.getLogger('nox.coreapps.examples.pyswitch')
# Global pyswitch instance inst = None # Timeout for cached MAC entries CACHE_TIMEOUT = 1000 # -- # Given a ARP Request, Send ARP Response # -- def send_arp_reply(dp, packet, inport): # Grab the arp hdrs of the rcvd pkt reqh = packet.find('arp') logger.debug("send arp reply") # Create the arp packet and fill in the info replyh = arp() replyh.hwsrc = mac_to_int('\x44\x87\xfc\x4e\x67\x69') replyh.hwdst = reqh.hwsrc replyh.hwlen = reqh.hwlen replyh.opcode = arp.REPLY replyh.protolen = reqh.protolen replyh.protosrc = strToIp("192.168.0.100") replyh.protodst = reqh.protosrc replyh.prototype = arp.PROTO_TYPE_IP # Create the ethernet packet, fill in the info and set as payload the arp # packet replypkt = ethernet() replypkt.set_payload(replyh) replypkt.type = ethernet.ARP_TYPE replypkt.src = mac_to_int('\x44\x87\xfc\x4e\x67\x69') replypkt.dst = packet.src logger.debug("arp pkt %s" % str(replypkt)) # Send the arp reply out the same switch that recvd the request and out the # port from which the REQUEST was rcvd inst.send_openflow_packet(dp, replypkt.__str__(), inport) print "ARP Reply sent..." # -- # Given a packet, learn the source and peg to a switch/inport # -- def do_l2_learning(dpid, inport, packet): global inst # Check whether ARP REQUEST or not if packet.type == ethernet.ARP_TYPE: arph = packet.find('arp') print "ARP Packet source is", (ipToStr(arph.protosrc) == "192.168.0.56") print "ARP Packet destination is", (ipToStr(arph.protodst) == "192.168.0.50") # packet drop # Generate ARP Response with destination MAC of controller if(arph.opcode == arp.REQUEST and ipToStr(arph.protodst) == "192.168.0.50"): send_arp_reply(dpid, packet, inport) # learn MAC on incoming port srcaddr = packet.src.tostring() if ord(srcaddr[0]) & 1: return if inst.st[dpid].has_key(srcaddr): dst = inst.st[dpid][srcaddr] if dst[0] != inport: log.msg('MAC has moved from '+str(dst)+'to'+str(inport), system='pyswitch') else: return else: log.msg('learned MAC '+mac_to_str(packet.src)+' on %d %d'% (dpid,inport), system="pyswitch") # learn or update timestamp of entry inst.st[dpid][srcaddr] = (inport, time(), packet) # Replace any old entry for (switch,mac). mac = mac_to_int(packet.src) From: Kyriakos Zarifis [mailto:kyr.zari...@gmail.com] Sent: Tuesday, November 15, 2011 12:23 AM To: Harshil Anil Kumar Shah Cc: nox-dev@noxrepo.org Subject: Re: [nox-dev] Not able to send ARP Reply Hello, How exactly did you figure out that the ARP is not received? Id try the following troubleshooting steps to see where the problem is: Did you try to use wireshark to see how far you ARP packet goes? Is it actually sent out the controller interface? (it probably is) Is it being received on the switch interface? (this might not be true, depending on how you constructed the ARP) If yes, is it properly formed? Can the switch process it and install an arp entry from it? (you could also paste the code where you construct/send the ARP) On Mon, Nov 14, 2011 at 5:05 AM, Harshil Anil Kumar Shah <harshil_s...@infosys.com<mailto:harshil_s...@infosys.com>> wrote: Hi, Currently, I am trying to send ARP Reply to my openflow switch from NOX-0.8. In the debug message it shows that ARP Reply is sent and also shows the packet information. But I am not able to receive it on my openflow switch. What can be the solution? Thanks in advance. Regards, Harshil Shah, Convergence Lab, Infosys Labs Infosys | Bangalore Mob # : +91 97428 87966<tel:%2B91%2097428%2087966>. **************** CAUTION - Disclaimer ***************** This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system. ***INFOSYS******** End of Disclaimer ********INFOSYS*** _______________________________________________ nox-dev mailing list nox-dev@noxrepo.org<mailto:nox-dev@noxrepo.org> http://noxrepo.org/mailman/listinfo/nox-dev
_______________________________________________ nox-dev mailing list nox-dev@noxrepo.org http://noxrepo.org/mailman/listinfo/nox-dev