For the past year, I've been struggling with getting email to work reliably on the S60 3rd edition-based Nokia phones (in particular, the E60). Often, after connecting and IDLEing for awhile, the IMAP connection drops. This can be managed by enabling "auto-retrieve", but that in itself has its own problems, such as auto-retrieve disabling itself upon any failure.
I never thought that it could be fixed, but surprisingly, after I migrated my mails from Courier-IMAP to Dovecot, the phone kept its connection for the whole day. What could be different about it?
It turns out that Dovecot implements its own application-layer keepalives, sending a NOOP every 2 minutes (Fig. 1).
static void keepalive_timeout(void *context)
{
struct cmd_idle_context *ctx = context;
if (ctx->client->output_pending) {
/* it's busy sending output */
return;
}
client_send_line(ctx->client, "* OK Still here");
}Fig. 1 - src/imap/cmd-idle.c
I had long suspected that the connection dropouts were due to the IMAP TCP session timing out by my 3G provider's (Virgin) NAT router. Although TCP keepalives are enabled by Courier (the IMAP server used), keepalives are either too infrequent or not honored by the router.
This workaround creates extra network traffic in both directions, as well as increase the phone's battery consumption. At a keepalive interval of 2 minutes and assuming both the keepalive and acknowledgement total 100 bytes, a day should result in a 72KB worth of keepalive chatter. As an individual, this has negligible impact me, however it may pose problems on mass deployments. Eronen showed in his controlled trials that battery consumption by keepalives is inversely proportional to keepalive interval[1]. However, even at a keepalive interval of 2.5 minutes, battery consumption was 2.5 times of the idle state. This is due to the exceptionally high power consumed when the phone radio is used, as compared when it idles (Eronen determined 29mW at idle, 9200mJ per keepalive).
The keepalive problem is further compounded if several flows or applications keepalive asynchronously. Given that a 3G channel is open for several seconds, it provides a power-conserving opportunity where several flows share and piggyback the channel while it is open.
As far as I'm concerned, all I can in is to make the best compromise out of the situation by increasing the keepalive interval as long as I can (10 minutes?) on my personal Dovecot installation without exceeding Virgin's NAT timeouts.
1. Eronen, P. 2008. TCP Wake-up: Reducing Keep-Alive Traffic in Mobile IPv4 and IPsec NAT Traversal.








Recent comments
7 weeks 5 days ago
26 weeks 6 days ago
26 weeks 6 days ago
28 weeks 6 days ago
29 weeks 3 days ago