emNet IP X Config
Jump to navigation
Jump to search
IP_X_Config
Overview
IP_X_Config is a configuration function used by the emNet IP stack during initialization (IP_Init()). Its primary purpose is to assign memory, configure buffers, set TCP/UDP parameters, and initialize network interfaces.
Memory Pool Configuration
The emNet stack uses a shared memory pool defined by ALLOC_SIZE. This pool is dynamically allocated and shared between:
- Protocol buffers (Tx/Rx)
- Driver transfer memory
- TCP/UDP sockets
- Extensions (IPv6, DHCP, VLAN, multiple interfaces, etc.)
Choosing ALLOC_SIZE
The correct value of ALLOC_SIZE is critical for system stability:
- It depends on the number and size of buffers, the configured MTU, driver requirements, and enabled features.
- If ALLOC_SIZE is too small, the stack may run out of memory at runtime.
- Overhead must be added for:
- System-specific alignment constraints
- Memory management overhead
Example Configurations
Different system profiles require different ALLOC_SIZE values:
| System Profile | MTU | Small Buffers | Big Buffers | TCP Window (Tx/Rx) | Notes |
|---|---|---|---|---|---|
| Microcontroller, minimum size | 576 | 4 * 256 | 3 * (mtu+16) | 2*(mtu-40) / 1*(mtu-40) | Optimized for minimal RAM |
| Microcontroller, size optimized | 576 | 8 * 256 | 4 * (mtu+16) | 2*(mtu-40) / 2*(mtu-40) | Balanced memory usage |
| Microcontroller, speed/multi-conn. | 1500 | 12 * 256 | 6 * (mtu+16) | 3*(mtu-40) / 3*(mtu-40) | Higher throughput |
| System with lots of RAM | 1500 | 50 * 256 | 50 * (mtu+16) | 8*(mtu-40) / 8*(mtu-40) | Large-scale systems |
Notes
- The MTU (Maximum Transmission Unit) ranges from 576 (RFC minimum) to 1500 (Ethernet maximum).
- Large buffers must always be sized as MTU + 16 to accommodate Ethernet headers.
- TCP Tx space should allow at least two full packets.
- Systems with more RAM can allocate significantly larger pools for higher performance and multiple connections.