最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c - DPDK Application keeps showing Discarded Packets - Stack Overflow

programmeradmin0浏览0评论

I am using DPDk to get packets from a Mellanox Card (ConnectX-6) Port and process them. The traffic is supposed to be 100Gbps. I am using the following thread to print statistics from the NIC

static void lcore_main_display_stats(void)
{
    struct rte_eth_xstat_name xstat_names[MAX_XSTATS];
    int retval;
    int num_xstats = 0;
    struct rte_eth_stats stats;
    struct rte_eth_xstat xstats[MAX_XSTATS];
    uint64_t prev_reading = 0;
    uint64_t current_diff = 0;


    while (MAIN_KEEP_RUNNING == main_keep_running)
    {
        fflush(stdout);
        if (PORT_ACTIVE == downlink1_port.port_status)
        {
            // Get standard statistics
            retval = rte_eth_stats_get(downlink1_port.port_id, &stats);

            // Get extended statistics names
            num_xstats = rte_eth_xstats_get_names(downlink1_port.port_id, xstat_names, MAX_XSTATS);

            // Get extended statistics
            retval = rte_eth_xstats_get(downlink1_port.port_id, xstats, num_xstats);

            current_diff = stats.ibytes - prev_reading;
            Gbps = (current_diff / 1024.0 / 1024.0 / 1024.0) * 8;
            prev_reading = stats.ibytes;
            
            // Get standard statistics
            retval = rte_eth_stats_get(downlink1_port.port_id, &stats);
            if (retval != 0)
            {
                fprintf(stderr, "Failed to get standard stats for port %u: %s\n", downlink1_port.port_id, rte_strerror(-retval));
                return;
            }

            printf("\n--- Standard Statistics ---\n");
            printf("Packets received: %" PRIu64 "\n", stats.ipackets);
            printf("Packets transmitted: %" PRIu64 "\n", stats.opackets);
            printf("Bytes received: %" PRIu64 "\n", stats.ibytes);
            printf("Giga bytes received: %f\n", ((double)stats.ibytes / 1024.0 / 1024.0 / 1024.0));
            printf("Bytes transmitted: %" PRIu64 "\n", stats.obytes);
            printf("RX errors: %" PRIu64 "\n", stats.ierrors);
            printf("TX errors: %" PRIu64 "\n", stats.oerrors);
            printf("Missed packets: %" PRIu64 "\n", stats.imissed);
            printf("Missed packets\%: %f\n", ((double)stats.imissed/stats.ipackets)*100);
            for (int i = 0; i < num_xstats; i++)
            {
                if (!strcmp("rx_phy_discard_packets", xstat_names[i].name))
                {
                    printf("%s: %" PRIu64 "\n", xstat_names[i].name, xstats[i].value);
                    printf("Discarded packet percentage: %f\%\n", ((double)xstats[i].value / stats.ipackets) * 100);
                }
            }
            printf("RX no mbuf errors: %" PRIu64 "\n", stats.rx_nombuf);
            printf("Gbps: %f \n", Gbps);
        }

        sleep(ONE_SECOND_SLEEP_TIME);
        fflush(stdout);
    }

But sometimes I can see that discarded packets are increasing each second. I have tried many possible scenarios, but I keep getting discarded packets. It is worth mentioning that the discarded packets appear when the throughput is between 70 and 85Gbps for example. And when it reaches 90Gbps is stops. At the same time missed packets keep the initial value without any increase. A sample output:

Packets received: 6113919634
Packets transmitted: 0
Bytes received: 6369429122446
Giga bytes received: 5931.993129
Bytes transmitted: 0
RX errors: 0
TX errors: 0
Missed packets: 148596
Missed packets%: 0.002430
rx_phy_discard_packets: 12258048
Discarded packet percentage: 0.200494%
RX no mbuf errors: 0
Gbps: 78.914868 

I have tried to change MTU up to 9600, but still the problem appears.

Any explanations, suggestions, or solutions for this?

发布评论

评论列表(0)

  1. 暂无评论