FWIW, this is currently the way to send ARP packets, meaning you'd have to construct them manually (as is the case with most packets - there are not too many utility functions. It's not clear whether a higher-level API would be helpful as there are many different constructions for a packet and we might end up with too many utility functions, probably with many passed variables, which could be equally confusing as having to construct a packet manually )
On Wed, Feb 16, 2011 at 3:01 PM, Niky Riga <[email protected]> wrote: > [I have typed this email for a while but was distracted before actually > sending it, I see that in the meantime Ali already sent some very similar > code, I am sending mine just as a reference as well] > > Sure, if it would help here is the code. > It's in python, and I wrote it against the zaku release. > I am sure this is not the best way to do this and it's definitely not > bulletproof. I just needed a quick way to test this capability for an > experiment. > > Cheers, > Niky > > MAC_ADDR = "00:00:00:00:00:01" > IP_ADDR = ""10.100.1.200" > > > if packet.type == ethernet.ARP_TYPE: > if (ip_to_str(arph.protodst) == IP_ADDR and > arph.opcode == arp.REQUEST) : > arph = packet.find('arp') > if (arph.opcode == arp.REQUEST) : > send_arp_reply(dpid, packet, inport) > > # Fxn that send an arp reply > # INPUT > # - dpid : the dpid that sent up the ARP REQUEST > # - reqpkt : the rcvd ARP REQUEST packet > # - inport : the port where the ARP REQUEST can from > def send_arp_reply(dpid, reqpkt, inport) : > # Grab the arp hdrs of the rcvd pkt > reqh = reqpkt.find('arp') > logger.debug("send arp reply") > # Create the arp packet and fill in the info > replyh = arp() > replyh.hwsrc = octstr_to_array(MAC_ADDR) > replyh.hwdst = reqh.hwsrc > replyh.hwlen = reqh.hwlen > replyh.opcode = arp.REPLY > replyh.protolen = reqh.protolen > replyh.protosrc = reqh.protodst > replyh.protodst = reqh.protosrc > > # 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 = octstr_to_array(MAC_ADDR) > replypkt.dst = reqpkt.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(dpid, replypkt.tostring(), inport) > > > On 2/16/11 4:29 PM, kk yap wrote: > >> Hi, >> >> There are many ways to do this and none of this is particularly more >> appealing. If you are using Python, you can try dpkt or scapy. >> Handcrafting it is not that bad for ARP either. If you are using >> C/C++, I do not know of nice libraries to use here so anyone who has >> any idea can educate me too. >> >> In general, you can craft all sort of packets in NOX and it is not >> clear than NOX is responsible for support that. >> >> Regards >> KK >> >> On 16 February 2011 13:20, Bob Lantz<[email protected]> wrote: >> >>> Generating ARPs in OpenFlow is a frequently encountered problem (a >>> FEP?)!! And how to do so conveniently and correctly might be something of >>> what I call a FABNAQ - a Frequently Asked But Never (or rarely adequately) >>> Answered Question. (FABNAQs are great because they generate lots of Google >>> results which don't actually answer the question.) >>> >>> So, if you have working code to generate correct ARP replies, I think >>> sending it to the list would be helpful for posterity! >>> >>> Also, for NOX developers - what is the preferred easy way to generate ARP >>> packets? If it's not simple or convenient, is there a way to make it more >>> so? >>> >>> -Bob >>> >>> On Feb 16, 2011, at 12:18 PM, Niky Riga wrote: >>> >>> Hi Aaron, >>>> >>>> that might not be an issue at all, but I don't see in your code where >>>> you set the ethernet headers (basically the src and dst) for the arp reply. >>>> >>>> If you want, I have some code that I wrote a while back to send arp >>>> replies, that seemed to work as expected. I can forward it along if this is >>>> helpful. >>>> >>>> --niky >>>> >>>> On 2/16/11 2:59 PM, Aaron Rosen wrote: >>>> >>>>> Hello, >>>>> >>>>> I'm trying to send arp replies from my nox controller though for some >>>>> reason my packets don't seem to be getting sent out and I was hoping >>>>> someone could point out where I'm going wrong. This is the code I >>>>> have: >>>>> >>>>> if packet.type == ethernet.ARP_TYPE: >>>>> arppacket = arp.arp(packet.next.arr, packet.next.prev) >>>>> if arppacket.opcode == arppacket.REQUEST: >>>>> tmp_dst = arppacket.protodst >>>>> arppacket.protodst = arppacket.protosrc >>>>> arppacket.protosrc = tmp_dst >>>>> arppacket.hwdst = arppacket.hwsrc >>>>> arppacket.hwsrc = >>>>> mac_to_int('\xd2\x85\xde\x8e\xf6\x13') >>>>> arppacket.opcode = arppacket.REPLY >>>>> packet.next = arppacket; >>>>> self.send_openflow(dpid, None, packet.arr, >>>>> openflow.OFPP_FLOOD, inport); >>>>> print "ARP REPLY SEND!!" >>>>> return CONTINUE >>>>> >>>>> When I run tcpdump on the node that is sending the requests I does not >>>>> see any of these packets. >>>>> >>>>> I'm trying to look at my openflow traffic with wireshark but for some >>>>> reason I'm not seeing any. Though at my controller I'm definitely >>>>> getting the packets. (I think this may because I'm using mininet? I've >>>>> tried all the interfaces on my machine in wireshark). Though when I >>>>> try this using the Openflow Tutorial provided VM i'm also not seeing >>>>> any 'of' packets in wireshark there? (Any idea why)? >>>>> >>>>> Thanks, >>>>> >>>>> Aaron >>>>> >>>>> >>>>> >>>>> >>>> _______________________________________________ >>>> nox-dev mailing list >>>> [email protected] >>>> http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org >>>> >>> >>> >>> _______________________________________________ >>> nox-dev mailing list >>> [email protected] >>> http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org >>> >>> > _______________________________________________ > nox-dev mailing list > [email protected] > http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org >
_______________________________________________ nox-dev mailing list [email protected] http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org
