PROFINET¶
Status: Planned
This module is not yet implemented. The design below represents the target architecture.
Overview¶
PROFINET is the industrial Ethernet standard from PROFIBUS International (PI). It provides three communication channels: non-real-time (TCP/UDP), real-time (RT, cyclic at Layer 2), and isochronous real-time (IRT, hardware-synchronized with sub-microsecond jitter).
Architecture¶
┌──────────────────────────────────────────────────────────────────────┐
│ PROFINET Communication Stack: │
│ │
│ ┌───────────────────────────────────────────────────────────────┐ │
│ │ Application (PLC program, drive control, I/O) │ │
│ ├───────────────┬───────────────────┬───────────────────────────┤ │
│ │ NRT (TCP/IP)│ RT (Cyclic) │ IRT (Isochronous) │ │
│ │ - Parameter │ - Process data │ - Motion control │ │
│ │ - Diagnostics│ - 1-10 ms cycle │ - < 1 ms cycle │ │
│ │ - Config │ - VLAN priority │ - Hardware forwarding │ │
│ ├───────────────┼───────────────────┼───────────────────────────┤ │
│ │ UDP/TCP │ Ethernet L2 │ Ethernet L2 (scheduled) │ │
│ │ (standard) │ (EtherType │ (Time-triggered) │ │
│ │ │ 0x8892) │ │ │
│ └───────────────┴───────────────────┴───────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────┘
PROFINET Frame Format (RT)¶
┌──────────────────────────────────────────────────────────────────────┐
│ Dst MAC │ Src MAC │ VLAN Tag │ EtherType │ Frame ID │ Data │ │
│ (6B) │ (6B) │ (4B opt) │ 0x8892 │ (2 bytes) │(variable) │ │
└──────────────────────────────────────────────────────────────────────┘
Frame ID Ranges:
0x0100-0x7FFF: RT (cyclic process data)
0x8000-0xBFFF: RT (acyclic, alarms)
0xC000-0xFBFF: IRT (isochronous, time-critical)
0xFC00-0xFCFF: RTC3 (high-performance)
0xFE00-0xFEFF: DCP (Discovery and Configuration Protocol)
Communication Classes¶
| Class | Cycle Time | Jitter | Use Case |
|---|---|---|---|
| NRT | N/A | N/A | Configuration, diagnostics |
| RT (Class 1) | 10 ms | ±1 ms | Standard I/O |
| RT (Class 2) | 1-10 ms | ±100 µs | Fast I/O |
| IRT (Class 3) | 250 µs–1 ms | < 1 µs | Motion, servo |
Planned API¶
typedef struct {
raw_socket_t raw; /* Underlying raw socket */
uint16_t frame_id; /* Cyclic frame ID */
uint32_t cycle_time_us; /* Send interval */
uint16_t station_name_len;
char station_name[240]; /* PROFINET station name */
uint8_t mac_addr[6];
} pn_controller_t;
typedef struct {
uint16_t slot;
uint16_t subslot;
uint16_t data_offset;
uint16_t data_length;
} pn_io_module_t;
/* Controller lifecycle */
int pn_controller_init(pn_controller_t *ctrl, const char *if_name);
int pn_discover_devices(pn_controller_t *ctrl); /* DCP protocol */
int pn_connect(pn_controller_t *ctrl, const char *station_name);
int pn_controller_close(pn_controller_t *ctrl);
/* Cyclic I/O */
int pn_io_read(pn_controller_t *ctrl, pn_io_module_t *module,
void *data, size_t len);
int pn_io_write(pn_controller_t *ctrl, pn_io_module_t *module,
const void *data, size_t len);
/* Acyclic (parameter access) */
int pn_read_record(pn_controller_t *ctrl, uint16_t slot, uint16_t subslot,
uint16_t index, void *data, size_t *len);
int pn_write_record(pn_controller_t *ctrl, uint16_t slot, uint16_t subslot,
uint16_t index, const void *data, size_t len);
Device Discovery (DCP)¶
┌─────────────────────────────────────────────────────────────────┐
│ DCP (Discovery and Configuration Protocol): │
│ │
│ Controller Device │
│ │ │ │
│ │── DCP Identify (multicast) ─────────►│ │
│ │ │ │
│ │◄── DCP Identify Response ────────────│ │
│ │ (station name, IP, MAC) │ │
│ │ │ │
│ │── DCP Set (IP address) ─────────────►│ │
│ │ │ │
│ │── DCP Set (Station Name) ───────────►│ │
│ │ │ │
└─────────────────────────────────────────────────────────────────┘
Performance Targets¶
| Metric | Target | Notes |
|---|---|---|
| RT cycle time | 1 ms | Class 2 |
| IRT cycle time | 250 µs | Class 3 (hardware forwarding) |
| DCP discovery | < 100 ms | Multicast scan |
| Failover (MRP) | < 200 ms | Media Redundancy Protocol |
Implementation Roadmap¶
- PROFINET frame construction (EtherType 0x8892)
- DCP Identify multicast (device discovery)
- DCP Set (IP and station name assignment)
- Context Manager (connection setup, AR establishment)
- Cyclic RT provider/consumer
- IOPS/IOCS status handling
- Alarm and diagnostic channels
- Integration with epoll_reactor (timer-driven RT cycles)
- MRP (Media Redundancy Protocol) for ring topology