Main Content

pcapWriter

PCAP file writer of protocol packets

Since R2020b

    Description

    The pcapWriter object writes generated and recovered protocol packets to a packet capture (PCAP) file (.pcap).

    You can write these packet types to a PCAP file:

    • Generated and recovered WLAN protocol packets

    • Generated and recovered 5G NR protocol packets (requires 5G Toolbox™)

    • Generated and recovered Bluetooth low energy (LE) link layer (LL) packets (requires Bluetooth® Toolbox)

    Creation

    Description

    pcapObj = pcapWriter creates a default PCAP file writer object.

    example

    pcapObj = pcapWriter(Name,Value) sets properties using one or more name-value pair arguments. Enclose each property name in quotes. For example, 'ByteOrder','big-endian' specifies the byte order as big-endian.

    Properties

    expand all

    Note

    The pcapWriter object does not overwrite the existing PCAP file. During each call of this object, specify a unique PCAP file name.

    Name of the PCAP file, specified as a character row vector or a string scalar.

    Data Types: char | string

    Byte order, specified as 'little-endian' or 'big-endian'.

    Data Types: char | string

    Object Functions

    expand all

    writeWrite protocol packet data to PCAP or PCAPNG file
    writeGlobalHeaderWrite global header to PCAP file

    Examples

    collapse all

    Create a PCAP file writer object, specifying the name of the PCAP file. Specify the link type for WLAN packet.

    pcapObj = pcapWriter('FileName','writeWLANpacketdata2');
    wlanLinkType = 105;

    Write a global header to the PCAP file.

    writeGlobalHeader(pcapObj,wlanLinkType);

    Specify a WLAN packet.

    mpdu = 'B4000000FFFFFFFFFFFF00123456789BA79A5B28';

    Write the WLAN packet to the PCAP file.

    timestamp = 124800; % Number of microseconds
    write(pcapObj,mpdu,timestamp);

    References

    [1] “Radiotap - Introduction.” Accessed May 20, 2020. https://www.radiotap.org/.

    [2] Group, The Tcpdump. “Tcpdump/Libpcap Public Repository.” Accessed May 20, 2020. https://www.tcpdump.org.

    [3] “Development/LibpcapFileFormat - The Wireshark Wiki.” Accessed May 20, 2020. https://www.wireshark.org.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2020b

    See Also

    Objects