On my system, I get much better performance by sending ethernet packets with sendp compared to sending IP packets using send.
# this gives appox 500pps on my system pe=Ether()/IP(dst="10.13.37.218")/ICMP() sendp(pe, loop=True) # this gives approx 100pps on my system pi=IP(dst="10.13.37.218")/ICMP() send(pi, loop=True)
But sending a (pre-processed) packet on the socket is faster:
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) s.bind(("eth0", 0)) pe=Ether()/IP(dst="10.13.37.218")/ICMP() data = pe.build() while True: s.send(data)
But moving pe.build () into the loop drastically slows down, hinting that this actual package building takes time.
source share