aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2020-09-12 01:25:23 +0200
committerJan Gelety <jgelety@cisco.com>2020-09-30 10:39:13 +0000
commit2c0affb70d06918e6ba0c9409d4cb7afc39b603a (patch)
tree15b2119e2fa8888315146c30a629f287f9aedf88 /resources
parent44e560e51b41b5af5931be3ffa027411269c288d (diff)
test: compute max_translations_per_thread based on worker threads number
Change-Id: I1c638aef886bf37a9feb4a29e4949c7c8f19b717 Signed-off-by: Jan Gelety <jgelety@cisco.com> (cherry picked from commit d99951620507d354c4803eb1ee26609d992b70b3) Change-Id: Iaf5b4dffe603b0cf5cf0430fc6ca20acb7a01fda Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/libraries/python/NATUtil.py16
1 files changed, 16 insertions, 0 deletions
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