WHAT THIS WEB SITE COVERS:

This web site covers the network service of Minix, version 2.0.4. Version 2.0.4 was the latest version when the web site was started. Since then, Minix version 3 has been released. However, version 3 is based on version 2 - the study of version 2.0.4 *is* worthwhile.

While this web site covers most of the functionality of the network service, there is significant functionality that it does not cover. The most important omission is TCP (Transmission Control Protocol). We did not cover TCP because we simply did not have the time to adequately document this complex protocol. We also did not document any of the ethernet drivers (tasks) available for Minix. While an ethernet driver is not part of the network service, an ethernet driver and the network service are dependent on each other. Like TCP, we simply did not have the time to document the files that make up an ethernet driver. However, the interactions with the system's ethernet driver that are necessary for the network service to do its job are documented in detail.

Since there are no implementations of ppp (Point to Point Protocol) or slip (Serial Line IP) included in the official Minix 2 distribution, the "psip" (PSeudo IP) files and functions are not covered. The psip functions are simply generic functions that call protocol-specific functions; to have a full understanding of the psip files and functions, the underlying ppp and slip functions would also need to be studied. Hopefully, the Minix 3 distribution will include ppp and slip implementations. (For an excellent source of information on the ppp and slip protocols, visit Claudio Tantignone's site.)

That being said, this web site covers the files within the Minix network service that relate to the ethernet, ip, udp, icmp, and arp protocols.


NETWORK SERVICE FUNDAMENTALS:

Before digging into the code, it is helpful to gain a general understanding of several items.

DIRECTORY STRUCTURE:

It is helpful to understand the directory structure (actually, it's only two directories) that contain the network service files.

The following files are found in the src/inet directory:

buf.c, clock.c, const.h, inet.c, inet.h, inet_config.c, inet_config.h, Makefile, mnx_eth.c, mq.c, mq.h, osdep_eth.h, proto.h, sr.c, stacktrace.c, version.c

These files are specific to Minix. For example, inet.c contains code that involves sending messages to the kernel and the file system and memory manager. If the network service were ported to another operating system (e.g., Linux), these files would need to be modified.

The following files are found in the src/inet/generic directory:

arp.c, arp.h, assert.h, buf.h, clock.h, eth.c, eth.h, eth_int.h, event.c, event.h, icmp.c, icmp.h, icmp_lib.h, io.c, io.h, ip.c, ip.h, ip_eth.c, ip_int.h, ip_ioctl.c, ip_lib.c, ip_ps.c, ip_read.c, ip_write.c, ipr.c, ipr.h, psip.c, psip.h, sr.h, tcp.c, tcp.h, tcp_int.h, tcp_lib.c, tcp_recv.c, tcp_send.c, type.h, udp.c, udp.h

As the name of the directory ("generic") suggests, these files are not specific to Minix and would not need to be modified if the network service were ported to another operating system.

The home page has links to the most important files that are covered by this web site. Anyone interested in learning about the Minix network service should begin by studying inet.c, the file that contains main() and the main loop (see below).


MESSAGE PASSING:

Due to the microkernel design of Minix, user processes request operations from the network service through messages. However, user processes never send messages directly to the network service. Instead, user processes send messages to the file system, which then relays the messages to the network service. In the same manner, the network service never sends messages directly to the user processes. The network service sends messages to the file system, which then relays the messages to the user processes.

In addition to sending/receiving messages to/from the file system, the network service sends/receives messages to/from the ethernet task (driver). For example, if a user process sends a message to the network service (via the file system) requesting a write operation, the network service eventually sends a message to the ethernet task requesting a write operation.

Messages are also sent to/received from the Synchronous Alarm task.


THE MAIN LOOP:

After the initialization phase of the network service, the network service enters an endless loop. In this loop, the network service processes any waiting events and then waits for messages from three possible sources (the file system, the ethernet task, or the synchronous alarm task) and, after receiving a message, processes the message accordingly.

Understanding the main loop is crucial to understanding the network service. Therefore, a study of the network service should begin with inet.c, the file that contains the main loop.


FILE DESCRIPTORS:

One of the most important concepts to understand is the concept of file descriptors within the network service. In Minix (and unix as well), the different layers within the OSI model are represented by files. For example, if there are two data-link layer devices (e.g., two ethernet cards), the "/dev/udp0" and "/dev/udp1" files represent the udp layers for the first and second ethernet cards, respectively. In order for a user process to send a udp packet, the process must first open up one of these device files (by sending a message to the file system that, in turn, sends a message to the network service) and thereby acquiring a file descriptor to the file and then write to this file descriptor in much the same way that the process would write to a normal file (with the notable difference that the user process must first configure the associated file descriptor).