+ def cnat_fhc_translation(self):
+ """CNat Translation"""
+ self.logger.info(self.vapi.cli("sh cnat client"))
+ self.logger.info(self.vapi.cli("sh cnat translation"))
+
+ for nbr, translation in enumerate(self.mbtranslations):
+ vip = translation.vip
+
+ #
+ # Flows to the VIP with same ips and different source ports are loadbalanced identically
+ # in both cases of flow hash 0x03 (src ip and dst ip) and 0x08 (dst port)
+ #
+ ctx = CnatTestContext(self, translation.iproto, vip.is_v6)
+ for src_pgi, sport in product(range(N_REMOTE_HOSTS), [1234, 1233]):
+ # from client to vip
+ ctx.cnat_send(self.pg0, src_pgi, sport, self.pg1, vip.ip, vip.port)
+ dport1 = ctx.rxs[0][ctx.L4PROTO].dport
+ ctx._test.assertIn(
+ dport1,
+ [translation.paths[0][DST].port, translation.paths[1][DST].port],
+ )
+ ctx.cnat_expect(self.pg0, src_pgi, sport, self.pg1, nbr, dport1)
+
+ ctx.cnat_send(
+ self.pg0, src_pgi, sport + 122, self.pg1, vip.ip, vip.port
+ )
+ dport2 = ctx.rxs[0][ctx.L4PROTO].dport
+ ctx._test.assertIn(
+ dport2,
+ [translation.paths[0][DST].port, translation.paths[1][DST].port],
+ )
+ ctx.cnat_expect(self.pg0, src_pgi, sport + 122, self.pg1, nbr, dport2)
+
+ ctx._test.assertEqual(dport1, dport2)
+