From: bert hubert Date: Sat, 31 Jan 2015 19:38:49 +0000 (+0100) Subject: attempt at calibrated qps generator X-Git-Tag: dnsdist-1.0.0-alpha1~311 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d8a5de79720cfc147041c4a0bf3e45483062488;p=thirdparty%2Fpdns.git attempt at calibrated qps generator --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 165e82608b..cab789a994 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -75,12 +75,13 @@ bin_PROGRAMS += \ saxfr if CXX2011 -bin_PROGRAMS += dnsdist +bin_PROGRAMS += dnsdist calidns endif endif EXTRA_PROGRAMS = \ + calidns \ dnsbulktest \ dnsdemog \ dnsdist \ @@ -464,6 +465,28 @@ sdig_SOURCES = \ sdig_LDADD = $(POLARSSL_LIBS) sdig_LDFLAGS=$(THREADFLAGS) +calidns_SOURCES = \ + base32.cc \ + base64.cc base64.hh \ + calidns.cc \ + dnslabeltext.cc \ + dnsparser.cc dnsparser.hh \ + dnsrecords.cc \ + dnswriter.cc dnswriter.hh \ + logger.cc \ + misc.cc misc.hh \ + nsecrecords.cc \ + qtype.cc \ + rcpgenerator.cc rcpgenerator.hh \ + sillyrecords.cc \ + sstuff.hh \ + statbag.cc \ + unix_utility.cc + +calidns_LDADD = $(POLARSSL_LIBS) +calidns_LDFLAGS=$(THREADFLAGS) + + saxfr_SOURCES = \ base32.cc \ base64.cc base64.hh \ diff --git a/pdns/calidns.cc b/pdns/calidns.cc new file mode 100644 index 0000000000..5e8399c066 --- /dev/null +++ b/pdns/calidns.cc @@ -0,0 +1,114 @@ +#include +#include "dnsparser.hh" +#include "sstuff.hh" +#include "misc.hh" +#include "dnswriter.hh" +#include "dnsrecords.hh" +#include +#include +#include "statbag.hh" +#include +using std::thread; + +StatBag S; + +std::atomic g_recvcounter; +volatile bool g_done; + +void* recvThread(Socket* s) +{ + char response[1500]; + while(!g_done) { + try { + s->read(response, sizeof(response)); + g_recvcounter++; + } + catch(...){} + } + return 0; +} + + +void setSocketBuffer(int fd, int optname, uint32_t size) +{ + uint32_t psize=0; + socklen_t len=sizeof(psize); + + if(!getsockopt(fd, SOL_SOCKET, optname, (char*)&psize, &len) && psize > size) { + cerr<<"Not decreasing socket buffer size from "< > packets; + while(getline(ifs, line)) { + vector packet; + boost::trim(line); + auto p = splitField(line, ' '); + DNSPacketWriter pw(packet, p.first, DNSRecordContent::TypeToNumber(p.second)); + packets.push_back(packet); + } + cout<<"Generated "<