<html>
<a name=TOP></a>
<title> Salsa - Networking </title>
<!--#include file="salsainclude.html" -->

<img src="../images/back.gif" align=center><a href="../topics.html"><b>Topics</b></a> 
<img src="../images/back.gif" align=center><A href="nachos_overview.html"><b>Nachos</b></a>
<img src="../images/forward.gif" align = center><a href="vm.html"><b>Virtual
Memory in Nachos</b></a>

<p>
<center><img src="../images/titles/net24.gif"> <br>
[
<a href="networkdisplay.html">Source code in <em> code/network
</em></a>|
<a href="../Quizzes/quiz9.html">Quiz</a>
]
</center>

<p>
Distribution of computation between several physical processors has become
common in computer systems.  This document discusses the networking component
of operating systems.  We first discuss networking in general terms and then
explain the network implementation in Nachos.

<h3><img src="../images/square_red.gif" height=20 width=23> Networking</h3>
Two schemes are in vogue for distributed computation.  In a
<em>multiprocessor</em> system, the processors share memory and a clock, and
communication usually takes place through shared memory.  In a
<em>distributed</em> system, the processors do not share memory or a clock and
communicate with one another through various communication networks, such as
high-speed buses or telephone lines.  From the point of view of a specific
processor in a distributed system, the rest of the processors are
<em>remote</em>, whereas its own resources are <em>local</em>.  The processors
in a distributed system may be called a <em>host, site,</em> or a
<em>node</em>.  When a process at site <em>A</em> wants to communicate with a
process at site <em>B</em>, the message needs to routed properly to that site.
This is the responsibility of a <em>router</em>.  It can either be a host
computer with routing software or a special-purpose device.  Various
<em>routing protocols</em> exist for determining the actual route on which a
message will be sent.

<p>
The sites in a distributed network can be connected physically in a number of
ways.  We list the most common ones below:

<ul>
<li><b><em>Fully Connected Networks</b></em>  Each site is directly linked
with all other sites in the system.  The cost of this configuration is high
since a direct communication line must be present between all the sites.
Messages however, can be sent fast; only one link needs to be used.
Reliability of such systems is also high since many links must fail for the
system to become partitioned.

<li><b><em>Partially Connected Networks</b></em>  Direct links exist between
some, but not all pairs of sites.  The cost of configuration is lower than
that of the above scheme.  However, a message from one site to another may
have to be sent through several intermediate sites, resulting in slower
communication.

<li><b><em>Hierarchical Networks</b></em> The sites are organized as a tree.
Each site has a unique parent and possibly some children.  The parent and the
child communicate directly and the children communicate through the parent
site.  In general, the failure of any node (except a leaf) in this
configuration  partitions the network into several disjoint subtrees.
This configuration is commonly used for corporate networks.

<li><b><em>Star Networks</b></em> One of the sites in the system is
connected to <em>all</em> other sites.  None of the other sites are connected
to any other.  The cost of this system is linear in the number of sites.  The
communication cost is also low, because a message requires at most two
transfers.

<li><b><em>Ring Networks</b></em> Each site is connected to exactly two other
sites.  The ring can either be unidirectional or bidirectional.  In the
former, a site can send a message to only one of its neighbors and all the
sites must send the messages in the same direction.  A single site failure
partitions the network in this case.  In a bidirectional ring, a site can
send a message to both of its neighbors.  However, two links must fail before
the network is partitioned.

<li><b><em>Multiaccess Bus Networks</b></em>  There is a single shared link
(the bus) to which all sites in the network are connected.  The sites may be
organized as a straight line or as a ring and communicate directly with each
other through the shared link.  The failure of one site does not affect
communication along the link.  However, if the link fails, the network is
partitioned completely.  The <em>Ethernet</em> network is based on this model.

<li><b><em>Hybrid Networks</b></em> Different types of networks are connected
together.  That is, each site in the network can have a different
configuration.  Communication between sites is complicated because multiple
protocols must be followed.
</ul>

<p>
The actual design (and implementation) of a network is specified by the
International Standards Organization (ISO).  In the ISO model, the network is
organized as seven layers on each site.  Each layer on a site communicates
with the equivalent layer on the remote site.  These are briefly listed below:

<ul>
<li><b><em>Physical Layer</b></em> Concerned with transmitting raw bits over a
communication channel.

<li><b><em>Data-link Layer</b></em> Responsible for handling the
<em>frames</em>, or fixed-length parts of packets, including any error
detection and recovery that occurred in the physical layer.

<li><b><em>Network Layer</b></em> Responsible for providing connections and
for routing packets in the communication network.  Routers work at this layer.

<li><b><em>Transport Layer</b></em>  Responsible for low-level access to the
network and for transfer of messages between the clients.

<li><b><em>Session Layer</b></em> Responsible for implementing sessions, or
process-to-process communication protocols.

<li><b><em>Presentation Layer</b></em> Responsible for resolving the
differences in formats among the various sites in the network, including
character conversions.

<li><b><em>Application Layer</b></em> Interacts directly with the users of the
network.  Deals with file transfer, remote-login protocols, email etc.
</ul>


<h3><img src="../images/square_red.gif" height=20 width=23> Networking in
Nachos</h3> 
Nachos provides the abstraction of unreliable, ordered, fixed-size
message delivery to <em>mailboxes</em> on other directly connected machines.
Messages can be dropped by the network but are never corrupted.  Any thread
running on Nachos can send a message to a mailbox on a directly connected
machine using the <em>PostOffice</em> object.  The <em>PostOffice</em>
delivers packets to a specific buffer (a <em>MailBox</em>), based on the
mailbox number stored in the packet header.  Mail waits in the mailbox until a
thread asks for it; if the mailbox is empty, threads can wait for mail to
arrive in it.  Thus, the <em>PostOffice</em> de-multiplexes incoming packets,
delivering them to the appropriate thread.  Each message contains a return
address which is the id of the machine that sent the message, and a <em>from
box</em> which is the number of the mailbox on the sending machine to which
the receiving thread can send an acknowledgement.


<h4><img src="../images/square_blue.gif"> The <em>PostOffice</em> class</h4> 
The <em>PostOffice</em> class is defined in the the files <em>post.h</em> and
<em>post.cc</em> in the <a href="networkdisplay.html"><em>network</em></a>
directory.    This class defines a post-office or a collection of mailboxes.
It is a synchronized object that provides two main operations: <em>Send</em> -
send a message to a remote machine, and <em>Receive</em> - wait until a
message is in the mailbox, then remove and return it.  Incoming messages are
put by the PostOffice into the appropriate mailbox, waking up any threads
waiting on Receive.

<p> The file <em>post.h</em> also defines three other classes - <em>Mail</em>,
<em>MailHeader</em> and <em>MailBox</em>.  <em>Mail</em> defines the format of
an incoming/outgoing message.  The constructor function of this class
initializes a single mail message, by concatenating the <em>PacketHeader</em>
(explained below) and the <em>MailHeader</em>.  The <em>MailHeader</em> is
part of the message header.  It is prepended to the message by the PostOffice
before the message is sent to the Network and contains the the destination
mailbox address, the source mailbox address and the number of bytes in the
message data.  Thus, the packet that is delivered to the remote machine
contains the actual message, the <em>MailHeader</em> and the
<em>PacketHeader</em> (the
<em>Mail</em> object).  Finally, the <em>MailBox</em> class defines a single
mailbox for messages.  Incoming messages are put by the PostOffice into the
appropriate mailbox, and these messages can then be retrieved by threads on
that machine.  A mailbox is implemented simply as a list of messages using the
<em>SynchList</em> object (<a
href="threadsdisplay.html"><em>synchlist.h(cc)</em></a>).

<h4><img src="../images/square_blue.gif"> The Network Device</h4> 
The emulation of a physical network connection is implemented in the
files <em>network.h</em> and <em>network.cc</em> in the <em>machine</em>
directory.  The abstraction is one of ordered, unreliable, fixed-size packet
delivery to other machines on the network.  The class <em>PacketHeader</em>
defines a network packet header and contains the network address of the
destination and source machine, and the number of bytes in the message
(excluding the <em>PacketHeader</em> but including the <em>MailHeader</em>).

<p>
The actual network device is defined by the <em>Network</em> class.  This
class simulates a network interface, using UNIX sockets to deliver packets
between multiple invocations of Nachos.  It contains routines to send and
receive a packet from a remote machine.

<p>  The following figure summarizes the above discussion.

<P>
<img src="diagrams/network-type.gif">

<p>
<img src="../images/clr-line2.gif">
<p>
<img src="../images/tomsmall.gif" hspace=5><a
href="http://gaia.cs.umass.edu/cs653"><b>Want to know more about
Networking?</b></a><br>
<img src="../images/tomsmall.gif" hspace=5><a href="networkdisplay.html">
<b>Source code in <em> code/network</em></b></a><br>
<img src="../images/tomsmall.gif" hspace=5><a href="../Quizzes/quiz9.html">
<b>Quiz</b></a>

<p>
<img src="../images/up.gif" align=center><a href="#TOP">Back to Top </a>

<p>
<em>Last modified on <!--#flastmod file="network.html" --></em>

</body></html>


