Author Topic: PSA: Wiznet chip is not a real networking stack  (Read 7840 times)

0 Members and 2 Guests are viewing this topic.

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 3811
  • Country: gb
Re: PSA: Wiznet chip is not a real networking stack
« Reply #25 on: September 23, 2026, 07:05:18 pm »
Haha, I actually meant customer (client) ;D
But yes, you're right of course, network client logging needs tools.
 

Online gamalot

  • Super Contributor
  • ***
  • Posts: 1940
  • Country: au
  • Correct my English
    • Youtube
Re: PSA: Wiznet chip is not a real networking stack
« Reply #26 on: September 23, 2026, 07:20:39 pm »
AI can now port and generate lwip based networking code for a target platform in minutes.
I'm a poet, I didn't even know it. |  https://youtube.com/@gamalot | https://github.com/gamalot
 

Offline Perkele

  • Regular Contributor
  • *
  • Posts: 77
  • Country: ie
Re: PSA: Wiznet chip is not a real networking stack
« Reply #27 on: September 23, 2026, 07:31:32 pm »
If there's a way to export data from a device, and if it is allowed to export "debugging" stuff, I'm usually dumping the network traffic in the following format:
https://wiki.wireshark.org/Development/LibpcapFileFormat
It helped me a couple of times when debugging some issues with wireless stacks.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4658
  • Country: us
Re: PSA: Wiznet chip is not a real networking stack
« Reply #28 on: September 23, 2026, 07:46:45 pm »
Quote
Claude knocked up a UDP transmit function, talking direct to the WFM200 chip, in seconds. Hardly any code, too.
Ah.  Did it include all the other bits of IP that even a UDP-only host is supposed to support (ICMP and fragmentation, for instance), or did you get exactly the sort of "non-conforming but seems to work most of the time" implementation that OP was complaining about?

I've actually got a patent claiming that a very small microcontroller could "implement tcp" by storing a sequence of packets it expects to send, and the responses it "should" get (eg in external EEPROM), essentially reducing the implementation to a pretty simple state machine.  I'm pretty happy that I never actually implemented it.  (although, it's probably just a generalization of the "header prediction" stuff that first showed up in CSLIP.)

I've also actually spent hours in a DoD contractor's office going through RFC1122/RFC1123 item by item to "verify" a product was suitable...
 

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6048
  • Country: gb
  • Doing electronics since the 1960s...
Re: PSA: Wiznet chip is not a real networking stack
« Reply #29 on: September 24, 2026, 05:39:37 am »
No. This application sends defined and very small packets over wifi. Fair point though; one could not hack it like this if doing anything more sophisticated.

It is a fair point about implementing ICMP, so the presence of the UDP emitter can be checked with a ping. Thanks for that tip.
« Last Edit: September 24, 2026, 05:45:04 am by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Online Jeroen3

  • Super Contributor
  • ***
  • Posts: 4583
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: PSA: Wiznet chip is not a real networking stack
« Reply #30 on: September 24, 2026, 05:51:33 am »
Just a few weeks ago I was diagnosing networking issues in Windows 11.
I was not expecting this to be required. But it turns out, Windows has a very long delay before it tries to retransmit. Kind of useless if you have packet loss on modbus tcp.

So now we are using UDP and do the retransmits on modbus layer.

You can always run into issues.
 

Online gerbay

  • Regular Contributor
  • *
  • Posts: 90
  • Country: tr
Re: PSA: Wiznet chip is not a real networking stack
« Reply #31 on: September 24, 2026, 06:28:57 am »
Those experiencing issues with TCP (with small packets) should ensure that the Nagle algorithm is disabled.
 

Online SiwastajaTopic starter

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: fi
Re: PSA: Wiznet chip is not a real networking stack
« Reply #32 on: September 24, 2026, 06:34:04 am »
Those experiencing issues with TCP (with small packets) should ensure that the Nagle algorithm is disabled.

Nagle exists for a reason. For generic undefined type of "issues", doing a random change is unlikely to help. Disabling Nagle makes sense when the issue, specifically, is lag in real-time application, in a network well capable of the overhead disabling it causes.

But if the network suffers from congestion, disabling the feature which reduces network use by an order of magnitude, can totally kill it.
 

Online Jeroen3

  • Super Contributor
  • ***
  • Posts: 4583
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: PSA: Wiznet chip is not a real networking stack
« Reply #33 on: September 24, 2026, 07:47:19 am »
Networking is so difficult. How do you even know about this.

Last weekend I was also trying resolve F1 stream glitches. It was that bad that I went to look at packet captures.... 50% TCP retransmits!

Turns out, live streams are distributed in short bursts. Very high payload short burst. approx 1s each.
My 1Gbe fiber passes these fine. But then, what I didn't expect, was that this burst caused loss on the ethernet layer because there was a 2.5Gbe switch in between. Which can deliver these packet at a rate a 1 Gb switch can't pass along, and can't buffer. Dropping packets. You need to enable ethernet flow control.
Unmanaged switches won't tell you this...

This didn't fix the glitches though. TCP worked as designed, even with the loss all data was there.
---
What does wiznet run as cpu nowadays?
« Last Edit: September 24, 2026, 07:49:40 am by Jeroen3 »
 
The following users thanked this post: spostma

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30262
  • Country: nl
    • NCT Developments
Re: PSA: Wiznet chip is not a real networking stack
« Reply #34 on: September 24, 2026, 08:07:29 am »
Those experiencing issues with TCP (with small packets) should ensure that the Nagle algorithm is disabled.
That is a workaround. But the cold hard fact is that the IP stack on Windows is badly broken (and has been for decades). Some devices send TCP packets twice as a workaround so Windows responds with a next packet immediately. The IP stack on Linux doesn't have this issue; it uses a much more sophisticated algoritihm to optimise / maximise TCP packet flow rate.
« Last Edit: September 24, 2026, 08:09:41 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4658
  • Country: us
Re: PSA: Wiznet chip is not a real networking stack
« Reply #35 on: September 24, 2026, 09:31:08 am »
Quote
it turns out, Windows has a very long delay before it tries to retransmit.
Modern IP/TCP stacks are engineered and optimized for networks whose major packet drop (and thus retransmit) reason is congestion at routers, rather than actual lossy link hardware, memory shortages at the final destination, or slow links.  So (re)transmission algorithms are designed/required to avoid congestion.  Which is swell for the sort of bulk data transfers that are very common in today's Internet, but not so good for any number of smaller applications.  It's something of a Pet Peeve of mine, but it's hard to get anyone to care.

Nagle is very useful for optimizing bandwidth, adn was sort-of brilliant.  So is "delayed ack."  But they assume particular data patterns, and they can interact very weirdly indeed. :-(   The required "slow start" (Jacobson) algorithms sort-of devolve into Nagle if you're sending small packets.
 
The following users thanked this post: liteyear

Online Jeroen3

  • Super Contributor
  • ***
  • Posts: 4583
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: PSA: Wiznet chip is not a real networking stack
« Reply #36 on: September 24, 2026, 10:34:42 am »
Yeah, I dipped my toe in the Mikrotik queues to limit bandwidth, and there are a lot of methods.

I think in case of TCP it's good to know that it only guarantees order and correctness, not speed or latency.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 9200
  • Country: de
  • A qualified hobbyist ;)
Re: PSA: Wiznet chip is not a real networking stack
« Reply #37 on: September 24, 2026, 11:28:51 am »
On top there are several algorithms for packet queuing, e.g. CoDel/CAKE, to 'smooth' traffic.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30262
  • Country: nl
    • NCT Developments
Re: PSA: Wiznet chip is not a real networking stack
« Reply #38 on: September 24, 2026, 04:27:06 pm »
Yeah, I dipped my toe in the Mikrotik queues to limit bandwidth, and there are a lot of methods.

I think in case of TCP it's good to know that it only guarantees order and correctness, not speed or latency.
In that aspect it amazes me that the people behind Modbus decided to use tcp/ip. It is probably the worse fit for a realtime PLC protocol. They probably wanted something similar like a serial port (a stream) and forgot that Modbus in itself is packet based which suits UDP so much better.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: Siwastaja

Offline peter-h

  • Super Contributor
  • ***
  • Posts: 6048
  • Country: gb
  • Doing electronics since the 1960s...
Re: PSA: Wiznet chip is not a real networking stack
« Reply #39 on: September 24, 2026, 05:11:06 pm »
Absolutely! There is an ack so error detection/correction is taken care of. I guess they went for TCP/IP because it is routeable, but how often does one need that?

The boxes which run modbus over tcp/ip are supposedly packing up the modbus packet (which can be huge, 10s of kbytes in the responses for example if you do a multi register read) into multiple tcp/ip packets, obviously MTU constrained as usual along the way, and reassemble them into single modbus packets at the other end. So it is a protocol specific gateway (if done properly).
« Last Edit: September 24, 2026, 07:55:11 pm by peter-h »
Z80 Z180 Z280 Z8 S8 8031 8051 H8/300 H8/500 80x86 90S1200 32F417
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30262
  • Country: nl
    • NCT Developments
Re: PSA: Wiznet chip is not a real networking stack
« Reply #40 on: September 24, 2026, 08:16:59 pm »
Absolutely! There is an ack so error detection/correction is taken care of. I guess they went for TCP/IP because it is routeable, but how often does one need that?
UDP is perfectly routable. It works with IP addresses just like TCP.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17805
  • Country: fr
Re: PSA: Wiznet chip is not a real networking stack
« Reply #41 on: September 24, 2026, 09:01:58 pm »
The main rationale was likely the benefit of guaranteed delivery order - keep in mind Modbus was originally a serial protocol and while missed packets could happen from communication errors,  out-of-order packets was just impossible. With UDP, order of delivery is not guaranted. After that, I guess the fact TCP is session-oriented and retransmission is automatic was also seen as a benefit rather than having to implement all this on a higher level.

 

Offline gspeed

  • Contributor
  • Posts: 49
  • Country: cn
Re: PSA: Wiznet chip is not a real networking stack
« Reply #42 on: September 25, 2026, 04:18:55 am »
Wiznet chips do have raw mode though?
 

Online SiwastajaTopic starter

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: fi
Re: PSA: Wiznet chip is not a real networking stack
« Reply #43 on: September 25, 2026, 06:12:50 am »
The main rationale was likely the benefit of guaranteed delivery order - keep in mind Modbus was originally a serial protocol and while missed packets could happen from communication errors,  out-of-order packets was just impossible. With UDP, order of delivery is not guaranted. After that, I guess the fact TCP is session-oriented and retransmission is automatic was also seen as a benefit rather than having to implement all this on a higher level.

I sometimes miss a packet-oriented (like UDP) with built-in retransmission and ordering (like TCP); not on top of TCP/UDP, but at the same level, as alternative. TCP does a lot of useful things, and then forces an abstraction where the user-accessible datagram is exactly 8 bits, so if you need larger frames, as every real application in existence does, you the build a packetization system on top. Every usual layer on top of TCP, including HTTP, MQTT etc. are fundamentally packet delimiter systems (with application-specific extra features). The simplest ad-hoc packetization is a length field followed by any data; because TCP never loses anything, that suffices: you read the length field, then the correct amount of data, and are guaranteed to have the next length field. But this is still unnecessary work and it fights with layers below (Nagle, delayed ack, etc.) which try to figure out where application's data boundaries are.

Modbus TCP vendors seem to struggle somewhat, we have seen implementations which eventually crash if you keep doing polls on an open socket, forcing you to do a state machine on the application side which opens socket, communicates, checks everything went well, closes socket, and only then declares the operation finished. UDP would not be any more complicated, but simpler: still the same "retry until success" state machine, but without connection management.
« Last Edit: September 25, 2026, 06:16:14 am by Siwastaja »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4658
  • Country: us
Re: PSA: Wiznet chip is not a real networking stack
« Reply #44 on: September 25, 2026, 09:01:25 am »
Quote
it fights with layers below (Nagle, delayed ack, etc.) which try to figure out where application's data boundaries are.
I feel like TCP's PUSH and URGENT data were never fully explored (and are currently under-utilized.)
There's a tremendous chicken-and-egg problem.  IIRC, various reliable datagram protocols have been propsed, but they need to be implemented in the common OSes before they'd be useful on embedded systems, and there needs to be a real need on the embedded side before the OS vendors would be interested.

I suspect that the modbus folks didn't think there would be any problems at all running stuff used to 115.2kbps or less over a 100Mbps Ethernet LAN (which was probably the immediate goal.)  oops.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30262
  • Country: nl
    • NCT Developments
Re: PSA: Wiznet chip is not a real networking stack
« Reply #45 on: September 25, 2026, 09:24:22 am »
The main rationale was likely the benefit of guaranteed delivery order - keep in mind Modbus was originally a serial protocol and while missed packets could happen from communication errors,  out-of-order packets was just impossible. With UDP, order of delivery is not guaranted. After that, I guess the fact TCP is session-oriented and retransmission is automatic was also seen as a benefit rather than having to implement all this on a higher level.

I sometimes miss a packet-oriented (like UDP) with built-in retransmission and ordering (like TCP); not on top of TCP/UDP, but at the same level, as alternative. TCP does a lot of useful things, and then forces an abstraction where the user-accessible datagram is exactly 8 bits, so if you need larger frames, as every real application in existence does, you the build a packetization system on top. Every usual layer on top of TCP, including HTTP, MQTT etc. are fundamentally packet delimiter systems (with application-specific extra features). The simplest ad-hoc packetization is a length field followed by any data; because TCP never loses anything, that suffices: you read the length field, then the correct amount of data, and are guaranteed to have the next length field. But this is still unnecessary work and it fights with layers below (Nagle, delayed ack, etc.) which try to figure out where application's data boundaries are.

Modbus TCP vendors seem to struggle somewhat, we have seen implementations which eventually crash if you keep doing polls on an open socket, forcing you to do a state machine on the application side which opens socket, communicates, checks everything went well, closes socket, and only then declares the operation finished. UDP would not be any more complicated, but simpler: still the same "retry until success" state machine, but without connection management.
Agreed. And correct me if I'm wrong, Modbus is essentially a PLC protocol where the status of inputs and outputs is updated continuously. So some packet loss is not a problem. If they added a packet sequence number to the network packets, detecting out-of-order packets is trivial.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline glenenglish

  • Frequent Contributor
  • **
  • Posts: 560
  • Country: au
  • RF engineer. AI6UM / VK1XX . Aviation pilot. MTBr
Re: PSA: Wiznet chip is not a real networking stack
« Reply #46 on: September 25, 2026, 09:49:18 am »
dont use LWIP.. OMG do people stil use that ? I am amazed when dev boards come out with that as the tcp  stack.
we're not in 4 bit land anymore.

use FreeRTOS+TCP
 

Online SiwastajaTopic starter

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: fi
Re: PSA: Wiznet chip is not a real networking stack
« Reply #47 on: September 25, 2026, 12:15:38 pm »
dont use LWIP.. OMG do people stil use that ? I am amazed when dev boards come out with that as the tcp  stack.
we're not in 4 bit land anymore.

Age and popularity itself isn't a disadvantage, rather it's the opposite: it's the strongest advantage, and exactly the reason people "still" use it. TCP itself reached kind-of maturity in 1980's, and usage patterns have remained very similar for 20 years, so the big questions are related to reliability, safety and efficiency, quality of documentation and ease of use. Directly, age isn't a factor, and indirectly, it's a positive factor. A replacement needs to fix significant issues to be better.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30262
  • Country: nl
    • NCT Developments
Re: PSA: Wiznet chip is not a real networking stack
« Reply #48 on: September 25, 2026, 03:10:40 pm »
In my experience a solution being popular says absolutely nothing about quality or suitability.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: Siwastaja, newbrain

Offline aeg

  • Frequent Contributor
  • **
  • Posts: 462
  • Country: us
Re: PSA: Wiznet chip is not a real networking stack
« Reply #49 on: September 26, 2026, 03:06:37 am »
FreeRTOS+TCP is total amateur hour. It can't even do IP fragment reassembly! And look at ipconfigARP_STORES_REMOTE_ADDRESSES... the people behind it don't understand how ARP and routing work.

There's nothing wrong with lwIP. It's solid. The code style is idiosyncratic. It's a network stack; it requires effort to understand. There's no way around that.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->