+ All Categories
Home > Documents > © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/...

© O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/...

Date post: 31-Dec-2015
Category:
Upload: roland-mitchell
View: 225 times
Download: 6 times
Share this document with a friend
Popular Tags:
64
© O. Bonaventure 2008 CNP3/2008.2. Part 2 : Applications Olivier Bonaventure http://inl.info.ucl.ac.be / Computer Networking : Principles, Protocols and Practice
Transcript
Page 1: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Part 2 : Applications

Olivier Bonaventurehttp://inl.info.ucl.ac.be/

Computer Networking : Principles, Protocols and Practice

Page 2: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

The Application Layer

l Contents

l The client-server model

l Name to address resolution

l email

l world wide web

l peer-to-peer applications

Page 3: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

The client server model

l Clientl interacts with server through transport layerl sends queries or commands

Client Server

Service provider (“the network”)

Queries

l Serverl Answers the queries received from clients l Executes the commands from clients l Many clients can use the same server

l Example : email, www, ...

Responses

Page 4: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

The client server model (2)

l Client and servers interact with service providerl Both the client and the server must speak the

same languageu Application-level protocol : set of syntactical and

semantical rules that define the messages exchanged between the client and the server and their ordering

Client Server

Service provider (“the network”)

QueriesResponses

Page 5: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Transport service on the Internet

l On the Internet, applications can use two different transport services

l The service provided by the User Datagram Protocol (UDP)

u unreliable connectionless service with error detection

l The service provided by the Transmission Control Protocol (TCP)

u reliable bytestream connection-oriented service

Page 6: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

UDP service

l Identification of an applicationu IP address + UDP + port number

l Characteristics of UDP serviceu connectionlessu unreliable

u messages can be lostu transmission errors can be detected but not recoveredu sequence is not preserved

u Maximum size of messages : almost 64 Kbytes

UDP service

Applic.2

Applic.1

IdentificationIP address : 2001:4860:a005::68Protocol : UDPPort : 53

Identification: IP address : 2001:6a8:3080:2:217:f2ff:fed6:65c0Protocol : UDPPort : 1234

Page 7: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

TCP service

l Identification of an applicationu IP address + UDP + port number

l Characteristics of TCP serviceu connection-orientedu bidirectionalu reliableu byte streamu connection release

u abrupt if initiated by service provider u graceful or abrupt if initiated by user

TCP service

Applic.2

Applic.1

IdentificationIP address: 139.165.16.12Protocol : TCPPort : 80

Identification: IP address : 138.48.32.107Protocol : TCPPort : 9876

Page 8: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Internet applications

l Contents

l The client-server model

l Name to address resolution

l email

l world wide web

l peer-to-peer applications

Page 9: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Names and addresses

l Address of a serverl IP Address of the host on which the server is running

port number (TCP or UDP)u usually well known port number

l Drawbackl Difficult to remember an IP address for a human

l Idea l Replace IP address by a hostnamel Easier for humans

u but IP address is necessary to contact server

l How to translate a hostname in an IP address ?

Page 10: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Names and addresses (2)

## Internet host table#127.0.0.1 localhost138.48.32.99 babbage

138.48.32.100 leibniz138.48.32.1 routeur138.48.32.92 corneille 138.48.32.107 backus138.48.20.152 arzach138.48.32.137 almin01138.48.32.170 duke

l hosts.txt filel contains the name-address tablel must be updated regularly

l cannot be used in a large network

Page 11: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Hostnames

l Requirementl Host names should be unique

l How to achieve this in a scalable manner ? l Introduce hierarchy l Each hostname is composed of two parts

u domain name (globally unique)u hostname (unique within a given domain)

l How to uniquely distribute domain names ?u Introduce hierarchyu A small number of top-level domain namesu Inside each top-level domain, allocate uniquely second

level domain namesu Inside each seconde-level domain, allocate uniquely

either third-level domain names or host names,u ...

Page 12: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Host names and domain names

l Tree of all host names

edu com net gov mil be fr de

Sun apple fbi whitehouse ac rtbf cec inria

java eng mail www fundp ulg ucl

www info lihd scf

Pollux backus leibniz Angora siamois spirou

Page 13: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

How to translate names into addresses ?

l How to efficiently translate a host name ?l By using a centralised database

u there are more than 1 billion host names todayl By using a distributed database

u DNS : Domain Name Systemu relies on the hierarchy of domain names u there is one server responsible for each domain and

this server must be queried to translate host names inside this domain

edu com net gov mil be fr de

sun apple fbi whitehouse ac rtbf cec inria

java mail www fundp ulg ucl

www info lihd scf

Page 14: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

How to translate names into addresses ?

l Domain Name Service (DNS)l Each DNS server is responsible for a domain and

knowsu The IP addresses of all host names in this domainu The IP addresses of the DNS servers responsible for

subdomains

l Examples

u java.sun.comu www.ucl.ac.be

edu com net gov mil be fr de

sun apple fbi whitehouse ac rtbf cec inria

java mail www fundp ulg ucl

www info math fsa

Page 15: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

DNS resolver

l To be able to translate name to addresses, a DNS implementation needs

l to know actual list of IP addresses of root serversl to implement the DNS protocol and traverse the

domain names hierarchyl Difficult to do this on all endhosts

l Solutionl DNS resolver

u one resolver for a set of endhostsu maintains up-to-date list of IP addresses of root serversu implements DNS protocol

l endhostsu only need to be able to send DNS requests to resolveru must know IP address of closest DNS resolvers

Page 16: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

DNS : optimisations

l Reduce risk of failuresl several root-serversl server DNS servers authoritative for each domainl each endhost can send queries to multiple resolvers

l Improved performancel avoid sending several times the same queryl cache memory on DNS resolvers containing

u recent name-addresses translationsu addresses of DNS servers recently contacted

l DNS protocoll usually runs over UDPl sometimes is also used over TCP

Page 17: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

DNS : message format

Identification Flags

32 bits

Number of additionalNumber of authority

Number of answers12 bytes

Questions(variable number of resource records)

Number of questions

Answers(variable number of resource records)

Authority(variable number of resource records)

Additional information(variable number of resource records)

Each DNS request contains a number that will be returned in theresponse by the server to allow the client to match the request.

lQuestion/ResponselRecursive question or notlAuthoritative answer or notlPossible error

Page 18: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

DNS : resource records

l Each DNS messages is composed of resource records (RR) encoded as TLV

l < Name, Value, Type, TTL>l Types de RR

u A (Address)u Name is a hostname and Value an IPv4 address

u AAAA (Address)u Name is a hostname and Value an IPv6 address

u NS (NameServer)u Name is a domain name and Value is the hostname of the DNS

server responsible for this domainu MX (Mail Exchange)

u Name is a domain name and Value is the name of the SMTP server that must be contacted to send emails to this domain

u Type CNAMEu Alias

Lifetime of the RR in server’s cache

Page 19: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Internet applications

l Contents

l The client-server model

l Name to address resolution

l email

l world wide web

l peer-to-peer applications

Page 20: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Email

l Simplified modell Alice sends an email to Bob

[email protected]@a.net

Alice’semail server

b.net ‘s email server

Alice sends her emailto local mail forwarder

Alice’s server sends emailto b.net’s MX

Bob retrieves messagefrom his server

Page 21: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Email message format

Exp: ABC S.A.Rue de Fer 105000 Namur

DEF Corp.Steel street 9WA78 AX LondonGrande Bretagne

From: [email protected]: [email protected]: HelloDate : 27 Sept. 1999 0901

Dear Sir,

Bla Bla Bla...

Header

Message body

Page 22: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Message format (2)

l Header formatl Contains only US-ASCII (7bits) charactersl At least three lines that end with <CRLF>

u From: sender@domainu To:recipient@domainu Date: <creation date of message>

u example : 26 Aug 199 1445 EDTl Optional fields

u Subject: subject of messageu cc: copy@domainu Message-ID: <number@domain>u Received: information on path followed by messageu In-Reply-To: <message-ID>

l Header ends with empty line (<CRLF>)

Page 23: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

MIME

l Internet email was designed for US-ASCII l How to transmit more complex messages ?

l Multipurpose Internet Mail Extensionsl Improved email message formatl Constraints

u must remain compatible with old email serversu most of them only support US-ASCII and short lines

u must support non-English textu character set must be beyond 7bits US-ASCII

u must support various formats in a single messageu message body, attachments, ...

u must allow to transmit audio, video, ...u need to identify the type of content

l Solutionl add new optional fields in headerl add optional fields inside message body when

necessary

Page 24: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

MIME (2)

l New header fields

l MIME-Version:u version of MIME used to encode messageu current version : 1.0

l Content-Description:u comment describing the content of the message

l Content-Type:u type of information inside message

l Content-Transfer-Encoding:u how the message has been encoded

l Content-Id:u unique identifier for the content

Page 25: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

MIME: Content-Type

l Content-Type : type/encodingl type of content

u text, image, video, applicationu multipart

l encoding of contentu text/plain , text/htmlu image/gif, image/jpegu audio/basicu video/mpeg, video/quicktimeu application/octet-stream, application/postscriptu multipart/alternative

u message contains several times the same information with different encodings

u multipart/mixedu message contains several information of different types

u example : text of message body and attachment

Page 26: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Character sets and content encoding

l How to support rich character sets ?l Content-Type: text/plain; charset=us-ascii

u ASCII 7bits, defaultl Content-Type: text/plain; charset=iso-8859-1

u Character set suitable for Western European languages, defined by ISO, 8 bits per character

u Content-Type: text/plain; charset=unicodeu Universal character set, defined by ISO, 16 bits per character

l How to encode non-text data ?l data must be encoded in US-ASCII 7 bits charactersl Base64l uses ASCII characteres A...Z,a...z,0...9, "+" et "/"

u A=0, B=1, C=2, ... +=62 et /=63l Each character is used to encode 6 bits

u 24 bits from initial message -> 4 ASCII charactersl Special character “=” used for padding

Page 27: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Multipart/mixed

l How to place different contents and encoding in a single message ?

l We need a delimiter between the different content types placed inside message body

Date: Mon, 20 Sep 1999 16:33:16 +0200From: Nathaniel Borenstein <[email protected]>To: Ned Freed <[email protected]>Subject: TestMIME-Version: 1.0Content-Type: multipart/mixed; boundary="simple boundary"

preamble, to be ignored

--simple boundaryContent-Type: text/plain; charset=us-ascii

partie 1

--simple boundaryContent-Type: text/plain; charset=us-ascii

partie 2--simple boundary

Page 28: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Email transmission

l SMTP : Simple Mail Transfer protocoll uses TCP servicel Address of SMTP server

u IP address of server + TCP + port number: 25u RR of type MX can be used to find the SMTP server responsible for a

given domain

[email protected]@a.net

a.net’sSMTP server

b.net’s SMTPserver

SMTP Emailretrieval

SMTP

Page 29: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

SMTP

l Client-server modell Server waits for email messages to relay/deliverl Client sends email messages through server

l Application-level protocoll client opens TCP connectionl Client sends commands composed of

u command parameter <CRLF>u HELOu MAIL FROM:u RCPT TO:u DATAu QUIT

l Server answers with one-line repliesu numeric_code comment (text) <CRLF>

u 250 OKu 221 closing

Page 30: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

SMTP (2)

l Three phases of SMTP1. Establishment of an SMTP association

u TCP connection established upon request from clientu Server greetingsu HELO command from client

2. Message transferu MAIL FROM: <user@domaine>1. RCPT TO: <user@domaine>u DATA

u transmission of entire message including headersu one line containing only the dot “.” characters marks end of message

1. Other subsequent messages can be transmitted afterl Release of the SMTP association

u QUITu Closing message from server1. TCP connection is closed

Page 31: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Retrieval of email messages

l In the old days1. Destination is always connected to the Internet

u email addresses are username@hostnameu When an email arrives, it is stored in a file that belongs to the

user, e.g. /var/mail on Unix

u Todayu Most networks have one or a few SMTP servers used

to receive emails, but also detect spam, viruses, ...1. Endusers retrieve their emails from this server

u Post Office Protocol (POP)u Internet Mail Access Protocol (IMAP) u Webmail

Page 32: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

POP

l Goall Allow authenticated users to retrieve email messages

from serverl Operation

l POP uses TCP servicel Address of POP server

u Host address + TCP + port number : 110l Client send commands

u command : one ASCII line ending with <CRLF>u USER, PASS, STAT, RETR, DELE, QUIT

l server replies withu +OK if command was successful

u email messages follow some +OK repliesu -ERR in case of errors

Page 33: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

POP (2)

l Three phases of the protocol1. Authorisation : checking the user credentials

u USER <username>u PASS <password>

2. Transactionu retrieval and removal of messagesu STAT

u list headers of stored messagesu RETR <n>

1. retrieval of the nth messageu DELE <n>

u the nth message is marked for deletion3. Update

u End of the retrieval phaseu Messages marked for deletion are removed from serveru TCP connection is closed

Page 34: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Internet applications

l Contents

l The client-server model

l Name to address resolution

l email

l world wide web

l peer-to-peer applications

Page 35: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

FTP : File Transfer Protocol

l Protocol from the old daysl allows a client to send/retrieve files from a server

l Problems solved by FTPl User authentication

u username, passwordl Filesystem traversal

u browse directories on server and locate filesl file transfer

u to or from the server

ClientServer

CommandsFtp-control : port21

ResponsesFtp-data : port 20

Page 36: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

FTP : main commands

l Main commandsl USER <user>

u username, ftp for anonymous accessl PASS <pass>

u allows user to send password associated to usernamel SYST

u information about type of serverl CWD <path>

u directory traversall STOR <file>

u save file in the current directory on serverl RETR <file>

u retrieve file from current directory on serverl PORT <B1,B2,B3,B4,B5,B6>

u use TCP connection on port B5*256+B6 on B1.B2.B3.B4

Page 37: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

World Wide Web

l Goalsl Allow browsers to browse hypertext documents

stored on multiple servers

Client(browser)

Server www.machin.be

Server www.truc.fr

Server www.stuff.com

Query

Information

Page 38: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

World Wide Web (2)

l The five key elements of www

1. An addressing scheme that allows to identify any document stored on a server

u URL : Uniform Resource Locator2. An hypertext language that allows to easily write

documents with hypertext linksu HTML : HyperText Markup Language

l An efficient and lightweight application-level protocol to exchange documents

u HTTP : HyperText Transfer Protocol1. Servers2. Clients (browsers)

Page 39: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Uniform Resource Locator (URL)

l Uniform Resource Locator (URL)

l generic syntax : <protocol>://<document>u protocol used to retrieve document from server

u http is the most common one but others are frequently usedu document indicates the server and the location of the

documentu <user>:<password>@<server>:<port>/<path>

u <user> : optional usernameu <password> : optional passwordu <machine> : hostname or IP address of the server that hosts the

document u <port> : optional port numberu <path> : document location on server

u examples u http://www.info.ucl.ac.beu http://alice:[email protected]:80/index.html

Page 40: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTML

l HyperText Markup Langagel Language used to encode documents on the web

l Keywords

u <HTML>...</HTML> u <HEAD>...</HEAD> u <BODY>...</BODY>u <TITLE>..</TITLE>u <B>...</B>u <I>...</I>u <H1>...</H1>u <P>u <HR>u <UL>...</UL>u <OL>...</OL>u <IMG SRC="URL">u <A HREF="URL">text anchor</A>

Page 41: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTML (2)

l Example

<HTML>

<HEAD><TITLE>HTML test page</TITLE></HEAD>

<BODY><IMG SRC="http://www.images.be/logo.gif"><H1>Web servers from UCL UCL<P></H1><HR><UL> <LI><A HREF="http://www.uclouvain.be">UCL</A> <LI><A HREF="http://www.info.ucl.ac.be">CSE Dept.</A> <LI><A HREF="http://www.math.ucl.ac.be">Math</A></UL></BODY>

</HTML>

Header

Body

Image on remote server

First level title

External hypertext link

Page 42: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Information transfer www

l HTTP 1.0 - non-persistent connectionl Principle

u relies on TPC service (default port : 80)u Client sends request, server sends reply

Client Server

CONNECT.request CONNECT.indication

CONNECT.confirmCONNECT.response

DATA.request(Request)

DATA.req(Response)

DATA.ind(Request)

DATA.ind(Response)DISCONNECT.ind

DISCONNECT.req

DISCONNECT.reqDISCONNECT.ind

Page 43: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP

ClientServer

MethodHeaderCRLF

MIME Document

Request

Method GETlPOSTl...

Header contains additional informationabout request sent by client

Status lineHeaderCRLF

MIME Document

Response

Header contains information about serverand optional parameters specific to response

Success or failure

HTTP is a stateless protocol, server does not maintain any state fromone request to anotherlPOP, FTP, SMTP are examples of stateful protocols in contrast

Page 44: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP : Example

Client

Serverwww.info.ucl.ac.beGET /index.html HTTP/1.1

Host: www.info.fundp.ac.be CRLF

Request

ResponseHTTP/1.1 200 OK Date: Fri, 10 Sep 1999 14:29:19 GMT Server: Apache/1.3.0 (Unix) ApacheJServ/1.0b5 Last-Modified: Thu, 02 Sep 1999 11:50:50 GMT Content-Length: 1224 Content-Type: text/html CRLF <HTML>. . .</HTML>

Page 45: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP : Methods

l Methodsl GET

u method used to request a "document" stored on serveru GET <document> HTTP/1.0

u exampleu GET /index.html HTTP/1.0

l POSTu method used to send a "document" to a server

u document is part of the request and encoded as a MIME document

Page 46: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP : Request headers

l Request headersl Allow to add information about the client or the request l Host: <name>

u Name of the server where the document is stored l Authorization

u allows to perform access controll If-Modified-Since: <date>

u server will only send the requested document if the document is more recent than date

l Referer: <url>u Information, indicates the URL visited by the client before this

requestl User-Agent: <agent>

u information, indicates the browser used on the client

Page 47: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP : Status line

l Status liinel Format : Version_HTTP Code Comment l Success/Failure

u 1xx : For information (unused)u 2xx : Success

u Example : HTTP/1.0 200 OKu 3xx : Redirection

u Request could not be handled on local server and should be sent to another server

u Example : u HTTP/1.0 301 Moved permanentlyu attached MIME document will contain URL of document

u 4xx : Client-side erroru examples

u syntax error, unreachable URL, unauthorised, ... u 5xx : Server-side error

u examples : u internal error, method not implemented on server, ...

Page 48: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP : Response headers

l Headerl Optional information about the server, the response or

the document attached to the responsel Date

u date of the document attached to responseu example : Date: Wed, 05 Sep 2001 13:27:34 GMT

l Serveru Name and version of http server usedu example :

Server: Apache/1.3.20 (Unix)ApacheJServ/1.1.2 PHP/4.0.6l Content-*

u MIME header of the attached document u example :

Content-Length: 5891Content-Type: text/html

Page 49: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP 1.1

l HTTP 1.0l a single TCP connection used to transmit

a single document (html file, image,...)u the establishment and release of the TCP connection

induce a significant overhead, in particular for small pages

l HTTP 1.1l uses a single persistent TCP connection

u This TPC connection can be used for several requests and the corresponding responses

u the cost of establishing and releasing the TCP connection is amortised over multiple requests

u Although HTTP 1.1 uses a single TCP connection for multiple requests, HTTP 1.1 remains stateless

Page 50: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP 1.1 : Persistent connection

ClientServer

CONNECT.request CONNECT.indication

CONNECT.confirm CONNECT.response

DISCONNECT.indDISCONNECT.req

DISCONNECT.reqDISCONNECT.ind

HTTP/1.1 200 OKKeep-Alive: timeout=15, max=99Connection: Keep-Alive...

GET / HTTP1.1Connection: Keep-Alive... HTTP/1.1 200 OK

Keep-Alive: timeout=15, max=100Connection: Keep-Alive...GET /images/logo.gif HTTP1.1

Connection: Keep-Alive...

Page 51: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Improving performance

l Observationl Many pages are requested multiple times or from

close endhostsl Solution

l local cache on each clientu if-modified-since header helps

l one cache for multiple endhosts

Client1

ClientN

Proxy

ServerA

ServeurB

Page 52: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP Authentication

l Example

Client

Server

HTTP/1.0 401 Authorization reqWWW authenticate: machin...

GET / HTTP1.1...

Browser asks user/password to user

HTTP/1.1 200 OK...

GET / HTTP1.1Authorization: User-password...

GET /images/t.gif HTTP1.1Authorization: User-password...Browser sends user/password in each request

Page 53: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

HTTP Cookies

l Example

Client

Server

HTTP/1.0 200 OKSet-Cookie: machin...

GET / HTTP1.1...

Browser saves cookie

HTTP/1.1 200 OK...

GET /doc HTTP1.1Cookie: machin...

GET /images/t.gif HTTP1.1Cookie: machi...Browser sends cookie in all requests sent to server

Response is functionof URL and cookie

Normal response

Page 54: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Internet applications

l Contents

l The client-server model

l Name to address resolution

l email

l world wide web

l peer-to-peer applications

Page 55: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Predicted IP traffic growth

Page 56: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Predicted IP traffic growth

Page 57: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Predicted IP traffic growth (3)

Page 58: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Peer-to-peer file sharing

l Evolution of file sharing on the Internet

l Servers using ftp protocoll A single server that serves all files on diskl A set of mirror serves serving the same content

l The innovation introduced by Napsterl How to distribute many files from many nodes ?

u Keep the files on their source nodesu Central Napster server stores description and URL of

each shared fileu Users willing to obtain a file consult central server to

obtain file URL and then download file from their respective source nodes

u server remains simple and can index large number of filesu server does not directly participate in file transfer

Page 59: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Peer-to-peer file sharing (2)

l Limitations of the Napster approachl a single server indexes all filesl if a source node fails, then the ongoing file

transfers must be restartedu completely or partially depending on the file transfer

protocol begin used for the transferl performance of file transfer is function of

performance of the corresponding source nodeu if source node is connected via ADSL, performance will

be severely limitedl How to improve ?

l Divide the file in blocksl Each block can be served by multiple nodes

u provides redundancyl Download from several nodes at the same time

u one TCP connection may be slow and others faster

Page 60: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Distributed Hash Table based P2P

l How to scale file sharing to a very large number n of nodes ?

l Principle of the solutionl Use a hash function such as SHA-1l Each node has one identifier, id=hash(IPaddress)

and a pointer to its successor on the Chord ring

Node 1

Node 5

Node 7

Node 12

Node 15

Page 61: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

How to store files ?

l Principlel File FOOBAR is stored on the node whose id is

the successor of hash(“FOOBAR”) on the ringl A node on the ring uses its successors to find the

responsible node for a given fileu Examples

Node 1

Node 5

Node 7

Node 12

Node 15

Hash(FOOBAR)=13Hash(BARFOO)=5

Page 62: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

How to find files faster ?

l Performance of file lookup l O(n)

u worst case is to follow linked list of n nodes

l How to improve ?

l Allow nodes to know addition pointers to other nodes on the Chord ring to speedup lookup

u m = number of bits in the key/node identifiersu Each node maintains routing table of m entriesu The ith entry in the table at node n contains the identity

of the first node, s, that succeeds n by at least 2^i−1 on the identifier circle, i.e., s = successor(n + 2^i−1 )

u arithmetic modulo 2^m is used u A finger table entry includes both the Chord identifier

and the IP address (and port number) of relevant node.

Page 63: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Scalable lookup with Chord

l Examplel m=8

l How to find key 53 from node 8 ?

Node 8

Node 13

Node 29

Node 46

Node 57

Node 51

Node 37

N8+1 N13

N8+2 N13

N8+4 N13

N8+8 N29

N8+16 N29

N8+32 N46

N46+1 N51

N46+2 N51

N46+4 N51

N46+8 N57

N46+16 N57

N46+32 N8

Page 64: © O. Bonaventure 2008CNP3/2008.2. Part 2 : Applications Olivier Bonaventure ://inl.info.ucl.ac.be/ Computer Networking : Principles,

© O. Bonaventure 2008CNP3/2008.2.

Summary

l Client-server model

l UDP and TCP services

l Application-level protocolsl DNS

u relies on UDP, statelessl SMTP, POP, FTP

u rely on TCP, statefulll HTTP

u relies on TCP, stateless

l Peer-to-peer applications


Recommended