bbperf 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bbperf/.gitignore +3 -0
- bbperf/__init__.py +0 -0
- bbperf/bbperf.py +79 -0
- bbperf/calibration.py +40 -0
- bbperf/client.py +223 -0
- bbperf/const.py +27 -0
- bbperf/control_receiver_thread.py +109 -0
- bbperf/data_receiver_thread.py +142 -0
- bbperf/data_sender_thread.py +214 -0
- bbperf/data_udp_ping_sender_thread.py +45 -0
- bbperf/exceptions.py +5 -0
- bbperf/graph.py +37 -0
- bbperf/output.py +225 -0
- bbperf/run_test.sh +41 -0
- bbperf/server.py +184 -0
- bbperf/tcp-graph.gp +49 -0
- bbperf/tcp_control_connection_class.py +196 -0
- bbperf/udp-graph.gp +58 -0
- bbperf/util.py +105 -0
- bbperf-0.0.1.dist-info/METADATA +128 -0
- bbperf-0.0.1.dist-info/RECORD +24 -0
- bbperf-0.0.1.dist-info/WHEEL +4 -0
- bbperf-0.0.1.dist-info/entry_points.txt +2 -0
- bbperf-0.0.1.dist-info/licenses/LICENSE +14 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Copyright (c) 2024 Cloudflare, Inc.
|
|
2
|
+
# Licensed under the Apache 2.0 license found in the LICENSE file or at https://www.apache.org/licenses/LICENSE-2.0
|
|
3
|
+
|
|
4
|
+
import time
|
|
5
|
+
import socket
|
|
6
|
+
import select
|
|
7
|
+
|
|
8
|
+
from . import util
|
|
9
|
+
from . import const
|
|
10
|
+
from . import calibration
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# falling off the end of this method terminates the process
|
|
14
|
+
def run(args, stdout_queue, data_sock, peer_addr):
|
|
15
|
+
if args.verbosity:
|
|
16
|
+
stdout_queue.put("data sender: start of process")
|
|
17
|
+
|
|
18
|
+
peer_addr_for_udp = peer_addr
|
|
19
|
+
|
|
20
|
+
if args.udp and (peer_addr_for_udp is None):
|
|
21
|
+
# for udp, we have to wait for a ping message so we know where to send the data packets
|
|
22
|
+
while True:
|
|
23
|
+
# blocking
|
|
24
|
+
bytes_read, pkt_from_addr = data_sock.recvfrom(const.BUFSZ)
|
|
25
|
+
if len(bytes_read) == len(const.UDP_PING_MSG):
|
|
26
|
+
if bytes_read.decode() == const.UDP_PING_MSG:
|
|
27
|
+
peer_addr_for_udp = pkt_from_addr
|
|
28
|
+
if args.verbosity:
|
|
29
|
+
stdout_queue.put("data sender: peer address: {}".format(peer_addr_for_udp))
|
|
30
|
+
break
|
|
31
|
+
|
|
32
|
+
# calculate sending rate
|
|
33
|
+
|
|
34
|
+
if args.bandwidth:
|
|
35
|
+
bandwidth_is_pps, bandwidth_val_int = util.convert_bandwidth_str_to_int(args.bandwidth)
|
|
36
|
+
|
|
37
|
+
if args.udp:
|
|
38
|
+
if bandwidth_is_pps:
|
|
39
|
+
packets_per_sec = bandwidth_val_int
|
|
40
|
+
sends_per_sec = packets_per_sec
|
|
41
|
+
else:
|
|
42
|
+
# udp/bps
|
|
43
|
+
packets_per_sec = (bandwidth_val_int / 8.0) / len(const.PAYLOAD_1K)
|
|
44
|
+
sends_per_sec = packets_per_sec
|
|
45
|
+
|
|
46
|
+
batch_size = const.RATE_LIMITED_BATCH_SIZE_PKTS_UDP_PKTS
|
|
47
|
+
|
|
48
|
+
else:
|
|
49
|
+
# tcp
|
|
50
|
+
if bandwidth_is_pps:
|
|
51
|
+
packets_per_sec = bandwidth_val_int
|
|
52
|
+
sends_per_sec = bandwidth_val_int / ( len(const.PAYLOAD_4K) / 1400.0 )
|
|
53
|
+
else:
|
|
54
|
+
packets_per_sec = (bandwidth_val_int / 8.0) / 1400.0
|
|
55
|
+
sends_per_sec = packets_per_sec / ( len(const.PAYLOAD_4K) / 1400.0 )
|
|
56
|
+
|
|
57
|
+
batch_size = const.RATE_LIMITED_BATCH_SIZE_PKTS_TCP_PKTS
|
|
58
|
+
|
|
59
|
+
batches_per_sec = sends_per_sec / batch_size
|
|
60
|
+
|
|
61
|
+
if batches_per_sec < 1:
|
|
62
|
+
batches_per_sec = 1
|
|
63
|
+
batch_size = 1
|
|
64
|
+
|
|
65
|
+
delay_between_batches = 1.0 / batches_per_sec
|
|
66
|
+
|
|
67
|
+
if args.verbosity:
|
|
68
|
+
print("bandwidth_val: {}\npackets_per_sec: {}\nsends_per_sec: {}\nbatch_size: {}\nbatches_per_sec: {}\ndelay_between_batches: {}".format(
|
|
69
|
+
bandwidth_val_int,
|
|
70
|
+
packets_per_sec,
|
|
71
|
+
sends_per_sec,
|
|
72
|
+
batch_size,
|
|
73
|
+
batches_per_sec,
|
|
74
|
+
delay_between_batches
|
|
75
|
+
))
|
|
76
|
+
|
|
77
|
+
# start sending
|
|
78
|
+
|
|
79
|
+
if args.verbosity:
|
|
80
|
+
stdout_queue.put("data sender: sending")
|
|
81
|
+
|
|
82
|
+
curr_time_sec = time.time()
|
|
83
|
+
|
|
84
|
+
# stop sending time
|
|
85
|
+
end_time = curr_time_sec + args.time
|
|
86
|
+
|
|
87
|
+
interval_start_time = curr_time_sec
|
|
88
|
+
interval_end_time = interval_start_time + const.SAMPLE_INTERVAL_SEC
|
|
89
|
+
|
|
90
|
+
interval_time_sec = 0.0
|
|
91
|
+
interval_send_count = 0
|
|
92
|
+
interval_bytes_sent = 0
|
|
93
|
+
|
|
94
|
+
accum_send_count = 0
|
|
95
|
+
accum_bytes_sent = 0
|
|
96
|
+
|
|
97
|
+
total_send_counter = 1
|
|
98
|
+
|
|
99
|
+
while True:
|
|
100
|
+
curr_time_sec = time.time()
|
|
101
|
+
is_calibrated = calibration.is_calibrated()
|
|
102
|
+
record_type = b'run' if is_calibrated else b'cal'
|
|
103
|
+
|
|
104
|
+
# we want to be fast here, since this is data write loop, so use ba.extend
|
|
105
|
+
|
|
106
|
+
ba = bytearray()
|
|
107
|
+
ba.extend(b' a ')
|
|
108
|
+
ba.extend(record_type)
|
|
109
|
+
ba.extend(b' ')
|
|
110
|
+
ba.extend(str(curr_time_sec).encode())
|
|
111
|
+
ba.extend(b' ')
|
|
112
|
+
ba.extend(str(interval_time_sec).encode())
|
|
113
|
+
ba.extend(b' ')
|
|
114
|
+
ba.extend(str(interval_send_count).encode())
|
|
115
|
+
ba.extend(b' ')
|
|
116
|
+
ba.extend(str(interval_bytes_sent).encode())
|
|
117
|
+
ba.extend(b' ')
|
|
118
|
+
ba.extend(str(total_send_counter).encode())
|
|
119
|
+
ba.extend(b' b ')
|
|
120
|
+
|
|
121
|
+
if args.udp:
|
|
122
|
+
ba.extend(const.PAYLOAD_1K)
|
|
123
|
+
elif is_calibrated:
|
|
124
|
+
ba.extend(const.PAYLOAD_4K)
|
|
125
|
+
else:
|
|
126
|
+
ba.extend(const.PAYLOAD_1K)
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
# blocking
|
|
130
|
+
# we want to block here, as blocked time should "count"
|
|
131
|
+
|
|
132
|
+
# we use select to take advantage of tcp_notsent_lowat
|
|
133
|
+
_, _, _ = select.select( [], [data_sock], [])
|
|
134
|
+
|
|
135
|
+
if args.udp:
|
|
136
|
+
num_bytes_sent = data_sock.sendto(ba, peer_addr_for_udp)
|
|
137
|
+
else:
|
|
138
|
+
# tcp
|
|
139
|
+
num_bytes_sent = data_sock.send(ba)
|
|
140
|
+
|
|
141
|
+
if num_bytes_sent <= 0:
|
|
142
|
+
msg = "ERROR: send failed"
|
|
143
|
+
stdout_queue.put(msg)
|
|
144
|
+
raise Exception(msg)
|
|
145
|
+
|
|
146
|
+
except ConnectionResetError:
|
|
147
|
+
stdout_queue.put("Connection reset by peer")
|
|
148
|
+
# exit process
|
|
149
|
+
break
|
|
150
|
+
|
|
151
|
+
except BrokenPipeError:
|
|
152
|
+
# this can happen at the end of a tcp reverse test
|
|
153
|
+
stdout_queue.put("broken pipe error")
|
|
154
|
+
# exit process
|
|
155
|
+
break
|
|
156
|
+
|
|
157
|
+
except BlockingIOError:
|
|
158
|
+
# same as EAGAIN EWOULDBLOCK
|
|
159
|
+
# we did not send, loop back up and try again
|
|
160
|
+
continue
|
|
161
|
+
|
|
162
|
+
except socket.timeout:
|
|
163
|
+
# we did not send, loop back up and try again
|
|
164
|
+
continue
|
|
165
|
+
|
|
166
|
+
total_send_counter += 1
|
|
167
|
+
accum_send_count += 1
|
|
168
|
+
accum_bytes_sent += num_bytes_sent
|
|
169
|
+
|
|
170
|
+
if curr_time_sec > interval_end_time:
|
|
171
|
+
interval_time_sec = curr_time_sec - interval_start_time
|
|
172
|
+
interval_send_count = accum_send_count
|
|
173
|
+
interval_bytes_sent = accum_bytes_sent
|
|
174
|
+
|
|
175
|
+
interval_start_time = curr_time_sec
|
|
176
|
+
interval_end_time = interval_start_time + const.SAMPLE_INTERVAL_SEC
|
|
177
|
+
accum_send_count = 0
|
|
178
|
+
accum_bytes_sent = 0
|
|
179
|
+
|
|
180
|
+
# send very slowly at first to establish unloaded latency
|
|
181
|
+
if not is_calibrated:
|
|
182
|
+
time.sleep(0.2)
|
|
183
|
+
# initialize batch variables here in case next loop is batch processing
|
|
184
|
+
current_batch_start_time = time.time()
|
|
185
|
+
current_batch_counter = 0
|
|
186
|
+
continue
|
|
187
|
+
|
|
188
|
+
# normal end of test
|
|
189
|
+
if curr_time_sec > end_time:
|
|
190
|
+
break
|
|
191
|
+
|
|
192
|
+
if args.bandwidth:
|
|
193
|
+
current_batch_counter += 1
|
|
194
|
+
if current_batch_counter >= batch_size:
|
|
195
|
+
this_delay = delay_between_batches - (curr_time_sec - current_batch_start_time)
|
|
196
|
+
if this_delay > 0:
|
|
197
|
+
time.sleep(delay_between_batches)
|
|
198
|
+
else:
|
|
199
|
+
if args.verbosity == 3:
|
|
200
|
+
print("send_counter: {} current_batch_start_time: {} curr_time_sec: {} delay_between_batches: {} this_delay: {}".format(
|
|
201
|
+
total_send_counter,
|
|
202
|
+
current_batch_start_time,
|
|
203
|
+
curr_time_sec,
|
|
204
|
+
delay_between_batches,
|
|
205
|
+
this_delay
|
|
206
|
+
))
|
|
207
|
+
current_batch_start_time += delay_between_batches
|
|
208
|
+
current_batch_counter = 0
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
util.done_with_socket(data_sock)
|
|
212
|
+
|
|
213
|
+
if args.verbosity:
|
|
214
|
+
stdout_queue.put("data sender: end of process")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Copyright (c) 2024 Cloudflare, Inc.
|
|
2
|
+
# Licensed under the Apache 2.0 license found in the LICENSE file or at https://www.apache.org/licenses/LICENSE-2.0
|
|
3
|
+
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
from . import const
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# We need to tell the server what our (the client's) address and port are for
|
|
10
|
+
# the udp test. We do not know what is it (from the servers's perspective), so
|
|
11
|
+
# we send some traffic so the server can figure it out.
|
|
12
|
+
|
|
13
|
+
# falling off the end of this method terminates the process
|
|
14
|
+
def run(args, stdout_queue, data_sock, peer_addr):
|
|
15
|
+
if args.verbosity:
|
|
16
|
+
stdout_queue.put("data udp ping sender: start of process")
|
|
17
|
+
|
|
18
|
+
peer_addr_for_udp = peer_addr
|
|
19
|
+
|
|
20
|
+
payload_bytes = const.UDP_PING_MSG.encode()
|
|
21
|
+
|
|
22
|
+
ping_interval_sec = 0.1
|
|
23
|
+
ping_duration_sec = 5
|
|
24
|
+
total_pings_to_send = ping_duration_sec / ping_interval_sec
|
|
25
|
+
|
|
26
|
+
send_count = 0
|
|
27
|
+
|
|
28
|
+
while True:
|
|
29
|
+
|
|
30
|
+
try:
|
|
31
|
+
data_sock.sendto(payload_bytes, peer_addr_for_udp)
|
|
32
|
+
send_count += 1
|
|
33
|
+
|
|
34
|
+
except Exception as e:
|
|
35
|
+
stdout_queue.put("ERROR: data udp ping sender: exception: {}".format(e))
|
|
36
|
+
# exit process
|
|
37
|
+
break
|
|
38
|
+
|
|
39
|
+
time.sleep(ping_interval_sec)
|
|
40
|
+
|
|
41
|
+
if send_count > total_pings_to_send:
|
|
42
|
+
break
|
|
43
|
+
|
|
44
|
+
if args.verbosity:
|
|
45
|
+
stdout_queue.put("data udp ping sender: end of process")
|
bbperf/exceptions.py
ADDED
bbperf/graph.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Copyright (c) 2024 Cloudflare, Inc.
|
|
2
|
+
# Licensed under the Apache 2.0 license found in the LICENSE file or at https://www.apache.org/licenses/LICENSE-2.0
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import argparse
|
|
6
|
+
import subprocess
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def create_graph(args, datafile1):
|
|
10
|
+
|
|
11
|
+
this_script_dir = os.path.dirname(os.path.abspath(__file__))
|
|
12
|
+
|
|
13
|
+
if args.udp:
|
|
14
|
+
gp_file = this_script_dir + "/udp-graph.gp"
|
|
15
|
+
else:
|
|
16
|
+
gp_file = this_script_dir + "/tcp-graph.gp"
|
|
17
|
+
|
|
18
|
+
gnuplot_script = "datafile1 = \"" + datafile1 + "\" ; load \"" + gp_file + "\""
|
|
19
|
+
|
|
20
|
+
result = subprocess.run(["gnuplot", "-e", gnuplot_script], capture_output=True)
|
|
21
|
+
|
|
22
|
+
if args.verbosity or (result.returncode != 0):
|
|
23
|
+
print("gnuplot -e {}".format(gnuplot_script))
|
|
24
|
+
print("returncode: {}".format(result.returncode))
|
|
25
|
+
print("stdout: {}".format(result.stdout))
|
|
26
|
+
print("stderr: {}".format(result.stderr))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == '__main__':
|
|
30
|
+
datafile1 = "/tmp/bbperf-tcp-data-aa97m9xl"
|
|
31
|
+
|
|
32
|
+
args_d = { "udp": True }
|
|
33
|
+
|
|
34
|
+
# recreate args as if it came directly from argparse
|
|
35
|
+
args = argparse.Namespace(**args_d)
|
|
36
|
+
|
|
37
|
+
create_graph(args, datafile1)
|
bbperf/output.py
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Copyright (c) 2024 Cloudflare, Inc.
|
|
2
|
+
# Licensed under the Apache 2.0 license found in the LICENSE file or at https://www.apache.org/licenses/LICENSE-2.0
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import time
|
|
6
|
+
import tempfile
|
|
7
|
+
|
|
8
|
+
from . import calibration
|
|
9
|
+
from . import const
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
args = None
|
|
13
|
+
tmpfile1 = None
|
|
14
|
+
tmpfile2 = None
|
|
15
|
+
last_line_to_stdout_time = 0
|
|
16
|
+
print_header1 = True
|
|
17
|
+
print_header2 = True
|
|
18
|
+
print_header3 = True
|
|
19
|
+
relative_start_time_sec = None
|
|
20
|
+
total_dropped_as_of_last_interval = 0
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def init(args0):
|
|
24
|
+
global args
|
|
25
|
+
global tmpfile1
|
|
26
|
+
global tmpfile2
|
|
27
|
+
|
|
28
|
+
args = args0
|
|
29
|
+
|
|
30
|
+
# create and open file
|
|
31
|
+
|
|
32
|
+
if args.udp:
|
|
33
|
+
tmp_graph_filename_prefix = "bbperf-graph-data-udp-"
|
|
34
|
+
tmp_raw_filename_prefix = "bbperf-raw-data-udp-"
|
|
35
|
+
else:
|
|
36
|
+
tmp_graph_filename_prefix = "bbperf-graph-data-tcp-"
|
|
37
|
+
tmp_raw_filename_prefix = "bbperf-raw-data-tcp-"
|
|
38
|
+
|
|
39
|
+
tmpfile1 = tempfile.NamedTemporaryFile(prefix=tmp_graph_filename_prefix, delete=False)
|
|
40
|
+
tmpfile2 = tempfile.NamedTemporaryFile(prefix=tmp_raw_filename_prefix, delete=False)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_graph_data_file_name():
|
|
44
|
+
return tmpfile1.name
|
|
45
|
+
|
|
46
|
+
def get_raw_data_file_name():
|
|
47
|
+
return tmpfile2.name
|
|
48
|
+
|
|
49
|
+
def term():
|
|
50
|
+
tmpfile1.close()
|
|
51
|
+
tmpfile2.close()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def delete_data_files():
|
|
55
|
+
if args.verbosity:
|
|
56
|
+
print("deleting graph data file: {}".format(tmpfile1.name))
|
|
57
|
+
print("deleting raw data file: {}".format(tmpfile2.name))
|
|
58
|
+
|
|
59
|
+
os.remove(tmpfile1.name)
|
|
60
|
+
os.remove(tmpfile2.name)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def write_data_to_file(lineout, fileout):
|
|
64
|
+
lineout_bytes = "{}\n".format(lineout).encode()
|
|
65
|
+
fileout.file.write(lineout_bytes)
|
|
66
|
+
|
|
67
|
+
def write_raw_data_to_file(lineout):
|
|
68
|
+
write_data_to_file(lineout, tmpfile2)
|
|
69
|
+
|
|
70
|
+
def write_graph_data_to_file(lineout):
|
|
71
|
+
write_data_to_file(lineout, tmpfile1)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# keep in mind here that the interval data is coming in at a faster
|
|
75
|
+
# rate than what we want to (normally) display on stdout
|
|
76
|
+
|
|
77
|
+
def print_output(s1):
|
|
78
|
+
global args
|
|
79
|
+
global last_line_to_stdout_time
|
|
80
|
+
global print_header1
|
|
81
|
+
global print_header2
|
|
82
|
+
global print_header3
|
|
83
|
+
global relative_start_time_sec
|
|
84
|
+
global total_dropped_as_of_last_interval
|
|
85
|
+
|
|
86
|
+
write_raw_data_to_file(s1)
|
|
87
|
+
|
|
88
|
+
swords = s1.split()
|
|
89
|
+
|
|
90
|
+
r_record_type = swords[1]
|
|
91
|
+
r_pkt_sent_time_sec = float(swords[2])
|
|
92
|
+
r_sender_interval_duration_sec = float(swords[3])
|
|
93
|
+
r_sender_interval_pkts_sent = int(swords[4]) # valid for udp only
|
|
94
|
+
r_sender_interval_bytes_sent = int(swords[5])
|
|
95
|
+
r_sender_total_pkts_sent = int(swords[6]) # valid for udp only
|
|
96
|
+
r_receiver_interval_duration_sec = float(swords[8])
|
|
97
|
+
r_receiver_interval_pkts_received = int(swords[9]) # valid for udp only
|
|
98
|
+
r_receiver_interval_bytes_received = int(swords[10])
|
|
99
|
+
r_receiver_total_pkts_received = int(swords[11]) # valid for udp only
|
|
100
|
+
r_pkt_received_time_sec = float(swords[13])
|
|
101
|
+
|
|
102
|
+
curr_time = time.time()
|
|
103
|
+
rtt_sec = r_pkt_received_time_sec - r_pkt_sent_time_sec
|
|
104
|
+
|
|
105
|
+
if relative_start_time_sec is None:
|
|
106
|
+
# first incoming result has arrived
|
|
107
|
+
relative_start_time_sec = r_pkt_sent_time_sec
|
|
108
|
+
relative_pkt_sent_time_sec = 0
|
|
109
|
+
relative_pkt_received_time_sec = 0
|
|
110
|
+
else:
|
|
111
|
+
relative_pkt_sent_time_sec = r_pkt_sent_time_sec - relative_start_time_sec
|
|
112
|
+
relative_pkt_received_time_sec = r_pkt_received_time_sec - relative_start_time_sec
|
|
113
|
+
|
|
114
|
+
if r_record_type == "run":
|
|
115
|
+
|
|
116
|
+
sender_interval_rate_bps = (r_sender_interval_bytes_sent * 8.0) / r_sender_interval_duration_sec
|
|
117
|
+
sender_interval_rate_mbps = sender_interval_rate_bps / (10 ** 6)
|
|
118
|
+
|
|
119
|
+
receiver_interval_rate_bytes_per_sec = r_receiver_interval_bytes_received / r_receiver_interval_duration_sec
|
|
120
|
+
receiver_interval_rate_bps = receiver_interval_rate_bytes_per_sec * 8
|
|
121
|
+
receiver_interval_rate_mbps = receiver_interval_rate_bps / (10 ** 6)
|
|
122
|
+
|
|
123
|
+
rtt_ms = rtt_sec * 1000
|
|
124
|
+
|
|
125
|
+
unloaded_rtt_sec = calibration.get_unloaded_latency_rtt_sec()
|
|
126
|
+
unloaded_rtt_ms = unloaded_rtt_sec * 1000
|
|
127
|
+
|
|
128
|
+
bdp_bytes = int( receiver_interval_rate_bytes_per_sec * unloaded_rtt_sec )
|
|
129
|
+
buffered_bytes = int( receiver_interval_rate_bytes_per_sec * rtt_sec )
|
|
130
|
+
|
|
131
|
+
if bdp_bytes > 0:
|
|
132
|
+
bloat_factor = float(buffered_bytes) / bdp_bytes
|
|
133
|
+
else:
|
|
134
|
+
bloat_factor = 0
|
|
135
|
+
|
|
136
|
+
if args.udp:
|
|
137
|
+
sender_pps = int(r_sender_interval_pkts_sent / r_sender_interval_duration_sec)
|
|
138
|
+
receiver_pps = int(r_receiver_interval_pkts_received / r_receiver_interval_duration_sec)
|
|
139
|
+
|
|
140
|
+
total_dropped = r_sender_total_pkts_sent - r_receiver_total_pkts_received
|
|
141
|
+
dropped_this_interval = total_dropped - total_dropped_as_of_last_interval
|
|
142
|
+
if dropped_this_interval < 0:
|
|
143
|
+
dropped_this_interval = 0
|
|
144
|
+
dropped_this_interval_percent = (dropped_this_interval * 100.0) / r_sender_interval_pkts_sent
|
|
145
|
+
# remember this for next loop:
|
|
146
|
+
total_dropped_as_of_last_interval = total_dropped
|
|
147
|
+
else:
|
|
148
|
+
# tcp
|
|
149
|
+
sender_pps = -1
|
|
150
|
+
receiver_pps = -1
|
|
151
|
+
dropped_this_interval = -1
|
|
152
|
+
dropped_this_interval_percent = -1
|
|
153
|
+
|
|
154
|
+
if print_header3:
|
|
155
|
+
lineout = "sent_time recv_time sender_pps sender_Mbps receiver_pps receiver_Mbps unloaded_rtt_ms rtt_ms BDP_bytes buffered_bytes bloat_factor pkts_dropped pkts_dropped_percent"
|
|
156
|
+
write_graph_data_to_file(lineout)
|
|
157
|
+
print_header3 = False
|
|
158
|
+
|
|
159
|
+
# write to file the same data and same rate as what we are receiving over the control connection
|
|
160
|
+
lineout = "{} {} {} {} {} {} {} {} {} {} {} {} {}".format(
|
|
161
|
+
relative_pkt_sent_time_sec,
|
|
162
|
+
relative_pkt_received_time_sec,
|
|
163
|
+
sender_pps,
|
|
164
|
+
sender_interval_rate_mbps,
|
|
165
|
+
receiver_pps,
|
|
166
|
+
receiver_interval_rate_mbps,
|
|
167
|
+
unloaded_rtt_ms,
|
|
168
|
+
rtt_ms,
|
|
169
|
+
bdp_bytes,
|
|
170
|
+
buffered_bytes,
|
|
171
|
+
bloat_factor,
|
|
172
|
+
dropped_this_interval,
|
|
173
|
+
dropped_this_interval_percent
|
|
174
|
+
)
|
|
175
|
+
write_graph_data_to_file(lineout)
|
|
176
|
+
|
|
177
|
+
# write to stdout at the rate of one line per second
|
|
178
|
+
# each stdout line will be a 0.1s snapshot
|
|
179
|
+
if (curr_time > (last_line_to_stdout_time + const.STDOUT_INTERVAL_SEC)) or args.verbosity:
|
|
180
|
+
if print_header2:
|
|
181
|
+
print(" sent_time recv_time sender_pps sender_Mbps receiver_pps receiver_Mbps unloaded_rtt_ms rtt_ms BDP_bytes buffered_bytes bloat pkts_dropped drop%")
|
|
182
|
+
print_header2 = False
|
|
183
|
+
|
|
184
|
+
if dropped_this_interval_percent < 0:
|
|
185
|
+
dropped_this_interval_percent_str = " n/a"
|
|
186
|
+
else:
|
|
187
|
+
dropped_this_interval_percent_str = "{:6.3f}%".format(dropped_this_interval_percent)
|
|
188
|
+
|
|
189
|
+
print("{:11.6f} {:11.6f} {:8d} {:11.3f} {:8d} {:11.3f} {:8.3f} {:9.3f} {:9d} {:9d} {:6.1f}x {:6d} {}".format(
|
|
190
|
+
relative_pkt_sent_time_sec,
|
|
191
|
+
relative_pkt_received_time_sec,
|
|
192
|
+
sender_pps,
|
|
193
|
+
sender_interval_rate_mbps,
|
|
194
|
+
receiver_pps,
|
|
195
|
+
receiver_interval_rate_mbps,
|
|
196
|
+
unloaded_rtt_ms,
|
|
197
|
+
rtt_ms,
|
|
198
|
+
bdp_bytes,
|
|
199
|
+
buffered_bytes,
|
|
200
|
+
bloat_factor,
|
|
201
|
+
dropped_this_interval,
|
|
202
|
+
dropped_this_interval_percent_str
|
|
203
|
+
))
|
|
204
|
+
|
|
205
|
+
last_line_to_stdout_time = curr_time
|
|
206
|
+
|
|
207
|
+
else:
|
|
208
|
+
calibration.update_rtt_sec(rtt_sec)
|
|
209
|
+
|
|
210
|
+
if curr_time > (last_line_to_stdout_time + const.STDOUT_INTERVAL_SEC):
|
|
211
|
+
if print_header1:
|
|
212
|
+
print("calibrating")
|
|
213
|
+
print(" sent_time recv_time rtt_ms")
|
|
214
|
+
print_header1 = False
|
|
215
|
+
|
|
216
|
+
unloaded_latency_rtt_sec = calibration.get_unloaded_latency_rtt_sec()
|
|
217
|
+
unloaded_latency_rtt_ms = unloaded_latency_rtt_sec * 1000
|
|
218
|
+
|
|
219
|
+
print("{:11.6f} {:11.6f} {:11.6f}".format(
|
|
220
|
+
relative_pkt_sent_time_sec,
|
|
221
|
+
relative_pkt_received_time_sec,
|
|
222
|
+
unloaded_latency_rtt_ms
|
|
223
|
+
))
|
|
224
|
+
|
|
225
|
+
last_line_to_stdout_time = curr_time
|
bbperf/run_test.sh
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2024 Cloudflare, Inc.
|
|
4
|
+
# Licensed under the Apache 2.0 license found in the LICENSE file or at https://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
+
|
|
6
|
+
SERVER_ADDR=127.0.0.1
|
|
7
|
+
|
|
8
|
+
DURATION=10
|
|
9
|
+
|
|
10
|
+
OPTARGS=""
|
|
11
|
+
#OPTARGS="-k -g"
|
|
12
|
+
|
|
13
|
+
set -x
|
|
14
|
+
|
|
15
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS
|
|
16
|
+
|
|
17
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -R
|
|
18
|
+
|
|
19
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M
|
|
20
|
+
|
|
21
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -R
|
|
22
|
+
|
|
23
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps
|
|
24
|
+
|
|
25
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -R
|
|
26
|
+
|
|
27
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps
|
|
28
|
+
|
|
29
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -R
|
|
30
|
+
|
|
31
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -u
|
|
32
|
+
|
|
33
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -u -R
|
|
34
|
+
|
|
35
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -u
|
|
36
|
+
|
|
37
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -u -R
|
|
38
|
+
|
|
39
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -u
|
|
40
|
+
|
|
41
|
+
./bbperf.py -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -u -R
|