networkOrchestrator.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef __PRSONA_NETWORK_ORCHESTRATOR_HPP
  2. #define __PRSONA_NETWORK_ORCHESTRATOR_HPP
  3. #include <string>
  4. #include <vector>
  5. #include <chrono>
  6. #include "networking.hpp"
  7. const std::chrono::seconds ONE_SECOND(1);
  8. const std::chrono::milliseconds HALF_SECOND(500);
  9. /* "PUBLIC" FUNCTIONS */
  10. // START UP AND SHUT DOWN INSTANCES
  11. int start_remote_actor(
  12. const std::string& target,
  13. bool server,
  14. const std::string& id,
  15. const std::string& output,
  16. size_t lambda,
  17. bool maliciousServers);
  18. void shut_down_remote_actors(
  19. const std::vector<std::string>& relevantIPs,
  20. const std::vector<int>& relevantPorts);
  21. // SYNCHRONIZATION
  22. void wait_for_servers_ready(
  23. std::string dealer,
  24. int dealerPort);
  25. void wait_for_clients_created(
  26. std::string dealer,
  27. int dealerPort,
  28. size_t numClients);
  29. void wait_for_client_ready(
  30. std::string client,
  31. int clientPort);
  32. // RUN EXPERIMENT
  33. void execute_experiment(
  34. std::default_random_engine& rng,
  35. std::string dealerIP,
  36. int dealerPort,
  37. std::vector<std::string> serverIPs,
  38. std::vector<int> serverPorts,
  39. std::vector<std::string> clientIPs,
  40. std::vector<int> clientPorts,
  41. const char *filename);
  42. /* "PRIVATE" FUNCTIONS */
  43. // TRIGGER EXPERIMENT EVENTS
  44. void trigger_epoch_change(
  45. std::string dealer,
  46. int dealerPort);
  47. void trigger_vote(
  48. std::string target,
  49. int targetPort);
  50. void trigger_reputation_proof(
  51. std::string target,
  52. int targetPort,
  53. std::string verifier,
  54. int verifierPort);
  55. // EXECUTOR HELPER
  56. std::vector<size_t> generate_random_set(
  57. std::default_random_engine& rng,
  58. size_t size,
  59. size_t maxVal);
  60. #endif