  Fifth-generation (5G) networks enable a variety of use cases that require
differentiated connectivity, e.g., Ultra-Reliable and Low-Latency
Communications (URLLC), enhanced Mobile Broadband (eMBB), and massive Machine
Type Communication (mMTC). To explore the full potential of these use cases, it
is mandatory to understand the communication along with the 5G network segments
and architecture components. User Equipment (UE), Radio Access Network (RAN),
and 5G Core (5GC) are the main components that support these new network
concepts and paradigms. 3rd Generation Partnership Project has recently
published Release 16, including the protocols used to communicate between RANs
and 5GC, i.e., Non-Access Stratum (NAS) and NG Application Protocol (NGAP). The
main goal of this work is to present a comprehensive tutorial about NAS and
NGAP specifications using a didactic and practical approach. The tutorial
describes the protocol stacks and aspects of the functionality of these
protocols in 5G networks, such as authentication and identification procedures,
data session establishment, and resource allocation. Moreover, we review the
message flows related to these protocols in UE and Next Generation Node B
(gNodeB) registration. To illustrate the concepts presented in the tutorial, we
developed the my5G Tester: a 5GC tester that implements NAS and NGAP for
evaluating three open-source 5GC projects using a black-box testing
methodology.
