Can I read a PCAPNG file with the 'vita49Reader' function in MATLAB 2023a?

20 views (last 30 days)
I would like to access the information in a PCAPNG file using the 'vita49Reader' function in MATLAB R2023a. If the file extension cannot be passed into the function, what file extensions can be read by the 'vita49Reader' function and how can I access the information in the PCAPNG file?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Aug 2023
The 'vita49Reader' does not depend on the file extension of the data passed in as an argument, but at the format of the data. To avoid an error when running the function, the data passed in should only contain VITA49 packets.
To successfully read a PCAPNG file in MATLAB you must first convert your PCAPNG file to a PCAP file which can then be used as an input for the 'vita49Reader' function.
You can follow the steps detailed below for the complete workflow that would allow a user to read a PCAPNG file with the 'vita49Reader' function:
1. Externally convert your PCAPNG file to a PCAP file.
2. Read and format the PCAP file in MATLAB using the following lines of code:
>> pcapObj = pcapReader("fileName.pcap");
>> pcapData = pcapObj.readAll;
>> data = arrayfun(@(x) pcapData(x).Packet.eth.Payload,1:numel(pcapData),UniformOutput=false);
>> fileID = fopen("data.bin","w"); % This will create the vita49 file
>> cellfun(@(x) fwrite(fileID,x(29:end)),data);
>> fclose(fileID);  
3. Once the VITA49 file named, 'data.bin', file is created, you can use the 'vita49Reader' function to read the file.

More Answers (0)

Categories

Find more on MATLAB Compiler SDK in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!