Removing padding from UDP packets in python (Linux

2019-06-10 19:43发布

问题:

I am trying to remove null padding from UDP packets sent from a Linux computer. Currently it pads the size of the packet to 60 bytes.

I am constructing a raw socket using AF_PACKET and SOCK_RAW. I created everything from the ethernet frame header, ip header (in which I specify a packet size of less than 60) and the udp packet itself.

I send over a local network and the observed packet in wireshark has null padding. Any advice on how to overcome this issue?

回答1:

This is pretty much impossible without playing around with the Linux drivers. This isn't the best answer but it should guide anyone else looking to do this in the right direction.3

Type sudo ethtool -d eth0 to see if your driver has pad short packets enabled.