Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (FreeBSD-5.4-RELEASE)
Apropos / Subsearch:
optional field

NG_NETFLOW(4)            BSD Kernel Interfaces Manual            NG_NETFLOW(4)

     ng_netflow -- Cisco's NetFlow implementation

     #include <&lt;sys/types.h>&gt;
     #include <&lt;netinet/in.h>&gt;
     #include <&lt;netgraph/netflow/ng_netflow.h>&gt;

     The ng_netflow node implements Cisco's NetFlow export protocol on a
     router running FreeBSD.  The ng_netflow node listens for incoming traffic
     and identifies unique flows in it.  Flows are distinguished by endpoint
     IP addresses, TCP/UDP port numbers, ToS and input interface.  Expired
     flows are exported out of the node in NetFlow version 5 UDP datagrams.
     Expiration reason can be one of the following:

     -   RST or FIN TCP segment.

     -   Active timeout.  Flows cannot live more than the specified period of
         time.  The default is 1800 seconds (30 minutes).

     -   Inactive timeout.  A flow was inactive for the specified period of
         time.  The default is 15 seconds.

     Export information is stored in NetFlow version 5 datagrams.

     This node type supports up to NG_NETFLOW_MAXIFACES hooks named iface0,
     iface1, etc., plus a single hook named export.  The node reads data on
     iface* hooks, and sends export datagrams to the export hook.  In normal
     operation, the export hook is connected to the inet/dgram/udp hook of the
     ng_ksocket(4) node.

     This node type supports the generic control messages, plus the following:

             Returns some node statistics and the current timeout values in a
             struct ng_netflow_info.

             Returns information about the ifaceN hook.  The hook number is
             passed as an argument.

             Sets data link type on the ifaceN hook.  Currently, supported
             types are raw IP datagrams and Ethernet.  This messsage type uses
             struct ng_netflow_setdlt as an argument:

                 struct ng_netflow_setdlt {
                         uint16_t iface;         /* which iface to operate on */
                         uint8_t  dlt;           /* DLT_XXX from bpf.h */

             The requested ifaceN hook must already be connected, otherwise
             message send operation will return an error.

             In some cases, ng_netflow may be unable to determine the input
             interface index of a packet.  This can happen if traffic enters
             the ng_netflow node before it comes to the system interface's
             input queue.  An example of such a setup is capturing a traffic
             between synchronous data line and ng_iface(4).  In this case, the
             input index should be associated with a given hook.  The inter-
             face's index can be determined via if_nametoindex(3) from user-
             land.  This message requires struct ng_netflow_setifindex as an

                 struct ng_netflow_setifindex {
                         u_int16_t iface;        /* which iface to operate on */
                         u_int16_t index;        /* new index */

             The requested ifaceN hook must already be connected, otherwise
             the message send operation will return an error.

             Sets values in seconds for NetFlow active/inactive timeouts.
             This message requires struct ng_netflow_settimeouts as an argu-

                 struct ng_netflow_settimeouts {
                         uint32_t        inactive_timeout;
                         uint32_t        active_timeout;

             This control message asks a node to dump the entire contents of
             the flow cache.  It is called from flowctl(8), not directly from

     Most binary control messages have an ASCII equivalent.  The supported
     ASCII commands are:

     NGM_NETFLOW_INFO         "info"
     NGM_NETFLOW_IFINFO       "ifinfo %u"
     NGM_NETFLOW_SETDLT       "setdlt { iface = %u dlt = %u }"
     NGM_NETFLOW_SETIFINDEX   "setifindex { iface = %u index = %u }"
     NGM_NETFLOW_SETTIMEOUTS  "settimeouts { inactive = %u active = %u }"

     This node shuts down upon receipt of a NGM_SHUTDOWN control message, or
     when all hooks have been disconnected.

     The simplest possible configuration is one Ethernet interface, where flow
     collecting is enabled.

           /usr/sbin/ngctl -f- <<-SEQ
                   mkpeer fxp0: tee lower right
                   connect fxp0: fxp0:lower upper left
                   mkpeer fxp0:lower netflow right2left iface0
                   name fxp0:lower.right2left netflow
                   mkpeer netflow: ksocket export inet/dgram/udp
                   msg netflow:export connect inet/

     This is a more complicated example of a router with 2 NetFlow-enabled
     interfaces fxp0 and ng0.  Note that the ng0: node in this example is con-
     nected to ng_tee(4).

           /usr/sbin/ngctl -f- <<-SEQ
                   # connect ng0's tee to iface0 hook
                   mkpeer ng0:inet netflow right2left iface0
                   name ng0:inet.right2left netflow
                   # set DLT to raw mode
                   msg netflow: setdlt { iface=0 dlt=12 }
                   # set interface index (5 in this example)
                   msg netflow: setifindex { iface=0 index=5 }

                   # Create tee on fxp0, and connect it to iface1 hook
                   mkpeer fxp0: tee lower right
                   connect fxp0: fxp0:lower upper left
                   name fxp0:lower fxp0_tee
                   connect fxp0_tee: netflow: right2left iface1

                   # Create ksocket node on export hook, and configure it
                   # to send exports to proper destination
                   mkpeer netflow: ksocket export inet/dgram/udp
                   msg netflow:export connect inet/

     flowctl(4), netgraph(4), ng_ksocket(4), ng_tee(4), ngctl(8)


     The ng_netflow node type was written by Gleb Smirnoff
     <glebiusATFreeBSD.org>, based on ng_ipacct written by Roman V. Palagin

     The ng_netflow node type does not fill in AS numbers.  This is due to the
     lack of necessary information in the kernel routing table.  However, this
     information can be injected into the kernel from a routing daemon such as
     GNU Zebra.  This functionality may become available in future releases.

BSD                              April 8, 2004                             BSD