What hardware are you using to transmit those short packets? Which manufacturer's silicon lets you do that?
My assertion that "Ethernet packets have to be padded" had me worried. So I went trying to find some proper references. The "usual place" (Wikipedia) says that "Runts are shorter than the minimum size and are rejected" and that CSMA/CD requires the minimum length to detect collisions.
Ethernet - Wikipedia
That's not good enough for me. It took hours to finally get "the right answer", but I'll leave that until later. Since we're all running 100MHz full-duplex Ethernet through Switches, nothing should be colliding any more, so that justification for the minimum packet length doesn't exist. So maybe it isn't true any more.
The original specifications for Ethernet is IEEE 802.3. I've got a bound copy of
IEEE 802.3 (Draft, 1984)
4.4 Specific Implementations
4.4.2 Allowable Implementations
4.4.2.1 Parameterized Values
The following table identifies the parameters
that shall be used in the 10 MB/s implementation
(type 10BASE5) of a CSMA/CD procedure.
minFrameSize 512 bits (64 octets)
That (yes, 1984!) applies to 10BASE5 (the old "Yellow Hose Ethernet", but not specifically to anything else. But I have the printed 10BASE-T Supplement, and it says:
IEEE 802.3 Supplement Section 13 and 14 (10BASE-T) (1991)
Revisions to 802.3 1190 edition
4.4.2.1 Parameterized Values
In first sentence, delete "(type 10BASE5)".
Instead of saying "the Parameters for this standard are..." or "They're the same as the 10BASE5 ones" it says "Delete this bit in the original so by omission it now applies to the new standard". IEEE Pokemoni - "Gotta Catch 'Em All" as they all reference each other!
I could spend a few days (and a thousand dollars or more) getting all of the updates to the standards and seeing which bits of other standards they delete, but that's no fun: See how many there are:
Ethernet physical layer - Wikipedia
Instead I'll look at the Ethernet sources and see how the drivers enforce (or not) the minimum packet length there.
Linux Sources:
include/linux/if_ether.h
#define ETH_ALEN 6 /* Octets in one ethernet addr */
#define ETH_HLEN 14 /* Total octets in header. */
#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
#define ETH_DATA_LEN 1500 /* Max. octets in payload */
#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
#define ETH_FCS_LEN 4 /* Octets in the FCS */
net/core/pktgen.c: pkt_dev->min_pkt_size = ETH_ZLEN;
As for where the above definition is used, it gets VERY interesting. The drivers are all in "drivers/net/ethernet", and some of the drivers use the above definition, but others don't. Specifically I can find 171 references, some of which look like this:
3com/3c501.c: if (len < ETH_ZLEN)
3com/3c501.c: pad = ETH_ZLEN - len;
3com/typhoon.c: * it with zeros to ETH_ZLEN for us.
8390/axnet_cs.c: u8 packet[ETH_ZLEN];
8390/axnet_cs.c: send_length = max(length, ETH_ZLEN);
8390/axnet_cs.c: memset(packet, 0, ETH_ZLEN);
8390/lib8390.c: char buf[ETH_ZLEN];
8390/lib8390.c: if (skb->len < ETH_ZLEN) {
8390/lib8390.c: memset(buf, 0, ETH_ZLEN); /* more efficient t
8390/lib8390.c: send_length = ETH_ZLEN;
amd/7990.c: len = (skblen <= ETH_ZLEN) ? ETH_ZLEN : skblen;
amd/7990.c: if (skb->len < ETH_ZLEN)
amd/7990.c: memset((void *)&ib->tx_buf[entry][0], 0, ETH_ZLEN);
amd/a2065.c: if (skb_padto(skb, ETH_ZLEN))
amd/a2065.c: skblen = max_t(unsigned, skb->len, ETH_ZLEN);The controllers that use the definition include "3com: 3, 8390: 7, amd: 28, atheros: 4, brocade: 1, fujitsu: 9, hp: 1, i825xx: 32". The ones that DON'T reference this include "adaptec, adi, aeroflex, alteon, apple, broadcom, cadence, calxeda, chelsio, cirrus, cisco, davicom, dec, dlink, freescale, fujitsu, hp, i825xx".
Checking one of the ones that does include this reveals the following comment and code:
drivers/net/ethernet/amd/lance.c:
/* The old LANCE chips doesn't automatically pad buffers to min. size. */
if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) {"Automatically pad"??? Note none of the Freescale Ethernet drivers reference the limit. That's because:
MCF52259 Reference Manual, FEC Chapter:
21.5.7 FEC Frame Transmission
Transmit logic automatically pads short frames (if the TC bit in the transmit buffer descriptor
for the end of frame buffer is set).
You don't have to worry about padding in a FEC driver because it is an automatic function of the hardware. You can't send a short packet through a FEC. Well, you can - you just have to calculate the CRC yourself and clear the "TC" bit. But you're not meant to.
So if you're sending "short packets" on the wire, you're using some other manufacturer's Ethernet chip to do this. One that looks like it requires the Driver to do the padding. And you're not doing that.
> It took hours to finally get "the right answer", but I'll leave that until later.
Which is now. If you're running full duplex, why do you still need to obey the minimum packet length? Because Ethernet is backwards-compatible and has never changed the standard to "orphan" previous generations. You can still plug an old (or small and cheap, and usually old) device that only supports 10BASE-T into a switch, and it will still work. The switch will receive the packet at 100MHz and transmit it unchanged out the other port at 10MHz. It expects the "minimum packet length for collision" to still work. You can ever bridge back to 10BASE2 and even a 2.5km long 10BASE5 network, and they still should work. That means the 100BASET (or even Gigabit) packet your hardware sends may end up as-is, same length and with the same CRC on a 1990 era coaxial Ethernet. And it still has to have that padding for the collision detection to work there. That's why it is in the standard, and why all current hardware is allowed to assume it is there.
You could argue that the chips should be able to handle short packets if you aren't bridging back to old networks, but the chips were neither designed OR TESTED with short packets, Anything not tested doesn't work. Anything tested still doesn't work, but you're meant to try and fix it.
Tom