diff --git a/debug.html b/debug.html
index 9237350d..512de420 100644
--- a/debug.html
+++ b/debug.html
@@ -265,6 +265,7 @@ function load_next()
+
diff --git a/index.html b/index.html
index 6a53f802..5d78c035 100644
--- a/index.html
+++ b/index.html
@@ -185,6 +185,7 @@
+
diff --git a/src/browser/main.js b/src/browser/main.js
index 8cb44315..5027d435 100644
--- a/src/browser/main.js
+++ b/src/browser/main.js
@@ -1632,6 +1632,35 @@
// $("memory_dump_dmp").blur();
//};
+ $("capture_network_traffic").onclick = function()
+ {
+ this.value = "0 packets";
+
+ let capture = [];
+
+ function do_capture(direction, data)
+ {
+ capture.push({ direction, time: performance.now() / 1000, hex_dump: hex_dump(data) });
+ $("capture_network_traffic").value = capture.length + " packets";
+ }
+
+ emulator.emulator_bus.register("net0-receive", do_capture.bind(this, "I"));
+ emulator.add_listener("net0-send", do_capture.bind(this, "O"));
+
+ this.onclick = function()
+ {
+ const capture_raw = capture.map(({ direction, time, hex_dump }) => {
+ // https://www.wireshark.org/docs/wsug_html_chunked/ChIOImportSection.html
+ // In wireshark: file -> import from hex -> tick direction indication, timestamp %s.%f
+ return direction + " " + time.toFixed(6) + hex_dump + "\n";
+ }).join("");
+ dump_file(capture_raw, "traffic.hex");
+ capture = [];
+ this.value = "0 packets";
+ };
+ };
+
+
$("save_state").onclick = async function()
{
const result = await emulator.save_state();