DPDK发送自定义pkt但收不到

DPDK send customized pkt but fail to receive

我正在尝试使用dpdk 发送自定义包,但我发现某些包结构会导致无法接收。例如,我这样定义包结构:

union my_pkt{
   struct hdr{
       uint32_t id;
       uint32_t name_len;
       uint64_t tsc;
       uint8_t name[100];
   }__attribute__((__packed__)) pkt_hdr;
   char buff[500];
};

我的服务器运行 dpdk 只能收到第一批pkts,但是rte_eth_tx_burst() 的返回值显示已经发送了更多的包。
但是,如果我修改结构如下:

union my_pkt{
   struct hdr{
       uint32_t id;
       uint32_t name_len;
       uint32_t tsc[2];//modify this line
       uint8_t name[100];
   }__attribute__((__packed__)) pkt_hdr;
   char buff[500];
};

发送和接收都正常。两个结构之间的唯一区别是 uint64_t 时间戳被替换为由 2 个项目组成的 uint32_t 数组。我调试了 i40e 驱动程序代码,但无法理解哪里出错了。

有人可以帮助我吗?谢谢!

虽然从您的描述中不清楚,但您可能应该在缓冲区的开头添加一个以太网 header,即:

union my_pkt{
   struct hdr{
       struct ether_hdr; // Ethernet header
       uint32_t id;
       uint32_t name_len;
       uint64_t tsc;
       uint8_t name[100];
   }__attribute__((__packed__)) pkt_hdr;
   char buff[500];
};

然后用 destination/source 个 MAC 填充它并输入您的代码。