# stonemaguire/nativeethernet architecture

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

- Interactive diagram: https://gitdiagram.com/stonemaguire/nativeethernet
- Repository: https://github.com/stonemaguire/nativeethernet

## Overview

NativeEthernet is a Teensy 4.1 networking library that replaces the Arduino Ethernet API, backed by the FNET stack. A sketch configures Ethernet and then uses TCP client/server or UDP APIs; hostname-based UDP destinations use DNS resolution, and the library also exposes mDNS service registration. The excerpts show socket operations delegated to a socket layer and FNET calls, but do not establish every initialization or dispatch relationship, so those links are omitted.

Main entry points: [`src/Nativesocket.cpp`](https://github.com/stonemaguire/nativeethernet/blob/master/src/Nativesocket.cpp) (Socket Operations), [`src/NativeEthernet.h`](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernet.h) (Compatibility API), [`src/NativeEthernetUdp.cpp`](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetUdp.cpp) (UDP), [`src/NativeEthernetClient.cpp`](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetClient.cpp) (TCP Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Ethernet API"]
  node_ethernet["Ethernet Setup<br/>[NativeEthernet.cpp]"]
  node_ethernet_api["Compatibility API<br/>[NativeEthernet.h]"]
  node_tcp_client["TCP Client"]
  node_tcp_server["TCP Server"]
  node_udp["UDP"]
end

subgraph group_network["Network Services"]
  node_dns["DNS Resolver<br/>[NativeDns.cpp]"]
  node_mdns["mDNS Services<br/>[NativeMdns.cpp]"]
end

subgraph group_transport["Socket Transport"]
  node_socket_ops["Socket Operations<br/>[Nativesocket.cpp]"]
  node_socket_defs["Socket Definitions<br/>[NativeW5100.h]"]
end

node_sketch(("Arduino Sketch"))
node_fnet["FNET Stack"]

node_sketch -->|"uses"| node_ethernet_api
node_ethernet -->|"initializes stack"| node_fnet
node_tcp_client -->|"uses socket API"| node_ethernet_api
node_tcp_server -->|"uses socket API"| node_ethernet_api
node_udp -->|"uses socket API"| node_ethernet_api
node_udp -->|"resolves host"| node_dns
node_dns -->|"resolves names"| node_fnet
node_mdns -->|"registers services"| node_fnet
node_tcp_client -->|"sends and receives"| node_socket_ops
node_udp -->|"sends and receives"| node_socket_ops
node_socket_ops -->|"operates sockets"| node_fnet
node_tcp_server -->|"accepts connections"| node_fnet
node_socket_ops -->|"uses protocol states"| node_socket_defs

click node_ethernet "https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernet.cpp"
click node_ethernet_api "https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernet.h"
click node_tcp_client "https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetClient.cpp"
click node_tcp_server "https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetServer.cpp"
click node_udp "https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetUdp.cpp"
click node_dns "https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeDns.cpp"
click node_mdns "https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeMdns.cpp"
click node_socket_ops "https://github.com/stonemaguire/nativeethernet/blob/master/src/Nativesocket.cpp"
click node_socket_defs "https://github.com/stonemaguire/nativeethernet/blob/master/src/utility/NativeW5100.h"

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_ethernet,node_ethernet_api,node_tcp_client,node_tcp_server,node_udp toneBlue
class node_dns,node_mdns toneAmber
class node_socket_ops,node_socket_defs toneMint
class node_sketch,node_fnet toneIndigo
```

## Components

### Ethernet API

- [Ethernet Setup](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernet.cpp): `src/NativeEthernet.cpp`
- [Compatibility API](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernet.h): `src/NativeEthernet.h`
- [TCP Client](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetClient.cpp): `src/NativeEthernetClient.cpp`
- [TCP Server](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetServer.cpp): `src/NativeEthernetServer.cpp`
- [UDP](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeEthernetUdp.cpp): `src/NativeEthernetUdp.cpp`

### Network Services

- [DNS Resolver](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeDns.cpp): `src/NativeDns.cpp`
- [mDNS Services](https://github.com/stonemaguire/nativeethernet/blob/master/src/NativeMdns.cpp): `src/NativeMdns.cpp`

### Socket Transport

- [Socket Operations](https://github.com/stonemaguire/nativeethernet/blob/master/src/Nativesocket.cpp): `src/Nativesocket.cpp`
- [Socket Definitions](https://github.com/stonemaguire/nativeethernet/blob/master/src/utility/NativeW5100.h): `src/utility/NativeW5100.h`

### Other components

- **Arduino Sketch**
- **FNET Stack**

## Connections

- Arduino Sketch → Compatibility API: uses (evidence: `README.md`)
- Ethernet Setup → FNET Stack: initializes stack (evidence: `src/NativeEthernet.cpp`)
- TCP Client → Compatibility API: uses socket API (evidence: `src/NativeEthernetClient.cpp`)
- TCP Server → Compatibility API: uses socket API (evidence: `src/NativeEthernetServer.cpp`)
- UDP → Compatibility API: uses socket API (evidence: `src/NativeEthernetUdp.cpp`)
- UDP → DNS Resolver: resolves host (evidence: `src/NativeEthernetUdp.cpp`)
- DNS Resolver → FNET Stack: resolves names (evidence: `src/NativeDns.cpp`)
- mDNS Services → FNET Stack: registers services (evidence: `src/NativeMdns.cpp`)
- TCP Client → Socket Operations: sends and receives (evidence: `src/NativeEthernetClient.cpp`)
- UDP → Socket Operations: sends and receives (evidence: `src/NativeEthernetUdp.cpp`)
- Socket Operations → FNET Stack: operates sockets (evidence: `src/Nativesocket.cpp`)
- TCP Server → FNET Stack: accepts connections (evidence: `src/NativeEthernetServer.cpp`)
- Socket Operations → Socket Definitions: uses protocol states (evidence: `src/Nativesocket.cpp`)
