com0com & Virtual Null-Modem COM Pairs


Definition: com0com (Null-modem emulator) is an open-source kernel-mode virtual serial port driver for Windows. It enables developers and engineers to create interconnected pairs of virtual COM ports (e.g. COM3 <-> COM4) without physical serial hardware or cables.

What is a Null Modem?

Historically, a null modem is a physically crossed RS-232 serial cable used to connect two DTE (Data Terminal Equipment) devices directly—such as two PCs—without a modem in between. The Transmit (TX) line of one device connects to the Receive (RX) line of the other, and hardware handshaking lines (RTS/CTS, DTR/DSR) are cross-connected.

graph LR subgraph "Device A (Sender / App)" DTE1["PC A (Serial App)"] end subgraph "Crossed RS-232 Null-Modem Pinout" DTE1 -->|"TX (Transmit Data)"| RX2["RX (Receive Data - Device B)"] TX2["TX (Transmit Data - Device B)"] -->|"RX (Receive Data)"| DTE1 DTE1 -->|"RTS (Request To Send)"| CTS2["CTS (Clear To Send - Device B)"] RTS2["RTS (Request To Send - Device B)"] -->|"CTS (Clear To Send)"| DTE1 DTE1 -->|"DTR (Data Terminal Ready)"| DSR2["DSR / DCD (Data Set Ready - Device B)"] DSR2_SRC["DTR (Device B)"] -->|"DSR / DCD"| DTE1 end subgraph "Device B (Receiver / Sim)" RX2 --- DTE2["PC B (Device Simulator)"] TX2 --- DTE2 CTS2 --- DTE2 RTS2 --- DTE2 DSR2 --- DTE2 DSR2_SRC --- DTE2 end

RS-232 Signal Line Breakdown

How com0com Virtual Null-Modem Driver Works

The com0com driver creates virtual device instances in Windows kernel space. When an application writes data to virtual port CNCA0 (aliased as COM3), the driver redirects the data stream directly into the input buffer of virtual port CNCB0 (aliased as COM4), simulating an instantaneous physical null-modem link with near-zero latency.

graph TD AppA["Serial Client Application (e.g., PuTTY / Custom C# App)"] <-->|COM3 / CNCA0| Driver["com0com Kernel-Mode Virtual Driver"] Driver <-->|COM4 / CNCB0| AppB["Device Emulator / Simulator (e.g., Python / Modbus Sim)"]

Key Use Cases

Configuring Virtual COM Pairs via CLI (setupc.exe)

While com0com offers a graphical user interface (GUI), it can be fully scripted and configured using the command-line utility setupc.exe:

# Install a new virtual port pair
install PortName=COM3 PortName=COM4

# View existing virtual port pairs
list

# Enable baud rate emulation (optional)
change CNCA0 EmuBR=yes
change CNCB0 EmuBR=yes

# Remove a virtual port pair
remove 0

Comparison: Physical vs. Virtual Serial Ports

Feature Physical Serial Port (RS-232) Virtual COM Pair (com0com)
Hardware Required RS-232 Cables, USB-to-Serial DB9 None (Kernel Driver)
Maximum Speed Typically 115,200 baud (up to 1-3 Mbps) Unlimited (RAM throughput GB/s)
Latency Physical propagation delay Near-zero (<1 ms memory copy)
Signal Pin Emulation Physical voltage levels (±12V) Software emulated (RTS, CTS, DTR, DSR, DCD)

Complementary Tool: com2tcp

Included with the com0com suite is com2tcp, a console application that bridges a virtual COM port to a TCP/IP network connection. This allows serial applications to communicate over Ethernet or local sockets seamlessly:

# Bridge virtual COM4 to a remote TCP server on port 4000
com2tcp.exe \\.\CNCB0 192.168.1.50 4000