Let’s get TCP working with MS-DOS

We showed a few MS-DOS applications before, showcasing text-mode file managers, command prompt history, archivers, text editors and banner creators. We even remembered MemMaker, the RAM optimizer saving our souls when we needed a few more kilobytes of memory for that stubborn game. And yes, we talked about the rudimentary connection between two computers over serial cable.
The direct cable connection between the two computers enabled the most basic form of communication between them. Of course, we were limited by the number of available ports. If today we have USB ports everywhere, easily reaching a dozen, and extensible with USB hubs, in the past ports were a limited affair. Computers were usually fitted with one parallel port and two serial ports, often one occupied by a mouse. And if we were in an office, the parallel port would usually be busy with a printer.
This port scarcity made computer connectivity expensive. It also made computer networking impossible. Connection was practically limited to two computers, and they would better be close together, because serial cable length could not stretch too far without corrupting the connection.
Networking and MS-DOS
Networking was also not really a thing when MS-DOS was initially released. The main networking brand back then was Novell, and they started the whole personal computing networking fever by launching the NE1000 card for the PC, followed by the NE2000 upgrade. But if the first MS-DOS version was launched in 1981, these network cards appeared just around 1987. Personal networking was simply not something the MS-DOS developers were thinking about.
Now, the TCP protocol was invented in 1974 and Unix systems were already using it almost at launch. In fact, TCP was designed to be applied with Unix because of its features. But remember, MS-DOS did not even exist back then. So not only there were no personal computing network cards when MS-DOS was released, there was not even a TCP stack for it. Nobody really thought of personal networking.
Well, nobody until Microsoft released Windows 3.11 for Workgroups in 1993. That’s almost ten years since the first MS-DOS version. And not even Windows for Workgroups had a TCP stack bundled. The official Microsoft TCP stack was released later in 1995 and was intended for Windows 95. It worked with Windows 3.11 just as a backwards compatibility feature. We know how Microsoft loves their backwards compatibility.
Suffice it to say MS-DOS never had a TCP/IP stack. The one we need to use is mTCP, a collection of TCP applications for MS-DOS written by Michael Brutman. Fortunately, as of 2023 it is still maintained. We can grab it from the official page or from my Github.
Enabling networking in 86Box

But if technically there was a network card available made by the venerable Netware, and if we have access to some TCP utilities, it means today we can connect an MS-DOS system to the Internet, right? Let’s try it!
First, we need to add a network card to our 86Box virtual computer. We do this in the Settings dialog using the Network tab, where we pick the Novell NE2000 network card. We also need to configure the hardware ports where the card will be installed, and note the SLiRP networking mode. SLiRP will link the virtual network card to a sort of virtual router that is able to talk with the host computer, enabling Internet access from the host:

Enabling networking in MS-DOS
Now we need the Novell NE2000 driver which again can be found on my Github page. It’s the network.zip
file and contains the NE2000 driver along with a network card detector. I bundled it in the image thinking it might be useful but it’s not very precise. Now we can start the driver giving the ports as parameters:

The driver does take a bit of RAM, so we might want to skip it when dealing with resource intensive games:

Configuring TCP/IP with mTCP

We can also add the driver to autoexec.bat
so it runs at startup. We did a small optimization here to load it in the high memory area, freeing a bit of conventional RAM. Note the SET MTCPCFG
command above. This points to a TCP configuration file detailing the computer IP address, gateway, and DNS. These must be as below because they are the default for 86Box:

After all is configured, we simply reboot the system to run the driver and set the MTCPCFG
environment variable. We are ready to run PING
:

In the above screenshot we pinged our host computer, which as said before is our gateway and DNS. This is SLiRP. We have a virtual router that connects our MS-DOS computer to the host, sharing the Internet connection. The MS-DOS computer has the IP 10.0.2.15, the gateway has 10.0.2.2 and the DNS has 10.0.2.3. Since both the gateway and the DNS are our host computer which has access to the Internet, the virtual MS-DOS computer also has access to the Internet. This means we can reach other websites:

Again, note that all of the above can be achieved with the official Microsoft TCP/IP stack for Windows 3.11, but that stack won’t work just with MS-DOS. The stack we use here is made specifically for MS-DOS and enables it to make full use of the Internet.
So technically we are done. At this point our computer has internet access and MS-DOS can see and reach other Internet services. Next time we will learn how to take advantage of this new ability. Thank you for reading and see you then!