Hash Calculation

Feature Set N-ANL9

Napatech SmartNIC
Content Type
Feature Description
Capture Software Version

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.

4GA Hash-General-1 Sheet.1 Hash key data Hash key data Sheet.2 Word 0 Word 0 Sheet.3 Word 1 Word 1 Sheet.4 Word 2 Word 2 Sheet.5 0 0 Sheet.6 4 4 Sheet.7 8 8 45 degree single.60 Center drag circle.18 Hash algorithm Hash algorithm 45 degree single.62 Sheet.11 32-bit hash value 32-bit hash value Sheet.12 Word 8 Word 8 Sheet.13 Word 9 Word 9 Sheet.14 32 32 Sheet.15 36 36 Sheet.16 40 40 Sheet.17 Sheet.18 Sheet.19 Sheet.20 328 bits 328 bits Sheet.21 32 bits 32 bits Sheet.22

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.

Page-1 Decision.16 Are hash data fields valid? Are hash data fields valid? Dynamic connector.2 Dynamic connector.3 Sheet.4 No No Process.17 Mark hash value as invalid. Hash value = 0. Mark hash value as invalid.Hash value = 0. Dynamic connector.6 Sheet.7 Yes Yes Dynamic connector.10 Dynamic connector.9 Center drag circle.18 Generate hash value Generate hash value Process.6 Sort if specified. Sort if specified. Dynamic connector.15 Process.11 Mark hash value as valid. Save hash information in extended o... Mark hash value as valid.Save hash information inextended or dynamic descriptor. Center drag circle.16 Done Done Process.13 Extract from packet the data field(s) that are to be used as ... Extract from packet the data field(s) that are to be used as hash key data. Process.14 Clear (zero) hash key data area. Clear (zero) hash key data area. Dynamic connector.17 Dynamic connector.18 Process.19 Based on frame decoder information select hash key type to be... Based on frame decoder information select hash key type to be used. Dynamic connector.20 Process.23 Mask if specified. Mask if specified. Dynamic connector.24 Process.25 Generate hash value. Generate hash value. Dynamic connector.26 Process.27 Swap if specified. Swap if specified. Dynamic connector.28

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 dynamic descriptor 2, which contains a 24-bit hash value.

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).

For dynamic descriptor 2, the hash value is retrieved directly from the packet descriptor (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).