Question

I am using jNetPcap to decode rtp from tcpdumps. Currently I use the SIP Invite Message and the source IP (and also checking via source ips..) to detect the directions (forward, reverse) from the call.. this is working but not really how it is intended to work from rfc standard and to work-around all possible behaviours.

Is there any way to determine from SSRC in which direction the source works for a sip call? As far as I can see the ssrc identifiers first appear on the rtp stream from which I can not say which call flow direction it is.

And I don't want to save both directions and have the user decide which direction it is.

Was it helpful?

Solution 2

I did dirty parsing but it seems that jnetpcap has no better way to do that:

private class JPacketHandlerSSRCs implements JPacketHandler<String> {

    @Override
    public void nextPacket(JPacket packet, String user) {
        // TODO Auto-generated method stub

        Udp udp = new Udp();
        Rtp rtp = new Rtp();
        Sdp sdp = new Sdp();
        Sip sip = new Sip();

        // get the source ip of the caller from the invite message.
        // seems to be a tricky and dirty workaround, poor jnetpcap framework!
        if(packet.hasHeader(sip) && packet.hasHeader(sdp)) {

            if( (sip.getUTF8String(0, '@')).startsWith("INVITE ") ) {
                String sdptext = sdp.text();
                int pos = sdptext.indexOf("m=audio ") + 8;
                int end = pos;
                if(pos != -1)
                    while(sdptext.charAt(end) != ' ') end++;

                rtp_forward_channel_port = Integer.parseInt(sdptext.substring(pos, end));
                }
        }



        if(packet.hasHeader(udp))
            if(rtp_forward_channel_port == udp.source() && packet.hasHeader(rtp)) {
            try {
                dos = getOutputStream(rtp.ssrc());
                dos.write(rtp.getPayload());
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }


        }
    }

OTHER TIPS

There is no way of determining from just the RTP streams which party placed the call. You would need to capture the INVITE/200/ACK exchange to map from IP address/port/transport triples to participants in the call. It sounds like you're already doing that.

I'm not sure what you mean by "but not really how it is intended to work from rfc standard". It seems that both the RTP and SIP standards are doing exactly what they should be doing. SIP uses SDP to isolate itself from knowing directly about the media plane, which allows SIP to work with arbitrary media protocols.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top