views:

301

answers:

2

I was wondering can anyone point me to a good tutorial on how to construct a SDP message.

I have read the basics and can construct and understand the parameters but I just cant seem to get it to work.

I either get a not acceptable here reply or no reply at all, this is after I get 100 Trying and 180 ringing back.

So my SIP works but it doesn't like the SDP Data.

Its currently constructed like this:

String sdpData = "v=0\r\n"
            + "o=- 019078020 0"
            + " IN IP4  sip.ciceronetworks.com\r\n" + "s=MySession\r\n"
            + "c=IN IP4  sip.ciceronetworks.com\r\n"
            + "t=0 0\r\n" + "m=audio 6002 RTP/AVP 0\r\n"
            + "a=sendrecv\r\n" + "a=rtpmap:0 PCMU/8000\r\n" + "a=ptime:20\r\n"+ "a=fmtp:97 mode=20\r\n";


    byte[] contents = sdpData.getBytes(); 

    request.setContent(contents, contentTypeHeader); 

And while like that I get 100 trying then 180 ringing but when I accept the call on the other end I get nothing back at all, it seems to just crash, I also get "Audio device Error" on the pc client that I try ringing.

Anyone any ideas?

+2  A: 

The issue could be really simple: you seem to forgot the newline after "a=sendrecv". :-)

Anyway, here's an advice: For testing purposes you are probably better off using a tool rather than jumping right in and writing parts of the protocol. You can use sipp for this purpose, it makes a great tool for testing SIP networks. Other than that you could of course just sniff the network traffic between two working SIP devices and see how it differs from your traffic.

EDIT:

I missed this one before: You should omit a=fmtp:97 mode=20, as the session description is invalid this way: You may only use the format parameter attribute for codecs that are mentioned in the media line. Codecs are identified via the payload type number (0=PCMU, 8=PCMA, 18=G723, ...). Some codecs don't have officially assigned numbers, for these the dynamic range 96-127 should be used: user agents are free to assign a number in this range via an rtpmap attribute. So, unless you specify which codec you mean by 97, there is no way for the other user agent to know which codec the format parameters should be applied to.

paprika
Thanks, that wasn't the issue though. I have network traffic and everything seems to be the same as my SDP data, so its kind of annoying trying to find out whats wrong
Donal Rafferty
+1  A: 

Paprika is right: the a=fmtp:97 mode=20 is simply wrong (and looks like it's part of an iLBC codec offer). You didn't offer codec 97, you offered codec 0 (PCMU).

Note that the a=fmtp:97 shouldn't hurt you, it's just spurious.

The most likely problem is that you are not sip.ciceronetworks.com - i.e. your c= line (and m= line) said "send my media to port 6002 at sip.ciceronetworks.com". I suspect your PC's IP address is not the same as sip.ciceronetworks.com, and/or there's a firewall/NAT between you and the other end.

It probably isn't your problem, but the o= line is wrong per the spec From RFC 4566:

o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address>

Getting VoIP to work is not as simple as the RFCs or cookbook explanations would imply....

jesup