doc/help/Drivers-Network.md
The Network driver is the right transport once a project outgrows a single USB cable: when the device is on another machine, behind a network gateway, on a Wi-Fi link, or being shared between multiple Serial Studio instances. The driver speaks two transport protocols:
Both are available in the free build.
TCP, the Transmission Control Protocol, was specified in RFC 793 in 1981 and is still the workhorse of the Internet. It provides a reliable, ordered stream of bytes between two endpoints, hides packet loss, retransmits what is missing, and enforces flow control so a fast sender does not overwhelm a slow receiver.
A TCP connection has three phases:
sequenceDiagram
participant C as Client
participant S as Server
Note over C,S: 1. Three-way handshake
C->>S: SYN
S->>C: SYN-ACK
C->>S: ACK
Note over C,S: 2. Data transfer
C->>S: data segment (seq=N)
S->>C: ACK (ack=N+len)
S->>C: data segment
C->>S: ACK
Note over C,S: ...
Note over C,S: 3. Graceful close
C->>S: FIN
S->>C: ACK
S->>C: FIN
C->>S: ACK
Once the handshake completes, both sides see a virtual full-duplex pipe: write bytes in at one end, and the same bytes come out at the other end, in order, with nothing missing. TCP achieves this on top of an unreliable IP network by numbering every byte, acknowledging what it received, and retransmitting anything that is not acknowledged in time.
The most important thing about TCP is that it is a stream of bytes, not a stream of messages. If a device writes 100 bytes followed by 100 bytes, the receiver may see one read of 200 bytes, or two of 100, or 200 of 1. The boundaries are not preserved.
This matters for Serial Studio because frame parsing has to operate on the stream. With a delimiter (newline, custom byte sequence) the FrameReader finds frames regardless of how the OS chunked the stream. With fixed-length frames it counts bytes. Either approach works; do not assume "one TCP packet = one frame". Each extracted frame is then handed to the project's frame parser as a single parse(frame) call.
Every TCP endpoint is (IP address, port number). Ports go from 0 to 65535. 0-1023 are "well-known" (reserved for system services on most operating systems); 1024-49151 are "registered" (database servers, application services); 49152-65535 are "ephemeral" (assigned by the OS to outgoing client connections).
Serial Studio enforces no specific choice. Use whatever the device is configured for.
UDP, the User Datagram Protocol, was specified in RFC 768 in 1980; the entire specification is three pages. Where TCP provides a reliable stream, UDP provides something far simpler: send one packet and hope it arrives. There are no guarantees.
UDP's header is 8 bytes: source port, destination port, length, and checksum. There is no handshake, no acknowledgement, no retransmission, no ordering, and no flow control. A lost packet stays lost. Out-of-order packets stay out of order.
Choose UDP when either the data is inherently datagram-shaped (one self-contained reading per packet), or it is acceptable to drop a stale message rather than wait for it.
UDP supports a special form of distribution called multicast: one sender publishes to a multicast group address, and any number of receivers can subscribe to that group. Routers and switches that support multicast replicate packets only where receivers exist.
Multicast group addresses are in the IP range 224.0.1.0 to 239.255.255.255. The most useful sub-range for application traffic is 239.0.0.0/8 (administratively scoped, organisation-local).
flowchart LR
Sender["Sender (e.g., 192.168.1.10)"]
Switch[Multicast-aware switch / router]
R1["Receiver 1
joined 239.1.1.1:5000"]
R2["Receiver 2
joined 239.1.1.1:5000"]
R3["Receiver 3
not joined"]
Sender -->|"to 239.1.1.1:5000"| Switch
Switch --> R1
Switch --> R2
Switch -. drop .-> R3
Receivers join a group by sending an IGMP (Internet Group Management Protocol) Membership Report. The router then forwards the multicast traffic on that interface. When the receiver leaves, it sends an IGMP Leave message and the router stops forwarding. Without IGMP support in the network, multicast either floods everywhere or fails entirely.
In Serial Studio, multicast is useful when:
The Network driver wraps Qt's QTcpSocket and QUdpSocket. It lives on the main thread and uses Qt's async I/O; there is no dedicated thread (see Threading and Timing Guarantees).
Serial Studio is a TCP client only. It dials out to an existing TCP server. It does not listen for incoming TCP connections, and there is no setting to make it act as a server. If the device expects to push data to a listener, run a small TCP server in front of Serial Studio (see Common pitfalls).
The Setup panel exposes these fields:
| Field | Applies to | Controls | Default |
|---|---|---|---|
| Socket Type | both | TCP or UDP | TCP |
| Remote Address | both | Server IP / hostname (TCP) or peer / multicast group (UDP) | 127.0.0.1 |
| Remote Port | TCP, UDP non-multicast | Port to connect to (TCP) or send to (UDP); hidden while Multicast is checked | 23 (TCP), 53 (UDP) |
| Local Port | UDP only | Port to bind for receiving; 0 = OS-assigned | 0 |
| Multicast | UDP only | When checked, Remote Address is treated as a multicast group (e.g. 239.1.1.1) and Serial Studio joins it on connect; the OS handles IGMP transparently | off |
Remote Address accepts hostnames as well as IP literals. A hostname triggers a background DNS lookup, and the Connect button stays disabled until the name resolves. Clearing the address or a port field restores its default.
UDP uses a single socket; there is no separate Receiver / Sender / Multicast mode. Serial Studio binds Local Port to receive datagrams. Incoming datagrams are read one at a time, so on the receive side UDP preserves the message boundaries that TCP discards. Outbound data (actions, output controls, the console send line) is sent as datagrams to Remote Address / Remote Port.
The same settings are scriptable through the io.network.* commands of the JSON-RPC API: setSocketType (socketTypeIndex 0 = TCP, 1 = UDP), setRemoteAddress, setTcpPort, setUdpLocalPort, setUdpRemotePort, setUdpMulticast, and lookup, plus the read-only getConfig and listSocketTypes. The port commands take a port parameter (1-65535; setUdpLocalPort also accepts 0). When the in-app AI issues these commands, they sit behind the Allow device control toggle.
For step-by-step setup, see the Protocol Setup Guides, Network section.
telnet host port (or nc host port) tries the same connection; if that fails, the problem is in the network or the remote endpoint, not in Serial Studio.ncat -lk <port> and socat also work. To avoid running a relay at all, send the data over UDP, since Serial Studio binds a local port for that.ufw status shows whether the port is blocked.netstat -an | findstr :7777 (Windows) or lsof -i :7777 (Linux/macOS). The error does not apply to TCP: Serial Studio is a TCP client and uses an OS-assigned ephemeral source port.TCP_NODELAY); configure this on the device or remote service if latency matters, since Serial Studio leaves the socket at Qt's defaults.frame1frame2frame3 with no delimiter and no length prefix, parsing is impossible. Add a delimiter (newline) or a length prefix.