Contenido principal

pcapWriter

PCAP file writer of protocol packets

    Description

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

    Creation

    Description

    pcapObj = pcapWriter creates a default PCAP file writer object.

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

    example

    Properties

    expand all

    Note

    The pcapWriter object does not overwrite the existing PCAP file. Each time when you call this object, specify a unique PCAP file name.

    This property is read-only after object creation.

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

    Data Types: char | string

    This property is read-only after object creation.

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

    Data Types: char | string

    Since R2026a

    This property is read-only after object creation.

    Name of the first-in first-out (FIFO) pipe file (also known as a named pipe), specified as a character row vector or string scalar. This value is an absolute or relative path to a pipe that you create outside MATLAB.

    Dependencies

    To enable this property, do not specify FileName.

    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 Bluetooth LE link type.

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

    Write a global header to the PCAP file.

    writeGlobalHeader(pcapObj,bleLinkType);

    Specify a Bluetooth LE LL packet.

    llpacket = '42BC13E206120E00050014010A001F0040001700170000007D47C0';

    Write the Bluetooth LE LL packet to the PCAP file.

    timestamp = 129100;                % Packet arrival time in POSIX® microseconds elapsed since 1/1/1970
    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

    expand all

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

    Version History

    Introduced in R2020b

    expand all

    See Also

    Objects