Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.



7759 posts

Uber Geek
+1 received by user: 495

Trusted

Topic # 114549 23-Feb-2013 08:20 Send private message

I've been trawling the net and my understanding is if you are on ios, push ing is done by a server talking to Apple then Apple remotely wakes up the iPhone to download the new stuff. My understanding is the phone is fully asleep at all times hence no battery strain.

It's that right?

It's it the same for android and does setting something to push have no effect on all the times when it is sleeping waiting for the remote poke?

Thanks

Create new topic
526 posts

Ultimate Geek
+1 received by user: 35


  Reply # 770032 25-Feb-2013 18:15 Send private message

From a low-level network standpoint, there are only a few ways that the push mechanism could be done. I can think of 3 off the top of my head:

(1) A persistent connection from the device to the server. The device makes a request for data and waits for a reply.If the server gets data it'll send it back right away, otherwise it'll eventually send back a "no data"response to keep the network connection alive.


(2) A stateless network connection using UDP. The device blips the server occasionally to say "I'm still here"and to keep any firewall holes alive.May not work with all firewalls.


(3) The device is reachable directly from the public internet. The phone doesn't need to wait for anything - it'll be contacted as needed. Doesn't work with most firewalls.


In the 2 most likely cases, the device needs to keep a network connection alive somehow. I'm not sure whether there is some sort of low power way of doing this without fully waking the CPU, but I'd say that both Android and iOS use fairly similar methods.

5971 posts

Uber Geek
+1 received by user: 109

Trusted
Subscriber

  Reply # 770039 25-Feb-2013 18:33 Send private message

Hi, this is how its done, GCM replaces c2dm but the overall concept is the same.

http://developer.android.com/google/gcm/index.html

Cyril

526 posts

Ultimate Geek
+1 received by user: 35


  Reply # 770258 26-Feb-2013 08:32 Send private message

cyril7: Hi, this is how its done, GCM replaces c2dm but the overall concept is the same.

http://developer.android.com/google/gcm/index.html


Looks like it uses HTTP behind the scenes to transmit the data. HTTP is a request/response protocol, meaning that the server can't arbitrarily push data to the client.All our can do is delay each response as long as possible and probably respond with a 204 No Content if there's nothing to report.


As I mentioned above, this requires that the phone keeps an open network connection. I believe that the CPU can sleep while it's waiting for a response, but it still needs to wake up briefly at regular intervals to keep the connection alive. I'm not sure how long firewalls and routers keep idle TCP connection open for, but it's probably somewhere between 90 seconds and 10 minutes. Chances are that the phone has to wake up every couple of minutes, which does have an effect on battery life.

673 posts

Ultimate Geek
+1 received by user: 26

Subscriber

  Reply # 770268 26-Feb-2013 09:06 Send private message

Why doesn't the phone just sleep completely and then notify the server when/if it has an IP change? That way the server always knows how to contact the phone and send email when it arrives? Hardly any battery use would be the outcome.

5971 posts

Uber Geek
+1 received by user: 109

Trusted
Subscriber

  Reply # 770269 26-Feb-2013 09:20 Send private message

Hi, based on my M2M experience in the past 2min polls will keep both the mobile network and most routed networks open.

Cyril



7759 posts

Uber Geek
+1 received by user: 495

Trusted

  Reply # 770285 26-Feb-2013 09:47 Send private message

myopinion: Why doesn't the phone just sleep completely and then notify the server when/if it has an IP change? That way the server always knows how to contact the phone and send email when it arrives? Hardly any battery use would be the outcome.


is that how apple's push works? if so apple push superior to android push?

673 posts

Ultimate Geek
+1 received by user: 26

Subscriber

  Reply # 770291 26-Feb-2013 09:49 Send private message

Not sure but that's how I would try and make it :)

526 posts

Ultimate Geek
+1 received by user: 35


  Reply # 772078 1-Mar-2013 08:53 Send private message

Publishing the phone's IP address isn't going to work for most WiFi networks. The vast majority of these networks (including almost every home network) use NAT.

NAT creates a private internal network where each device gets its own private IP address. These addresses are from special reserved ranges that cannot appear on the public internet. When you connect to a public network service your firewall/router forwards the data on your behalf, rewriting the address and port information to make site the data gets to the correct destination.

NAT makes it difficult to receive incoming connections. When a firewall/router receives a connection for port X, it has no way of knowing which device on the internal network to send it to. The only way to get around this is to set up port forwarding, configuring the router to send requests for specific ports to specific internal addresses. This is strictly one port to one address, so if the push server expects to contact the phone on a certain port then only one phone on the network could get push notifications.

The only way around this restriction is to get the phone to register a port number. The server can then try to connect to that port on the IP address that the registration came in on. If everything is set up correctly then out should work.

The question then is how to know what port number to register. There's no standard way to query the router for this information, and you can't expect the user to know it in every case. You could use UPnP to dynamically request a port forwarding be created, but that assumes that UPnP is supported by the router and enabled by the network administrator.

As you can see, the obvious/simple solution is anything but. It might work on cellular networks (if they aren't using NAT) but won't work on the majority of home and business networks. You also wouldn't try to use the IP address/port as a primary method and fall back to polling because then time got 2 loss of code to support. It's far better to support the one method that almost always works, even if it is less efficient.

Create new topic




Twitter »
Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





Trending now »

Hot discussions in our forums right now:

Who Audits IRD?
Created by gundar, last reply by charsleysa on 22-Oct-2014 15:52 (18 replies)
Pages... 2


22nd Only: PB Tech BROTHER HL1110 Mono laser Printer $15 shipped(after $30 cashback)
Created by loceff13, last reply by Jaxson on 22-Oct-2014 15:44 (17 replies)
Pages... 2


American legal jurisdiction in New Zealand
Created by ajobbins, last reply by gzt on 21-Oct-2014 14:58 (30 replies)
Pages... 2


Another Trade Me competitor: SellShed
Created by freitasm, last reply by SellShed on 22-Oct-2014 11:54 (42 replies)
Pages... 2 3


Spark Socialiser
Created by freitasm, last reply by old3eyes on 22-Oct-2014 10:37 (26 replies)
Pages... 2


Snap have failed our company!
Created by dafman, last reply by toejam316 on 22-Oct-2014 13:03 (25 replies)
Pages... 2


Overcharged by Slingshot for months - warning to existing customers
Created by dusty42, last reply by jeffnz on 22-Oct-2014 16:07 (34 replies)
Pages... 2 3


Abnormal upstream data usage - Vodafone Cable Wellington
Created by otherside, last reply by freitasm on 22-Oct-2014 15:33 (11 replies)


Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.