Hi,
I have an example which I used in NOX-classic in a Python component, but
I hope it might be useful for you.
In a packet_in handler def handle_packet_in(self, dpid, inport, reason,
length, bufid, packet) I do the following:
if packet.type == ethernet.ARP_TYPE:
arp = packet.find("arp")
if arp.REQUEST:
if not mac_to_str(arp.hwsrc) in self._mactable.keys():
self._mactable[mac_to_str(arp.hwsrc)] = (dpid, inport)
elif arp.REPLY:
if not mac_to_str(arp.hwsrc) in self._mactable.keys():
self._mactable[mac_to_str(arp.hwsrc)] = (dpid, inport)
# FLOOD the ARP Packet
self.send_openflow(dpid, bufid, packet.arr, openflow.OFPP_FLOOD,
inport)
This is a little snippet to build up a mactable which I used in one of
my components.
Hope this helps..
Best regards,
Bernd
On 23.05.2012 18:13, Weiyang Mo wrote:
Hi,
I need NOX to distinguish ARP and UDP packets from a host. Here' the
following:
host- - - - switch - - - NOX
The host trys sending UDP packets which contain speicial payload to
NOX and let NOX does something. The UDP attempt only includes dstip
address of NOX and therefore the host will send ARP request to find
the MAC of NOX and it causes some problems. I want to distinguish ARP
and UDP packets from the host.
If it is an ARP packet, the NOX controller will reply the mac address
to the host (Then the host knows how to send UDP). If it is a UDP
packet, NOX controller will get its payload and do something. I cannot
use "packet.next.srcip" or "packet.nextdstip", it will show no
attributes for ARP packets. And the packet.type or packet.ARP_TYPE
returns a number.
Any code to get the packet type(ARP) or the ARP packet's source and
destination address?
Thanks very much.
Best
Weiyang