From 040eee1aa49b49df4698d83a05af57c220127fd1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 13:36:04 +0200 Subject: Adding upstream version 2.2.0. Signed-off-by: Daniel Baumann --- src/bin/perfdhcp/avalanche_scen.h | 81 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/bin/perfdhcp/avalanche_scen.h (limited to 'src/bin/perfdhcp/avalanche_scen.h') diff --git a/src/bin/perfdhcp/avalanche_scen.h b/src/bin/perfdhcp/avalanche_scen.h new file mode 100644 index 0000000..b745efe --- /dev/null +++ b/src/bin/perfdhcp/avalanche_scen.h @@ -0,0 +1,81 @@ +// Copyright (C) 2012-2019,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/. + +#ifndef AVALANCHE_SCEN_H +#define AVALANCHE_SCEN_H + +#include + +#include + + +namespace isc { +namespace perfdhcp { + +// This class fixes an issue in older compilers +// that cannot handle enum class as key in std::unordered_map. +// See: https://stackoverflow.com/questions/18837857/cant-use-enum-class-as-unordered-map-key +struct EnumClassHash +{ + template + std::size_t operator()(T t) const + { + return static_cast(t); + } +}; + +/// \brief Avalanche Scenario class. +/// +/// This class is used to run the performance test where DHCP server +/// is first loaded with indicated buffer of Discover or Solicit messages +/// and then the class is waiting till receiving all required responses. +/// Full DORA and SARR message sequences are expected. +class AvalancheScen : public AbstractScen { +public: + /// \brief Default and the only constructor of AvalancheScen. + /// + /// \param options reference to command options, + /// \param socket reference to a socket. + AvalancheScen(CommandOptions& options, BasePerfSocket &socket): + AbstractScen(options, socket), + socket_(socket), + total_resent_(0) {}; + + /// brief\ Run performance test. + /// + /// Method runs whole performance test. + /// + /// \return execution status. + int run() override; + +protected: + + // A reference to socket; + BasePerfSocket &socket_; + + /// A map xchg type -> (a map of trans id -> retransmissions count. + std::unordered_map, EnumClassHash> retransmissions_; + /// A map xchg type -> (a map of trans id -> time of sending first packet. + std::unordered_map, EnumClassHash> start_times_; + + /// Total number of resent packets. + int total_resent_; + + /// \\brief Resend packets. + /// + /// It resends packets for given exchange type that did not receive + /// a response yet. + /// + /// \param xchg_type exchange type that should be looked for. + /// \return number of packets still waiting for resending. + int resendPackets(ExchangeType xchg_type); + +}; + +} +} + +#endif // AVALANCHE_SCEN_H -- cgit v1.2.3