Networking Implementation

Networking Implementation
SchemeStation documentation

1 Introduction

SCHEMESTATION is a network oriented operating system. This implies that the system has to provide the user processes (agents) communication facilities. As the current aim of the current project is to simulate the actual hardware on the top of a UNIX system, a natural choice is to simulate the network traffic on the top of the TCP/IP protocol stack. Network simulation could be done on the top of bare IP or even on the top of plain hardware (eg. Ethernet). We, however, see no point in doing this as the aim of this project is not to rewrite network software.

Thus, communication is simulated on the top of the TCP/IP stack, which provides the necessary reliability. (In a realistic system another, perhaps SCHEMESTATION-specific, protocol could be used.)

TCP provides a reliable stream-like connection; SCHEMESTATION uses transfer data in packets. This packet traffic is implemented on the top of TCP, so the simulation itself does not need to take care of acknowledging packets or similar stuff.

2 Addressing

Since every packet is sent, in principle, to an agent (not to a domain for example), addressing scheme needs to uniquely address agents. The networking system is however responsible for addressing only domains. The network system passes received packets to the messaging system [Messaging System Specification] that along with the addressing system [Addressing module specification] does then finer-grain addressing based on agent addresses.

Every packet contains a destination address. The address is a 128-bit domain address; the agent specifier is part of the payload of the packet, and the networking system does not need to be aware of it.

3 Communication between domains

Every SCHEMESTATION simulator may listen to its own TCP/IP port. The convention is however, that in a simulated multi-domain SCHEMESTATION environment there is one router that listens to a port (by default, 7000). Other domains connect to it and send all packets through this connection. For generality, however, every domain maintains a list of open connections, and search through it too see whether they are directly connected to the domain they need to send the packet to. If no such direct connection is found, the packet is sent to the router.

When the router is started, the listened port is bound and begun to listen with net_becomrouter() before calling the net_initialize() function. (The port number is passed as a command line argument to the network simulator.) If listening the port fails the function returns error.

Client domains call net_userouter() instead. The router to connect to is given as an argument.

When a domain wishes to send a packet to another domain, it first checks whether it should use a router. If no router is in the connections list, it searches for a direct connection (with net_findconnection) through the list of readily established connection if one is made to the desired destination. If one is found, the client puts the packet on the connection's list of packets to be send with net_deliverpacket. If no connection exists it establishes first a new connection to the destination with net_openconnection.

The event loop notifies the network module every time it is possible to send data over a connection by calling net_eloop_callback. The networking module then sends as many packets as possible with net_sendpacket and gives the control back to the caller.

The event loop also notifies the network module of arrived packets by calling net_eloop_callback. The network reads all available packets from the socket with net_recvpacket and for every completely received packet it calls the addressing system callback registered with net_registerpacketcallback. Packets can be partially received or sent, in which case processing them is completed when the event loop gives control back next time, or even later.

Opening a connection consists of calling net_openconnection that allocates the connection struct, adds it to the global connection list, opens the socket the the destination, and does handshake with net_doclienthandshake.

The server side (router) gets notification of opened connection from the event loop ( net_acceptcallback) and calls net_acceptconnection that allocates the connection struct, adds it to the global connection list, and does handshake with net_serverhandshake.

The handshake is done as follows: a client sends first a magic number, then protocol version number, and then its SSPP DomainAddress. The server replies with another magic number, protocol version number and its address. The client then sends an open connection control command, and at this point both ends agree on having a valid connection.

The parties can use control commands to, for example, close connections. If the data length is set zero, the packet includes a (network byte order) 2-octet control command a argument. These include opening a connection (0) and closing a connection (1). These command are handled by net_handlecontrol

4.4.8 The functions of module networking


File network-internal.h

C-functions:


File network-packet.h

C-functions:


File network.h

C-functions:


File network-packet.h

C-functions: