Skip to content
Murphy McCauley edited this page Mar 8, 2012 · 1 revision

General

All of the packet processing code is in nox/lib/packet/.

In general you can iterate over the packet headers using .next. So packet.next should be the IP header. packet.next.next the tcp header and so on. Note that if VLANs are in play, they'll come in as an additional header.

Alternatively, if you know what type of packet you have, you can also use the protocol name (rather than next)

my_iphdr = packet.ip


Authenticator

One way to get the location of a MAC is to call authenticator::get_dl_addr_entry()

The returned DLEntry should contain all known locations for that address.


Routing

Other applications can also ask the routing module for a specific route using the “get_route” method.


Topology

pytopology has a method get_outlinks thats takes a source datapathid and destination datapathid, and returns a list of all of the port pairs that are connected. This is defined in pytopology.i

For example:

if datapath 1's ports 5 and 6 are connected to datapath 2's ports 3 and 4 respectively, you would have the following.

from nox.lib.netinet.netinet import create_datapathid_from_host

dp1 = create_datapathid_from_host(1) dp2 = create_datapathid_from_host(2) ports = pytop.get_outlinks(dp1, dp2)

where ports would be a list of PyLinkPorts of length 2, where PyLinkPorts is described in that pytopology.i file. Particularly it would be the equivalent of [(5,] , however it's actually a SWIG-ed out list, which needs to be iterated through using begin(), incr(), and end().


Generating events in python

http://www.mail-archive.com/nox-dev@noxrepo.org/msg00919.html

Clone this wiki locally