TCP/IP stack for embedded devices

If your embedded device talks to the network, it runs a TCP/IP stack. Period.

Whether it is an STM32 industrial controller, an ESP32 IoT gadget, or an NXP board in a robot - networking always boils down to the same thing: implementing TCP/IP.

A TCP/IP stack is the software layer that allows a microcontroller to send packets, receive packets, open connections, serve web pages, stream telemetry, or talk to cloud services. Without it, your Ethernet or WiFi hardware is just blinking LEDs.

The interesting bit: a TCP/IP stack does not have to be huge. Modern embedded stacks like Mongoose run comfortably on microcontrollers such as STM32 and provide everything needed for network-enabled devices.

This page explains what a TCP/IP stack is, how it works, and why Mongoose is one of the simplest TCP/IP stacks to integrate on STM32 and other embedded platforms.

What is a TCP/IP stack

TCP/IP stands for Transmission Control Protocol / Internet Protocol. It is the protocol suite that allows devices to communicate across networks and the Internet.

In simple words:

  • IP delivers packets between devices
  • TCP guarantees reliable communication between applications

TCP/IP splits networking into layers. Each layer does a specific job and hides complexity from the layer above.

Typical TCP/IP stack layers:

  • Application layer - HTTP, MQTT, WebSocket, DNS
  • Transport layer - TCP or UDP
  • Internet layer - IP, ICMP
  • Link layer - Ethernet, WiFi drivers

When your embedded device sends a message, the data travels down through these layers, gets packed into network frames, moves through the network, and is unpacked on the receiving side.

Sounds complicated. Luckily the TCP/IP stack handles all of it.

TCP/IP explained in 6 minutes

Before diving deeper, here is a quick visual explanation of how TCP/IP works.

Key ideas from the video:

TCP/IP is basically a layered communication system.

Applications produce data. That data is split into packets. Each packet contains addressing information so routers know where to send it. At the destination, packets are reassembled into the original data stream.

TCP provides reliability - it numbers packets, detects loss, and retransmits missing data. IP handles addressing and routing across networks.

That simple model powers nearly every connected device on Earth.

How TCP/IP stacks work inside embedded devices

Inside an embedded device, the TCP/IP stack sits between the network hardware and the application.

Very simplified architecture:

Application
    |
HTTP / MQTT / WebSocket
    |
TCP / UDP
    |
IP
    |
Ethernet / WiFi driver
    |
Network hardware

The application does not care about packets, routing, checksums, or retransmissions. It simply opens connections and sends data.

The TCP/IP stack does the heavy lifting: packet segmentation, retransmission, congestion control, routing, checksums, connection management. On large operating systems this stack is part of the kernel. On microcontrollers like STM32 it is just a library compiled into firmware.

TCP/IP stack implementation explained

If you want to see what a real TCP/IP stack implementation looks like internally, this deep dive walks through the whole design.

The video goes through packet buffers, connection state machines, TCP retransmission logic, and how event-driven networking works in embedded systems.

Understanding these pieces helps explain why some stacks are easy to use and others are painful.

TCP/IP stacks for STM32 and embedded systems

Embedded developers typically encounter these TCP/IP stacks:

  • lwIP
  • Mongoose
  • FreeRTOS+TCP
  • Zephyr networking
  • vendor-specific stacks

Most STM32 projects end up using lwIP because it is bundled with STM32Cube.

But bundling does not mean simplicity.

Many engineers discover that integrating lwIP requires significant configuration, glue code, and debugging. Network configuration alone often involves dozens of macros and build-time options.

Mongoose takes a different approach. It provides a full TCP/IP stack, HTTP server, WebSocket, MQTT, TLS, OTA firmware update support. All in a small portable library designed specifically for embedded devices.

lwIP vs Mongoose on STM32

This video compares lwIP and Mongoose integration on STM32Cube projects.

The main takeaway is simple: networking stacks should make application development easier, not harder.

Mongoose focuses on reducing integration friction and letting developers build device networking quickly.

TCP/IP stacks comparison

Below is a simplified comparison of common embedded TCP/IP stacks.

Stack TCP/IP HTTP server WebSocket TLS License
lwIP yes no no external BSD
FreeRTOS+TCP yes no no external MIT
Oryx yes yes partial yes commercial
Zephyr yes yes partial yes commercial
NetX yes yes partial yes commercial
Mongoose yes yes yes yes dual

Mongoose is a two-file portable library that requires minimal configuration. It uses an event-driven architecture, has built-in networking protocols and designed specifically for embedded firmware.

Instead of fighting configuration files, developers focus on building device features.

When to use a TCP/IP stack like Mongoose

Mongoose is particularly useful when building: STM32 industrial devices, IoT sensors and gateways, connected instruments, smart controllers, embedded Linux appliances, ESP32 and RP2040 network devices

In these systems, networking is not just packet routing. It is also application protocols, device APIs, and remote management.

A TCP/IP stack that integrates all those pieces saves a lot of engineering time.

Summary

A TCP/IP stack is the core networking component of any connected device.

It implements the layered networking model that powers the Internet - handling packet routing, reliable transport, and communication between applications.

On embedded devices like STM32 microcontrollers, the TCP/IP stack is usually implemented as a firmware library.

Mongoose provides a lightweight TCP/IP stack designed specifically for embedded systems. It combines networking, application protocols, and security features into a single portable library, making it one of the simplest ways to add networking to embedded devices.