Now last_total variables for datagrams are properly initialized.
Batch size for UDP runs when using throughput limiting now caps at 1460
to avoid splitting datagrams.
Final throughput avg printout is now rounded to the nearest integer.
Type: fix
Change-Id: Ia52687b73bd22ec682a971f9ee902572c9212436
Signed-off-by: Semir Sionek <[email protected]>
if !s.CoverageRun {
s.Log("\nBaseline: %.2f bytes/s\nWith loss: %.2f bytes/s", baseline, withLoss)
s.AssertGreaterEqual(baseline, withLoss)
- s.AssertGreaterEqual(withLoss, baseline*0.15)
+ s.AssertGreaterEqual(withLoss, uint64(float64(baseline)*0.15))
}
}
if !s.CoverageRun {
s.Log("\nBaseline: %.2f bytes/s\nWith loss: %.2f bytes/s", baseline, withLoss)
s.AssertGreaterEqual(baseline, withLoss)
- s.AssertGreaterEqual(withLoss, baseline*0.15)
+ s.AssertGreaterEqual(withLoss, uint64(float64(baseline)*0.15))
}
}
"net/http/httputil"
"os"
"os/exec"
+ "regexp"
"strconv"
"strings"
"time"
return conn
}
-// Parses transfer speed ("N bytes/second full-duplex")
-func (s *HstSuite) ParseEchoClientTransfer(stats string) (float64, error) {
- lines := strings.Split(strings.TrimSpace(stats), "\n")
- for i := len(lines) - 1; i >= 0; i-- {
- line := strings.TrimSpace(lines[i])
- if strings.Contains(line, "bytes/second") {
- parts := strings.Fields(line)
- if len(parts) == 0 {
- return 0, errors.New("check format of stats")
- }
- num := strings.ReplaceAll(parts[0], ",", "")
- return strconv.ParseFloat(num, 64)
- }
+// Parses transfer speed ("NBps full-duplex")
+func (s *HstSuite) ParseEchoClientTransfer(stats string) (uint64, error) {
+ pattern := regexp.MustCompile(`(?i)(\d+)\s+bytes/second\s+(?:half|full)-duplex`)
+ match := pattern.FindStringSubmatch(stats)
+ if len(match) == 0 {
+ return 0, errors.New("throughput pattern not found")
+ }
+ uVal, err := strconv.ParseUint(match[1], 10, 64)
+ if err != nil {
+ return 0, fmt.Errorf("failed to parse numeric value '%s': %w", match[1], err)
}
- return 0, errors.New(`"bytes/second" not found`)
+ return uVal, nil
}
ecm->last_print_time = 0;
ecm->last_total_tx_bytes = 0;
ecm->last_total_rx_bytes = 0;
+ ecm->last_total_rx_dgrams = 0;
+ ecm->last_total_tx_dgrams = 0;
clib_memset (&ecm->rtt_stats, 0, sizeof (ec_rttstat_t));
ecm->rtt_stats.min_rtt = CLIB_F64_MAX;
if (ecm->rtt_stats.w_lock == NULL)
/* find a suitable pacing window length & data chunk size */
bytes_paced_target =
ecm->throughput * ecm->pacing_window_len / ecm->n_clients;
- while (bytes_paced_target > target_size_threshold)
+ while (
+ bytes_paced_target > target_size_threshold ||
+ (ecm->transport_proto == TRANSPORT_PROTO_UDP && bytes_paced_target > 1460))
{
ecm->pacing_window_len /= 2;
bytes_paced_target /= 2;
transfer_type = ecm->echo_bytes ? "full-duplex" : "half-duplex";
ec_cli ("%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds", total_bytes,
total_bytes / (1ULL << 20), total_bytes / (1ULL << 30), total_delta);
- ec_cli ("%.2f bytes/second %s", ((f64) total_bytes) / (total_delta),
+ ec_cli ("%u bytes/second %s",
+ flt_round_nearest (((f64) total_bytes) / (total_delta)),
+ transfer_type);
+ ec_cli ("%UBps %s", format_base10,
+ flt_round_nearest (((f64) total_bytes) / (total_delta)),
transfer_type);
- ec_cli ("%.4f gbit/second %s",
- (((f64) total_bytes * 8.0) / total_delta / 1e9), transfer_type);
}
static clib_error_t *