Using mTCP in Virtual Environments

mTCP meets DOSBox, VirtualBox and VMWare!


A few years ago if you wanted to run DOS on a machine you either had to have an old machine to run it on or hope that your new machine was not too advanced for a 20 year old operating system. Emulated and virtual machines like DOSBox, VirtualBox, and VMWare breathe new life into DOS and other obsolete operating systems by letting you run your DOS applications side by side with your current applications on the latest and greatest hardware.

The following are some quick notes on three emulation and virutal machine environments that I have used. I expect others to be similar.

DOSBox

DOSBox is an x86 PC emulator designed to run old DOS games on modern hardware running modern operating systems. While Windows XP has a DOS-like command line it is not sufficient to run many old games. This is where DOSBox takes over and shines.

While relatively full featured, DOSBox is not a full machine emulator. DOS is emulated just enough to make the old games run. The command prompt recognizes a few major commands; you may need to add more from your favorite DOS version. DOSBox can be configured to share part of the host operating system filesystem so that moving files in and out is not too hard.

By default there is no networking support. To get an emulated network device you need to use a special build of DOSBox created by "HAL9000". The HAL9000 "megabuilds" add NE2000 emulation allowing networking applications to run, plus a few other goodies. When using the NE2000 emulation DOSBox will appear to be physically connected to the network. (This is commonly known as "bridged" mode.) I have been using the megabuilds for over two years now and I am very pleased with their quality.

I do most of my functional testing with DOSBox so I know that it works well with mTCP. The biggest function missing from DOSBox is proper Ctrl-Break and Ctrl-C handling. mTCP lets you break out of some long running applications using Ctrl-Break and Ctrl-C so under DOSBox that feature might not work. But for the most part DOSBox is a great way to run mTCP.

DOSBox main site http://www.dosbox.com/
HAL9000 DOSBox megabuilds http://home.arcor.de/h-a-l-9000/
NE2000 packet driver for use with the HAL9000 megabuild http://www.brutman.com/mTCP/NE2000.COM

VirtualBox

VirtualBox is an open source program that creates a virtual x86 machine within your host operating system. You define the amount of memory, the size of the virtual hard drive, the amount of video memory, networking support, and a few other attributes to create a virtual machine. Then you boot the virtual machine and install DOS on it, just like you would do on a bare machine that you are installing for the first time. The virtual machine emulation takes advantage of modern CPU features making it extremely fast - almost as fast as running directly on the hardware without the host operating system in the way. Virtual machines slow down when doing I/O operations but it is not enough to worry about.

VirtualBox  has a variety of network cards that it can emulate and it can make your virtual machine look like it is directly on the network ("bridged"), behind a firewall ("NAT", or Network Address Translation), and a few other options. I use "bridged" mode and the AMD PCNet device, which is the same device used by VMWare Player. If you use a different emulated device be sure to find the correct packet driver for it.

All of the mTCP applications run well except for PING, which runs but seems to suffer from a timing problem. I reprogram the interval timer to get higher resolution timings than are normally possible on DOS and it looks as though PING is tripping on this. It will eventually complete but it takes much longer between ping packets than it should. (The packet timings are accurate, but the wait time between packets is too long.)

VirtualBox main site http://virtualbox.org/
AMD PCNet packet driver http://www.brutman.com/mTCP/PCNTPK.COM


FreeDOS and VirtualBox

Interested in getting started quickly with FreeDOS and Networking? Ulrich Hansen put together a virtual machine and disk image that includes FreeDOS, mTCP, and a wide variety of TCP/IP programs and utilities from other authors. This gives you a quick way to sample the applications without installing everything by hand.

Ulrich's FreeDOS Networking sampler can be found at: http://lazybrowndog.net/freedos/virtualbox/


VMWare Player

VMWare Player is a closed source (but free) virtual x86 machine that is very similar in operation to VirtualBox. (VMWare predates VirtualBox by quite a bit.) You define your virtual machine, install DOS, and then run it side by side with your host operating system.

The networking works basically the same way as it does in VirtualBox - "bridged" makes your virtual machine look like it is directly connected to the LAN. "NAT" (Network Address Translation) makes it look like your virtual machine is hiding behind a firewall on your host operating system. "Host-only" is the most limited, and it allows you to communicate only with the host operating system. VMWare emulates some form of  AMD PCNet Ethernet device.

I am using version 3.1.3 on Windows XP. Everything works perfectly, including PING, so VMWare Player probably does a better job of emulating the PC timer hardware that I am reprogramming.

VMWare Player main site http://www.vmware.com/products/player/
AMD PCNet packet driver http://www.brutman.com/mTCP/PCNTPK.COM


SwsVpkt

SwsVpkt is a virtual packet driver that allows DOS networking applications to run directly under Windows NT4, 2000 and XP in a command window.

SwsVpkt works by letting those applications send RAW Ethernet packets to and from the network using a network card on the machine. Unlike the other solutions on this page SwsVpkt does not give your code the illusion of having a separate network card with a unique MAC address. Your DOS application will be sending and receiving packets using the actual MAC address of the card you select to use. If you use the same card that your host operating system is using you need to configure mTCP to use a different IP address than what your host is using. This makes DHCP unusable as your DHCP server will see the MAC address and give mTCP the same address that it gave your host operating system. As a result, static configuration of the IP address in the mTCP configuration file is required.

Here are some usage notes:
On my machine "swsvpkt -l" finds four network adapters it can bind to:
E:\DOSPROGS\MTCP>swsvpkt -l

Packet driver for Windows VDM version 1.05, updated Fri May 19 12:59:33 2006
Copyright (C)2005,2006 Lawrence Rust. All rights reserved.

Found interface:
0: VMware Virtual Ethernet Adapter
1: VMware Virtual Ethernet Adapter
2: Intel(R) 82562V-2 10/100 Network Connection (Microsoft's Packet Scheduler)
3: NOC Extranet Access Adapter (Microsoft's Packet Scheduler)

To run I use swsvpkt -a2 0x60:
E:\DOSPROGS\MTCP>swsvpkt -a2 0x60

Packet driver for Windows VDM version 1.05, updated Fri May 19 12:59:33 2006
Copyright (C)2005,2006 Lawrence Rust. All rights reserved.

Found interface:
0: VMware Virtual Ethernet Adapter
1: VMware Virtual Ethernet Adapter
2: Intel(R) 82562V-2 10/100 Network Connection (Microsoft's Packet Scheduler)
3: NOC Extranet Access Adapter (Microsoft's Packet Scheduler)

Installed on SWI 0x60, using IRQ 7.

The mTCP applications seem to work normally when run using swsvpkt. I have noticed that swsvpkt leaves the command window in a strange state - command line editing no longer works after I have run it. I'm not quite sure what is going on, so if you know what it is please drop me a line. (Other command line windows are not affected.)

SwsVpkt main site http://www.softsystem.co.uk/products/swsvpkt.htm



Created March 10th, 2011, Last updated May 30th, 2012
(C)opyright Michael B. Brutman, mbbrutman@gmail.com