1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/// The command line flag that names the server under test.
pub const ARG_ADDR: &str = "--addr";
/// The command line flag that sets the number of connections.
pub const ARG_CONNECTIONS: &str = "--connections";
/// The command line flag that sets the measured window, in seconds.
pub const ARG_DURATION: &str = "--duration";
/// The command line flag that sets the warm-up window, in seconds.
pub const ARG_WARMUP: &str = "--warmup";
/// The address the generator drives when none is given.
pub const DEFAULT_ADDR: &str = "127.0.0.1:8080";
/// The number of connections the generator opens when none is given.
pub const DEFAULT_CONNECTIONS: usize = 64;
/// The length of the measured window when none is given, in seconds.
pub const DEFAULT_DURATION_SECS: u64 = 10;
/// The length of the warm-up window when none is given, in seconds.
pub const DEFAULT_WARMUP_SECS: u64 = 3;
/// The bytes that end an HTTP response head.
pub const HEAD_TERMINATOR: & = b"\r\n\r\n";
/// The bytes that end one line of an HTTP response head.
pub const LINE_TERMINATOR: & = b"\r\n";
/// The name of the header that announces the body length.
pub const CONTENT_LENGTH_NAME: & = b"content-length";
/// The request for the static route.
pub const REQUEST_ROOT: &str =
"GET / HTTP/1.1\r\nHost: bench\r\nAccept: */*\r\nUser-Agent: bench/1.0\r\n\r\n";
/// The request for the dynamic route.
pub const REQUEST_USER: &str =
"GET /api/user/12345 HTTP/1.1\r\nHost: bench\r\nAccept: */*\r\n\r\n";
/// The request for the query route.
pub const REQUEST_SEARCH: &str =
"GET /api/search?q=hyperlane&limit=10 HTTP/1.1\r\nHost: bench\r\nAccept: */*\r\n\r\n";
/// The request for the header route.
pub const REQUEST_HEADERS: &str =
"GET /api/headers HTTP/1.1\r\nHost: bench\r\nx-bench-tag: alpha\r\nx-bench-extra: 1\r\n\r\n";
/// The body length the static route answers with.
pub const EXPECT_ROOT: usize = 25;
/// The body length the dynamic route answers with.
pub const EXPECT_USER: usize = 10;
/// The body length the query route answers with.
pub const EXPECT_SEARCH: usize = 11;
/// The body length the header route answers with.
pub const EXPECT_HEADERS: usize = 9;
/// The body length the body route answers with.
pub const EXPECT_ECHO: usize = 11;
/// The size of the buffer a connection reads into.
pub const READ_BUFFER_SIZE: usize = 16 * 1024;
/// The command line flag that names the wire protocol.
pub const ARG_PROTOCOL: &str = "--protocol";
/// The command line flag that names the connection mode.
pub const ARG_MODE: &str = "--mode";
/// The command line flag that names the certificate authority.
pub const ARG_CA: &str = "--ca";
/// The command line flag that caps the connection rate.
pub const ARG_RATE: &str = "--rate";
/// The connection rate the generator uses when none is given.
///
/// A short-connection row opens one connection per request, and the kernel
/// holds each closed connection in TIME_WAIT for twice the maximum segment
/// lifetime. The ephemeral port range is therefore the ceiling on the
/// connection rate, and an unpaced generator spends the range in seconds and
/// then fails with EADDRNOTAVAIL, which reads as a server defect and is not
/// one.
pub const DEFAULT_RATE_PER_SEC: u64 = 200;
/// The protocol name that selects HTTP/1 over a plain socket.
pub const PROTOCOL_HTTP1: &str = "h1";
/// The protocol name that selects HTTP/1 over TLS.
pub const PROTOCOL_HTTP1_TLS: &str = "h1-tls";
/// The protocol name that selects HTTP/2 over a plain socket.
pub const PROTOCOL_HTTP2: &str = "h2c";
/// The protocol name that selects HTTP/2 over TLS.
pub const PROTOCOL_HTTP2_TLS: &str = "h2-tls";
/// The protocol name that selects HTTP/3 over QUIC.
pub const PROTOCOL_HTTP3: &str = "h3";
/// The connection mode name that keeps the connection open.
pub const MODE_KEEPALIVE: &str = "keepalive";
/// The connection mode name that opens one connection per request.
pub const MODE_SHORT: &str = "short";
/// The identifier the ALPN protocol of HTTP/1.1 is spelled with.
pub const ALPN_HTTP1: & = b"http/1.1";
/// The identifier the ALPN protocol of HTTP/2 is spelled with.
pub const ALPN_HTTP2: & = b"h2";
/// The identifier the ALPN protocol of HTTP/3 is spelled with.
pub const ALPN_HTTP3: & = b"h3";
/// The value every request carries in the accept header.
pub const HEADER_ACCEPT: &str = "*/*";
/// The value every request carries in the user agent header.
pub const HEADER_USER_AGENT: &str = "bench/1.0";
/// The reason the QUIC connection is closed when the run ends.
pub const QUIC_CLOSE_REASON: & = b"done";
/// The method a request uses when its request line names none.
pub const METHOD_GET: &str = "GET";
/// The head of the request for the body route.
pub const REQUEST_ECHO_HEAD: &str =
"POST /api/echo HTTP/1.1\r\nHost: bench\r\nContent-Length: 11\r\n\r\n";
/// The body the body route carries.
pub const BODY_ECHO: &str = "hello world";