socketsRemoving padding from UDP packets in python (Linux)

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?

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

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

Related Articles
  • I am working on a project where in game telemetry data from F1 2012 is interpreted by Python and sent to an Arduino to display as a physical dashboard. F1 2012 sends the data via UDP packets at address, port 20777. I have a simple python pr
  • I'm having trouble receiving a UDP packet sent from an FPGA in a python program. I've checked similar questions and did the following: Checked that Wireshark can the see UDP packet Disabled windows firewall in PC Used sock.bind() since it's UDP packe
  • I'm trying to contact an A/V device through UDP. I send a packet to local broadcast, and it responds with information about the device. I can verify it works with Wireshark. However, I never get the response in Python, it just sits ther
  • I am trying to create a raw socket in Python that listens for UDP packets only: import socket s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_UDP) s.bind(('', 1337)) while True: print s.recvfrom(65535) This needs to be run as
  • I don't know if it the case of network config or something is wrong with my software. I have a device whose address is This device is connected directly to my pc linux server, which has address I want to send a UDP packet
  • Struggling past two days with the following questions: do the loopbacked packets go through access point back to sender if the sender is subscribed to the multicast group? Even if it's not the case, is it possible to force loopback through the AP? Al
  • Possibly related questions that seem close but don't describe my issue as I understand it: Reading all the data from a UDP socket Python UDP socket semi-randomly failing to receive Python raw socket listening for UDP packets; only half of the packets
  • I've written this ruby program to send a UDP Packet to port 16800: require 'socket' sock = sock.bind("", 47123) sock.send("Hello!", 0, "", 16800) sock.close where is my own ip address.
  • I'm sending very large (64000 bytes) datagrams. I realize that the MTU is much smaller than 64000 bytes (a typical value is around 1500 bytes, from my reading), but I would suspect that one of two things would happen - either no datagrams would make
You Might Also Like