blob: b1f24b82d6a8d8d6f26c3f31f5f25834d232edc6 [file] [log] [blame]
// Copyright 2025 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@available(added=HEAD)
library fuchsia.developer.ffx.speedtest;
using zx;
/// The default value used for transfer length when not provided.
const DEFAULT_TRANSFER_SIZE uint32 = 1000000; // 1MB
/// The default value used for buffer size when not provided.
const DEFAULT_BUFFER_SIZE uint32 = 262144; // 256KiB
/// Common transfer parameters.
type TransferParams = table {
/// The amount of bytes to transfer.
///
/// Must be greater than zero. Interpreted as [`DEFAULT_TRANSFER_SIZE`] if
/// absent.
1: len_bytes uint32;
/// The length of the buffer to use to read or write.
///
/// Must be greater than zero. Interpreted as [`DEFAULT_BUFFER_SIZE`] if
/// absent.
2: buffer_bytes uint32;
};
/// The result of a transfer.
type TransferReport = table {
/// The total transfer time in nanoseconds from the perspective of the
/// server.
///
/// Required.
1: duration_nsec uint64;
};
@discoverable
open protocol Speedtest {
/// No-op, server responds immediately.
flexible Ping() -> ();
/// Server writes data into the provided zircon socket and reports stats.
flexible SocketUp(resource struct {
socket zx.Handle:<SOCKET, zx.Rights.WRITE | zx.Rights.WAIT>;
params TransferParams;
}) -> (TransferReport);
/// Server reads data from the provided zircon socket and reports stats.
flexible SocketDown(resource struct {
socket zx.Handle:<SOCKET, zx.Rights.READ | zx.Rights.WAIT>;
params TransferParams;
}) -> (TransferReport);
};