Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does imsdroid support peer to peer communication? #631

Open
basheerkohli opened this issue Jun 4, 2020 · 23 comments
Open

Does imsdroid support peer to peer communication? #631

basheerkohli opened this issue Jun 4, 2020 · 23 comments

Comments

@basheerkohli
Copy link

basheerkohli commented Jun 4, 2020

Hey folks,

Can anyone please let me know that, does this imsdroid supports peer to peer communication?

Thanks .Cheers

@MassimoMessore
Copy link

MassimoMessore commented Jun 4, 2020 via email

@basheerkohli
Copy link
Author

Hey Massimo,

I appreciate the quick response. So moving forward I have another question.

So is the NGNEngine and AVSESSION needs to be run in the background indefinitely in order to accept the incoming calls when the application is not in the running state?

OR else is there is another way of detecting the incoming call? Say for supposing push notifications. Upon receiving the push notification one can then start the NGNEngine and AVSESSION to accept the incoming call?

@MassimoMessore
Copy link

MassimoMessore commented Jun 10, 2020 via email

@basheerkohli
Copy link
Author

Thanks for your support Massimo. We will look into the push notification development if needed.
Meanwhile, I have some queries regarding the NGNAVSession creation for taking incoming calls.

From the demo examples, it's clear that on invoking the below method I can get the NGNAVSession object which is used for managing Audio Video option and useful in initiating the call.

public static NgnAVSession createOutgoingSession(NgnSipStack sipStack, NgnMediaType mediaType);

As the naming convention of the method itself says that this method is only used for creating an outgoing session. So in order to take an incoming call , I found another method ( takeIncomingSession ) from the same class [NgnAVSession.java]

public static NgnAVSession takeIncomingSession(NgnSipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage) ;
can I consider this method for accepting incoming call sessions? If yes, I am unclear with the parameters of this method definition.

Four parameters,

  1. NgnSipStack == iNgnSipService.getSipStack(); able get the sipstack object from the ngnSipService object.
    2.CallSession == unclear. How to get the callSession object?
    3.twrap_media_type_t == As the media type is audio in my case i can go with twrap_media_type_t.twrap_media_audio as of now
    4.SipMessage == unclera. How to get the SipMessage Object?

What if we have null as the values for 2 and 4 parameters?

Thanks. Looking for your response.
Basheer S.

@MassimoMessore
Copy link

Hi,

You can find a full example of how you can place outgoing calls here:

public static boolean makeCall(String remoteUri, NgnMediaType mediaType){

To accept incoming calls, once you retrieve the NgnAVSession you can just use the acceptCall() method.

Regards.
Massimo

@basheerkohli
Copy link
Author

basheerkohli commented Jun 17, 2020

Hey Massimo,

Thanks for your support we are facing an issue while registration. The contact SIP header value is getting always mapped with a private I.P address. Which makes it's impossible to form a connection between two peers. Following the framework code, we just identified there are some flags and methods which enable the STUN server functionality of getting a public IP address from the given private address.

The method used to enable STUN server :

SIPStack.setStunServerEnabled(boolean enable);
SIPStack.setStunServer(String serverHost,String port);

But unfortunately, the contact SIP header value is still mapped with a private I.P address.
STUN server configuration details.
DEFAULT_NATT_STUN_SERVER= stun.l.google.com
DEFAULT_NATT_STUN_PORT=19305

@MassimoMessore
Copy link

Hi.
I always used p2p among peers on the same LAN and it works fine but when you need to deal with NAT traversal things can become more tricky.
In particular get the public IP in the Contact header is only part of the problem (and yes the methods you've found to enable STUN look correct, just double check if the STUN server works or try with another one).
One other issue is to open the NAT for incoming connections when a peer needs to receive a call. In most cases you need the called peer to generate arbitrary traffic towards the ip:port of the caller, before it can receive the incoming INVITE.
For example the caller could send a push notification to the callee containing its public ip:port and then start sending INVITEs (according to SIP timers). When the callee receives the PN, it could send arbitrary ip packets towards the ip:port received into the PN just to open the NAT and let the INVITEs to traverse the NAT.

This is just an example and could not work in some networking scenarios. BTW for p2p communications across public networks, I guess webrtc/ice is the mainstream. I know doubango has added some support for it but I never really got into it.

Regards
Massimo

@basheerkohli
Copy link
Author

Hi ,

Mentioned STUN server is working fine , it's providing public IP address as response .Tested the STUN server using a javascript library. But unfortunately it's not happening in Doungao SDK . Private IP adrees is still getting mapped to Contact header in the request . Iam just trying to understand the Doubango C library code for any help. Do you have any other information regarding sending of public address to contact header.

Thanks.Cheers.

@MassimoMessore
Copy link

Hi.

Please also check if you enabled STUN for the MediaSessionMgr.
https://github.com/DoubangoTelecom/imsdroid/blob/master/android-ngn-stack/src/org/doubango/ngn/NgnEngine.java#L234

Regards
Massimo

@basheerkohli
Copy link
Author

No luck,
Have enabled for the MediaSessionMgr too. Logs were written for double-checking. Everything shows that STUN is enabled.

@basheerkohli
Copy link
Author

According to my observations what I found is, the IP address which is mapping to the Contact Header is the local IP of the mobile. I have attached a screenshot of my Status screen of the My Phone where you can see the IP addresses (IPv4 and IPv6). These IP addresses get changed if I switch to another network.

Screenshot of Status Screen: Settings>About Phone > Status > IP Address.

1592478582545

@MassimoMessore
Copy link

Hi.

I just tried with an imsdroid-based android app and it works: I see my public IP address into the contact (87.14.x.y).

Contact Stun

What I've done was just setting the following into NgnConfigurationEntry.java:

  • DEFAULT_NATT_USE_STUN_FOR_SIP = true
  • DEFAULT_NATT_STUN_SERVER = "stun.l.google.com"
  • DEFAULT_NATT_STUN_PORT = 19305

I suggest you to clone and build the imsdroid project and try to set the proper STUN configuration and see if it works.

Regards
Massimo

@basheerkohli
Copy link
Author

Hey Masimo,

followed your instructions.

  1. Cloned the project.
  2. Change of configurations.
    NgnConfigurationEntry.java
    public static final boolean DEFAULT_NATT_USE_STUN = true;
    public static final boolean DEFAULT_NATT_USE_STUN_FOR_SIP = true;
    public static final boolean DEFAULT_NATT_USE_ICE = false;
    public static final boolean DEFAULT_NATT_USE_STUN_FOR_ICE = true;
    public static final boolean DEFAULT_NATT_USE_TURN_FOR_ICE = false;
    public static final boolean DEFAULT_NATT_STUN_DISCO = false;
    public static final String DEFAULT_NATT_STUN_SERVER = "stun.l.google.com";
    public static final int DEFAULT_NATT_STUN_PORT = 19305;
    public static final String DEFAULT_NATT_STUN_USERNAME = "";
    public static final String DEFAULT_NATT_STUN_PASSWORD = "";

But the results are not promising. Still getting the private I.P address in Contact Header.
git

Note: We are facing the same in IDoubs too.

Thanks.

@DoubangoTelecom
Copy link
Owner

You should use Wireshark to check if there are stun requests. Also, the device logs should contain useful information

@MassimoMessore
Copy link

I see you're using TCP as transport protocol. Maybe I'm wrong, but I remember I saw a comment somewhere in the code saying STUN is only supported when using UDP.

Can you please try using UDP and see if something changes?

Regards

@DoubangoTelecom
Copy link
Owner

I see you're using TCP as transport protocol. Maybe I'm wrong, but I remember I saw a comment somewhere in the code saying STUN is only supported when using UDP.

Can you please try using UDP and see if something changes?

Regards

The Google stun server doesn't support tcp.

@DoubangoTelecom
Copy link
Owner

also, tcp is only supported when ICE is used

@basheerkohli
Copy link
Author

Hi Massimo,
I was about to mention you the same . STUN server requests were not captured while capturing android traffic with TCP placed.

Whereas using UDP as transport protocol STUN server requests got captured and finally able to see the public address on the Contact header.

Thanks for your support.

@pradweep
Copy link

Hi Massimo,

Previously I was facing the same issue using TCP I was unable to send. Public IP address to the server. But then after changing it to UDP I can able to send public IP address in contact header and registration is working perfectly . But the problem comes while initiating the call , the invite packets were not receiving at the signalling server side. Checked with air traffic from the mobile end ,the invite packets has captured but unfortunately not being able to receive at the server side. This was not happening when using TCP protocol as network.

@basheerkohli are you able to send invite packets to signalling server using UDP protocol please confirm the same.

Best Regards,
Pradweep Kumar.

@basheerkohli
Copy link
Author

Hi @pradweep ,
Yes it is happening my end too . Though the packets were captured from mobile end it was not seen receiving at server end during invite action after using UDP as network protocal. But everything going well and good incase of registration as we have used the same UDP protocal for it. @MassimoMessore do you have any thoughts on this ?

@MassimoMessore
Copy link

@MassimoMessore do you have any thoughts on this ?

Hi, it's hard to say without seeing any log or wireshark trace. Could be a packet fragmentation issue, since the INVITE generally carries much more data than the the REGISTER, but could be anything.

Regards
Massimo

@basheerkohli
Copy link
Author

Hi Massimo,
According to this source
[ https://lists.cs.columbia.edu/pipermail/sip-implementors/2006-August/013749.html]
I found that the MAX size of the packet should not be more than 1500 bytes.

When coming to Wireshark trace the INVITE packets which were captured were more than this number they are 1509 bytes each. So I think it makes the issue, correct me if I am wrong, if not do we have methods or configurations provided by the SDK to remove unwanted headers in the SIP packets so that I can reduce the size of the packet.

Thanks. Cheers.
Basheer.

@MassimoMessore
Copy link

Hi Basheer,
You can add/remove SIP headers or 3GPP caps with methods included in NgnSipSession.java.

You can also try to remove unwanted/unused codecs (to reduce the SDP) using SipStack::setCodecs.

Regards.
Massimo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants