Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stream pcap file to RTP/RTCP stream?

I have captured three different stream as pcap file with meta datas. How can I stream back to RTP/RTCP stream?

like image 720
Swaminathan Avatar asked May 20 '11 15:05

Swaminathan


People also ask

How does Wireshark detect RTP packet loss?

Analyzing the Traffic. As next steps, select Telephony -> RTP -> RTP Streams. Then, observe an output like: As observed, there are 4 RTP streams, but the first and third one have almost 4% packet loss. Select one of them and then select 'Analyze'.


1 Answers

If I understand correctly, you have the pcaps, but you want to get the RTP from them?

Wireshark UI

You could use Wireshark's UI to easily take the RTP from the pcap via the Menu: Telephony/RTP/ then show all streams... click a stream it lists, and then 'analyize.'

However, if you want to automate this, and avoid the UI... you can use tshark. I found several tutorials online and used them to build a test harness that automatically rebuilds the audio/rtp on a pcap, then makes a wav and transcribes the audio on that wav to text.

Automated with Tshark

I was making a test call, and wanted to convert the pcap recorded to audio. To do this, I stripped the RTP out of the pcap, then converted the rtp file to raw audio, and then to a wav.

I do this all via the command line so it can be automated. So really I have a shell script that does this:

tshark -a duration:20 -w /jenkins/userContent/sip_1call.pcap

The above records a packet capture for 20 seconds (the duration of the call going on at the same time) and outputs the packets as sip_1call.pcap

ssrc=$(tshark -n -r /jenkins/userContent/sip_1call.pcap -R rtp -T fields -e rtp.ssrc -Eseparator=, | sort -u | awk 'FNR ==1 {print}')

I'm setting the variable ssrc to this action of using tshark to pull out the rtp ssrc value. What the ssrc is is, is an identifier of a RTP stream. If you have one stream, you'd have one RTP ssrc value. You would need to capture all the RTP.ssrc's and output them to a file and that can easily become raw audio again.

sudo tshark -n -r /jenkins/userContent/sip_1call.pcap -R rtp -R "rtp.ssrc == $ssrc" -T fields -e rtp.payload | tee payloads

At this point of my shell script, I'm running tshark again on the recorded pcap and taking that ssrc value and saying "find all of them as 'payload'"

for payload in `cat payloads`; do IFS=:; for byte in $payload; do printf "\\x$byte" >> /jenkins/userContent/sip_1call.raw; done; done

Now the script is setting those RTP.ssrc's to a output file, i'm calling sip_1call.raw

For my purpose I also wanted to convert that raw file to a wav, so I used sox:

sox -t raw -r 8000 -v 4 -c 1 -U /jenkins/userContent/sip_1call.raw /jenkins/userContent/sip_1call.wav

I did some more stuff in my automation framework (like transcribe the audio to text and compare against a known string)... but that's outside the scope of your question.

I hope that helps...

More on SSRc: http://en.wikipedia.org/wiki/Real-time_Transport_Protocol

More details on the full shell script I'm using: http://www.continuous-qa.com/2013/04/automated-verification-of-voip-audio.html

like image 105
continuousqa Avatar answered Sep 30 '22 22:09

continuousqa