IPFIXcol2

repository·master·Indexed 41 days ago

https://github.com/cesnet/ipfixcol2

A high-performance IPFIX flow collector featuring a modular pipeline of input, intermediate, and output plugins. Includes tools like fdsdump for reading and filtering FDS format flow data, ipfixsend2 for flow simulation, and a specialized ClickHouse output plugin for high-speed binary export and high-availability storage of flow records.

Tokens
30.4K
Snippets
73
Records
135
Agent score
51%

What's inside IPFIXcol2

  1. Overview of the JSON Kafka output plugin

    master

    The json-kafka plugin is a specialized version of the JSON output plugin designed for Apache Kafka. It converts IPFIX flow records into JSON format and sends them to a Kafka cluster.

    Key characteristics:

    • Field Formatting: Fields are formatted as <Enterprise Name>:<Information Element Name>. For example, iana:sourceIPv4Address. If the field name/type is unknown and ignoreUnknown is disabled, it uses the format enXX:idYY (where XX is the Enterprise Number and YY is the ID).
    • Data Types: Supports structured data types like basicList, subTemplateList, and subTemplateMultiList.
    • Record Types: The plugin produces different JSON record types distinguished by the @type key:
      • ipfix.entry: The standard flow record (most common).
      • ipfix.optionsEntry: Metadata about the exporter (e.g., sampling stats). Disabled by default via ignoreOptions.
      • ipfix.template and ipfix.optionsTemplate: Records describing the structure of flow/options records. Disabled by default via templateInfo.
  2. Overview of pcap2flow

    master

    pcap2flow is a utility designed to extract NetFlow v5/v9 and IPFIX packets from a PCAP file and replay them to a collector.

    Key behaviors:

    • Session Preservation: To avoid mixing packets from different original Transport Sessions (TS), the tool creates a new independent session to the target collector for each original TS found in the PCAP.
    • Packet Filtering: All non-flow packets within the PCAP file are automatically ignored.
    • Intended Use: This tool is strictly for testing collectors and their plugins using previously captured flow packets. It is not intended for production environments due to non-ideal performance.
  3. Use fdsdump to read and display flow data

    master

    The fdsdump tool reads flow data stored in the FDS format and allows you to display, filter, sort, and aggregate the records. It supports multiple output formats including formatted tables and JSON. You can specify input files using the -r flag, which also supports glob patterns and can be used multiple times to include multiple file sets.

    fdsdump [options] -r <FDS_FILES>
  4. Use the FDS output plugin for long-term flow storage

    master
    The FDS (Flow Data Storage) output plugin converts and stores IPFIX Data Records into the FDS file format. This format is based on IPFIX and is designed for highly effective long-term storage, preserving complete flow records (including Enterprise-specific fields and biflows) along with exporter identification. Data is stored in flat files that are automatically rotated and renamed based on time intervals.
  5. Use the TCP input plugin

    master

    The TCP input plugin receives IPFIX messages over the TCP transport protocol from one or more exporters and passes them into the collector. Because TCP is a reliable transport protocol, exporters can detect connection or disconnection, which avoids common issues with template retransmission and initial periods of inability to interpret flow records found in UDP-based collectors.

    Key features:

    • Reliability: Detects connection/disconnection.
    • Compression Support: Automatically detects and handles IPFIX messages compressed using LZ4 stream compression (compatible with ipfixprobe).
    • Concurrency: Multiple instances can run concurrently if they listen on different ports or local IP addresses.
    <input>
        <name>TCP input</name>
        <plugin>tcp</plugin>
        <params>
            <localPort>4739</localPort>
            <localIPAddress></localIPAddress>
        </params>
    </input>
  6. Use the UDP input plugin

    master

    The UDP input plugin receives IPFIX messages over the UDP transport protocol from one or more exporters and passes them into the collector.

    Key Behaviors:

    • Concurrency: You can run multiple instances of this plugin concurrently, but each instance must listen on a unique combination of local port and local IP address.
    • Unidirectional Nature: IPFIX over UDP is unidirectional. The collector can only receive data.
    • Template Latency: Because IPFIX relies on templates to interpret records, if the collector starts after an exporter, it may miss the initial templates. It may take several minutes for the first records to be successfully interpreted, depending on the exporter's template retransmission interval.
    • Reliability Warning: UDP is an unreliable protocol. A common cause of lost flow records is an undersized system socket receive buffer. While the plugin attempts to set the buffer to the OS maximum at startup, this may still be insufficient for high-speed networks or multiple exporters.
    <!-- Example of the plugin type used in configuration -->
    <plugin>udp</plugin>
  7. Overview of IPFIXcol2 plugin architecture

    master

    IPFIXcol2 is a high-performance flow data collector that uses a plugin-based architecture. You can compose a pipeline by selecting combinations of the following plugin types:

    • Input plugins: Receive NetFlow/IPFIX data (e.g., UDP, TCP, FDS File, IPFIX File). Multiple instances can run concurrently on different interfaces/ports.
    • Intermediate plugins: Modify, enrich, or filter records (e.g., Anonymization using Crypto-PAn).
    • Output plugins: Store or forward flows (e.g., JSON, ClickHouse, Kafka, FDS File, Viewer).

    Note: Some plugins (like ClickHouse, UniRec, or lnfstore) require individual installation due to extra dependencies.

  8. Choose a fdsdump mode: Statistics, Lister, or Aggregation

    master

    Statistics mode

    Activated with the -I flag. It prints summary information about the flows in the FDS files, such as packet counts, byte counts, and flow counts (including directionality for biflows).

    Lister mode

    (Default) Displays individual flow records in a specified format (table or JSON). Records can be sorted and ordered by field values.

    Aggregation mode

    (TBD) Used for grouping and aggregating flow data.

  9. Understand the JSON structure of Template records

    master

    When <templateInfo> is enabled, Template records are converted with the @type set to ipfix.template. These records define the structure of flow records and include:

    • ipfix:templateId: A unique identifier for the Transport Session and Observation Domain.
    • ipfix:fields: An array of JSON objects, each specifying a field's ipfix:elementId, ipfix:enterpriseId, and ipfix:fieldLength.
    {
        "@type": "ipfix.template",
        "ipfix:templateId": 49171,
        "ipfix:fields": [
            {
                "ipfix:elementId": 16399,
                "ipfix:enterpriseId": 6871,
                "ipfix:fieldLength": 1
            }, 
            {
                "ipfix:elementId": 184,
                "ipfix:enterpriseId": 29305,
                "ipfix:fieldLength": 4
            }
        ]
    }
  10. How the ClickHouse output plugin works

    master

    The plugin converts and stores IPFIX flow records into a ClickHouse database using binary-level export (avoiding text SQL conversion) for high performance.

    Key behaviors:

    • High-Speed Export: Capable of hundreds of thousands to a million records per second.
    • Customizable Mapping: You can map any IPFIX/NetFlow items to specific database columns.
    • High Availability (HA): Supports multiple ClickHouse endpoints. It uses a failover strategy (not round-robin); if one endpoint fails, data is redirected to the next available one.
    • Schema Requirement: The plugin does not automatically create tables. It expects the table and schema to exist beforehand and will error if the schema does not match your configuration.
  11. Understand structured data types in JSON output

    master

    IPFIX flow records can include RFC6313 structured data types. These are formatted as JSON objects with an @type field.

    basicList

    Contains a fieldID and a data array of values.

    {
        "example:blField": {
            "@type": "basicList",
            "semantic": "anyOf",
            "fieldID": "iana:octetDeltaCount",
            "data": [23, 34, 23]
        }
    }

    subTemplateList

    Contains a data array of JSON objects. All objects share the same structure defined by the template.

    {
        "example:stlField": {
            "@type": "subTemplateList",
            "semantic": "allOf",
            "data": [
                {"keyA.1": "value1", "keyA.2": "value2"},
                {"keyB.1": "value1", "keyB.2": "value2"}
            ]
        }
    }

    subTemplateMultiList

    Contains a data array of nested arrays. Each nested array contains objects with a consistent structure.

    {
        "example:stmlField": {
            "@type": "subTemplateMultiList",
            "semantic": "allOf",
            "data" : [
                [
                    {"keyA.1": "value1", "keyA.2": "value2"},
                    {"keyB.1": "value1", "keyB.2": "value2"}
                ],
                [
                    {"idA.1": "something", "idB.1": 123}
                ]
            ]
        }
    }