The services layer

See more about:

Where are we?

We talked about the bucket o’ numbers layer. Now let’s move on the services layer.

This lesson's topic

Figure 1. This lesson’s topic

This lesson’s goals

By the end of this lesson, you should:

  • Know that a service is something one computer does for another.
  • Know how the email protocol SMTP works.
  • Know how the Web protocol HTTP works.

A “service” is something that one computer does for another. Like sending email, fetching Web pages, saving data to a database, whatever. Email is one of the easiest services to understand, so let’s start with that.

Sending email

Jake wants to send an email to Jules. Jake’s email address is jake@evildoom.com. Jules’ is jules@dogbowl.com.

Jake starts up his email client. Jake uses Windows Mail. Windows Mail runs on his own PC in his kennel. Jake types in a message. When he’s ready, he clicks the Send button.

Email client

Figure 2. An email client

The term “client” has more than one meaning. Sometimes, “client” means the physical computer Jake is using. Sometimes, “client” means the email software running on the computer (Windows Mail). You have to figure out from the context what is meant.

Jake’s PC can’t send email by itself. It doesn’t have a domain name (the “evildoom.com” part of “jake@evildoom.com”). Instead, Jake’s email client asks another computer to send the email. This computer is the email server for evildoom.com. It offers email service to everyone with an EvilDoom account.

Client and server

Figure 3. Client and server

Just like the word “client,” the word “server” has more than one meaning. Sometimes, it means a physical computer. Sometimes, it means some software running on that computer, that offers services.

There’s lots of different email server software. qmail, Microsoft Exchange, and others.

When Jake sets up Windows Mail (his email client software), he has to tell it which server to talk to:

Identifying a server

Figure 4. Identifying a server

Now the client will know where to send messages.

OK, so Jake has finished typing his message, and clicks the Send button. Windows Mail on Jake’s PC starts a conversation with the email server. It’s like a conversation between dogs. One computer says something, the other replies, the other replies to that, and so on.

The conversation between email client and server goes something like this:

Client: HELO mail.evildoom.com
Server: 250 Hello evildoom.com
Client: rcpt to: jules (at) dogbowl.com
Server: 250 Ok
Client: DATA
Server: 354 End data with .
Client: Subject: Study group meeting
Client: D00d,
Client:
Client: I'm buying the coffee tonight.
Client:
Client: Jake
Client: .
Server: 250 Ok Mail queued for delivery
Client: QUIT
Server: 221 Bye

The conversation follows some rules, such as using HELO to start, and ending the message with a period (.) on a line by itself. The set of rules are called the simple mail transfer protocol (SMTP).

Jonathan Postel created the SMTP protocol. He wrote down the rules in a document called RFC 821. It’s great reading if you have trouble sleeping. You can see it at http://www.freesoft.org/CIE/RFC/821/index.htm.

When Microsoft’s programmers created Microsoft Mail (the client program Jake is using), they read RFC 821, so they’d know how their program should talk to servers. They put in an instruction something like this:

print "HELO " & computer_name;

Now suppose that EvilDoom is running the qmail server. The dude who wrote qmail, Dan Bernstein, read RFC 821. So he knew what clients would send to his server software, and what responses they would expect. He wrote code something like this:

get Command;
if ( Command == 'HELO' ) call StartMessage;

The two functions of a client

You can see that the client software has two main functions.

Client functions

Figure 5. Client functions

First, it has to support the user’s tasks. For email, that means (1) letting the user type in messages to send, and (2) showing messages from other people.

Second, the client has to be able to talk to a server. They have to share the same protocol (set of communication rules), otherwise they won’t be able to interact.

Standards rock!

The only reason that the Microsoft Mail client can talk to the qmail server is that they both use SMTP. That is, they both follow the rules in RFC 821 that Jonathan Postel wrote.

RFC 821 is a public document. Anyone can see it. Some software companies use private protocols. They won’t tell anyone how they work.

Who creates standards? All sorts of people, but some groups are more important than others. SMTP is supported by the Internet Engineering Task Force, an open community that reviews and adopts standards.

That’s enough email for now. Let’s move on to the Web.

HTTP

HTTP stands for the hypertext transfer protocol. It’s a standard, just like SMTP. However, it’s designed to support sending data on the Web, not sending email.

Service-layer protocols are like that. They support specific types of communication. There are hundreds of protocols, for instant messaging, mapping, gaming, and lots of other things. But to a Weber, only a few are important.

HTTP is maintained by the World Wide Web Consortium, another nonprofit standards group. The W3C is the most important standards group for the Web.

The setup is the same as before, with a client and a server. But this time, the client is a Web browser, and the server is a Web server.

Web client and server

Figure 6. Web client and server

There are many Web browsers, including Firefox, Google Chrome, Safari, Opera, and Internet Explorer. We’ll use Firefox in our lessons, because it has nice features for Webers.

There are many Web servers as well. The most widely used is the Apache Web server. It runs on just about every computer there is.

HTTP is the set of rules that browsers and servers use to communicate. Browsers follow the rules when they talk to Web servers. Web servers follow the rules when they respond to Web clients.

Suppose Jake clicks on this link on a page:

Superdogs

Figure 7. Superdogs

Here’s the conversation between the browser and the server.

Client:
GET superdogs.html HTTP/1.1
Host: www.evildoom.com

Server:
HTTP/1.1 200 OK
Last-Modified: Mon, 25 Dec 2006 22:22:22 GMT
Content-Type: text/html
(Web page content)

The HTTP standard document says that clients should use GET to fetch content. Servers should use the code 200 to say that everything is OK. There’s lots more to HTTP, but you get the idea. HTTP is a set of rules that browsers and servers use to talk to each other.

Going deeper

  • HTTP headers. A short CoreDogs article on HTTP response headers.

Summary

In this lesson, you learned:

  • That a service is something one computer does for another.
  • How the email protocol SMTP works.
  • How the Web protocol HTTP works.

What now?

A Web browser gets data from a Web server, and sends it to the display layers. That’s coming up next.


How to...

Lessons

User login

Log in problems? Try here


Dogs