Engravion
Software & IoT Solutions
🚀 Engravion 3.0 is live — faster, smarter, more powerful. Read the release notes →
IoT & Embedded

Zero-Copy Networking in Embedded C: A Deep Dive

How we achieved 2.5x throughput improvement in EmbedOS's TCP stack by eliminating memory copies between the network driver and the application layer.

Super Admin Mar 25, 2026 1 min read 3,389 views

Memory bandwidth is precious in embedded systems. In our EmbedOS TCP/IP stack, we were seeing the network layer account for 40% of total CPU time on an ARM Cortex-M4 running at 168MHz — most of it in memcpy calls copying packet data between the DMA buffer and the socket buffer.

The Problem: Three Copies Where Zero Are Needed

In a naive TCP implementation, an incoming packet goes: NIC DMA buffer → driver RX ring → IP layer buffer → TCP layer buffer → application buffer. That's three copies. For a 1500-byte Ethernet frame, that's 4,500 bytes moved on every receive.

The Solution: Scatter-Gather DMA + pbuf Chain

We replaced our contiguous buffer model with a pbuf chain (borrowed from lwIP) and added scatter-gather DMA support in the Ethernet driver. Now the NIC writes packet fragments directly into pre-allocated pbuf nodes, and those same nodes are passed up the stack to the application without any copying.

Results

Peak TCP throughput increased from 38 Mbit/s to 94 Mbit/s on the STM32H7. CPU utilisation for the network stack dropped from 40% to 16%. Latency for small packets (< 200 bytes) decreased by 31%.

Share this article: X LinkedIn Facebook

0 Comments

Leave a Comment

Comments are moderated and appear once approved.

Super Admin

Author

Message Us