libpcap是否使用了linux的流控层?

Does libpcap use the traffic control layer of linux?

我正在创建一个单独的网络堆栈,我正在使用 libpcap,或者具体来说,pcap_inject 函数将数据包直接发送到 link 层。但是,当我查看 tc -s qdisc show dev eth0 命令时,我发现我发送的数据包计入从队列发送的数据包。所以我的问题是,pcap_inject是否调用linux的流控层发送数据包?还是直接发给设备驱动?

提前致谢

does pcap_inject call the traffic control layer of linux to send packets? Or does it directly send to the device driver?

它执行 send() call on a PF_PACKET socket. By default, packets sent on those sockets go through the traffic control layer; to quote the PF_PACKET socket man page:

   PACKET_QDISC_BYPASS (since Linux 3.14)
          By default, packets sent through packet sockets pass through
          the kernel's qdisc (traffic control) layer, which is fine for
          the vast majority of use cases.  For traffic generator appli‐
          ances using packet sockets that intend to brute-force flood
          the network—for example, to test devices under load in a simi‐
          lar fashion to pktgen—this layer can be bypassed by setting
          this integer option to 1.  A side effect is that packet
          buffering in the qdisc layer is avoided, which will lead to
          increased drops when network device transmit queues are busy;
          therefore, use at your own risk.

libpcap 不会打开该选项。