Networking and FreeDOS

6-2-2013

All I want is a way to transfer files. (Although my FreeDOS machine has a floppy, almost none of the other machines I work with in this day and age do, and floppies were horribly unreliable even in the best of worlds).

Initially I thought that setting up networking was going to be some labor of hercules effort to get set up. I was completely wrong, it is dead easy. Here is an outline to get you oriented:

  1. Select a network card.
  2. Load a packet driver for that card.
  3. Set up the file wattcp.cfg
  4. Run the scp2dos application
It is just that simple, at least it was for me, but of course there are some important details and one big gotcha along the way.

The Network Card

My advice up front is to select and use a PCI network card. You can struggle with an old jumper configured ISA card if you want (I have plenty of those and indeed may screw around with them someday). A PCI card will just make your life easy. An ISA "plug and play" card is very likely to be your worst nightmare.

The card I used was a 10baseT card based on the Digital 21041 chip, also known fondly as the "tulip" card.

The Packet Driver

This was dead easy because the FreeDOS 1.0 install did the dirty work for me. Along towards the end of the install process, it offered to install a packet driver for me. I agreed to the offer. It detected my card in PCI slot 01 with IRQ 0B and offered to add an entry to my autoexec.bat. This turned out to be the following line:
C:\FDOS\drivers\net\crynwr\dc 0x60
The 0x60 is apparently the software interrupt to be used by the packet driver.

The WATTCP configuration file

Put the file wattcp.cfg into the directory /fdos/bin where the executables for all the network applications are (see below). Don't trip over a useless file in the /net directory. The file wattcp.cfg holds network configuration for applications based on the wattcp stack (such as ssh2dos). Note that wattcp is a library that applications (in my case ssh2dos) can use to incorporate TCP functionality, any such application will reference wattcp.cfg.

Just to belabor the point, for anyone from a unix/linux background. In any unix/linux system, the network stack is part of the kernel and is shared by all applications. Things are totally and utterly different with WATTCP under dos. Here the only thing shared is the packet driver which is loaded once and for all at boot time. The network stack is linked into each and every WATTCP based application. This in fact works just fine given that DOS is not a multitasking OS and only one application is ever running at a time.

However, this also means that the Freedos machine will not repond to ping (since no network stack is loaded and running).

I scratched my head for some time wondering where to put this file. Apparently the idea is that this file is located in the same directory as the application (in my case ssh2dos) using it. This would be the directory C:\FDOS\BIN, so that is where it goes.

A minimal file might be:

my_ip=192.168.0.5
netmask=255.255.255.0
A more sophisticated file might be:
my_ip=192.168.0.5
netmask=255.255.255.0
gateway=192.168.0.1
nameserver=128.97.111.3
nameserver=128.98.0.2
If there was a ping utility included as part of FreeDOS, (although oddly enough there is not) it just might be wattcp based and reference this file.

Heading off on a tangent for just a moment. Somewhere it was suggested that you could define a variable in your autoexec.bat indicating where this configuration file is located. Something like:

SET WATTCP.CFG=C:\NET\WATTCP.CFG
I tried this, but it did not work for me.

ssh2dos (ssh2d386)

This one network application is all that I need, (well actually it is scp2dos that I really need). It should just work given the setup described above. Rumor has it that this program takes a long time (minutes) to set up a connection, but I have not found this to be the case (maybe it would be on a 8 Mhz 8086). On the Pentium 166 I am using, it only takes 5-10 seconds.

Note also, it is recommended that on a 386 chip or better, the ssh2d386 executable be used, although the ssh2dos executable certainly works.

Note that there are both sshdos and ssh2dos. The sshdos package uses protocol version 1.5 and is almost certainly not what you want (it won't run against the ssh servers on my linux machines). The ssh2dos package uses protocol version 2.0, which is what you want in this day and age. The claim is that the ssh2dos package includes ssh and scp (which I have found) as well as sftp and telnet clients (which I have yet to find, but see below).

Typical use:

ssh2dos user 192.168.0.4
ssh2dos -s password user 192.168.0.9
ssh2dos -t vt100 -v -n -g username servername
ssh2d386 user 192.168.0.9
The "-v" switch turns on verbose mode, so it tells you what it is doing when it is establishing a connection. You need to use IP numbers since you don't have a DNS service.

scp2dos (scp2d386)

OK, the bad news right up front. The version of scp2dos (0.1.1) shipped with FreeDOS 1.0 has bugs and will not work. Well it half works, it copies files from my FreeDOS machine to my linux server just fine, it just won't work in the other direction. There is a newer version that does work (see below).

To copy files to my freedos computer I attempt to do:

scp2d386 user@server:file localfile
scp2d386 -s password user@server:file localfile
These give the message "Protocol error: Expected control record". Some people have erroneously claimed that this is a problem with my server, which is spitting out some text due to commands in my .bashrc or some such. This is baloney. Any number of other ssh clients work just fine with my ssh server. And when I follow this advice and go to some lengths (via a .hushlogin file) to make my server silent it still fails.

A link to a recommended set of "fixed" packages (thanks to Geraldo Netto geraldo_boca_at_hotmail.com) is:

I fetched these (version 0.2.1) and they fix the problem! As a bonus, this package includes the sftp and telnet that do not seem to be included with FreeDOS 1.0
Now if I could just find ping!! Rumor has it that the Wattcp-32 package includes ping, tcpinfo, and something like arp.

The scp2dos program is in C:\fdos\bin\scp2dos.exe On sourceforge (as of 9/2010) this seems to be up to versions 0.2.1 and the download is SshDosSockets.zip -- the trick though is how to get this onto my freedos machine without a working scp2dos program. :-(

To copy files from my freedos computer I do:

scp2d386 localfile user@server:file
scp2d386 -s password localfile user@server:file
Both of these commands work in either the 0.1.1 and 0.2.1 version without the above "control record" problem.

DNS

Amazingly, it would seem that DNS is included as part of the WATTCP stack given that the configuration file allows you to specify nameservers and domains and such. My problem is that it has yet to work for me, and I still just use IP numbers. Stay tuned.

All you ever wanted to know about DOS networking

A very nice essay was written in 2007 by Ulrich Hansen. It was available at the this link, and I also have a local copy here. (It is a very good write up, and it would be a pity if it vanished).

Links


Have any comments? Questions? Drop me a line!

Adventures in Computing / tom@mmto.org