Skip to content

Why Does Ping Reach 34 ms via lwIP but Stay Under 1 ms on W6300 Hardware Sockets?

Arduino sketches bring up W55RP20-EVB-Pico and W6300-EVB-Pico2 over MACRAW and lwIP; the author's tests compare polling-driven RTT with hardware sockets.

Grace_Koo

Published November 20, 2026 · © MIT license (MIT)

Original author: ramtucOriginal source (new tab)

Why Does Ping Reach 34 ms via lwIP but Stay Under 1 ms on W6300 Hardware Sockets?

Components

Hardware components

Project description

📚 Context: ramtuc/wiznet-pico-basics — first-step code for the W55RP20-EVB-Pico and the W6300-EVB-Pico2, written for two electwork.net articles: DHCP, ping and a TCP echo, plus IPv6 link-local on the W6300. Each board is brought up twice, once with Arduino sketches on arduino-pico 6.3.1 and once with WIZnet's official C examples, and ping and echo times are measured on both.


01 — Two boards, one first step

W55RP20-EVB-Pico: the W55RP20 next to the RJ45 jack, BOOTSEL and RUN buttons by the USB-C connector. Photo: electwork.net, by the repository author
W55RP20-EVB-Pico: the W55RP20 next to the RJ45 jack, BOOTSEL and RUN buttons by the USB-C connector. Photo: electwork.net, by the repository author
ItemW55RP20-EVB-PicoW6300-EVB-Pico2
MCURP2040 inside the W55RP20 packageRP2350, separate chip
EthernetW5500 inside the W55RP20 packageW6300, separate chip
Link to the chipSPI: CS 20, SCK 21, MISO 22, MOSI 23, INT 24, RST 25QSPI: INT 15, CS 16, SCLK 17, IO0–IO3 18–21, RST 22
Bus clock in the C examples50 MHz PIO SPI, system clock 200 MHz37.5 MHz PIO QSPI in Quad mode, system clock 150 MHz
Free GPIOGP0–15 and GP26–28, 19 pinsGP0–14 and GP26–28, 18 pins
IP handled by the chipIPv4IPv4 and IPv6
Socket buffers32 KB over 8 sockets64 KB over 8 sockets

The repository holds the two Arduino sketches and a PowerShell client. Each sketch takes an address by DHCP, prints the MAC and IP, and echoes TCP port 5000; the W6300 sketch also lists its IPv6 addresses. The hardware-socket runs use WIZnet-PICO-C's dhcp_dns and loopback examples as shipped, with only the loopback's static IP changed to fit the LAN.


02 — Why both buses come from PIO

Neither board can use the RP2040 or RP2350 hardware SPI for its chip:

BoardWhy hardware SPI does not fit
W55RP20-EVB-PicoGPIO20–23 reach only SPI0, which expects MISO on 20 and SCK on 22; the package wires SCK to 21 and MISO to 22
W6300-EVB-Pico2The RP2350 QSPI block (QMI) drives only the dedicated flash pins, which carry the 2 MB flash; the PL022 SPI blocks have one data line each; even Single mode does not match SPI0's pin map on GPIO15–22

So a PIO state machine generates the bus. In WIZnet-PICO-C, wizchip_qspi_pio.pio holds Single, Dual and Quad programs that differ in one line, out pins, 1, 2 or 4.


03 — Same board, two network paths

The official C examples talk to the chip's hardware sockets and the chip runs TCP/IP; the Arduino path runs lwIP on the RP2040 or RP2350, polled every 20 ms, and moves raw frames to a chip used as MAC and PHY
The official C examples talk to the chip's hardware sockets and the chip runs TCP/IP; the Arduino path runs lwIP on the RP2040 or RP2350, polled every 20 ms, and moves raw frames to a chip used as MAC and PHY
 Arduino, arduino-pico 6.3.1Official C examples, WIZnet-PICO-C
Chip modeMACRAW, raw Ethernet framesHardware sockets (TOE)
TCP/IP runs inlwIP on the RP2040 or RP2350The W5500 or W6300
APIWiFiClient, WiFiServersocket(), listen(), send(), recv()
Connectionsset by the lwIP configuration8 sockets

arduino-pico's lwIP_w55rp20 opens socket 0 in MACRAW mode and gives it the whole 16 KB TX and RX buffers. The author treats the two as choices, not a ranking: the Arduino path keeps the Pico W Wi-Fi API, and the socket path keeps TCP/IP off the MCU's CPU and RAM.


04 — The ping that shows who answered

ping RTT: on the W55RP20-EVB-Pico lwIP replies in 2 to 21 ms with an average of 13, on the W6300-EVB-Pico2 in 2 to 34 ms with an average of 12, both at TTL 255; through the chips' hardware sockets every reply is under 1 ms at TTL 128
ping RTT: on the W55RP20-EVB-Pico lwIP replies in 2 to 21 ms with an average of 13, on the W6300-EVB-Pico2 in 2 to 34 ms with an average of 12, both at TTL 255; through the chips' hardware sockets every reply is under 1 ms at TTL 128
Board and pathping RTT, min / avg / maxTTLTCP echo, first and second run
W55RP20, Arduino (lwIP)2 / 13 / 21 ms25521 ms, 41 ms
W55RP20, C loopback (chip)all under 1 ms12812 ms, 1 ms
W6300, Arduino (lwIP)2 / 12 / 34 ms25519 ms, 22 ms
W6300, C loopback (chip)all under 1 ms128about 10 ms

Each case is 10 pings with no loss. arduino-pico runs lwIP from a 20 ms poll, so a ping that reaches the chip waits until the next poll before lwIP builds the reply; the author attributes the RTT spread to that 0–20 ms wait. Through hardware sockets the chip answers ICMP by itself. The TTL tells the two apart: 255 is lwIP's IP_DEFAULT_TTL, 128 comes from the chip, and Windows ping prints it on every line.


05 — Why the sketch needs delay(50)

while (client.connected()) {
  int n = client.available();
  if (n > 0) {
    uint8_t buf[128];
    n = client.read(buf, min(n, (int)sizeof(buf)));
    client.write(buf, n);   // send back what arrived, in one write
  }
  delay(50);                // leave room for the 20 ms lwIP poll
}
Loop on the W55RP20-EVB-PicoResult
Echo byte by byte with no pauseOnly the first byte returns, closed never prints, ARP and ping stop until the loop exits
delay(1) per passStill stalls
delay(50) per pass, one write per chunkEcho, disconnect and ping all work
One line per connection, then stop()Works, but carries one line per connection

A comment in arduino-pico's LwipEthernet.cpp notes that frequent lwIP calls from user code postpone the poll, and client.connected() and client.available() are such calls. Writing byte by byte also meets Nagle, which WiFiClient enables by default, and the PC's delayed ACK. lwipPollingPeriod(ms) changes the period, though the arduino-pico docs warn that too short a period can lock up Ethernet.


06 — What the W6300 adds

W6300-EVB-Pico2: the RP2350 and the W6300 as two chips between the UDE RJ45 jack and USB-C. Photo: electwork.net, by the repository author
W6300-EVB-Pico2: the RP2350 and the W6300 as two chips between the UDE RJ45 jack and USB-C. Photo: electwork.net, by the repository author
ItemW5500W6300
IPIPv4IPv4 and IPv6 dual stack
Offloaded protocolsTCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoESame plus IPv6, ICMPv6, MLDv1
Host busSPIQSPI (Single, Dual, Quad) or 8-bit parallel
Buffers16 KB TX + 16 KB RX, 2 KB per socket by default32 KB TX + 32 KB RX, 4 KB per socket by default
Commands without a socketnoneARP, PING, ICMPv6 (DAD, NS, RS, NA)
IP fragmentationnot supportednot supported

TCP and UDP sockets also get dual modes that accept IPv4 and IPv6 on one socket. On the Arduino path lwIP builds the link-local address from the MAC (EUI-64) and runs DAD; the sketch printed FE80::D4C7:62FF:FE4C:A0A5 (preferred) inside its 3 s wait, and a ULA from the router's advertisement appeared about two minutes later. The C examples write a fixed address, fe80::208:dcff:fe57:5725, into the chip's LLAR register, so two boards running the same example on one LAN need their MAC and LLA changed.


07 — Where it stands

  • The articles cover the first step only. Throughput, CPU load and the QSPI mode comparison are left for the author's follow-up articles.
  • The repository holds the Arduino sketches and the PowerShell client; the hardware-socket numbers come from the WIZnet-PICO-C examples.
  • MIT license.

Two boards, two paths, and one TTL value that tells you which side answered the ping.


08 — Similar Projects on WIZnet Makers


Q&A

Q. In what mode is the WIZnet chip used? Both. The Arduino sketches run it in MACRAW under lwIP; the C examples use its hardware sockets (TOE).

Q. Does the RTT gap mean lwIP is slow? The author attributes the spread to the 20 ms poll in arduino-pico rather than to lwIP itself. Throughput and CPU load are left for follow-up articles.

Q. How do I build the sketches? arduino-pico 6.3.1 with the board rp2040:rp2040:wiznet_55rp20_evb_pico or rp2040:rp2040:wiznet_6300_evb_pico2. For IPv6 on the W6300, set Tools > IP/Bluetooth Stack to IPv4 + IPv6.

Q. Can it be reused? Yes, under the MIT license.


Original Link: https://github.com/ramtuc/wiznet-pico-basics

Sketches: arduino/w55rp20-evb-pico/dhcp_tcp_echo/, arduino/w6300-evb-pico2/dhcp_tcp_echo_ipv6/ · Client: tools/tcp_echo_client.ps1 · Articles: W55RP20-EVB-Pico basics, W6300-EVB-Pico2 basics (Japanese)

Documents

  • Arduino sketches and PowerShell echo client

Comments

Comments