Live data from Hacker News

WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

github.com

21–30 of 51 posts

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#21
post #18

How does it deal with all the dynamic TCP buffering things where things may get quite large?

It has a fixed maximum number of concurrent sockets, and each socket has queues backed by per-socket fixed-size transmit and receive buffers (see `rxmem` and `txmem` in `struct tsocket`[1]). This is fine, because in TCP, each side advertises remaining buffer space via the window size header field [2] (possibly with its meaning modified by the window scale option during the initial handshake - see [3] & `struct PACKED tcp_opt_ws`), and possibly also how much it can maximally receive in one packet (via the MSS option on the initial handshake [4]; possibly modified by intermediary systems via MSS clamping). wolfip has unusually small buffer sizes, and hardcodes them via #define, and everything else (e.g. congestion control) is pretty rudimentary too, but otherwise it's pretty much the same as in a "normal" implementation.

[1] https://github.com/wolfSSL/wolfip/blob/60444d869e8f451aa2dca... [2] https://github.com/wolfSSL/wolfip/blob/60444d869e8f451aa2dca... [3] https://github.com/wolfSSL/wolfip/blob/60444d869e8f451aa2dca... [4] https://github.com/wolfSSL/wolfip/blob/60444d869e8f451aa2dca...

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#22
post #18

How does it deal with all the dynamic TCP buffering things where things may get quite large?

It has a fixed maximum number of concurrent sockets, and each socket has queues backed by per-socket fixed-size transmit and receive buffers (see `rxmem` and `txmem` in `struct tsocket`[1]). This is fine, because in TCP, each side advertises remaining buffer space via the window size header field [2] (possibly with its meaning modified by the window scale option during the initial handshake - see [3] & `struct PACKED…

Ok. So I guess it doesn't try to go very fast.

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#24
post #5

Earlier quoted context omitted.

Not sure if they do for _this_ package, but the Wolf* people's model is usually selling certification packages so you can put their things in stuff that need certifications and you offload liability. You also get people that wrote it and that you can pay for support. I kind of like them, had a short project where I had to call on them for getting their WolfSSL to work with a ATECC508 device and it was pretty good sup…

As the project is GPL’ed I guess they sell a commercial version. GPL is toxic for embedded commercial software. But it can be good marketing to sell the commercial version. Edit: I meant commercial license

In my company we used their stuff often. They have an optional commercial license for basically all their products. The price was very reasonable as well.

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#25
post #22

Earlier quoted context omitted.

It has a fixed maximum number of concurrent sockets, and each socket has queues backed by per-socket fixed-size transmit and receive buffers (see `rxmem` and `txmem` in `struct tsocket`[1]). This is fine, because in TCP, each side advertises remaining buffer space via the window size header field [2] (possibly with its meaning modified by the window scale option during the initial handshake - see [3] & `struct PACKED…

Ok. So I guess it doesn't try to go very fast.

Buffer size is the product of bandwidth and delay, so if communicating with something close, it can still go fast.

Had an illustration of this once when my then-employers IT dept set up the desktop IP phones to update from a TFTP server on the other continental land mass. Since TFTP only allows one outstanding packet, everyone outside head office had to wait a long time for their phone to update, while head office didn't see any issue.

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#26
post #22

Earlier quoted context omitted.

It has a fixed maximum number of concurrent sockets, and each socket has queues backed by per-socket fixed-size transmit and receive buffers (see `rxmem` and `txmem` in `struct tsocket`[1]). This is fine, because in TCP, each side advertises remaining buffer space via the window size header field [2] (possibly with its meaning modified by the window scale option during the initial handshake - see [3] & `struct PACKED…

Ok. So I guess it doesn't try to go very fast.

passt has been doing something similar for years (see https://passt.top/kvm_forum_2022.pdf pages 17, 18) and it's actually pretty fast (https://passt.top/#performance_1), even though it's not as resource-constrained as WolfIP.

We're finally adding multithreading (https://bugs.passt.top/show_bug.cgi?id=13) these days.

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#27
post #5

Earlier quoted context omitted.

Not sure if they do for _this_ package, but the Wolf* people's model is usually selling certification packages so you can put their things in stuff that need certifications and you offload liability. You also get people that wrote it and that you can pay for support. I kind of like them, had a short project where I had to call on them for getting their WolfSSL to work with a ATECC508 device and it was pretty good sup…

As the project is GPL’ed I guess they sell a commercial version. GPL is toxic for embedded commercial software. But it can be good marketing to sell the commercial version. Edit: I meant commercial license

“GPL is toxic for embedded commercial software”

Why is that?

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#29
post #27
post #5

Earlier quoted context omitted.

As the project is GPL’ed I guess they sell a commercial version. GPL is toxic for embedded commercial software. But it can be good marketing to sell the commercial version. Edit: I meant commercial license

“GPL is toxic for embedded commercial software” Why is that?

He probably meant viral or tried to make a deadly twist on virality

Re: WolfIP: Lightweight TCP/IP stack with no dynamic memory allocations

#30
post #19

Are there TCP/IP stacks out there in common use that are allocating memory all the time?

Yes, TCP is pretty hungry for buffers. The bandwidth*delay product can eat gigs of memory on a server. You have to be ready to retransmit anything that's in flight / haven't received the ack for yet.

The bandwidth delay product for a 10Gbps stream for a 300ms RTT theoretically only requires ~384MB

One option is just to simply keep buffers small and fixed and disconnect blocked clients on write() after some timeout

Post reply on HN