Main Content

pcapWriter

PCAP file writer of protocol packets

    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 Bluetooth® low energy (BLE) link layer (LL) packets (requires Communications Toolbox™ Library for the Bluetooth Protocol)

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

    • Generated and recovered WLAN protocol packets (requires WLAN 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 BLE link type.

    pcapObj = pcapWriter('FileName','writeBLE');
    bleLinkType = 251;

    Write a global header to the PCAP file.

    writeGlobalHeader(pcapObj,bleLinkType);

    Specify a BLE LL packet.

    llpacket = '42BC13E206120E00050014010A001F0040001700170000007D47C0';

    Write the BLE LL packet to the PCAP file.

    timestamp = 129100; % Number of microseconds
    write(pcapObj,llpacket,timestamp);

    References

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

    [2] “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™.

    See Also

    Objects

    Introduced in R2020b