APN Resolution and Mobile Data Session Establishment
When someone says a phone "has no data", the problem is very often an APN problem. The Access Point Name is a small string, but it decides which packet gateway serves the session, which IP pool the subscriber draws from, and which policy applies. This post explains what an APN is, how the network resolves it, and where the session setup can go wrong.
What an APN is
An APN names a network the subscriber can reach and the gateway that provides it. It has two parts:
- Network Identifier: the label the user or operator chose, such as
internetorims. This is the part you see in phone settings. - Operator Identifier: which operator's core hosts the gateway, written in a fixed format from the operator's MCC and MNC.
The full form of an APN is the two joined together. Phones normally show only the first part, because the operator identifier can be filled in by the network.
Where the APN comes from
There are two sources, and the network reconciles them:
- The subscription. The subscriber database lists the APNs a subscriber may use and marks one as the default.
- The device request. The phone may ask for a specific APN in its attach or session request, using its configured settings.
If the phone asks for an APN, the MME checks it against the subscription. If the APN is not allowed, the request is rejected. If the phone sends none, the MME uses the default from the subscription. That is why an empty or wrong APN setting on a device may either work by accident or fail outright, depending on the network's configuration.
Resolving the APN to a gateway
The MME does not have a hard-coded list of packet gateways. It builds a DNS name from the APN and looks it up. For the EPC the name has this shape:
<APN-NI>.apn.epc.mnc<MNC>.mcc<MCC>.3gppnetwork.org
The MNC is written with three digits, padded with a leading zero when the network code has only two. The DNS lookup returns records that let the MME pick a gateway, and it can prefer the one closest to the serving gateway. Here is a small helper that builds the name:
def apn_fqdn(apn_ni: str, mcc: str, mnc: str) -> str:
assert len(mcc) == 3 and mnc.isdigit() and len(mnc) in (2, 3)
mnc3 = mnc.zfill(3)
return f"{apn_ni.lower()}.apn.epc.mnc{mnc3}.mcc{mcc}.3gppnetwork.org"
# apn_fqdn("internet", "310", "26")
# -> "internet.apn.epc.mnc026.mcc310.3gppnetwork.org"
The example uses a made-up combination of numbers to show the padding. For a visited subscriber, the home network's identifiers are used when the gateway is in the home network, which is how roaming traffic finds its way back.
Session establishment in order
- The MME validates the requested APN against the subscription.
- It resolves the gateway through DNS.
- It sends a create-session request to the serving gateway, which forwards it to the packet gateway.
- The packet gateway applies policy, allocates an address and creates the session.
- The response travels back, and the MME tells the phone the session is up.
What the gateway does with the APN
The APN also acts as a key into configuration on the gateway:
- Which address pool to allocate from.
- Which DNS servers to hand to the device.
- Which policy and charging rules to attach.
- Whether traffic goes to the open internet or to a private network.
Two APNs on the same subscription can behave completely differently. A common example is one APN for internet data and another for voice over the operator's own network.
Common failures
- APN not in the subscription. The MME rejects with an error that the APN is missing or unknown.
- DNS does not resolve. A typo in the operator's DNS zone leaves the MME with no gateway to use.
- Wrong APN on the device. Especially on a phone set up by hand or moved between operators.
- Roaming policy. The subscriber has the APN at home but not when abroad.
In 5G
The same idea carries over under a different name. The Data Network Name (DNN) plays the role of the APN, and the session management function replaces much of the MME's role in choosing a user-plane function.
Takeaways
- The APN selects the gateway and the policy, and it must be permitted by the subscription.
- The name is resolved with DNS, so a broken DNS record breaks data for everyone on that APN.
- Debug "no data" by checking the APN before anything else.
About the author: I work on content and web development at eSIMCircle, a travel eSIM provider. This series comes from the engineering side of that work.
About the author
- eSIMCircle provides affordable global eSIM plans with reliable data in 200+ countries.
Comments
Join the discussionNo comments yet. Be the first to comment.
