bbperf 0.0.1__tar.gz → 0.0.3__tar.gz

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.
Files changed (30) hide show
  1. bbperf-0.0.3/.gitignore +3 -0
  2. bbperf-0.0.3/DEPLOY.txt +48 -0
  3. {bbperf-0.0.1 → bbperf-0.0.3}/PKG-INFO +12 -8
  4. {bbperf-0.0.1 → bbperf-0.0.3}/README.md +10 -7
  5. {bbperf-0.0.1 → bbperf-0.0.3}/pyproject.toml +4 -1
  6. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/bbperf.py +5 -1
  7. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/client.py +4 -2
  8. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/const.py +5 -0
  9. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/control_receiver_thread.py +21 -2
  10. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/data_sender_thread.py +20 -51
  11. bbperf-0.0.3/src/bbperf/json_output_class.py +69 -0
  12. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/output.py +55 -54
  13. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/server.py +4 -2
  14. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/tcp_control_connection_class.py +5 -1
  15. bbperf-0.0.3/src/bbperf/udp_rate_manager_class.py +55 -0
  16. bbperf-0.0.3/src/bbperf/util.py +196 -0
  17. bbperf-0.0.3/tests/run_test.sh +52 -0
  18. bbperf-0.0.1/.gitignore +0 -1
  19. bbperf-0.0.1/src/bbperf/run_test.sh +0 -41
  20. bbperf-0.0.1/src/bbperf/util.py +0 -105
  21. {bbperf-0.0.1 → bbperf-0.0.3}/LICENSE +0 -0
  22. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/.gitignore +0 -0
  23. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/__init__.py +0 -0
  24. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/calibration.py +0 -0
  25. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/data_receiver_thread.py +2 -2
  26. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/data_udp_ping_sender_thread.py +0 -0
  27. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/exceptions.py +0 -0
  28. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/graph.py +0 -0
  29. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/tcp-graph.gp +0 -0
  30. {bbperf-0.0.1 → bbperf-0.0.3}/src/bbperf/udp-graph.gp +0 -0
@@ -0,0 +1,3 @@
1
+ dist
2
+ .venv
3
+ .vscode
@@ -0,0 +1,48 @@
1
+
2
+ PREREQUISITES
3
+
4
+ Appropriate account/credentials to upload to the PyPI site
5
+
6
+ python3 -m pip install --upgrade pip build twine
7
+
8
+ BUILD
9
+
10
+ Create tar.gz and whl files in dist directory:
11
+
12
+ cd /path/to/bbperf/git/repo/dir <-- the directory with the pyproject.toml file
13
+
14
+ vim pyproject.toml <-- increment the version number
15
+
16
+ git tag -a v0.0.2 -m 'version 0.0.2'
17
+
18
+ git push origin --tags
19
+
20
+ python3 -m build
21
+
22
+ UPLOAD
23
+
24
+ Upload dist files to production PyPI site:
25
+
26
+ cd /path/to/bbperf/git/repo/dir <-- the directory with the pyproject.toml file
27
+
28
+ python3 -m twine upload dist/*
29
+
30
+ To view:
31
+ https://pypi.org
32
+
33
+ MISCELLANEOUS
34
+
35
+ Using the test PyPI site:
36
+
37
+ python3 -m twine upload --repository testpypi dist/*
38
+
39
+ To view:
40
+ https://test.pypi.org
41
+
42
+ To install from test PyPI:
43
+ python3 -m pip install --upgrade --index-url https://test.pypi.org/simple/ --nodeps bbperf
44
+
45
+ Installing from the local git repository:
46
+
47
+ python3 -m pip install /path/to/bbperf/git/repo/dir <-- the directory with the pyproject.toml file
48
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bbperf
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: An end-to-end performance and bufferbloat measurement tool
5
5
  Project-URL: Homepage, https://github.com/cloudflare/bbperf
6
6
  Project-URL: Issues, https://github.com/cloudflare/bbperf/issues
@@ -13,6 +13,7 @@ Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Topic :: System :: Networking
15
15
  Requires-Python: >=3.9
16
+ Requires-Dist: numpy
16
17
  Description-Content-Type: text/markdown
17
18
 
18
19
  <p align="center"><strong>bbperf</strong> <em>- An end-to-end performance and bufferbloat measurement tool</em></p>
@@ -42,6 +43,8 @@ Features that distinguish this tool from existing tools include:
42
43
 
43
44
  * Automatic generation of graphs
44
45
 
46
+ * The UDP option will automatically adjust the sending rate to just above the goodput rate so that any bufferbloat issues are measured. This feature is enabled by default. Simply omit the `-b/--bandwidth` option when running a `-u/--udp` test.
47
+
45
48
  ### Usage
46
49
 
47
50
  To run a test:
@@ -64,7 +67,7 @@ The direction of data flow is from the client to the server. That is reversed w
64
67
 
65
68
  ```
66
69
  $ bbperf.py --help
67
- usage: bbperf.py [-h] [-v] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-b BANDWIDTH] [-g] [-k]
70
+ usage: bbperf.py [-h] [-v] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-b BANDWIDTH] [-g] [-k] [-J JSON_FILE]
68
71
 
69
72
  bbperf: end to end performance and bufferbloat measurement tool
70
73
 
@@ -72,18 +75,19 @@ options:
72
75
  -h, --help show this help message and exit
73
76
  -v, --verbosity increase output verbosity
74
77
  -s, --server run in server mode
75
- -c SERVER_IP, --client SERVER_IP
78
+ -c, --client SERVER_IP
76
79
  run in client mode
77
- -p SERVER_PORT, --port SERVER_PORT
80
+ -p, --port SERVER_PORT
78
81
  server port (default: 5301)
79
82
  -R, --reverse data flow in download direction (server to client)
80
- -t SECONDS, --time SECONDS
81
- duration of run in seconds
83
+ -t, --time SECONDS duration of run in seconds
82
84
  -u, --udp run in UDP mode (default: TCP mode)
83
- -b BANDWIDTH, --bandwidth BANDWIDTH
84
- n[kmgKMG] | n[kmgKMG]pps
85
+ -b, --bandwidth BANDWIDTH
86
+ n[kmgKMG] | n[kmgKMG]pps, optional for both TCP and UDP
85
87
  -g, --graph generate graph (requires gnuplot)
86
88
  -k, --keep keep data file
89
+ -J, --json-file JSON_FILE
90
+ JSON output file
87
91
  ```
88
92
 
89
93
  Output from `bbperf` includes the following information:
@@ -25,6 +25,8 @@ Features that distinguish this tool from existing tools include:
25
25
 
26
26
  * Automatic generation of graphs
27
27
 
28
+ * The UDP option will automatically adjust the sending rate to just above the goodput rate so that any bufferbloat issues are measured. This feature is enabled by default. Simply omit the `-b/--bandwidth` option when running a `-u/--udp` test.
29
+
28
30
  ### Usage
29
31
 
30
32
  To run a test:
@@ -47,7 +49,7 @@ The direction of data flow is from the client to the server. That is reversed w
47
49
 
48
50
  ```
49
51
  $ bbperf.py --help
50
- usage: bbperf.py [-h] [-v] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-b BANDWIDTH] [-g] [-k]
52
+ usage: bbperf.py [-h] [-v] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-b BANDWIDTH] [-g] [-k] [-J JSON_FILE]
51
53
 
52
54
  bbperf: end to end performance and bufferbloat measurement tool
53
55
 
@@ -55,18 +57,19 @@ options:
55
57
  -h, --help show this help message and exit
56
58
  -v, --verbosity increase output verbosity
57
59
  -s, --server run in server mode
58
- -c SERVER_IP, --client SERVER_IP
60
+ -c, --client SERVER_IP
59
61
  run in client mode
60
- -p SERVER_PORT, --port SERVER_PORT
62
+ -p, --port SERVER_PORT
61
63
  server port (default: 5301)
62
64
  -R, --reverse data flow in download direction (server to client)
63
- -t SECONDS, --time SECONDS
64
- duration of run in seconds
65
+ -t, --time SECONDS duration of run in seconds
65
66
  -u, --udp run in UDP mode (default: TCP mode)
66
- -b BANDWIDTH, --bandwidth BANDWIDTH
67
- n[kmgKMG] | n[kmgKMG]pps
67
+ -b, --bandwidth BANDWIDTH
68
+ n[kmgKMG] | n[kmgKMG]pps, optional for both TCP and UDP
68
69
  -g, --graph generate graph (requires gnuplot)
69
70
  -k, --keep keep data file
71
+ -J, --json-file JSON_FILE
72
+ JSON output file
70
73
  ```
71
74
 
72
75
  Output from `bbperf` includes the following information:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bbperf"
7
- version = "0.0.1"
7
+ version = "0.0.3"
8
8
  authors = [
9
9
  { name="Mike Freemon", email="mfreemon@cloudflare.com" },
10
10
  ]
@@ -18,6 +18,9 @@ classifiers = [
18
18
  "License :: OSI Approved :: Apache Software License",
19
19
  "Topic :: System :: Networking",
20
20
  ]
21
+ dependencies = [
22
+ "numpy",
23
+ ]
21
24
  license = "Apache-2.0"
22
25
  license-files = ["LICEN[CS]E*"]
23
26
 
@@ -53,7 +53,7 @@ def mainline():
53
53
 
54
54
  parser.add_argument("-b", "--bandwidth",
55
55
  default=None,
56
- help="n[kmgKMG] | n[kmgKMG]pps")
56
+ help="n[kmgKMG] | n[kmgKMG]pps, optional for both TCP and UDP")
57
57
 
58
58
  parser.add_argument("-g", "--graph",
59
59
  action="store_true",
@@ -65,6 +65,10 @@ def mainline():
65
65
  default=False,
66
66
  help="keep data file")
67
67
 
68
+ parser.add_argument("-J", "--json-file",
69
+ default=None,
70
+ help="JSON output file")
71
+
68
72
  args = parser.parse_args()
69
73
 
70
74
  util.validate_args(args)
@@ -79,6 +79,8 @@ def client_mainline(args):
79
79
  if args.verbosity:
80
80
  print("created data connection ({})".format("udp" if args.udp else "tcp"))
81
81
 
82
+ shared_udp_sending_rate_pps = multiprocessing.Value('d', const.UDP_DEFAULT_INITIAL_RATE)
83
+
82
84
  # run test
83
85
 
84
86
  if args.verbosity:
@@ -95,7 +97,7 @@ def client_mainline(args):
95
97
  control_receiver_process = multiprocessing.Process(
96
98
  name = "controlreceiver",
97
99
  target = control_receiver_thread.run_recv_term_queue,
98
- args = (args, control_receiver_stdout_queue, control_conn, control_receiver_results_queue),
100
+ args = (args, control_receiver_stdout_queue, control_conn, control_receiver_results_queue, shared_udp_sending_rate_pps),
99
101
  daemon = True)
100
102
 
101
103
  control_receiver_process.start()
@@ -105,7 +107,7 @@ def client_mainline(args):
105
107
  data_sender_process = multiprocessing.Process(
106
108
  name = "datasender",
107
109
  target = data_sender_thread.run,
108
- args = (args, data_sender_stdout_queue, data_sock, server_addr),
110
+ args = (args, data_sender_stdout_queue, data_sock, server_addr, shared_udp_sending_rate_pps),
109
111
  daemon = True)
110
112
 
111
113
  # test starts here
@@ -25,3 +25,8 @@ START_MSG = " start "
25
25
  UDP_PING_MSG = "ping"
26
26
 
27
27
  SOCKET_TIMEOUT_SEC=20
28
+
29
+ UDP_DEFAULT_INITIAL_RATE = 8000
30
+
31
+ UDP_MIN_RATE = 100
32
+ UDP_MAX_RATE = 800000
@@ -4,13 +4,18 @@
4
4
  import time
5
5
 
6
6
  from .exceptions import PeerDisconnectedException
7
+ from .udp_rate_manager_class import UdpRateManagerClass
7
8
 
8
9
 
10
+ # direction up, runs on client
11
+ # args are client args (not server args)
9
12
  # falling off the end of this method terminates the process
10
- def run_recv_term_queue(args, stdout_queue, control_conn, results_queue):
13
+ def run_recv_term_queue(args, stdout_queue, control_conn, results_queue, shared_udp_sending_rate_pps):
11
14
  if args.verbosity:
12
15
  stdout_queue.put("starting control receiver process: run_recv_term_queue")
13
16
 
17
+ udp_rate_manager = UdpRateManagerClass(args, shared_udp_sending_rate_pps)
18
+
14
19
  while True:
15
20
 
16
21
  try:
@@ -35,17 +40,25 @@ def run_recv_term_queue(args, stdout_queue, control_conn, results_queue):
35
40
 
36
41
  results_queue.put(new_str)
37
42
 
43
+ # udp autorate
44
+ if args.udp and not args.bandwidth:
45
+ udp_rate_manager.update(new_str)
46
+
38
47
  control_conn.close()
39
48
 
40
49
  if args.verbosity:
41
50
  stdout_queue.put("exiting control receiver process: run_recv_term_queue")
42
51
 
43
52
 
53
+ # direction down, runs on server
54
+ # args are client args (not server args)
44
55
  # falling off the end of this method terminates the process
45
- def run_recv_term_send(args, stdout_queue, control_conn):
56
+ def run_recv_term_send(args, stdout_queue, control_conn, shared_udp_sending_rate_pps):
46
57
  if args.verbosity:
47
58
  stdout_queue.put("starting control receiver process: run_recv_term_send")
48
59
 
60
+ udp_rate_manager = UdpRateManagerClass(args, shared_udp_sending_rate_pps)
61
+
49
62
  while True:
50
63
 
51
64
  try:
@@ -70,12 +83,18 @@ def run_recv_term_send(args, stdout_queue, control_conn):
70
83
 
71
84
  control_conn.send(new_str.encode())
72
85
 
86
+ # udp autorate
87
+ if args.udp and not args.bandwidth:
88
+ udp_rate_manager.update(new_str)
89
+
73
90
  control_conn.close()
74
91
 
75
92
  if args.verbosity:
76
93
  stdout_queue.put("exiting control receiver process: run_recv_term_send")
77
94
 
78
95
 
96
+ # direction down, runs on client (passthru)
97
+ # args are client args (not server args) -- this always runs on client
79
98
  # falling off the end of this method terminates the process
80
99
  def run_recv_queue(args, stdout_queue, control_conn, results_queue):
81
100
  if args.verbosity:
@@ -11,7 +11,7 @@ from . import calibration
11
11
 
12
12
 
13
13
  # falling off the end of this method terminates the process
14
- def run(args, stdout_queue, data_sock, peer_addr):
14
+ def run(args, stdout_queue, data_sock, peer_addr, shared_udp_sending_rate_pps):
15
15
  if args.verbosity:
16
16
  stdout_queue.put("data sender: start of process")
17
17
 
@@ -31,48 +31,15 @@ def run(args, stdout_queue, data_sock, peer_addr):
31
31
 
32
32
  # calculate sending rate
33
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
-
34
+ if args.bandwidth or args.udp:
35
+ if args.bandwidth:
36
+ bandwidth_is_pps, bandwidth_val_int = util.convert_bandwidth_str_to_int(args.bandwidth)
48
37
  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 )
38
+ # must be UDP with no bandwidth specified, so use UDP autorate
39
+ bandwidth_is_pps = True
40
+ bandwidth_val_int = shared_udp_sending_rate_pps.value
56
41
 
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
- ))
42
+ batch_size, delay_between_batches = util.convert_bandwidth_spec_to_batch_info(args, bandwidth_is_pps, bandwidth_val_int)
76
43
 
77
44
  # start sending
78
45
 
@@ -172,11 +139,22 @@ def run(args, stdout_queue, data_sock, peer_addr):
172
139
  interval_send_count = accum_send_count
173
140
  interval_bytes_sent = accum_bytes_sent
174
141
 
142
+ if args.verbosity == 3:
143
+ print("data_sender: a {} {} {} {} {} {} b".format(
144
+ record_type, curr_time_sec, interval_time_sec, interval_send_count, interval_bytes_sent, total_send_counter)
145
+ )
146
+
175
147
  interval_start_time = curr_time_sec
176
148
  interval_end_time = interval_start_time + const.SAMPLE_INTERVAL_SEC
177
149
  accum_send_count = 0
178
150
  accum_bytes_sent = 0
179
151
 
152
+ # update udp rate when autorate in effect
153
+ if args.udp and not args.bandwidth:
154
+ bandwidth_is_pps = True
155
+ bandwidth_val_int = shared_udp_sending_rate_pps.value
156
+ batch_size, delay_between_batches = util.convert_bandwidth_spec_to_batch_info(args, bandwidth_is_pps, bandwidth_val_int)
157
+
180
158
  # send very slowly at first to establish unloaded latency
181
159
  if not is_calibrated:
182
160
  time.sleep(0.2)
@@ -189,21 +167,12 @@ def run(args, stdout_queue, data_sock, peer_addr):
189
167
  if curr_time_sec > end_time:
190
168
  break
191
169
 
192
- if args.bandwidth:
170
+ if args.bandwidth or args.udp:
193
171
  current_batch_counter += 1
194
172
  if current_batch_counter >= batch_size:
195
173
  this_delay = delay_between_batches - (curr_time_sec - current_batch_start_time)
196
174
  if this_delay > 0:
197
175
  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
176
  current_batch_start_time += delay_between_batches
208
177
  current_batch_counter = 0
209
178
 
@@ -0,0 +1,69 @@
1
+
2
+ import json
3
+ import numpy
4
+
5
+ class JsonOutputClass:
6
+
7
+ def __init__(self, args):
8
+ self.args = args
9
+
10
+ self.json_output_file = open(args.json_file, 'w')
11
+
12
+ self.output_dict = {}
13
+ self.output_dict["entries"] = []
14
+
15
+ def set_unloaded_rtt_ms(self, rtt_ms):
16
+ if "unloaded_rtt_ms" not in self.output_dict:
17
+ self.output_dict["unloaded_rtt_ms"] = rtt_ms
18
+
19
+ def add_entry(self, entry):
20
+ self.output_dict["entries"].append(entry)
21
+
22
+ def create_aggregate_stats(self):
23
+ loaded_rtt_ms_list = []
24
+ receiver_throughput_rate_mbps_list = []
25
+ excess_buffered_bytes_list = []
26
+ receiver_pps_list = []
27
+ pkt_loss_percent_list = []
28
+
29
+ for entry in self.output_dict["entries"]:
30
+ loaded_rtt_ms_list.append(entry["loaded_rtt_ms"])
31
+ receiver_throughput_rate_mbps_list.append(entry["receiver_throughput_rate_mbps"])
32
+ excess_buffered_bytes_list.append(entry["excess_buffered_bytes"])
33
+ receiver_pps_list.append(entry["receiver_pps"])
34
+ pkt_loss_percent_list.append(entry["pkt_loss_percent"])
35
+
36
+ p50, p90, p99 = numpy.percentile(loaded_rtt_ms_list, [50, 90, 99])
37
+ self.output_dict["loaded_rtt_ms"] = {}
38
+ self.output_dict["loaded_rtt_ms"]["p50"] = p50
39
+ self.output_dict["loaded_rtt_ms"]["p90"] = p90
40
+ self.output_dict["loaded_rtt_ms"]["p99"] = p99
41
+
42
+ p50, p90, p99 = numpy.percentile(receiver_throughput_rate_mbps_list, [50, 90, 99])
43
+ self.output_dict["receiver_throughput_rate_mbps"] = {}
44
+ self.output_dict["receiver_throughput_rate_mbps"]["p50"] = p50
45
+ self.output_dict["receiver_throughput_rate_mbps"]["p90"] = p90
46
+ self.output_dict["receiver_throughput_rate_mbps"]["p99"] = p99
47
+
48
+ p50, p90, p99 = numpy.percentile(excess_buffered_bytes_list, [50, 90, 99])
49
+ self.output_dict["excess_buffered_bytes"] = {}
50
+ self.output_dict["excess_buffered_bytes"]["p50"] = p50
51
+ self.output_dict["excess_buffered_bytes"]["p90"] = p90
52
+ self.output_dict["excess_buffered_bytes"]["p99"] = p99
53
+
54
+ p50, p90, p99 = numpy.percentile(receiver_pps_list, [50, 90, 99])
55
+ self.output_dict["receiver_pps"] = {}
56
+ self.output_dict["receiver_pps"]["p50"] = p50
57
+ self.output_dict["receiver_pps"]["p90"] = p90
58
+ self.output_dict["receiver_pps"]["p99"] = p99
59
+
60
+ p50, p90, p99 = numpy.percentile(pkt_loss_percent_list, [50, 90, 99])
61
+ self.output_dict["pkt_loss_percent"] = {}
62
+ self.output_dict["pkt_loss_percent"]["p50"] = p50
63
+ self.output_dict["pkt_loss_percent"]["p90"] = p90
64
+ self.output_dict["pkt_loss_percent"]["p99"] = p99
65
+
66
+ def write_output_file(self):
67
+ self.create_aggregate_stats()
68
+ json.dump(self.output_dict, self.json_output_file, indent=4)
69
+ self.json_output_file.close()
@@ -7,6 +7,8 @@ import tempfile
7
7
 
8
8
  from . import calibration
9
9
  from . import const
10
+ from . import util
11
+ from .json_output_class import JsonOutputClass
10
12
 
11
13
 
12
14
  args = None
@@ -18,12 +20,14 @@ print_header2 = True
18
20
  print_header3 = True
19
21
  relative_start_time_sec = None
20
22
  total_dropped_as_of_last_interval = 0
23
+ json_output = None
21
24
 
22
25
 
23
26
  def init(args0):
24
27
  global args
25
28
  global tmpfile1
26
29
  global tmpfile2
30
+ global json_output
27
31
 
28
32
  args = args0
29
33
 
@@ -39,6 +43,14 @@ def init(args0):
39
43
  tmpfile1 = tempfile.NamedTemporaryFile(prefix=tmp_graph_filename_prefix, delete=False)
40
44
  tmpfile2 = tempfile.NamedTemporaryFile(prefix=tmp_raw_filename_prefix, delete=False)
41
45
 
46
+ # requested JSON output file
47
+ if args.json_file:
48
+ try:
49
+ json_output = JsonOutputClass(args)
50
+ except Exception as e:
51
+ print("ERROR creating json output: {} {}".format(type(e), str(e)))
52
+ json_output = None
53
+
42
54
 
43
55
  def get_graph_data_file_name():
44
56
  return tmpfile1.name
@@ -50,6 +62,9 @@ def term():
50
62
  tmpfile1.close()
51
63
  tmpfile2.close()
52
64
 
65
+ if json_output:
66
+ json_output.write_output_file()
67
+
53
68
 
54
69
  def delete_data_files():
55
70
  if args.verbosity:
@@ -85,69 +100,42 @@ def print_output(s1):
85
100
 
86
101
  write_raw_data_to_file(s1)
87
102
 
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
103
  curr_time = time.time()
103
- rtt_sec = r_pkt_received_time_sec - r_pkt_sent_time_sec
104
+
105
+ r_record = util.parse_r_record(args, s1)
104
106
 
105
107
  if relative_start_time_sec is None:
106
108
  # first incoming result has arrived
107
- relative_start_time_sec = r_pkt_sent_time_sec
109
+ relative_start_time_sec = r_record["r_pkt_sent_time_sec"]
108
110
  relative_pkt_sent_time_sec = 0
109
111
  relative_pkt_received_time_sec = 0
110
112
  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
113
+ relative_pkt_sent_time_sec = r_record["r_pkt_sent_time_sec"] - relative_start_time_sec
114
+ relative_pkt_received_time_sec = r_record["r_pkt_received_time_sec"] - relative_start_time_sec
124
115
 
116
+ if r_record["r_record_type"] == "run":
125
117
  unloaded_rtt_sec = calibration.get_unloaded_latency_rtt_sec()
126
118
  unloaded_rtt_ms = unloaded_rtt_sec * 1000
127
119
 
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 )
120
+ if json_output:
121
+ json_output.set_unloaded_rtt_ms(unloaded_rtt_ms)
122
+
123
+ bdp_bytes = int( r_record["receiver_interval_rate_bytes_per_sec"] * unloaded_rtt_sec )
130
124
 
131
125
  if bdp_bytes > 0:
132
- bloat_factor = float(buffered_bytes) / bdp_bytes
126
+ bloat_factor = float(r_record["buffered_bytes"]) / bdp_bytes
133
127
  else:
134
128
  bloat_factor = 0
135
129
 
136
130
  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
131
+ dropped_this_interval = r_record["total_dropped"] - total_dropped_as_of_last_interval
142
132
  if dropped_this_interval < 0:
143
133
  dropped_this_interval = 0
144
- dropped_this_interval_percent = (dropped_this_interval * 100.0) / r_sender_interval_pkts_sent
134
+ dropped_this_interval_percent = (dropped_this_interval * 100.0) / r_record["r_sender_interval_pkts_sent"]
145
135
  # remember this for next loop:
146
- total_dropped_as_of_last_interval = total_dropped
136
+ total_dropped_as_of_last_interval = r_record["total_dropped"]
147
137
  else:
148
138
  # tcp
149
- sender_pps = -1
150
- receiver_pps = -1
151
139
  dropped_this_interval = -1
152
140
  dropped_this_interval_percent = -1
153
141
 
@@ -160,20 +148,33 @@ def print_output(s1):
160
148
  lineout = "{} {} {} {} {} {} {} {} {} {} {} {} {}".format(
161
149
  relative_pkt_sent_time_sec,
162
150
  relative_pkt_received_time_sec,
163
- sender_pps,
164
- sender_interval_rate_mbps,
165
- receiver_pps,
166
- receiver_interval_rate_mbps,
151
+ r_record["sender_pps"],
152
+ r_record["sender_interval_rate_mbps"],
153
+ r_record["receiver_pps"],
154
+ r_record["receiver_interval_rate_mbps"],
167
155
  unloaded_rtt_ms,
168
- rtt_ms,
156
+ r_record["rtt_ms"],
169
157
  bdp_bytes,
170
- buffered_bytes,
158
+ r_record["buffered_bytes"],
171
159
  bloat_factor,
172
160
  dropped_this_interval,
173
161
  dropped_this_interval_percent
174
162
  )
163
+
175
164
  write_graph_data_to_file(lineout)
176
165
 
166
+ # add to JSON output
167
+ if json_output:
168
+ new_entry = {
169
+ "sent_time_sec": r_record["r_pkt_sent_time_sec"],
170
+ "loaded_rtt_ms": r_record["rtt_ms"],
171
+ "receiver_throughput_rate_mbps": r_record["receiver_interval_rate_mbps"],
172
+ "excess_buffered_bytes": (r_record["buffered_bytes"] - bdp_bytes),
173
+ "receiver_pps": r_record["receiver_pps"],
174
+ "pkt_loss_percent": dropped_this_interval_percent
175
+ }
176
+ json_output.add_entry(new_entry)
177
+
177
178
  # write to stdout at the rate of one line per second
178
179
  # each stdout line will be a 0.1s snapshot
179
180
  if (curr_time > (last_line_to_stdout_time + const.STDOUT_INTERVAL_SEC)) or args.verbosity:
@@ -189,14 +190,14 @@ def print_output(s1):
189
190
  print("{:11.6f} {:11.6f} {:8d} {:11.3f} {:8d} {:11.3f} {:8.3f} {:9.3f} {:9d} {:9d} {:6.1f}x {:6d} {}".format(
190
191
  relative_pkt_sent_time_sec,
191
192
  relative_pkt_received_time_sec,
192
- sender_pps,
193
- sender_interval_rate_mbps,
194
- receiver_pps,
195
- receiver_interval_rate_mbps,
193
+ r_record["sender_pps"],
194
+ r_record["sender_interval_rate_mbps"],
195
+ r_record["receiver_pps"],
196
+ r_record["receiver_interval_rate_mbps"],
196
197
  unloaded_rtt_ms,
197
- rtt_ms,
198
+ r_record["rtt_ms"],
198
199
  bdp_bytes,
199
- buffered_bytes,
200
+ r_record["buffered_bytes"],
200
201
  bloat_factor,
201
202
  dropped_this_interval,
202
203
  dropped_this_interval_percent_str
@@ -205,7 +206,7 @@ def print_output(s1):
205
206
  last_line_to_stdout_time = curr_time
206
207
 
207
208
  else:
208
- calibration.update_rtt_sec(rtt_sec)
209
+ calibration.update_rtt_sec(r_record["rtt_sec"])
209
210
 
210
211
  if curr_time > (last_line_to_stdout_time + const.STDOUT_INTERVAL_SEC):
211
212
  if print_header1:
@@ -92,6 +92,8 @@ def server_mainline(args):
92
92
 
93
93
  print("created data connection ({})".format("udp" if client_args.udp else "tcp"))
94
94
 
95
+ shared_udp_sending_rate_pps = multiprocessing.Value('d', const.UDP_DEFAULT_INITIAL_RATE)
96
+
95
97
  # run test
96
98
 
97
99
  print("test running")
@@ -127,7 +129,7 @@ def server_mainline(args):
127
129
  control_receiver_process = multiprocessing.Process(
128
130
  name = "controlreceiver",
129
131
  target = control_receiver_thread.run_recv_term_send,
130
- args = (client_args, control_receiver_stdout_queue, control_conn),
132
+ args = (client_args, control_receiver_stdout_queue, control_conn, shared_udp_sending_rate_pps),
131
133
  daemon = True)
132
134
 
133
135
  data_sender_stdout_queue = multiprocessing.Queue()
@@ -135,7 +137,7 @@ def server_mainline(args):
135
137
  data_sender_process = multiprocessing.Process(
136
138
  name = "datasender",
137
139
  target = data_sender_thread.run,
138
- args = (client_args, data_sender_stdout_queue, data_sock, None),
140
+ args = (client_args, data_sender_stdout_queue, data_sock, None, shared_udp_sending_rate_pps),
139
141
  daemon = True)
140
142
 
141
143
  # wait for start message
@@ -3,6 +3,7 @@
3
3
 
4
4
  import json
5
5
  import argparse
6
+ import socket
6
7
 
7
8
  from . import const
8
9
  from . import util
@@ -24,6 +25,9 @@ class TcpControlConnectionClass:
24
25
 
25
26
  control_sock.settimeout(const.SOCKET_TIMEOUT_SEC)
26
27
 
28
+ # set TCP_NODELAY because the control messages back to the
29
+ # sender from the data receiver are part of the RTT measurement
30
+ control_sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
27
31
 
28
32
  def set_args(self, args):
29
33
  self.args = args
@@ -70,7 +74,7 @@ class TcpControlConnectionClass:
70
74
  raise PeerDisconnectedException()
71
75
 
72
76
  if self.args and self.args.verbosity == 3:
73
- print("control connection: recv: {}".format("*" + recv_bytes.decode() + "*"))
77
+ print("control connection: recv: {}".format(recv_bytes.decode()))
74
78
 
75
79
  return recv_bytes
76
80
 
@@ -0,0 +1,55 @@
1
+
2
+ import numpy
3
+
4
+ from . import const
5
+ from . import util
6
+
7
+ # this is a simple congestion control algorithm for the udp test
8
+ class UdpRateManagerClass:
9
+
10
+ # args are client args
11
+ def __init__(self, args, shared_udp_sending_rate_pps):
12
+ self.args = args
13
+ self.shared_udp_sending_rate_pps = shared_udp_sending_rate_pps
14
+ self.receiver_pps_list = []
15
+ self.last_new_rate = 0
16
+
17
+ # control receiver calls this with interval pps (every 0.1 seconds)
18
+ def update(self, new_str):
19
+ r_record = util.parse_r_record(self.args, new_str)
20
+
21
+ # gut checks to avoid updating based on bogus input
22
+ if r_record["r_sender_total_pkts_sent"] < 100:
23
+ return
24
+ if r_record["r_sender_interval_pkts_sent"] < 10:
25
+ return
26
+ if r_record["receiver_pps"] < 100:
27
+ return
28
+
29
+ self.receiver_pps_list.append(r_record["receiver_pps"])
30
+ if len(self.receiver_pps_list) > 10:
31
+ self.receiver_pps_list = self.receiver_pps_list[1:]
32
+
33
+ receiver_pps_p90 = numpy.percentile(self.receiver_pps_list, [90])
34
+
35
+ new_rate = receiver_pps_p90 * 1.2
36
+
37
+ if new_rate < const.UDP_MIN_RATE:
38
+ new_rate = const.UDP_MIN_RATE
39
+ # cap it to something big
40
+ if new_rate > const.UDP_MAX_RATE:
41
+ new_rate = const.UDP_MAX_RATE
42
+
43
+ if abs(new_rate - self.last_new_rate) < 2:
44
+ # do not bother with tiny changes
45
+ return
46
+
47
+ if self.args.verbosity == 3:
48
+ print("UdpRateManager: update: receiver pps {} old rate {} new rate {}".format(
49
+ r_record["receiver_pps"],
50
+ self.shared_udp_sending_rate_pps.value,
51
+ new_rate)
52
+ )
53
+
54
+ self.shared_udp_sending_rate_pps.value = new_rate
55
+ self.last_new_rate = new_rate
@@ -0,0 +1,196 @@
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 socket
5
+ import ipaddress
6
+
7
+ from . import const
8
+ from .exceptions import PeerDisconnectedException
9
+
10
+
11
+ def validate_args(args):
12
+ if args.server and args.client:
13
+ raise Exception("ERROR: cannot be both client and server")
14
+
15
+ if args.client:
16
+ # this is server IP address
17
+ # allow any exception here to propogate up
18
+ ipaddress.ip_address(args.client)
19
+
20
+ if args.port > 65535:
21
+ raise Exception("ERROR: invalid server port {}".format(args.port))
22
+
23
+ if args.time <= 0:
24
+ raise Exception("ERROR: argument time must be positive")
25
+
26
+ if args.time < 10:
27
+ raise Exception("ERROR: time must be at least 10 seconds")
28
+
29
+
30
+ def convert_bandwidth_str_to_int(arg_str):
31
+ # input string:
32
+ # n[kmgKMG] | n[kmgKMG]pps
33
+
34
+ idx = arg_str.find("pps")
35
+ if idx > -1:
36
+ # found, so pps
37
+ is_pps = True
38
+ human_num_str = arg_str[:idx]
39
+ else:
40
+ # bps
41
+ is_pps = False
42
+ human_num_str = arg_str
43
+
44
+ last_char = human_num_str[-1:]
45
+
46
+ if last_char in [ "k", "K" ]:
47
+ ret_val = int(human_num_str[0:-1]) * (10 ** 3)
48
+
49
+ elif last_char in [ "m", "M" ]:
50
+ ret_val = int(human_num_str[0:-1]) * (10 ** 6)
51
+
52
+ elif last_char in [ "g", "G" ]:
53
+ ret_val = int(human_num_str[0:-1]) * (10 ** 9)
54
+
55
+ else:
56
+ ret_val = int(human_num_str)
57
+
58
+ return is_pps, ret_val
59
+
60
+
61
+ def convert_bandwidth_spec_to_batch_info(args, bandwidth_is_pps, bandwidth_val_int):
62
+
63
+ if args.udp:
64
+ if bandwidth_is_pps:
65
+ packets_per_sec = bandwidth_val_int
66
+ sends_per_sec = packets_per_sec
67
+ else:
68
+ # udp/bps
69
+ packets_per_sec = (bandwidth_val_int / 8.0) / len(const.PAYLOAD_1K)
70
+ sends_per_sec = packets_per_sec
71
+
72
+ batch_size = const.RATE_LIMITED_BATCH_SIZE_PKTS_UDP_PKTS
73
+
74
+ else:
75
+ # tcp
76
+ if bandwidth_is_pps:
77
+ packets_per_sec = bandwidth_val_int
78
+ sends_per_sec = bandwidth_val_int / ( len(const.PAYLOAD_4K) / 1400.0 )
79
+ else:
80
+ packets_per_sec = (bandwidth_val_int / 8.0) / 1400.0
81
+ sends_per_sec = packets_per_sec / ( len(const.PAYLOAD_4K) / 1400.0 )
82
+
83
+ batch_size = const.RATE_LIMITED_BATCH_SIZE_PKTS_TCP_PKTS
84
+
85
+ batches_per_sec = sends_per_sec / batch_size
86
+
87
+ if batches_per_sec < 1:
88
+ batches_per_sec = 1
89
+ batch_size = 1
90
+
91
+ delay_between_batches = 1.0 / batches_per_sec
92
+
93
+ return batch_size, delay_between_batches
94
+
95
+
96
+ def done_with_socket(mysock):
97
+ try:
98
+ mysock.shutdown(socket.SHUT_RDWR)
99
+ except:
100
+ pass
101
+
102
+ try:
103
+ mysock.close()
104
+ except:
105
+ pass
106
+
107
+
108
+ def threads_are_running(thread_list):
109
+ any_running = False
110
+
111
+ for t in thread_list:
112
+ if t.is_alive():
113
+ any_running = True
114
+
115
+ return any_running
116
+
117
+
118
+ def recv_exact_num_bytes_tcp(client_sock, total_num_bytes_to_read):
119
+ payload_bytes = bytearray()
120
+ num_bytes_read = 0
121
+
122
+ while num_bytes_read < total_num_bytes_to_read:
123
+
124
+ num_bytes_remaining = total_num_bytes_to_read - num_bytes_read
125
+
126
+ # blocking
127
+ recv_bytes = client_sock.recv(num_bytes_remaining)
128
+
129
+ num_bytes_received = len(recv_bytes)
130
+
131
+ if num_bytes_received == 0:
132
+ raise PeerDisconnectedException()
133
+
134
+ num_bytes_read += num_bytes_received
135
+
136
+ payload_bytes.extend(recv_bytes)
137
+
138
+ return payload_bytes
139
+
140
+
141
+ def parse_r_record(args, s1):
142
+ r_record = {}
143
+
144
+ swords = s1.split()
145
+
146
+ # literal "a"
147
+ r_record["r_record_type"] = swords[1]
148
+ r_record["r_pkt_sent_time_sec"] = float(swords[2])
149
+ r_record["r_sender_interval_duration_sec"] = float(swords[3])
150
+ r_record["r_sender_interval_pkts_sent"] = int(swords[4]) # valid for udp only
151
+ r_record["r_sender_interval_bytes_sent"] = int(swords[5])
152
+ r_record["r_sender_total_pkts_sent"] = int(swords[6]) # valid for udp only
153
+ # literal "b"
154
+ r_record["r_receiver_interval_duration_sec"] = float(swords[8])
155
+ r_record["r_receiver_interval_pkts_received"] = int(swords[9]) # valid for udp only
156
+ r_record["r_receiver_interval_bytes_received"] = int(swords[10])
157
+ r_record["r_receiver_total_pkts_received"] = int(swords[11]) # valid for udp only
158
+ # literal "c"
159
+ r_record["r_pkt_received_time_sec"] = float(swords[13])
160
+ # literal "d"
161
+
162
+ r_record["rtt_sec"] = r_record["r_pkt_received_time_sec"] - r_record["r_pkt_sent_time_sec"]
163
+ r_record["rtt_ms"] = r_record["rtt_sec"] * 1000
164
+
165
+ try:
166
+ # first record received has zeros
167
+ sender_interval_rate_bps = (r_record["r_sender_interval_bytes_sent"] * 8.0) / r_record["r_sender_interval_duration_sec"]
168
+ except ZeroDivisionError:
169
+ sender_interval_rate_bps = 0
170
+
171
+ r_record["sender_interval_rate_mbps"] = sender_interval_rate_bps / (10 ** 6)
172
+
173
+ r_record["receiver_interval_rate_bytes_per_sec"] = r_record["r_receiver_interval_bytes_received"] / r_record["r_receiver_interval_duration_sec"]
174
+
175
+ receiver_interval_rate_bps = r_record["receiver_interval_rate_bytes_per_sec"] * 8
176
+ r_record["receiver_interval_rate_mbps"] = receiver_interval_rate_bps / (10 ** 6)
177
+
178
+ r_record["buffered_bytes"] = int( r_record["receiver_interval_rate_bytes_per_sec"] * r_record["rtt_sec"] )
179
+
180
+ if args.udp:
181
+ try:
182
+ # first record received has zeroes
183
+ r_record["sender_pps"] = int(r_record["r_sender_interval_pkts_sent"] / r_record["r_sender_interval_duration_sec"])
184
+ except ZeroDivisionError:
185
+ r_record["sender_pps"] = 0
186
+
187
+ r_record["receiver_pps"] = int(r_record["r_receiver_interval_pkts_received"] / r_record["r_receiver_interval_duration_sec"])
188
+ r_record["total_dropped"] = r_record["r_sender_total_pkts_sent"] - r_record["r_receiver_total_pkts_received"]
189
+
190
+ assert r_record["total_dropped"] >= 0
191
+ else:
192
+ r_record["sender_pps"] = -1
193
+ r_record["receiver_pps"] = -1
194
+ r_record["total_dropped"] = -1
195
+
196
+ return r_record
@@ -0,0 +1,52 @@
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 -c $SERVER_ADDR -t $DURATION $EXTRAARGS
16
+
17
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -R
18
+
19
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -J /tmp/foo578439759837.out
20
+ rm /tmp/foo578439759837.out
21
+
22
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -R -J /tmp/foo578439759837.out
23
+ rm /tmp/foo578439759837.out
24
+
25
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -u
26
+
27
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -u -R
28
+
29
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M
30
+
31
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -R
32
+
33
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps
34
+
35
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -R
36
+
37
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps
38
+
39
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -R
40
+
41
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -u
42
+
43
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -u -R
44
+
45
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -u
46
+
47
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -u -R
48
+
49
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -u
50
+
51
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -u -R
52
+
bbperf-0.0.1/.gitignore DELETED
@@ -1 +0,0 @@
1
- dist
@@ -1,41 +0,0 @@
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
@@ -1,105 +0,0 @@
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 socket
5
- import ipaddress
6
-
7
- from .exceptions import PeerDisconnectedException
8
-
9
-
10
- def validate_args(args):
11
- if args.server and args.client:
12
- raise Exception("ERROR: cannot be both client and server")
13
-
14
- if args.client:
15
- # this is server IP address
16
- # allow any exception here to propogate up
17
- ipaddress.ip_address(args.client)
18
-
19
- if args.port > 65535:
20
- raise Exception("ERROR: invalid server port {}".format(args.port))
21
-
22
- if args.time <= 0:
23
- raise Exception("ERROR: argument time must be positive")
24
-
25
- if args.time < 10:
26
- raise Exception("ERROR: time must be at least 10 seconds")
27
-
28
- if args.udp and not args.bandwidth:
29
- raise Exception("ERROR: bandwidth option must be specified for UDP mode")
30
-
31
-
32
- def convert_bandwidth_str_to_int(arg_str):
33
- # input string:
34
- # n[kmgKMG] | n[kmgKMG]pps
35
-
36
- idx = arg_str.find("pps")
37
- if idx > -1:
38
- # found, so pps
39
- is_pps = True
40
- human_num_str = arg_str[:idx]
41
- else:
42
- # bps
43
- is_pps = False
44
- human_num_str = arg_str
45
-
46
- last_char = human_num_str[-1:]
47
-
48
- if last_char in [ "k", "K" ]:
49
- ret_val = int(human_num_str[0:-1]) * (10 ** 3)
50
-
51
- elif last_char in [ "m", "M" ]:
52
- ret_val = int(human_num_str[0:-1]) * (10 ** 6)
53
-
54
- elif last_char in [ "g", "G" ]:
55
- ret_val = int(human_num_str[0:-1]) * (10 ** 9)
56
-
57
- else:
58
- ret_val = int(human_num_str)
59
-
60
- return is_pps, ret_val
61
-
62
-
63
- def done_with_socket(mysock):
64
- try:
65
- mysock.shutdown(socket.SHUT_RDWR)
66
- except:
67
- pass
68
-
69
- try:
70
- mysock.close()
71
- except:
72
- pass
73
-
74
-
75
- def threads_are_running(thread_list):
76
- any_running = False
77
-
78
- for t in thread_list:
79
- if t.is_alive():
80
- any_running = True
81
-
82
- return any_running
83
-
84
-
85
- def recv_exact_num_bytes_tcp(client_sock, total_num_bytes_to_read):
86
- payload_bytes = bytearray()
87
- num_bytes_read = 0
88
-
89
- while num_bytes_read < total_num_bytes_to_read:
90
-
91
- num_bytes_remaining = total_num_bytes_to_read - num_bytes_read
92
-
93
- # blocking
94
- recv_bytes = client_sock.recv(num_bytes_remaining)
95
-
96
- num_bytes_received = len(recv_bytes)
97
-
98
- if num_bytes_received == 0:
99
- raise PeerDisconnectedException()
100
-
101
- num_bytes_read += num_bytes_received
102
-
103
- payload_bytes.extend(recv_bytes)
104
-
105
- return payload_bytes
File without changes
File without changes
File without changes
File without changes
@@ -68,8 +68,6 @@ def run(args, stdout_queue, control_conn, data_sock, peer_addr):
68
68
  except socket.timeout:
69
69
  pass
70
70
 
71
- total_recv_calls += 1
72
-
73
71
  curr_time_sec = time.time()
74
72
 
75
73
  if end_time and (curr_time_sec > end_time):
@@ -82,6 +80,8 @@ def run(args, stdout_queue, control_conn, data_sock, peer_addr):
82
80
  # recv must have timed out, skip the rest of this loop
83
81
  continue
84
82
 
83
+ total_recv_calls += 1
84
+
85
85
  if not end_time:
86
86
  # first data packet arrived, so test just started running
87
87
  end_time = curr_time_sec + args.time
File without changes
File without changes
File without changes
File without changes