88
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

  • Upload
    valin

  • View
    47

  • Download
    0

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

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

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

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

Application Layer

2

Page 3: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

3

Page 4: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

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

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

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

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

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 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

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

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

Connectionless iterative server

UDP

12

Page 13: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Connection-oriented concurrent server

TCP

13

Page 14: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

Domain Name System(DNS)

15

Page 16: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

Hierarchical Distributed Name Space

Root Server

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

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

17

Page 18: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

18

DNS root Servers

Page 19: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

DNS root Servers

19

Page 20: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Domains

20

Page 21: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

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

Country domains

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

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

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

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

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

23

Page 24: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Recursive resolution

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

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

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

است

24

Page 25: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

Iterative resolution

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

26

Page 27: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Query and response messages

27

Page 28: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

HTTP and WWW

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

29

Page 30: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

World Wide Web

Distributed services

30

Page 31: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Hypertext

31

Page 32: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Browser architecture

Interpreter

32

Page 33: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Categories of Web documents

33

Page 34: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Static document

34

Page 35: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Dynamic document

35

Page 36: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Active document

36

Page 37: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

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

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

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

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

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

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

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

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

46

HTTP request and response format

Page 47: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

47

Status line

Request line

خط درخواست

خط وضعیت

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

Page 48: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

,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

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

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

Example 1

51

Page 52: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

Example 2

53

Page 54: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

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

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

SMTPand POP3

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

56

Page 57: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Electronic MailElectronic Mail

Sending/Receiving Mail

Addresses

User Agent

MIME

Mail Transfer Agent

Mail Access Protocols

Page 58: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Format of an email

Page 59: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Email address

Page 60: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

User agent

Page 61: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Some examples of command-driven user agents are mail, pine, and elm.

NoteNote::

Page 62: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Some examples of GUI-based user agents are Eudora, Outlook, and

Netscape.

NoteNote::

Page 63: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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.

Scenario: 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

Page 64: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

MIME

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

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

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

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

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

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

Page 65: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

MIME header

Page 66: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Data types and subtypes in MIMEData types and subtypes in MIME

Type Subtype Description

Text Plain Unformatted text

Multiport

Mixed Body contains ordered parts of different data types

Parallel Same as above, but no order

Digest Similar to mixed, but the default is message/RFC822

Alternative Parts are different versions of the same message

Message

RFC822 Body is an encapsulated message

Partial Body is a fragment of a bigger message

Ext. Body Body is a reference to another message

ImageJPEG Image is in JPEG

GIF Video is in GIF format

Video MPEG Video is in MPEG format

Audio Basic Single-channel encoding of voice at 8 KHz

ApplicationPostScript Adobe PostScript

Octet-Stream General binary data (8-bit bytes)

Page 67: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Content-transfer encodingContent-transfer encoding

Category Description

Type ASCII characters and short lines

7bit Non-ASCII characters and short lines

8bit Non-ASCII characters with unlimited-length lines

Binary 6-bit blocks of data are encoded into 8-bit ASCII characters

Base64Non-ASCII characters are encoded as an equal sign followed by an ASCII code

Page 68: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Base64

Page 69: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Base64 encoding tableBase64 encoding table

Value Code Value Code Value Code Value Code Value Code Value Code

0 A 11 L 22 W 33 h 44 s 55 3

1 B 12 M 23 X 34 i 45 t 56 4

2 C 13 N 24 Y 35 j 46 u 57 5

3 D 14 O 25 Z 36 k 47 v 58 6

4 E 15 P 26 a 37 l 48 w 59 7

5 F 16 Q 27 b 38 m 49 x 60 8

6 G 17 R 28 c 39 n 50 y 61 9

7 H 18 S 29 d 40 o 51 z 62 +

8 I 19 T 30 e 41 p 52 0 63 /

9 J 20 U 31 f 42 q 53 1

10 K 21 V 32 g 43 r 54 2

Page 70: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

MTA client and server

Page 71: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

Page 72: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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نامه =================== بدنه و سرآيند

==================DATA

354 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

Page 73: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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

Page 74: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

File Transfer File Transfer

Connections

Communication

File Transfer

User Interface

Anonymous

Page 75: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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::

Page 76: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

FTP

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

Page 77: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

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 Connections1

Page 78: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Using the control connection

Page 79: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Using the data connection

Page 80: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

File transfer

Page 81: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Example 1Example 1

Figure 26.16 (next slide) shows an example of how a file is stored.

1. The control connection is created, and several control commands and responses are exchanged.

2. Data are transferred record by record.

3. A few commands and responses are exchanged to close the connection.

Page 82: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Example 1

Page 83: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

List of FTP commands in UNIXList 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,?

Page 84: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Example 2Example 2

We show some of the user interface commands that accomplish the same task as in Example 1. The user input is shown in boldface. As shown below, some of the commands are provided automatically by the interface. The user receives a prompt and provides only the

arguments.$ ftp challenger.atc.fhda.eduConnected to challenger.atc.fhda.edu220 Server readyName: forouzanPassword: xxxxxxxftp > ls /usr/user/report200 OK150 Opening ASCII mode......................226 transfer completeftp > close221 Goodbyeftp > quit

Page 85: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Example 3Example 3

We show an example of using anonymous FTP. We connect to internic.net, where we assume there are some public data available.$ 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

Page 86: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

Remote Login:Remote Login:TelnetTelnet

Page 87: Department of Computer and IT Engineering University of Kurdistan Computer Networks II
Page 88: Department of Computer and IT Engineering University of Kurdistan Computer Networks II

88QuestionsQuestionsQuestionsQuestions