Raw Socket
Sends and receives Ethernet frames directly on a network interface, below IP. Protocols that are not carried over TCP or UDP at all - PROFINET real-time traffic, for instance - need this.
It captures and injects through libpcap, so the host needs a libpcap (Linux, macOS) or Npcap
(Windows) installation, and the process needs permission to open the interface in capture mode -
root, CAP_NET_RAW, or membership of a group the packet-capture device belongs to.
Transport syntax
{name of the network interface}
The name depends on the operating system - eth0 or enp3s0 on Linux, en0 on macOS,
\\Device\\NPF_{GUID} on Windows. Leave it out and the transport takes the first interface it
finds, which is only sensible on a machine with one.
profinet://en0?raw-socket.remote-address=00:0e:cf:12:34:56&raw-socket.protocol-id=34962
The interface can also be named with the raw-socket.interface-name option instead; the address
segment wins if both name one.
Name |
Type |
Default Value |
Required |
Description |
Name |
Raw Socket (Ethernet) |
|||
Code |
|
|||
Maven Dependency |
<dependency> <groupId>org.apache.plc4x</groupId> <artifactId>plc4j-transports-raw-socket</artifactId> <version>1.1.0</version> </dependency> |
|||
Config options: |
||||
|
STRING |
Network interface name to use (e.g., "eth0", "en0", "\\Device\\NPF_{GUID}" on Windows). Alternative to naming the interface in the address segment of the connection string, which takes precedence. If neither names one, the first available interface is used. |
||
|
STRING |
Local MAC address to send from. If not set, uses interface’s MAC address. |
||
|
STRING |
required |
Remote MAC address to send to. |
|
|
INT |
required |
EtherType / Protocol number (e.g., 0x88B5 for PROFINET, 0x88CC for LLDP, custom values) |
|
|
BOOLEAN |
false |
Promiscuous mode - capture all packets on the network, not just those destined for this interface. |
|
|
INT |
1000 |
Packet capture timeout in milliseconds. |
|
|
INT |
65536 |
Snapshot length - maximum bytes to capture per packet. 0 means capture entire packet. |
|
|
INT |
1048576 |
Buffer size for packet capture in bytes. |
|
|
INT |
1048576 |
Bytes of captured frames that may wait for a consumer before frames are dropped. |
|
|
INT |
0 |
VLAN ID (0 means no VLAN tag). Range: 0-4095 |
|
|
INT |
0 |
VLAN priority (0-7). Only used if vlanId > 0. |
|
|
BOOLEAN |
false |
Reuse the underlying network interface across multiple transport instances. When true, instances with the same interface and protocol will share a pcap handle. This is useful for protocols where multiple logical connections share one Ethernet type. |
|
|
STRING |
BPF (Berkeley Packet Filter) expression to filter packets. |
||
|
INT |
1500 |
Maximum frame size (MTU) in bytes. |
|
|
INT |
0 |
Read timeout for blocking reads in milliseconds. |
|
|
BOOLEAN |
false |
Deliver full Ethernet frames to the driver and accept raw Ethernet frames on send. Required for L2 protocols that build their own Ethernet headers. |
|
raw-socket.remote-address and raw-socket.protocol-id have no sensible default and must be
given. The protocol id is the EtherType - 0x88B5 (34997) and 0x8892 (34962) for PROFINET,
0x88CC (35020) for LLDP.
If frames go missing under load, raise raw-socket.receive-queue-size - it bounds how many
bytes of captured frames may wait for the driver before the oldest are dropped.
|