Browse Source

epoch_duration removed from enclave_api.h (clients don't need epoch_durations). Epoch_duration taken as a command line parameter for experiment script to tune that depending on the experiment. Log connected clients to confirm the number of active clients

Sajin 1 year ago
parent
commit
46092807eb
6 changed files with 28 additions and 9 deletions
  1. 2 0
      App/net.cpp
  2. 1 0
      App/net.hpp
  3. 15 4
      App/start.cpp
  4. 1 0
      App/start.hpp
  5. 9 3
      App/teems.cpp
  6. 0 2
      Enclave/enclave_api.h

+ 2 - 0
App/net.cpp

@@ -16,6 +16,7 @@
 #define CEILDIV(x,y) (((x)+(y)-1)/(y))
 
 NetIO *g_netio = NULL;
+size_t client_count = 0;
 
 NodeIO::NodeIO(tcp::socket &&socket, nodenum_t nodenum) :
     sock(std::move(socket)), node_num(nodenum), msgsize_inflight(0),
@@ -248,6 +249,7 @@ void NetIO::ing_authenticate_new_client(tcp::socket* csocket,
             // Receive client message bundles on this socket
             // for client sim_id c_simid
             if(ret) {
+                client_count++;
                 ing_receive_msgbundle(csocket, c_simid);
             } else{
                 printf("Client <-> Ingestion authentication failed\n");

+ 1 - 0
App/net.hpp

@@ -176,5 +176,6 @@ public:
 };
 
 extern NetIO *g_netio;
+extern size_t client_count;
 
 #endif

+ 15 - 4
App/start.cpp

@@ -5,6 +5,9 @@
 #include "Untrusted.hpp"
 #include "start.hpp"
 
+// epoch_duration is set to 5 seconds by default
+int epoch_duration = 5;
+
 class Epoch {
     NetIO &netio;
     uint32_t epoch_num;
@@ -147,6 +150,12 @@ static void epoch_clients(NetIO &netio) {
 
 static void route_clients_test(NetIO &netio)
 {
+    // Default epoch_interval is 5 sec
+    size_t epoch_interval = epoch_duration * 1000000;
+    printf("Epoch duration = %d\n", epoch_duration);
+    // Sleep two epoch_interval for clients to connect
+    usleep(2 * epoch_interval);
+
     // Precompute some WaksmanNetworks
     const Config &config = netio.config();
     size_t num_sizes = ecall_precompute_sort(-2);
@@ -163,7 +172,7 @@ static void route_clients_test(NetIO &netio)
     }
 
     // Run epoch
-    for (int i=1; i<50; ++i) {
+    for (int i=1; i<=10; ++i) {
         struct timespec tp;
         clock_gettime(CLOCK_REALTIME_COARSE, &tp);
         unsigned long start = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
@@ -174,12 +183,14 @@ static void route_clients_test(NetIO &netio)
         unsigned long end = tp.tv_sec * 1000000 + tp.tv_nsec/1000;
         unsigned long diff = end - start;
 
-        printf("Epoch time: %lu.%06lu s\n", diff/1000000, diff%1000000);
+        //printf("client_count = %ld\n", client_count);
+        printf("Epoch %d time: %lu.%06lu s\n", i, diff/1000000, diff%1000000);
 
         // Sleep for the rest of the epoch interval
-        if (diff < EPOCH_INTERVAL) {
-            usleep(EPOCH_INTERVAL - (useconds_t) diff);
+        if (diff < epoch_interval) {
+            usleep(epoch_interval - (useconds_t) diff);
         }
+
     }
     netio.close();
     exit(0);

+ 1 - 0
App/start.hpp

@@ -7,4 +7,5 @@
 // to do on the command line
 void start(NetIO &netio, char **args);
 
+extern int epoch_duration;
 #endif

+ 9 - 3
App/teems.cpp

@@ -129,7 +129,7 @@ static void usage(const char *argv0)
 {
     fprintf(stderr, "Usage: %s --gen sealedprivkeyfile pubkeyfile\n",
         argv0);
-    fprintf(stderr, "or     %s -k sealedprivkeyfile -n myname [-t nthreads] [command] < config.json\n",
+    fprintf(stderr, "or     %s -k sealedprivkeyfile -n myname [-t nthreads] [-e epoch_duration] [command] < config.json\n",
         argv0);
     exit(1);
 }
@@ -201,6 +201,12 @@ int main(int argc, char **argv)
                 usage(progname);
             }
             nthreads = uint16_t(atoi(argv[1]));
+            argv += 2;    
+        } else if (!strcmp(*argv, "-e")) {
+            if (argv[1] == NULL) {
+                usage(progname);
+            }
+            epoch_duration = size_t(atoi(argv[1]));
             argv += 2;
         } else {
             usage(progname);
@@ -259,8 +265,8 @@ int main(int argc, char **argv)
             NodeIO &node = netio.node(node_num);
             node.recv_commands(
                 // error_cb
-                [node_num](boost::system::error_code ec) {
-                    printf("Error %s from %d\n", ec.message().c_str(), node_num);
+                [node_num, &config](boost::system::error_code ec) {
+                    printf("Error %s from %d %s\n", ec.message().c_str(), node_num, config.nodes[node_num].name.c_str());
                 },
                 // epoch_cb
                 [](uint32_t epoch) {

+ 0 - 2
Enclave/enclave_api.h

@@ -40,6 +40,4 @@ struct EnclaveAPINodeConfig {
 #define DEST_STORAGE_NODE_BITS 10
 #define DEST_UID_BITS 22
 
-// Epoch timing configuration (in us)
-#define EPOCH_INTERVAL 2000000
 #endif