| Home | | Developer Releases | | Stable Releases | | Documentation |

README  - 0.98
Technical README
Next Previous Contents

16. Networking using DOSEmu

A mini-HOWTO from Bart Hartgers <barth@stack.nl> ( for the detailed original description see below )

16.1 The DOSNET virtual device.

Dosnet.o is a kernel module that implements a special virtual network device. In combination with pktdrv.c and libpacket.c, this will enable multiple dosemu sessions and the linux kernel to be on a virtual network. Each has it's own network device and ethernet address.

This means that you can telnet or ftp from the dos-session to your telnetd/ftpd running in linux and, with IP forwarding enabled in the kernel, connect to any host on your network.

16.2 Setup for virtual TCP/IP

Go to ./src/dosext/net/v-net and make dosnet.o. As root, insmod dosnet.o. Now as root, configure the dsn0 interface (for example: ifconfig dsn0 netmask, and add a route for it (for example: route add -net netmask dsn0).

Finally, start dosemu, and give your TCP/IP client and ip-address in the subnet you just configured. This address should be unique, i.e. no other dosemu, or the kernel, should have this address. For the example addresses given above, would be good. Now you can use a dos telnet client to telnet to your own machine!

16.3 Full Details

Modified description of Vinod G Kulkarni <vinod@cse.iitb.ernet.in>

Allowing a program to have its own network protocol stacks.

Resulting in multiple dosemu's to use netware, ncsa telnet etc.


Allowing network access from dosemu is an important functionality. For pc based network product developers, it will offer an easy development environment will full control over all the traffic without having to run around and use several machines. It will allow already available client-server based "front-ends" to run on dosemulator. (Assuming that they are all packet driver based -- as of now ;-) )

To accomplish that, we require independent protocol stacks to coexist along with linux' IP stack. One way is to add independent network card. However, it is cumbersome and allows at most only 2-3 stacks. Other option is to use the a virtual network device that will route the packets to the actual stacks which run as user programs.


Have a virtual device which provides routing interface at one end (so it is a network device from linux side) and at other end, it sends/receives packets from/to user stacks.

All the user stacks AND virtual device are virtually connected by a network (equavalent to a physical cable). Any broadcast packet (sent by either user stack or router interface of the virtual device) should be sent to all the user stacks and router. All non-broadcast packets can be sent by communicating with each other.

Each user stack (here dosemu process) will have an base interface which allows sending and receiving of packets. On the top of this, a proper interface (such as packet driver interface) can be built. In dosemu, a packet driver interface is emulated.

Every user stack will have a unique virtual ethernet address.


This package includes:

  1. dosnet module. Acts as virtual network device introducing 'dsn0' interface. It provides usual network interface AND also facility to communicate with dosemu's.
  2. Modified packet driver code (pktnew.c and libdosemu.c) to enable the above. Modifications include these:
    1. Generate an unique ethernet address for each dosemu . I have used minor no. of the tty in use as part of ethernet address. This works unless you start two dosemu's in same tty.
    2. Communication with dosnet device is done by opening a SOCK_PACKET socket of special type.
  3. IPX bridge code. Between eth0 and dsn0 so that multiple lan accesses can be made. 0.1 is non-intelligent. (both versions are alpha codes.) Actually IPX routing code is there in kernel. Has anyone been successful in using this? Yet another alternative is to use IPTunnelling of IPX packets (rfc 1234). Novell has NLMs for this on the netware side. On linux, we should run a daemon implementing this rfc.

Virtual device 'dsn0'

Compile the module dosnet and insmod it, and give it an IP address, with a new IP network number. And You have to set up proper routing tables on all machines you want to connect to. So linux side interface is easy to set up.

This device is assigned a virtual ethernet address, defined in dosnet.h.

This device is usual loadable module. (Someone please check if it can be made more efficient.) However, what is interesting is the way it allows access to user stacks (i.e. dosemu's.) i.e. its media interface.

A packet arrives to dosnet from linux for our virtual internal network (after routing process). If it is broadcast packet, dosnet should send it to all dosemu's/user stacks. If it is normal packet, it should send it only particular user stack which has same destination ethernet address .

It performs this process by the following method, using SOCK_PACKET interface , (and not introducing new devices).:

The dosemu opens a SOCK_PACKET interface for type 'x' with the dosnet device. The result of this will be an addition of entry into type handler table for type 'x'. This table stores the type and corresponding handler function (called when a packet of this type arrives.)

Each dosemu will open the interface with unique 'x' .

sending packets from dosemu to dosnet

SOCK_PACKET allows you to send the packet "as is". So not a problem at all.

dosnet -> dosemu

this is tricky. The packet is simply given by dosnet device to upper layers. However, the upper layer calls function to find out the type of the packet which is device specific (default is eth_type_trans().). This routine, which returns type of given packet, is to be implemented in each device. So in dosnet, this plays a special role. If the packet is identified as type 'x', the upper layers (net/inet/dev.c) call the type handler for 'x'.

Looking at destination ethernet address of a packet, we can say deduct that it is packet for dosemu, and its type is 'x' (i.e. 'x' is "inserted" in dosemu's virtual ethernet address.) Type handler function for 'x' is essentially SOCK_PACKET receiver function which sends packet back to dosemu.

NOTE: the "type" field is in destination ethernet address and not its usual place (which depends on frame type.) So the packet is left intact -- there is no wrapper function etc. We should use type "x" which is unused by others; so the packet can carry _ANY_ protocol since the data field is left untouched.

Broadcast packets

We use a common type "y" for dosnet broadcasts. Each dosemu "registers" for "y" along with usual "x" type packet using SOCK_PACKET. This "y" is same for all dosemu's. (The packet is duplicated if more than one SOCK_PACKET asks for same type. )

Packet driver code

I have add the code for handling multiple protocols.

When a packet arrives, it arrives on one of the two SOCK_PACKET handle we need to find out which of the registered protocols should be handled this code. (Earlier code opened multiple sockets, one for each IPX type. However it is not useful now because we use *any* type.) When a new type is registered, it is added to a Type list. When a new packet arrives, first we find out the frame type(and hence the position of type field in the packet, and then try matching it with registered types. [ ---- I missed comparing class; I will add it later.] Then call the helper corresponding to the handle of that type.

Rob, you should help in the following:

  1. Packet driver code ...

    We should now open only two sockets: one specific to dosemu and other broadcast. So we have to add code to demultiplex into packet types... I couldn't succeed. Even broadcast packets are not getting to dosemu.

  2. Which virtual ethernet addresses to use (officially)?
  3. Which special packet type can be used?
  4. Kernel overhead .. lots of packet types getting introduced in type handler table... how to reduce?


So at last one can open multiple DOSEMU's and access network from each of them ... However, you HAVE TO set up ROUTING TABLES etc.

Vinod G Kulkarni <vinod@cse.iitb.ernet.in>

Telnetting to other Systems

Other systems need to have route to this "new" network. The easiest way to do this is to have static route for dosnet IP network included in remote machine you want to connect to. After all tests are carried out, one could include them permanently (i.e. in gated configurations etc.). However, the "new" IP address should only be internal to your organisation, and not allowed to route outside. There is some rfc in this regard, I will let you know later. For e.g., I am working on Internal network I created was (See the above route command.) To connect to another linux system from dosemu, I include static route by running 'route add -net gw' on that system. It becomes more complex if you need to connect to outside of

Accessing Novell netware

Since dosemu is now on "different device", IPX needs to be either bridged or routed. If it is bridged, then there is no requirement for any extra administration ; simply run 'ipxbridge' program supplied with the dosnet sources. (There are two versions of it; 0.1 copies all packets to from/to both interface. 0.2 is "intelligent bridge", it copies packet to other interface only if the destination lies on other interface. )

If you instead want to use "routing" for IPX, then you need to enable IPX config option in the kernel. Next, you should select a network number that won't clash with others. Set up static direct ipx routes in linux, and then in one Novell netware server which is directly connected (i.e. without any router inbetween.). (That is where you should contact Novell sysadm's ;-) The idea is, the server acts as route broadcaster. (I haven't actually tested this; and we are working on getting proper daemons etc. which will make linux act as IPX router proper.)

(You could include this info along with other documentation...)

Hope this helps,


I just realised one more thing: The ipxbridge-0.2 code assumes that you have 'eth0' and 'eth1' as the two interfaces. And it uses this fact while choosing the interface to put the packet. So it won't recognise when 'dsn0' is used.

ipxbridge-0.1 will work though.

Also, note that both these programs put the card in promiscuous mode.

So my suggestion is to "somehow" get IPX routing done by linux!


Next Previous Contents
The DOSEMU team