tele202 lecture 16 internet applications (1) 1 lecturer dr z. huang overview ¥last lecture »socket...

15
16 Internet applications (1) 1 Lecturer Overview Last Lecture » Socket programming » Source: chapter 17 This Lecture » Internet applications (1) » Source: chapter 19 Next Lecture » Internet applications (2) » Source: chapter 19

Upload: leslie-logan

Post on 11-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang

Overview

Last Lecture» Socket programming

» Source: chapter 17

This Lecture» Internet applications (1)

» Source: chapter 19

Next Lecture» Internet applications (2)

» Source: chapter 19

Page 2: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 2 Lecturer Dr Z. Huang

Client/Server

TCP is like a telephone service» Applications using the service need to

establish connection with their peers by using socket functions, just like (a little bit more complicated than) placing a telephone call

Client/server model» Server: provide service

» Client: request service from a server

Server’s control flow» Accept connections from a client by using

socket primitives

» Receive a request from the client

» Process the request and send a response to the client

Client’s control flow» 1. Request connection with a server by using

the socket primitives

» 2. Send a request message to the server

» 3. Wait to receive the response message from the server

» 4. Repeat step 2 and 3 until there is no more request

» 5. Close the connection with the server

Page 3: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 3 Lecturer Dr Z. Huang

Electronic mails

Mailbox» Each recipient has a mailbox, which is a

storage area (a file) on disk

Each mailbox is assigned a unique address

» mailbox@host-domain-name

» [email protected]

When a sender wants to send a mail to address mailbox@host-domain-name, it first locates the host’s IP address by using DNS, and then establishes connection with the host and transfers the mail using SMTP

Each host has a mail server which can receive mails to its mailboxes and deliver them to the corresponding mailboxes

Page 4: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 4 Lecturer Dr Z. Huang

SMTP

Simple Mail Transfer Protocol Email is delivered by

» the source host establishing a TCP connection to port 25 of the destination host

» An email daemon on the destination host listening to that port

» The daemon speaking SMTP

Simple ASCII protocol (RFC 821, 1425)

SMTP operation» First the client (the source host) establishes a

connection with the server (the destination host), and then waits for message from the server

» The server sends its identity and tell the client whether it will accept mail.

» If the server is willing to accept the mail, the client sends the name of the sender of the email and intended recipient.

» If it is a valid recipient, server sends a go-ahead message.

» Message is sent and acknowledged.

» When all the email has been exchanged, connection is released.

Page 5: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 5 Lecturer Dr Z. Huang

Mailbox location

On which computer to place the mailbox?

» The computer should be available all the time

» Should have enough resources, such as memory space and CPU capacity

» Should be connected to Internet continuously

How can PCs with dial-up connection to Internet receive mails?

The mailboxes normally reside on mail servers and PCs fetch mails from the servers using Post Office Protocol (POP)

POP is very useful for computers which don’t have permanent Internet connection, such as laptops

Page 6: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 6 Lecturer Dr Z. Huang

POP3

Post Office Protocol version 3» RFC 1225

Servers are used to hold mails for machines which are not regular mail servers.

» Laptops

» PC's

» MAC's

POP3 is used to fetch mails from a remote mail server and store it locally.

POP3 operation» The client first sends a login and a password

to authenticate the session.

» Once authentication has been accepted, the client sends commands to retrieve a copy pf one or more messages

» The server transfers the messages and deletes them from the permanent mailbox

» Logout

Both POP3 and SMTP manipulate the mailbox. To ensure correct operation, the two servers must coordinate use of the mailbox.

Page 7: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 7 Lecturer Dr Z. Huang

Email format

Email format is part of the protocols of SMTP and POP

Emails consist of a header and a body which are separated by a blank line

Header includes information about the sender, the recipient, date, format of the content, and etc

From: [email protected]

To: [email protected]

Date: Fri, 25 August 2000 10:21:32

Subject: lunch with me

Content-Type: text/plain

Body contains only plain textMultipurpose Internet Mail

Extensions (MIME)» Used to encode binary data

» Specify the encoding schemes used in the body

» Normally base64 encoding is used to convert binary to ASCII

Page 8: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 8 Lecturer Dr Z. Huang

Email exploders and gateways

Email exploder» Maintain mailing lists in a database

» When a mail to a mailing list is received, it forwards the mail to each member of the list

Email gateway» A computer dedicated to processing emails is

often called an email gateway

» It can run email exploders and forward emails

» It also maintain a large database for mailing lists

» When a message is sent via an email gateway, it passes across the Internet at least twice

» It can manage automated mailing list. Users can send subscribe or unsubscribe message to join or leave a list without human intervention

» By using a gateway, eg atlas, a computer can be removed or renamed without changing the employee’s email address, e.g. [email protected]

Page 9: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 9 Lecturer Dr Z. Huang

FTP

File Transfer Protocol» Widely deployed Internet file transfer service

» Oldest application protocol used in Internet and predates TCP/IP

How does FTP work?» TCP is used for data/commands transfer

» Use open command to establish a control connection with a FTP server

– open tigger.otago.ac.nz

» The control connection is used to send commands and receive responses

» If a file is required to be transferred, a data connection is established between the client and server

– get somefile

» The file is transferred via the data connection which is closed once the transfer completes

» The control connection is up until the command close or bye is typed

Page 10: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 10 Lecturer Dr Z. Huang

Other file applications

Trivial File Transfer Protocol(TFTP)» Similar to but simpler than FTP

» UDP, instead of TCP, is used

» Smaller set of commands, excluding commands for file interrogation, e.g. ls

» Does not support authorisation. A client does not send a login name or password; a file can be transferred only if the file permissions allow global access

» Advantages

– Can be used when UDP is available but TCP is not

– Less memory required in TFTP, which is required in a small special purpose hardware device

– It is especially useful for bootstrapping a hardware device which does not have a disk on which to store system software

» A small hardware device may only have TFTP, UDP and IP in its ROM, and transfer the system software from a server to its memory using TFTP when bootstrapping

Network File System (NFS)» Allows an application to open a remote file

without transferring the entire file

» Save network bandwidth

» It gives the user an illusion that he/she has the file locally, though the file may be miles away

Page 11: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 11 Lecturer Dr Z. Huang

World-wide Web

WWW History» Began in 1989 at CERN (European center for

nuclear research) by a physicist Tim Berners-Lee

» Text based prototype operational 18 months later

» Mosaic in February 1993 by Marc Andreessen, who formed Netscape Communications Corp. a year later

» World Wide Web Consortium formed by CERN and MIT in 1994

» When Netscape went public in 1995, investors paid 1.5 billion dollars for the stock for only one product

Browsers are used to display web pages, while servers provides the requested documents

Hypertext Transfer Protocol(HTTP)» Used for communication between browsers

and servers

Uniform Resource Locators(URL)» Used to locate a document (web page)

» protocol://machine/path to file

HyperText Markup Language (HTML)

» Language used to write web pages

Page 12: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 12 Lecturer Dr Z. Huang

Web server and browser

A web server performs a straightforward task repeatedly

» Waits for a browser to open a connection and request a specific page

» The server then sends a copy of the requested item, closes the connection, and repeat above

Web browsers have a more complex structure than Web servers

» A browser contains several large software components that work together to provide the illusion of a seamless service

» A browser consists of a set of clients, a set of interpreters, and a controller managing them

» It interprets both mouse and keyboard input

» Normally when it receives a request from the user, it asks HTTP client to request the requested HTML page and then asks the HTML interpreter to display the page

Page 13: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 13 Lecturer Dr Z. Huang

HTTP Scenario

The browser gets a URL from userThe browser determines the URLThe browser asks DNS for the IP

address using the IP name in the URL

The browser makes a TCP connection to port 80 (usually) of a remote host specified by the IP address in order to connect to the Web server

Then the browser sends a GET command giving the path to a file as a parameter

The Web server sends the requested file back to the browser

Then the browser release the TCP connection

The browser displays the text of the page according to the semantic of HTML

The browser may further use HTTP to fetch the images on the page

Page 14: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 14 Lecturer Dr Z. Huang

HTTP Protocol

HTTP» ASCII protocol

» Each interaction consists of one ASCII request, followed by one MIME-like response (RFC 822)

» A HTTP response consists of a header and a body separated by a blank line

HTTP/1.1 200 OKDate: Thu, 27 Apr 2000 04:03:16 GMTServer: Apache/1.3.0 (Unix)Last-Modified: Thu 17 Sep 1998 02:32:53 GMTContent-Length: 1310Content-Type: text/html

<body content>» A new TCP connection is established for each

HTTP interaction

Protocol methods» GET: request a Web page

» HEAD: request the header of a page

» PUT: request to store a Web page

» POST: request to append to a resource

» DELETE: request to remove a Web page

» LINK: connect two existing resources

» UNLINK: break a connection between two resources

Page 15: TELE202 Lecture 16 Internet applications (1) 1 Lecturer Dr Z. Huang Overview ¥Last Lecture »Socket programming »Source: chapter 17 ¥This Lecture »Internet

TELE202 Lecture 16 Internet applications (1) 15 Lecturer Dr Z. Huang

Summary

Client/serverSMTPPOP3Email exploders and gatewaysFTPTFTPNFSWWWHTTPURLHTML