Session 26: Networking

Textbook: None related

  physical layer
Internetwork layer
  gateway routing
  IP header
Transport layer
  clients and servers
  reliable delivery
  TCP header
Application layer

Modern operating systems must include some support of networking. In fact, they basically have to support TCP/IP, the de facto world networking standard. (It hasn't always been that way, but with the explosion of the Internet it has.)


On one level... The Internet is a network of wires connected with computers. On another... The Internet gives programs the capability to communicate between computers. TCP bridges this gap by decomposing it into a set of four layers:


Each layer adds a header explaining how to handle the message.

| physical | internetwork | transport |         application          |
|  header  |    header    |  header   |           message            |
<--- front

Of the physical layer we will say little: It magically sends a message across a single network.

The physical layer

The Internet is a network of networks.

/--------\      /------------\
| CMU CS | ---- | CMU Andrew |
\--------/      \------------/
      \           /
       \ /-----\ /
         | PSC |
         /-----\      /----\
         | MCI | ---- | OU |
         \-----/      \----/
Each network can deliver messages within itself directly. Messages between networks must find their way - without a map!

Networks have gateways, computers that route messages between networks.

/---------\               /------------\
| CMU CS  |               | CMU Andrew |
|         | --- gw.cs --- |
| gs88.sp |               | |
\---------/               \------------/
/------\                    /-------\
|      |                    |  PSC  |
| Pitt | -- pitt-ip-fddi -- |       |
|      |                    | mario |
\------/                    \-------/
                            |  MCI  |
Packets travel gateway to gateway until reaching destination network.

Internetwork layer

Now we look at the internetwork layer, implemented using IP (Internet Protocol).

IP provides best-effort delivery: It makes a good try to get packet to destination computer but may lose (drop) it.

Reasons for dropping a packet include

Working around packet drops is left the transport layer to handle

Packet drops are frequent (50% not uncommon). The endpoints negotiate and resend until all packets make it.


Machines have two names: a mnemonic English name
and a 4-byte IP address
The IP address is used to describe the destination of a message.


Before a message is sent, it is divided into packets.

           original message
     |            |             |           |
     v            v             v           v
...|1011011  ...|0111000   ...|1001000   ...|...  packets
Each packet has about 1,000 bytes.

Gateway routing

Each gateway has a routing table telling where to send packets.

| 10.*.*.* |                                        rest of
\----------/                                        Internet
     |                                                 |
     |                                  /----------\
     o                                           | 40.*.*.* |
     |                                  \----------/
     |                                                 |
/----------\ /----------\ |
| 20.*.*.* | -------- o -------- | 30.*.*.* | -------- o
\----------/                     \----------/
The routing table for in this network would be
if destination     then route
network is...        to...
20.*.*.*           destination directly
30.*.*.*           destination directly

Periodically gateways tell their neighbors about the best routes they know to destination networks. When a gateway receives this information, it updates its routing table and forwards information about any changes to its neighbors.

The IP header

The following is a version 6 header.

byte  0  IP version number (in this case, 6)
byte  1

byte  4  length of packet
byte  6  transport protocol
byte  7  hop limit (subtract 1 each gateway, drop if 0, to avoid immortal packets)
byte  8
         source computer IP address

byte 24
         destination computer IP address

byte 40
   :     transport layer message

Transport layer

IP gives us

But our programs want This is a job for TCP (Transport Control Protocol).


Each program reserves a port of communication so that other prograsm can specify which program should receive its messages.


Clients and Servers

The server is a program waiting on a computer with a port reserved. A client reserves a port on its own computer and sends messages to the server by sending messages to the server's port-computer combination. Then the server can respond by sending messages to the client's port-computer combination. And they talk.

(Notice there's nothing wrong with a server or client talking to multiple programs using the same port.)

Reliable delivery

One challenging problem is deciding how long to wait before giving up on acknowledgements. The sender adapts based on what it has recently seen. Doing this well turns out to be quite complicated. We'll skip the details on this adaptation process - it's complicated.

But this simple acknowledge technique has a major problem that we will address: It's very slow.

Better to have many buckets.
This is done with a sliding window.
|  1 |  2 |  3 |  4 |  5 |  6 |  7 |  8 |  9 | 10 | 11 |
	  A sliding window of size 4
The window size corresponds to the number of buckets.

The TCP header

byte  0   source port
byte  2   destination port
byte  4   sequence number
          (tells which segment is sent)
byte  8   acknowledgement number
          (tells which segment has been received)
byte 12   header length
byte 12.5 ignore
byte 14   desired window size
byte 16   ignore

byte 20
   :      options
byte ??
   :      application message

Application layer


Now we move onto the application layer. We'll look at two application layer protocols: HTTP and SMTP. HTTP is the protocol used for the World-Wide Web.

We're going to look at HTTP/0.9, the original HTTP definition. This particular protocol is a minimalistic protocol that all Web servers and browsers implement.

Say I'm running a Web server on the computer on port 8000. From the browser, the user can type the URL The browser will interpret this and send the following message to the server. (The following is what Netscape would send.)

GET /test.html HTTP/1.0
Connection: Keep-Alive
User-Agent: Mozilla/4.72 [en] (X11; U; Linux 2.2.14-5.0 i686)
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
Accept-Encoding: gzip
Accept-Language: en
Accept-Charset: iso-8859-1,*,utf-8

This message says that the browser wants the file ``/test.html'' from the server. In HTTP/0.9, everything after these first two words is ignored. (You can see that Netscape is using HTTP/1.0, and after the message it also tells the server quite a few other things. For example, the Accept: line tells the server that it prefers GIF images.

An HTTP/0.9 server will simply reply with the requested file.

<h1>This is test.html</h1>
<h2>Not too impressive, is it?</h2>
The browser receives this and displays it to the screen.

The application layer: SMTP

SMTP is another application-layer protocol, used for sending mail. It typically runs at port 25 and is quite a bit more complicated than HTTP because it involves a give-and-take sequence of commands. Here's a session where I send a message to myself. The boldface indicates messages that the client sends.

220 ESMTP Server (Microsoft Exchange
Internet Mail Service 5.5.2650.21) ready
250 OK
mail from:
250 OK - mail from 
rcpt to:
250 OK - Recipient 
354 Send data.  End with CRLF.CRLF
Subject: Test message

This is a test message. ---Carl Burch
250 OK
221 closing connection