Teensy 4.1 ethernet

I'm a fan of the Teensy line of microcontrollers. I have a whole pile of them for various projects. When I saw that 4.1 was combining a 600MHz processor, 1MB ram, 8MB flash, and ethernet with ieee1588/ptp, I was excited.

The ethernet connector is still a "build it yourself" sort of thing, so I ordered the parts off of Digikey and the boards off of OSH Park.

Parts waiting for assembly

The parts I got were: 0.1uF 50V 0805 capacitors, 6 pin header, rj45 with built-in magnetics, connectors, and a cable.

Soldering done

The cap goes between the center tap on the RJ45 transformers and ground, to drain any extra voltage off the lines.  Since I didn't get enough connectors or pin headers to run two wires, I decided to mount one of the jacks directly on the Teensy.

Direct mount

I angled the direct mount RJ45 so I'd have enough room to plug in the USB.  I put the jack on first and then the pin headers, which meant I don't really have enough room to reach the pins under the jack.  That will still work for what I need.

Wired

Now I have two Teensies to connect to my network.  I have an extra RJ45 board as well.

First thing I tried was the lwip_iperf example app on the Teensy.  It sends data as fast as it can to a client that I ran on another system on my network.

68Mbit/s iperf

tcptrace gave the following stats on that connection:

min/avg/max receive window advertised: 5836/5839/5840 bytes
retransmitted data packets: 0
throughput: 8568722 bytes/s (68549776 bits/s)

The RTT was around 650us.  You can exchange one full receive window full of bytes every RTT.  5840 bytes / 0.00065 seconds = 8984615 bytes/s.  So it looks like I am receiver window limited.  I changed the TCP_SND_BUF setting in lwipopts.h from 4*TCP_MSS (5840 bytes) to 8*TCP_MSS (11680 bytes) and ran iperf again.

94Mbit/s iperf

tcptrace gave the following stats:

min/avg/max receive window advertised: 11678/11679/11680 bytes
retransmitted data packets: 0
throughput: 11810315 bytes/s (94482520 bits/s)

That's as much as I would expect to get out of 100M ethernet.

Using iperf's --tradeoff test for receive speed, I had to change TCP_WND to 8*TCP_MSS to get 94Mbit/s.  These were between two systems connected directly to ethernet.  If one of them was on wifi, that would raise the latency and I'd need even larger buffers to reach full speeds.