12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #!/usr/bin/python3
- import subprocess
- import os
- import sys
- import math
- from core_allocator import core_allocation
- # CONFIGS TO SET:
- MANIFEST_FILE = "App/manifest.yaml"
- '''
- Generate a manifest file with:
- N: number of clients
- M: number of servers
- T: number of threads for each server
- B: msg_size
- '''
- def generate_manifest(N, M, T, B, PRIVATE_ROUTE = True, priv_out=1, priv_in=1, pub_out=1, pub_in=1):
- (servers_allocation, client_allocation) = core_allocation(M, T)
- assert servers_allocation is not None
- assert client_allocation is not None
- mf = open(MANIFEST_FILE, 'w+')
- manifest_params = '''params:
- # The total max number of users
- user_count: {N}
- # The size of a message in bytes
- msg_size: {B}
- # The number of private messages each user can send per epoch
- priv_out: {pro}
- # The number of private messages each user can receive per epoch
- priv_in: {pri}
- # The number of public messages each user can send per epoch
- pub_out: {puo}
- # The number of public messages each user can receive per epoch
- pub_in: {pui}
- # Private or public routing protocol selection
- private_routing: {PRIVATE_ROUTE}
- # Currently hardcoding an AES key for client -> server communications,
- # but in reality, a key exchange would be done
- master_secret: \"AHardCodedAESKey\"\n'''.format(N = str(N), B = str(B), PRIVATE_ROUTE=str(PRIVATE_ROUTE),\
- pro = str(priv_out), pri = str(priv_in), puo = str(pub_out), pui = str(pub_in))
- # print (manifest_params)
- mf.write(manifest_params)
- server_params = '''\ns{i}:
- sprvfile: keys/priv.seal.s{i}
- pubfile: keys/pub.s{i}
- weight: 1
- listen: 127.0.0.{i}:12500
- clisten: 127.0.0.{i}:13000
- slisten: 127.0.0.{i}:13001
- launchprefix: numactl {nstring}
- args: -t {T}
- roles: 7\n'''
- for s in range(1, M+1):
- core_alloc = servers_allocation[s-1]
- numa_string = "-C " + ",".join(map(str, core_alloc))
- curr_params = server_params.format(i = str(s), nstring = numa_string, T = str(T))
- # print(curr_params)
- mf.write(curr_params)
- mf.close()
- if __name__ == "__main__":
- if(len(sys.argv)!=5):
- print("Incorrect usage!\n Expects 4 parameters. n,m,t,b")
- exit()
- n = int(sys.argv[1])
- m = int(sys.argv[2])
- t = int(sys.argv[3])
- b = int(sys.argv[4])
- generate_manifest(n, m, t, b)
|