LaForge's home page (Posts about gprs)https://laforge.gnumonks.org/blog/tags/gprs.atom2022-06-21T07:49:57ZHarald WelteNikolaOsmocom.org GTP-U kernel implementation merged mainlinehttps://laforge.gnumonks.org/blog/20160526-gtp-kernel/2016-05-26T12:00:00+02:002016-05-26T12:00:00+02:00Harald Welte<p>Have you ever used <em>mobile data</em> on your phone or using Tethering?</p>
<p>In packet-switched cellular networks (aka <em>mobile data</em>) from GPRS to
EDGE, from UMTS to HSPA and all the way into modern LTE networks, there
is a tunneling protocol called GTP (<a class="reference external" href="https://en.wikipedia.org/wiki/GPRS_Tunnelling_Protocol">GPRS Tunneling Protocol</a>).</p>
<p>This was the first cellular protocol that involved transport over
TCP/IP, as opposed to all the ISDN/E1/T1/FrameRelay world with their
weird protocol stacks. So it should have been something super easy to
implement on and in Linux, and nobody should have had a reason to run a
proprietary GGSN, ever.</p>
<p>However, the cellular telecom world lives in a different universe, and to
this day you can be safe to assume that all production GGSNs are
proprietary hardware and/or software :(</p>
<p>In 2002, Jens Jakobsen at Mondru AB released the initial version of
<a class="reference external" href="http://osmocom.org/projects/openggsn">OpenGGSN</a>, a userspace
implementation of this tunneling protocol and the GGSN network element.
Development however ceased in 2005, and we at the Osmocom project
thus adopted OpenGGSN maintenance in 2016.</p>
<p>Having a userspace implementation of any tunneling protocol of course
only works for relatively low bandwidth, due to the scheduling and
memory-copying overhead between kernel, userspace, and kernel again.</p>
<p>So OpenGGSN might have been useful for early GPRS networks where the
maximum data rate per subscriber is in the hundreds of kilobits, but it
certainly is not possible for any real operator, particularly not at
today's data rates.</p>
<p>That's why for decades, all commonly used IP tunneling protocols have
been implemented inside the Linux kernel, which has some tunneling
infrastructure used with tunnels like IP-IP, SIT, GRE, PPTP, L2TP and
others.</p>
<p>But then again, the cellular world lives in a universe where Free and
Open Source Software didn't exit until OpenBTS and OpenBSC changed all o
that from 2008 onwards. So nobody ever bothered to add GTP support to
the in-kernel tunneling framework.</p>
<p>In 2012, I started an <a class="reference external" href="https://laforge.gnumonks.org/blog/20160211-netdevconf-gtp/">in-kernel implementation of GTP-U</a> (the user
plane with actual user IP data) as part of my work at <a class="reference external" href="http://sysmocom.de/">sysmocom</a>. My former netfilter colleague and current
netfilter core team leader Pablo Neira was contracted to bring it
further along, but unfortunately the customer project funding the effort
was discontinued, and we didn't have time to complete it.</p>
<p>Luckily, in 2015 Andreas Schultz of <a class="reference external" href="http://travelping.com/">Travelping</a> came around and has forward-ported the old
code to a more modern kernel, fixed the numerous bugs and started to
test and use it. He also kept pushing Pablo and me for review and
submission, thanks for that!</p>
<p>Finally, in May 2016, the code was merged into the mainline kernel,
and now every upcoming version of the Linux kernel will have a fast and
efficient in-kernel implementation of GTP-U. It is configured via
netlink from userspace, where you are expected to run a corresponding
daemon for the control plane, such as either OpenGGSN, or the new GGSN +
PDN-GW implementation in Erlang called <a class="reference external" href="https://github.com/travelping/ergw">erGW</a>.</p>
<p>You can find the kernel code at <a class="reference external" href="https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/gtp.c">drivers/net/gtp.c</a>,
and the userspace netlink library code (libgtpnl) at <a class="reference external" href="http://git.osmocom.org/libgtpnl/">git.osmocom.org</a>.</p>
<p>I haven't done actual benchmarking of the performance that you can get
on modern x86 hardware with this, but I would expect it to be the same
of what you can also get from other similar in-kernel tunneling
implementations.</p>
<p>Now that the cellular industry has failed for decades to realize how
easy and little effort would have been needed to have a fast and
inexpensive GGSN around, let's see if now that other people did it for
them, there will be some adoption.</p>
<p>If you're interested in testing or running a GGSN or PDN-GW and become
an early adopter, feel free to reach out to Andreas, Pablo and/or me.
The <a class="reference external" href="https://lists.osmocom.org/mailman/admin/osmocom-net-gprs">osmocom-net-gprs mailing list</a> might be a good way to discuss further development and/or testing.</p>Progress on the Linux kernel GTP codehttps://laforge.gnumonks.org/blog/20151108-kernel-gtp/2015-11-08T00:00:00+01:002015-11-08T00:00:00+01:00Harald Welte<p>It is always sad if you start to develop some project and then never get
around finishing it, as there are too many things to take care in
parallel. But then, days only have 24 hours...</p>
<p>Back in 2012 I started to write some generic Linux kernel GTP tunneling
code. GTP is the <a class="reference external" href="https://en.wikipedia.org/wiki/GPRS_Tunnelling_Protocol">GPRS Tunneling Protocol</a>, a protocol
between core network elements in GPRS networks, later extended to be
used in UMTS and even LTE networks.</p>
<p>GTP is split in a control plane for management and the user plane
carrying the actual user IP traffic of a mobile subscriber. So if
you're reading this blog via a cellular interent connection, your data
is carried in GTP-U within the cellular core network.</p>
<p>To me as a former Linux kernel networking developer, the user plane of
GTP (GTP-U) had always belonged into kernel space. It is a tunneling
protocol not too different from many other tunneling protocols that
already exist (GRE, IPIP, L2TP, PPP, ...) and for the user plane, all it
does is basically add a header in one direction and remove the header in
the other direction. User data, particularly in networks with many
subscribers and/or high bandwidth use.</p>
<p>Also, unlike many other telecom / cellular protocols, GTP is an IP-only
protocol with no E1, Frame Relay or ATM legacy. It also has nothing to
do with SS7, nor does it use ASN.1 syntax and/or some exotic encoding
rules. In summary, it is nothing like any other GSM/3GPP protocol, and
looks much more of what you're used from the IETF/Internet world.</p>
<p>Unfortunately I didn't get very far with my code back in 2012, but
luckily Pablo Neira (one of my colleagues from netfilter/iptables days)
picked it up and brought it along. However, for some time it has been
stalled until recently it was thankfully <a class="reference external" href="http://lists.osmocom.org/pipermail/openbsc/2015-October/000585.html">picked up by Andreas Schultz</a>
and now receives some attention and discussion, with the clear intention
to finish + submit it for mainline inclusion.</p>
<p>The code is now kept in a git repository at
<a class="reference external" href="http://git.osmocom.org/osmo-gtp-kernel/">http://git.osmocom.org/osmo-gtp-kernel/</a></p>
<p>Thanks to Pablo and Andreas for picking this up, let's hope this is the
last coding sprint before it goes mainline and gets actually used in
production.</p>