# PCAP Viewer

> 在瀏覽器直接打開 .pcap 與 .pcapng：封包列表、協定解析樹、十六進位對照高亮。擷取檔全程留在你的電腦，不會上傳。

- URL: https://bytescope.dev/zh-Hant/pcap-viewer/
- Locale: zh-Hant · Also: [en](https://bytescope.dev/en/pcap-viewer.md) · [ja](https://bytescope.dev/ja/pcap-viewer.md)
- Runs: 檔案不會離開你的瀏覽器 — 全部在本機處理。
- Requires: Any modern browser (Chrome, Edge, Firefox, Safari), desktop and mobile.
- Updated: 2026-09-08

## What it does

把 `.pcap` 或 `.pcapng` 丟進來，你會拿到分析封包時真正在用的三個面板：虛擬滾動的封包列表（No. / Time / Source / Destination / Protocol / Length / Info）、選中封包的協定解析樹，以及和樹雙向連動的十六進位 / ASCII 面板。點樹上的欄位，就只有它那幾個位元組會亮；點十六進位面板裡的一個位元組，涵蓋它的最內層欄位會展開並被選起來。像 TCP 旗標、IP 分片旗標這種住在位元組內部的值，除了把所在位元組亮起來，還會把位元位置畫出來——只給你一個位元組並不算回答。

不上傳不是這個工具的賣點，是它的前提。擷取檔就是那個網路的地圖：內部定址、DNS 查詢與 TLS SNI 裡的主機名稱、憑證主體、User-Agent，遇到明文協定連帳密都在裡面。別家線上檢視器要你把這些丟到他們的伺服器。這裡是分頁自己讀檔、交給 Web Worker、在記憶體裡解析——根本沒有上傳的端點，你可以開著開發者工具驗證：打開一個擷取檔，一個網路請求都不會出現。

容器層讀得懂傳統 libpcap 的四種 magic（小端 / 大端 × 微秒 / 奈秒），也讀 pcapng 的多個介面區塊、EPB / SPB、註解與名稱解析區塊。摘要卡會列出格式、位元組序、版本、每個介面的鏈結類型與 snaplen、封包數、擷取的時間範圍，以及容器產生的每一條警告和造成它的封包編號。檔案被截斷或損壞不會直接陣亡：讀得到的封包照樣顯示，壞掉的地方以警告回報，而不是丟一頁錯誤給你。

解析範圍在鏈結層是 Ethernet、802.1Q / QinQ VLAN、Linux SLL / SLL2、raw IP 與 Null/Loopback；往上是 ARP、含選項與分片重組的 IPv4、含擴充標頭的 IPv6、ICMPv4、含 NDP 的 ICMPv6、旗標／選項／序號分析齊全的 TCP，以及 UDP；再上去是 DNS、含 chunked 與跨 segment 重組的 HTTP/1、TLS 的 record 與 handshake、明文的 HTTP/2（含 HPACK）與 QUIC。哪些東西**不會被解開**沒有藏在註腳裡，就寫在解析樹上方的誠實聲明面板。

## Limits

Does not capture live traffic from the browser and does not decrypt TLS; it parses .pcap/.pcapng files you already have.

## Machine output

Copy JSON copies an envelope `{ tool, url, generatedAt, userAgentHint, result }`. `tool` is `"pcap-viewer"`; `result` is the on-screen capture summary and packet-list columns below. The dropped file name, packet payload bytes, hex dumps, and follow-stream bodies are omitted. DNS names and TCP flags appear only as they do in the Info column.

- `format` (string | null) — `"pcap"` | `"pcapng"`. `null` = not supplied.
- `byteOrder` (string | null) — `"LE"` | `"BE"`. `null` = not supplied.
- `version` (object | null) — Container version `{ major, minor }`. `null` = not supplied.
- `packetCount` (number | null) — Packets the container declared. `null` = not supplied.
- `byteLength` (number | null) — Capture size in bytes. `null` = not supplied.
- `firstTimestampNs` (string | null) — First packet time as a decimal nanosecond string. `null` = not present on the summary.
- `lastTimestampNs` (string | null) — Last packet time as a decimal nanosecond string. `null` = not present on the summary.
- `gunzipped` (boolean) — The file was gunzipped before parsing.
- `shb` (object | null) — Section header hardware / os / userAppl (each string or `null`). `null` = no SHB option block on screen.
- `interfaces` (object) — Capture interfaces as shown (id, linkType, linkTypeName, snapLen, name or `null`), capped at 200. `totalCount` is the real interface count.
- `comments` (object) — SHB/EPB comments in file order, capped at 200.
- `decryptionSecrets` (object | null) — DSB presence as shown: `count` and `types` only — never key material. `null` = no secrets block.
- `warnings` (object) — Parse warnings in parse order, capped at 200. Each: `frame` (0 = container), `message`.
- `packets` (object) — Packet-list rows in file order, capped at 200. Each: `number`, `timestampNs` (decimal string), `originalLength`, `capturedLength`, `streamId` (or `null`), `protocol` (or `null` if the cell was empty; `"raw"` = not dissected; `"data"` = unknown application payload), `source`, `destination`, `info`. `totalCount` is `max(container packetCount, supplied length)`, not the copied length. Payload bytes are omitted.
- `protocolCounts` (object) — Packet and on-wire byte counts per protocol, counted over every supplied packet (not the copied prefix), sorted by packets descending then protocol. Capped at 200.
- `talkers` (object) — Packet and on-wire byte counts per source/destination address, counted over every supplied packet, sorted by packets descending then address. Capped at 200. `totalCount` is the real distinct-address count.

## FAQ

### 我的擷取檔會被上傳嗎？

不會。檔案由 FileReader 讀進來，交給同一個分頁裡的 Web Worker，在那裡解析。使用期間這頁不會發出任何網路請求，你可以開著開發者工具的 Network 分頁，看它一直是空的。這件事在這個工具上特別重要：擷取檔裡有你的內部拓撲、主機名稱，常常還有憑證，為了讀兩個封包就把這些交給陌生伺服器並不划算。

### 最大能開多大的擷取檔？

256 MiB。解析時整份檔案必須放在分頁的記憶體裡，超過這個量瀏覽器通常會直接把分頁殺掉而不是跑完，所以工具會誠實拒絕，而不是讓你卡在那裡。更大的檔先切開：`editcap -c 200000 big.pcap part.pcap` 會切成每 20 萬個封包一份，`tcpdump -r big.pcap -w small.pcap -c 100000` 取前 10 萬個封包。`.pcap.gz` 會在分頁裡解壓縮，同樣的上限套在解壓縮後的大小。

### 它能解密 TLS 或 HTTPS 嗎？

不能，也不會假裝能。沒有工作階段金鑰，TLS 的應用層資料就是密文，而且維持是密文。明文流動的東西一律照列：record 層、handshake、SNI、ALPN 清單、提出與協商的版本與 cipher suite，以及憑證的主體、簽發者、有效期間與 SAN。HTTP/2 只有在明文（h2c 或 prior knowledge）時讀得到；跑在 TLS 上的 h2 讀不到。QUIC 只有 Initial 封包能解（金鑰由 RFC 9001 的公開值推導出來），所以這頁能告訴你「這是 HTTP/3」並列出 ClientHello 的 SNI 與 ALPN，就到這裡為止。

### pcapng 可以夾帶 TLS 金鑰，它會拿來用嗎？

會回報，但不會用。pcapng 有 Decryption Secrets Block，用設了 `SSLKEYLOGFILE` 的瀏覽器抓下來的檔案，可能把工作階段金鑰包在檔案裡——Wireshark 會拿它解密。這個工具會讀這個區塊，告訴你檔案裡有幾組、哪些型別的金鑰，然後什麼都不解。手上握著金鑰卻只說「這段是加密的」，或是對檔案裡明擺著的金鑰裝作沒看到，兩種都不誠實；回報完就停手才是 v1 該有的立場。

### 檔案打開了，可是解析樹是空的，為什麼？

幾乎可以確定是這一版不解析的鏈結層。v1 處理 Ethernet、802.1Q / QinQ、Linux SLL / SLL2、raw IP 與 Null/Loopback。Frame Relay、Token Ring、FDDI、帶 radiotap 的 802.11 和各種序列封裝在真實世界都存在，這種檔案在這裡也打得開——容器、封包列表、時間戳記、原始位元組都是真的——但解析會停在鏈結層。頁面會直接寫出鏈結類型的名稱，並說明解析停在哪裡；不給任何說明的空樹才是最不誠實的壞法。

### 它能取代 Wireshark 嗎？

如果只是要讀別人傳給你的擷取檔，多半可以，而且不用裝任何東西，也不用相信誰家的上傳表單。即時抓包則完全比不了：瀏覽器沒有抓封包的 API，這個工具只能打開別的東西錄下來的檔案。Wireshark 還有給金鑰後的解密、橫跨數千個解析器的專家分析，以及 Lua 擴充。這頁瞄準的是日常的那一半——打開檔案、找到那個封包、把位元組讀出來——而且不遮掩那一半到哪裡結束。

## Related tools

- [Subnet Calculator](https://bytescope.dev/zh-Hant/subnet-calculator.md) — 確認擷取檔裡的位址落在哪個子網路。
- [Certificate Decoder](https://bytescope.dev/zh-Hant/certificate-decoder.md) — 把 TLS 握手裡看到的憑證貼進去，完整讀一遍。
- [WebRTC Test](https://bytescope.dev/zh-Hant/webrtc-test.md) — 怪擷取檔之前，先確認連線本身。
- [Hex Editor](https://bytescope.dev/zh-Hant/hex-editor.md) — 用同一套十六進位面板，打開任何檔案的原始位元組。
