0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 =====================================
0004 The Linux kernel GTP tunneling module
0005 =====================================
0006
0007 Documentation by
0008 Harald Welte <laforge@gnumonks.org> and
0009 Andreas Schultz <aschultz@tpip.net>
0010
0011 In 'drivers/net/gtp.c' you are finding a kernel-level implementation
0012 of a GTP tunnel endpoint.
0013
0014 What is GTP
0015 ===========
0016
0017 GTP is the Generic Tunnel Protocol, which is a 3GPP protocol used for
0018 tunneling User-IP payload between a mobile station (phone, modem)
0019 and the interconnection between an external packet data network (such
0020 as the internet).
0021
0022 So when you start a 'data connection' from your mobile phone, the
0023 phone will use the control plane to signal for the establishment of
0024 such a tunnel between that external data network and the phone. The
0025 tunnel endpoints thus reside on the phone and in the gateway. All
0026 intermediate nodes just transport the encapsulated packet.
0027
0028 The phone itself does not implement GTP but uses some other
0029 technology-dependent protocol stack for transmitting the user IP
0030 payload, such as LLC/SNDCP/RLC/MAC.
0031
0032 At some network element inside the cellular operator infrastructure
0033 (SGSN in case of GPRS/EGPRS or classic UMTS, hNodeB in case of a 3G
0034 femtocell, eNodeB in case of 4G/LTE), the cellular protocol stacking
0035 is translated into GTP *without breaking the end-to-end tunnel*. So
0036 intermediate nodes just perform some specific relay function.
0037
0038 At some point the GTP packet ends up on the so-called GGSN (GSM/UMTS)
0039 or P-GW (LTE), which terminates the tunnel, decapsulates the packet
0040 and forwards it onto an external packet data network. This can be
0041 public internet, but can also be any private IP network (or even
0042 theoretically some non-IP network like X.25).
0043
0044 You can find the protocol specification in 3GPP TS 29.060, available
0045 publicly via the 3GPP website at http://www.3gpp.org/DynaReport/29060.htm
0046
0047 A direct PDF link to v13.6.0 is provided for convenience below:
0048 http://www.etsi.org/deliver/etsi_ts/129000_129099/129060/13.06.00_60/ts_129060v130600p.pdf
0049
0050 The Linux GTP tunnelling module
0051 ===============================
0052
0053 The module implements the function of a tunnel endpoint, i.e. it is
0054 able to decapsulate tunneled IP packets in the uplink originated by
0055 the phone, and encapsulate raw IP packets received from the external
0056 packet network in downlink towards the phone.
0057
0058 It *only* implements the so-called 'user plane', carrying the User-IP
0059 payload, called GTP-U. It does not implement the 'control plane',
0060 which is a signaling protocol used for establishment and teardown of
0061 GTP tunnels (GTP-C).
0062
0063 So in order to have a working GGSN/P-GW setup, you will need a
0064 userspace program that implements the GTP-C protocol and which then
0065 uses the netlink interface provided by the GTP-U module in the kernel
0066 to configure the kernel module.
0067
0068 This split architecture follows the tunneling modules of other
0069 protocols, e.g. PPPoE or L2TP, where you also run a userspace daemon
0070 to handle the tunnel establishment, authentication etc. and only the
0071 data plane is accelerated inside the kernel.
0072
0073 Don't be confused by terminology: The GTP User Plane goes through
0074 kernel accelerated path, while the GTP Control Plane goes to
0075 Userspace :)
0076
0077 The official homepage of the module is at
0078 https://osmocom.org/projects/linux-kernel-gtp-u/wiki
0079
0080 Userspace Programs with Linux Kernel GTP-U support
0081 ==================================================
0082
0083 At the time of this writing, there are at least two Free Software
0084 implementations that implement GTP-C and can use the netlink interface
0085 to make use of the Linux kernel GTP-U support:
0086
0087 * OpenGGSN (classic 2G/3G GGSN in C):
0088 https://osmocom.org/projects/openggsn/wiki/OpenGGSN
0089
0090 * ergw (GGSN + P-GW in Erlang):
0091 https://github.com/travelping/ergw
0092
0093 Userspace Library / Command Line Utilities
0094 ==========================================
0095
0096 There is a userspace library called 'libgtpnl' which is based on
0097 libmnl and which implements a C-language API towards the netlink
0098 interface provided by the Kernel GTP module:
0099
0100 http://git.osmocom.org/libgtpnl/
0101
0102 Protocol Versions
0103 =================
0104
0105 There are two different versions of GTP-U: v0 [GSM TS 09.60] and v1
0106 [3GPP TS 29.281]. Both are implemented in the Kernel GTP module.
0107 Version 0 is a legacy version, and deprecated from recent 3GPP
0108 specifications.
0109
0110 GTP-U uses UDP for transporting PDUs. The receiving UDP port is 2151
0111 for GTPv1-U and 3386 for GTPv0-U.
0112
0113 There are three versions of GTP-C: v0, v1, and v2. As the kernel
0114 doesn't implement GTP-C, we don't have to worry about this. It's the
0115 responsibility of the control plane implementation in userspace to
0116 implement that.
0117
0118 IPv6
0119 ====
0120
0121 The 3GPP specifications indicate either IPv4 or IPv6 can be used both
0122 on the inner (user) IP layer, or on the outer (transport) layer.
0123
0124 Unfortunately, the Kernel module currently supports IPv6 neither for
0125 the User IP payload, nor for the outer IP layer. Patches or other
0126 Contributions to fix this are most welcome!
0127
0128 Mailing List
0129 ============
0130
0131 If you have questions regarding how to use the Kernel GTP module from
0132 your own software, or want to contribute to the code, please use the
0133 osmocom-net-grps mailing list for related discussion. The list can be
0134 reached at osmocom-net-gprs@lists.osmocom.org and the mailman
0135 interface for managing your subscription is at
0136 https://lists.osmocom.org/mailman/listinfo/osmocom-net-gprs
0137
0138 Issue Tracker
0139 =============
0140
0141 The Osmocom project maintains an issue tracker for the Kernel GTP-U
0142 module at
0143 https://osmocom.org/projects/linux-kernel-gtp-u/issues
0144
0145 History / Acknowledgements
0146 ==========================
0147
0148 The Module was originally created in 2012 by Harald Welte, but never
0149 completed. Pablo came in to finish the mess Harald left behind. But
0150 doe to a lack of user interest, it never got merged.
0151
0152 In 2015, Andreas Schultz came to the rescue and fixed lots more bugs,
0153 extended it with new features and finally pushed all of us to get it
0154 mainline, where it was merged in 4.7.0.
0155
0156 Architectural Details
0157 =====================
0158
0159 Local GTP-U entity and tunnel identification
0160 --------------------------------------------
0161
0162 GTP-U uses UDP for transporting PDU's. The receiving UDP port is 2152
0163 for GTPv1-U and 3386 for GTPv0-U.
0164
0165 There is only one GTP-U entity (and therefor SGSN/GGSN/S-GW/PDN-GW
0166 instance) per IP address. Tunnel Endpoint Identifier (TEID) are unique
0167 per GTP-U entity.
0168
0169 A specific tunnel is only defined by the destination entity. Since the
0170 destination port is constant, only the destination IP and TEID define
0171 a tunnel. The source IP and Port have no meaning for the tunnel.
0172
0173 Therefore:
0174
0175 * when sending, the remote entity is defined by the remote IP and
0176 the tunnel endpoint id. The source IP and port have no meaning and
0177 can be changed at any time.
0178
0179 * when receiving the local entity is defined by the local
0180 destination IP and the tunnel endpoint id. The source IP and port
0181 have no meaning and can change at any time.
0182
0183 [3GPP TS 29.281] Section 4.3.0 defines this so::
0184
0185 The TEID in the GTP-U header is used to de-multiplex traffic
0186 incoming from remote tunnel endpoints so that it is delivered to the
0187 User plane entities in a way that allows multiplexing of different
0188 users, different packet protocols and different QoS levels.
0189 Therefore no two remote GTP-U endpoints shall send traffic to a
0190 GTP-U protocol entity using the same TEID value except
0191 for data forwarding as part of mobility procedures.
0192
0193 The definition above only defines that two remote GTP-U endpoints
0194 *should not* send to the same TEID, it *does not* forbid or exclude
0195 such a scenario. In fact, the mentioned mobility procedures make it
0196 necessary that the GTP-U entity accepts traffic for TEIDs from
0197 multiple or unknown peers.
0198
0199 Therefore, the receiving side identifies tunnels exclusively based on
0200 TEIDs, not based on the source IP!
0201
0202 APN vs. Network Device
0203 ======================
0204
0205 The GTP-U driver creates a Linux network device for each Gi/SGi
0206 interface.
0207
0208 [3GPP TS 29.281] calls the Gi/SGi reference point an interface. This
0209 may lead to the impression that the GGSN/P-GW can have only one such
0210 interface.
0211
0212 Correct is that the Gi/SGi reference point defines the interworking
0213 between +the 3GPP packet domain (PDN) based on GTP-U tunnel and IP
0214 based networks.
0215
0216 There is no provision in any of the 3GPP documents that limits the
0217 number of Gi/SGi interfaces implemented by a GGSN/P-GW.
0218
0219 [3GPP TS 29.061] Section 11.3 makes it clear that the selection of a
0220 specific Gi/SGi interfaces is made through the Access Point Name
0221 (APN)::
0222
0223 2. each private network manages its own addressing. In general this
0224 will result in different private networks having overlapping
0225 address ranges. A logically separate connection (e.g. an IP in IP
0226 tunnel or layer 2 virtual circuit) is used between the GGSN/P-GW
0227 and each private network.
0228
0229 In this case the IP address alone is not necessarily unique. The
0230 pair of values, Access Point Name (APN) and IPv4 address and/or
0231 IPv6 prefixes, is unique.
0232
0233 In order to support the overlapping address range use case, each APN
0234 is mapped to a separate Gi/SGi interface (network device).
0235
0236 .. note::
0237
0238 The Access Point Name is purely a control plane (GTP-C) concept.
0239 At the GTP-U level, only Tunnel Endpoint Identifiers are present in
0240 GTP-U packets and network devices are known
0241
0242 Therefore for a given UE the mapping in IP to PDN network is:
0243
0244 * network device + MS IP -> Peer IP + Peer TEID,
0245
0246 and from PDN to IP network:
0247
0248 * local GTP-U IP + TEID -> network device
0249
0250 Furthermore, before a received T-PDU is injected into the network
0251 device the MS IP is checked against the IP recorded in PDP context.