80
Department of Computer and IT Department of Computer and IT Engineering Engineering University of Kurdistan University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri By: Dr. Alireza Abdollahpouri

Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Embed Size (px)

Citation preview

Page 1: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Department of Computer and IT EngineeringDepartment of Computer and IT EngineeringUniversity of KurdistanUniversity of Kurdistan

Computer Networks IIApplication Layer

By: Dr. Alireza AbdollahpouriBy: Dr. Alireza Abdollahpouri

Page 2: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

الیه کاربرد مستقیما با کاربر )برنامه ها یا اشخاص( در ارتباط است. این الیه از طریق پروتکلهاي مختلفی که در اختیار دارد،

خدمات مورد نیاز کاربران را فراهم میآورد. هر کدام از پروتکلهاي این الیه بسته به نوع و ماهیت آنها از یکی از

در الیه پایینتر استفاده میکنند. UDP یا TCP پروتکلهاي

Application Layer

2

Page 3: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

3

Page 4: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

مشهورترین پروتكلهاي اين اليه عبارتند از:

FTPپروتكلي براي انتقال فايل :HTTP پروتكلي براي دسترسي به :

صفحات وبDNS پروتكلي براي ترجمه نامهاي :

IPنمادين به آدرسهاي

Telnet پروتكلي براي ورود به :سيستم از راه دور

SMTP و POP3 پروتكلهايي براي :E-mailارسال و دريافت

Application-Layer Protocols

4

Page 5: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

application

transportnetworkdata linkphysical

modem

modem

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

Application: communicating, distributed processes e.g., e-mail, Web, P2P file

sharing, instant messaging running in end systems (hosts) exchange messages to

implement application

Application-layer protocols one “piece” of an app define messages exchanged

by apps and actions taken use communication services

provided by lower layer protocols (TCP, UDP)

Applications and Application-Layer Protocols

5

Page 6: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

modem

modem

Typical network app has two pieces: client and server

Client: initiates contact with server

(“speaks first”) typically requests service

from server, Web: client implemented in

browser; e-mail: in mail reader replyServer:

provides requested service to client e.g., Web server sends requested

Web page, mail server delivers e-mail

applicatio

transport

networkdata linkphysical

applicatin

transport

networkdata linkphysical

request

Client-Server Paradigm

6

Page 7: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

process sends/receives messages to/from its socket

socket analogous to door sending process pushes

message out door sending process assumes

transport infrastructure on other side of door which brings message to socket at receiving process

process

TCP withbuffers,variables

socket

host orserver

process

TCP withbuffers,variables

socket

host orserver

Internet

controlledby OS

controlled byapp developer

Processes Communicating Across Network

7

Page 8: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Data loss some apps (e.g., audio)

can tolerate some loss other apps (e.g., file

transfer, telnet) require 100% reliable data transfer

Timing some apps (e.g.,

Internet telephony, interactive games) require low delay to be “effective”

Bandwidth some apps (e.g.,

multimedia) require minimum amount of bandwidth to be “effective”

other apps (“elastic apps”) make use of whatever bandwidth they get

What transport service does an app need?

8

Page 9: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Application Data loss

Bandwidth Time Sensitive

file transfer no loss elastic no

e-mail no loss elastic no

web documents

no loss elastic (few kbps) no

real-time audio/video

loss-tolerant

audio: few kbps-1Mbps

video:10kbps-5Mbps

yes, 100s of msec

stored audio/video

loss-tolerant

same as above yes, few sec

interactive games

loss-tolerant

few kbps-10kbps yes, 100s of msec

instant messaging

no loss elastic yes and no

Requirements of Selected Network Applications

9

Page 10: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

TCP service: connection-oriented: setup

required between client and server processes

reliable transport between sending and receiving process

flow control: sender won’t overwhelm receiver

congestion control: throttle sender when network overloaded

no guarantee on: timing, minimum bandwidth

UDP service: unreliable data transfer

between sending and receiving process

does not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee

Internet Transport Protocols Services

10

Page 11: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Internet apps: application, transport protocols

applications application-layer protocol

underlying transport protocol

e-mail SMTP [RFC 2821] TCP

remote terminal access

Telnet [RFC 854] TCP

web HTTP [RFC 2616] TCP

file transfer FTP [RFC 959] TCP

Name server DNS [ RFC 1034] UDP or TCP

streaming multimedia proprietary(e.g., youtube)

Typically UDP

11

Page 12: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Connectionless iterative server

UDP

12

Page 13: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Connection-oriented concurrent server

TCP

13

Page 14: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Sockets

ClientsocketClientsocket

ConnectionsocketConnectionsocket

WelcomingsocketWelcomingsocket

Three-way handsh

ake

Client processClient process Server processServer process

Client IP Address&

Port Number

Server IP Address&

Port Number2

Server IP Address&

Port Number1

bytes

sendread read write

14

Page 15: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Domain Name System(DNS)

15

Page 16: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

16

راه حل: استفاده از یک پایگاه داده سلسله مراتبی توزیع شده

راه حل: استفاده از یک پایگاه داده سلسله مراتبی توزیع شده

در اولين سالهاي راه اندازي شبكه اينترنت، راه حل IP اي براي ترجمه نامهاي نمادين به آدرس بسيار ساده

IP وجود داشت و آن تعريف تمام نامها و آدرسهاي بود. اين فايل داراي hosts.txt معادل، در يك فايل بنام

دو ستون بود كه در يك طرف آدرس نمادين و در طرف معادل آن نوشته شده بود. به دليل اينكه IP ديگر آدرس

در آن تاريخ تعداد آدرسها زياد نبود، حجم چنين فايلي توانست شد و هر ماشين ميزبان مي چندان بزرگ نمي

يك نسخه از اين فايل را در اختيار داشته باشد و هر شب اين فايل را از روي فايل مرجع 24سـاعت

كرد تا هر گونه تغيير احتمالي و روز مي تازه سازي و بهتعريف آدرسهاي جديد اعمال شود. بديهي است كه

امروزه با حجم ميليوني آدرسها در اينترنت، داشتن يك فايل متمركز و قرار دادن تمام آدرسها و معادل

. در آن، امكان پذير نيستIPآدرس

در اولين سالهاي راه اندازي شبكه اينترنت، راه حل IP اي براي ترجمه نامهاي نمادين به آدرس بسيار ساده

IP وجود داشت و آن تعريف تمام نامها و آدرسهاي بود. اين فايل داراي hosts.txt معادل، در يك فايل بنام

دو ستون بود كه در يك طرف آدرس نمادين و در طرف معادل آن نوشته شده بود. به دليل اينكه IP ديگر آدرس

در آن تاريخ تعداد آدرسها زياد نبود، حجم چنين فايلي توانست شد و هر ماشين ميزبان مي چندان بزرگ نمي

يك نسخه از اين فايل را در اختيار داشته باشد و هر شب اين فايل را از روي فايل مرجع 24سـاعت

كرد تا هر گونه تغيير احتمالي و روز مي تازه سازي و بهتعريف آدرسهاي جديد اعمال شود. بديهي است كه

امروزه با حجم ميليوني آدرسها در اينترنت، داشتن يك فايل متمركز و قرار دادن تمام آدرسها و معادل

. در آن، امكان پذير نيستIPآدرس

Page 17: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Hierarchical Distributed Name Space

Root Server

عدد سرویس دهنده 13تعداد ریشه وجود دارد

عدد سرویس دهنده 13تعداد ریشه وجود دارد

17

Page 18: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

18

DNS root Servers

Page 19: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

DNS root Servers

19

Page 20: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Domains

20

Page 21: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

DNS in the Internet

The inverse domain is used to map an IP address to a name

21

Page 22: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Generic domains

Description

com Commercial organizations

edu Educational institutions

gov Government institutions

int International organizations

mil Military groups

net Network support centers

org Nonprofit organizations

22

Page 23: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

23

Country domains

http://www.nic.ir/http://www.nic.ir/

های پژوهشگاه دانش در تهران مسئولیت بنیادی

و زیر دامنه ir کنترل دامنههای آن را به عهده دارد

های پژوهشگاه دانش در تهران مسئولیت بنیادی

و زیر دامنه ir کنترل دامنههای آن را به عهده دارد

Page 24: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Iterative resolution

پرس و جوي تکراري

قسمت اعظم تالش براي تبدیل یک نام

سرویس سرویس برعهده دهنده محلیدهنده محلی

است

24

Page 25: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

DNS Protocol: Forward Lookup Query

“ .”

org. edu. com. ir.

ac.ir.

uok.ac.ir.Local

Name Server

RootName Server

Client

www.icann.org.

Authorized nameserver for org. zone

Forward Lookup Query:What is IP Address of www.icann.org

IP Address of www.icann.org is 142.12.01.23

25

Page 26: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Recursive resolution

پرس و جوي بازگشتی

26

Page 27: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Query and response messages

27

Page 28: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

DNS can use the services of UDP or TCP,

using the well-known port 53.

NoteNote::

28

Page 29: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

HTTP and WWW

وب جهان گستر و پروتکل انتقال صفحات ابرمتن

29

Page 30: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

World Wide Web

Distributed services

30

Page 31: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Hypertext

31

Page 32: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Browser architecture

Interpreter

32

Page 33: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Categories of Web documents

33

Page 34: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Static document

34

Page 35: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Dynamic document

35

Page 36: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Active document

36

Page 37: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Web page consists of objects Object can be HTML file, JPEG image, Java

applet, audio file,… Web page consists of base HTML-file which

includes several referenced objects Each object is addressable by a URL Example URL:

Web page consists of objects Object can be HTML file, JPEG image, Java

applet, audio file,… Web page consists of base HTML-file which

includes several referenced objects Each object is addressable by a URL Example URL:

eng.uok.ac.ir/abdollahpouri/index.html

host name path name

Web and HTTP

37

Page 38: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

HTTP: hypertext transfer protocol

Web’s app layer protocol client/server model

client: browser that requests, receives, “displays” Web objects

server: Web server sends objects in response to requests

HTTP 1.0: RFC 1945 HTTP 1.1: RFC 2068

PC runningExplorer

Server running

Apache Webserver

Mac runningNavigator

HTTP request

HTTP request

HTTP response

HTTP resp

onseStorage

contents:base files, objects

HTTP Overview

38

Page 39: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

HTTP uses the services of TCP on well-known port 80.

NoteNote::

39

Page 40: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Uses TCP: client initiates TCP

connection (creates socket) to server, port 80

server accepts TCP connection from client

HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)

TCP connection closed

Uses TCP: client initiates TCP

connection (creates socket) to server, port 80

server accepts TCP connection from client

HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)

TCP connection closed

HTTP is “stateless” server maintains no

information about past client requests

HTTP Overview (cont.)

40

Page 41: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Nonpersistent HTTP At most one object is

sent over a TCP connection.

HTTP/1.0 uses nonpersistent HTTP

Persistent HTTP Multiple objects can be

sent over single TCP connection between client and server.

HTTP/1.1 uses persistent connections in default mode

HTTP Connections

41

Page 42: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Suppose user enters URL www.uok.ac.ir/computer/home.html

Suppose user enters URL www.uok.ac.ir/computer/home.html

1. HTTP client initiates TCP connection to HTTP server )process( at www.uok.ac.ir on port 80

3. HTTP client sends HTTP request message )containing URL( into TCP connection socket. Message indicates that client wants object Computer/home.html

2. HTTP server at host www.uok.ac.ir waiting for TCP connection at port 80. “accepts” connection, notifying client

4. HTTP server receives request message, forms response message containing requested object, and sends message into its socket

tim

e

(contains text, references to 10

jpeg images)

(contains text, references to 10

jpeg images)

Non-persistent HTTP

42

Page 43: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects

7. Steps 1-6 repeated for each of 10 jpeg objects

6. HTTP server closes TCP connection.

time

4. …

Non-persistent HTTP (cont.)

43

Page 44: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Response time: one RTT to initiate TCP

connection one RTT for HTTP request

and first few bytes of HTTP response to return

file transmission time

total = 2RTT+transmit time

time to transmit file

initiate TCPconnection

RTT

requestfile

RTT

filereceived

time time

Response Time Modeling

44

Page 45: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Nonpersistent HTTP issues: requires 2 RTTs per object OS must work and allocate

host resources for each TCP connection

but browsers often open parallel TCP connections to fetch referenced objects

Persistent HTTP server leaves connection

open after sending response subsequent HTTP messages

between same client/server are sent over connection

Nonpersistent HTTP issues: requires 2 RTTs per object OS must work and allocate

host resources for each TCP connection

but browsers often open parallel TCP connections to fetch referenced objects

Persistent HTTP server leaves connection

open after sending response subsequent HTTP messages

between same client/server are sent over connection

Persistent without pipelining: client issues new request only

when previous response has been received

one RTT for each referenced object

Persistent with pipelining: default in HTTP/1.1 client sends requests as soon

as it encounters a referenced object

as little as one RTT for all the referenced objects

Persistent HTTP

45

Page 46: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

46

HTTP request and response format

Page 47: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

47

Status line

Request line

خط درخواست

خط وضعیت

هر سطر سرآیند به این فرمت است

Page 48: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

درخواست دیگر :انواع

,OPTIONS, PATCH, COPY, MOVE, LINK, UNLINK, TRACE

درخواست دیگر :انواع

OPTIONS, PATCH, COPY, MOVE, LINK, UNLINK, TRACE,

48

Page 49: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

HTTP request message: ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:frIf-modified-since:Sat, 2 Nov 2002 13:45:12 (carriage return, line feed)

request line)GET, POST,

HEAD commands(

header lines

Carriage return, line feed

indicates end of message

HTTP Request Message - example

49

Page 50: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Example 1

This example retrieves a document. We use the GET method to retrieve an image with the path /usr/bin/image1. The request line shows the method (GET), the URL, and the HTTP version (1.1).

The header has two lines that show that the client can accept images in GIF and JPEG format. The request does not have a body.

The response message contains the status line and four lines of header. The header lines define the date, server, MIME version,

and length of the document. The body of the document follows the header (see next slide).

50

Page 51: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Example 1

51

Page 52: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Example 2

This example retrieves information about a document. We use the HEAD method to retrieve information about an HTML document.

The request line shows the method (HEAD), URL, and HTTP version (1.1). The header is one line showing that the client can accept the document in any format (wild card). The request does

not have a body. The response message contains the status line and five lines of header. The header lines define the date, server, MIME

version, type of document, and length of the document (see next slide). Note that the response message does not contain a body.

52

Page 53: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Example 2

53

Page 54: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

فرض كنيد كاربر، آدرس زير را در مرورگر خود وارد مي كند:

http://www.w3.org/hyper/www/project.html

مرورگر با تحليل آدرس متوجه ميشود كه بايد تقاضاي به سمت سرويس دهنده HTTP فايلي را طبق پروتكل

بفرستد. مراحلي كه اتفاق مي افتند به شرح زير خواهند بود:

مرورگر آدرس را تحليل كرده و قسمتهاي پروتكل، (1آدرس نام حوزه، شاخه و نام فايل را از آن استخراج

ميكند. سرويس دهنده 53 با پورت UDP مرورگر يك اتصال (2

DNS برقرار نموده و تقاضاي ترجمه آدرس نام حوزه را ماشين سرويس دهنده IP به آن ارسال مي نمايد تا آدرس

بدست آيد. در اين مثال مرورگر تقاضاي ترجمه نامwww.w3.org را به DNS ارسال ميكند.

54

Page 55: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

3) DNS در پاسخ، آدرس IP معادل با نام حوزه رارا IP آدرس DNS برميگرداند. فرض كنيد در اين مثال

برگردانده است. 128.30.52.31و 128.30.52.31با آدرس TCP مرورگر يك ارتباط(4

برقرار ميكند.80پورتپس از برقراري ارتباط، يك پيغام درخواست به صورت ( 5

زير به سمت سرويس دهنده ارسال ميشود:“GET/ hyper/www/project.html http/1.1”

سرويس دهنده اين رشته را دريافت و پس از پردازش ( 6استخراج كرده / hyper/www /را از شاخه project.htmlآن، فايل

و براي مرورگر ارسال مي نمايد. مرورگر فايل را دريافت كرده و پس از خاتمه دريافت (7

را قطع ميكند. TCPارتباط مرورگر فايل ابرمتني را تفسير كرده و آنرا روي ( 8

خروجي نمايش ميدهد. اگر فايل ابرمتني در جايي داراي صدا يا تصوير باشد به (9

را تكرار نموده و آنها را 8 تا 1 ازاي تك تك آنها مراحل(persistent httpكند )با فرض بترتيب دريافت مي

3) DNS در پاسخ، آدرس IP معادل با نام حوزه رارا IP آدرس DNS برميگرداند. فرض كنيد در اين مثال

برگردانده است. 128.30.52.31و 128.30.52.31با آدرس TCP مرورگر يك ارتباط(4

برقرار ميكند.80پورتپس از برقراري ارتباط، يك پيغام درخواست به صورت ( 5

زير به سمت سرويس دهنده ارسال ميشود:“GET /hyper/www/project.html http/1.1”

سرويس دهنده اين رشته را دريافت و پس از پردازش ( 6استخراج كرده / hyper/www /را از شاخه project.htmlآن، فايل

و براي مرورگر ارسال مي نمايد. مرورگر فايل را دريافت كرده و پس از خاتمه دريافت (7

را قطع ميكند. TCPارتباط مرورگر فايل ابرمتني را تفسير كرده و آنرا روي ( 8

خروجي نمايش ميدهد. اگر فايل ابرمتني در جايي داراي صدا يا تصوير باشد به (9

را تكرار نموده و آنها را 8 تا 1 ازاي تك تك آنها مراحل(persistent httpكند )با فرض بترتيب دريافت مي

55

Page 56: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

SMTPand POP3

پروتکلهای انتقال و دریافت ایمیل

56

Page 57: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Email address

57

Page 58: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Three major components: user agents mail servers simple mail transfer protocol:

SMTP

User Agent Sometimes is called:

“mail reader” composing, editing, reading

mail messages e.g., Eudora, Outlook, elm,

Netscape Messenger outgoing, incoming

messages stored on server

user mailbox

outgoing message queue

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SM

TP

Electronic Mail

58

Page 59: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

User agent

59

Page 60: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Mail Servers mailbox contains incoming messages for user message queue of outgoing (to be sent) mail messages SMTP protocol between mail servers to send email messages

“client”: sending mail server (sending agent) “server”: receiving mail server (receiving agent)

Electronic Mail: Mail Servers

60

mailboxes

Message queue

Page 61: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

1) User1 (sender) uses UA to compose message to [email protected] .

2) User1’s UA sends message to his mail server; message placed in message queue.

3) Client side of SMTP opens TCP connection with User2’s mail server.

4) SMTP client sends User1’s message over the TCP connection.

5) User2’s mail server places the message in User2’s mailbox.

6) User2 invokes his/her user agent to read message.

Example: User1 sends message to User2

useragent

mailserver

mailserver user

agent

1

23 4 5

6User1

User2

[email protected]

[email protected]

webmail.uok.ac.ir

yahoo.com

61

Page 62: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

62

SMTP commands

Page 63: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

C:\> telnet www.uok.ac.ir 25Connecting to www.uok.ac.ir ...

اتصال ================== ==========برقراري220 PARSDATA Mail Server (IMail 8.00 2586-5) NT-ESMTP Server X1HELO PARSDATA250 hello PARSDATA Mail Serverنامه ===================== ========== پوششMAILFROM: [email protected] okRCPT TO: [email protected] ok deliver to alternateنامه =================== بدنه و ========= سرآيند

DATA354 ok, send it; end with <CRLF>.<CRLF>FROM: AbdollahpourTO: myselfHi this is a sample e-mail to show SMTP in action. .اتصال ============= ===============خاتمه 250 Message queuedQUIT221 GoodbyeConnection to host lost

header

bodybody

blankline

..

SMTPارسال ایمیل به صورت مستقیم با دستورات SMTPارسال ایمیل به صورت مستقیم با دستورات

63

Page 64: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

MIME

MIMEدهد كاراكترهاي غير يك پروتكل تكميلي است كه اجازه مي ASCII يك پروتكل MIME منتقل شوند. دقت كنيد كهSMTP نيز از طريق

باشد بلكه نيست و قادر به ارسال نامه نميSMTP جايگزين براي را به MIME شود. ميتوان محسوب ميSMTP اي براي پروتكل توسعه

و ASCII را به دادهASCII اي تصور نمود كه داده غير صورت برنامه بالعكس ترجمه ميكند

MIMEدهد كاراكترهاي غير يك پروتكل تكميلي است كه اجازه مي ASCII يك پروتكل MIME منتقل شوند. دقت كنيد كهSMTP نيز از طريق

باشد بلكه نيست و قادر به ارسال نامه نميSMTP جايگزين براي را به MIME شود. ميتوان محسوب ميSMTP اي براي پروتكل توسعه

و ASCII را به دادهASCII اي تصور نمود كه داده غير صورت برنامه بالعكس ترجمه ميكند

64

Page 65: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

MIME header

From: [email protected] To: [email protected] Subject: Picture of iustcc: [email protected] MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg

base64 encoded data ..... ......................... ......base64 encoded data

.

Examples of other Content-Types:•Image/gif•Text/plain•Text/html•Audio/basic•Video/mpeg•…

65

Page 66: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

SMTP: delivery/storage to receiver’s server (PUSH) Mail access protocol: retrieval from server (PULL)

POP: Post Office Protocol [RFC 1939] authorization (agent <-->server) and download

IMAP: Internet Mail Access Protocol [RFC 1730] more features (more complex) manipulation of stored messages on server

HTTP: Hotmail , Yahoo! Mail, etc.

useragent

sender’s mail server

useragent

SMTP SMTP accessprotocol

receiver’s mail server

Sender Receiver

Mail Access Protocols

66

Page 67: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

authorization phase client commands:

user: declare username pass: password

server responses +OK -ERR

transaction phase, client: list: list message numbers retr: retrieve message by

number dele: delete quit

C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off

S: +OK POP3 server ready C: user USER1S: +OK C: pass zxcdvf S: +OK user successfully logged on

POP3 Protocol

67

Page 68: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

FTP

پروتکل انتقال فایل

68

Page 69: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

FTP uses the services of TCP. It needs two TCP connections. The well-known

port 21 is used for the control connection, and the well-known port 20 is used for the data connection.

NoteNote::

69

Page 70: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

FTP

control connection: “out of band”control connection: “out of band”

استفاده میکند TCP از دو اتصال FTPپروتکل استفاده میکند TCP از دو اتصال FTPپروتکل

70

Page 71: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

FTP client contacts FTP server at port 21, specifying TCP as transport protocol.

Client obtains authorization over control connection. Client browses remote directoryremote directory by sending commands

over control connection. When server receives a command for a file transfer,

server opens a TCP data conn. to client at port 20.

FTP clientFTP server

TCP control connectionport 21 )persistent(

TCP data connectionport

20)nonpersistent(

FTP: Separate Control, Data Connections

71

Page 72: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

File transfer

72

Page 73: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Control and data connections

73

Page 74: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

List of FTP commands in UNIX

Commands

!, $, account, append, ascii, bell, binary, bye, case, cd, cdup, close, cr, delete, debug, dir, discount, form, get, glob, hash, help, lcd, ls, macdef, mdelete, mdir, mget, mkdir, mls, mode, mput, nmap, ntrans, open, prompt, proxy, sendport, put, pwd, quit, quote, recv, remotehelp, rename, reset, rmdir, runique, send, status, struct, sunique, tenex, trace, type, user, verbose,?

74

Page 75: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Example 1

$ ftp ftp.uok.ac.irConnected to ftp.uok.ac.ir220 Server readyName: AbdollahpouriPassword: xxxxxxxftp > ls /usr/user/report200 OK150 Opening ASCII mode......................226 transfer completeftp > close221 Goodbyeftp > quit

75

Page 76: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Example 2

$ ftp internic.netConnected to internic.net220 Server readyName: anonymous331 Guest login OK, send "guest" as passwordPassword: guestftp > pwd257 '/' is current directoryftp > ls200 OK150 Opening ASCII modebin...ftp > close221 Goodbyeftp > quit

76

Page 77: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

Telnet(remote login)

دسترسی از راه دور

77

Page 78: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

78

این پروتکل کاربر را قادر میسازد که با استفاده از یک ترمینال، از هر مکانی و با استفاده از یک خط ارتباطی همانند

خط تلفن با یک سیستم راه دور ارتباط برقرار کرده و وارد سیستم شده، از آن

سرویس بگیرد.Telnet از پروتکلTCP استفاده میکند23 و پورت Telnet از پروتکلTCP استفاده میکند23 و پورت

Page 79: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

79

Page 80: Department of Computer and IT Engineering University of Kurdistan Computer Networks II Application Layer By: Dr. Alireza Abdollahpouri

80QuestionsQuestionsQuestionsQuestions