Matlab pcap2matlab function - matlab

Given a pcap file I need to get the payloads of packets in Matlab. I read pcap2matlab does this but I couldn't understand the documentation properly. Can any one help me in this regard ?. If anyone used this function please explain to me both in capture mode and read mode.

Reading the documentation on pcap2matlab, you capture information directly from your network interface or you can use it in read mode where you read *.pcap files that you generate from a network logging utility such as Wireshark.
pcap2matlab looks like you should be able to use it in read only mode by reading in a filename directly, without any other parameters it should read directly into the EOF.
From the docs.
% 2. A filename string that identifies the pcap file to read. Setting this input argument
% to a filename string will automatically set the function to work in read mode.
pcap2matlab('', '','filename.pcap')

Related

Julia: Standard method to write data to ::Cmd

I'm struggling to find a simple way to read data from arecord, and then after some processing send it to aplay using Julia. I've figured out how to use pipelines to directly send data over:
run(pipeline(`arecord -d 3`, `aplay`)) # Same as: arecord -d 3 | aplay
I've also figured out how to obtain data:
data = read(`arecord -d 3`)
However, the simple task of outputting data to aplay has eluded me, which got me thinking of how, in general, one would go about taking some data d and throwing it into some ::Cmd (or at least converting some ::Cmd into an ::IOStream) variable in Julia. Also, what would the differences be between a 1 off stream (like the above for reading audio data) and a continuous stream (which would only stop after being told to close).
Thanks in advance for your help.
EDIT: arecord and aplay are standard linux terminal commands to record and play audio. arecord -d 3 generates a simple vector of 8bit values, sampling at 8kHz.
To be clear, I'm asking:
What is the standard way of reading data from a ::Cmd as a continuous data stream into a vector (e.g. reading from a never-ending file).
What is the standard way of writing a vector of data into a ::Cmd as either a 1 off instance or as a continuous stream of data (e.g. writing to a file once verses continually appending it).
This is NOT file specific because writing to aplay, a standard ::Cmd variable which works in the pipeline example above, does not work when just trying to pass it some data using either the pipeline or write functions (or at least I have been unsuccessful in doing so).
After reading and processing data. Try
open(`aplay`,"w",STDOUT) do stdin
write(stdin, data)
end

Is there a way to replay a gzip-compressed log file in kdb+ without uncompressing it first?

Streaming execute, -11!, does not work on named pipes, so an obvious solution of redirecting the gzip -cd output to a named pipe and passing it to -11! does not work.
-11! accepts a compressed file and streams it so long as it was compressed with -19! (using 2 as the compression algorithm parameter, which is gzip).
The only difference between a normal gzipped file and a kdb compressed one is a few bytes at the beginning of the file.
EDIT (see comment) Thanks, this isn't true - the bytes are different at the end of the file
So a possible solution is to prepend your gzipped files (if they weren't produced by -19!) with the appropriate byte array first.
For anyone using kdb v3.4+ streaming execution for named pipes was introduced as the function .Q.fps.
Here is a simple example of .Q.fps in action, first create the pipe via command line:
echo "aa" > test.pipe
Next in a q session:
q).Q.fps[0N!]`:test.pipe
,"aa"
Where 0N! is a function used to display the contents of the file.

Accessing Named Pipe with Simulink?

I have a named pipe server in my software, which I have accessed using C# and Python. I have a customer asking me if it's possible to access the named pipe through Simulink, but I have never used that software. Google and Stackoverflow don't seem to contain any examples of this, but I'm not sure that means that it's not possible. Does anyone know for sure whether Simulink is or isn't capable of accessing the named pipe server in another program?
I don't know what simulink is, but a named pipe usually just shows up like a file... they would have to go to some length to detect that a file was a pipe (fstat/lstat)
but you can make one to test with like...
mkfifo dog
echo "bark"
then try to open that file in simulink...
that is just basically the semantics of opening a file, if simulink tries to seek around in the file ... it will
fail...
you should read about what a fifo is, and play with it, like in the above example:
try in another shell: cat dog...

Perl and wireshark export file dialog

I am interested in opening a capture file in wireshark and then exporting the data in "C arrays" format [Wireshark provides that option in its GUI. One can do it by following "File->Export->as C arrays file" from the main menu.My question is how can I do this in perl? Can someone help me with a script for this?
I Would like to parse each and every packet of the wireshark capture. So I thought, I will first convert each packet to an array and then parse it. Do you have any suggestions on this? My capture consists of all IEEE 802.11 frames.
If you want to do all the parsing yourself, i.e. look at the raw packet data, I would suggest writing your own program using libpcap to read pcap-format capture files (on UN*X, libpcap 1.1.0 and later can also read pcap-ng-format capture files, which is what Wireshark 1.8.0 and later write by default). No need to write stuff out as C arrays.

ExtAudioFileSeek and ExtAudioFileWrite together on the same file

I have a situation where I can save a post-processing pass through the audio by taking some manipulated buffer from the end of the track and writing them to the beginning of my output file.
I originally thought I could do this by resetting the write pointer using ExtAudioFileSeek, and was about to implement it when I saw this line in the docs
Ensure that the file you are seeking in is open for reading only. This function’s behavior with files open for writing is undefined.
Now I know I could close the file for writing then reopen it, but the process is a little more complicated than that. Part of the manipulation I am doing is reading from buffers that are in the file I am writing to. The overall process looks like this:
Read buffers from the end of the read file
Read buffers from the beginning of the write file
Process the buffers
Write the buffers back to the beginning of the write file, overwriting the buffers I read in step 2
Logically, this can be done in 1 pass no problem. Programmatically, how can I achieve the same thing without corrupting my data, becoming less-efficient (opposite of my goal) or potentially imploding the universe?
Yes, using a single audio file for both reading and writing may, as you put it, implode the universe, or at least lead to other nastiness. I think that the key to solving this problem is in step 4, where you should write the output to a new file instead of trying to "recycle" the initial write file. After your processing is complete, you can simply scrap the intermediate write file.
Or have I misunderstood the problem?
Oh, and also, you should use ExtAudioFileWriteAsync instead of ExtAudioFileWrite for your writes if you are doing this in realtime. Otherwise the I/O load will cause audio dropouts.