X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FNATUtil.py;h=aabcd36cdae92457bf2f5d52096c0b25a0dad426;hb=2c0affb70d06918e6ba0c9409d4cb7afc39b603a;hp=857870393e648bdefa1410632f2ce1a993c6a1d2;hpb=44e560e51b41b5af5931be3ffa027411269c288d;p=csit.git diff --git a/resources/libraries/python/NATUtil.py b/resources/libraries/python/NATUtil.py index 857870393e..aabcd36cda 100644 --- a/resources/libraries/python/NATUtil.py +++ b/resources/libraries/python/NATUtil.py @@ -185,6 +185,22 @@ class NATUtil: ] PapiSocketExecutor.dump_and_log(node, cmds) + @staticmethod + def compute_max_translations_per_thread(sessions, threads): + """Compute value of max_translations_per_thread NAT44 parameter based on + total number of worker threads. + + :param sessions: Required number of NAT44 sessions. + :param threads: Number of worker threads. + :type sessions: int + :type threads: int + :returns: Value of max_translations_per_thread NAT44 parameter. + :rtype: int + """ + from math import log2, modf + rest, mult = modf(log2(sessions/(10*threads))) + return 2 ** (int(mult) + (1 if rest else 0)) * 10 + # DET44 PAPI calls # DET44 means deterministic mode of NAT44 @staticmethod