WolfIP Doesn’t Allocate | Hackaday
Skip to content
For some types of embedded systems — especially those that are safety-critical — it’s considered bad form to dynamically allocate memory during operation. While you can usually arrange for your own code to behave, it’s the libraries that get you. In particular, it is hard to find a TCP/IP stack that doesn’t allocate and free memory all over the place. Unless you’ve found wolfIP.
The library supports a BSD-like non-blocking socket API. It can act as an endpoint, but can also support multiple interfaces and forwarding if you were building something like a router. It doesn’t appear to be bare-bones either. In addition to the normal things you’d expect for IPv4, there’s also ICMP, IPSEC, ARP, DHCP, DNS, and HTTP with or without SSL TLS. There is also a FIPS-compliant implementation of WireGuard for VPN, although it is not directly compatible with standard WireGuard, only with other instances of itself (known as wolfGuard). There is a Linux kernel module for WolfGuard, though.
The code should be fairly easy to port, and it includes a binding for FreeRTOS already. If you’ve used wolfIP, let us know in the comments.
If you want to really get down to the low-level, try this project. Of, if you want a refresher on basics, we can help with that, too.
30 thoughts on “WolfIP Doesn’t Allocate”
There are safety critical application with an TCP/IP Stack and Libaries? I hope they are never used in an airplane that I took or a car that I will buy.
Report comment
Reply
This. Never mix safety with slopTech.
Report comment
Reply
https://en.wikipedia.org/wiki/Fieldbus
Modbus TCP and modern x.509 secured variants with static host IP on air-gapped networks are still very common, galvanically isolated. and a highly interoperable ISO/OSI. Note, the industrial certification on this type of equipment often far exceeds consumer equipment.
CAN bus is like UDP, and heavily loaded with countless closed format pseudo-standards people just make up. The only reason it is in cars was the Laws mandating ODBII ports in anything post 1996 for emissions control. Some undocumented CANt bus versions are even booby-trapped, so you poke your nose in there to repair something, than you will be paying for a factory service tech. The other 97% of the time, it is just some wonk ripping off consumers.
Finally, don’t assume the industrial connectors will look like consumer cables in either case, and note airplanes have their own proprietary standards with several redundancies.
Best of luck kid. =3
Report comment
Reply
Good safety design requires that you compensate for the weaknesses of your tools. It doesn’t tell you what tools to use. The first step is accepting that everything is inherently unreliable, so determining that TCP/IP is inherently unreliable doesn’t automatically disqualify it. In fact, if you disqualify TCP/IP because it’s inherently unreliable, and accept something else instead because you view it as inherently reliable, then you just made a severe error that makes safety impossible.
It really depends what you’re trying to accomplish but the idea that something is unsuitable just because it has weaknesses is only going to lead you down a bad path. We are always designing around weaknesses, not looking for things that aren’t weak!
Report comment
Reply
LWIP is pretty rock stable, I like using it. It lets me write socket level code on ESP32 and similar SoCs. The best part, I can run the same-ish code on my PC, that runs on ESP32. At least the socket part of it
Raw socket features I haven’t used though.
Report comment
Reply
Does LWIP allocate memory dynamically though? That’s the key feature here. As soon as memory is allocated dynamically, you lose determinism.
Report comment
Reply
Hmm that is true. But is TCP/IP really what we need in the same sentence with "determinism" and static allocation?
Report comment
Reply
TCP/IP itself might not be a part of critical functionality but it still has potential of impacting actual critical stuff if it goes wrong enough.
Report comment
Reply
ESP32 tcp sockets can crash if you are not consuming data fast enough due to allocation issues. Not really something you would want in certain systems.
Report comment
Reply
Just a reminder, GPLv3, so no commercial usage, since, unlike on PC, there is no user-space exception. If you use this library, the whole code must be GPLv3.
Report comment
Reply
FUD.
only the modified code needs to be distributed.
Report comment
Reply
Not FUD. If you include GPLv3 in an application, then GPLv3 extends itself to the whole application. And as this targets embedded systems, most likely microcontrollers, it highly limits the usability in commercial settings. I found it strange that wolfSSL doesn’t offer a commercial license on this page. As this is something we would definitely pay for in certain projects that we do.
The github summary on GPLv3 is pretty clear on...