~ubuntu-branches/ubuntu/maverick/pdns/maverick-updates

« back to all changes in this revision

Viewing changes to pdns/dnspbench.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matthijs Mohlmann, Matthijs Mohlmann, Christoph Haas
  • Date: 2007-04-15 23:23:39 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070415232339-5x3scc8gx04e50um
Tags: 2.9.21-1
[ Matthijs Mohlmann ]
* New upstream release. (Closes: #420294)
* Remove meta pdns package.
* Added new sqlite3 backend package.
* Months and minutes where mixed up. (Closes: #406462)
* Case sensitivity in bind backend caused PowerDNS to not serve a certain
  zone. (Closes: #406461)
* Bind backend forgot about zones on a notify. (Closes: #398213)

[ Christoph Haas ]
* Documented incorporated backend bind. (Closes: #415471)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "logger.hh"
 
2
Logger L("dnspbench");
 
3
 
1
4
#include "dnsparser.hh"
2
5
#include "sstuff.hh"
3
6
#include "misc.hh"
4
7
#include "dnswriter.hh"
5
8
#include "dnsrecords.hh"
6
 
#include "logger.hh"
 
9
 
7
10
#include "statbag.hh"
 
11
#include <stdint.h>
8
12
#include <set>
9
 
#define BOOST_NO_MT
10
 
 
11
 
#include <boost/pool/pool.hpp>
12
 
#include <boost/pool/object_pool.hpp>
13
 
 
14
 
#include <boost/pool/pool_alloc.hpp>
 
13
 
15
14
using namespace boost;
16
15
 
17
 
Logger L("dnspbench");
 
16
 
18
17
StatBag S;
19
18
 
 
19
#include <bits/atomicity.h>
 
20
// This code is ugly but does speedup the recursor tremendously on multi-processor systems, and even has a large effect (20, 30%) on uniprocessor 
 
21
namespace __gnu_cxx
 
22
{
 
23
  _Atomic_word
 
24
  __attribute__ ((__unused__))
 
25
  __exchange_and_add(volatile _Atomic_word* __mem, int __val)
 
26
  {
 
27
    register _Atomic_word __result=*__mem;
 
28
    *__mem+=__val;
 
29
    return __result;
 
30
  }
 
31
 
 
32
  void
 
33
  __attribute__ ((__unused__))
 
34
  __atomic_add(volatile _Atomic_word* __mem, int __val)
 
35
  {
 
36
    *__mem+=__val;
 
37
  }
 
38
}
 
39
 
 
40
int xcount;
 
41
 
20
42
int main(int argc, char** argv)
21
43
try
22
44
{
23
 
  set<int, std::less<int>, boost::pool_allocator<int> > blah;
24
 
 
25
 
  for(unsigned int n=0;n< 1000000;++n)
26
 
    blah.insert(random());
27
 
  cerr<<"Done inserting"<<endl;
28
 
  string line;
29
 
  getline(cin, line);
30
 
  cerr<<"Done!"<<endl;
31
 
 
32
 
  exit(0);
33
 
 
34
 
  dnsheader dnsheader;
35
 
  dnsheader.qdcount=htons(1);
36
 
  dnsheader.ancount=htons(1);
 
45
  reportAllTypes();
 
46
 
37
47
  Socket s(InterNetwork, Datagram);
38
 
  string spacket;
39
 
  char* p=(char*)&dnsheader;
40
 
  spacket.assign(p, p+sizeof(dnsheader));
41
 
  IPEndpoint rem("127.0.0.1",5300);
42
 
  s.sendTo(spacket, rem);
43
48
  
44
 
  return 0;
45
 
 
46
 
  reportAllTypes();
 
49
  IPEndpoint rem("10.0.1.6", atoi(argv[1])), loc("213.156.2.1", 53);
 
50
  //  s.bind(loc);
 
51
 
 
52
  vector<uint8_t> vpacket;
 
53
  string domain="ds9a.nl";
 
54
  uint16_t type=1;
 
55
 
 
56
  for(unsigned int n=0; n < 65536; ++n) {
 
57
    DNSPacketWriter pw(vpacket, domain, type);
 
58
    
 
59
    pw.getHeader()->rd=1;
 
60
    pw.getHeader()->qr=0;
 
61
    pw.getHeader()->id=n;
 
62
    //    ARecordContent arc("1.2.3.4");
 
63
    //    pw.startRecord("ds9a.nl", 1, 9999, 1, DNSPacketWriter::ANSWER);
 
64
    //    arc.toPacket(pw);
 
65
    //    pw.commit();
 
66
 
 
67
    string spacket((char*)(&*vpacket.begin()), vpacket.size());
 
68
    s.sendTo(spacket, rem);
 
69
  }
 
70
 
 
71
  return 0; 
 
72
#if 0
47
73
 
48
74
  vector<uint8_t> packet;
49
75
 
61
87
 
62
88
  shared_ptr<DNSRecordContent> regen=DNSRecordContent::unserialize(argv[1], type, record);
63
89
  cerr<<"Out: "<<argv[1]<<" IN "<<argv[2]<<" "<<regen->getZoneRepresentation()<<endl;
 
90
#endif
64
91
}
65
92
catch(exception& e)
66
93
{