gen_manifest.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/python3
  2. import subprocess
  3. import os
  4. import sys
  5. import math
  6. from core_allocator import core_allocation
  7. # CONFIGS TO SET:
  8. MANIFEST_FILE = "App/manifest.yaml"
  9. '''
  10. Generate a manifest file with:
  11. N: number of clients
  12. M: number of servers
  13. T: number of threads for each server
  14. B: msg_size
  15. '''
  16. def generate_manifest(N, M, T, B, TOKEN_CHANNEL = True, token_out=1, token_in=1, id_out=1, id_in=1):
  17. (servers_allocation, client_allocation) = core_allocation(M, T)
  18. assert servers_allocation is not None
  19. assert client_allocation is not None
  20. mf = open(MANIFEST_FILE, 'w+')
  21. manifest_params = '''params:
  22. # The total max number of users
  23. user_count: {N}
  24. # The size of a message in bytes
  25. msg_size: {B}
  26. # The number of token channel messages each user can send per epoch
  27. token_out: {toko}
  28. # The number of token channel messages each user can receive per epoch
  29. token_in: {toki}
  30. # The number of ID channel messages each user can send per epoch
  31. id_out: {ido}
  32. # The number of ID channel messages each user can receive per epoch
  33. id_in: {idi}
  34. # Token channel or ID channel routing protocol selection
  35. token_channel: {TOKEN_CHANNEL}
  36. # Currently hardcoding an AES key for client -> server communications,
  37. # but in reality, a key exchange would be done
  38. master_secret: \"AHardCodedAESKey\"\n'''.format(N = str(N), B = str(B), TOKEN_CHANNEL=str(TOKEN_CHANNEL),\
  39. toko = str(token_out), toki = str(token_in), ido = str(id_out), idi = str(id_in))
  40. # print (manifest_params)
  41. mf.write(manifest_params)
  42. server_params = '''\ns{i}:
  43. sprvfile: keys/priv.seal.s{i}
  44. pubfile: keys/pub.s{i}
  45. weight: 1
  46. listen: 127.0.0.{i}:12500
  47. clisten: 127.0.0.{i}:13000
  48. slisten: 127.0.0.{i}:13001
  49. launchprefix: numactl {nstring}
  50. args: -t {T}
  51. roles: 7\n'''
  52. for s in range(1, M+1):
  53. core_alloc = servers_allocation[s-1]
  54. numa_string = "-C " + ",".join(map(str, core_alloc))
  55. curr_params = server_params.format(i = str(s), nstring = numa_string, T = str(T))
  56. # print(curr_params)
  57. mf.write(curr_params)
  58. mf.close()
  59. if __name__ == "__main__":
  60. if(len(sys.argv)!=5):
  61. print("Incorrect usage!\n Expects 4 parameters. n,m,t,b")
  62. exit()
  63. n = int(sys.argv[1])
  64. m = int(sys.argv[2])
  65. t = int(sys.argv[3])
  66. b = int(sys.argv[4])
  67. generate_manifest(n, m, t, b)