So the parameters for the packet_in callback are: dpid, inport, reason, len,
bufid, packet
The last one is an "ethernet" object from src/nox/lib/packet/ethernet.py. For
IP packets, this ethernet object will then reference an ipv4 object which then
might reference a tcp object. So for example, you might write something like:
def packet_in_callback (dpid, inport, reason, len, bufid, packet):
ip = packet.find("ipv4")
if ip is not None:
tcp = ip.find("tcp")
if tcp is not None:
print "%s:%i -> %s:%i" % (ip.srcip, tcp.srcport, ip.dstip, tcp.dstport)
(Apologies if that doesn't just work; I didn't try it and my NOX is getting a
little rusty.)
Hopefully that'll get you started.
-- Murphy
On Feb 4, 2012, at 6:58 AM, Gabe Bassett wrote:
>
> Please see the question below. If you can point me in the right direction,
> I’d appreciate it!
>
> Gabe
>
> From: Gabe Bassett
> Sent: Friday, February 03, 2012 5:55 PM
> To: 'yap...@stanford.edu'
> Subject: Nox question
>
> Hi,
> I’m trying to learn openflow by building on the nox switch tutorial (as well
> as learning python in the process). Could you help me with a quick question?
>
> What is the best way to access the Source and Destination IP addresses and
> Ports?
>
> Is there any way to reference it with just the information passed to the
> register_for_packet_in() event handler that gets passed through
> packet_in_callback to learn_and_forward?
>
> Thanks for the help.
>
> Gabe
> ___
> nox-dev mailing list
> 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