From f3f8331cf8da12c3816a63bea449d38d78ebff7c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Sat, 21 Apr 2018 22:18:43 +0200 Subject: [PATCH] calidns: Add a maximum-qps option to stay at a given stable load --- docs/manpages/calidns.1.rst | 4 ++++ pdns/calidns.cc | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/manpages/calidns.1.rst b/docs/manpages/calidns.1.rst index e43a83268..c7b943de3 100644 --- a/docs/manpages/calidns.1.rst +++ b/docs/manpages/calidns.1.rst @@ -32,6 +32,10 @@ This is similar to Alexa top 1 million list. Options ------- +--ecs Add EDNS Client Subnet option to outgoing queries using random + addresses from the specified *SUBNET* range (IPv4 only). --increment On every subsequent run, multiply the number of queries per second by *NUM*. By default, this is 1.1. +--maximum-qps Stop incrementing once this rate has been reached, to provide a + stable load. --want-recursion Set this flag to send queries with the Recursion Desired flag set. diff --git a/pdns/calidns.cc b/pdns/calidns.cc index f8b358ea4..9fb42fb97 100644 --- a/pdns/calidns.cc +++ b/pdns/calidns.cc @@ -223,6 +223,7 @@ try ("version", "Show the version number") ("ecs", po::value(), "Add EDNS Client Subnet option to outgoing queries using random addresses from the specified range (IPv4 only)") ("increment", po::value()->default_value(1.1), "Set the factor to increase the QPS load per run") + ("maximum-qps", po::value(), "Stop incrementing once this rate has been reached, to provide a stable load") ("want-recursion", "Set the Recursion Desired flag on queries"); po::options_description alloptions; po::options_description hidden("hidden options"); @@ -274,6 +275,11 @@ try hitrate /= 100; uint32_t qpsstart = g_vm["initial-qps"].as(); + uint32_t maximumQps = std::numeric_limits::max(); + if (g_vm.count("maximum-qps")) { + maximumQps = g_vm["maximum-qps"].as(); + } + Netmask ecsRange; if (g_vm.count("ecs")) { dns_random_init("0123456789abcdef"); @@ -347,10 +353,10 @@ try sockets.push_back(sock); } new thread(recvThread, &sockets); - int qps; + uint32_t qps; ofstream plot("plot"); - for(qps=qpsstart;;qps *= increment) { + for(qps=qpsstart;;) { double seconds=1; cout<<"Aiming at "<