Browse Source

server CPU time log

sshsshy 3 years ago
parent
commit
cd544b96cd
3 changed files with 24 additions and 4 deletions
  1. 1 1
      ZT_LSORAMserver.cc
  2. 2 2
      ZT_ORAMserver.cc
  3. 21 1
      pirserver.cc

+ 1 - 1
ZT_LSORAMserver.cc

@@ -118,7 +118,7 @@ void ZT_LSORAMServer::initializeZeroTrace() {
   ret = ECDSA_do_verify((const unsigned char*) serialized_public_key, PRIME256V1_KEY_SIZE*2, sig_enclave, enclave_verification_key);
 
   if(ret==1){
-	  //fprintf(stderr, "ZT_LSORAM: init: GetEnclavePublishedKey : Verification Successful! \n");
+	  fprintf(stderr, "ZT_LSORAM: init: GetEnclavePublishedKey : Verification Successful! \n");
   }
   else{
 	  fprintf(stderr, "ZT_LSORAM: init: GetEnclavePublishedKey : Verification FAILED! \n");

+ 2 - 2
ZT_ORAMserver.cc

@@ -46,7 +46,7 @@ EC_KEY *ENCLAVE_PUBLIC_KEY = NULL;
 
 // ZT Spawn new ORAM command:
 // ZT_New(max_blocks, data_size, stash_size, oblivious, recursion_data_size, oram_type, Z);
-#define MAX_BLOCKS 1000
+#define MAX_BLOCKS 100
 #define OBLIVIOUS_TYPE_ORAM 1
 #define RECURSION_DATA_SIZE 64
 
@@ -135,7 +135,7 @@ void ZT_ORAMServer::initializeZeroTrace() {
   ret = ECDSA_do_verify((const unsigned char*) serialized_public_key, PRIME256V1_KEY_SIZE*2, sig_enclave, enclave_verification_key);
 
   if(ret==1){
-	  //fprintf(stderr, "ZT_LSORAM: init: GetEnclavePublishedKey : Verification Successful! \n");
+	  fprintf(stderr, "ZT_LSORAM: init: GetEnclavePublishedKey : Verification Successful! \n");
   }
   else{
 	  fprintf(stderr, "ZT_LSORAM: init: GetEnclavePublishedKey : Verification FAILED! \n");

+ 21 - 1
pirserver.cc

@@ -6,8 +6,12 @@
 #include <unistd.h>
 #include <arpa/inet.h>
 #include <string>
+#include <stdio.h>
+#include <time.h>
 #include "pirserver.h"
 
+#define PIRSERVER_LOG_FILE "pirserverlog"
+
 #define PIRSERVER_HDR_SIZE 13
 
 #define PIRSERVER_REQUEST_PARAMS 0x01
@@ -49,6 +53,8 @@ write_all(const char *buf, size_t len)
 void
 PIRServer::mainloop()
 {
+    FILE *fptr = fopen(PIRSERVER_LOG_FILE, "a");
+    clock_t start, end, cpu_time;
     char header[PIRSERVER_HDR_SIZE];
     size_t bodylen = 0;
     char *body = NULL;
@@ -69,6 +75,7 @@ PIRServer::mainloop()
         // We have a complete request.  Dispatch it.
         switch(header[8]) {
         case PIRSERVER_REQUEST_PARAMS:
+            start = clock();
             get_params(response);
             response_len = response.length();
             header[8] = PIRSERVER_RESPONSE_PARAMS;
@@ -79,15 +86,21 @@ PIRServer::mainloop()
                 res = write_all(response.c_str(), response_len);
                 if (res <= 0) return;
             }
+            end = clock();
+            fprintf(fptr, "REQUEST_PARAMS,");
             break;
         case PIRSERVER_REQUEST_STORE:
             if (bodylen >= 32) {
+                start = clock();
                 string key(body, 32);
                 string value(body+32, bodylen-32);
                 store(key, value);
+                end=clock();
+                fprintf(fptr, "STORE,");
             }
             break;
         case PIRSERVER_REQUEST_LOOKUP:
+            start = clock();
             query.assign(body, bodylen);
             if (lookup(query, response)) {
                 response_len = response.length();
@@ -103,9 +116,16 @@ PIRServer::mainloop()
                 res = write_all(response.c_str(), response_len);
                 if (res <= 0) return;
             }
+            end = clock();
+            fprintf(fptr, "LOOKUP,");
             break;
         }
-
+        
+        cpu_time = end - start;
+        //Time logged in ms
+        fprintf(fptr,"%f\n", ((float)cpu_time/CLOCKS_PER_SEC) * 1000 );
+        fflush(fptr);
+        
         // Clean up for the next request.
         free(body);
         body = NULL;