Archived

This forum has been archived. Please start a new discussion on GitHub.

ICE in WAN environment

Hello.
Need a help. If i use ICE in lets say for iOS device and want to do a peer to peer communication like WebRTC how does that is possible.

WebRTC supports TURN and SIGNALLING. How does ICE can exchange information of IPs for peer to peer communication when two devices iOS are in Wide Area Network (Like 4G or 5G).

Appreciate! if you can provide a code sample or example using which this can be achieved. The problem i am trying to address is P2P communication like WebRTC (Which solves only bidirectional communication) using ICE in Mobile devices environments.

Thanks a Bunch.

Comments

  • benoit
    benoit Rennes, France

    Hi,

    It's not quite clear to me what you're trying to do. Are you trying to implement a centralized Ice service that allows iOS devices to register their IPs and then allow them to exchange the registered IP information?

    Cheers,
    Benoit

  • I want to run ICE service (server) on iOS device and want to have this available to other device (iOS or Android) and communicate over internet. So the Host device's IP address shall be available with client. How to make Host does the device iOS which is running ICE server service can make its ip visible to others on 4G, 5G internet ?

  • Any response will be much appreciated ?

  • benoit
    benoit Rennes, France

    Hi,

    The Ice server running on the iOS device should listen on all the interfaces available on the device by setting the object adapter endpoint to tcp -h * -p <port> or ssl -h * -p <port> (if you want to use SSL instead of plain TCP) and where you substitute <port> with the well-known port you want to use for your service. See Object Adapter Endpoints.

    You can then use the getPublishedEndpoints method from the Ice::ObjectAdapter interface (see Discovering Object Adapter Endpoints) to retrieve the endpoints that the Ice server is listening on. One of the endpoint will contain the public IP address accessible from the 4G network. You can retrieve the address using the Ice::IPEndpointInfo class.

    For example, the following code will print on the IP address of each endpoint:

    // Objective-C
    id<ICEObjectAdapter> adapter = [communicator createObjectAdapterWithEndpoints:@"MyAdapter" endpoints:@"tcp -h * -p 12345"];
    [adapter activate];
    for(id<ICEEndpoint> e in [adapter getPublishedEndpoints])
    {
        for(ICEEndpointInfo<ICEEndpointInfo>* info = [e getInfo]; info; info = info.underlying)
        {
            if([info isKindOfClass:[ICEIPEndpointInfo class]])
            {
                NSLog(@"IP: %@", ((ICEIPEndpointInfo*)info).host);
            }
        }
    }
    

    Cheers,
    Benoit.

  • benoit
    benoit Rennes, France
    edited November 2019

    And here's a Swift version:

    // Swift
    let adapter = try communicator.createObjectAdapterWithEndpoints(name: "MyAdapter", endpoints:"tcp -h * -p 12345")
    try adapter.activate()
    for e in adapter.getPublishedEndpoints() {
        var info = e.getInfo()
        while info != nil {
            if let ipInfo = info as? Ice.IPEndpointInfo {
                print("\(ipInfo.host)")
            }
            info = info!.underlying
        }
    }
    

    We recommend using Swift now as we're deprecating the Objective-C mapping.