Tuple Swap

Napatech Link™ Software Features

product_line_custom
Intel® PAC
Napatech SmartNIC
category
Feature Description

Tuple swap

In the hash calculations the source and destination addresses and ports can be swapped. Swapping can be based on IP match lists.

Note: For sorted hash keys the sorting takes place before the swapping. Masking takes place after the swapping.

Simple tuple swap illustration

Simple tuple swap can be used in a scenario as shown in this figure where IP sessions going in opposite directions are received on separate ports, and all traffic to and from a specific IP address (X in the example) must end up in the same host buffer. In this case tuple swap is specified for one of the ports and a hash mask is added to enable only a specific IP address (X in the example) in the hash key.


Simple tuple swap

Simple tuple swap NTPL example

This NTPL example distributes tunneled GTP traffic to and from different clients inside a tunnel to streams 0 to 7 using the inner 2-tuple hash key. All uplink traffic is on port 0 and all downlink traffic is on port 1 as in the example shown in Simple tuple swap illustration. All tunneled traffic is IPv4 packets.

The first command defines hash key mask No. 1 where the destination IP address is masked out.

The second command defines a hash mode for port 0 using mask No. 1. Since port 0 receives the uplink traffic, only the IP address X is used in the hash calculation for the client in Simple tuple swap illustration.

The third command defines a hash mode for port 1 using mask No. 1, and swaps the source and destination IP addresses before the hash mask is applied. Since port 1 receives the downlink traffic, again only IP address X is used in the hash calculation for the client in Simple tuple swap illustration. In this way all traffic to and from X ends up in the same stream.

The fourth command distributes the traffic from different client IP addresses between streams 0 to 7:

HashMask[HashWord0=[FF.FF.FF.FF]; HashWord4=[0.0.0.0]] = MaskNo == 1
HashMode[InnerLayer3Type = IPV4; MaskNo=1; Port=0; TupleSwap=False] = HashInner2Tuple
HashMode[InnerLayer3Type = IPV4; MaskNo=1; Port=1; TupleSwap=True] = HashInner2Tuple
Assign[StreamId=(0..7)] = All

Distributing flows by XORing source and destination addresses

XORing the source and destination IP addresses creates a value that is independent of the direction of the traffic.


Flow distribution by using XOR for source and destination addresses

In this example, the source and destination IP addresses are XORed in the hash recipes IPv4_Flow and IPv6_Flow.

These hash recipes can then be used to distribute traffic based on flows.

Define IPv4_Flow = Hash(HashWord0_3=Layer3Header[12]/32,HashWord4_7=Layer3Header[16]/32,XOR=True)
Define IPv6_Flow = Hash(HashWord0_3=Layer3Header[8]/128,HashWord4_7=DestinationIP[0]/128,XOR=True)
Assign[StreamId=(0..3);Hash=IPv4_Flow] = Layer3Protocol == IPV4
Assign[StreamId=(0..3);Hash=IPv6_Flow] = Layer3Protocol == IPV6

Distributing traffic based on subscriber's IP address

The hash recipe to be used can be selected based on key match test. This way, different hash recipes can selected based on the direction of the traffic.


Traffic distribution based on subscriber IP address

In this example, the HashUp recipe is selected when the inner source IP matches, and the HashDown recipe is selected when the inner destination IP matches.

// Distribute frames based on mobile subscriber’s IP address
Define InnerSrcIPv4 = Field(InnerLayer3Header[12]/32)
Define InnerDestIPv4 = Field(InnerLayer3Header[16]/32)
Define HashUp = Hash(HashWord0_3=InnerSrcIPv4)
Define HashDown = Hash(HashWord0_3=InnerDestIPv4)
IPMatchList[KeySet=1] = IPv4Addr == [192.168.0.1], [10.10.100.1]
Assign[StreamId=(0..3);Hash=HashUp] = KeyMatch(InnerSrcIPv4) == 1 AND KeyMatch(InnerDestIPv4) == Any
Assign[StreamId=(0..3);Hash=HashDown] = KeyMatch(InnerSrcIPv4) == Any AND KeyMatch(InnerDestIPv4) == 1