Skip to content

Instantly share code, notes, and snippets.

@gpolitis
Last active August 17, 2021 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpolitis/53e1d19af623b71d4fda6b8132c3a522 to your computer and use it in GitHub Desktop.
Save gpolitis/53e1d19af623b71d4fda6b8132c3a522 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import numpy as np
# A: the array with the possible last-n values
# B: the array with the calls (where each element X represents a X-peeps call)
# returns a matrix where each row "i" is a vector of how many LD streams a
# participant in call "j" would receive.
def product(A, B):
res = np.empty([len(A), len(B)])
for i,row in enumerate(A):
for j,col in enumerate(B):
res[i, j] = np.max(np.min([row, col]), 0)
return res
# endpoints: the array with the calls (where each element X represent a X-peeps
# call.
# last_n: the array with the possible last-n values.
# returns an array where each element contains the total bitrate going through
# the bridge for each last-n value.
def bitrate(endpoints, last_n):
endpoint_recv_rates = endpoint_send_rates[2] + product(last_n - 1, endpoints - 2)*endpoint_send_rates[0]
bridge_send_rate = np.matmul(endpoints, endpoint_recv_rates.T)
bridge_recv_rate = np.sum(endpoints*np.sum(endpoint_send_rates))
bridge_total = bridge_recv_rate + bridge_send_rate
return bridge_total
# we may have tweaked these a bit in meet
endpoint_send_rates = np.array([.2, .5, 2.5])
# assume a couple of calls, one 35-peeps and one 25-peeps
endpoints = np.array([35, 25])
# compute the bitrate for different last_n values
last_n = np.array([100, 9, 1])
# With these variables the bitrate method computes [688. 450. 354.] which means
# for the above two calls the (max) total bitrate will be
#
# 688Mbps with last_n 100
# 438Mbps with last_n 9
# 342Mbps with last_n 1
#
# This is the max, the actual bitrate will be more or less depending on network
# conditions and user settings (low bandwidth mode, tile-view, etc.).
print(bitrate(endpoints, last_n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment