Hi Siga, Your issue (in by best guess) is not in your concept, as you are using the correct ports to send and receive, it is most likely in your socket code. If you'd like to email me your code for socket creation, binding, sending and receiving I'd be happy to look at it for you.
I'm also curious if you are using a new DGRAM socket for your rtp or trying to reuse your sip socket? Just to verify you are trying to bind your rtp socket before your send your INVITE/SDP right? Also you are checking the return value of your bind call? If 22456 is already in use you will not be able to bind that port (unless you set some socket options but you don't want to do that), which is why you need to bind first to reserve a port then send your INVITE/SDP. One way to do reserve a port is start with a port number to try and bind. If the bind fails then increment that port by 2 (rtp should be on an even port number) and try to bind again in a loop. Repeat this process until your bind is successful or you've looped through your entire rtp range without success. Don't forget once your port gets above 0xffff (max udp port) then reset the port to the beginning of your starting port range. Hope this helps, Brandon -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Siga Sent: Monday, March 07, 2011 12:32 PM To: [email protected] Subject: [Sip-implementors] Ports for sending and receiving RTP packets! Hi, I am facing rather a strange problem with the ports for sending and receiving RTP packets. This is the second time I am posting my question. Initially I am able to set up a SIP Client successfully SIP CLIENT SIP SERVER (1.2.3.4) (3.4.5.6) INVITE: 1.2.3.4:5060 --------------------------------------------> 100 Trying: 3.4.5.6 <--------------------------------------------- 200 OK: 3.4.5.6 <-------------------------------------------- ACK: 1.2.3.4:5060 --------------------------------------------> RTP Packets --------------------------------------------> Here comes the problem: my SIP Client INVITE looks like this "INVITE sip:[email protected]/2.0\r\n" "Via:SIP/2.0/UDP 192.168.x.000:5060;branch=z9hG4bKdg18\r\n" "Max-Forwards: 70\r\n" "To: server <sip:[email protected]>\r\n" "From: User<sip:[email protected]>; tag = 76341\r\n" "Call-ID: [email protected]@192.168.x.x\r\n" "CSeq: 1 INVITE\r\n" "Contact: <sip:[email protected]>\r\n" "Content-Type: application/sdp\r\n" "Content-Length:142\r\n"; "\r\n" "v=0\r\n" "o=User 53655765 2353687637 IN IP4 192.168.x.000\r\n" "s=-\r\n" "c=IN IP4 192.168.x.000\r\n" "t=0 0\r\n" "*m=audio 22456 *RTP/AVP 0 8\r\n" "m=video 51372 RTP/AVP 98 49\r\n" "a=rtpmap:0 PCMA/8000\r\n" "a=rtpmap:98 H263-1999/90000\r\n"; that is here I am mentioning that I am available on the port = *22456 , *for receiving RTP packets. On the other hand from the *200 OK SDP* which I get from the *SIP Server* I am parsing the audio port number = *18564 *which I use to send the audio RTP packets from the Client side. Until here everything is fine, but when I try to bind my client to the local address(1.2.3.4) and port number, there are two scenarios 1. If I bind my client to the local port = *22456, *this is how I am doing* **Local.sin_port = 22456**; *When I have done like this* *I cant send anything to the SIP Server, after time out SIP Server sends BYE to the SIP Client. 2. If I bind my client to the local port = *5060 (SIP PORT), **Local.sin_port = 5060**; *When I have done like this* *I can send RTP packets to the SIP Server and there is a constant flow of packets which I can capture and view using Wireshark. For both the above cases, I am declaring the remote port for the Server in this manner* remote.sin_port = **18564 * is this normal to send RTP packets from the local port = *5060(SIP PORT)* with remote port = *18564 *and receive RTP packets from SIP Server on local port = *22456 * with remote port = *18564. *I am really confused here*. *If I am doing something wrong then please correct me*. *If you need any further information then please let me know. Regards* * _______________________________________________ Sip-implementors mailing list [email protected] https://lists.cs.columbia.edu/cucslists/listinfo/sip-implementors _______________________________________________ Sip-implementors mailing list [email protected] https://lists.cs.columbia.edu/cucslists/listinfo/sip-implementors
