[2024]Digital Global Overview Report 2024 Meltwater.pdf
Using GTP on Linux with libgtpnl
1. Using GTP on Linux
( libgtpnl )
SRv6 Consortium, Data plane Study Group
Kentaro Ebisawa | Twitter: @ebiken
Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 1
2. • Linux has kernel level implementation of GTP tunnel endpoint
• Since Linux Kernel 4.7
• “drivers/net/gtp.c”
• https://github.com/torvalds/linux/blob/master/Documentation/networking/gtp.txt
• https://osmocom.org/projects/linux-kernel-gtp-u/wiki
• Features
• Encap / Decap of GTP-U (GTP User Plane)
• GTP-U v0 [GSM TS 09.60] and v1 [3GPP TS 29.281]
• IPv4 only : No GTP over IPv6 nor IPv6 user traffic on GTP payload
Since GTPv0 is deprecated, this slide will only show GTPv1
Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 2
GTP on Linux
3. • You can use netlink to configure GTP Kernel module.
• The most simple way is to use tools in libgtpnl
• No need to run control plane software.
• http://git.osmocom.org/libgtpnl/
• https://osmocom.org/projects/linux-kernel-gtp-u/wiki/Libgtpnl
Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 3
How to configure GTP-U on Linux
4. Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 4
Building libgtpnl
> Install prerequisites
$ sudo apt install libmnl-dev autoconf libtool
> Clone source code, configure and build
$ git clone git://git.osmocom.org/libgtpnl.git
$ cd libgtpnl
libgtpnl$ autoreconf –fi
libgtpnl$ ./configure
libgtpnl$ make
libgtpnl$ sudo make install
libgtpnl$ sudo ldconfig
> Check gtp-link and gtp-tunnel are built
libgtpnl$ sudo -s
libgtpnl# cd tools
libgtpnl/tools# ./gtp-link
Usage: ./gtp-link <add|del> <device>
libgtpnl/tools# ./gtp-tunnel
./gtp-tunnel <add|delete|list> [<options,...>]
> If LIBMNL error happens during ./configure, do below.
./configure: line 2950: syntax error near unexpected token `LIBMNL,'
./configure: line 2950: `PKG_CHECK_MODULES(LIBMNL, libmnl >= 1.0.0)’
$ whereis libmnl
libmnl: /usr/lib/x86_64-linux-gnu/libmnl.a /usr/lib/x86_64-linux-
gnu/libmnl.so /usr/local/lib/libmnl.so /usr/local/lib/libmnl.la
/usr/include/libmnl
$ ldd /usr/local/lib/libmnl.so
linux-vdso.so.1 (0x00007fffdadf9000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6f9af5d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6f9b554000)
> make sure you run autoreconf again before running ./configure
libgtpnl$ autoreconf –fi
libgtpnl$ ./configure
5. Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 5
Configure GTP endpoints inside netns
netns: default netns: ns2
veth1
172.0.0.1/24
veth2
172.0.0.2/24
gtp1
(gtp device)
gtp2
(gtp device)
lo (loopback)
172.99.0.2/32
lo (loopback)
172.99.0.1/32
TEID# 100
TEID#200
TEID# 100
TEID#200
$ sudo –s
ip link add veth1 type veth peer name veth2
ip addr add 172.0.0.1/24 dev veth1
ip link set veth1 up
ip addr add 172.99.0.1/32 dev lo
> Create gtp device
./gtp-link add gtp1
> Open a new console and configure tunnel (PDP session)
./gtp-tunnel add gtp1 v1 200 100 172.99.0.2 172.0.0.2
ip route add 172.99.0.2/32 dev gtp1
$ sudo –s
ip netns add ns2
ip link set veth2 netns ns2
ip netns exec ns2 ip addr add 172.0.0.2/24 dev veth2
ip netns exec ns2 ip link set veth2 up
ip netns exec ns2 ip addr add 172.99.0.2/32 dev lo
ip netns exec ns2 ip link set lo up
> Create gtp device
ip netns exec ns2 ./gtp-link add gtp2
> Open a new console and configure tunnel (PDP session)
ip netns exec ns2 ./gtp-tunnel add gtp2 v1 100 200 172.99.0.1 172.0.0.1
ip netns exec ns2 ip route add 172.99.0.1/32 dev gtp2
6. Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 6
command to configuration mapping (gtp1 => gtp2)
netns: default netns: ns2
veth1
172.0.0.1/24
veth2
172.0.0.2/24
gtp1
(gtp device)
gtp2
(gtp device)
lo (loopback)
172.99.0.2/32
lo (loopback)
172.99.0.1/32
TEID# 100
TEID#200
TEID# 100
TEID#200
./gtp-tunnel add gtp1 v1 200 100 172.99.0.2 172.0.0.2
./gtp-tunnel add <gtp device> <v1> <i_tei> <o_tei> <ms-addr> <sgsn-addr>
gtp device
i_tei
o_tei sgsn-addr
ms-addr
output TEID
input TEID
Tunnel Endpoint
MS: Mobile Station
(UE in LTE)
Packet with dst IP = <ms-addr> will be encapsulated in
GTP packet with dst IP = <sgsn-addr> and TEID = <o_tei>
7. Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 7
Confirm tunnel (PDP session) configuration
netns: default netns: ns2
veth1
172.0.0.1/24
veth2
172.0.0.2/24
gtp1
(gtp device)
gtp2
(gtp device)
lo (loopback)
172.99.0.2/32
lo (loopback)
172.99.0.1/32
TEID# 100
TEID#200
TEID# 100
TEID#200
libgtpnl/tools# ./gtp-tunnel list
version 1 tei 200/100 ms_addr 172.99.0.2 sgsn_addr 172.0.0.2
libgtpnl/tools# ip netns exec ns2 ./gtp-tunnel list
version 1 tei 100/200 ms_addr 172.99.0.1 sgsn_addr 172.0.0.1
8. Using GTP on Linux (libgtpnl) | SRv6 Consortium, Data plane Study Group | 2018/12/31 (rev 0) 8
GTP Packet Dump
netns: default netns: ns2
veth1
172.0.0.1/24
veth2
172.0.0.2/24
gtp1
(gtp device)
gtp2
(gtp device)
lo (loopback)
172.99.0.2/32
lo (loopback)
172.99.0.1/32
TEID# 100
TEID#200
TEID# 100
TEID#200
# ping 172.99.0.2
ICMP echo request
ICMP echo reply