浏览代码

Create some messages to raw ingest

Ian Goldberg 1 年之前
父节点
当前提交
fb55160555
共有 4 个文件被更改,包括 81 次插入1 次删除
  1. 1 0
      App/net.hpp
  2. 77 0
      App/start.cpp
  3. 1 1
      Enclave/Enclave.config.xml
  4. 2 0
      Enclave/route.cpp

+ 1 - 0
App/net.hpp

@@ -135,6 +135,7 @@ public:
         assert(node_num < num_nodes);
         return nodeios[node_num].value();
     }
+    const Config &config() { return conf; }
 };
 
 extern NetIO *g_netio;

+ 77 - 0
App/start.cpp

@@ -1,11 +1,88 @@
 #include <stdlib.h>
 
+#include "Untrusted.hpp"
 #include "start.hpp"
 
+static void route_test(NetIO &netio, char **args)
+{
+    // Count the number of arguments
+    size_t nargs = 0;
+    while (args[nargs]) {
+        ++nargs;
+    }
+
+    uint16_t num_nodes = netio.num_nodes;
+    size_t sq_nodes = num_nodes;
+    sq_nodes *= sq_nodes;
+
+    if (nargs != sq_nodes) {
+        printf("Expecting %lu arguments, found %lu\n", sq_nodes, nargs);
+        return;
+    }
+
+    // The arguments are num_nodes sets of num_nodes values.  The jth
+    // value in the ith set is the number of private routing tokens
+    // ingestion node i holds for storage node j.
+
+    // We are node i = netio.me, so ignore the other sets of values.
+
+    uint32_t num_tokens[num_nodes];
+    uint32_t tot_tokens = 0;
+    for (nodenum_t j=0;j<num_nodes;++j) {
+        num_tokens[j] = atoi(args[netio.me*num_nodes+j]);
+        tot_tokens += num_tokens[j];
+    }
+
+    const Config &config = netio.config();
+    uint16_t msg_size = config.msg_size;
+
+    uint8_t *msgs = new uint8_t[tot_tokens * msg_size];
+    uint8_t *nextmsg = msgs;
+    uint32_t dest_uid_mask = (1 << DEST_UID_BITS) - 1;
+    uint32_t rem_tokens = tot_tokens;
+    while (rem_tokens > 0) {
+        // Pick a random remaining token
+        uint32_t r = uint32_t(lrand48()) % rem_tokens;
+        for (nodenum_t j=0;j<num_nodes;++j) {
+            if (r < num_tokens[j]) {
+                // Use a token from node j
+                *((uint32_t*)nextmsg) =
+                    (j << DEST_UID_BITS) + (r & dest_uid_mask);
+                // Put a bunch of copies of r as the message body
+                for (uint16_t i=1;i<msg_size/4;++i) {
+                    ((uint32_t*)nextmsg)[i] = r;
+                }
+                num_tokens[j] -= 1;
+                rem_tokens -= 1;
+                nextmsg += msg_size;
+            } else {
+                r -= num_tokens[j];
+            }
+        }
+    }
+    /*
+    for (uint32_t i=0;i<tot_tokens;++i) {
+        for(uint16_t j=0;j<msg_size/4;++j) {
+            printf("%08x ", ((uint32_t*)msgs)[i*msg_size/4+j]);
+        }
+        printf("\n");
+    }
+    */
+    if (!ecall_ingest_raw(msgs, tot_tokens)) {
+        printf("Ingestion failed\n");
+        return;
+    }
+}
+
 // Once all the networking is set up, start doing whatever we were asked
 // to do on the command line
 void start(NetIO &netio, char **args)
 {
+    if (*args && !strcmp(*args, "route")) {
+        ++args;
+        route_test(netio, args);
+        return;
+    }
     printf("Reading\n");
     for (nodenum_t node_num = 0; node_num < netio.num_nodes; ++node_num) {
         if (node_num == netio.me) continue;

+ 1 - 1
Enclave/Enclave.config.xml

@@ -3,7 +3,7 @@
   <ProdID>0</ProdID>
   <ISVSVN>0</ISVSVN>
   <StackMaxSize>0x40000</StackMaxSize>
-  <HeapMaxSize>0x3000000</HeapMaxSize>
+  <HeapMaxSize>0x8000000</HeapMaxSize>
   <TCSNum>10</TCSNum>
   <TCSPolicy>1</TCSPolicy>
   <DisableDebug>0</DisableDebug>

+ 2 - 0
Enclave/route.cpp

@@ -146,6 +146,8 @@ bool ecall_ingest_raw(uint8_t *msgs, uint32_t num_msgs)
     uint32_t start = round1.reserved;
     if (start + num_msgs > route_state.tot_msg_per_ing) {
         pthread_mutex_unlock(&round1.mutex);
+        printf("Max %u messages exceeded\n",
+            route_state.tot_msg_per_ing);
         return false;
     }
     round1.reserved += num_msgs;