Count number of GTP data packets on the N3 interface

Hi,
I’m trying to extract some of the 3GPP performance metrics as per 3GPP TS 28.552.
In particular I’m trying to get the number of GTP data packets on the N3 interface (3GPP TS 28.552, Sec 5.4.1.3).

I’m not clear where in the UPF src I should start looking. I can see the PDR and FAR being created. Should I look in updk or gtp5g?

Any help is appreciated.

Thanks,
Niloy

Hi @niloysh,

You can find RX and TX of gtp5g interface like below,

upfgtp: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet6 fe80::277b:9842:3c03:44c1 prefixlen 64 scopeid 0x20
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
RX packets 148 bytes 13616 (13.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 148 bytes 13616 (13.6 KB)
TX errors 6 dropped 0 overruns 0 carrier 0 collisions 0

We are doing the UL and DL drop counters for each PDR, and get it through the /proc interface.

Likewise, we are planning to add UL and DL counters for each PDR as well as increment the upfgtp interface RX and TX count.

Hi, @muthuramanecs03g

Thanks for the reply.
I can see the Tx and Rx stats for the upfgtp interface in /proc/net/dev
Could you please share some details regarding how you are getting the stats per PDR?

Also, I am trying to get the throughput per S-NSSAI, so any idea on how to correlate these PDR stats with S-NSSAI would be really helpful.

Thanks,
Niloy

Hi @niloysh,

We didn’t implement it and like to do it.

In the latest gtp5g source code, you can find /proc/gtp5g/pdr.

One of the contributors will do a drop count of UL and DL in the next few days.

You may implement or wait about three days.

Hi @niloysh,

We added the PDR drop count of UL and DL and shown through /proc/gtp5g/pdr.

You may have to get the latest code from GitHub - free5gc/gtp5g: Linux kernel module 5G GTP-U

If you want to add more things then follow up on the PDR implementation.

Hi @muthuramanecs03g,
Thanks for your work in updating the gtp5g code.

I went through the instructions on the readme.
I looked into the libgtp5gnl code and at the moment it seems to create a separate gtp5gtest interface and statically assign pdr and far in the upf_pdr_far_qer.sh script.

Could you share some details on how this can be used with the free5gc upf function? That creates an upfgtp interface. I would like to get the tx and rx stats per pdr when using the UPF function that comes with free5gc.

Thanks,
Niloy

Hi @niloysh,

You can find the libgtp5gnl source code in free5gc/NFs/upf/updk/src/third_party/libgtp5gnl.

Hi @muthuramanecs03g,

Thank you for the response.
However, I am not clear on how to get the tx and rx statistics per PDR. I’ll outline the steps I did below.

  • I updated the gtp5g source code (following the instructions here)

    Please find below the output of modinfo gtp5g

    modinfo

  • I downloaded the latest free5gc code and followed the instructions to install the latest nightly build.

  • I ran free5gc (including the UPF) along with UERANSIM. A PDU session was established, and I can list the PDRs using the libgtp5gnl scripts. This is the latest libgtp5gnl from the free5gc repo here.

    pdr

  • I sent some packets through the UERANSIM interface and now I want to see the packet Tx and Rx statistics per PDU session. For this it would be useful to get the stats per PDR.

I cannot see any gtp5g interface in /proc
If I try to create a new gtp5g interface following the instructions here (Step 3), I get the following.

libgtp5gnl

The free5gc UPF function created a upfgtp interface that is being used.
I am not sure what the relation between this upfgtp and gtp5g interface is.
I would like to see the tx and rx statistics per PDR.

Thanks for your help.

Hi @niloysh,

I cannot see any gtp5g interface in /proc
If I try to create a new gtp5g interface following the instructions here (Step 3), I get the following.

This error happened due to “bind: Address already in use”, you have to clean like below

sudo ./run.sh Clean

and also make sure there is no interface of gtp5g not exist by ifconfig cli command

The free5gc UPF function created a upfgtp interface that is being used.
I am not sure what the relation between this upfgtp and gtp5g interface is.
I would like to see the tx and rx statistics per PDR.

You should familiar with Linux kernel programming & concepts. If you are not familiar then start with understanding the gtp5g kernel module. If you want to know the relationship between free5GC/NFs/UPF and gtp5g then add more debug prints yourself in gtp5g or increase the debug prints through /proc/gtp5g/debug.

For your case, you can add TX and RX of uplink and downlink by

struct gtp5g_pdr {
struct hlist_node hlist_id;
struct hlist_node hlist_i_teid;
struct hlist_node hlist_addr;
struct hlist_node hlist_related_far;
struct hlist_node hlist_related_qer;

u16     				id;
u32     				precedence;
u8      				*outer_header_removal;

struct gtp5g_pdi      	*pdi;

u32     				*far_id;
struct gtp5g_far      	*far;

u32     				*qer_id;
struct gtp5g_qer      	*qer;

// AF_UNIX socket for buffer
struct sockaddr_un 		addr_unix;
struct socket 			*sock_for_buf;

u16     af;
struct in_addr 			role_addr_ipv4;
struct sock            	*sk;
struct net_device   	*dev;
struct rcu_head        	rcu_head;

/* Drop Count */
u64                     ul_drop_cnt;
u64                     dl_drop_cnt;

};

Add a counter in PDR like below,

u64 ul_cnt;
u64 dl_cnt;

You can refer to the ul_drop_cnt & dl_drop_cnt how it was used in the gtp5g kernel module, likewise, you have to implement your requirements.