libperfdhcp_la_SOURCES += rate_control.cc rate_control.h
libperfdhcp_la_SOURCES += stats_mgr.cc stats_mgr.h
libperfdhcp_la_SOURCES += test_control.cc test_control.h
-libperfdhcp_la_SOURCES += random_number_generator.h
libperfdhcp_la_SOURCES += receiver.cc receiver.h
libperfdhcp_la_SOURCES += perf_socket.cc perf_socket.h
libperfdhcp_la_SOURCES += abstract_scen.h
+++ /dev/null
-// Copyright (C) 2010-2024 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifndef NSAS_RANDOM_NUMBER_GENERATOR_H
-#define NSAS_RANDOM_NUMBER_GENERATOR_H
-
-#include <algorithm>
-#include <cmath>
-#include <iterator>
-#include <numeric>
-#include <vector>
-
-#include <exceptions/exceptions.h>
-
-#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_int.hpp>
-#include <boost/random/uniform_real.hpp>
-#include <boost/random/variate_generator.hpp>
-
-/// PLEASE DO NOT USE THIS IN CRYPTOGRAPHICALLY SENSITIVE CODE.
-
-namespace isc {
-namespace perfdhcp {
-
-/// \brief Uniform random integer generator
-///
-/// Generate uniformly distributed integers in range of [min, max]
-class UniformRandomIntegerGenerator{
-public:
- /// \brief Constructor
- ///
- /// \param min The minimum number in the range
- /// \param max The maximum number in the range
- UniformRandomIntegerGenerator(int min, int max):
- min_(std::min(min, max)), max_(std::max(min, max)),
- dist_(min_, max_), generator_(rng_, dist_)
- {
- // Init with the current time
- rng_.seed(time(0));
- }
-
- /// \brief Generate uniformly distributed integer
- int operator()() { return generator_(); }
-private:
- /// Hide default and copy constructor
- UniformRandomIntegerGenerator();///< Default constructor
- UniformRandomIntegerGenerator(const UniformRandomIntegerGenerator&); ///< Copy constructor
-
- int min_; ///< The minimum integer that can generate
- int max_; ///< The maximum integer that can generate
- boost::uniform_int<> dist_; ///< Distribute uniformly.
- boost::mt19937 rng_; ///< Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator
- boost::variate_generator<boost::mt19937&, boost::uniform_int<> > generator_; ///< Uniform generator
-};
-
-} // namespace perfdhcp
-} // namespace isc
-
-#endif//NSAS_RANDOM_NUMBER_GENERATOR_H
NumberGenerator(),
distribution(min, max) {
// Initialize the randomness source with the current time.
- randomnessGenerator.seed(time(NULL));
+ randomnessGenerator.seed(time(0));
}
/// \brief Generate number in range of [min, max].
AM_LDFLAGS = -static
endif
+TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
CLEANFILES = *.gcno *.gcda
# The test[1-5].hex are created by the TestControl.PacketTemplates
# unit tests and have to be removed.
CLEANFILES += test1.hex test2.hex test3.hex test4.hex test5.hex
-TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
-
TESTS =
if HAVE_GTEST
TESTS += run_unittests
run_unittests_SOURCES += basic_scen_unittest.cc
run_unittests_SOURCES += avalanche_scen_unittest.cc
run_unittests_SOURCES += command_options_helper.h
-run_unittests_SOURCES += random_number_generator_unittest.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
+++ /dev/null
-// Copyright (C) 2010-2021 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#include <config.h>
-
-#include <perfdhcp/random_number_generator.h>
-
-#include <gtest/gtest.h>
-#include <boost/shared_ptr.hpp>
-
-#include <iostream>
-
-using namespace isc;
-using namespace isc::perfdhcp;
-using namespace std;
-
-/// \brief Test Fixture Class for uniform random number generator
-///
-/// The hard part for this test is how to test that the number is random?
-/// and how to test that the number is uniformly distributed?
-/// Or maybe we can trust the boost implementation
-class UniformRandomIntegerGeneratorTest : public ::testing::Test {
-public:
- UniformRandomIntegerGeneratorTest():
- gen_(min_, max_)
- {
- }
- virtual ~UniformRandomIntegerGeneratorTest(){}
-
- int gen() { return (gen_()); }
- int max() const { return (max_); }
- int min() const { return (min_); }
-
-private:
- UniformRandomIntegerGenerator gen_;
-
- const static int min_ = 1;
- const static int max_ = 10;
-};
-
-// Test of the generated integers are in the range [min, max]
-TEST_F(UniformRandomIntegerGeneratorTest, IntegerRange) {
- vector<int> numbers;
-
- // Generate a lot of random integers
- for (int i = 0; i < max()*10; ++i) {
- numbers.push_back(gen());
- }
-
- // Remove the duplicated values
- sort(numbers.begin(), numbers.end());
- vector<int>::iterator it = unique(numbers.begin(), numbers.end());
-
- // make sure the numbers are in range [min, max]
- ASSERT_EQ(it - numbers.begin(), max() - min() + 1);
-}