0

I'm actually developping a SIP application using Jain SIP and I noticed with WireShark that in fact the port I want to use during the initialization process of the SipProvider object isn't being used to send requests. For example :

public SipLayer(String username, String ip, int port) throws PeerUnavailableException, TransportNotSupportedException, InvalidArgumentException, ObjectInUseException, TooManyListenersException {

    setUsername(username);
    sipFactory = SipFactory.getInstance();
    sipFactory.setPathName("gov.nist");
    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", "MyApp");
    properties.setProperty("javax.sip.IP_ADDRESS", ip);

    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG",
            "textclient.txt");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG",
            "textclientdebug.log");

    sipStack = sipFactory.createSipStack(properties);
    headerFactory = sipFactory.createHeaderFactory();
    addressFactory = sipFactory.createAddressFactory();
    messageFactory = sipFactory.createMessageFactory();

    ListeningPoint tcp = sipStack.createListeningPoint(ip, port, "tcp");

    sipProvider = sipStack.createSipProvider(tcp);
    sipProvider.addSipListener(this);
}

Here is my constructor where i'm initializing the sipProvider. I'm using TCP and i want to use the 5600 port. So when sending a stateless request, i'm using the following code in my method :

sipProvider.sendRequest(request);

When making a capture, i noticed that the TCP port being used isn't the 5600 i have chosen but something like 52065 for example.

Can someone please tell me how can i force the sipProvider object to use my 5600 TCP port please?

Thanks for your help :)

1 Answers1

0

This is an OS/Java/TCP limitation. It's not impossible, but it doesn't work on most machines so JAIN-SIP uses ephemeral ports like most other SIP devices. See this answer https://serverfault.com/questions/326819/does-the-tcp-source-port-have-to-be-unique-per-host

Community
  • 1
  • 1
Vladimir Ralev
  • 1,371
  • 9
  • 18
  • What do you mean by TCP limitation? I mean in Java i can create a TCP socket by providing my InetAddress and a port number. This socket i can bind it to the remote address together with it's remote port and there's no problem. Well, with Jain SIP, that's exactly what i want, i want to be able to send Requests and receive responses on a given port. The port i have provided is in fact used and listening but when sending Requests, this port won't be used :( Why? And how can i force the sipProvider to use only the port i have provided and not to create another one? – Ronnie Pottayya Jul 21 '14 at 12:43
  • Check the link I gave above. If you think it will work on your system you can go ahead and change the code to try it. It doesn't work on most systems. Unless recent versions of Java/OSes have fixed it, that is.. – Vladimir Ralev Jul 21 '14 at 16:48