0

My AF-XDP userspace program is based on this tutorial: https://github.com/xdp-project/xdp-tutorial/tree/master/advanced03-AF_XDP

I am currently trying to parse ~360.000 RTP-packets per second (checking for continuous sequence numbers) but I loose around 25 per second (this means that for 25 packets the statement previous_rtp_sqnz_nmbr + 1 == current_rtp_sqnz_nmbr doesn't hold true).

So I tried to increase the number of allocated packets NUM_FRAMES from 228.000 to 328.000. With default FRAME_SIZE of XSK_UMEM__DEFAULT_FRAME_SIZE = 4096 this results in 1281Mbyte being allocated (no problem because I have 32GB of RAM) but for whatever reason, this function call:

static struct xsk_umem_info *configure_xsk_umem(void *buffer, uint64_t size)
{
    printf("Try to allocate %lu\n", size);
    struct xsk_umem_info *umem;
    int ret;

    umem = calloc(1, sizeof(*umem));
    if (!umem)
        return NULL;

    ret = xsk_umem__create(&umem->umem, buffer, size, &umem->fq, &umem->cq,
                   NULL);
    if (ret) {
        errno = -ret;
        return NULL;
    }

    umem->buffer = buffer;
    return umem;
}

fails with

Try to allocate 1343488000
ERROR: Can't create umem "Cannot allocate memory"

I don't know why? But because I know that my RTP-packets are not larger than 1500bytes, I set FRAME_SIZE 3072 so I am now at around 960Mbyte (which works without an error).

However, I am now loosing half of the received packets (this means that for 180.000 packets the previous sequence number doesn't line up with the current sequence number).

Because of this I ask the question: What is the relationship between FRAME_SIZE and the actual size of a packet? Because obviously it can not be the same.

Edit: I am using 5.4.0-4-amd64 #1 SMP Debian 5.4.19-1 (2020-02-13) x86_64 GNU/Linux and just copied the libbpf-repository from here into my code-base: https://github.com/libbpf/libbpf

So I don't know whether the error mentioned here: https://github.com/xdp-project/xdp-tutorial/issues/76 is still valid?

binaryBigInt
  • 1,526
  • 2
  • 18
  • 44
  • https://github.com/xdp-project/xdp-tutorial/issues/76 – Qeole Mar 04 '20 at 10:13
  • `FRAME_SIZE` seems to be a value which is just used to [tell how much UMEM to allocate](https://github.com/xdp-project/xdp-tutorial/blob/3a1c469cc8e7f1113452a940770a7707164e81ce/advanced03-AF_XDP/af_xdp_user.c#L200), it refers to the [UMEM frames](https://www.kernel.org/doc/html/latest/networking/af_xdp.html#umem) and not actual packet size. I don't know why you experience packet loss, though :/ – Qeole Mar 04 '20 at 10:24
  • @Qeole I am on Linux 5.4 and just copied the latest codebase from `libbpf` - do you think the error does still exist in this combination? Because it doesn't work nevertheless – binaryBigInt Mar 04 '20 at 10:26
  • Sorry, no idea :/ I haven't tried to run the sample myself. I just hoped the link could help :(. – Qeole Mar 04 '20 at 10:53
  • So, was your packet loss due to [AF_XDP steering packets only from one queue](https://stackoverflow.com/questions/60603415/af-xdp-no-packets-for-socket-with-queue-id-0-even-though-every-packet-is-redire)? Or is it unrelated and still not resolved? – Qeole Mar 12 '20 at 16:32

0 Answers0