I have a PCAPNG file and I need to get the RTP packets from it. Specifically, one of my RTP packets looks like...
Frame N: X bytes on wire...
- Ethernet II, Src: ...
- IPv4, Src: ...
- TCP, Src Port: rstp ...
- RTSP Interleaved Frame, Channel: 0x02, 163 bytes
- Real-Time Transport Protocol
...and what I need from each packet is...
- The channel from the RTSP interleaved frame
- The length from the RTSP interleaved frame
- The payload from the RTP
...using this data, I will re-create an audio and video file to re-construct the full video from a local payload (playback is not streaming).
I am able to successfully get the RTP packets using either...
tshark -r my.pcap -R -T fields -e rtp.payload -w rtp.out
or...
tshark -r my.pcap -R -T fields -e rtp.payload > rtp.out
...but the problem I am having is that the first method will save everything I need, but for some reason it will add extra data (i.e. more than just the RTP payload and RTSP interleaved frame contents) in strange places... which is preventing me from writing a program to produce the data I need to test. I attempted to remove all the extra data using several regular expressions, but there are too many different scenarios that overlap onto other valid scenarios.
The second method will provide only the RTP payload without the interleaved properties I need (it will produce the hex with a colon between each byte, but that is easily handled). Even if I could make another call to get all the RTSP interleaved frame properties, I am going to need to combine the 2 outputs by identifying each packet using a separator / delimiter, which I'd like to avoid (I couldn't get tshark to do that either...).
I looked into the tshark read filters, which seems like it should be able to do what I need, but so far I haven't been able to figure it out. Note that I am only doing this to create sample data and write the logic that formats the data required for playback. Eventually one of my co-workers will modify the streaming client to capture the data in the appropriate format (so I can simply run the data through ffmpeg without modifying it). Any ideas of how I can create the format I need?