PortDock

PortDock TCP Guide

TCP client, server and relay with multiple peers, echo and auto-reconnect

About this program

PortDock TCP is a test tool for exchanging data with a device over Ethernet (TCP/IP).

It works as a «client» (the PC connects to the device), a «server» (the device connects to the PC) or a «relay» (monitor — sits between two sides and logs both directions).

It shows received data as HEX and ASCII, sends data with a checksum and keeps test logs in a file.

Getting started

  • 1. Choose «Mode» on the left: «Client (connect to device)» if the device waits for connections, «Server (device connects)» if the device connects to the PC.
  • 2. As a client enter the device «Host» (IP) and «Port»; as a server enter the «Bind address» and the «Port» to listen on.
  • 3. Click «Connect» (client) or «Start listening» (server). When the status reads «Connected» or «Listening», you are ready.
  • 4. Type what to send at the bottom and click «Send» (or press Enter). Received data appears as RX ◀, sent data as TX ▶.

Screen layout

  • Left: «Mode», address, «Port», the «Advanced connection» section (immediate send, reconnect), «Connect»/«Start listening» (while running: «Disconnect» for a client, «Stop listening» for server/relay), status, (server) «Connected peers», the «Receive settings» section (framing, RX checksum check, echo), «Log to file».
  • «Advanced connection» and «Receive settings» are collapsed with the current values next to the title («Nagle off · reconnect 2 s», «Idle gap 20ms · No checksum check»). They start expanded when something differs from the defaults, and their open state is remembered.
  • Top toolbar: «View» (HEX, ASCII, «Both» — «Both» at first), «Auto-scroll», total RX/TX bytes, «Save view», «Clear».
  • Below the toolbar, the find/filter row: find box, ▲/▼, «Matches only», «FAIL only», direction (All/RX/TX/EV). See «Find and filter the log».
  • Log: time, direction (RX ◀ / TX ▶ / EV), (server) peer address and data. With RX checksum verification on, lines get «OK» or «FAIL».
  • Bottom: the send row ((server) «To», HEX/ASCII, input, checksum, line ending, «Send»), «Bytes to send», «Repeat (ms)», «+ Save to list».
  • Right: «Commands», «Triggers» and «Detail» (click a log line to see its peer, byte count, HEX and ASCII).
  • In a narrow window (1180 px or less) the right pane is hidden; open it with «☰ Commands · Detail» in the toolbar (just «☰» at 1100 px or less). Clicking a log line opens it at «Detail» (not when Shift/Ctrl-selecting several lines).
  • «⋯ More» on the second send row: character delay, Send file… and (with repeat off) the repeat count. The repeat count shows in the row only while repeat is on or a count is set.
  • 📌 in the header: always on top — keeps this window above others (same as «Always on top» in Settings).
  • The window title shows the current state (e.g. «COM3 115200 8N1 · Connected ● REC — PortDock Serial»), so you can tell windows apart on the taskbar.
  • At 900 px wide or less (e.g. half-screen snap) the left connection panel folds away and a summary line with «⚙ Connection» and the connect button appears. «⚙ Connection» opens the panel; ✕ or clicking outside closes it.
  • The toolbar has «View options» (time gap column: none / gap from previous line / response time); the right side of the status line shows throughput (RX/TX B/s), frame counts and «last RX n s ago».
  • Second send row: «Repeat (ms)», «times», «+ Save to list», «Char delay (ms)» and «Send file…». ⚙ next to the checksum opens checksum options.
  • «Triggers» sits below «Commands» in the right pane (click ▸ to expand).

Connection settings

  • «Mode»: the tabs [Client | Server | Relay] — client (connect to the device), server (the device connects) or relay (monitor, see «Relay (monitor)» below). Each mode remembers its own address and port, so switching tabs never overwrites another mode's address (e.g. the client's device IP) with 0.0.0.0. It cannot change while running.
  • «Host» (client): IP address or name of the device, e.g. «192.168.0.10».
  • «Bind address (0.0.0.0 = all NICs)» (server): which network card accepts connections. Usually 0.0.0.0. To use one card only, enter this PC's IP on that card.
  • «Port»: for a client, the device's port (e.g. 502 for Modbus TCP); for a server, the port to listen on. A server port of 0 lets the OS pick a free port.
  • «Send immediately (no Nagle)» (in «Advanced connection»): small data is sent at once instead of being collected. Best left on for device testing.
  • «Reconnect automatically» (client): if the connection drops or fails, it retries every «Reconnect interval (ms)» (200 or more, default 2000). When off, it stops after the first drop. Each connect attempt waits up to 3 s.
  • «Echo received data» (server, in «Receive settings»): sends received data straight back to the sender. Can be toggled while running.
  • While running, the button reads «Disconnect» for a client and «Stop listening» for server/relay (F4 does the same).
  • When a client connects to port 502 but framing is not «Modbus TCP», a one-time «View as Modbus TCP» notice appears. Clicking it splits each request/response into one line with decoding in Detail.
  • Echo turns itself off above 200 times per second (two echoing sides would bounce forever). An «ECHO OFF …» line and an error message appear.
  • The server accepts up to 64 connections. Further ones are refused with «REJECT …».
  • While running, mode, host, port, no-delay and reconnect settings are locked (🔒). Echo, framing and the RX checksum check apply immediately when changed.
  • When waiting to reconnect or stopped, the status line also shows the last failure reason.

Connected peers (server)

  • While listening, «Connected peers» on the left shows the attached devices, or «None yet».
  • With two or more peers, «Disconnect all (n)» closes them all at once (listening continues).
  • «Kick» next to a peer closes that connection only. Long addresses (IPv6) are shortened with an ellipsis (hover for the full one) so «Kick» stays visible.
  • «To» at the left of the send row selects «All» or one peer.
  • With no peer connected, «Send» is disabled.
  • If the chosen peer disconnects, the selection does not fall back to «All»: it stays as «(disconnected) address» and «Send», «Repeat» and ▶ in the list are disabled until you pick another peer (reason: «The selected peer disconnected»). A running repeat stops with an EV line in the log.
  • When the same IP connects again (usually from a new port), «Same address reconnected» and a «Send to this peer» button appear. It never switches by itself.
  • If a send to «All» reached only some peers, it says e.g. «Sent to 2 of 3».

Framing

TCP delivers a continuous stream, so you choose where one line (frame) ends. Each connection is split separately, and in every mode whatever has arrived is released after «Idle gap (ms)» of silence.

  • «Idle gap»: split after the set time (default 20 ms) of silence.
  • «Terminator»: split as soon as the bytes in «Terminator (HEX)» arrive (e.g. «0D 0A»). The terminator stays in the line.
  • «Terminator (HEX)» accepts «0D 0A», «0D0A», «0x0D 0x0A» or names «CR LF»/«CRLF» (CR LF CRLF NUL STX ETX). Below the field it shows how it was read, e.g. «Read as: 0D 0A (2 bytes)», or the reason in red if it cannot be read. When empty, it warns that only the idle gap splits frames.
  • «Fixed length»: split every «Length» bytes.
  • An endless stream without gaps is split every 16 KB.
  • Changes apply immediately while running.

Reading a Modbus TCP device — walkthrough

Steps to read registers from a Modbus TCP device (PLC, drive, meter, gateway) once. To keep reading values in a table, PortDock Modbus Master is easier.

  • 1. Tab «Client», the device IP as address, port 502 → «Connect». The first time, a «View as Modbus TCP» notice appears — it sets framing to «Modbus TCP (MBAP length)».
  • 2. Open the request dialog with «Modbus…» in the send bar. Slave ID 1, function 03, start address («4xxxx notation» for 40001 style), quantity 10.
  • 3. «Put in input» sets the send bar to HEX, no checksum, no line ending and fills in the request with its MBAP header (transaction ID). «Send».
  • 4. Click the reply line: «Detail» shows the MBAP decoding and values paired with the request such as «40001 = 1812 (0x0714)» (same transaction ID). Exceptions show their name (e.g. 02 Illegal Data Address).
  • No reply: check the IP, port and Slave ID (behind a gateway, the RTU device's Slave ID).

Sending

Choose HEX or ASCII left of the input. While you type, «Bytes to send» shows the exact bytes and count. If the input is invalid, the reason appears there instead.

  • HEX: «01 03 0A», «01030A» and «0x01,0x03,0x0A» are the same 3 bytes. Separate with spaces, commas, semicolons or hyphens. Two digits per byte.
  • ASCII: characters are sent as typed. Special characters: «\r» (CR), «\n» (LF), «\t» (tab), «\0» (0x00), «\\» (backslash), «\xNN» (one byte in two HEX digits, e.g. «\x02»).
  • «Checksum»: CRC16 Modbus (low byte first), CRC16 CCITT and CRC16 XMODEM (high byte first), CRC8, LRC, BCC (XOR), SUM8, SUM16 (high byte first), CRC-32 (low byte first) or CRC (custom). ⚙ next to it changes the range, position and byte order.
  • «Line ending»: «None», CR, LF or CR LF appended at the very end. Separate from the receive-side «Terminator».
  • The order is «body + checksum + line ending». By default the checksum covers the whole body from the first byte, not the line ending (⚙ options change the range and position).
  • Examples: «STATUS?» + CR LF, or HEX «01 03 00 00 00 0A» + CRC16 Modbus → «01 03 00 00 00 0A C5 CD».
  • If a write fails (e.g. not written within 2 s), that connection can no longer be trusted, so it is closed and «SEND FAIL …» is logged.
  • Switching HEX↔ASCII converts the input to the same bytes in the new notation (e.g. «41 54 0D 0A» ↔ «AT» plus CR LF escapes). If the input cannot be read, the text is kept and a notice explains why.
  • If a checksum is on when you switch, a notice (instead of a dialog) says so and offers «Turn checksum off».

Repeat and commands

  • «Repeat (ms)»: when checked, the current input is sent at the set interval (10 ms or more). A turn is skipped if the previous send has not finished.
  • Repeat turns off when the connection drops and does not restart by itself.
  • «+ Save to list»: adds the current input (with mode, checksum and line ending) to «Commands» on the right. The name can be edited.
  • As a server, commands go to the peer chosen in «To».
  • Commands are kept when you restart the program.
  • In the list, ▶ sends (Enter or double-click in the name too), ✎ is «Load into the input», ⧉ duplicates and ✕ deletes. A deleted command can be restored with «Undo» in the notice for 5 seconds (no confirmation dialog).
  • Reorder with ↑/↓ left of the name, or Alt+↑/↓ in the name box.
  • When the list is empty, «Add examples» puts in a few common example commands (names start with «e.g.»). Serial follows «Use»: AT, ATI, AT+GMR or Modbus FC03/FC04 reads; TCP adds *IDN? (SCPI), an HTTP request and a Modbus TCP read (two Modbus TCP reads when framing is Modbus TCP); UDP adds a text, *IDN? and a HEX example. No write commands are added.
  • After «+ Add to list» the new command's name box is focused so you can rename it right away. «Add to commands» in a log line's right-click menu adds those exact bytes (HEX, no checksum or line ending).
  • «Export list» / «Import list» move only the command list as a JSON file (to another PC or another PortDock program). When importing into a non-empty list, choose «Append» or «Replace list» in place; «Undo» works afterwards too.

RX checksum verification

Choose a type in «Verify RX checksum» and each received line is checked for a correct checksum at its end, marked «OK» or «FAIL».

  • If framing is «Terminator» and the line ends with it, the terminator is removed and the checksum before it is checked.
  • Lines shorter than the checksum are not marked.
  • The file log gets «[OK]» or «[CHECK FAIL]».
  • Wrongly split frames also show «FAIL». Check framing first.

Log and event lines (EV)

EV lines between RX and TX record events such as connects and disconnects, and are written to the file log too.

  • CONNECT 192.168.0.10:502: the client connected.
  • CONNECT FAIL …: the connection failed (device off, wrong address or port, firewall, etc.). With auto reconnect on, it tries again.
  • LISTEN 0.0.0.0:5000: the server started listening on this address and port.
  • ACCEPT 192.168.0.20:51234: a peer connected to the server.
  • ACCEPT ERROR …: an error occurred while accepting a connection.
  • REJECT … — max 64 connections: refused because there are too many connections.
  • CLOSE address (reason): a connection ended. The reason is «closed by peer», «disconnected by user» or the error text.
  • STOP LISTEN: the server stopped listening.
  • ECHO ON / ECHO OFF: echo was turned on or off. When it turns off by itself above 200 per second, the reason is added.
  • SEND FAIL address: sending to that peer failed.
  • TRIGGER «name»: a trigger matched (may end with «— repeat stopped» / «— file log stopped»). Screen only.
  • REPEAT done (n sent): the repeat count was reached. Screen only.
  • LOG NEXT new name / LOG PART 2 (prev old name): the file log was split by size or time and continues in the next file (written to both files).
  • Follow: new lines are followed only while you are at the bottom. Scroll up to pause (the view stays put) — «↓ Jump to latest (n new)» appears at the bottom right. Click it, press End or scroll to the bottom to follow again. The «Auto-scroll» checkbox shows whether it is following.
  • Selecting: click a line, Shift+click for a range, Ctrl+click to add or remove one. Clicking does not stop following.
  • Right-click menu: Copy lines · Copy HEX · Copy ASCII · Copy HEX + ASCII · Copy as C array ({0x01, 0x03}) · Send again (TX lines — exactly those bytes) · Add to commands · Find this. Data copies (HEX, ASCII, C array) skip event lines (EV), one frame per line.

Find and filter the log

The row just below the toolbar finds and filters log lines. Filtering only changes the view — nothing is deleted, and the file log is not affected.

  • Find box: 2-digit HEX groups such as «01 03» search bytes; anything else searches text (case-insensitive). Pick «Auto», «HEX» or «Text» next to it when ambiguous (e.g. «0A»). Event lines (EV) are searched by their description in text mode.
  • Matches are highlighted; ▲/▼ (or Enter/Shift+Enter) select the previous/next match. «3/17» means the third of 17 matches («–/17» when the selected line is not a match).
  • «Matches only» shows only matching lines. «FAIL only» shows only lines whose RX checksum failed. The direction box: «All», RX, TX, EV.
  • While filtering, «120 of 5,000 lines» appears on the right; ✕ turns everything off. New lines keep arriving and appear when they match.
  • «CHECK FAIL n» in the toolbar counts lines with a failed checksum since the last «Clear» (shown only when there are any). Click it to toggle «FAIL only».
  • Keys: Ctrl+F focuses the find box, Enter next, Shift+Enter previous, Esc clears the text (press again to clear all filters).

Saving and detail

  • «Log to file»: while running, appends RX, TX and EV to the chosen file. Click again («Stop logging») to stop.
  • A file line (HEX format) looks like «2026-10-17 21:05:03.123 RX [192.168.0.10:502] 01 03 02 00 64 [OK]». In CSV the peer address goes in the last column (peer).
  • «Save view»: saves the lines on screen to a text file in the current «View» (HEX, ASCII, or «Both» as «HEX | ASCII»). With a filter on, only the visible lines are saved. The first line (starting with #) records the view, filter and line count. Times follow «Log timestamp» in Settings; lines with a failed checksum end with «[CHECK FAIL]». (The line format of «Log to file» follows «File log format» in Settings regardless of the view — HEX by default.)
  • «Clear»: empties the screen log and RX/TX counts. The file log is not affected.
  • Clicking a log line shows time, peer, byte count, HEX and ASCII in «Detail» (following continues).
  • In ASCII view, control characters appear as «<CR>», «<LF>», «<STX>», others as «<1B>» and so on. Bytes 0x80 and up are read with «Text encoding» in Settings.

Warning and hint messages

  • «Port 0 lets the OS pick a free port; the actual port appears in the status line after start.»: the server port is 0. If the device connects to a fixed port, enter that number.
  • «Opening a server the first time may show a Windows Firewall prompt (admin rights).»: if you do not allow it, other PCs and devices cannot connect. Click allow when it appears.
  • Echo turned off by itself («Echo turned off: over 200 per second»): the peer may be echoing too. Turn echo off on one side.
  • Settings: «Automatic logging will not start until a folder is chosen.»: you turned on «Start file logging on connect»; pick a folder with «Choose».
  • Settings: «Stop the connection and logging before importing.»: click «Stop» and «Stop logging» first.

Settings (⚙)

  • «Language»: 한국어 or English.
  • «Theme»: «Follow Windows», «Light» or «Dark».
  • «Font size (px)»: 11 to 18.
  • «Log timestamp»: «hh:mm:ss.ms», «Date + time», «UTC» or «Elapsed since start (Clear resets)». Applies to the screen and «Save view» (the file log always uses date + time).
  • «Lines kept on screen»: 1,000 to 1,000,000 (default 100,000). Older lines are dropped from the screen only.
  • «Auto-scroll on new lines»: the initial state of «Auto-scroll» (follow) when the program starts. Scrolling up still pauses it.
  • «Start file logging on connect»: with an «Auto-log folder» chosen, every start logs to «portdock-tcp-date-time.log».
  • «Ask before closing while connected or logging»: protects a running test from an accidental close.
  • «Export settings» and «Import settings»: move display settings and commands as a JSON file. Files from other PortDock programs are refused.
  • «Reset to defaults»: resets display settings only (commands are kept).
  • «Always on top»: keeps this window above other windows (same as 📌 in the header).
  • «Expand all (expert view)»: shows the groups that are normally collapsed (advanced connection, receive settings, fault injection, statistics, scan options, triggers, auto-reply …) open. Folding one while it is on lasts only for this run. Turning it off returns each group to its remembered state.

Shortcuts and tips

  • F4: start / stop (same as the button on the left).
  • Ctrl+L: clear the on-screen log (file logs are kept).
  • Ctrl+S: save view.
  • Ctrl+Shift+L: start / stop logging to file.
  • Esc: stop repeat sending (outside text boxes — inside a box Esc keeps its own meaning).
  • End: jump to the latest log line and follow again.
  • Ctrl+C: copy the selected log lines as «time direction data» (in the current view). Inside a text box it copies normally.
  • Ctrl+F: focus the log find box. In it, Enter next, Shift+Enter previous, Esc clear.
  • F1 or the ? button: this help. Close it with Esc.
  • Number boxes: ↑/↓ by 1, Shift+↑/↓ by 10, PageUp/PageDown by 100, or the mouse wheel once the box is focused. The baud box steps through the listed rates.
  • Shortcuts are ignored while a dialog or the right-click menu is open, or while composing Korean text.
  • ↑/↓ in the send box: recall earlier sends (history).
  • F2, F3, F5–F12: send the command with that key (the «Key» box in the command list).
  • Enter in the input: send (when a peer is connected).
  • In a narrow window, open the right pane with «☰ Commands» and close it with ✕ or by clicking outside.
  • Not sure whether the device is a client or a server? If its settings have a «server IP» field (where the device connects to), use this program as the server.
  • You can find this PC's IP with ipconfig in a Windows command prompt.

Input history and command hotkeys

  • ↑/↓ in the send box recall earlier sends (last 50, with their HEX/ASCII mode). Sending the same thing again just moves it to the end. History is kept across restarts.
  • Your unsent edit is never lost — it is set aside on the first ↑ and comes back with ↓ at the bottom. ↑/↓ do nothing while composing Korean text.
  • Only sends from the «Send» button and Enter in the box are remembered (not repeat, commands or Send again).
  • Command hotkeys: pick F2, F3 or F5–F12 in a command's «Key» box to send it with that key (works even while typing in the send box). F1 (help) and F4 (connect) are reserved; keys used by another command show greyed out as «F7 — «name»».
  • Hotkeys are saved in exported command lists. Duplicated commands get no key, and keys already in use are dropped on import. Hotkeys are ignored while a dialog or the right-click menu is open.

Time gap column, throughput and repeat count

  • «Time gap column» in the toolbar's «View options»: «Gap from previous line» shows the time since the previous RX/TX line (+12 ms); «Response time (TX→RX)» the time from the last TX to this RX. It appears next to the time and is included in line copies (Ctrl+C) and «Save view». Event lines (EV) stay empty.
  • Times have 1 ms resolution and include USB adapter / OS delivery delays (a few ms); use an oscilloscope for exact device timing.
  • Right side of the status line: «RX 1.2 KB/s · TX 0 B/s» is the throughput over the last second, «frames 120/30» the lines received/sent since «Clear», and «last RX 3 s ago» the time of the last reception. It turns red after 10 s of silence while running.
  • The «times» box next to «Repeat (ms)»: repeat stops by itself after that many sends (0 = until turned off). «sent 3/10» shows progress, and «REPEAT done (10 sent)» is added as an event line (screen only).

Triggers

Open «Triggers» in the right pane and click «+ Trigger». When a received line (RX) contains the pattern, the chosen actions run.

  • Pattern — HEX: «01 03 ?? **» (?? = any byte, ** = zero or more bytes). ASCII: e.g. «ALARM*» (? = any byte, * = zero or more, \r \n \xNN escapes, a literal ? is \x3F). Matches anywhere in the line, case-sensitive — the same rules as an auto-reply rule with «Wildcards» on.
  • Actions: «Color» (pick a color) · «Beep» · «Stop repeat» · «Stop log» (turns off Log to file) · «Event line» (an EV line «TRIGGER «name»») · «Flash» (flashes the taskbar when the window is in the background). Stopping repeat or logging is noted in the event line too.
  • Each trigger shows its hit count (e.g. «3×»), the header the total. «Reset counts» starts again from 0. Unchecking pauses one trigger; deleting can be undone for 5 seconds.
  • Triggers run on screen only (colors and event lines are not written to the file log). The list is kept across restarts.

Checksum options, CRC-32 and custom CRC

Click ⚙ next to the checksum in the send bar or in «Verify RX checksum» to open the options. ⚙• means options are on.

  • «Leading bytes left out of the calculation»: leaves a header such as STX or an address out.
  • «Insert this many bytes before the end»: puts the checksum m bytes before the end (before ETX etc.); those m bytes are left out of the calculation too. Example: «\x02AB\x03» + BCC, skip 1, before end 1 → 02 41 42 [03] 03. The line ending (CR LF) is still appended at the very end.
  • «Reverse byte order»: swaps 2- and 4-byte checksums. By default CRC16 Modbus and CRC-32 are low byte first; CCITT, XMODEM, SUM16 and custom CRC high byte first.
  • RX verification uses the same options — it skips the first n bytes and compares the checksum m bytes before the end (the terminator is removed first in terminator mode).
  • «CRC-32»: ISO-HDLC (as in zip/Ethernet), 4 bytes. «CRC (custom)»: width 8/16/32, poly, init, xorout (HEX), refin and refout exactly as in the reveng catalogue. «Preset» offers CRC-16/ARC, KERMIT, X.25, DNP, CRC-32/MPEG-2, CRC-32C and more. Values that do not fit the width are flagged in red and nothing is sent.
  • Checksum options are saved and exported with commands.

Text encoding and file log format

The «Text and file log» part of Settings (⚙).

  • «Text encoding»: UTF-8 (default), CP949 (EUC-KR), Latin-1, ASCII. Used for the ASCII view, copies and saves, and for characters sent in ASCII mode. Bytes the encoding cannot read appear as «<C7>», control characters as «<CR>». If a character to send is not in the encoding, «Bytes to send» explains why and nothing is sent (\xNN escapes always give that byte). Korean text in the log search is matched as UTF-8 bytes — search CP949 lines in HEX.
  • «File log format»: HEX (as before), ASCII (text), HEX + ASCII, or CSV (for Excel: «ts,dir,len,hex,ascii,check,note,peer», UTF-8 BOM). CSV cells starting with = + - @ get a leading ' so Excel does not treat them as formulas. With CSV the save dialog suggests a .csv name.
  • «Split by size (MB)» / «Split by time (hours)»: logging continues in «name-002.log», «name-003.log» … The old file ends with «LOG NEXT new name» and the new one starts with «LOG PART 2 (prev old name)». 0 means never split.
  • Format and splitting apply from the next file log you start (the current file is unchanged).

Send file and character delay

  • «Char delay (ms)» in the send bar: pauses this long between bytes for every send (Send, repeat, commands, Send again) — for slow devices with small buffers. 0 sends everything at once.
  • «Send file…»: choose a file (open dialog) and send it byte for byte — no checksum or line ending is added. Up to 32 MB.
  • «Split»: «Chunks» sends a fixed size (256 bytes by default) at a time; «Lines» splits after LF, CR LF or a lone CR and sends line by line. «Delay between characters» pauses between bytes, «Delay between lines/chunks» between lines (chunks).
  • While sending, a progress bar and «Sending 45% (1,843/4,096 bytes)» appear in the dialog and under the send bar, and the log shows a TX line per line/chunk. «Cancel sending» stops right there and logs «SEND CANCELLED 1843/4096». A disconnect stops it too.
  • Closing the dialog does not stop sending. After choosing a file, its size and an estimated time (from speed and delays) are shown.

Relay (monitor) — watch HMI ⇄ PLC

«Relay (monitor — A ⇄ this PC ⇄ B)» in «Mode» puts this PC between two devices. When A (e.g. an HMI/SCADA) connects to this PC instead of B (e.g. a PLC), each connection gets its own link to B and everything in between is logged.

  • 1. Enter «This PC address for A to connect to» (usually 0.0.0.0) and «Port» (e.g. 502), and the «Device to relay to (B)» host and port (the PLC's IP, 502). Press «Start listening».
  • 2. Change A's target IP to this PC (see «This PC» on the left). On connect, «RELAY A-address ⇄ B-address» is logged and A's address appears under «Relayed pairs».
  • Directions: «A→B ▶» is what A sent to B (RX in file logs and copies), «◀ B→A» is B's answer (TX). The peer column is A's address. Each direction has its own framer, so a split on one side never mixes with the other.
  • Data is forwarded the moment it arrives (framing and checksum checks only affect the log, never the forwarded bytes). Auto reply and echo are not used.
  • When either side closes, the other is closed too and the first side is logged, e.g. «CLOSE A ⇄ B (B side closed)». There is no reconnect — when A connects again a new pair is made. If B cannot be reached, «RELAY FAIL …» is logged and A is closed.
  • Injecting: pick «To A» or «To B» at the far left of the send bar and send (a specific pair can be chosen in «To»). Injected data is logged in that direction after an «INJECT → A/B» event. It reaches real equipment — be careful.
  • «Kick» next to a pair closes that pair (both A and B).

Modbus TCP

  • «Modbus TCP (MBAP length)» in «Framing» splits each request/response by the MBAP length field — even when two arrive together or one arrives in pieces. If the length field is implausible (over 260 bytes etc.) the «Idle gap (ms)» (default 1000) splits instead.
  • Detail pane: if the selected line is MBAP-shaped it shows transaction ID, length field (red if wrong), Unit ID (= Slave ID), function, address, quantity and values under «Modbus TCP · request/response», with a one-line summary «id1 FC03 HR 0..9 (10)».
  • «Paired with request»: if the selected line is a reply, the request from the same peer with the same transaction ID (opposite direction — in relay mode the RX request from the HMI side) is looked up and a value table with addresses such as «40001 = 1812 (0x0714)» is shown. Choose U16, S16, HEX, F32 ABCD, F32 CDAB and the address notation (0-based/4xxxx); exception replies show their name, e.g. «Exception 02 Illegal Data Address». It pairs only when Slave ID, function and byte count match.
  • «Modbus…» in the send bar builds a request with the MBAP header from Slave ID (goes into the MBAP Unit ID field), function, address (0-based/PLC notation) and quantity (or values). «Put in input» sets the send bar to HEX, no checksum, no line ending (Modbus TCP has no CRC). «Save to list» adds it to the commands.
  • «Auto MBAP transaction ID» (shown with Modbus TCP framing, on by default) puts an incrementing ID into the first 2 bytes of every send — repeat, commands and send-again included. Data that is not MBAP-shaped is sent unchanged.
  • To imitate a device, add an auto-reply rule that echoes the transaction ID and Unit ID (Slave ID), e.g. «{req 0..1} 00 00 00 05 {req 6} 03 02 00 64» (see «Reply templates»).

This PC's addresses (adapters)

  • Click the server/relay «Bind address» to pick one of this PC's adapter addresses (disconnected ones say «not connected») or 0.0.0.0 (all adapters). You can also type one.
  • «This PC» on the left lists connected adapters as IPv4/prefix and name. Click one to bind to it; hover for the description, netmask and gateway. ↻ reloads the list (e.g. after plugging a cable).
  • An address that is not on this PC is flagged before you start. If starting fails with «address not available», the error ends with this PC's addresses.
  • If it fails with «port already in use», the program holding the port and its PID are shown (no admin rights needed — system processes show the PID only).

Auto reply

«▸ Auto reply» in the right pane answers received lines with the same rules as Simulator — no separate device simulator needed.

  • «On» in its header turns it on or off (green when on). Rules are kept while off and reply as soon as it is on. Rules, the switch and match options survive restarts.
  • A rule: «When» pattern (HEX/ASCII, «exact»/«contains», HEX wildcards ??/**) → «Reply» (checksum, line ending, delay). The first matching rule replies, and every reply is logged as «AUTO name».
  • ASCII patterns compare literally (the default for new rules — SCPI «*IDN?» as is). Turn on a rule's «Wildcards» to make ? any one character and * zero or more. Rules saved before 10/18 load with it on, so they behave as before.
  • With no rules, the [Modbus RTU 03 reply] [SCPI *IDN? reply] [Echo] example buttons give you a start. A new rule takes the format of the rule above it (HEX/ASCII, exact/contains, reply format, line ending).
  • «Ignore line ending when matching» strips the framing terminator and CR/LF before comparing. «Log unmatched requests (NO MATCH)» logs «NO MATCH — closest: name» when no rule matches.
  • Replies go back to the sender (TCP server: that connection; UDP: the sender's address). If our own reply comes straight back, it is not answered again, so endless ping-pong cannot start.
  • The number on each card is its reply count; «Reset counts» sets it to 0. An invalid rule turns red and only that rule is skipped.
  • This is a simple auto reply riding on the connection. For many rules or device emulation (unsolicited sends and fault emulation included) use PortDock Simulator — a note under the panel says so too.

Reply templates ({…} fields)

A reply may contain {…} fields that are filled for every request. They work in HEX and ASCII, and «Insert field» next to the reply puts one at the cursor.

  • {req} whole request · {req 0..1} request bytes 0–1 (inclusive) · {req 6} one byte · {req 2..} byte 2 to the end · {req -2..-1} the last 2 bytes (negative counts from the end, -1 = last).
  • {counter} how many times this rule has replied (from 0), 1 byte · {counter 2} / {counter 4} size in bytes · add le for little-endian (default big-endian) · {counter dec} decimal text. «Reset counts» starts over at 0.
  • {rand 0..100} random value in the range (inclusive; size 1/2/4 bytes to fit the max) · {rand 0..1000 2 le} explicit size and order · {rand 10..99 dec} decimal text.
  • {time} current time «HH:MM:SS» as text · {time %Y-%m-%d %H:%M:%S} custom format · {unix} Unix seconds · {unix ms} milliseconds.
  • {crc kind} checksum of all bytes before this field, placed here · {crc bcc 1..-1} explicit range (counted over the reply without checksum fields) · add swap to reverse the byte order. Kinds: crc16-modbus, crc16-ccitt, crc16-xmodem, crc8, lrc, bcc, sum8, sum16, crc32.
  • Order: fill fields → {crc} fields → the rule's «Checksum» (over everything) → «Line ending». So «01 03 02 {req 4..5}» with checksum CRC16 Modbus equals «01 03 02 {req 4..5} {crc crc16-modbus}».
  • Example — Modbus TCP read of 2 holding registers: when «?? ?? 00 00 00 06 ?? 03 **», reply «{req 0..1} 00 00 00 07 {req 6} 03 04 00 64 00 C8». The transaction ID (bytes 0–1) and MBAP Unit ID (byte 6, the Slave ID) are echoed so the master can pair them. MBAP has no CRC, so set checksum to «None».
  • Example — a device with sequence numbers: «ACK {counter dec}\r\n» (ASCII). Example — BCC after STX…ETX: «02 {req 1..-2} 03 {crc bcc 1..-1}».
  • If a request is too short for a field such as {req 9}, nothing is sent and the log shows «AUTO name — request range …». A { that does not start a known name (req, counter, rand, time, unix, crc) is sent as is (e.g. {"ok":1}). To send text like «{req» literally, write \x7B in ASCII.
  • Type a request into «Sample request» under «More» (same HEX/ASCII as the pattern) to see whether it matches and the exact reply bytes. It is filled with count 0 and sample random values, so real values differ.

Fault injection and rotating replies

Expand «▸ More» on a rule card to test the host's timeout, retry and state handling. Active options are always shown as small tags under the card («delay 10–50 ms», «drop 1 in 3», …).

  • «Delay range»: replies after a random delay between the start and end (ms) every time (jitter). If the end is not above the start, the start is a fixed delay. The log shows the real delay, e.g. «AUTO name +37ms».
  • «drop every Nth request»: the Nth, 2Nth … requests matching this rule get no answer (0 = off). «% = drop by chance» drops with that probability. Dropped requests are logged as «DROP name — …» and do not count as replies.
  • «Rotate replies»: with several replies («+ Add reply»), each match sends the next one «in sequence» (1 → 2 → … → 1) or a «random» one — to mimic a device whose state changes (idle → running → done). The log shows which, e.g. «AUTO name [2/3]».
  • «In sequence» and {counter} use the rule's reply count — «Reset counts» starts over. Editing a rule (same name) keeps counting.

Troubleshooting

  • CONNECT FAIL keeps appearing: check device power and cable, IP and port, and that the PC and device are on the same subnet (e.g. 192.168.0.x).
  • «Already running or starting»: this program is already running. Click «Stop» and try again.
  • An «access» or «address in use» error when opening a server: another program is using that port. Use another port or close that program.
  • The server is open but the device cannot connect: check that you allowed the Windows Firewall prompt and that the device connects to this PC's IP.
  • Data merged or split: TCP does not keep message boundaries. Split with «Terminator» or «Fixed length», or adjust the idle gap.
  • Checksum «FAIL»: check the checksum type, framing, and whether the device leaves a header byte out of the calculation.
  • «No peer is connected»: no peer has connected yet, or it disconnected.
  • Windows 7 is not supported. Use Windows 10 or 11.
  • The program does not open: it needs Microsoft Edge WebView2. Windows 11 includes it; otherwise the installer downloads it (internet required). On an offline PC, install the WebView2 Runtime installer separately.