From 7797f183c31914c095daf27404dd1beb8aaa7441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Chac=C3=B3n?= Date: Wed, 29 Mar 2023 09:58:12 -0600 Subject: [PATCH] When network.json is created by integration, node bandwidth will be capped by parent nodes --- src/integrationCommon.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/integrationCommon.py b/src/integrationCommon.py index 33f20e31..52d7b6f2 100644 --- a/src/integrationCommon.py +++ b/src/integrationCommon.py @@ -291,14 +291,19 @@ class NetworkGraph: del self.__visited + # Child nodes inherit bandwidth maximums of parents. We apply this here to avoid bugs when compression is applied with flattenA(). def inheritBandwidthMaxes(data, parentMaxDL, parentMaxUL): for node in data: if isinstance(node, str): if (isinstance(data[node], dict)) and (node != 'children'): + # Cap based on this node's max bandwidth, or parent node's max bandwidth, whichever is lower data[node]['downloadBandwidthMbps'] = min(int(data[node]['downloadBandwidthMbps']),int(parentMaxDL)) data[node]['uploadBandwidthMbps'] = min(int(data[node]['uploadBandwidthMbps']),int(parentMaxUL)) + # Recursive call this function for children nodes attached to this node if 'children' in data[node]: + # We need to keep tabs on the minor counter, because we can't have repeating class IDs. Here, we bring back the minor counter from the recursive function inheritBandwidthMaxes(data[node]['children'], data[node]['downloadBandwidthMbps'], data[node]['uploadBandwidthMbps']) + # Here is the actual call to the recursive function inheritBandwidthMaxes(topLevelNode, parentMaxDL=upstreamBandwidthCapacityDownloadMbps, parentMaxUL=upstreamBandwidthCapacityUploadMbps) with open('network.json', 'w') as f: