You are on page 1of 23

Chapter 2 Application Layer

Computer Networking: A Top Down Approach,

4th edition. Jim Kurose, Keith Ross Addison-Wesley, July 2007.

Last Lecture

HTTP Request and Response

Messages HTTP state aware mechanism

Todays Lecture
Electronic mail (Email)
SMTP Domain Name System (DNS)

HTTP Request Message


Two types of HTTP messages: Request, Response HTTP request message: Human-readable format A typical HTTP request message GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu User-agent: Mozilla/4.0 Connection: close Accept-language:fr (Blank Line) Body

HTTP Request Message


Request Line

First Line of HTTP request message The request line has three fields Method field can take on several values GET,POST, PUT, DELETE etc Majority of HTTP request messages use GET URL field HTTP version field Header Lines Host: Host on which the object resides User-agent: Identifies the client program e.g. Mozilla/4.0 Connection: Shows whether the connection should be closed or not Accept-language: Shows the language the client prefers

HTTP Request Message


Body is empty with

GET method Used with the POST method Web page often includes form input Input is sent to server in body

PUT method: To upload objects to web server DELETE method Allows a user or an application to delete an object on web server

Find out about OPTIONS, TRACE, HEAD?

HTTP Response Message


HTTP/1.1 200 OK Connection: close Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 Content-Length: 6821 Content-Type: text/html
Body contains Requested Object

HTTP Response Message


Status Line Protocol Version Status Code and Status Message
The status code and associated phrase indicate the result of the request

Header Line Connection: Shows whether the connection should be closed or not Date and time: When the HTTP response was created Server: Analogous to user-agent in request message Last-modified: When the Object was last created or modified Content-length: Number of bytes in object being sent Content-Type: Indicates the object type (HTML text etc.)

HTTP Response Status Codes


The status code and associated phrase indicate the result of the request

200 OK

Request succeeded and information is returned in response Requested object moved, new location specified later in this message (Location:) Request message not understood by server Requested document not found on this server

301 Moved Permanently

400 Bad Request

404 Not Found

505 Version not supported

HTTP version is not supported by the server

Electronic Mail
Asynchronous Communication Medium Three major components:
User Agents Mail Servers Simple Mail Transfer Protocol: SMTP
user agent mail server

outgoing message queue user mailbox

user agent

SMTP SMTP SMTP


mail server user agent user agent

mail server

user agent

User Agent a.k.a. mail reader composing, editing, reading mail messages e.g., Eudora, Outlook, Mozilla Thunderbird Sends message to the mail server

user agent

Electronic Mail
Mail Servers Each recipient has a mailbox located in one of the mail servers Mailbox manages and maintains the mail messages that have been sent to server him. Message queue of outgoing (to be sent) mail messages SMTP Simple Mail Transfer Protocol (SMTP) between mail servers to send email messages mail Client and Server server Both client and sever sides of SMTP run on every mail server. Runs on TCP at port 25. user agent RFC 5321
user agent user agent mail server user agent

SMTP

SMTP

user agent

user agent

Scenario: Alice sends message to Bob


1) Alice uses UA to compose message to bob@someschool.edu 2) Alices UA sends message to her mail server; message placed in message queue 3) Client side of SMTP opens TCP connection with Bobs mail server 4) SMTP client sends Alices message over the TCP connection 5) Bobs mail server places the message in Bobs mailbox 6) Bob invokes his user agent to read message

1 user agent 2

mail server 3

mail server 4 5 6

user agent

Sample SMTP Interaction


Client SMTP establishes a TCP connection with Server SMTP Application Layer handshaking to introduce themselves Sample SMTP Interaction
S: 220 hamburger.edu (Service Ready) C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: <alice@crepes.fr> S: 250 alice@crepes.fr... Sender ok C: RCPT TO: <bob@hamburger.edu> S: 250 bob@hamburger.edu ... Recipient ok C: DATA (All lines after DATA command are treated as the mail message) S: 354 Enter mail, end with "." on a line by itself C: Do you like ketchup? C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection

SMTP and HTTP


SMTP uses persistent connections

Can send all of the messages over the same TCP connection

Comparison with HTTP:


HTTP transfer files from web server to web client SMTP from one mail server to another Both use Persistent Connections HTTP: pull

Someone loads information on a web server and users use HTTP to pull this info TCP connection is initiated by the machine that wants to receive the file Sending mail sever pushes the file to the receiving mail server TCP connection is initiated by the machine that wants to send the file

SMTP: push

Mail Access Protocols


SMTP
user agent senders mail server receivers mail server

SMTP

access protocol

user agent

SMTP: delivery/storage to receivers server Mail access protocol: retrieval from server

POP: Post Office Protocol [RFC 1939] IMAP: Internet Mail Access Protocol [RFC 1730] HTTP: Gmail, Hotmail, Yahoo! Mail, etc. User agent is ordinary web browser HTTP to send email to web server HTTP to access mail box

DNS: Domain Name System


People: many identifiers:

Domain Name System:

SSN, name, passport # IP address (32 bit) name, e.g., ww.yahoo.com - used by humans

Internet hosts:

Q: map between IP addresses and name ?

implemented in hierarchy of many DNS servers An application-layer protocol that allows hosts to query the distributed database DNS uses UDP over port number 53. RFC 1034 and RFC 1035

Distributed Database

DNS
Simple design would have one DNS server that contains all the mappings Why not centralize DNS? Single point of failure Traffic volume Distant centralized database Maintenance
A centralized database in a single DNS server doesnt scale!

Distributed, Hierarchical Database


Root DNS Servers

com DNS servers yahoo.com amazon.com DNS servers DNS servers

org DNS servers pbs.org DNS servers

edu DNS servers poly.edu umass.edu DNS serversDNS servers

Client wants IP for www.amazon.com: Client first queries a root server The root server returns the IP addresses for TLD servers for the top level domain com The client then contacts one of the TLD servers which returns the IP address of an authoritative server for amazon.com The authoritative server then returns the IP address for the host name www.amazon.com

DNS: Root Name Servers


13 root DNS servers world wide Each server is a cluster of replicated servers

security and reliability purposes.

For more information see www.root-servers.org


a Verisign, Dulles, VA c Cogent, Herndon, VA (also LA) d U Maryland College Park, MD g US DoD Vienna, VA h ARL Aberdeen, MD
j Verisign, ( 21 locations)

k RIPE London (also 16 other locations) i Autonomica, Stockholm (plus 28 other locations) m WIDE Tokyo (also Seoul, Paris, SF)

e NASA Mt View, CA f Internet Software C. Palo Alto,


CA (and 36 other locations)

b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA

TLD and Authoritative Servers


Top-level Domain (TLD) Servers: Responsible for com, org, net, edu, etc, and all top-level country domains uk, fr, jp. Network Solutions maintains servers for com TLD Educause for edu TLD ICANN: Internet Corporation for Assigned Names and Numbers Authoritative DNS Servers: Every organization with publicly accessible hosts provide accessible DNS records.

That maps the names of those hosts to IP addresses Authoritative DNS servers houses these DNS records

Local Name Server


Does not strictly belong to hierarchy

Each company, university has one. Also called default name server
When host makes DNS query, query is sent

to its local DNS server

acts as proxy, forwards query into hierarchy

DNS name resolution example


Host at cis.poly.edu
2

root DNS server

3 4 5 local DNS server


dns.poly.edu

wants IP address for gaia.cs.umass.edu

TLD DNS server

Iterated query:

Contacted server replies with name of server to contact I dont know this name, but ask this server

requesting host
cis.poly.edu

authoritative DNS server dns.cs.umass.edu

gaia.cs.umass.edu

DNS name resolution example


Recursive Query:

root DNS server

Puts burden of name resolution on other server


DNS Caching Extensively used

6 TLD DNS server

local DNS server


dns.poly.edu

Cache entries timeout (disappear) after some time TLD servers typically cached in local name servers Thus root name servers not often visited

8
authoritative DNS server dns.cs.umass.edu

requesting host
cis.poly.edu

gaia.cs.umass.edu

You might also like