IBM Streams 4.2.1

Operator PacketDPDKSource

Primitive operator image not displayed. Problem loading file: ../../image/tk$com.ibm.streamsx.network/op$com.ibm.streamsx.network.source$PacketDPDKSource.svg

PacketDPDKSource is an operator for the IBM InfoSphere Streams product that captures live network packets from one of the network interfaces attached to the machine where it executes. The operator function and structure are very similar to PacketLiveSource; see that operator's documentation for details of common functions and general background. The primary difference between these related operators is that PacketDPDKSource leverages the DPDK libraries available at http://www.dpdk.org for higher performance and lower processing overhead.

Output filters and attribute assignments are SPL expressions. They may use any of the built-in SPL functions, and any of these functions, which are specific to the PacketFileSource operator:

The PacketDPDKSource operator steps quietly over 'jmirror' headers prepended to packets by Juniper Networks 'mirror encapsulation'.

This operator is part of the network toolkit. To use it in an application, include this statement in the SPL source file:

use com.ibm.streamsx.network.source::*;

Promiscuous Mode

Network interfaces normally ignore packets that are not addressed to them. However, when 'promiscious' mode is enabled on a network interface, it can capture all network packets on its ethernet segment, even those that are not addressed to it. This is sometimes referred to as "network sniffing". Modern ethernet switches normally send network interfaces only packets that are addressed to them; 'promiscious' mode is useful only when a switch has been specifically configured to send packets to a network interface that are not addressed to it. This is sometimes referred to as "mirroring".

The PacketDPDKSource operator will enable 'promiscuous' mode in a ethernet interface when its 'promiscous' parameter is set to true.

Dependencies

The PacketDPDKSource operator depends upon the DPDK libraries available from http://dpdk.org. The library must be installed on the machine where this operator is built. It has been tested with the following versions:
  • DPDK 2.2
The base DPDK library supports a wide range of NICs as described at http://dpdk.org. For IBM Streams, we have tested the following:
  • Mellanox CX-3
  • Mellanox CX-3 Pro
  • Intel e1000

There are very good documents for DPDK build/install/use on the DPDK website that should be referenced. Here are some notes of the steps that will help getting started on Streams:

  • Download and untar the dpdk.tgz file from http://dpdk.org.
  • Set environment variables (these are needed for DPDK and Streams builds and depend on your specific platform):

    export EXTRA_CFLAGS=-fPIC
    export RTE_SDK=/home/<userid>/dpdk-2.2.0   # (point to install directory)
    
    export RTE_TARGET=x86_64-native-linuxapp-gcc
       OR
    export RTE_TARGET=ppc_64-default-linuxapp-gcc
  • Configure the DPDK build from the top directory

    cd $RTE_SDK
    make config T=x86_64-native-linuxapp-gcc
       OR
    make config T=ppc_64-power8-linuxapp-gcc
  • Change configuration as needed. For example:

    # Edit the .config files
    vi ./build/.config
    
    # Set key parameters
    CONFIG_RTE_BUILD_COMBINE_LIBS=y
    CONFIG_RTE_LIBRTE_MLX4_PMD=y (MLX4 NIC)
    CONFIG_RTE_BUILD_SHARED_LIB=y (e1000 NIC)
       OR
    CONFIG_RTE_BUILD_SHARED_LIB=n (MLX4 NIC)
    
    # Build the library
    make
    
    # Complete the build
    make install T=x86_64-native-linuxapp-gcc
       OR
    make install T=ppc_64-power8-linuxapp-gcc
  • There is also a Streams to DPDK glue library that must be built. To do this, make sure the RTE environment variables noted above are set and then do the following:

    cd <toolkit-directory>/com.ibm.streamsx.network/impl/src/source/dpdk
    make
  • Build the Streams example application with the following steps:

    cd <toolkit-directory>/samples/SamplePacketDPDKSource
    
    # Update the sample Makefile to use the appropriate libraries for your adapter type
    vi Makefile
    
    # Modify the operator parameters as needed for your NIC and environment
    vi TestPacketDPDKSource.spl
    make
  • Create a dpdk group for permisssions.

    groupadd dpdk
    usermod -a -G dpdk <userid>
    groups <userid>
    
    # You may need to log out and back in to make sure your user is actively in the group.
    # Alternatively, you could use newgrp to change the current default group for the current shell session:
    newgrp dpdk
  • Configure and enable access to hugepages (You'll need to be root to do most of these):

    # Make sure hugetlbfs is mounted, and the appropriate group owner and permissions are set:
    # (May need to umount /dev/hugepages first, to make sure the right gid and mode settings take.)
    mount -t hugetlbfs nodev /dev/hugepages -o gid=dpdk,mode=1770
    
    # Enable a suitable number of huge pages of the appropriate size, on the appropriate NUMA nodes
    # The exact number and size of hugepages will depend on your workload and packet rates.
    # Note: Fewer, larger hugepages can be used if available, such as on POWER systems.
    # The exact NUMA nodes that need huge pages will depend on adapter location and which CPUs the
    # DPDK application threads will be running on.
    echo 1000 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
    
    # Ensure all users in the dpdk group can lock an unlimited amount of memory.
    # Add a line to /etc/security/limits.conf like the following:
    @dpdk - memlock unlimited
    # This will take effect at next login.
    
    # An alternative to setting up huge pages after booting each time, you could add
    # the mount options to /etc/fstab or a systemd unit file, and add a line to
    # /etc/sysctl.conf with the number of huge pages to reserve:
    vm.nr_hugepages = 1000
    # These will be spread over the NUMA nodes, and be of the default size for the system.
    # If you change these files, you will not need to run the explicit mount or echo 1000
    # commands, above, before running the DPDK applications (provided you have rebooted
    # the system after making the changes).
  • Additional Items for e1000 Adapters (RHEL7):

    # Bring the interface down
    ifconfig <eth-interface> down
      OR
    ip link set dev <eth-interface> down
    
    # Load the intel DPDK uio driver:
    modprobe uio
    insmod <dpdk-path>/dpdk-2.2.0/build/kmod/igb_uio.ko
    
    # Bind the interface to the intel DPDK uio driver:
    <dpdk-path>/dpdk-2.2.0/tools/dpdk_nic_bind.py --bind=igb_uio <eth-interface>
    <dpdk-path>/dpdk-2.2.0/tools/dpdk_nic_bind.py --status
    
    # Ensure the dpdk group has full access to the new uio device:
    chown root:dpdk /dev/uio0
    chmod 660 /dev/uio0
    
    # Ensure the dpdk group has full access to config and resources for the new uio device:
    chown root:dpdk /sys/class/uio/uio0/device/config
    cdmod 660 /sys/class/uio/uio0/device/config
    chown root:dpdk /sys/class/uio/uio0/device/resource*
    chmod 660 /sys/class/uio/uio0/device/resource*
    
    # Alternatively, a system-level udev rule could be used to ensure the dpdk group had access to
    # any new uio device by adding a file at /etc/udev/rules.d/10-dpdk.rules with content like:
    SUBSYSTEM=="uio", GROUP="dpdk", MODE="0660"
    # but note that this will not give access to the config and resource files, so that step would still
    # need to be done manually (or in a script).  If you do add a udev rule, it will take effect at the
    # next reboot, or, after forcing udev to reload rules (but then only at the time of the next uio bind):
    udevadm control --reload
    
    # If you need a particular interface to always be bound to the uio driver, at boot
    # time, the easiest way is to add the ifconfig down, modprobe/insmod,
    # dpdk_nic_bind.py, and chown/chmod commands to a simple startup script.
  • Additional Items for Mellanox Adapters (RHEL7). Assumes OFED packages have been installed. (See Mellanox Poll Mode Driver for DPDK and Mellanox OFED for more information.)

    # Configure IB module.
    # Add a line to (or create) /etc/modprobe.d/mlnx.conf:
    options ib_uverbs disable_raw_qp_enforcement=1
    
    # Make sure the mlx4 driver is re-loaded and uses the above settings:
    modprobe mlx4_en
    /etc/init.d/openibd restart
    # "ibstat" and "/etc/init.d/openibd status" are useful commands to verify things worked.
  • Other Adapters may require other additional items. See the DPDK documentation for more details.

  • Running the Streams application
    # Submit normally:
    streamtool submitjob output/TestPacketDPDKSource.sab
    
    # Packet output can be found in the "data" directory.

Summary

Ports
This operator has 0 input ports and 1 or more output ports.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 6 parameters.

Required: lcore

Optional: lcoreMaster, metricsInterval, nicPort, nicQueue, promiscuous

Metrics
This operator reports 4 metrics.

Properties

Implementation
C++
Threading
Always - Operator always provides a single threaded execution context.

Output Ports

Assignments
This operator allows any SPL expression of the correct type to be assigned to output attributes.
Ports (0...)

The PacketDPDKSource operator requires one or more output ports:

Each output port will produce one output tuple for each packet received if the corresponding expression in the outputFilters parameter evaluates true, or if no outputFilters parameter is specified.

Output attributes can be assigned values with any SPL expression that evaluates to the proper type, and the expressions may include any of the PacketDPDKSource result functions. Output attributes that match input attributes in name and type are copied automatically.

Properties

Parameters

This operator supports 6 parameters.

Required: lcore

Optional: lcoreMaster, metricsInterval, nicPort, nicQueue, promiscuous

lcore

Logical core number on which this operator will run.

Properties

lcoreMaster

Logical core number to be used for the master DPDK thread.

Properties

metricsInterval

This optional parameter takes an expression of type float64 that specifies the interval, in seconds, for sending operator metrics to the Streams runtime. If the value is zero or less, the operator will not report metrics to the runtime, and the output assigment functions for libpcap statistics will be zero.

The default value is '10.0'.

Properties

nicPort

NIC port of type uint32 which sources packets for this operator instance. Obtaining the proper mapping may require use of multiple tools, and varies by NIC.

Suggested tools to help identify NIC ports:

- ifconfig

- dpdk-*/tools/dpdk_nic_bind.py --status

- ibstat (for Mellanox NICs)

- lspci | grep -i net

Properties

nicQueue

NIC queue of type int32 which sources packets for this operator instance.

Properties

promiscuous

This optional parameter takes an expression of type 'boolean' that specifies whether or not 'promiscuous' mode should be enabled on the network interface.

Properties

Metrics

nPacketsReceivedCurrent - Counter

This metric counts the number of packets received by the network interface, as counted by dpdk

nPacketsDroppedCurrent - Counter

This metric counts the number of packets dropped by the network interface, as counted by dpdk

nPacketsProcessedCurrent - Counter

This metric counts number of bytes of packet data processed by the operator.

nBytesProcessedCurrent - Counter

This metric counts number of bytes of packet data processed by the operator.

Libraries

General support functions.
Include Path: ../../impl/include
streams_source interface library to dpdk.
Library Name: streams_source
Library Path: ../../impl/src/source/dpdk/build/lib
Include Path: ../../impl/src/source/dpdk