44
Ch 2. Application Layer Myungchul Kim [email protected]

Ch 2. Application Layer Myungchul Kim [email protected]

Embed Size (px)

Citation preview

Page 1: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

Ch 2. Application Layer

Myungchul Kim

[email protected]

Page 2: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

2

Principles of network applications

– Develping new applications -> writing software running on multiple end systems

Page 3: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

3

Network application architecture– Network architecture– Application architecture

Client-server architecture P2P architecture

Page 4: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

4

Client and server processes

The interface between the process and the computer network

– Application programming interface (API)

Page 5: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

5

Transport service available to applications

– Reliable data data transfer

– Throughput: bandwidth-sensitive applications and elastic applica

tions

– Timing

– Security

Page 6: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

6

Transport services provided by the Internet

– TCP services

Connection-oriented service: handshaking, connection establishmen

t, tearing down the connection

Reliable data transfer service

Congestion-control mechanism

– UDP services

Connectionless

No handshaking

An unreliable data transfer service

Page 7: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

7

Page 8: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

8

Today’s Internet can often provide satisfactory service to timesentive applica

tions, but it cannot provide any timing or bandwidth guarantees.

Addressing processes: host by IP address + process by port number

Page 9: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

9

Application-layer protocols

– The types of messages exchanged

– The syntax of the various message types

– The semantics of the fields

– Rules for examining when and how a process a sends messages and re

sponds to messages

– e.g., HTTP – Web’s application-layer protocol

Page 10: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

10

The Web and HTTP

Overview of HTTP– HyperText Transfer Protocol– Web page = a set of objects: an object = a file– Web browser = the client of HTTP– Web server = the server of HTTP– A stateless protocol

Non-persistent and persistent connections– HTTP with non-persistent connections

Each TCP connection is closed after the server sends the object. (next slide)

– HTTP with persistent connections The server leaves the TCP connection open after sending a respons

e.

Page 11: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

11

Nonpersistent HTTP

Suppose user enters URL www.someSchool.edu/someDepartment/home.index

1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 80

2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index

1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. “accepts” connection, notifying client

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

time

(contains text, references to 10

jpeg images)

Page 12: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

12

Nonpersistent HTTP (cont.)

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

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

4. HTTP server closes TCP connection.

time

Page 13: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

13

Page 14: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

14

HTTP message format– Request messages and response messages– HTTP request message

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST,

HEAD commands)

Carriage return, line feed

indicates end of message

Page 15: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

15

Page 16: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

16

HTTP response message

HTTP/1.1 200 OK Connection closeDate: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...

status line(protocol

status codestatus phrase)

header lines

data, e.g., requestedHTML file

Page 17: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

17

– HTTP response message:

Page 18: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

18

User-server interaction: Cookies– Identify users– One-click shopping; shopping cart service

Page 19: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

19

Web caching– Web cache = proxy server– A cache is both a server and a client at the same time.

Page 20: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

20

Page 21: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

21

Conditional GET

Goal: don’t send object if cache has up-to-date cached version

cache: specify date of cached copy in HTTP requestIf-modified-since: <date>

server: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not Modified

cache server

HTTP request msgIf-modified-since:

<date>

HTTP responseHTTP/1.0

304 Not Modified

object not

modified

HTTP request msgIf-modified-since:

<date>

HTTP responseHTTP/1.0 200 OK

<data>

object modified

Page 22: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

22

FTP

– Out-of-band, stateful protocol

Page 23: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

23

Electronic Mail

Simple Mail Transfer Protocol (SMTP)

Page 24: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

24

– The body of SMTP: 7-bit ASCII– Use persistent connections– Push protocol (cf. pull protocol e.g. HTTP)

Page 25: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

25

1) Alice uses UA to compose message and “to” [email protected]

2) Alice’s UA sends message to her mail server; message placed in message queue

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

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

5) Bob’s mail server places the message in Bob’s mailbox

6) Bob invokes his user agent to read message

Page 26: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

26

Mail Message Formats and MIME– Multipurpose Internet Mail Extensions (MIME)

Content-Type Content-Transfer-Encoding

Mail Access Protocols

– Post Office Protocol - Verson 3 (POP3), Internet Mail Acess Protocol (IMAP), and HTTP

Page 27: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

27

DNS – The Internet’s Directory Service

– Domain name system– Identifer: hostname, IP address– Translate hostnames to IP addresses– Host aliasing: canonical hostname– Mail server aliasing– Load distribution: DNS rotation– A centralized design

A single point of failure Traffic volume Distant centralized database Maintenance

Page 28: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

28

A distributed, hierachical database– Root DNS servers– Top-level domain (TLD) servers– Authoritative DNS servers

Page 29: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

29

Page 30: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

30

Page 31: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

31

Page 32: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

32

– DNS caching: cache the mapping in its local memory

DNS records and messages– Resource records (RRs)– RR: (Name, Value, Type, TTL)– Type = A: hostanme and its IP address– Type = NS: domain and hostname of an authoritative DNS server– Type = CNAME: cananical hostname– Type = MX: canaonical name of a mail server

Page 33: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

33

Page 34: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

34

Inserting records into the DNS database– Registrar– Internet Corporation for Assigned Names and Numbers (ICANN)

Page 35: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

35

Peer-to-Peer Applications

– Peers vs service providers– File distribution, organizing and searching for information and Int

ernet telephony application

P2P file distribution– Scalability of P2P architectures

Page 36: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

36

BitTorrent– File distribution– Torrent: the collection of all peers participating in the distribution of a par

ticular file– Chungs of a file (256KBytes)– Each torrent has an infrasturecture node called a tracker– Rarest first: from neighbors– Trading algorithm: gives priority to the neighbors that are currently suppl

ying data at the highest rate– Four top peers and one probing peer– Free-riding

Page 37: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

37

Page 38: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

38

Searching for information in a P2P community– Information index – a mapping of information to host locations– File sharing: files to peers– Instant message: username to locations (IP addresses)– Centralized index

Napster A hybird of P2P and client-server architecture Copyright infringement

Page 39: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

39

– Query flooding Gnutella The index is fully distributed over the community peers Overlay network Limited-scope query flooding New peers join: bootstrap problem

Page 40: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

40

Gnutella: Peer joining

1. joining peer Alice must find another peer in Gnutella network: use list of candidate peers

2. Alice sequentially attempts TCP connections with candidate peers until connection setup with Bob

3. Flooding: Alice sends Ping message to Bob; Bob forwards Ping message to his overlay neighbors (who then forward to their neighbors….)

peers receiving Ping message respond to Alice with Pong message

4. Alice receives many Pong messages, and can then setup additional TCP connections

Page 41: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

41

– Hierarchical overlay FastTrack, Kazaa and Morpheus Limited-scope flooding in the overlay network of super peers

Page 42: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

42

Case study: P2P Internet Telephony with Skype– Real time– P2P for user location and for NAT traversal

Page 43: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

43

P2P Case study: Skype

P2P (pc-to-pc, pc-to-phone, phone-to-pc) Voice-Over-IP (VoIP) application

– also IM proprietary application-layer

protocol (inferred via reverse engineering)

hierarchical overlay

Skype clients (SC)

Supernode (SN)

Skype login server

Page 44: Ch 2. Application Layer Myungchul Kim mckim@icu.ac.kr

44

Skype: making a call

User starts Skype

Skype login server

SC registers with SN– list of bootstrap SNs

SC logs in (authenticate)

Call: SC contacts SN will callee ID– SN contacts other SNs (unknown protocol, maybe flooding) to find addr of callee; returns addr to

SC

SC directly contacts callee, overTCP