From 73d0d76f29e03f5b1fc29be3095f7ac8642c8848 Mon Sep 17 00:00:00 2001 From: Logan oos Even <46396513+Logan007@users.noreply.github.com> Date: Sat, 12 Mar 2022 20:56:56 +0100 Subject: [PATCH] changed benchmark to MTU sized packets (#966) --- tools/n2n-benchmark.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/tools/n2n-benchmark.c b/tools/n2n-benchmark.c index 2dba6f2..b4a3c95 100644 --- a/tools/n2n-benchmark.c +++ b/tools/n2n-benchmark.c @@ -28,23 +28,7 @@ #define PACKETS_BEFORE_GETTIME 2047 // do not check time after every packet but after (2 ^ n - 1) -uint8_t PKT_CONTENT[]={ - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }; +uint8_t PKT_CONTENT[DEFAULT_MTU]; /* Prototypes */ static ssize_t do_encode_packet( uint8_t * pktbuf, size_t bufsize, const n2n_community_t c ); @@ -56,6 +40,8 @@ static void run_ecc_benchmark(void); int main(int argc, char * argv[]) { uint8_t pktbuf[N2N_PKT_BUF_SIZE]; + size_t i; + n2n_trans_op_t transop_null, transop_tf; n2n_trans_op_t transop_aes; n2n_trans_op_t transop_cc20; @@ -71,6 +57,7 @@ int main(int argc, char * argv[]) { /* Init configuration */ edge_init_conf_defaults(&conf); + strncpy((char*)conf.community_name, "abc123def456", sizeof(conf.community_name)); conf.encrypt_key = "SoMEVer!S$cUREPassWORD"; @@ -87,6 +74,11 @@ int main(int argc, char * argv[]) { n2n_transop_zstd_init(&conf, &transop_zstd); #endif + /* Setup packet content */ + for (i = 0; i < sizeof(PKT_CONTENT) / sizeof(PKT_CONTENT[0]); i++) { + PKT_CONTENT[i] = i & 0x0f; + } + /* Run the tests */ run_transop_benchmark("null", &transop_null, &conf, pktbuf); run_transop_benchmark("tf", &transop_tf, &conf, pktbuf);