networkOrchestrator.hpp 1.7 KB

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