[svn] commit: r3639 - in /branches/trac356/src/lib/nsas: nameserver_entry.cc nameserver_entry.h random_number_generator.h tests/Makefile.am tests/random_number_generator_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Nov 26 07:48:20 UTC 2010
Author: ocean
Date: Fri Nov 26 07:48:19 2010
New Revision: 3639
Log:
Add random number generator implementation and unit test
Added:
branches/trac356/src/lib/nsas/random_number_generator.h
branches/trac356/src/lib/nsas/tests/random_number_generator_unittest.cc
Modified:
branches/trac356/src/lib/nsas/nameserver_entry.cc
branches/trac356/src/lib/nsas/nameserver_entry.h
branches/trac356/src/lib/nsas/tests/Makefile.am
Modified: branches/trac356/src/lib/nsas/nameserver_entry.cc
==============================================================================
--- branches/trac356/src/lib/nsas/nameserver_entry.cc (original)
+++ branches/trac356/src/lib/nsas/nameserver_entry.cc Fri Nov 26 07:48:19 2010
@@ -40,13 +40,18 @@
namespace isc {
namespace nsas {
+// Generate a small random RTT when initialize the list of addresses
+// to select all the addresses in unpredicable order
+// The initia RTT is between 0ms and 7ms which is as the same as bind9
+#define MIN_INIT_RTT 0
+#define MAX_INIT_RTT 7
+UniformRandomIntegerGenerator NameserverEntry::rndRttGen_(MIN_INIT_RTT, MAX_INIT_RTT);
// Constructor, initialized with the list of addresses associated with this
// nameserver.
NameserverEntry::NameserverEntry(const AbstractRRset* v4Set,
const AbstractRRset* v6Set, time_t curtime) : expiration_(0)
{
- // TODO: Use pseudo-random RTT
uint32_t rtt = 0; // Round-trip time for an address
string v4name = ""; // Name from the V4 RRset
string v6name = ""; // Name from the v6 RRset
Modified: branches/trac356/src/lib/nsas/nameserver_entry.h
==============================================================================
--- branches/trac356/src/lib/nsas/nameserver_entry.h (original)
+++ branches/trac356/src/lib/nsas/nameserver_entry.h Fri Nov 26 07:48:19 2010
@@ -24,9 +24,10 @@
#include "address_entry.h"
#include "asiolink.h"
#include "exceptions/exceptions.h"
-#include "nsas_entry.h"
#include "hash_key.h"
#include "lru_list.h"
+#include "nsas_entry.h"
+#include "random_number_generator.h"
#include "rrset.h"
namespace isc {
@@ -195,12 +196,13 @@
};
private:
- boost::mutex mutex_; ///< Mutex protecting this object
- std::string name_; ///< Canonical name of the nameserver
- uint16_t classCode_; ///< Class of the nameserver
- std::vector<AddressEntry> address_; ///< Set of V4/V6 addresses
- time_t expiration_; ///< Summary expiration time
- time_t last_access_; ///< Last access time to the structure
+ boost::mutex mutex_; ///< Mutex protecting this object
+ std::string name_; ///< Canonical name of the nameserver
+ uint16_t classCode_; ///< Class of the nameserver
+ std::vector<AddressEntry> address_; ///< Set of V4/V6 addresses
+ time_t expiration_; ///< Summary expiration time
+ time_t last_access_; ///< Last access time to the structure
+ static UniformRandomIntegerGenerator rndRttGen_; ///< Small random RTT generator
};
} // namespace dns
Modified: branches/trac356/src/lib/nsas/tests/Makefile.am
==============================================================================
--- branches/trac356/src/lib/nsas/tests/Makefile.am (original)
+++ branches/trac356/src/lib/nsas/tests/Makefile.am Fri Nov 26 07:48:19 2010
@@ -29,6 +29,7 @@
run_unittests_SOURCES += nsas_entry_compare_unittest.cc
run_unittests_SOURCES += nsas_test_utilities.h
run_unittests_SOURCES += zone_entry_unittest.cc
+run_unittests_SOURCES += random_number_generator_unittest.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
More information about the bind10-changes
mailing list