imsdroid icon indicating copy to clipboard operation
imsdroid copied to clipboard

Does imsdroid support peer to peer communication?

Open basheerkohli opened this issue 4 years ago • 23 comments

Hey folks,

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

Thanks .Cheers

basheerkohli avatar Jun 04 '20 01:06 basheerkohli

Yes, it does but you need some method to exchange the full SIP uri (including the binding port) between the peers.

Once you get that, you can just call the other peer by calling its full SIP uri.

For example: INVITE sip:[email protected]:45532

Regards. Massimo

-------- Messaggio originale -------- Da: basheerkohli [email protected] Data: 04/06/20 03:17 (GMT+01:00) A: DoubangoTelecom/imsdroid [email protected] Cc: Subscribed [email protected] Oggetto: [EXT] [DoubangoTelecom/imsdroid] Does imsdroid support peer to peer communication? (#631)

Hey folks,

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

Thanks .Cheers

You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/DoubangoTelecom/imsdroid/issues/631, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADK4QSDQZGRSD3LD6Q5R2CLRU3Y3ZANCNFSM4NSFLXGQ.

Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie.

This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks.

Rispetta l'ambiente. Non stampare questa mail se non è necessario.

MassimoMessore avatar Jun 04 '20 05:06 MassimoMessore

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?

basheerkohli avatar Jun 10 '20 04:06 basheerkohli

Hi.

Yes. Because of the connection-oriented nature of SIP, the current android-ngn-stack architecture relies on the idea that the Engine and the NativeService need to run in background indefinitely to get incoming calls.

Unfortunately this leads to battery drain issues that often causes the app to be killed by the power manager of certain devices (see https://dontkillmyapp.com/ for further details).

BTW, you can surely use push notifications to address this issue but this is not currently supported by doubango/ngn-stack and will need a custom development.

If you want to explore the key-points, the IETF has recently proposed a standard solution (https://tools.ietf.org/html/rfc8599) but I'm not aware of free or commercial implementation of either clients or servers that are currently adopting it, even if proprietary solutions are available.

Regards Massimo

-------- Messaggio originale -------- Da: basheerkohli [email protected] Data: 10/06/20 06:58 (GMT+01:00) A: DoubangoTelecom/imsdroid [email protected] Cc: Messore Massimo [email protected], Comment [email protected] Oggetto: [EXT] Re: [DoubangoTelecom/imsdroid] Does imsdroid support peer to peer communication? (#631)

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?

You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/DoubangoTelecom/imsdroid/issues/631#issuecomment-641721358, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADK4QSDOTQK5ASUOYAGPBHLRV4HGNANCNFSM4NSFLXGQ.

Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie.

This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks.

Rispetta l'ambiente. Non stampare questa mail se non è necessario.

MassimoMessore avatar Jun 10 '20 05:06 MassimoMessore

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.

basheerkohli avatar Jun 10 '20 11:06 basheerkohli

Hi,

You can find a full example of how you can place outgoing calls here: https://github.com/DoubangoTelecom/imsdroid/blob/d1044c708300691fa398f6e44e7d80850ce95f7b/imsdroid/src/org/doubango/imsdroid/Screens/ScreenAV.java#L572

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

https://github.com/DoubangoTelecom/imsdroid/blob/d1044c708300691fa398f6e44e7d80850ce95f7b/imsdroid/src/org/doubango/imsdroid/Screens/ScreenAV.java#L648

Regards. Massimo

MassimoMessore avatar Jun 10 '20 15:06 MassimoMessore

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

basheerkohli avatar Jun 17 '20 07:06 basheerkohli

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

MassimoMessore avatar Jun 17 '20 09:06 MassimoMessore

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.

basheerkohli avatar Jun 18 '20 03:06 basheerkohli

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

MassimoMessore avatar Jun 18 '20 07:06 MassimoMessore

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

basheerkohli avatar Jun 18 '20 11:06 basheerkohli

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

basheerkohli avatar Jun 18 '20 11:06 basheerkohli

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

MassimoMessore avatar Jun 18 '20 13:06 MassimoMessore

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.

basheerkohli avatar Jun 18 '20 18:06 basheerkohli

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

DoubangoTelecom avatar Jun 18 '20 18:06 DoubangoTelecom

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

MassimoMessore avatar Jun 18 '20 18:06 MassimoMessore

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 avatar Jun 18 '20 18:06 DoubangoTelecom

also, tcp is only supported when ICE is used

DoubangoTelecom avatar Jun 18 '20 18:06 DoubangoTelecom

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.

basheerkohli avatar Jun 19 '20 07:06 basheerkohli

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.

pradweep avatar Jun 22 '20 01:06 pradweep

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 ?

basheerkohli avatar Jun 22 '20 05:06 basheerkohli

@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

MassimoMessore avatar Jun 22 '20 07:06 MassimoMessore

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.

basheerkohli avatar Jun 22 '20 12:06 basheerkohli

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

MassimoMessore avatar Jun 23 '20 07:06 MassimoMessore