Hash Calculation

Napatech Link™ Software Features

product_line_custom
Intel® PAC
Napatech SmartNIC
category
Feature Description

Hash value generation

The packet data used for the hash key can be specified using predefined hash key types or user-defined hash recipes.

The hash values are calculated using the NTH (Napatech hasher) algorithm.

This figure illustrates the generation of hash values.

Hash value generation

The hash key consists of 10 four-byte words and a one-byte field.

Note: The HashSeed parameter in the ntservice.ini file (see DN-0449) defines an alternative hash seed. The hash seed is used as initial value for the hash algorithm. Changing this value will alter the data distribution in the streams.

Predefined hash key types

This figure illustrates the possible hash key data for the different predefined hash key types. The hash key types are described in more detail in Hash Key Types. You configure which hash key type to use with NTPL (Napatech programming language – see DN-0449). The used hash key type can be delivered as part of extended descriptor 9 (see Packet Descriptors). It can be retrieved using the NT_NET_GET_PKT_HASH_TYPE macro (see DN-0449).

No. Hash Key Type MPLS Label VLAN ID IPv4 or IPv6 Addresses TCP or UDP Ports SCTP Ports GREv0 Key GTPv0 Flow Label GTPv1/GTPv2 TEID IP Identification Field Inner IPv4 or IPv6 Addresses Inner TCP, UDP or SCTP Ports
0 Disabled
1 Reserved
2 Last MPLS label X
3 All MPLS labels X
4 2-tuple X
5 2-tuple sorted X
6 Last VLAN ID X
7 All VLAN IDs X
8 5-tuple X1 X X
9 5-tuple sorted X1 X X
10 3-tuple GREv0 X X
11 3-tuple GREv0 sorted X X
12 5-tuple SCTP X X2
13 5-tuple SCTP sorted X X2
14 3-tuple GTPv0 X X
15 3-tuple GTPv0 sorted X X
16 3-tuple GTPv1/GTPv2 X X
17 3-tuple GTPv1/GTPv2 sorted X X
18 Inner 2-tuple X
19 Inner 2-tuple sorted X
20 Inner 5-tuple X1 X
21 Inner 5-tuple sorted X1 X
30 IP fragment tuple4 X3 X
31 Round robin

User-defined hash keys

To select only the packet data that are relevant for an application for hash calculation, the hash key can be specified by a user-defined hash key recipe. A user-defined hash key is composed of 2 four-word fields (128 bits) typically used for IP addresses, 2 one-word fields (32 bits) and 1 one-byte field. The first four fields can be set to any packet data, specified using dynamic offsets. The one-byte field can be used for either the outer or the inner IP protocol field.

An XOR option can be specified, for example in order to generate the same hash value for both traffic direction in a flow. The 2 four-word fields will be XORed together, and the upper and lower halves of each one-word field will be XORed together.

Hash key masks

The data used for each hash key field can be masked before hash value calculation by specifying a hash key mask (see Hash Key Masks).

Algorithm for generating hash values

This figure shows the algorithm for generating hash values.

Flow chart showing how to generate a hash value

Hash key data

A number of different packet header fields can be used as hash key data. These fields are described in Hash Key Types.

Use of hash values

The generated hash values can be used for multi-CPU distribution.

The values can be delivered as part of extended descriptor 9 (see Packet Descriptors), which contains a 24-bit hash value and a 5-bit hash key type or as part of a dynamic descriptor. Dynamic descriptors 2 and 4 may contain the full 32-bit hash value, while dynamic descriptor 3 may contain a 28-bit hash value.

For dynamic descriptors, the hash value is retrieved directly from the packet descriptor (see DN-0449).

For extended descriptor 9 the information can be retrieved using the NT_NET_GET_PKT_HASH and NT_NET_GET_PKT_HASH_TYPE macros (see DN-0449).

1 The 5-tuple and 5-tuple sorted hash key types also include the IPv4 protocol fields and/or IPv6 next header field.
2 The 5-tuple SCTP and 5-tuple SCTP sorted hash key types also include the SCTP verification tag field.
3 For IPv4, the IP fragment tuple hash key type also includes the IPv4 protocol field.
4 The IP fragment tuple hash key type cannot be selected using NTPL. It is only used for unmatched fragments of IP fragmented datagrams (see IP Fragment Handling).