====== Synchronet Virtual DOS Modem ======
SVDM is a MODEM emulator for Windows which utilizes the Synchronet Virtual UART/FOSSIL Driver (''DOSXTRN.EXE/SBBSEXEC.DLL'') to enable support for DOS communications programs on Windows NT-based operating systems. 64-bit Windows support is enabled by also installing [[https://mendelson.org/ntvdmx64.html|NTVDMx64]].

SVDM should run on 32-bit and 64-bit editions of Windows XP and later.

Although SVDM reuses components of the Synchronet BBS Software and shares some of its source code and libraries, it is is not technically "part of" Synchronet BBS nor is it required for the normal use or operation of a Synchronet BBS.

You can find the latest "release" of SVDM available for download (as ''svdm??.zip'') at [[http://synchro.net/Synchronet/]].
===== Uses =====
  * Use 16-bit DOS terminal programs (e.g. Telix, ProComm, Qmodem, Telemate, etc.) to connect to Internet-connected BBSes
  * Use 16-bit DOS terminal program's "host mode" to accept incoming Telnet or "Raw TCP" connections from Internet clients
  * Use 16-bit DOS BBS program (e.g. Synchronet v1/2, WWIVv4, TriBBS, etc.) to accept incoming Telnet or "Raw TCP" connections from Internet users
  * Run 16-bit DOS door programs from Internet-connected BBSes (with the SVDM ''-h'' command-line option)

===== Features ===== 
  * Open source (Microsoft Visual C)
  * Emulates an NS16550 UART
  * Provides a FOSSIL/PC-BIOS (int14h) software interface
  * IPv4 and IPv6 support (for inbound and outbound connections)
  * Inbound connection filtering based on IP address/range
  * Telnet client and server support
  * Raw TCP client and server support
  * Play optional sound (wave) files upon "ring", connection, and disconnection
  * Accurate Hayes Smartmodem / USRobotics Sportster Modem "AT Command Set" emulation
     * Complete with virtual NVRAM settings/number storage (i.e. AT&W, AT&Zn=S)
     * Optional auto-answer (ATS0=1)
     * RING result upon incoming connections
     * Verbal and numeric result modes
     * Caller ID support (enabled with AT+VCID=1 or AT#CID=1)
     * "Dial" IP addresses or hostnames with optionally-specified TCP port and/or protocol

===== Install =====
SVDM currently does not include an "installer", so you will need to copy the following files to a directory ideally in your system's search path:
  * ''svdm.exe'' - the main program (modem emulator)
  * ''svdm.ini'' - configuration settings, optional
  * ''dosxtrn.exe'' - 16-bit FOSSIL driver and VDD loader
  * ''sbbsexec.dll'' - 32-bit Virtual UART/Device Driver

On 32-bit editions of Windows Vista and later, ''sbbsexec.dll'' must also be copied to your ''Windows/System32'' directory (by an administrator).

===== Usage =====
The general usage is to use ''svdm'' to execute the 16-bit DOS communications //program// of interest. Any command-line options you want to pass to the //program// may be specified on the command-line after the //program// path/filename.

<file>
usage: svdm [-opts] <program> [options]
opts:
        -telnet   Use Telnet protocol by default
        -raw      Use Raw TCP by default
        -4        Use IPv4 address family by default
        -6        Use IPv6 address family by default
        -l[addr]  Listen for incoming TCP connections
                  [on optionally-specified network interface]
        -p<port>  Specify default TCP port number (decimal)
        -n<node>  Specify node number
        -d        Enable debug output
        -h<sock>  Specify socket descriptor/handle to use (decimal)
        -r<cps>   Specify maximum receive data rate (chars/second)
        -c<fname> Specify alternate configuration (.ini) path/filename
        -V        Display detailed version information and exit
</file>

==== Flow Control ====
When utilizing UART (COM Port) virtualization (e.g. with most DOS terminal programs and some DOS door programs), be sure to enable RTS/CTS hardware flow control in the DOS program and do **not** enable DTR/DSR or XON/XOFF (software) flow control.

==== Ports ====

For DOS programs using UART/COM Port I/O, the COM port number (or I/O port and IRQ) must match what SVDM is virtualizing. By default, SVDM virtualizes COM 1 (I/O Port 3F8, IRQ 4), but this can be changed globally or per program via the ''svdm.ini'' file.

For DOS programs using the PC-BIOS/FOSSIL int14h interface, all COM ports are supported and treated identically (i.e. the ''DX'' register value is ignored).

==== Baud Rates ====

The DTE baud rate set by the DOS program is not used by SVDM (i.e. the transmit and receive data rates are only limited by the TCP/IP network). If you wish to artificially limit the receive data rate for some reason (not normally necessary), you can use the ''-r'' command-line option or the "Rate" key in the root section of ''svdm.ini'' to set the maximum receive rate, in characters per second.

A DTE rate of 38400 bps is reflected by virtual device driver and if the DOS program attempts to change this value, there is no effect.

==== Connect Rates ====

For incoming TCP connections, SVDM will report either "CONNECT 9600" or just "CONNECT" (assumed 300 bps) depending on the modem's extended response (''ATX'') setting.

==== Bits o' Parity ====

The communication data (word) bit width, stop bits, and parity settings used by the DOS program are not used by SVDM. The equivalent of 8 data bits, no parity, and one stop bit, is assumed.

==== Disconnect ==== 
If the DOS program de-asserts ("drops") DTR, the TCP connection will be terminated (by default). Alternatively, the DOS program can send the escape sequence (by default, "+++", surrounded by a one second guard time of inactivity) to enter command mode and then send "ATH" or "ATH0" to disconnect.

===== Examples =====

Run Telix (popular comm program for MS-DOS from the 1980s):
  svdm telix

Run Renegade BBS Software (in WFC mode), listening on all network interfaces for incoming TCP connections:
  svdm -l renegade
  
===== Dialing =====

SVDM responds to the ''ATD'' dial command to perform an outbound TCP connection. If the first character of the dial-string (following the 'D') is an uppercase 'T' or 'P', this character is ignored as it was used to specify "tone" or "pulse" dialing on the old telephone system and not relevant to TCP/IP connections. For example, any of the following commands may be used to "dial" test.synchro.net:
  ATDTtest.synchro.net
  ATDPtest.synchro.net  
  ATDtest.synchro.net
  atdtest.synchro.net

The address to "dial" may be specified as a DNS hostname, an IPv4 address, or an IPv6 address:
  ATDvert.synchro.net
  ATD192.168.1.2
  ATD[::1]

The TCP port to connect to may be specified following the address and a colon:
  ATDvert.synchro.net:23
  ATD192.168.1.2:23
  ATD[::1]:23
  
The TCP protocol to connect with may be specified (followed by a colon) before the address:
  ATDtelnet:vert.synchro.net
  ATDtelnet:192.168.1.2
  ATDraw:[::1]
  
The last "number dialed" can be dialed again by dialing 'L' or 'l':
  ATDL
  
Up to 20 dial strings (numbers) can be stored using the ''AT&Z'' command:
  AT&Z0=vert.synchro.net
  AT&Z1=L
  
Saved dial strings (numbers) can be queried/displayed using the ''AT&Z'' command:
  AT&Z0?
  AT&ZL?

Saved dial strings (numbers) can be dialed by using the ''ATDSn'' command:
  ATDS0

If your DOS terminal program of choice has trouble dialing long dial strings (e.g. accommodating long DNS hostnames or IPv6 addresses), try using the saved number storage feature to resolve that limitation. After enter the following command, dialing "S0" as a "phone number" would actually connect to "telnet:vert.synchro.net:23".
  AT&Z0=telnet:vert.synchro.net:23
  
Another option for dialing longer dial strings is to specify "aliases" in the ''[alias]'' section of your ''svdm.ini'' file. Any combination of printable ASCII characters may be used for a dial string alias, except for the colon ('':'') and equals (''='') characters.
<code ini>
[alias]
vertrauen=telnet:vert.synchro.net:23
</code>
  ATDvertrauen

===== Configure =====

SVDM's behavior can be customized or modified by specifying command-line parameters, invoking modem "AT commands", or creating/modifying a ''.ini file''.

The default configuration file ''svdm.ini'' will be loaded from the same directory where the executed ''svdm.exe'' is located.

^ Section      ^ Key       ^ Default       ^ Description ^
| //Root//     | ''Mode''  | ''Telnet''    | Specify the TCP protocol: ''Telnet'' or ''Raw'' |
| //Root//     | ''Port''  | ''23''        | Specify the TCP port number |
| //Root//     | ''Node''  | ''0''         | Specify the BBS node number |
| //Root//     | ''Listen''| ''false''     | Enable listening for incoming TCP connections |
| //Root//     | ''Debug'' | ''false''     | Enable debug output |
| //Root//     | ''LogLevel'' | ''Info''   | Set virtual UART/FOSSIL driver log level |
| //Root//     | ''YieldInterval'' | ''1.0'' | Set time-slice yield interval (in milliseconds) for FOSSIL driver |
| //Root//     | ''CanDisconnect'' | ''true'' | Set to ''false'' to disable ability for DOS program to disconnect |
| //Root//     | ''ServerEcho'' | ''true'' | The server (e.g. BBS) is expected to echo input back to the client (for Telnet option negotiation) |
| //Root//     | ''ServerBinary'' | ''true'' | The server (e.g. BBS) is expected to support Telnet binary transmission mode (for Telnet option negotiation) |
| //Root//     | ''Rate''  | ''0''         | Limit receive rate to a specific number of //characters-per-second// |
| //Root//     | ''AddressFamily'' | ''unspec'' | Default IP address family: "unspec", "ipv4", or "ipv6" |
| //Root//     | ''BusyNotice''    | hard-coded | Message to send before disconnecting remote connections when already-servicing a remote client/user connection | 
| //Root//     | ''AnswerBanner''  | hard-coded | Message to display upon incoming connections, blank to disable |
| //Root//     | ''ConnectMsg''    | //blank//  | Text to report following "CONNECT" for incoming connections when extended, verbose result codes are in use (e.g. ''115200/ARQ''), blank for the default ''CONNECT 9600'' behavior |
| //Root//     | ''RingSound''     | //blank//  | Wave file to play upon incoming "ring" |
| //Root//     | ''ConnectSound''  | //blank//  | Wave file to play upon connection |
| //Root//     | ''DisconnectSound'' | //blank//  | Wave file to play upon disconnection |
| //Root//     | ''IpFilterFile''  | //blank//  | Path/filename of file containing lists of IP addresses/patterns/ranges to reject incoming connections from |
| //Root//     | ''clientFile''    | ''client.ini'' | File to write incoming connected client information (e.g. IP address), blank to disable |
| //Root//     | ''MainLoopDelay''       | ''0'' | Milliseconds to yield CPU in application main loop |
| //Root//     | ''SocketSelectTimeout'' | ''0'' | Milliseconds to wait for receive data on TCP socket |
| ''Modem''    | ''AutoAnswer''    | ''false''  | Automatically answer/accept incoming TCP-connection attempts (''ATS0'') |
| ''Modem''    | ''CallerID''      | ''false''  | Incoming/client IP address reporting between RING results (''AT+VCID'' or ''AT#CID'') |
| ''Modem''    | ''Echo''          | ''true''   | Send AT command characters back to terminal (''ATE'') |
| ''Modem''    | ''Quiet''         | ''false''  | Respond to AT commands (''ATQ'') |
| ''Modem''    | ''Numeric''       | ''false''  | Respond to AT commands with numeric rather than verbal result codes (''ATV'') |
| ''Modem''    | ''Speaker''       | ''false''  | Enable modem speaker sound effects, i.e. play the ''RingSound''/''ConnectSound''/''DisconnectSound'' wave files (''ATM'') |
| ''Modem''    | ''CR''            | ''13''     | ASCII value of carriage return character (''ATS3'') |
| ''Modem''    | ''LF''            | ''10''     | ASCII value of line feed character (''ATS4'') |
| ''Modem''    | ''BS''            | ''8''      | ASCII value of backspace character (''ATS5'') |
| ''Modem''    | ''ESC''           | ''43, +''  | ASCII value of escape character (''ATS2'') |
| ''Modem''    | ''ExtResults''    | ''4''      | Extended results mode (''ATX'') |
| ''Modem''    | ''DialWait''      | ''60''     | Dial timeout in seconds (''ATS7'') |
| ''Modem''    | ''GuardTime''     | ''50''     | Escape sequence Guard time in 20-millisecond units (''ATS12'') |
| ''UART''     | ''Virtualize''    | ''true''   | Virtualize a UART (COM Port) in addition to providing a [[:ref:FOSSIL]] service |
| ''UART''     | ''ComPort''       | ''1''      | COM Port number (e.g. 1-4) to virtualize |
| ''UART''     | ''IRQ''           | //depends// | Hardware interrupt request (IRQ) line to virtualize, e.g. 4 |
| ''UART''     | ''Address''       | //depends// | Hardware I/O port base address (use ''0x'' prefix for hexadecimal notation, e.g. ''0x3f8'') |
| ''alias''    | various           |            | Each key is a unique dial string alias (e.g. ''mybbs = protocol:address:port'') |
| ''sockopts'' | various           |            | Options listed at ''[[config:sockopts.ini]]'' may be included in the ''[sockopts]'' section (for advanced uses only) |

Settings changed via modem AT command take precedence over command-line options which take precedence over ''.ini'' file settings.

Settings in the //Root// section may also be specified in a program-specific section (named after the program itself), to create program-specific settings.

Settings in the ''UART'' section may also be over-ridden in a program-specific section but naming the section ''[//<program>//.UART]''.
For example, by default SVDM emulates a UART for COM Port 1 (I/O address 0x3f8, IRQ 4), but you could change the emulated COM Port for one particular program by creating a program-specific UART section in the ''.ini'' file:
<code ini>
[telix.UART]
ComPort=2
</code>

===== AT Command Set =====

SVDM will recognize and respond to modem commands only when in "command mode".

When there is no active connection, "command mode" is the current mode. When there is an active connection, the terminal can force the modem into command mode by sending the Hayes-302 escape sequence (by default, "+++") with the minimum guard time of inactivity before and after the escape sequence. The duration of the guard time (default of one second) and the character repeated 3 times for the escape sequence are configurable via modem S-registers.

Modem commands are prefixed by "AT" (case-insensitively), which stands for "attention", hence the name "AT Command".

After the initial "AT" is sent to the modem, zero or more commands may be specified, followed by a final carriage-return (CR) character. The ASCII values of the carriage-return and line-feed characters are configurable via modem S-registers. The backspace character (configurable via S-register) is recognized as a destructive edit command to modify a command sequence before the command is submitted (usually with the ENTER key).

If all of the commands are valid, then the modem will respond with the "OK" response (or ''0'' in numeric response mode). There are exceptions (e.g. ''D'' command).

If any of the commands are invalid, then the modem will respond with the "ERROR" response (or ''4'' in numeric response mode).

Any white-space characters within the AT command sequence are ignored.

Some commands (e.g. ''D'', ''&Zn=''), must be the last command of the command sequence since they accept an arbitrary string argument that may contain otherwise-valid AT command characters and sequences.

^ Command ^ Description ^
| ''A''   | Answer an incoming call (accept an incoming TCP connection) |
| ''D[T|P]s'' | Dial a number string (connect to the specified TCP host) |
| ''En''  | Set command echo (e.g. ''ATE0'' to disable command echo) |
| ''Hn''  | Control ON/OFF hook (e.g. ''ATH0'' to hang-up) |
| ''In''  | Display modem information |
| ''Ln''  | Control speaker volume (ignored) |
| ''Mn''  | Enable speaker (e.g. ''ATM1'' enables wave file playback) |
| ''O''   | Return online (from command mode) |
| ''Qn''  | Display/suppress result codes (e.g. ''ATQ1'' enables //quiet mode//) |
| ''P''   | Pulse mode dialing (ignored) |
| ''Sr=n''| Set register //r// to //n//. |
| ''Sr?'' | Display value of S-Register //r//. |
| ''T''   | Tone mode dialing (ignored) |
| ''Vn''  | Control verbal result codes (e.g. ''ATV0'' enables //numeric// result mode) |
| ''Xn''  | Control extended result codes (e.g. ''ATX0'' disables extended result codes) |
| ''Z''   | Initialize/re-initialize modem (e.g. re-read ''.ini'' file) |
| ''&W''  | Write modem settings to ''.ini'' file |
| ''&Zn=s'' | Store a dial string //s// into slot //n// (0-19) |
| ''&Zn=L'' | Store last-dialed string into slot //n// (0-19) |
| ''&Zn?''  | Display saved dial string from slot //n// |
| ''&ZL?''  | Display last dialed string |
| ''+VCID=n'' | Control Caller ID reporting (alias: ''#CID='') |
| ''+VCID?'' | Query Caller ID enabled status (alias: ''#CID?'') |

S-Registers store additional/advanced modem settings as decimal-numeric values:

^ S-Register ^ Default ^ Description ^
| 0          | 0       | Auto-answer after this number of rings |
| 1          | 0       | Counts number of phone rings |
| 2          | 43      | ASCII value of escape code character (128-255 to disable) |
| 3          | 13      | ASCII value of carriage-return character |
| 4          | 10      | ASCII value of line-feed character |
| 5          | 8       | ASCII value of backspace character |
| 7          | 60      | Number of seconds to wait for carrier (TCP connection success) |
| 12         | 50      | Guard time duration (in 20 millisecond units) |
 
===== See Also =====
  * [[:util:|Utility index]]
  * [[:monitor:sbbsexec]]
  * [[:config:sbbsexec.ini]]
  * [[https://www.youtube.com/watch?v=fxp38Nde3fg|Initial demonstration/announcement video]]

{{tag>modem fossil uart emulation terminal MS-DOS client}}
