diff --git a/tools/ft-analyzer/ftanalyzer/common/fast_analyzer_wrapper.py b/tools/ft-analyzer/ftanalyzer/common/fast_analyzer_wrapper.py index 39320a55..ea17eafb 100644 --- a/tools/ft-analyzer/ftanalyzer/common/fast_analyzer_wrapper.py +++ b/tools/ft-analyzer/ftanalyzer/common/fast_analyzer_wrapper.py @@ -36,8 +36,7 @@ ) from ftanalyzer.reports.statistical_report import StatisticalReport -SITE_PACKAGES_PREFIX = sysconfig.get_path("stdlib") -GLOBAL_IMPORT_DIR = f"{SITE_PACKAGES_PREFIX}/site-packages/flowtest" +GLOBAL_IMPORT_DIR = os.path.join(sysconfig.get_path("platlib"), "flowtest") def fast_analyzer_available() -> bool: diff --git a/tools/ft-fast-analyzer/src/statisticalmodel.h b/tools/ft-fast-analyzer/src/statisticalmodel.h index 386d17bf..e8899858 100644 --- a/tools/ft-fast-analyzer/src/statisticalmodel.h +++ b/tools/ft-fast-analyzer/src/statisticalmodel.h @@ -80,7 +80,7 @@ struct SMSubnetSegment final : public SMSegment { std::optional source; ///< Source subnet. std::optional dest; ///< Destination subnet. - bool bidir; ///< Bidirectional flag. + bool bidir = false; ///< Bidirectional flag. }; /** diff --git a/tools/ft-generator/src/config/common.cpp b/tools/ft-generator/src/config/common.cpp index 697f263d..7497d1e6 100644 --- a/tools/ft-generator/src/config/common.cpp +++ b/tools/ft-generator/src/config/common.cpp @@ -191,7 +191,7 @@ uint64_t ParseSpeedUnit(const YAML::Node& node) throw ConfigError(node, "invalid speed unit value"); } - return OverflowCheckedMultiply(*value, multiplier * 8); + return OverflowCheckedMultiply(*value, multiplier); } void ConfigError::PrintPrettyError( diff --git a/tools/ft-generator/tests/ftgeneratortests/tests/pcap/test_timestamps.py b/tools/ft-generator/tests/ftgeneratortests/tests/pcap/test_timestamps.py index 0a881b69..ce5ffe36 100644 --- a/tools/ft-generator/tests/ftgeneratortests/tests/pcap/test_timestamps.py +++ b/tools/ft-generator/tests/ftgeneratortests/tests/pcap/test_timestamps.py @@ -32,7 +32,7 @@ def calc_min_gap_nanos(packet_size, link_speed_gbps, min_packet_gap_ns): transfer_nanos = frame_total * 1_000_000_000 / (link_speed_gbps * 1_000_000_000) - return min(transfer_nanos, min_packet_gap_ns) + return transfer_nanos + min_packet_gap_ns def test_timestamp(ft_generator: Generator): diff --git a/tools/ft-profile-sampler/src/biflow.cpp b/tools/ft-profile-sampler/src/biflow.cpp index 64673d30..6d27b520 100644 --- a/tools/ft-profile-sampler/src/biflow.cpp +++ b/tools/ft-profile-sampler/src/biflow.cpp @@ -125,7 +125,7 @@ void Biflow::CreateHistogram(ft::Timestamp start, ft::Timestamp interval, unsign double Biflow::GetHistogramBin(unsigned idx) const { if (pkt_hist.size() == 0) { - std::runtime_error("packet histogram has not been created"); + throw std::runtime_error("packet histogram has not been created"); } if (idx >= start_window_idx && idx <= end_window_idx) { diff --git a/tools/ft-profile-sampler/src/evolution.cpp b/tools/ft-profile-sampler/src/evolution.cpp index bae47949..4723f575 100644 --- a/tools/ft-profile-sampler/src/evolution.cpp +++ b/tools/ft-profile-sampler/src/evolution.cpp @@ -35,7 +35,7 @@ void Evolution::CreateInitialPopulation() } for (auto& fut : futures) { - fut.wait(); + fut.get(); } UpdateFitnessStats(); @@ -46,7 +46,7 @@ void Evolution::InitialPopulationWorker(uint64_t seed) uint64_t profileSize = _profile->GetSize(); std::mt19937_64 rnd(seed); std::uniform_int_distribution geneCountDistrib(_minGenesCnt, _maxGenesCnt); - std::uniform_int_distribution geneDistrib(0, profileSize); + std::uniform_int_distribution geneDistrib(0, profileSize - 1); while (true) { { std::lock_guard lock(_mtx); diff --git a/tools/ft-profile-sampler/src/metrics.cpp b/tools/ft-profile-sampler/src/metrics.cpp index f466e2ec..2f92e39f 100644 --- a/tools/ft-profile-sampler/src/metrics.cpp +++ b/tools/ft-profile-sampler/src/metrics.cpp @@ -132,7 +132,7 @@ void Metrics::GatherWindowStats(const std::vector& data, unsigned histSi } const auto& biflow = data[i]; for (unsigned windowIndex = biflow.start_window_idx / WINDOW_SIZE; - windowIndex <= biflow.end_window_idx / WINDOW_SIZE + 1; + windowIndex <= biflow.end_window_idx / WINDOW_SIZE; windowIndex++) { double pkts = 0; for (unsigned j = 0; j < WINDOW_SIZE; j++) { diff --git a/tools/ft-replay/src/dpdkPlugin.cpp b/tools/ft-replay/src/dpdkPlugin.cpp index 67f76e83..8e0475fb 100644 --- a/tools/ft-replay/src/dpdkPlugin.cpp +++ b/tools/ft-replay/src/dpdkPlugin.cpp @@ -30,6 +30,9 @@ namespace replay { +// Ethernet frame overhead: 14-byte header + 4-byte FCS +static constexpr size_t ETH_OVERHEAD = 18; + // register the dpdk plugin to the factory OutputPluginFactoryRegistrator dpdkPluginRegistration("dpdk"); @@ -146,7 +149,7 @@ int DpdkPlugin::GetDpdkPort(const std::string& PCIAddress, struct rte_eth_dev_in throwErr(); } - if (_MTUSize < devInfo->min_mtu || _MTUSize > devInfo->max_mtu) { + if ((_MTUSize - ETH_OVERHEAD) < devInfo->min_mtu || (_MTUSize - ETH_OVERHEAD) > devInfo->max_mtu) { _logger->error( "MTU size of out NIC supported range {}-{}", devInfo->min_mtu, @@ -185,7 +188,7 @@ void DpdkPlugin::ConfigureDpdkPort(uint16_t portId) } } - ret = rte_eth_dev_set_mtu(portId, _MTUSize); + ret = rte_eth_dev_set_mtu(portId, _MTUSize - ETH_OVERHEAD); if (ret < 0) { _logger->error("rte_eth_dev_set_mtu() has failed with code {}", ret); throwErr(); diff --git a/tools/ft-replay/src/packet.hpp b/tools/ft-replay/src/packet.hpp index d11bcd26..fb9ef1e8 100644 --- a/tools/ft-replay/src/packet.hpp +++ b/tools/ft-replay/src/packet.hpp @@ -47,15 +47,15 @@ enum class OutInterface { * */ struct PacketInfo { - enum L3Type l3Type; + L3Type l3Type; uint16_t l3Offset; - enum L4Type l4Type; + L4Type l4Type; uint16_t l4Offset; //< Zero if l4type == L4Type::NotFound uint16_t ipAddressesChecksum; //< checksum of IP addresses in host byte order - enum OutInterface outInterface; //< used for multi-port replaying + OutInterface outInterface; //< used for multi-port replaying }; /** diff --git a/tools/ft-replay/src/packetBuilder.cpp b/tools/ft-replay/src/packetBuilder.cpp index df6c4c17..521bb1da 100644 --- a/tools/ft-replay/src/packetBuilder.cpp +++ b/tools/ft-replay/src/packetBuilder.cpp @@ -129,7 +129,7 @@ void PacketBuilder::PresetHwChecksum(Packet& packet) } } -int PacketBuilder::DecidePort(const std::byte* rawData, enum L3Type l3Type, uint16_t l3Offset) const +int PacketBuilder::DecidePort(const std::byte* rawData, L3Type l3Type, uint16_t l3Offset) const { if (l3Type == L3Type::IPv4) { const iphdr* ipHeader = reinterpret_cast(rawData + l3Offset); @@ -254,7 +254,7 @@ PacketInfo PacketBuilder::GetPacketInfo(const RawPacket* rawPacket) const info.l4Type = LayerToL4Protocol(l4Layer._type); } - if (DecidePort(rawPacket->data, info.l3Type, info.l3Offset) < 0) { + if (DecidePort(rawPacket->data, info.l3Type, info.l3Offset) <= 0) { info.outInterface = OutInterface::Interface0; } else { info.outInterface = OutInterface::Interface1; diff --git a/tools/ft-replay/src/packetBuilder.hpp b/tools/ft-replay/src/packetBuilder.hpp index 686462b5..7b7e10cc 100644 --- a/tools/ft-replay/src/packetBuilder.hpp +++ b/tools/ft-replay/src/packetBuilder.hpp @@ -97,7 +97,7 @@ class PacketBuilder { std::unique_ptr GetDataCopyWithVlan(const std::byte* rawData, uint16_t dataLen); void ValidatePacketLength(uint16_t packetLength) const; void PresetHwChecksum(Packet& packet); - int DecidePort(const std::byte* rawData, enum L3Type l3Type, uint16_t l3Offset) const; + int DecidePort(const std::byte* rawData, L3Type l3Type, uint16_t l3Offset) const; uint16_t _vlanID = 0; double _timeMultiplier = 1.0;