0

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

提前致谢

4

1 回答 1

1

pcap_inject 会调用linux的流量控制层发送数据包吗?还是直接发送给设备驱动程序?

send()调用PF_PACKET 套接字。默认情况下,在这些套接字上发送的数据包会通过流量控制层;引用PF_PACKET 套接字手册页

   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 不会打开该选项。

于 2020-02-28T04:47:48.597 回答