Main Content


Write custom block to PCAPNG file

Since R2020b



    writeCustomBlock(pcapngObj,customData) writes the custom block data, customData, to a PCAPNG file specified in the PCAPNG file writer object.


    collapse all

    Create a default PCAPNG file writer object.

    pcapngObj = pcapngWriter;

    Write the interface block for 5G New Radio (NR). 5G NR packets do not have a valid link type. As per Tcpdump, if a valid link type is not present, specify the link type of SLL packet.

    interface = '5GNR';         % Interface name
    linkType = 113;             % Link type of SLL packet
    interfaceID = writeInterfaceDescriptionBlock(pcapngObj,linkType,interface);

    Write the custom block to specify user-defined data.

    writeCustomBlock(pcapngObj,"This block writes user-defined data");

    Input Arguments

    collapse all


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

    PCAPNG file writer object, specified as a pcapngWriter object.

    User-defined data, specified as a character vector or a string scalar.

    Data Types: char | string


    [1] Tuexen, M. “PCAP Next Generation (Pcapng) Capture File Format.” 2020.

    [2] Group, The Tcpdump. “Tcpdump/Libpcap Public Repository.” Accessed May 20, 2020.

    [3] “Development/LibpcapFileFormat - The Wireshark Wiki.” Accessed May 20, 2020.

    Extended Capabilities

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

    Version History

    Introduced in R2020b