mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Fix queuingStructure.json
This commit is contained in:
parent
2beac8ce19
commit
98f109b1af
@ -553,18 +553,22 @@ def refreshShapers():
|
|||||||
devicesShaped = []
|
devicesShaped = []
|
||||||
parentNodes = []
|
parentNodes = []
|
||||||
def traverseNetwork(data, depth, major, minor, queue, parentClassID, parentMaxDL, parentMaxUL):
|
def traverseNetwork(data, depth, major, minor, queue, parentClassID, parentMaxDL, parentMaxUL):
|
||||||
tabs = ' ' * depth
|
|
||||||
for elem in data:
|
for elem in data:
|
||||||
circuitsForThisNetworkNode = {}
|
circuitsForThisNetworkNode = []
|
||||||
elemClassID = hex(major) + ':' + hex(minor)
|
elemClassID = hex(major) + ':' + hex(minor)
|
||||||
|
data[elem]['classid'] = elemClassID
|
||||||
# Cap based on this node's max bandwidth, or parent node's max bandwidth, whichever is lower
|
# Cap based on this node's max bandwidth, or parent node's max bandwidth, whichever is lower
|
||||||
elemDownloadMax = min(data[elem]['downloadBandwidthMbps'],parentMaxDL)
|
elemDownloadMax = min(data[elem]['downloadBandwidthMbps'],parentMaxDL)
|
||||||
elemUploadMax = min(data[elem]['uploadBandwidthMbps'],parentMaxUL)
|
elemUploadMax = min(data[elem]['uploadBandwidthMbps'],parentMaxUL)
|
||||||
|
data[elem]['downloadBandwidthMbps'] = elemDownloadMax
|
||||||
|
data[elem]['uploadBandwidthMbps'] = elemUploadMax
|
||||||
# Calculations are done in findBandwidthMins(), determine optimal HTB rates (mins) and ceils (maxs)
|
# Calculations are done in findBandwidthMins(), determine optimal HTB rates (mins) and ceils (maxs)
|
||||||
# For some reason that doesn't always yield the expected result, so it's better to play with ceil more than rate
|
# For some reason that doesn't always yield the expected result, so it's better to play with ceil more than rate
|
||||||
# Here we override the rate as 95% of ceil.
|
# Here we override the rate as 95% of ceil.
|
||||||
elemDownloadMin = round(elemDownloadMax*.95)
|
elemDownloadMin = round(elemDownloadMax*.95)
|
||||||
elemUploadMin = round(elemUploadMax*.95)
|
elemUploadMin = round(elemUploadMax*.95)
|
||||||
|
data[elem]['downloadBandwidthMbpsMin'] = elemDownloadMin
|
||||||
|
data[elem]['uploadBandwidthMbpsMin'] = elemUploadMin
|
||||||
command = 'class add dev ' + interfaceA + ' parent ' + parentClassID + ' classid ' + hex(minor) + ' htb rate '+ str(round(elemDownloadMin)) + 'mbit ceil '+ str(round(elemDownloadMax)) + 'mbit prio 3' + " # Node: " + elem
|
command = 'class add dev ' + interfaceA + ' parent ' + parentClassID + ' classid ' + hex(minor) + ' htb rate '+ str(round(elemDownloadMin)) + 'mbit ceil '+ str(round(elemDownloadMax)) + 'mbit prio 3' + " # Node: " + elem
|
||||||
linuxTCcommands.append(command)
|
linuxTCcommands.append(command)
|
||||||
command = 'class add dev ' + interfaceB + ' parent ' + parentClassID + ' classid ' + hex(minor) + ' htb rate '+ str(round(elemUploadMin)) + 'mbit ceil '+ str(round(elemUploadMax)) + 'mbit prio 3'
|
command = 'class add dev ' + interfaceB + ' parent ' + parentClassID + ' classid ' + hex(minor) + ' htb rate '+ str(round(elemUploadMin)) + 'mbit ceil '+ str(round(elemUploadMax)) + 'mbit prio 3'
|
||||||
@ -591,6 +595,7 @@ def refreshShapers():
|
|||||||
parentString = hex(major) + ':'
|
parentString = hex(major) + ':'
|
||||||
flowIDstring = hex(major) + ':' + hex(minor)
|
flowIDstring = hex(major) + ':' + hex(minor)
|
||||||
circuit['qdisc'] = flowIDstring
|
circuit['qdisc'] = flowIDstring
|
||||||
|
# Create circuit dictionary to be added to network structure, eventually output as queuingStructure.json
|
||||||
thisNewCircuitItemForNetwork = {
|
thisNewCircuitItemForNetwork = {
|
||||||
'maxDownload' : maxDownload,
|
'maxDownload' : maxDownload,
|
||||||
'maxUpload' : maxUpload,
|
'maxUpload' : maxUpload,
|
||||||
@ -600,13 +605,10 @@ def refreshShapers():
|
|||||||
"circuitName": circuit['circuitName'],
|
"circuitName": circuit['circuitName'],
|
||||||
"ParentNode": circuit['ParentNode'],
|
"ParentNode": circuit['ParentNode'],
|
||||||
"devices": circuit['devices'],
|
"devices": circuit['devices'],
|
||||||
"downloadMin": circuit['downloadMin'],
|
|
||||||
"uploadMin": circuit['uploadMin'],
|
|
||||||
"downloadMax": circuit['downloadMax'],
|
|
||||||
"uploadMax": circuit['uploadMax'],
|
|
||||||
"qdisc": flowIDstring,
|
"qdisc": flowIDstring,
|
||||||
"comment": circuit['comment']
|
"comment": circuit['comment']
|
||||||
}
|
}
|
||||||
|
# Generate TC commands to be executed later
|
||||||
comment = " # CircuitID: " + circuit['circuitID'] + " DeviceIDs: "
|
comment = " # CircuitID: " + circuit['circuitID'] + " DeviceIDs: "
|
||||||
for device in circuit['devices']:
|
for device in circuit['devices']:
|
||||||
comment = comment + device['deviceID'] + ', '
|
comment = comment + device['deviceID'] + ', '
|
||||||
@ -619,7 +621,6 @@ def refreshShapers():
|
|||||||
linuxTCcommands.append(command)
|
linuxTCcommands.append(command)
|
||||||
command = 'qdisc add dev ' + interfaceB + ' parent ' + hex(major) + ':' + hex(minor) + ' ' + fqOrCAKE
|
command = 'qdisc add dev ' + interfaceB + ' parent ' + hex(major) + ':' + hex(minor) + ' ' + fqOrCAKE
|
||||||
linuxTCcommands.append(command)
|
linuxTCcommands.append(command)
|
||||||
|
|
||||||
thisNewCircuitItemForNetwork['devices'] = circuit['devices']
|
thisNewCircuitItemForNetwork['devices'] = circuit['devices']
|
||||||
for device in circuit['devices']:
|
for device in circuit['devices']:
|
||||||
if device['ipv4s']:
|
if device['ipv4s']:
|
||||||
@ -636,9 +637,10 @@ def refreshShapers():
|
|||||||
ipv6FiltersDst.append((ipv6, parentString, flowIDstring))
|
ipv6FiltersDst.append((ipv6, parentString, flowIDstring))
|
||||||
if device['deviceName'] not in devicesShaped:
|
if device['deviceName'] not in devicesShaped:
|
||||||
devicesShaped.append(device['deviceName'])
|
devicesShaped.append(device['deviceName'])
|
||||||
circuitsForThisNetworkNode = circuitsForThisNetworkNode | thisNewCircuitItemForNetwork
|
circuitsForThisNetworkNode.append(thisNewCircuitItemForNetwork)
|
||||||
data[elem]['circuits'] = circuitsForThisNetworkNode
|
|
||||||
minor += 1
|
minor += 1
|
||||||
|
if len(circuitsForThisNetworkNode) > 0:
|
||||||
|
data[elem]['circuits'] = circuitsForThisNetworkNode
|
||||||
# Recursive call this function for children nodes attached to this node
|
# Recursive call this function for children nodes attached to this node
|
||||||
if 'children' in data[elem]:
|
if 'children' in data[elem]:
|
||||||
# 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
|
# 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
|
||||||
|
Loading…
Reference in New Issue
Block a user