mTCP Setup DHCP client for DOS logo

Introduction

To communicate on a network a machine must have a valid IP address and some configuration settings. Most modern computers and devices today use DHCP to get their IP address automatically from a router on the local network. mTCP includes a DHCP client that allows your PC running DOS to get an IP address in the exact same way. Or if you prefer, mTCP can be configured to use a hard coded IP address and related configuration settings that you provide. That method (known as static configuration) was commonly in use many years ago but has been superceded by DHCP.

This is the quick version of how to setup mTCP. The detailed instructions for the mTCP DHCP client can be found in DHCP.TXT and a more comprehensive setup guide can be found in SETUP.TXT.

mTCP requires a packet driver be loaded, an environment variable be set, and a configuration file be created before it can run. These three things allow it to talk to your Ethernet card (or emulated device) and find the configuration settings that it needs. Here are the high level steps for getting started:

  1. Load the packet driver for your Ethernet card
  2. Set the MTCPCFG environment variable to point at your mTCP configuration file
  3. If using DHCP, run the mTCP DHCP client

That's it! Here are the details ...

Loading the Packet Driver

(Note: If you are using PPP or SLIP the general procedure is the same. But see SETUP.TXT for some details that apply only to PPP and SLIP.)

mTCP does almost everything except talk to your Ethernet card. There are a lot of Ethernet cards out there and they all use different hardware and look different at the hardware level. To make mTCP able to use a wide variety of Ethernet cards a piece of code called a 'packet driver' gets loaded first. Each Ethernet card comes with a packet driver designed for that specific Ethernet card and that packet driver is responsible for making the Ethernet card look like a standard device. mTCP talks to the packet driver in a generic way while the packet driver converts the requests to something meaningful for your Ethernet card. That keeps mTCP from having to know the details of every Ethernet card out there - it just has to know how to talk to packet drivers.

You need to have the correct packet driver for your Ethernet card. Here are some places to look:

Almost all classic 8 and 16 bit Ethernet cards (3C503, NE1000, NE2000, WD8003, SMC, Intel 8/16, etc.) have a packet driver available. Many PCI cards and Ethernet devices embedded on motherboards have a packet driver available as well. Some devices that are not Ethernet such as serial ports and parallel ports can be made to look like an Ethernet device with a special packet driver; the setup for PPP and SLIP in SETUP.TXT explains how to use those.

The exact parameters on the packet drivers will vary but one that you will always have to provide is the software interrupt number that the packet driver is going to take control of. The software interrupt number is the address of the 'service' that the packet driver is going to provide to mTCP applications, and that service is the ability to send and receive packets on the Ethernet hardware.

Note that the software interrupt number has nothing to do with the configuration of the Ethernet hardware. The software interrupt number is assigned by you and you are telling the packet driver which software interrupt to use. Software interrupt numbers are usually in the range of 0x60 (hex) to 0x66 (hex). You need to pick one that is not in use already but since most DOS software does not these software interrupts 0x60 is usually available. This is in contrast to hardware interrupt numbers, which is what the Ethernet card uses to signal to the computer that new packets have arrived. Hardware interrupts are set on the card using jumpers or by configuration software that comes with the card.

Here is an example showing an NE2000 clone card being loaded using the default I/O ports and IRQ3 . It is also being told to use software interrupt 0x60:

ne2000 0x60 3

Here is another example featuring an older Western Digital 8003 card:

smc_wd 0x60 0x03 0x280 0xD000

In this example the software interrupt to use is 0x60, the IRQ is 3, the I/O ports start at 0x280, and the shared memory address for the RAM on the card is going to be located at 0xD000:0000 in memory.

For a general discussion on packet drivers see the DOS Packet Drivers page.

Creating the configuration file

Next it is time to create the configuration file. You generally have to do this just once.

mTCP requires a configuration file to tell it things like the IP address to use, where the nameservers are, etc. There are two ways to create this configuration file:

If you are going to use DHCP you can get by with just two lines in the configuration file. One line tells mTCP which software interrupt to use to talk to the packet driver. The other assigns a hostname to your machine. Here is an example of a minimum configuration file for mTCP:

PACKETINT 0x60
HOSTNAME PCjr

Just create a file with these lines, substitute in the correct software interrupt value and hostname for your machine, and you can move onto the next step. (The PACKETINT parameter here needs to be set to whatever software interrupt you told the packet driver to use. Hostname can be whatever you like, but don't make it too long or use punctuation.)

If you are going to use static configuration you have a little more work. Here are the lines you need to add and fill in correctly:

PACKETINT 0x60
IPADDR 192.168.2.6
NETMASK 255.255.255.0
GATEWAY 192.168.2.1
NAMESERVER 68.115.71.53
MTU 1500
HOSTNAME PCjr

And of course, fill in the correct values for your network.

All of the mTCP programs read the configuration file each time they start. Besides holding network parameters the configuration file can hold configuration settings for the applications. Those additional settings are documented by each application.

Setting the MTCPCFG environment variable

Next you need to set an environment variable to point to the configuration file. All of the mTCP code looks for the environment variable first - if it does not find it, it doesn't run. If the environment variable is set correctly then the mTCP code will be able to find the configuration file.

set MTCPCFG=c:\packet\tcp.cfg

That is it! You can put this in AUTOEXEC.BAT or another batch file that you run before you start using mTCP. Be sure to put the location of your file in place of "c:\packet\tcp.cfg". I suggest using a full path name starting with a drive letter (as shown above) so that mTCP can always find the file. Another good idea is to place the mTCP programs on your PATH so that you can find the mTCP programs no matter what subdirectory or drive you are in.

Running the DHCP Client

If you have the packet driver loaded and the MTCPCFG environment variable pointing at a good configuration file you are ready to run DHCP. DHCP is really simple to run - just type dhcp and go! If your setup is correct and it makes contact with a DHCP server on the network it will get an IP address and other settings and write them to the configuration file for you.

Here is a screen shot of a DHCP run from one of my systems:

mTCP DHCP screenshot

Now you can run one of the mTCP applications, like Telnet, FTP or IRCjr.

Note that you only have to run DHCP.EXE once in a while. The exact timing depends on your DHCP server, but a good rule of thumb is once a day before you start using mTCP applications. If your machine is acting strange and can not connect to other machines it will not hurt you to run DHCP.EXE again - the DHCP server might have dropped your machine due to a reset or a short lease time. (In the example above my DHCP server handed out an address that was good for 86,400 seconds, which works out to 24 hours.) The latest version of the mTCP programs will check and warn you if the DHCP lease has expired when they first start.

Or, Static Configuration

If you choose to do the configuration by hand you will still need to set the MTCPCFG environment variable and create a configuration file.

Here is the list of network related variables that you should have set:

Parameter Name    Purpose    Required or Optional
PACKETINT   This is the software interrupt number that the packet driver is listening on. This should match the software interrupt number that you told the packet driver to use.   Required
IPADDR   IP address of this machine (eg: 192.168.2.3)   Required
NETMASK   Network mask setting for your local area network (eg: 255.255.255.0)   Required
GATEWAY   The IP address of your router (eg: 192.168.2.1) If you don't provide this or if you set it wrong you will not be able to communicate with machines that are not directly connected to your LAN.   Optional
NAMESERVER   If you don't provide this or if you set it wrong you will not be able to convert machine names to IP addresses.   Optional
MTU   The MTU size for your Ethernet. The default is 576 bytes. Ethernet can use 1500 bytes.   Optional
HOSTNAME   A fun name for your machine. Don't make it too long or use punctuation.   Optional

It is recommended that the values marked 'optional' are provided. Otherwise, you will lose functions like routing to other networks, DNS lookups, etc.

Note: The mTCP applications do not care if you use DHCP or static configuration. They all read the configuration file the same way and they don't know or care how the configuration file was generated. So you can safely use DHCP once and then edit the values by hand if you decide to use static configuration instead.

For more setup and configuration information ...

Please see DHCP.TXT for details on the DHCP client and SETUP.TXT for a comprehensive guide to setting up mTCP. For most people the information on this page is far more than you need to get going, but if you want all of the details and some tips SETUP.TXT is the place to go. (SETUP.TXT gets updated for each release of mTCP.)

mTCP DHCP and WATTCP

Although the mTCP DHCP client is designed for use with mTCP applications, there is no reason why it can not be used as a general DHCP client for DOS. All that is needed is a little program or script that can convert the output of the DHCP client to something that WATTCP can understand.

Support

Nothing is perfect but we can try ...

The DHCP client is part of the mTCP project which features a TCP/IP library for DOS and several TCP/IP applications that use the library. The applications include a Telnet client, an FTP client, an IRC client, an FTP server, Ping, Netcat, an SNTP client, and an HTTP file fetcher. All of the software is open source and is licensed under the GPL, version 3. More information about mTCP can be found at the mTCP project page.

Have a comment or need help? Please email me at mbbrutman at gmail.com.


Link: mTCP main project page

Created July 31st, 2008, Last updated December 23rd, 2013
C)opyright Michael B. Brutman, mbbrutman at gmail.com