>
Home5G NRNAS — Non-Access StratumNAS Overview
✉️ NAS — Non-Access StratumBeginner

NAS Overview (5GMM & 5GSM) in 5G NR

The layer between UE and AMF/SMF that the gNB only relays — mobility and session management.

📚 3GPP-basedTS 24.501

Non-Access Stratum (NAS) is the conversation the UE has directly with the core network — not with the radio. The gNB carries these messages but cannot read the important parts of them: NAS is defined in TS 24.501 and runs end-to-end between the UE and the AMF/SMF, staying transparent to the RAN. If the Access Stratum is how a phone talks to a cell, NAS is how a subscriber talks to the network that owns their SIM.

Introduction

NAS is the control-plane protocol suite (TS 24.501) that manages a UE as a subscriber rather than as a radio occupant of a cell. It runs end-to-end between the UE and the 5G core — the AMF for mobility and the SMF for sessions — and it is the layer that decides whether a UE is even allowed onto the network, what identity it carries, which keys protect its signalling, and which data pipes it may open.

NAS is in play across the whole UE lifecycle. It runs the moment a UE powers on (Registration), whenever it needs to resume from idle (Service Request), whenever the core wants to update it (Configuration Update), and every time an application asks for connectivity (PDU Session procedures). Below NAS sits the Access Stratum (RRC/PDCP/RLC/MAC/PHY) that actually moves the bytes; NAS simply hands sealed messages to the AS to carry.

Because NAS is a small number of distinct procedures — registration, authentication, security-mode, service request, session management — and each carries a small, well-defined set of IEs, a NAS problem almost always localises to one message and one field. That is why reading NAS message by message, header field by header field, turns a vague "device won't attach / won't get data" complaint into a specific, testable fault.

Why NAS is needed

💡

In plain words: think of the gNB as the front desk of a hotel and the core network as the hotel's central management. When you check in you hand the desk a sealed envelope addressed to management — your ID, your booking, your payment. The desk clerk carries it to the back office but never opens it; only management verifies who you are and what room (data pipe) you get. NAS is that sealed envelope: the UE talks to the core through the gNB, but only the core reads it.

Subscriber-level functions — identity, authentication, mobility state, reachability, and data sessions — must be owned by the core and stay independent of which cell the UE happens to be camped on. If those functions lived in the RAN, every handover would risk dropping the security context or the sessions. Keeping them in NAS decouples the subscriber relationship from the radio: the cell can change underneath the UE hundreds of times, and its identity, keys, and PDU sessions ride through untouched.

What

A control-plane protocol between the UE and the 5G core (the AMF for mobility, the SMF for sessions), specified in TS 24.501. To the gNB it is an opaque container it must forward but must not parse.

Why

Subscriber-level functions — identity, authentication, mobility state, data sessions — must be owned by the core, independent of which cell or gNB the UE happens to be on. Keeping them in NAS decouples them from the radio, so a handover between cells never disturbs the subscriber's security context or its sessions.

How

NAS messages ride inside AS containers: over the air in the RRC dedicatedNAS-Message IE, and between gNB and AMF in the NGAP NAS-PDU IE. The gNB copies the bytes from one container to the other without inspecting them.

What NAS Is, and What the gNB Sees

Everything the UE and RAN exchange to set up and steer the radio link — RRCReconfiguration, measurement reports, scheduling grants, HARQ — is the Access Stratum (AS). NAS is the layer above that: the signalling that manages the UE as a subscriber of the network rather than as an occupant of a particular cell. Registering to the network, being authenticated, being handed a temporary identity, being paged, and opening a data pipe are all NAS jobs. The gNB never terminates NAS; it only relays it as an opaque blob of bytes.

The clean separation is deliberate. Because NAS security keys live only at the UE and the AMF, the gNB physically cannot decrypt or forge NAS content even if it wanted to. That is what "transparent" means here: the RAN is a trusted courier for a sealed envelope, and the envelope is opened only at the two endpoints. This is also why the same NAS context survives as the UE moves between gNBs — the radio changes underneath, but the subscriber-to-core relationship does not.

🎯

One-liner: AS = UE↔gNB (radio). NAS = UE↔core (subscriber). The gNB is a courier for NAS, not a reader of it.

Two Protocols: 5GMM and 5GSM

TS 24.501 splits NAS into two sub-protocols, and every NAS message announces which one it belongs to through the Extended protocol discriminator in its header. The two never compete; one carries the other.

5GMM — 5GS Mobility Management. This is the UE-to-AMF protocol. It handles the UE as a mobile subscriber: the Registration procedure (initial, mobility, periodic), Deregistration, the Service Request procedure, primary authentication, NAS security establishment, paging response, and the Configuration Update procedure the AMF uses to push new parameters — a fresh 5G-GUTI, an updated allowed NSSAI, a new TAI list. 5GMM owns the UE's reachability, its location tracking, and its security state. Everything a UE must do before it can move any user data at all is a 5GMM job.

5GSM — 5GS Session Management. This is the UE-to-SMF protocol, and it manages data connectivity end to end: PDU Session Establishment, PDU Session Modification, and PDU Session Release. The subtlety is that the SMF is not directly reachable by the UE. Every 5GSM message is placed inside a NAS container and carried by a 5GMM transport message — typically the UL NAS TRANSPORT / DL NAS TRANSPORT pair — which the AMF receives on the N1 interface and relays to the correct SMF over the service-based core. So 5GSM never talks to the network on its own; it always rides on 5GMM, and the AMF acts as the router that maps a PDU session ID and S-NSSAI to an SMF.

Aspect5GMM5GSM
Full name5GS Mobility Management5GS Session Management
PurposeMobility, identity, security, reachabilityPDU session lifecycle (data pipes)
UE peer in the coreAMF (directly)SMF (relayed by the AMF over N1)
Example messagesRegistration Request, Authentication Request, Security Mode Command, Service Request, Configuration Update CommandPDU Session Establishment Request, PDU Session Modification Command, PDU Session Release Command
Transport on the wireCarried directly in RRC / NGAP containersWrapped in a 5GMM transport message, then routed to the SMF
Who routes itTerminates at the AMFAMF forwards to SMF using PDU session ID + S-NSSAI
EPD value (header)0x7E (5GS mobility management)0x2E (5GS session management)

✅ Debugging steps

  • Read the first octet of the NAS PDU: Extended Protocol Discriminator = 0x7E means 5GMM, 0x2E means 5GSM. A message decoded against the wrong discriminator is a decoder misconfiguration, not a real fault.
  • For any 5GSM problem, first confirm the 5GMM transport that should carry it (UL/DL NAS TRANSPORT) actually appears; a missing PDU session outcome is often a 5GMM transport failure, not a 5GSM one.
  • Check that the AMF had a valid PDU session ID + S-NSSAI to route on — without them the AMF cannot pick an SMF.

⚠ Common causes of failure

  • 5GSM message rejected because it arrived without a usable 5GMM transport wrapper or routing header, so the AMF cannot dispatch it to an SMF.
  • Requested S-NSSAI not in the UE's Allowed NSSAI, so the 5GMM layer refuses to transport the session request.
  • Discriminator/decoder mismatch making a valid message look malformed in the trace.

The NAS Message Header

Every NAS message begins with a small, fixed preamble that tells the receiver three things: which sub-protocol it is, whether and how it is security-protected, and what the message actually is. Getting these first bytes right is what lets the same parser handle a plaintext Registration Request and a fully ciphered PDU Session Establishment Accept.

The first field is the Extended Protocol Discriminator (EPD). In 5G this is a full octet (extended from the 4-bit protocol discriminator of LTE), and its value selects 5GMM or 5GSM. The second field is the Security Header Type, a 4-bit value that says whether the message is a plain NAS message, integrity-protected only, or integrity-protected and ciphered — and whether it is a special "security mode" message. When the security header indicates a protected message, the message is actually a security-protected NAS message: an outer wrapper carrying the Message authentication code (MAC) and a Sequence number, inside which the real plaintext NAS message (with its own EPD and message type) is nested and possibly ciphered.

After the security header comes the Message type octet, which names the procedure — Registration request, Authentication request, Service request, and so on — followed by the message's information elements. 5GSM messages additionally carry a PDU session identity and a Procedure transaction identity up front, because a UE can juggle several PDU sessions and several in-flight session procedures at once.

Header fieldSizeWhat it does
Extended Protocol Discriminator1 octetSelects the sub-protocol: 5GMM or 5GSM.
Security Header Type4 bitsPlain, integrity-protected, or integrity-protected-and-ciphered (plus the security-mode variants).
Message authentication code (MAC)4 octetsPresent only in security-protected messages; the integrity tag over the message.
Sequence number1 octetPresent only in security-protected messages; the low 8 bits of the NAS COUNT.
Message type1 octetIdentifies the specific NAS procedure/message.
PDU session identity / PTI1 octet each5GSM only — identify which session and which session-management transaction.

The Security Header Type enumeration is small and worth memorising, because it is what a decoder uses to decide whether to attempt integrity/decipher:

Security Header Type (4-bit)Meaning
0000Plain NAS message, not security-protected.
0001Integrity-protected.
0010Integrity-protected and ciphered.
0011Integrity-protected with new 5G NAS security context (Security Mode Command).
0100Integrity-protected and ciphered with new 5G NAS security context (Security Mode Complete).
📘

Spec note: a protected NAS message is a container. The outer Security Header Type plus MAC plus Sequence number wrap an inner, complete NAS message that starts again with its own EPD and message type. That inner message is the part that gets ciphered.

Reading a NAS header in the logs

Most 5G protocol analysers decode the NAS PDU straight out of the RRC or NGAP container. The header fields above are the first thing to eyeball: they tell you which sub-protocol, whether protection is on, and where in the COUNT stream this message sits.

Representative NAS decode (analyser-style) — illustrative, values vary by vendor/build:

NAS-5GS Security protected NAS 5GS message Extended protocol discriminator : 5GMM (0x7e) Security header type : Integrity protected and ciphered (2) Message authentication code : 0x9f3c1ab7 Sequence number : 5 Plain NAS 5GS message (deciphered): Extended protocol discriminator : 5GMM (0x7e) Message type : Registration accept (0x42) 5GS registration result : 3GPP access 5G-GUTI : 262 01 ... 0x c1a2b3d4
FieldMeaningExampleCheck
Extended protocol discriminatorWhich NAS sub-protocol this PDU belongs to.5GMM (0x7e)Must match the procedure you expect; 0x2e would be 5GSM.
Security header typeWhether/how the message is protected.Integrity protected and cipheredAfter NAS SMC, messages should be type 2; a plaintext message here means security was not activated.
Message authentication code32-bit integrity tag over the message.0x9f3c1ab7If the receiver recomputes a different MAC, the message is dropped — suspect key/COUNT mismatch.
Sequence numberLow 8 bits of NAS COUNT.5Must advance monotonically per direction; a repeat/gap points at replay or a lost message.
Message typeWhich NAS procedure this is.Registration acceptConfirms you are decoding the right message in the flow.

✅ Debugging steps

  • Confirm the outer Security Header Type matches the phase of the call: plaintext is only expected before NAS SMC; after it, messages should be integrity-protected and ciphered.
  • If the decoder shows "MAC failure" or cannot decipher, check that the analyser has the right keys / that UE and AMF agree on the NAS COUNT.
  • Verify the Sequence number increments by one per direction; a jump suggests a dropped message earlier in the flow.

⚠ Common causes of failure

  • MAC verification failure — wrong K_NASint, desynchronised NAS COUNT, or a genuinely tampered message; the receiver discards it silently.
  • Decode errors from parsing a ciphered inner message as plaintext (analyser lacking keys) — looks like corruption but is not.
  • Sequence-number wrap not tracked, so the NAS overflow counter drifts and every subsequent MAC fails.

NAS Has Its Own Security

NAS protection is entirely separate from AS (PDCP) protection, and it comes first. Once primary authentication succeeds it yields the anchor key K_AMF, from which the UE and AMF each derive a dedicated NAS security context: an integrity key K_NASint and a ciphering key K_NASenc. These protect NAS signalling end-to-end between the UE and the AMF. The gNB, which only relays bytes, holds none of them.

Two properties matter. Integrity protection is mandatory for NAS once a security context is active — every protected NAS message carries a 32-bit Message authentication code, and a message that fails the integrity check is discarded. Ciphering is optional in the sense that a "null" ciphering algorithm exists, but confidentiality is normally applied. The chosen algorithms come from the operator-configured priority list and are one integrity algorithm (NIA0/1/2/3) and one ciphering algorithm (NEA0/1/2/3).

Which security context is in use is identified by the ngKSI (Key Set Identifier), a small value the UE and AMF exchange so they can point at the same K_AMF without re-running authentication on every connection. If the UE presents an ngKSI the AMF still recognises, they can reactivate the existing native context; otherwise a fresh authentication is triggered.

Replay and freshness are handled by the NAS COUNT, a 24-bit counter kept separately for uplink and downlink. It is built from a Sequence number (the low 8 bits, carried in the header) plus a NAS overflow counter (the high 16 bits, kept locally and incremented when the sequence number wraps). The full COUNT feeds both the integrity and ciphering algorithms as an input, so every message is cryptographically bound to its position in the stream and a replayed message computes the wrong MAC.

The context is switched on by the NAS Security Mode Command procedure: the AMF sends an integrity-protected Security Mode Command carrying the selected algorithms, the ngKSI, the UE security capabilities it received (echoed back so the UE can detect tampering), and the ABBA parameter; the UE replies with a Security Mode Complete that is both integrity-protected and ciphered with the new keys. The ABBA (Anti-Bidding-down Between Architectures) parameter binds the derived key to a specific set of security features, which — together with the AMF echoing the UE's advertised capabilities — is precisely the anti-bidding-down defence: an attacker cannot silently strip the UE down to weaker algorithms, because any alteration of the capabilities makes the integrity check fail.

Security elementRole
K_AMFAnchor NAS key from authentication; parent of the NAS keys.
K_NASint / K_NASencNAS integrity and ciphering keys, held only at UE and AMF.
ngKSIIdentifies the active security context so it can be reused without re-authenticating.
NAS COUNT24-bit freshness counter = overflow (16b) + sequence number (8b), per direction; anti-replay input.
ABBAAnti-bidding-down parameter binding the key to a feature set.
NAS SMCSecurity Mode Command/Complete exchange that activates the context.
🔐

Key split: K_NASenc/K_NASint protect UE↔AMF NAS. The K_gNB-derived keys protect UE↔gNB AS (PDCP/RRC). Both descend from K_AMF but live in different nodes — NAS security is established before AS keys even exist.

✅ Debugging steps

  • Confirm the NAS Security Mode Command and Security Mode Complete both appear; without them, no protected NAS message can be verified.
  • Check that the Security Mode Command echoes exactly the UE security capabilities the UE sent in Registration Request; a mismatch is either tampering or a stale capability copy.
  • Verify the selected NEA/NIA pair is one both sides support and is not NEA0/NIA0 (null) outside emergency scenarios.
  • If protected messages start failing mid-call, compare UE and AMF NAS COUNT — a desync makes every MAC wrong.

⚠ Common causes of failure

  • Security Mode Reject from the UE because the echoed capabilities differ from what it advertised (bidding-down detection).
  • No common algorithm between UE and AMF policy lists, so security cannot be activated.
  • NAS COUNT desynchronisation (missed message, overflow-counter drift) causing persistent MAC failures.
  • Stale ngKSI pointing at a context the AMF has purged, forcing an unexpected re-authentication.

5GMM and 5GSM States

The UE's 5GMM state has two independent dimensions, and it pays to keep them apart. Registration status tells you whether the network holds a mobility context for the UE. In 5GMM-DEREGISTERED the AMF has no valid registration — the UE must run the Registration procedure before it can use any service. In 5GMM-REGISTERED the UE has a valid registration, a 5G-GUTI, an allowed NSSAI, and a registration area (a TAI list), and can request services.

Connection status tells you whether a NAS signalling connection currently exists over N1. In 5GMM-IDLE (which maps to RRC_IDLE or RRC_INACTIVE on the radio) there is no active N1 NAS connection and the UE is reachable only via paging. In 5GMM-CONNECTED (mapping to RRC_CONNECTED) an N1 connection is up and NAS messages flow immediately. A registered UE toggles between these substates across its stay: a Service Request moves an idle registered UE back to CONNECTED to resume data or answer a page, and network inactivity releases it back to IDLE.

5GSM has its own, per-session state machine that lives inside the SMF and the UE in parallel: PDU SESSION INACTIVE when no session exists, transitioning through PDU SESSION ACTIVE PENDING during establishment to PDU SESSION ACTIVE once the user-plane is up, and back through PDU SESSION INACTIVE PENDING on release. Because 5GSM rides on 5GMM, a session can be ACTIVE while the 5GMM connection is IDLE — the pipe is provisioned but suspended until a Service Request reconnects it.

StateLayerMeaningTypical trigger to leave
5GMM-DEREGISTERED5GMMNo mobility context in the AMFRegistration Request (initial)
5GMM-REGISTERED5GMMValid registration held by the AMFDeregistration Request
5GMM-IDLE5GMM substateNo N1 NAS connection; paged when neededService Request / paging
5GMM-CONNECTED5GMM substateActive N1 NAS connectionInactivity → release to IDLE
PDU SESSION INACTIVE5GSMNo PDU session for this IDPDU Session Establishment Request
PDU SESSION ACTIVE5GSMSession established, user-plane provisionedPDU Session Release Command

Several NAS timers police these transitions, and they show up constantly in traces: T3510 guards Registration Request (waiting for Accept/Reject), T3550 guards Registration Complete, T3512 is the periodic-registration timer whose expiry drives periodic registration, and T3502/T3511 govern retry back-off after a registration attempt fails. A stuck state is almost always a timer that expired without the expected peer message.

✅ Debugging steps

  • Establish the two dimensions separately: is the UE registered (does the AMF hold a context?) and is it connected (is N1 up?). They fail for different reasons.
  • If a registered UE cannot be reached, confirm it is in 5GMM-IDLE and that paging is being sent in the right TAI list.
  • If a PDU session shows ACTIVE but no data flows, check whether the UE is 5GMM-IDLE — the user plane may simply be suspended pending a Service Request.
  • Correlate a stuck transition with the governing timer (T3510/T3550/T3512) to see which peer message never arrived.

⚠ Common causes of failure

  • UE stuck in 5GMM-DEREGISTERED after a Registration Reject with a permanent 5GMM cause (e.g. illegal UE / illegal ME).
  • Implicit deregistration because a periodic registration (T3512) was missed while the UE was unreachable.
  • Paging not reaching the UE because it moved outside its registered TAI list without a mobility registration.
  • Data stall mistaken for a session failure when the real state is ACTIVE + 5GMM-IDLE, needing only a Service Request.

How NAS Rides the Radio and N2

Because NAS terminates at the UE and the AMF, the gNB in between must pass it along without interpreting it — and it does so through two different carriers depending on which leg of the path the message is on.

On the radio (Uu): the UE and gNB use RRC (TS 38.331). A NAS message travels inside the RRC IE dedicatedNAS-Message, carried on a Signalling Radio Bearer — SRB1/SRB2 once the connection is up. In the uplink it rides in ULInformationTransfer; in the downlink in DLInformationTransfer; and during connection setup it is piggybacked on RRCSetupComplete, where the initial Registration Request or Service Request travels alongside the RRC completion.

Between gNB and AMF (N2): the two use NGAP (TS 38.413). The gNB lifts the NAS bytes out of the RRC container and drops them into the NGAP NAS-PDU IE, carried in INITIAL UE MESSAGE for the first message of a connection and thereafter in UPLINK NAS TRANSPORT and DOWNLINK NAS TRANSPORT. A 5GSM message rides this whole path folded inside its 5GMM transport wrapper, and only once the AMF unwraps it does the payload continue to the SMF over the service-based interface.

LegProtocolCarrier IE / messageDirection
Uu (setup)RRC (TS 38.331)RRCSetupCompletededicatedNAS-MessageUL, first NAS
Uu (steady)RRCULInformationTransfer / DLInformationTransferUL / DL
N2 (first)NGAP (TS 38.413)INITIAL UE MESSAGENAS-PDUgNB → AMF
N2 (steady)NGAPUPLINK/DOWNLINK NAS TRANSPORTNAS-PDUgNB ↔ AMF
UE gNB AMF SMF Uu — RRC (TS 38.331) N2 — NGAP (TS 38.413) SBI (N11) RRC dedicatedNAS-Message 5GMM Registration Request NGAP INITIAL UE MESSAGE NAS-PDU carries the same bytes ULInformationTransfer 5GMM UL NAS TRANSPORT (5GSM inside) NGAP UPLINK NAS TRANSPORT AMF relays 5GSM to SMF (PDU session) end-to-end NAS association — gNB is transparent, AMF routes 5GSM onward
Figure 1. NAS transport: 5GMM travels UE→gNB in RRC, gNB→AMF in NGAP; a nested 5GSM message is unwrapped at the AMF and relayed to the SMF.

Reading NAS transport in the logs

On the RAN–core boundary, the same NAS PDU appears twice: once inside RRC on the air trace and once inside NGAP on the N2 trace. Confirming the bytes are identical on both sides is the fastest way to prove the gNB relayed faithfully.

Representative gNB N2 trace — illustrative, values vary by vendor/build:

NGAP TX: INITIAL UE MESSAGE ranUeNgapId=41, rrcEstablishmentCause=mo-Signalling NAS-PDU (len=91): 7e004179... (5GMM Registration request, SUCI) userLocationInfo: TAI plmn=26201 tac=0x000123 NGAP RX: DOWNLINK NAS TRANSPORT amfUeNgapId=1007, ranUeNgapId=41 NAS-PDU (len=35): 7e00... (5GMM Authentication request)
FieldMeaningExampleCheck
NAS-PDUThe opaque NAS bytes the gNB relays.7e0041...Must byte-match the dedicatedNAS-Message on the Uu trace; any difference means the relay corrupted it.
ranUeNgapId / amfUeNgapIdThe N2 association IDs binding this UE's context at gNB and AMF.41 / 1007Both must be consistent across the connection; a mismatch fragments the UE context.
rrcEstablishmentCauseWhy the RRC connection (carrying the first NAS msg) was set up.mo-SignallingShould match the NAS reason (e.g. registration vs service request).
userLocationInfo / TAIServing cell TAI reported to the AMF.plmn=26201AMF uses it for registration-area and paging decisions; a wrong TAC misroutes paging.

✅ Debugging steps

  • Cross-check the NAS-PDU bytes on the NGAP trace against the dedicatedNAS-Message on the RRC trace — they must be identical.
  • Confirm the first NAS message rides INITIAL UE MESSAGE and later ones ride UPLINK/DOWNLINK NAS TRANSPORT; the wrong carrier means a context/state problem.
  • Verify the correct SRB (SRB1/SRB2) is up on the air for the phase of the call.

⚠ Common causes of failure

  • NAS message never reaches the AMF because INITIAL UE MESSAGE was not sent (RRC setup failed, or the N2 association is down).
  • Wrong AMF selected (bad NAS routing / GUAMI), so the UE's context cannot be found.
  • SRB not established, so DLInformationTransfer cannot deliver a downlink NAS message.

LTE ↔ NR

🔀

LTE ↔ NR: LTE NAS (TS 24.301) splits into EMM (mobility) and ESM (session) — the direct ancestors of 5GMM and 5GSM. The biggest structural changes in 5G: the protocol discriminator grew from 4 bits to a full-octet Extended Protocol Discriminator; the permanent identity is now concealed as a SUCI (the LTE IMSI was sent in the clear), and the temporary identity is the 5G-GUTI rather than the GUTI; the anchor NAS key is K_AMF rather than K_ASME, with the added ABBA anti-bidding-down binding; and 5GSM is decoupled onto the SMF and always tunnelled through 5GMM transport, whereas LTE ESM terminated at the MME alongside EMM. In LTE, an EPS bearer was the unit of connectivity; in 5G, a PDU session made of QoS flows replaces it.

Summary

NAS is the UE↔core control plane, and it decomposes cleanly: 5GMM owns mobility, identity, security, and reachability with the AMF; 5GSM owns data pipes with the SMF and always rides inside 5GMM transport. Read any NAS problem in this order — header (EPD, Security Header Type, COUNT) tells you which protocol and whether protection is on; the message type tells you the procedure; the IEs carry the decision.

The two things that trip people up most are the transport indirection (a session failure is often a 5GMM-transport or SMF-selection failure, not a 5GSM one) and the orthogonal states (registered vs connected; a session can be ACTIVE while the UE is IDLE). Keep those two facts in mind and most "won't attach / won't get data" tickets resolve to a specific message and field.

Interview quickfire

Q&A Interview quickfire

Q. If the gNB cannot read NAS, how does it forward it correctly?

A. It does not need to read the payload — it only moves the container. On the air it carries NAS inside the RRC dedicatedNAS-Message IE; toward the core it copies those bytes into the NGAP NAS-PDU IE (in INITIAL UE MESSAGE / UPLINK NAS TRANSPORT, and back via DOWNLINK NAS TRANSPORT). NAS security keys live only at the UE and AMF, so the gNB neither can nor needs to interpret the content.

Q. What is the difference between 5GMM and 5GSM, and how do they relate on the wire?

A. 5GMM manages mobility, identity and security with the AMF; 5GSM manages PDU sessions with the SMF. They are told apart by the Extended Protocol Discriminator (0x7e vs 0x2e). A 5GSM message is never sent alone — it is placed in a NAS container inside a 5GMM transport message, which the AMF routes to the correct SMF using the PDU session ID and S-NSSAI.

Q. Which NAS protections are mandatory, and how is replay prevented?

A. Integrity protection is mandatory once a security context is active — every protected message carries a 32-bit MAC and a failing check causes the message to be discarded. Ciphering is normally applied but a null algorithm exists. Replay is prevented by the 24-bit NAS COUNT (overflow counter plus sequence number, per direction), which feeds the integrity and ciphering algorithms so a replayed message computes the wrong MAC.

Q. What does the ngKSI do, and what stops a bidding-down attack?

A. The ngKSI identifies the active NAS security context (and its K_AMF) so the UE and AMF can reuse it without re-running authentication. Bidding-down is blocked by the NAS SMC: the AMF echoes the UE's advertised security capabilities and includes the ABBA parameter under integrity protection, so any attempt to strip the UE to weaker algorithms breaks the MAC and is detected.

Q. Can a UE be 5GMM-REGISTERED and 5GMM-IDLE at the same time?

A. Yes — the two dimensions are orthogonal. Registration status says the AMF holds a valid context (with a 5G-GUTI and allowed NSSAI); connection status says whether an N1 NAS connection is currently up. A registered UE with no traffic sits in IDLE and is paged when needed; a Service Request brings it back to CONNECTED, and a PDU session can stay ACTIVE across that idle period.

Where to go next

NAS is the frame; the procedures fill it in. See how a UE joins and is authenticated, how it opens a data pipe, and where all these keys come from.