-
Notifications
You must be signed in to change notification settings - Fork 0
Network Stack
JNode features a completely custom, pure-Java network stack implementation spanning from network device drivers up to the standard
java.net.SocketAPI.
Because JNode does not rely on a host OS (like Linux or Windows), it cannot use host socket implementations. The entire networking OSI model—from Link Layer to Transport Layer—is implemented in the net/ subproject.
The stack is heavily object-oriented and modular, allowing new protocols and layers to be plugged in dynamically.
| OSI Layer | JNode Concept | Example Protocols / Packages |
|---|---|---|
| Application |
java.net.Socket, java.net.DatagramSocket
|
HTTP, FTP (via standard Java APIs) |
| Transport | TransportLayer |
TCP (org.jnode.net.ipv4.tcp), UDP (org.jnode.net.ipv4.udp) |
| Network | NetworkLayer |
IPv4 (org.jnode.net.ipv4), ICMP, ARP (org.jnode.net.arp) |
| Data Link |
LinkLayer, NetDeviceAPI
|
Ethernet (org.jnode.net.ethernet), Wi-Fi (org.jnode.net.wireless) |
| Physical | Network Device Drivers | RTL8139, NE2000, Intel eepro100 |
Location: net/src/net/org/jnode/net/
The fundamental unit of data in the JNode network stack is the SocketBuffer (inspired by Linux's sk_buff).
- It contains the raw packet payload.
- As a packet travels up or down the stack, layers prepend or strip headers (e.g., MAC header, IP header, TCP header) using the
SocketBufferwithout needing to allocate new arrays or copy the payload. -
LayerHeader(and its subclassesLinkLayerHeader,NetworkLayerHeader,TransportLayerHeader) represent the parsed headers attached to a buffer.
Location: net/src/driver/org/jnode/driver/net/
Network cards are Devices managed by the standard DeviceManager. They expose the NetDeviceAPI (or WirelessNetDeviceAPI).
- Drivers handle the raw hardware ring buffers, DMA transfers, and IRQs.
- When a packet arrives, the driver allocates a
SocketBuffer, copies the data, and passes it up to the activeLinkLayer.
The stack is assembled dynamically via registries:
-
NetworkLayerManager: Registers network layers (like IPv4) and routes incoming packets from the Link Layer based on protocol IDs (e.g.,0x0800for IPv4). - Similarly, the Network Layer routes packets to the correct Transport Layer based on the IP protocol field (e.g.,
6for TCP,17for UDP).
To make standard Java networking work seamlessly on top of this custom stack, JNode integrates with OpenJDK/GNU Classpath's java.net mechanism.
-
SocketImplFactory: JNode registers a custom
SocketImplFactorythat creates JNode-specific socket implementations (e.g.,JNodeSocketImpl). - These implementations bridge the standard
java.netcalls (connect(),read(),write()) into the internalTransportLayerAPIs (TCP/UDP state machines). -
NetAPI: The
NetAPIImplclass provides the application-facing network API for device enumeration, address resolution, and DNS lookup. See NetAPI-Implementation for details.
- Network-Layers — Detailed three-layer architecture (LinkLayer, NetworkLayer, TransportLayer) and SocketBuffer
- NetAPI-Implementation — Application network API for device enumeration, address resolution, and DNS
- Network Device Plugin — Plugin interface for network device drivers, NetPlugin lifecycle, device abstraction
- IPv4-Protocol — IPv4 packet processing, fragment reassembly, routing table, and checksum handling
- Driver-Framework — How network cards are probed and initialized.
- Plugin-System — How protocol layers are registered.
-
Code-Conventions — Important rules regarding resource handling (
MemoryResourceand IRQs) in network drivers. - ARP — IPv4-to-MAC address resolution with cache management.
- DNS-Resolver — DNS hostname resolution with DHCP integration and dnsjava library.
- NetPermission — Security permission class for DHCP and BOOTP operations.