bbperf 0.0.2__tar.gz → 0.0.4__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 (29) hide show
  1. {bbperf-0.0.2 → bbperf-0.0.4}/.gitignore +1 -0
  2. {bbperf-0.0.2 → bbperf-0.0.4}/DEPLOY.txt +7 -0
  3. {bbperf-0.0.2 → bbperf-0.0.4}/PKG-INFO +21 -14
  4. {bbperf-0.0.2 → bbperf-0.0.4}/README.md +19 -13
  5. {bbperf-0.0.2 → bbperf-0.0.4}/pyproject.toml +4 -1
  6. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/bbperf.py +10 -5
  7. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/client.py +6 -4
  8. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/const.py +5 -0
  9. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/control_receiver_thread.py +21 -2
  10. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/data_receiver_thread.py +5 -4
  11. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/data_sender_thread.py +17 -55
  12. bbperf-0.0.4/src/bbperf/json_output_class.py +98 -0
  13. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/output.py +49 -56
  14. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/server.py +4 -2
  15. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/tcp_control_connection_class.py +3 -3
  16. bbperf-0.0.4/src/bbperf/udp_rate_manager_class.py +55 -0
  17. bbperf-0.0.4/src/bbperf/util.py +148 -0
  18. bbperf-0.0.4/tests/run_test.sh +25 -0
  19. bbperf-0.0.2/src/bbperf/util.py +0 -105
  20. bbperf-0.0.2/tests/run_test.sh +0 -42
  21. {bbperf-0.0.2 → bbperf-0.0.4}/LICENSE +0 -0
  22. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/.gitignore +0 -0
  23. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/__init__.py +0 -0
  24. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/calibration.py +0 -0
  25. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/data_udp_ping_sender_thread.py +0 -0
  26. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/exceptions.py +0 -0
  27. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/graph.py +0 -0
  28. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/tcp-graph.gp +0 -0
  29. {bbperf-0.0.2 → bbperf-0.0.4}/src/bbperf/udp-graph.gp +0 -0
@@ -1,2 +1,3 @@
1
1
  dist
2
2
  .venv
3
+ .vscode
@@ -12,6 +12,13 @@ Create tar.gz and whl files in dist directory:
12
12
  cd /path/to/bbperf/git/repo/dir <-- the directory with the pyproject.toml file
13
13
 
14
14
  vim pyproject.toml <-- increment the version number
15
+ git add pyproject.toml
16
+ git commit -m 'version 0.0.2'
17
+
18
+ git tag -a v0.0.2 -m 'version 0.0.2'
19
+
20
+ git push origin
21
+ git push origin --tags
15
22
 
16
23
  python3 -m build
17
24
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bbperf
3
- Version: 0.0.2
3
+ Version: 0.0.4
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>
@@ -25,11 +26,6 @@ Description-Content-Type: text/markdown
25
26
  * Usage of buffers between the endpoints
26
27
  * Bufferbloat (when the usage of buffers is excessive)
27
28
 
28
- For UDP, it also measures:
29
-
30
- * Packet rates
31
- * Packet loss rates
32
-
33
29
  Features that distinguish this tool from existing tools include:
34
30
 
35
31
  * Latency, both unloaded and loaded, is measured by the same flow that is under test.
@@ -42,6 +38,8 @@ Features that distinguish this tool from existing tools include:
42
38
 
43
39
  * Automatic generation of graphs
44
40
 
41
+ * The UDP option will automatically adjust the sending rate to just above the goodput rate so that any bufferbloat issues are measured.
42
+
45
43
  ### Usage
46
44
 
47
45
  To run a test:
@@ -64,26 +62,26 @@ The direction of data flow is from the client to the server. That is reversed w
64
62
 
65
63
  ```
66
64
  $ bbperf.py --help
67
- usage: bbperf.py [-h] [-v] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-b BANDWIDTH] [-g] [-k]
65
+ usage: bbperf.py [-h] [-v] [-q] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-g] [-k] [-J JSON_FILE]
68
66
 
69
67
  bbperf: end to end performance and bufferbloat measurement tool
70
68
 
71
69
  options:
72
70
  -h, --help show this help message and exit
73
- -v, --verbosity increase output verbosity
71
+ -v, --verbosity increase output verbosity (can be repeated)
72
+ -q, --quiet decrease output verbosity (can be repeated)
74
73
  -s, --server run in server mode
75
- -c SERVER_IP, --client SERVER_IP
74
+ -c, --client SERVER_IP
76
75
  run in client mode
77
- -p SERVER_PORT, --port SERVER_PORT
76
+ -p, --port SERVER_PORT
78
77
  server port (default: 5301)
79
78
  -R, --reverse data flow in download direction (server to client)
80
- -t SECONDS, --time SECONDS
81
- duration of run in seconds
79
+ -t, --time SECONDS duration of run in seconds
82
80
  -u, --udp run in UDP mode (default: TCP mode)
83
- -b BANDWIDTH, --bandwidth BANDWIDTH
84
- n[kmgKMG] | n[kmgKMG]pps
85
81
  -g, --graph generate graph (requires gnuplot)
86
82
  -k, --keep keep data file
83
+ -J, --json-file JSON_FILE
84
+ JSON output file
87
85
  ```
88
86
 
89
87
  Output from `bbperf` includes the following information:
@@ -103,6 +101,15 @@ Output from `bbperf` includes the following information:
103
101
  drop% percentage of packets dropped (UDP only)
104
102
  ```
105
103
 
104
+ Output to standard out is controlled via the `--verbosity` and `--quiet` options as follows:
105
+ ```
106
+ -qq nothing to stdout except errors
107
+ -q run summary in json format
108
+ (neither option) progress update once per second plus run summary in json format (default)
109
+ -v progress update once per 0.1 seconds, additional output, and run summary in json format
110
+ -vv debugging info useful for developers only
111
+ ```
112
+
106
113
  ### Installation
107
114
 
108
115
  `bbperf` is available via PyPI repository (pypi.org) and can be installed using pip.
@@ -8,11 +8,6 @@
8
8
  * Usage of buffers between the endpoints
9
9
  * Bufferbloat (when the usage of buffers is excessive)
10
10
 
11
- For UDP, it also measures:
12
-
13
- * Packet rates
14
- * Packet loss rates
15
-
16
11
  Features that distinguish this tool from existing tools include:
17
12
 
18
13
  * Latency, both unloaded and loaded, is measured by the same flow that is under test.
@@ -25,6 +20,8 @@ Features that distinguish this tool from existing tools include:
25
20
 
26
21
  * Automatic generation of graphs
27
22
 
23
+ * The UDP option will automatically adjust the sending rate to just above the goodput rate so that any bufferbloat issues are measured.
24
+
28
25
  ### Usage
29
26
 
30
27
  To run a test:
@@ -47,26 +44,26 @@ The direction of data flow is from the client to the server. That is reversed w
47
44
 
48
45
  ```
49
46
  $ bbperf.py --help
50
- usage: bbperf.py [-h] [-v] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-b BANDWIDTH] [-g] [-k]
47
+ usage: bbperf.py [-h] [-v] [-q] [-s] [-c SERVER_IP] [-p SERVER_PORT] [-R] [-t SECONDS] [-u] [-g] [-k] [-J JSON_FILE]
51
48
 
52
49
  bbperf: end to end performance and bufferbloat measurement tool
53
50
 
54
51
  options:
55
52
  -h, --help show this help message and exit
56
- -v, --verbosity increase output verbosity
53
+ -v, --verbosity increase output verbosity (can be repeated)
54
+ -q, --quiet decrease output verbosity (can be repeated)
57
55
  -s, --server run in server mode
58
- -c SERVER_IP, --client SERVER_IP
56
+ -c, --client SERVER_IP
59
57
  run in client mode
60
- -p SERVER_PORT, --port SERVER_PORT
58
+ -p, --port SERVER_PORT
61
59
  server port (default: 5301)
62
60
  -R, --reverse data flow in download direction (server to client)
63
- -t SECONDS, --time SECONDS
64
- duration of run in seconds
61
+ -t, --time SECONDS duration of run in seconds
65
62
  -u, --udp run in UDP mode (default: TCP mode)
66
- -b BANDWIDTH, --bandwidth BANDWIDTH
67
- n[kmgKMG] | n[kmgKMG]pps
68
63
  -g, --graph generate graph (requires gnuplot)
69
64
  -k, --keep keep data file
65
+ -J, --json-file JSON_FILE
66
+ JSON output file
70
67
  ```
71
68
 
72
69
  Output from `bbperf` includes the following information:
@@ -86,6 +83,15 @@ Output from `bbperf` includes the following information:
86
83
  drop% percentage of packets dropped (UDP only)
87
84
  ```
88
85
 
86
+ Output to standard out is controlled via the `--verbosity` and `--quiet` options as follows:
87
+ ```
88
+ -qq nothing to stdout except errors
89
+ -q run summary in json format
90
+ (neither option) progress update once per second plus run summary in json format (default)
91
+ -v progress update once per 0.1 seconds, additional output, and run summary in json format
92
+ -vv debugging info useful for developers only
93
+ ```
94
+
89
95
  ### Installation
90
96
 
91
97
  `bbperf` is available via PyPI repository (pypi.org) and can be installed using pip.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bbperf"
7
- version = "0.0.2"
7
+ version = "0.0.4"
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
 
@@ -17,7 +17,12 @@ def mainline():
17
17
  parser.add_argument("-v", "--verbosity",
18
18
  action="count",
19
19
  default=0,
20
- help="increase output verbosity")
20
+ help="increase output verbosity (can be repeated)")
21
+
22
+ parser.add_argument("-q", "--quiet",
23
+ action="count",
24
+ default=0,
25
+ help="decrease output verbosity (can be repeated)")
21
26
 
22
27
  parser.add_argument("-s", "--server",
23
28
  action="store_true",
@@ -51,10 +56,6 @@ def mainline():
51
56
  default=False,
52
57
  help="run in UDP mode (default: TCP mode)")
53
58
 
54
- parser.add_argument("-b", "--bandwidth",
55
- default=None,
56
- help="n[kmgKMG] | n[kmgKMG]pps")
57
-
58
59
  parser.add_argument("-g", "--graph",
59
60
  action="store_true",
60
61
  default=False,
@@ -65,6 +66,10 @@ def mainline():
65
66
  default=False,
66
67
  help="keep data file")
67
68
 
69
+ parser.add_argument("-J", "--json-file",
70
+ default=None,
71
+ help="JSON output file")
72
+
68
73
  args = parser.parse_args()
69
74
 
70
75
  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
@@ -212,11 +214,11 @@ def client_mainline(args):
212
214
  graphdatafilename = output.get_graph_data_file_name()
213
215
  rawdatafilename = output.get_raw_data_file_name()
214
216
 
215
- if args.graph:
217
+ if args.graph and not args.quiet:
216
218
  graph.create_graph(args, graphdatafilename)
217
219
  print("created graph: {}".format(graphdatafilename + ".png"))
218
220
 
219
- if args.keep:
221
+ if args.keep and not args.quiet:
220
222
  print("keeping graph data file: {}".format(graphdatafilename))
221
223
  print("keeping raw data file: {}".format(rawdatafilename))
222
224
  else:
@@ -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:
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:
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:
@@ -7,7 +7,7 @@ import socket
7
7
  from . import const
8
8
  from . import util
9
9
 
10
-
10
+ # args are client args
11
11
  def run(args, stdout_queue, control_conn, data_sock, peer_addr):
12
12
 
13
13
  if args.verbosity:
@@ -45,7 +45,8 @@ def run(args, stdout_queue, control_conn, data_sock, peer_addr):
45
45
  if peer_addr_for_udp is None:
46
46
  # first packet is received
47
47
  peer_addr_for_udp = pkt_from_addr
48
- print("peer address: {}".format(peer_addr_for_udp))
48
+ if not args.quiet:
49
+ print("peer address: {}".format(peer_addr_for_udp))
49
50
  else:
50
51
  raise Exception("ERROR: datagram from wrong peer address")
51
52
 
@@ -68,8 +69,6 @@ def run(args, stdout_queue, control_conn, data_sock, peer_addr):
68
69
  except socket.timeout:
69
70
  pass
70
71
 
71
- total_recv_calls += 1
72
-
73
72
  curr_time_sec = time.time()
74
73
 
75
74
  if end_time and (curr_time_sec > end_time):
@@ -82,6 +81,8 @@ def run(args, stdout_queue, control_conn, data_sock, peer_addr):
82
81
  # recv must have timed out, skip the rest of this loop
83
82
  continue
84
83
 
84
+ total_recv_calls += 1
85
+
85
86
  if not end_time:
86
87
  # first data packet arrived, so test just started running
87
88
  end_time = curr_time_sec + args.time
@@ -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
 
@@ -29,50 +29,10 @@ def run(args, stdout_queue, data_sock, peer_addr):
29
29
  stdout_queue.put("data sender: peer address: {}".format(peer_addr_for_udp))
30
30
  break
31
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
- ))
32
+ # udp autorate
33
+ if args.udp:
34
+ udp_pps = shared_udp_sending_rate_pps.value
35
+ batch_size, delay_between_batches = util.convert_udp_pps_to_batch_info(udp_pps)
76
36
 
77
37
  # start sending
78
38
 
@@ -172,11 +132,21 @@ def run(args, stdout_queue, data_sock, peer_addr):
172
132
  interval_send_count = accum_send_count
173
133
  interval_bytes_sent = accum_bytes_sent
174
134
 
135
+ if args.verbosity > 1:
136
+ print("data_sender: a {} {} {} {} {} {} b".format(
137
+ record_type, curr_time_sec, interval_time_sec, interval_send_count, interval_bytes_sent, total_send_counter)
138
+ )
139
+
175
140
  interval_start_time = curr_time_sec
176
141
  interval_end_time = interval_start_time + const.SAMPLE_INTERVAL_SEC
177
142
  accum_send_count = 0
178
143
  accum_bytes_sent = 0
179
144
 
145
+ # update udp autorate
146
+ if args.udp:
147
+ udp_pps = shared_udp_sending_rate_pps.value
148
+ batch_size, delay_between_batches = util.convert_udp_pps_to_batch_info(udp_pps)
149
+
180
150
  # send very slowly at first to establish unloaded latency
181
151
  if not is_calibrated:
182
152
  time.sleep(0.2)
@@ -189,21 +159,13 @@ def run(args, stdout_queue, data_sock, peer_addr):
189
159
  if curr_time_sec > end_time:
190
160
  break
191
161
 
192
- if args.bandwidth:
162
+ # pause between udp batches if necessary
163
+ if args.udp:
193
164
  current_batch_counter += 1
194
165
  if current_batch_counter >= batch_size:
195
166
  this_delay = delay_between_batches - (curr_time_sec - current_batch_start_time)
196
167
  if this_delay > 0:
197
168
  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
169
  current_batch_start_time += delay_between_batches
208
170
  current_batch_counter = 0
209
171
 
@@ -0,0 +1,98 @@
1
+
2
+ import json
3
+ import numpy
4
+
5
+ class JsonOutputClass:
6
+
7
+ def __init__(self, args):
8
+ self.args = args
9
+ self.output_dict = {}
10
+ self.output_dict["entries"] = []
11
+ self.unloaded_rtt_ms = None
12
+
13
+ if self.args.json_file:
14
+ self.json_output_file = open(self.args.json_file, 'w')
15
+
16
+ def set_unloaded_rtt_ms(self, rtt_ms):
17
+ self.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
+
31
+ sender_throughput_rate_mbps = entry["sender_throughput_rate_mbps"]
32
+ receiver_throughput_rate_mbps = entry["receiver_throughput_rate_mbps"]
33
+ throughput_rate_ratio = abs(sender_throughput_rate_mbps - receiver_throughput_rate_mbps) / receiver_throughput_rate_mbps
34
+
35
+ # only add entries that capture then flow when it is at max bloat potential
36
+ if ( (self.args.udp and entry["pkt_loss_percent"] > 0) or
37
+ ((not self.args.udp) and throughput_rate_ratio < 0.03) and (receiver_throughput_rate_mbps > 1.0) ):
38
+
39
+ loaded_rtt_ms_list.append(entry["loaded_rtt_ms"])
40
+ receiver_throughput_rate_mbps_list.append(entry["receiver_throughput_rate_mbps"])
41
+ excess_buffered_bytes_list.append(entry["excess_buffered_bytes"])
42
+ receiver_pps_list.append(entry["receiver_pps"])
43
+ pkt_loss_percent_list.append(entry["pkt_loss_percent"])
44
+
45
+ num_samples = len(loaded_rtt_ms_list)
46
+ if num_samples < 10:
47
+ if not self.args.quiet:
48
+ print("WARNING: not enough valid samples for summary statistics: {} samples. Increase the duration of the run using the '-t' option.".format(num_samples))
49
+ return
50
+
51
+ summary_dict = self.output_dict["summary"] = {}
52
+
53
+ summary_dict["num_samples"] = num_samples
54
+
55
+ summary_dict["unloaded_rtt_ms"] = self.unloaded_rtt_ms
56
+
57
+ p50, p90, p99 = numpy.percentile(loaded_rtt_ms_list, [50, 90, 99])
58
+ summary_dict["loaded_rtt_ms"] = {}
59
+ summary_dict["loaded_rtt_ms"]["p50"] = p50
60
+ summary_dict["loaded_rtt_ms"]["p90"] = p90
61
+ summary_dict["loaded_rtt_ms"]["p99"] = p99
62
+
63
+ p50, p90, p99 = numpy.percentile(receiver_throughput_rate_mbps_list, [50, 90, 99])
64
+ summary_dict["receiver_throughput_rate_mbps"] = {}
65
+ summary_dict["receiver_throughput_rate_mbps"]["p50"] = p50
66
+ summary_dict["receiver_throughput_rate_mbps"]["p90"] = p90
67
+ summary_dict["receiver_throughput_rate_mbps"]["p99"] = p99
68
+
69
+ p50, p90, p99 = numpy.percentile(excess_buffered_bytes_list, [50, 90, 99])
70
+ summary_dict["excess_buffered_bytes"] = {}
71
+ summary_dict["excess_buffered_bytes"]["p50"] = p50
72
+ summary_dict["excess_buffered_bytes"]["p90"] = p90
73
+ summary_dict["excess_buffered_bytes"]["p99"] = p99
74
+
75
+ p50, p90, p99 = numpy.percentile(receiver_pps_list, [50, 90, 99])
76
+ summary_dict["receiver_pps"] = {}
77
+ summary_dict["receiver_pps"]["p50"] = p50
78
+ summary_dict["receiver_pps"]["p90"] = p90
79
+ summary_dict["receiver_pps"]["p99"] = p99
80
+
81
+ p50, p90, p99 = numpy.percentile(pkt_loss_percent_list, [50, 90, 99])
82
+ summary_dict["pkt_loss_percent"] = {}
83
+ summary_dict["pkt_loss_percent"]["p50"] = p50
84
+ summary_dict["pkt_loss_percent"]["p90"] = p90
85
+ summary_dict["pkt_loss_percent"]["p99"] = p99
86
+
87
+ def write_output(self):
88
+ self.create_aggregate_stats()
89
+
90
+ # write to stdout
91
+ if (self.args.quiet < 2) and ("summary" in self.output_dict):
92
+ str_out = json.dumps(self.output_dict["summary"], indent=4)
93
+ print(str_out)
94
+
95
+ # write to file if requested
96
+ if self.args.json_file:
97
+ json.dump(self.output_dict, self.json_output_file, indent=4)
98
+ 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,8 @@ 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
+ json_output = JsonOutputClass(args)
47
+
42
48
 
43
49
  def get_graph_data_file_name():
44
50
  return tmpfile1.name
@@ -50,6 +56,8 @@ def term():
50
56
  tmpfile1.close()
51
57
  tmpfile2.close()
52
58
 
59
+ json_output.write_output()
60
+
53
61
 
54
62
  def delete_data_files():
55
63
  if args.verbosity:
@@ -85,69 +93,41 @@ def print_output(s1):
85
93
 
86
94
  write_raw_data_to_file(s1)
87
95
 
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
96
  curr_time = time.time()
103
- rtt_sec = r_pkt_received_time_sec - r_pkt_sent_time_sec
97
+
98
+ r_record = util.parse_r_record(args, s1)
104
99
 
105
100
  if relative_start_time_sec is None:
106
101
  # first incoming result has arrived
107
- relative_start_time_sec = r_pkt_sent_time_sec
102
+ relative_start_time_sec = r_record["r_pkt_sent_time_sec"]
108
103
  relative_pkt_sent_time_sec = 0
109
104
  relative_pkt_received_time_sec = 0
110
105
  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
106
+ relative_pkt_sent_time_sec = r_record["r_pkt_sent_time_sec"] - relative_start_time_sec
107
+ relative_pkt_received_time_sec = r_record["r_pkt_received_time_sec"] - relative_start_time_sec
124
108
 
109
+ if r_record["r_record_type"] == "run":
125
110
  unloaded_rtt_sec = calibration.get_unloaded_latency_rtt_sec()
126
111
  unloaded_rtt_ms = unloaded_rtt_sec * 1000
127
112
 
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 )
113
+ json_output.set_unloaded_rtt_ms(unloaded_rtt_ms)
114
+
115
+ bdp_bytes = int( r_record["receiver_interval_rate_bytes_per_sec"] * unloaded_rtt_sec )
130
116
 
131
117
  if bdp_bytes > 0:
132
- bloat_factor = float(buffered_bytes) / bdp_bytes
118
+ bloat_factor = float(r_record["buffered_bytes"]) / bdp_bytes
133
119
  else:
134
120
  bloat_factor = 0
135
121
 
136
122
  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
123
+ dropped_this_interval = r_record["total_dropped"] - total_dropped_as_of_last_interval
142
124
  if dropped_this_interval < 0:
143
125
  dropped_this_interval = 0
144
- dropped_this_interval_percent = (dropped_this_interval * 100.0) / r_sender_interval_pkts_sent
126
+ dropped_this_interval_percent = (dropped_this_interval * 100.0) / r_record["r_sender_interval_pkts_sent"]
145
127
  # remember this for next loop:
146
- total_dropped_as_of_last_interval = total_dropped
128
+ total_dropped_as_of_last_interval = r_record["total_dropped"]
147
129
  else:
148
130
  # tcp
149
- sender_pps = -1
150
- receiver_pps = -1
151
131
  dropped_this_interval = -1
152
132
  dropped_this_interval_percent = -1
153
133
 
@@ -160,23 +140,36 @@ def print_output(s1):
160
140
  lineout = "{} {} {} {} {} {} {} {} {} {} {} {} {}".format(
161
141
  relative_pkt_sent_time_sec,
162
142
  relative_pkt_received_time_sec,
163
- sender_pps,
164
- sender_interval_rate_mbps,
165
- receiver_pps,
166
- receiver_interval_rate_mbps,
143
+ r_record["sender_pps"],
144
+ r_record["sender_interval_rate_mbps"],
145
+ r_record["receiver_pps"],
146
+ r_record["receiver_interval_rate_mbps"],
167
147
  unloaded_rtt_ms,
168
- rtt_ms,
148
+ r_record["rtt_ms"],
169
149
  bdp_bytes,
170
- buffered_bytes,
150
+ r_record["buffered_bytes"],
171
151
  bloat_factor,
172
152
  dropped_this_interval,
173
153
  dropped_this_interval_percent
174
154
  )
155
+
175
156
  write_graph_data_to_file(lineout)
176
157
 
158
+ # add to JSON output
159
+ new_entry = {
160
+ "sent_time_sec": r_record["r_pkt_sent_time_sec"],
161
+ "loaded_rtt_ms": r_record["rtt_ms"],
162
+ "sender_throughput_rate_mbps": r_record["sender_interval_rate_mbps"],
163
+ "receiver_throughput_rate_mbps": r_record["receiver_interval_rate_mbps"],
164
+ "excess_buffered_bytes": (r_record["buffered_bytes"] - bdp_bytes),
165
+ "receiver_pps": r_record["receiver_pps"],
166
+ "pkt_loss_percent": dropped_this_interval_percent
167
+ }
168
+ json_output.add_entry(new_entry)
169
+
177
170
  # write to stdout at the rate of one line per second
178
171
  # 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:
172
+ if ((curr_time > (last_line_to_stdout_time + const.STDOUT_INTERVAL_SEC)) and not args.quiet) or args.verbosity:
180
173
  if print_header2:
181
174
  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
175
  print_header2 = False
@@ -189,14 +182,14 @@ def print_output(s1):
189
182
  print("{:11.6f} {:11.6f} {:8d} {:11.3f} {:8d} {:11.3f} {:8.3f} {:9.3f} {:9d} {:9d} {:6.1f}x {:6d} {}".format(
190
183
  relative_pkt_sent_time_sec,
191
184
  relative_pkt_received_time_sec,
192
- sender_pps,
193
- sender_interval_rate_mbps,
194
- receiver_pps,
195
- receiver_interval_rate_mbps,
185
+ r_record["sender_pps"],
186
+ r_record["sender_interval_rate_mbps"],
187
+ r_record["receiver_pps"],
188
+ r_record["receiver_interval_rate_mbps"],
196
189
  unloaded_rtt_ms,
197
- rtt_ms,
190
+ r_record["rtt_ms"],
198
191
  bdp_bytes,
199
- buffered_bytes,
192
+ r_record["buffered_bytes"],
200
193
  bloat_factor,
201
194
  dropped_this_interval,
202
195
  dropped_this_interval_percent_str
@@ -205,9 +198,9 @@ def print_output(s1):
205
198
  last_line_to_stdout_time = curr_time
206
199
 
207
200
  else:
208
- calibration.update_rtt_sec(rtt_sec)
201
+ calibration.update_rtt_sec(r_record["rtt_sec"])
209
202
 
210
- if curr_time > (last_line_to_stdout_time + const.STDOUT_INTERVAL_SEC):
203
+ if ((curr_time > (last_line_to_stdout_time + const.STDOUT_INTERVAL_SEC)) and not args.quiet) or args.verbosity:
211
204
  if print_header1:
212
205
  print("calibrating")
213
206
  print(" sent_time recv_time rtt_ms")
@@ -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
@@ -45,7 +45,7 @@ class TcpControlConnectionClass:
45
45
  num_bytes_sent
46
46
  ))
47
47
 
48
- if self.args and self.args.verbosity == 3:
48
+ if self.args and self.args.verbosity > 1:
49
49
  print("control connection: send: {}".format(payload_bytes.decode()))
50
50
 
51
51
 
@@ -73,8 +73,8 @@ class TcpControlConnectionClass:
73
73
  if len(recv_bytes) == 0:
74
74
  raise PeerDisconnectedException()
75
75
 
76
- if self.args and self.args.verbosity == 3:
77
- print("control connection: recv: {}".format("*" + recv_bytes.decode() + "*"))
76
+ if self.args and self.args.verbosity > 1:
77
+ print("control connection: recv: {}".format(recv_bytes.decode()))
78
78
 
79
79
  return recv_bytes
80
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 > 1:
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,148 @@
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
+ if args.verbosity and args.quiet:
30
+ raise Exception("ERROR: cannot specify both verbosity and quiet")
31
+
32
+
33
+ def convert_udp_pps_to_batch_info(packets_per_sec):
34
+
35
+ batch_size = const.RATE_LIMITED_BATCH_SIZE_PKTS_UDP_PKTS
36
+
37
+ batches_per_sec = packets_per_sec / batch_size
38
+
39
+ if batches_per_sec < 1:
40
+ batches_per_sec = 1
41
+ batch_size = 1
42
+
43
+ delay_between_batches = 1.0 / batches_per_sec
44
+
45
+ return batch_size, delay_between_batches
46
+
47
+
48
+ def done_with_socket(mysock):
49
+ try:
50
+ mysock.shutdown(socket.SHUT_RDWR)
51
+ except:
52
+ pass
53
+
54
+ try:
55
+ mysock.close()
56
+ except:
57
+ pass
58
+
59
+
60
+ def threads_are_running(thread_list):
61
+ any_running = False
62
+
63
+ for t in thread_list:
64
+ if t.is_alive():
65
+ any_running = True
66
+
67
+ return any_running
68
+
69
+
70
+ def recv_exact_num_bytes_tcp(client_sock, total_num_bytes_to_read):
71
+ payload_bytes = bytearray()
72
+ num_bytes_read = 0
73
+
74
+ while num_bytes_read < total_num_bytes_to_read:
75
+
76
+ num_bytes_remaining = total_num_bytes_to_read - num_bytes_read
77
+
78
+ # blocking
79
+ recv_bytes = client_sock.recv(num_bytes_remaining)
80
+
81
+ num_bytes_received = len(recv_bytes)
82
+
83
+ if num_bytes_received == 0:
84
+ raise PeerDisconnectedException()
85
+
86
+ num_bytes_read += num_bytes_received
87
+
88
+ payload_bytes.extend(recv_bytes)
89
+
90
+ return payload_bytes
91
+
92
+
93
+ def parse_r_record(args, s1):
94
+ r_record = {}
95
+
96
+ swords = s1.split()
97
+
98
+ # literal "a"
99
+ r_record["r_record_type"] = swords[1]
100
+ r_record["r_pkt_sent_time_sec"] = float(swords[2])
101
+ r_record["r_sender_interval_duration_sec"] = float(swords[3])
102
+ r_record["r_sender_interval_pkts_sent"] = int(swords[4]) # valid for udp only
103
+ r_record["r_sender_interval_bytes_sent"] = int(swords[5])
104
+ r_record["r_sender_total_pkts_sent"] = int(swords[6]) # valid for udp only
105
+ # literal "b"
106
+ r_record["r_receiver_interval_duration_sec"] = float(swords[8])
107
+ r_record["r_receiver_interval_pkts_received"] = int(swords[9]) # valid for udp only
108
+ r_record["r_receiver_interval_bytes_received"] = int(swords[10])
109
+ r_record["r_receiver_total_pkts_received"] = int(swords[11]) # valid for udp only
110
+ # literal "c"
111
+ r_record["r_pkt_received_time_sec"] = float(swords[13])
112
+ # literal "d"
113
+
114
+ r_record["rtt_sec"] = r_record["r_pkt_received_time_sec"] - r_record["r_pkt_sent_time_sec"]
115
+ r_record["rtt_ms"] = r_record["rtt_sec"] * 1000
116
+
117
+ try:
118
+ # first record received has zeros
119
+ sender_interval_rate_bps = (r_record["r_sender_interval_bytes_sent"] * 8.0) / r_record["r_sender_interval_duration_sec"]
120
+ except ZeroDivisionError:
121
+ sender_interval_rate_bps = 0
122
+
123
+ r_record["sender_interval_rate_mbps"] = sender_interval_rate_bps / (10 ** 6)
124
+
125
+ r_record["receiver_interval_rate_bytes_per_sec"] = r_record["r_receiver_interval_bytes_received"] / r_record["r_receiver_interval_duration_sec"]
126
+
127
+ receiver_interval_rate_bps = r_record["receiver_interval_rate_bytes_per_sec"] * 8
128
+ r_record["receiver_interval_rate_mbps"] = receiver_interval_rate_bps / (10 ** 6)
129
+
130
+ r_record["buffered_bytes"] = int( r_record["receiver_interval_rate_bytes_per_sec"] * r_record["rtt_sec"] )
131
+
132
+ if args.udp:
133
+ try:
134
+ # first record received has zeroes
135
+ r_record["sender_pps"] = int(r_record["r_sender_interval_pkts_sent"] / r_record["r_sender_interval_duration_sec"])
136
+ except ZeroDivisionError:
137
+ r_record["sender_pps"] = 0
138
+
139
+ r_record["receiver_pps"] = int(r_record["r_receiver_interval_pkts_received"] / r_record["r_receiver_interval_duration_sec"])
140
+ r_record["total_dropped"] = r_record["r_sender_total_pkts_sent"] - r_record["r_receiver_total_pkts_received"]
141
+
142
+ assert r_record["total_dropped"] >= 0
143
+ else:
144
+ r_record["sender_pps"] = -1
145
+ r_record["receiver_pps"] = -1
146
+ r_record["total_dropped"] = -1
147
+
148
+ return r_record
@@ -0,0 +1,25 @@
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 -u -t 20
20
+
21
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -u -R -t 20
22
+
23
+ bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -J /tmp/foo578439759837.out
24
+ rm /tmp/foo578439759837.out
25
+
@@ -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
@@ -1,42 +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 -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 -b 5M
20
-
21
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -R
22
-
23
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps
24
-
25
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -R
26
-
27
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps
28
-
29
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -R
30
-
31
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -u
32
-
33
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5M -u -R
34
-
35
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -u
36
-
37
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 5Kpps -u -R
38
-
39
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -u
40
-
41
- bbperf -c $SERVER_ADDR -t $DURATION $EXTRAARGS -b 20Kpps -u -R
42
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes