Search code examples
paddingethernetarp

ARP messages padding with zeroes.. sometimes


So, I'm trying to implement a TCP/IP stack in software as a learning experience. I have noticed using a packet sniffer that ARP messages are padded with zeroes... usually.

A quick Google search says that these zeroes are required (something about 46-byte Ethernet payload).. and another one says that this padding is "variable" and implies that it is optional.

What am I missing? Why are these zeroes there in the first place, and how do I know if I should skip an extra 18 bytes before the next packet comes in.

EDIT: Upon further research, it seems that the few packets without the padding are in fact malformed according to the Ethernet spec. Unfortunately, that doesn't help me, as I still have to deal with malformed packets.


Solution

  • Alright, I finally resolved this issue: it never occurred to me that there was a layer in between the Ethernet cable itself and the Ethernet MAC-address header.

    I'm not working with Ethernet cables, of course, but I am working with a packet sniffer that printed a newline after every packet.

    A simple incomingdata.split("\n").slice(1).join("\n") after processing each packet was sufficient to resolve the bug in all cases!