Tuple swap
In the hash calculations the source and destination addresses and ports can be swapped.
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 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
- Hash2TupleSorted
- Hash5TupleSorted
- HashInner2TupleSorted
- HashInner5TupleSorted
- Hash3TupleGREv0Sorted
- Hash3TupleGTPv0Sorted
- Hash3TupleGTPv1v2Sorted
- Hash5TupleSCTPSorted
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.
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