Protocols

July 2, 2025 ยท View on GitHub

You can find information on the protocols:

The mapping to the protobuf format is listed in the table below.

FieldDescriptionNetFlow v5sFlowNetFlow v9IPFIX
TypeType of flow messageNETFLOW_V5SFLOW_5NETFLOW_V9IPFIX
time_received_nsTimestamp in nanoseconds of when the message was receivedIncludedIncludedIncludedIncluded
sequence_numSequence number of the flow packetIncludedIncludedIncludedIncluded
sampling_rateSampling rate of the flowIncludedIncludedIncludedIncluded
sampler_addressAddress of the device that generated the packetIP source of packetAgent IPIP source of packetIP source of packet
time_flow_start_nsTime the flow started in nanosecondsSystem uptime and first=TimeReceivedSystem uptime and FIRST_SWITCHED (22)flowStartXXX (150, 152, 154, 156)
time_flow_end_nsTime the flow ended in nanosecondsSystem uptime and last=TimeReceivedSystem uptime and LAST_SWITCHED (23)flowEndXXX (151, 153, 155, 157)
bytesNumber of bytes in flowdOctetsLength of sampleIN_BYTES (1) OUT_BYTES (23)octetDeltaCount (1) postOctetDeltaCount (23)
packetsNumber of packets in flowdPkts=1IN_PKTS (2) OUT_PKTS (24)packetDeltaCount (2) postPacketDeltaCount (24)
src_addrSource address (IP)srcaddr (IPv4 only)IncludedIncludedIPV4_SRC_ADDR (8) IPV6_SRC_ADDR (27)
dst_addrDestination address (IP)dstaddr (IPv4 only)IncludedIncludedIPV4_DST_ADDR (12) IPV6_DST_ADDR (28)
etypeEthernet type (0x86dd for IPv6...)IPv4IncludedIncludedIncluded
protoProtocol (UDP, TCP, ICMP...)protIncludedPROTOCOL (4)protocolIdentifier (4)
src_portSource port (when UDP/TCP/SCTP)srcportIncludedL4_SRC_PORT (7)sourceTransportPort (7)
dst_portDestination port (when UDP/TCP/SCTP)dstportIncludedL4_DST_PORT (11)destinationTransportPort (11)
in_ifInput interfaceinputIncludedINPUT_SNMP (10)ingressInterface (10)
out_ifOutput interfaceoutputIncludedOUTPUT_SNMP (14)egressInterface (14)
src_macSource mac addressIncludedIN_SRC_MAC (56)sourceMacAddress (56)
dst_macDestination mac addressIncludedOUT_DST_MAC (57)postDestinationMacAddress (57)
src_vlanSource VLAN IDFrom ExtendedSwitchSRC_VLAN (58)vlanId (58)
dst_vlanDestination VLAN IDFrom ExtendedSwitchDST_VLAN (59)postVlanId (59)
vlan_id802.11q VLAN IDIncludedSRC_VLAN (58)vlanId (58)
ip_tosIP Type of ServicetosIncludedSRC_TOS (5)ipClassOfService (5)
forwarding_statusForwarding statusFORWARDING_STATUS (89)forwardingStatus (89)
ip_ttlIP Time to LiveIncludedIPTTL (52)minimumTTL (52
tcp_flagsTCP flagstcp_flagsIncludedTCP_FLAGS (6)tcpControlBits (6)
icmp_typeICMP TypeIncludedICMP_TYPE (32)icmpTypeXXX (176, 178) icmpTypeCodeXXX (32, 139)
icmp_codeICMP CodeIncludedICMP_TYPE (32)icmpCodeXXX (177, 179) icmpTypeCodeXXX (32, 139)
ipv6_flow_labelIPv6 Flow LabelIncludedIPV6_FLOW_LABEL (31)flowLabelIPv6 (31)
fragment_idIP Fragment IDIncludedIPV4_IDENT (54)fragmentIdentification (54)
fragment_offsetIP Fragment OffsetIncludedFRAGMENT_OFFSET (88)fragmentOffset (88) and fragmentFlags (197)
src_asSource AS numbersrc_asFrom ExtendedGatewaySRC_AS (16)bgpSourceAsNumber (16)
dst_asDestination AS numberdst_asFrom ExtendedGatewayDST_AS (17)bgpDestinationAsNumber (17)
next_hopNexthop addressnexthopFrom ExtendedRouterIPV4_NEXT_HOP (15) IPV6_NEXT_HOP (62)ipNextHopIPv4Address (15) ipNextHopIPv6Address (62)
next_hop_asNexthop AS numberFrom ExtendedGateway
src_netSource address masksrc_maskFrom ExtendedRouterSRC_MASK (9) IPV6_SRC_MASK (29)sourceIPv4PrefixLength (9) sourceIPv6PrefixLength (29)
dst_netDestination address maskdst_maskFrom ExtendedRouterDST_MASK (13) IPV6_DST_MASK (30)destinationIPv4PrefixLength (13) destinationIPv6PrefixLength (30)
bgp_next_hopBGP Nexthop addressFrom ExtendedGatewayBGP_IPV4_NEXT_HOP (18) BGP_IPV6_NEXT_HOP (63)bgpNextHopIPv4Address (18) bgpNextHopIPv6Address (63)
bgp_communitiesBGP CommunitiesFrom ExtendedGateway
as_pathAS PathFrom ExtendedGateway
mpls_ttlTTL of the MPLS labelIncluded
mpls_labelMPLS label listIncluded

Producers

When using the raw producer, you can access a sample:

$ go run main.go -produce raw -format json

This can be useful if you need to debug received packets or looking to dive into a specific protocol (eg: the sFlow counters).

{
    "type": "sflow",
    "message":
    {
        "version": 5,
        "ip-version": 1,
        "agent-ip": "127.0.0.1",
        "sub-agent-id": 100000,
        "sequence-number": 1234,
        "uptime": 19070720,
        "samples-count": 1,
        "samples":
        [
            {
                "header":
                {
                    "format": 2,
                    "length": 124,
                    "sample-sequence-number": 340,
                    "source-id-type": 0,
                    "source-id-value": 6
                },
                "counter-records-count": 1,
                "records":
                [
                    {
                        "header":
                        {
                            "data-format": 1,
                            "length": 88
                        },
                        "data":
                        {
                            "if-index": 6,
                            "if-type": 6,
                            "if-speed": 0,
                            "if-direction": 0,
                            "if-status": 3,
                            "if-in-octets": 0,
                            "if-in-ucast-pkts": 1000,
                            "if-in-multicast-pkts": 0,
                            "if-in-broadcast-pkts": 0,
                            "if-in-discards": 0,
                            "if-in-errors": 0,
                            "if-in-unknown-protos": 0,
                            "if-out-octets": 0,
                            "if-out-ucast-pkts": 2000,
                            "if-out-multicast-pkts": 0,
                            "if-out-broadcast-pkts": 0,
                            "if-out-discards": 0,
                            "if-out-errors": 0,
                            "if-promiscuous-mode": 0
                        }
                    }
                ]
            }
        ]
    },
    "src": "[::ffff:127.0.0.1]:50001",
    "time_received": "2023-04-15T20:44:42.723694Z"
}

When using the Protobuf producer, you have access to various configuration options. The mapping.yaml file can be used with -mapping=mapping.yaml in the CLI.

It enables features like:

  • Add protobuf fields
  • Renaming fields (JSON/text)
  • Hashing key (for Kafka)
  • Mapping new values from samples

For example, you can rename:

formatter:
  rename: # only for JSON/text
    src_mac: src_macaddr
    dst_mac: dst_macaddr

Columns and renderers

By default, all the columns above will be printed when using JSON or text. To restrict to a subset of columns, in the mapping file, list the ones you want:

formatter:
  fields:
    - src_addr

There is a support for virtual columns (eg: icmp_name).

Renderers are a special handling of fields:

formatter:
  render:
    src_mac: mac
    dst_mac: mac
    dst_net: none # overrides: render the network as integer instead of prefix based on src/dst addr

You can assign a specific formatter.

Map custom fields

If you are using enterprise fields that you need decoded or if you are looking for specific bytes inside the packet sample.

Data coming from the flows can be added to the protobuf either as an unsigned/signed integer a slice of bytes.

The sflow section allow to extract data from packet samples inside sFlow and inside IPFIX (dataframe). The following layers are available:

  • 0: no offset
  • 3, ipv4, ipv6, arp: network layer, offsets to IP/IPv6 header
  • 4, icmp, icmp6, udp, tcp: transport layer, offsets to TCP/UDP/ICMP header
  • 7: application layer, offsets to the TCP/UDP payload

The data extracted will then be added to either an existing field (see samping rate below), or to a newly defined field.

In order to display them with JSON or text, you need to specify them in fields.

formatter:
  fields:
    - sampling_rate
    - custom_src_port
    - juniper_properties
  protobuf:
    - name: juniper_properties
      index: 1001
      type: varint
      array: true
ipfix:
  mapping:
    - field: 34 # samplingInterval provided within the template
      destination: sampling_rate
      endian: little # special endianness

    - field: 137 # Juniper Properties
      destination: juniper_properties
      penprovided: true # has an enterprise number
      pen: 2636 # Juniper enterprise
netflowv9:
  mapping: []
    # ... similar to above but the enterprise number will not be supported
sflow:
  mapping: # also inside an IPFIX dataFrame
    - layer: "4" # Layer
      offset: 0 # Source port
      length: 16 # 2 bytes
      destination: custom_src_port

Another example if you wish to decode the TTL from the IP:

formatter:
  protobuf: # manual protobuf fields addition
    - name: egress_vrf_id
      index: 40
      type: varint
ipfix:
  mapping:
    - field: 51
      destination: ip_ttl_test
netflowv9:
  mapping:
    - field: 51
      destination: ip_ttl_test
sflow:
  mapping:
    - layer: "ipv4"
      offset: 64
      length: 8
      destination: ip_ttl_test
    - layer: "ipv6"
      offset: 56
      length: 8
      destination: ip_ttl_test