The services layer
Where are we?
We talked about the bucket o’ numbers layer. Now let’s move on the services layer.
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.
Jake wants to send an email to Jules. Jake’s email address is email@example.com. Jules’ is firstname.lastname@example.org.
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.
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 “email@example.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.
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.
When Jake sets up Windows Mail (his email client software), he has to tell it which server to talk to:
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:
250 Hello evildoom.com
rcpt to: jules (at) dogbowl.com
354 End data with .
Subject: Study group meeting
I'm buying the coffee tonight.
250 Ok Mail queued for delivery
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:
if ( Command == 'HELO' ) call StartMessage;
The two functions of a client
You can see that the client software has two main 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.
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 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.
Figure 6. Web client and server
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:
Figure 7. Superdogs
Here’s the conversation between the browser and the server.
GET superdogs.html HTTP/1.1
HTTP/1.1 200 OK
Last-Modified: Mon, 25 Dec 2006 22:22:22 GMT
(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.
- HTTP headers. A short CoreDogs article on HTTP response headers.
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.
A Web browser gets data from a Web server, and sends it to the display layers. That’s coming up next.