mirror of
https://github.com/kristoferssolo/tls-pq-bench.git
synced 2026-03-22 00:36:21 +00:00
feat(common,server): add ProtocolMode and route server through protocol dispatch
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use miette::Diagnostic;
|
||||
use thiserror::Error;
|
||||
|
||||
/// Result type using the common's custom error type.
|
||||
/// Result type using the `common`'s custom error type.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, Error, Diagnostic)]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
//! Common types and utilities for the TLS benchmark harness
|
||||
|
||||
pub mod cert;
|
||||
pub mod error;
|
||||
pub mod prelude;
|
||||
@@ -10,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use strum::{Display, EnumString};
|
||||
|
||||
/// TLS key exchange mode
|
||||
/// TLS 1.3 key exchange mode used for benchmark runs
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, EnumString, Display)]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
@@ -21,6 +19,23 @@ pub enum KeyExchangeMode {
|
||||
X25519Mlkem768,
|
||||
}
|
||||
|
||||
/// Application protocol carried over TLS in benchmark runs.
|
||||
///
|
||||
/// `Raw` is a minimal custom framing protocol (8-byte LE length request, then N payload bytes)
|
||||
/// used for low-overhead microbenchmarks.
|
||||
///
|
||||
/// `Http1` is an HTTP/1.1 request/response mode (`GET /bytes/{n}`) used for realism-oriented
|
||||
/// comparisons where HTTP parsing and headers are part of measured overhead.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, EnumString, Display)]
|
||||
#[strum(serialize_all = "lowercase")]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ProtocolMode {
|
||||
/// Minimal custom framing protocol for primary microbenchmarks.
|
||||
Raw,
|
||||
/// HTTP/1.1 mode for realism-oriented comparisons.
|
||||
Http1,
|
||||
}
|
||||
|
||||
/// A single benchmark measurement record, output as NDJSON
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BenchRecord {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pub use crate::{
|
||||
BenchRecord, KeyExchangeMode,
|
||||
BenchRecord, KeyExchangeMode, ProtocolMode,
|
||||
protocol::{read_payload, read_request, write_payload, write_request},
|
||||
};
|
||||
|
||||
@@ -42,6 +42,7 @@ pub async fn write_request<W: AsyncWriteExt + Unpin>(writer: &mut W, size: u64)
|
||||
/// Generate deterministic payload of the given size.
|
||||
///
|
||||
/// The pattern is a repeating sequence: 0x00, 0x01, ..., 0xFF, 0x00, ...
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn generate_payload(size: u64) -> Vec<u8> {
|
||||
(0..size).map(|i| (i & 0xFF) as u8).collect()
|
||||
|
||||
Reference in New Issue
Block a user