Collect PCAPs
After a packet capture is requested and the capture is collected, the output is contained within one or more files in PCAP file format. Before starting a full
type packet capture, you must first follow instructions for configuring a bucket.
Currently, when a packet capture is requested, packets flowing at Cloudflare's global network through the Magic Transit system are captured. The default API field for this is "system": "magic-transit"
, both for the request and response.
Sample and full
time_limit
: The minimum value is1
seconds and maximum value is300
seconds.packet_limit
: The minimum value is1
packet and maximum value is10000
packets.
Full
byte_limit
: The minimum value is1
byte and maximum value is1000000000
bytes.
- Log in to your Cloudflare dashboard ↗, and select you account.
- Select Magic Transit or Magic WAN.
- In Captures, select Start a capture.
- Select the Captures tab > Start a capture.
- Choose the type of capture you want to perform, and select Next.
- Fill out the required fields to begin the capture and then select Start.
The main Packet captures page displays a list of captures.
The PCAPs API needs both system
and type
to be specified to start a capture. A PCAP's system
is the product or logical subsystem where packets are captured, and a PCAP's type
is how the captured packets are built into a PCAP file.
Currently, you can only send one collect request per minute for sample PCAPs, and you can only have one running or pending full PCAP at a time.
Full PCAP
For full PCAP requests, refer to the required parameters listed at Create full PCAP requests. Note that full packet captures require two more parameters than sample packets.
The full PCAP request endpoint also contains optional fields you can use to limit the amount of packets captured. Both full and sample packet requests contain an optional filter_v1
parameter you can use to filter packets by IPv4 Source address, for example. For a full list of the filter options, refer to the parameter lists above.
Leave filter_v1
empty to collect all packets without any filtering.
While the collection is in progress, the response returns the status
field as pending
. You must wait for the PCAP collection to complete before downloading the file. When the PCAP is ready to download, the status changes to success
.
Sample PCAP
To create a sample PCAP request, send a JSON body with the required parameter listed at Create sample PCAP request.
Leave filter_v1
to collect all packets without any filtering.
The response is a JSON body that contains the details of the job running to build the packet capture. The response contains a unique identifier for the packet capture request along with the details sent in the request.
- Log in to your Cloudflare dashboard ↗, and select you account.
- Select Magic Transit or Magic WAN.
- In Packet captures, select Start a capture.
- Select the Captures tab.
To check the status of a running job, send a request to the endpoint and specify the PCAP identifier. The PCAP identifier is received in the response of a collect request as shown in the previous step.
The response will be similar to the one received when requesting a PCAP collection.
The capture status displays one of the following options:
- Complete: The capture request is done and ready for download.
- In progress: The capture request was captured but still processing.
- Failure: The capture failed. If this occurs, verify your ownership information.
After your request finishes processing, you can download your packet captures.
- Log in to your Cloudflare dashboard ↗, and select you account.
- Select Magic Transit or Magic WAN.
- In Packet captures, select Start a capture.
- Select the Captures tab.
- Locate your packet capture you want to download, and select Download.
Packet captures are available to download when the Status displays Success.
For more information on how to process multiple saved capture files into a single output file, refer to Wireshark's mergecap documentation ↗.
Full PCAPs
To obtain full PCAPs, download the files from the bucket specified in destination_conf
after the PCAP's status is success
. You may find multiple files named pcap_<pcap_id>.pcap
per capture as captures can occur across multiple machines.
Sample PCAPs
Once the sample PCAP collection is complete, you can download the PCAP by specifying the PCAP identifier used earlier.
- Log in to your Cloudflare dashboard ↗, and select you account.
- Select Magic Transit or Magic WAN.
- In Packet captures, select Start a capture.
- Select the Captures tab.
The list of packet captures associated with your account displays.
To view a list of sent requests, use the following command:
The response returns an array that includes up to 50 sent requests, which includes completed and ongoing requests.