# lwip-tcpip/lwip architecture

> Architecture diagram of the GitHub repository lwip-tcpip/lwip, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lwip-tcpip/lwip
- Repository: https://github.com/lwip-tcpip/lwip

## Overview

lwIP is a compact embedded TCP/IP stack. An application sends or receives traffic through the raw or socket APIs; the stack’s transport and IP layers process packets and hand them to network interfaces. The graph also preserves the README’s major protocol and application capabilities. Several internal runtime links are shown as unverified because the sampled excerpts expose headers and source-index references, not their complete call paths.

Main entry points: [`src/core/netif.c`](https://github.com/lwip-tcpip/lwip/blob/master/src/core/netif.c) (Network interface), [`src/core/ipv4/ip4.c`](https://github.com/lwip-tcpip/lwip/blob/master/src/core/ipv4/ip4.c) (IPv4), [`src/api/api_msg.c`](https://github.com/lwip-tcpip/lwip/blob/master/src/api/api_msg.c) (API messages), [`src/core/udp.c`](https://github.com/lwip-tcpip/lwip/blob/master/src/core/udp.c) (UDP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Application APIs"]
  node_socketapi["Socket API<br/>[sockets.c]"]
  node_rawapi["Raw API<br/>[api_lib.c]"]
  node_api_messages["API messages<br/>[api_msg.c]"]
  node_tcpip["TCP/IP thread API<br/>[tcpip.c]"]
end

subgraph group_protocols["Network protocols"]
  node_tcp["TCP<br/>[tcp.c]"]
  node_udp["UDP<br/>[udp.c]"]
  node_ip4["IPv4<br/>[ip4.c]"]
  node_ip6["IPv6<br/>[ip6.c]"]
  node_dhcp["Address configuration<br/>[dhcp.c]"]
  node_dns["DNS and mDNS<br/>[dns.c]"]
  node_ppp["PPP<br/>[ppp.c]"]
end

subgraph group_support["Packet and runtime support"]
  node_buffers["Packet buffers<br/>[pbuf.c]"]
  node_memory["Memory pools<br/>[memp.c]"]
end

subgraph group_apps["Network applications"]
  node_http["HTTP server/client<br/>[httpd.c]"]
  node_snmp["SNMP agent<br/>[snmp_core.c]"]
  node_mqtt["MQTT client<br/>[mqtt.c]"]
  node_sntp["SNTP client<br/>[sntp.c]"]
  node_netbios["NetBIOS responder<br/>[netbiosns.c]"]
end

subgraph group_interfaces["Interfaces and ports"]
  node_interface["Network interface<br/>[netif.c]"]
  node_ethernet["Ethernet framing<br/>[ethernet.c]"]
  node_port["Platform port<br/>[sys_arch.c]"]
end

node_application(("Embedded application"))
node_network(("Network peer"))

node_application -->|"uses sockets"| node_socketapi
node_application -->|"uses raw API"| node_rawapi
node_socketapi -->|"calls"| node_api_messages
node_api_messages -.->|"dispatches"| node_tcp
node_api_messages -.->|"dispatches"| node_udp
node_tcpip -.->|"processes messages"| node_api_messages
node_tcp -.->|"uses IP"| node_ip4
node_udp -.->|"uses IP"| node_ip4
node_ip4 -.->|"routes packets"| node_interface
node_ip6 -.->|"routes packets"| node_interface
node_interface -.->|"uses framing"| node_ethernet
node_interface -.->|"uses system services"| node_port
node_network -.->|"supplies packets"| node_interface
node_interface -.->|"transmits packets"| node_network
node_buffers -.->|"buffers segments"| node_tcp
node_buffers -.->|"buffers datagrams"| node_udp
node_memory -.->|"supports allocation"| node_buffers
node_dhcp -.->|"configures addressing"| node_ip4
node_dns -.->|"uses transport"| node_udp
node_ppp -.->|"carries IP"| node_ip4
node_ppp -.->|"carries IP"| node_ip6
node_http -.->|"serves requests"| node_application
node_snmp -.->|"exposes management"| node_application
node_mqtt -.->|"provides messaging"| node_application
node_sntp -.->|"provides time sync"| node_application
node_netbios -.->|"provides naming"| node_application

click node_socketapi "https://github.com/lwip-tcpip/lwip/blob/master/src/api/sockets.c"
click node_rawapi "https://github.com/lwip-tcpip/lwip/blob/master/src/api/api_lib.c"
click node_api_messages "https://github.com/lwip-tcpip/lwip/blob/master/src/api/api_msg.c"
click node_tcpip "https://github.com/lwip-tcpip/lwip/blob/master/src/api/tcpip.c"
click node_tcp "https://github.com/lwip-tcpip/lwip/blob/master/src/core/tcp.c"
click node_udp "https://github.com/lwip-tcpip/lwip/blob/master/src/core/udp.c"
click node_ip4 "https://github.com/lwip-tcpip/lwip/blob/master/src/core/ipv4/ip4.c"
click node_ip6 "https://github.com/lwip-tcpip/lwip/blob/master/src/core/ipv6/ip6.c"
click node_dhcp "https://github.com/lwip-tcpip/lwip/blob/master/src/core/ipv4/dhcp.c"
click node_dns "https://github.com/lwip-tcpip/lwip/blob/master/src/core/dns.c"
click node_ppp "https://github.com/lwip-tcpip/lwip/blob/master/src/netif/ppp/ppp.c"
click node_buffers "https://github.com/lwip-tcpip/lwip/blob/master/src/core/pbuf.c"
click node_memory "https://github.com/lwip-tcpip/lwip/blob/master/src/core/memp.c"
click node_http "https://github.com/lwip-tcpip/lwip/blob/master/src/apps/http/httpd.c"
click node_snmp "https://github.com/lwip-tcpip/lwip/blob/master/src/apps/snmp/snmp_core.c"
click node_mqtt "https://github.com/lwip-tcpip/lwip/blob/master/src/apps/mqtt/mqtt.c"
click node_sntp "https://github.com/lwip-tcpip/lwip/blob/master/src/apps/sntp/sntp.c"
click node_netbios "https://github.com/lwip-tcpip/lwip/blob/master/src/apps/netbiosns/netbiosns.c"
click node_interface "https://github.com/lwip-tcpip/lwip/blob/master/src/core/netif.c"
click node_ethernet "https://github.com/lwip-tcpip/lwip/blob/master/src/netif/ethernet.c"
click node_port "https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/freertos/sys_arch.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_socketapi,node_rawapi,node_api_messages,node_tcpip toneBlue
class node_tcp,node_udp,node_ip4,node_ip6,node_dhcp,node_dns,node_ppp toneAmber
class node_buffers,node_memory toneMint
class node_http,node_snmp,node_mqtt,node_sntp,node_netbios toneRose
class node_interface,node_ethernet,node_port,node_application,node_network toneIndigo
```

## Components

### Application APIs

- [Socket API](https://github.com/lwip-tcpip/lwip/blob/master/src/api/sockets.c): `src/api/sockets.c`
- [Raw API](https://github.com/lwip-tcpip/lwip/blob/master/src/api/api_lib.c): `src/api/api_lib.c`
- [API messages](https://github.com/lwip-tcpip/lwip/blob/master/src/api/api_msg.c): `src/api/api_msg.c`
- [TCP/IP thread API](https://github.com/lwip-tcpip/lwip/blob/master/src/api/tcpip.c): `src/api/tcpip.c`

### Network protocols

- [TCP](https://github.com/lwip-tcpip/lwip/blob/master/src/core/tcp.c): `src/core/tcp.c`
- [UDP](https://github.com/lwip-tcpip/lwip/blob/master/src/core/udp.c): `src/core/udp.c`
- [IPv4](https://github.com/lwip-tcpip/lwip/blob/master/src/core/ipv4/ip4.c): `src/core/ipv4/ip4.c`
- [IPv6](https://github.com/lwip-tcpip/lwip/blob/master/src/core/ipv6/ip6.c): `src/core/ipv6/ip6.c`
- [Address configuration](https://github.com/lwip-tcpip/lwip/blob/master/src/core/ipv4/dhcp.c): `src/core/ipv4/dhcp.c`
- [DNS and mDNS](https://github.com/lwip-tcpip/lwip/blob/master/src/core/dns.c): `src/core/dns.c`
- [PPP](https://github.com/lwip-tcpip/lwip/blob/master/src/netif/ppp/ppp.c): `src/netif/ppp/ppp.c`

### Packet and runtime support

- [Packet buffers](https://github.com/lwip-tcpip/lwip/blob/master/src/core/pbuf.c): `src/core/pbuf.c`
- [Memory pools](https://github.com/lwip-tcpip/lwip/blob/master/src/core/memp.c): `src/core/memp.c`

### Network applications

- [HTTP server/client](https://github.com/lwip-tcpip/lwip/blob/master/src/apps/http/httpd.c): `src/apps/http/httpd.c`
- [SNMP agent](https://github.com/lwip-tcpip/lwip/blob/master/src/apps/snmp/snmp_core.c): `src/apps/snmp/snmp_core.c`
- [MQTT client](https://github.com/lwip-tcpip/lwip/blob/master/src/apps/mqtt/mqtt.c): `src/apps/mqtt/mqtt.c`
- [SNTP client](https://github.com/lwip-tcpip/lwip/blob/master/src/apps/sntp/sntp.c): `src/apps/sntp/sntp.c`
- [NetBIOS responder](https://github.com/lwip-tcpip/lwip/blob/master/src/apps/netbiosns/netbiosns.c): `src/apps/netbiosns/netbiosns.c`

### Interfaces and ports

- [Network interface](https://github.com/lwip-tcpip/lwip/blob/master/src/core/netif.c): `src/core/netif.c`
- [Ethernet framing](https://github.com/lwip-tcpip/lwip/blob/master/src/netif/ethernet.c): `src/netif/ethernet.c`
- [Platform port](https://github.com/lwip-tcpip/lwip/blob/master/contrib/ports/freertos/sys_arch.c): `contrib/ports/freertos/sys_arch.c`

### Other components

- **Embedded application**
- **Network peer**

## Connections

- Embedded application → Socket API: uses sockets (evidence: `README`)
- Embedded application → Raw API: uses raw API (evidence: `README`)
- Socket API → API messages: calls (evidence: `src/api/sockets.c`)
- API messages → TCP: dispatches
- API messages → UDP: dispatches
- TCP/IP thread API → API messages: processes messages
- TCP → IPv4: uses IP
- UDP → IPv4: uses IP
- IPv4 → Network interface: routes packets
- IPv6 → Network interface: routes packets
- Network interface → Ethernet framing: uses framing
- Network interface → Platform port: uses system services
- Network peer → Network interface: supplies packets
- Network interface → Network peer: transmits packets
- Packet buffers → TCP: buffers segments
- Packet buffers → UDP: buffers datagrams
- Memory pools → Packet buffers: supports allocation
- Address configuration → IPv4: configures addressing
- DNS and mDNS → UDP: uses transport
- PPP → IPv4: carries IP
- PPP → IPv6: carries IP
- HTTP server/client → Embedded application: serves requests (evidence: `README`)
- SNMP agent → Embedded application: exposes management (evidence: `README`)
- MQTT client → Embedded application: provides messaging (evidence: `README`)
- SNTP client → Embedded application: provides time sync (evidence: `README`)
- NetBIOS responder → Embedded application: provides naming (evidence: `README`)
