Main Content

pcapngWriter

PCAPNG file writer of protocol packets

    Description

    The pcapngWriter object writes generated and recovered protocol packets to a packet capture next generation (PCAPNG) file (.pcapng).

    Creation

    Description

    pcapngObj = pcapngWriter creates a default PCAPNG file writer object.

    pcapngObj = pcapngWriter(PropertyName=Value) sets 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.

    example

    Properties

    expand all

    Note

    The pcapngWriter object does not overwrite the existing PCAPNG file. Each time when you create this object, specify a unique PCAPNG file name.

    This property is read-only after object creation.

    Name of the PCAPNG 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

    This property is read-only after object creation.

    Comment for the PCAPNG file, specified as a character vector or a string scalar.

    Data Types: char | string

    Since R2026a

    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
    writeCustomBlockWrite custom block to PCAPNG file
    writeInterfaceDescriptionBlockWrite interface description block to PCAPNG file

    Examples

    collapse all

    Create a PCAPNG file writer object, specifying the name of the PCAPNG file. Specify the Bluetooth LE link type.

    pcapngObj = pcapngWriter('FileName','BLELLCapture');

    Write an interface description block for Bluetooth LE.

    interfaceName = 'Bluetooth LE interface';
    bleLinkType = 251;
    interfaceId = writeInterfaceDescriptionBlock(pcapngObj,bleLinkType, ...
        interfaceName);

    Specify a Bluetooth LE LL packet.

    llpacket = '42BC13E206120E00050014010A001F0040001700170000007D47C0';

    Write the Bluetooth LE LL packet to the PCAPNG format file.

    timestamp = 0;                                 % Packet arrival time in POSIX® microseconds elapsed since 1/1/1970
    packetComment = 'This is a Bluetooth LE packet';
    write(pcapngObj,llpacket,timestamp,interfaceId,'PacketComment', ...
        packetComment);

    References

    [1] Tuexen, M. “PCAP Next Generation (Pcapng) Capture File Format.” 2020. https://www.ietf.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

    expand all

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

    Version History

    Introduced in R2020b

    expand all

    See Also

    Objects