From: Michal Nowikowski Date: Wed, 13 Feb 2019 09:14:29 +0000 (+0100) Subject: cleaned up protected/public definition of TestControl class X-Git-Tag: 397-cb-implement-mysqlconfigbackenddhcpv6_base~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=691fd3214de1d7dcd7f3c1b5ed46afeb3948b296;p=thirdparty%2Fkea.git cleaned up protected/public definition of TestControl class --- diff --git a/src/bin/perfdhcp/command_options.h b/src/bin/perfdhcp/command_options.h index efbfdafbfb..92ca961cf4 100644 --- a/src/bin/perfdhcp/command_options.h +++ b/src/bin/perfdhcp/command_options.h @@ -353,6 +353,9 @@ public: /// \return true if single-threaded mode is enabled. bool isSingleThreaded() const { return single_thread_mode_; } + /// \brief Returns selected scenario. + /// + /// \return enum Scenario. Scenario getScenario() const { return scenario_; } /// \brief Returns server name. diff --git a/src/bin/perfdhcp/stats_mgr.h b/src/bin/perfdhcp/stats_mgr.h index 7bb1bf3a21..adc028177a 100644 --- a/src/bin/perfdhcp/stats_mgr.h +++ b/src/bin/perfdhcp/stats_mgr.h @@ -213,7 +213,7 @@ public: /// } /// \endcode typedef boost::multi_index_container< - // Container holds shared_ptr or shared_ptr objects. + // Container holds PktPtr objects. dhcp::PktPtr, // List container indexes. boost::multi_index::indexed_by< @@ -229,8 +229,7 @@ public: // transaction id. This product is obtained by calling // hashTransid() function. boost::multi_index::global_fun< - // Hashing function takes shared_ptr or - // shared_ptr as argument. + // Hashing function takes PktPtr as argument. const dhcp::PktPtr&, // ... and returns uint32 value. uint32_t, @@ -261,6 +260,9 @@ public: /// \param archive_enabled if true packets archive mode is enabled. /// In this mode all packets are stored throughout the test execution. /// \param boot_time Holds the timestamp when perfdhcp has been started. + /// \param ignore_timestamp_reorder if true then while matching + /// response packets to request ones negative time difference is ignored + /// otherwise exception is raised. ExchangeStats(const ExchangeType xchg_type, const double drop_time, const bool archive_enabled, @@ -613,6 +615,9 @@ private: uint64_t rcvd_packets_num_; ///< Total number of received packets. boost::posix_time::ptime boot_time_; ///< Time when test is started. + /// If true then while matching + /// response packets to request ones negative time difference is ignored + /// otherwise exception is raised. bool ignore_timestamp_reorder_; }; @@ -653,6 +658,9 @@ public: /// the test. If this is not selected archiving should be disabled /// for performance reasons and to avoid waste of memory for storing /// large list of archived packets. + /// \param ignore_timestamp_reorder if true then while matching + /// response packets to request ones negative time difference is ignored + /// otherwise exception is raised. StatsMgr(bool ignore_timestamp_reorder); /// \brief Specify new exchange type. @@ -1115,10 +1123,13 @@ private: boost::posix_time::ptime boot_time_; ///< Time when test is started. + /// If true then while matching + /// response packets to request ones negative time difference is ignored + /// otherwise exception is raised. bool ignore_timestamp_reorder_; }; -/// Pointer to Statistics Manager for DHCPv4; +/// Pointer to Statistics Manager; typedef boost::shared_ptr StatsMgrPtr; diff --git a/src/bin/perfdhcp/test_control.h b/src/bin/perfdhcp/test_control.h index 0be0b1b478..bb496e8c6c 100644 --- a/src/bin/perfdhcp/test_control.h +++ b/src/bin/perfdhcp/test_control.h @@ -124,6 +124,10 @@ public: class TestControl : public boost::noncopyable { public: /// \brief Default constructor. + /// + /// \param ignore_timestamp_reorder if true then while matching + /// response packets to request ones negative time difference is ignored + /// otherwise exception is raised. TestControl(bool ignore_timestamp_reorder); /// Packet template buffer. @@ -214,15 +218,6 @@ public: macaddr_gen_ = generator; } - // We would really like following methods and members to be private but - // they have to be accessible for unit-testing. Another, possibly better, - // solution is to make this class friend of test class but this is not - // what's followed in other classes. -//protected: -public: // TODO clean up what should be and what should not be protected - /// Generate uniformly distributed integers in range of [min, max] - isc::util::random::UniformRandomIntegerGenerator number_generator_; - /// \brief Removes cached DHCPv6 Reply packets every second. /// /// This function wipes cached Reply packets from the storage. @@ -236,6 +231,93 @@ public: // TODO clean up what should be and what should not be protected /// has been reached. void cleanCachedPackets(); + bool interrupted() const { return interrupted_; } + + StatsMgr& getStatsMgr() { return stats_mgr_; }; + + void start() { receiver_.start(); } + void stop() { receiver_.stop(); } + + /// \brief Run wrapped command. + /// + /// \param do_stop execute wrapped command with "stop" argument. + void runWrapped(bool do_stop = false) const; + + bool serverIdReceived() const { return first_packet_serverid_.size() > 0; } + std::string getServerId() const { return vector2Hex(first_packet_serverid_); } + + /// \brief Send number of packets to initiate new exchanges. + /// + /// Method initiates the new DHCP exchanges by sending number + /// of DISCOVER (DHCPv4) or SOLICIT (DHCPv6) packets. If preload + /// mode was requested sent packets will not be counted in + /// the statistics. The responses from the server will be + /// received and counted as orphans because corresponding sent + /// packets are not included in StatsMgr for match. + /// When preload mode is disabled and diagnostics flag 'i' is + /// specified then function will be trying to receive late packets + /// before new packets are sent to the server. Statistics of + /// late received packets is updated accordingly. + /// + /// \todo do not count responses in preload mode as orphans. + /// + /// \param packets_num number of packets to be sent. + /// \param preload preload mode, packets not included in statistics. + /// \throw isc::Unexpected if thrown by packet sending method. + /// \throw isc::InvalidOperation if thrown by packet sending method. + /// \throw isc::OutOfRange if thrown by packet sending method. + void sendPackets(const uint64_t packets_num, + const bool preload = false); + + /// \brief Send number of DHCPREQUEST (renew) messages to a server. + /// + /// \param msg_num A number of messages to be sent. + /// + /// \return A number of messages actually sent. + uint64_t sendMultipleRequests(const uint64_t msg_num); + + /// \brief Send number of DHCPv6 Renew or Release messages to the server. + /// + /// \param msg_type A type of the messages to be sent (DHCPV6_RENEW or + /// DHCPV6_RELEASE). + /// \param msg_num A number of messages to be sent. + /// + /// \return A number of messages actually sent. + uint64_t sendMultipleMessages6(const uint32_t msg_type, + const uint64_t msg_num); + + /// \brief Pull packets from receiver and process them. + /// + /// It runs in a loop until there are no packets in receiver. + unsigned int consumeReceivedPackets(); + + /// \brief Print intermediate statistics. + /// + /// Print brief statistics regarding number of sent packets, + /// received packets and dropped packets so far. + void printIntermediateStats(); + + /// \brief Print performance statistics. + /// + /// Method prints performance statistics. + /// \throws isc::InvalidOperation if Statistics Manager was + /// not initialized. + void printStats() const; + + /// \brief Print templates information. + /// + /// Method prints information about data offsets + /// in packet templates and their contents. + void printTemplates() const; + + // We would really like following methods and members to be private but + // they have to be accessible for unit-testing. Another, possibly better, + // solution is to make this class friend of test class but this is not + // what's followed in other classes. +protected: + /// Generate uniformly distributed integers in range of [min, max] + isc::util::random::UniformRandomIntegerGenerator number_generator_; + /// \brief Creates DHCPREQUEST from a DHCPACK message. /// /// \param ack An instance of the DHCPACK message to be used to @@ -444,29 +526,11 @@ public: // TODO clean up what should be and what should not be protected /// odd number of hexadecimal digits. void initPacketTemplates(); - /// \brief Print intermediate statistics. - /// - /// Print brief statistics regarding number of sent packets, - /// received packets and dropped packets so far. - void printIntermediateStats(); - /// \brief Print rate statistics. /// /// Method print packet exchange rate statistics. void printRate() const; - /// \brief Print performance statistics. - /// - /// Method prints performance statistics. - /// \throws isc::InvalidOperation if Statistics Manager was - /// not initialized. - void printStats() const; - - /// \brief Pull packets from receiver and process them. - - /// It runs in a loop until there are no packets in receiver. - unsigned int consumeReceivedPackets(); - /// \brief Process received DHCPv4 packet. /// /// Method performs processing of the received DHCPv4 packet, @@ -592,46 +656,6 @@ public: // TODO clean up what should be and what should not be protected void sendDiscover4(const std::vector& template_buf, const bool preload = false); - /// \brief Send number of packets to initiate new exchanges. - /// - /// Method initiates the new DHCP exchanges by sending number - /// of DISCOVER (DHCPv4) or SOLICIT (DHCPv6) packets. If preload - /// mode was requested sent packets will not be counted in - /// the statistics. The responses from the server will be - /// received and counted as orphans because corresponding sent - /// packets are not included in StatsMgr for match. - /// When preload mode is disabled and diagnostics flag 'i' is - /// specified then function will be trying to receive late packets - /// before new packets are sent to the server. Statistics of - /// late received packets is updated accordingly. - /// - /// \todo do not count responses in preload mode as orphans. - /// - /// \param packets_num number of packets to be sent. - /// \param preload preload mode, packets not included in statistics. - /// \throw isc::Unexpected if thrown by packet sending method. - /// \throw isc::InvalidOperation if thrown by packet sending method. - /// \throw isc::OutOfRange if thrown by packet sending method. - void sendPackets(const uint64_t packets_num, - const bool preload = false); - - /// \brief Send number of DHCPREQUEST (renew) messages to a server. - /// - /// \param msg_num A number of messages to be sent. - /// - /// \return A number of messages actually sent. - uint64_t sendMultipleRequests(const uint64_t msg_num); - - /// \brief Send number of DHCPv6 Renew or Release messages to the server. - /// - /// \param msg_type A type of the messages to be sent (DHCPV6_RENEW or - /// DHCPV6_RELEASE). - /// \param msg_num A number of messages to be sent. - /// - /// \return A number of messages actually sent. - uint64_t sendMultipleMessages6(const uint32_t msg_type, - const uint64_t msg_num); - /// \brief Send DHCPv4 renew (DHCPREQUEST). /// /// \return true if the message has been sent, false otherwise. @@ -788,29 +812,6 @@ public: // TODO clean up what should be and what should not be protected /// @param pkt6 options will be added here void addExtraOpts(const dhcp::Pkt6Ptr& pkt6); - StatsMgr& getStatsMgr() { return stats_mgr_; }; - - void start() { receiver_.start(); } - void stop() { receiver_.stop(); } - - /// \brief Print templates information. - /// - /// Method prints information about data offsets - /// in packet templates and their contents. - void printTemplates() const; - - /// \brief Run wrapped command. - /// - /// \param do_stop execute wrapped command with "stop" argument. - void runWrapped(bool do_stop = false) const; - - bool serverIdReceived() const { return first_packet_serverid_.size() > 0; } - std::string getServerId() const { return vector2Hex(first_packet_serverid_); } - - bool interrupted() const { return interrupted_; } - -protected: - /// \brief Copies IA_NA or IA_PD option from one packet to another. /// /// This function checks the lease-type specified in the command line