Stop this APN madness!



Hi,

hopefully didn't get caught in spam filters, just wanted to add a little
drama. This is serious! :P

Let's talk about APNs and GSM modems a bit. Currently we have
nm-connection-editor page for mobile-broadband devices. On mobile
broadband settings tab you can set the number to dial to and the APN.
Now, I think this is something that should be changed.

DISCLAIMER:
I might be wrong on something as this all is based on my personal
experience. I also have a copy of an AT command reference guide[1].



First of all let's see how this dial number works. 
Quite often you hear thing like "just dial 'ATD*99#' and you should be
ready to go"[2]. Well this works for someone, but might not work for
somebody else. The reason for this is that the specification[1] says
(page 51) ATD command is given in form:

    atd*<gprs_sc>[*<addr>][*[<L2P>][*[<cid>]]]]#

where gprs_sc is 99.

In my experience *99# is just a shorthand command meaning *99***1#,
although it's not said in the specification that <cid> defaults to 1.
Anyway now you see the magical CID that I talked some months back.

CID means PDP Context Identifier (page 151) and as we can see the
dialing command must always specify a CID what to use to establish the
connection. And thus *99# works automatically if CID 1 happens to
contain correct settings. 


If you issue your modem a command "AT+CGDCONT?" you can get a list of
available PDP contexts.

Here's a nice example of Sony Ericsson K750:
AT+CGDCONT?
+CGDCONT: 1,"IP","wap.omnitel.it","0.0.0.0",0,0
+CGDCONT: 2,"IP","mms.tim.it","0.0.0.0",0,0
+CGDCONT: 3,"IP","wap.omnitel.it","0.0.0.0",0,0

this is also from Sony Ericsson K750i:
AT+CGDCONT?
+CGDCONT: 1,"IP","internet.telenor.se","0.0.0.0",0,0
+CGDCONT: 2,"IP","internet.telenor.se","0.0.0.0",0,0
+CGDCONT: 4,"IP","internet.telenor.se","0.0.0.0",0,0
+CGDCONT: 5,"IP","internet.telenor.se","0.0.0.0",0,0

and here's one from Nokia N81:
AT+CGDCONT?
+CGDCONT: 1,"IP",,,0,0

and this is from a brand new Huawei E169 that's first time plugged in:
at+cgdcont?
+CGDCONT: 1,"IP","","0.0.0.0",0,0


For those who don't know, APN is the string after "IP".


And here's an example how the Huawei behaves when I specified CID 2:
at+cgdcont=2,"IP","foobaar"
OK
Aat+cgdcont?
+CGDCONT: 1,"IP","","0.0.0.0",0,0
+CGDCONT: 2,"IP","foobaar","0.0.0.0",0,0

and note, this is after I unplugged and plugged the thing back in:
at+cgdcont?
+CGDCONT: 1,"IP","","0.0.0.0",0,0
+CGDCONT: 2,"IP","foobaar","0.0.0.0",0,0

As you can see some devices retain their setting even after a power loss
or reboot. And some do not, Like Nokias. And the situation does not
improve by the fact that some mobile phones (I've heard, not witnessed)
use the PDP Contexts also for internal browser or WAP or whatever so if
those are altered by NM there's a change that we could break some
functionality of the mobile phone.

So it's not safe to blindly override CID 1 or anything else for that
matter.




Now let's talk about APNs, shall we. Once again you hear a lot of "just
use 'internet' as APN and you should be ready to go". Well that might be
true for some providers, but just for example take a look provider
information of India[3].

On most cases if you use wrong APN you just don't get connected. No true
harm there except frustrated users. But now a more disturbing scenario;
some service providers have multiple billing methods for mobile
broadband. There's at least constant monthly fees, pay-per-Mb and even
pay-per-time. The selection between these is done by selecting a
specific APN. 

Just think for a minute here if we just blindly issue *99* and that's a
pay-per-Mb APN (CID 1) when the user thinks he has constant monthly fee
(CID 2). Or "internet" is the pay-per-Mb APN of users service provider.
Or we break the users phone by overriding CID 1 with something.




Okay. Enough hot air. Now some concrete solutions.

on nm-connection-editor:
 * remove the dial number entry and move the APN entry to it's place
 * under the hood set gsm.number to ### (see below for explanation)

NM (or modem-manager):
 * when mobile broadband connection is activated check the dial number
 * if the number is not ###, just dial the damn thing
   - don't set APN or anything. User clearly knows which CID is correct.
 * if the number is ### do something smart
   - first check if specified APN is already assigned to some CID 
     - get the list using "AT+CGDCONT?" and iterate that
     - if found, use that CID for dialing (ATD*99***<cid>#)
   - if the APN is not set then try to append it to the list
     - AT+CGDCONT=<cids+1>,"IP",<apn>
     - check that it really was appended to the list and use it
   - if appending fails for some reason just override CID 1
     - AT+CGDCONT=1,"IP",<apn>
     - good fail safe would be storing the original CID to a file so
that it can be manually restored if we manage to break someones phone.

Any thoughts or comments? 
just my 0,02€.

 -- Antti


[1] my reference:
google for "AT Commands Reference Guide" or,
http://www.telit.co.it/data/uploads_EN/products/80000ST10025a_AT_Commands_Reference_Guide_r2(1).pdf

[2] http://bugzilla.gnome.org/show_bug.cgi?id=525305#c4

[3] just search for "India":
http://svn.gnome.org/viewvc/mobile-broadband-provider-info/trunk/serviceproviders.xml?revision=15&view=markup

Attachment: signature.asc
Description: Digitaalisesti allekirjoitettu viestin osa



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]