42
1 Chapter 2: Application Layer Our goals: Conceptual aspects of network learn about protocols by examining some application-level application protocols transport-layer service models client-server paradigm peer-to-peer protocols HTTP SMTP DNS P2P Content distribution t k (CDN ) Application Layer (SSL) 1 peer to peer paradigm networks (CDNs) programming network applications sockets API 10/3/2017 Chapter 2: outline 2.1 principles of network 2.5 P2P applications 26 id t i network applications 2.2 Web and HTTP 2.3 electronic mail SMTP 24 DN 2.6 video streaming and content distribution networks (CDNs) 2.7 socket programming with Application Layer 2-2 2.4 DNS programming with UDP and TCP

Chapter 2: Application Layer - University of Texas at … 2: Application Layer Our goals: ... respond to messages gyp 10/3/2017 What transport service does an app need? Data loss

  • Upload
    dohanh

  • View
    216

  • Download
    2

Embed Size (px)

Citation preview

1

Chapter 2: Application LayerOur goals: Conceptual aspects

of network

learn about protocols by examining some application-level

application protocols transport-layer

service models client-server

paradigm peer-to-peer

ppprotocols HTTP SMTP DNS P2P Content distribution

t k (CDN )

Application Layer (SSL) 1

peer to peer paradigm

networks (CDNs) programming network

applications sockets API

10/3/2017

Chapter 2: outline

2.1 principles of network

2.5 P2P applications2 6 id t inetwork

applications2.2 Web and HTTP2.3 electronic mail

• SMTP2 4 DN

2.6 video streaming and content distribution networks (CDNs)

2.7 socket programming with

Application Layer 2-2

2.4 DNS programming with UDP and TCP

2

Creating a network appWrite programs that

run on (different) end systems

i t t k

applicationtransportnetworkdata linkphysical

communicate over network e.g., web server software

communicates with browser software

No need to write software for network-core devices This approach allows for

applicationtransport

applicationtransportnetworkdata linkphysical

Application Layer (SSL) 3

This approach allows for rapid app development

pnetworkdata linkphysical

10/3/2017

Application architectures Client-server

to scale –> racks of servers in a datacenter> racks of servers in a datacenter

to improve throughput and response time -> geographically distributed clusters of servers in CDNs

Peer-to-peer (P2P)

Application Layer (SSL) 4

p ( ) difficult to manage

-> super nodes (with some server characteristics) needed in addition to regular peers

10/3/2017

3

Client-server architectureserver:

always-on host permanent IP address data centers for

scalingclients:

communicate with server (speak first)

may be intermittently client/server

Application Layer (SSL) 5

connected may have dynamic IP

addresses do not communicate

directly with each other10/3/2017

Pure P2P architecture no always-on server arbitrary end systems

directly communicate peers are intermittently peers are intermittently

connected and may change IP addresses

difficult to manage find content or another

peer by broadcast (flooding)

peer-peer

Application Layer (SSL) 6

(flooding) NAT traversal problem

10/3/2017

Example: BitTorrent has trackers (super nodes that manage the peers and chunks of a torrent)

4

Processes communicatingProcess: program running

within a host. within same host, two

Client process: process that initiates communication

processes communicate using inter-process communication (defined by OS).

processes in different

Server process: process that waits to be contacted

Note: client & server processes run in P2P as

Application Layer (SSL) 7

pr c n ff r nthosts communicate by exchanging messages

well as client-server apps

10/3/2017

Note: A process in these slides may be a thread instead

Addressing processes to receive messages,

process must have an identifier

host device has unique

identifier includes both IP address and port number associated with process on host host device has unique

32-bit IP address Q: Is IP address of

host on which process runs enough for identifying the process?

process on host. Example port numbers:

HTTP server: 80 Mail server: 25

to send HTTP message to gaia.cs.umass.edu web server:

Application Layer (SSL) 8

process? A: No, many

processes can be running on same host

server: IP address: 128.119.245.12 Port number: 80

more shortly…

10/3/2017

5

App-layer protocol specs Types of messages

exchanged, e.g., request, response

Public-domain protocols: defined in RFCs whiche.g., request, response

Message syntax: what fields in messages &

how fields are delineated Message semantics

meaning of information in fields

defined in RFCs which enable interoperabilitye.g., HTTP, SMTP

Proprietary protocols: e.g., Skype

Application Layer (SSL) 9

Rules for when and how processes send & respond to messages

g yp

10/3/2017

What transport service does an app need?

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

tolerate some lossth ( fil

Throughput some apps (e.g., audio,

video) require minimum t f th h t t other apps (e.g., file

transfer, telnet, email) require 100% reliable data transfer

Timing some apps (e.g.,

I t t t l h

amount of throughput to be “effective”

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

Security

Application Layer (SSL) 10

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

Encryption, data integrity, … (in app layer, e.g. SSL/TLS)

10/3/2017

6

Transport service requirements of common apps

Application Data loss Throughput Time Sensitive

file transfere-mail

Web documentsinteractive audio/video

streaming stored audio/video

no lossno lossno lossloss-tolerant

loss-tolerant

elasticelasticelastic (few kbps)audio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above

nononoyes, 100’s of ms

yes, few secs

100’ f

Application Layer (SSL) 11

interactive gamesinstant messaging

loss-tolerantno loss

few kbps upelastic

yes, 100’s of msyes and no

10/3/2017

Internet transport protocols servicesTCP service: connection-oriented: setup

required between client and server processes; state info

li bl

UDP service: unreliable data

transfer between sending and receiving

reliable transport: between sending and receiving process

flow control: sender won’t overwhelm receiver

congestion control:throttle sender when network is overloaded

processes does not provide:

connection setup, reliability, flow control, congestion control, timing, throughput guarantee, or security

Application Layer (SSL) 12

is overloaded does not provide: timing,

minimum throughput guarantee, security

Q: why bother? Why is there a UDP?

10/3/2017

7

Internet apps: application & transport protocols

ApplicationApplicationlayer protocol

Underlyingtransport protocol

e-mailremote terminal access

Web file transfer

streaming multimedia

Internet telephony

SMTP [RFC 5321]

Telnet [RFC 854]

HTTP [RFC 2616]

FTP [RFC 959]

HTTP (e. g., Youtube)

SIP[RFC 3261],RTP[RFC 3550], proprietar (e g Sk pe)

TCPTCPTCPTCPTCP

Application Layer (SSL) 13

proprietary(e.g., Skype) UDP or TCP

10/3/2017

Chapter 2: outline

2.1 principles of network

2.5 P2P applications2 6 id t inetwork

applications2.2 Web and HTTP2.3 electronic mail

• SMTP2 4 DN

2.6 video streaming and content distribution networks (CDNs)

2.7 socket programming with

Application Layer 2-14

2.4 DNS programming with UDP and TCP

8

Web and HTTPFirst some jargon Web page consists of base HTML-file which

includes several referenced objectsj

Object can be HTML file, JPEG image, Java applet, audio file,…

Each object is addressable by a URL, for example

Application Layer (SSL) 15

www.someschool.edu/someDept/pic.gif

host name path name

10/3/2017

HTTP overviewHTTP: hypertext

transfer protocol Web’s application layer pp y

protocol client/server model

client: browser that requests, receives, displays Web objects

server: Web server sends objects in

PC runningExplorer

Server running

Apache Web

Application Layer (SSL) 16

jresponse to requests

p Wserver

Mac runningChrome

10/3/2017

9

HTTP overview (continued)

Uses TCP: client initiates TCP

HTTP is “stateless” server maintains no client initiates TCP

connection (creates socket) to server, port 80

server accepts TCP connection from client

HTTP messages exchanged between browser (HTTP client) and Web server

minformation about past client requests

Protocols that maintain “state” are complex

past history (state) must be maintained

aside

Application Layer (SSL) 17

cl ent) and Web server(HTTP server)

TCP connection closed

be maintained if server/client crashes,

their views of “state” may be inconsistent, must be reconciled

10/3/2017

Nonpersistent HTTPSuppose user enters URL

www.someSchool.edu/someDepartment/home.index

1a HTTP client initiates TCP

(contains text, references to 10

jpeg images)

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

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

3 HTTP server receives request

Application Layer (SSL) 18

URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index

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

time10/3/2017

10

Nonpersistent HTTP (cont.)

5 HTTP client receives response

4. HTTP server closes TCP connection.

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

time

Application Layer (SSL) 1910/3/2017

Non-Persistent HTTP: Response timeDefinition of RTT: time for

a small packet to travel from client to server and backand back.

Response time: one RTT to initiate TCP

connection one RTT for HTTP

request and first few time to transmit file

initiate TCPconnection

RTTrequestfile

RTT

fil

Application Layer (SSL) 20

bytes of HTTP response to return

file response time total

filereceived

time time

10/3/2017

= 2RTT+ file transmission time

11

Nonpersistent vs. Persistent HTTPNonpersistent HTTP delay requires 2 additional RTTs

for an object

Persistent HTTP delay server leaves connection

open after sending responseb t HTTP

most browsers open parallel TCP connections to fetch referenced objects very little additional time

for all reference objects but OS overhead to

allocate host resources for

subsequent HTTP messages between client/server are sent over same connection

client sends a new request as soon as it encounters a referenced object (pipelining)

s littl s n dditi n l

Application Layer (SSL) 21

allocate host resources for all TCP connections

as little as one additional RTT for all referenced objects (plus their transmission time)

10/3/2017

HTTP historyNonpersistent HTTP At most one object is

sent over a TCP

Persistent HTTP Version 1.1 (since 1999)

multiple objects can be connection Version 0.9 (in 1991)

• only one method (GET) • only one object type

(HTML)

sent over single TCP connection between client and server.

pipelining of requests Version 2 (since 2015)

allows server push

Application Layer (SSL) 22

Version 1.0 (in 1996) allows server push multiplexing requests

over a single TCP connection – without HOL blocking

10/3/2017

12

HTTP request message

two types of HTTP messages: request, response HTTP request message: HTTP request message:

ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1\r\nHost: www.someschool.edu\r\n User-agent: Mozilla/5.0\r\nConnection: close\r\n

request line(GET, POST,

HEAD commands)

header

Application Layer (SSL) 23

Connection: close\r\n Accept-language:fr\r\n\r\n

linesCarriage return, line feed indicate

end of header lines

10/3/2017

HTTP request message: general format

Application Layer (SSL) 2410/3/2017

13

Uploading form input

Post method: Web page often GET method: Web page often

includes form input Input is uploaded to

server in entity body

GET method: Uses GET method Entity body is empty Input is uploaded in

URL field of request line:

Application Layer (SSL) 25

www.somesite.com/animalsearch?monkeys&banana

10/3/2017

Method types

HTTP/1.0 GET

HTTP/1.1 GET POST HEAD GET

POST HEAD

asks server to leave requested object out of response

GET, POST, HEAD PUT

uploads file in entity body to path specified in URL field

DELETE deletes file specified in

Application Layer (SSL) 26

deletes file specified in the URL field

… (others)

10/3/2017

14

HTTP response message

HTTP/1.1 200 OK\r\n

status line(protocol

status codeConnection close\r\nDate: Tue, 09 Aug 2011 12:00:15 GMT\r\n Server: Apache/2.2.3 (CentOS)\r\n Last-Modified: Tue, 09 Aug 2011...\r\n Content-Length: 6821\r\n Content-Type: text/html\r\n\r\n data data data data data

status codestatus phrase)

headerlines

data e g

Application Layer (SSL) 27

data data data data data ... data, e.g., requestedHTML file

10/3/2017

Aside: several other methods to indicate length of a response

Cookies: keeping state info

client serverusual http request msg Amazon serverCookie file p q gusual http response +Set-cookie: 1678

usual http request msgcookie: 1678

usual http response msg

cookie-specificaction

Amazon servercreates ID

1678 for user

Cookie file

amazon: 1678ebay: 8734

ebay: 8734

k l

Application Layer (SSL) 28

usual http request msgcookie: 1678

usual http response msg

cookie-spectific

action

Cookie fileamazon: 1678ebay: 8734

one week later:

10/3/2017

15

Cookies Application end points keep state at client

and server across multiple transactions http messages carry state info but http

What cookies can bring: authorization shopping carts recommendations

Cookies and privacy: cookies permit sites

(including third parties) to learn a lot

http messages carry state info but http protocol is stateless

Application Layer (SSL) 29

recommendations user session state

(Web e-mail)

p )about you

10/3/2017

Web cache (proxy server)

user sets browser: web accesses via cache

Goal: satisfy client request without involving origin servers

origin cache browser sends all

HTTP requests to cache if object is not in

cache, request object from origin server

client

Proxyserver

gserver

Application Layer (SSL) 30

from origin server, then return object to client

else cache returns object

clientorigin server

10/3/2017

16

More about Web caching

cache acts as both client and server

Why Web caching? reduce response timeclient and server

typically cache is installed by ISP (university, company, residential ISP)

reduce response time for client request

reduce traffic on an institution’s access link.

Application Layer (SSL) 3110/3/2017

Caching example Assumptions average object size = 1 Mbits avg. request rate from institution’s

browsers to origin servers = 15/sec

originservers

publicInternet

browsers to origin servers = 15/sec Internet delay (ISP router to any

origin server and back) = 2 secConsequences utilization on LAN = 15% utilization on access link = 100% total delay = Internet delay + access

institutionalnetwork 100 Mbps LAN

15 Mbps access link

Application Layer (SSL) 32

link delay + LAN delay= 2 seconds + minutes + 0.01 second

many lost packets in reponses

institutionalcache

10/3/2017Assumption: request is very short and takes no time to transmit

17

Caching example (2)possible solution increase bandwidth of access

link to say 100 Mbps

originservers

publiclink to, say, 100 Mbps

consequence utilization on LAN = 15% utilization on access link = 15% Total delay = Internet delay +

access link delay + LAN delay

pInternet

institutionalnetwork 100 Mbps LAN

100 Mbps access link

Application Layer (SSL) 33

= 2 + 0.01 + 0.01 seconds

often a costly upgrade

100 Mbps LAN

institutionalcache

10/3/2017

Caching example (3)possible solution: install cache suppose hit rate is 0.4

s

originservers

publicconsequence 40% requests will be satisfied

almost immediately 60% requests satisfied by

origin servers utilization of access link

reduced to 60%, resulting in negligible delay (say 70 ms)

ave total delay = Internet

pInternet

institutionalnetwork 100 Mbps LAN

15 Mbps access link

Application Layer (SSL) 34

ave. total delay = Internet delay + access link delay + LAN delay= 0.6*(2 + 0.07 + 0.01) +

0.4* (0 + 0 + 0.01) seconds= 1.25 sec

100 Mbps LAN

institutionalcache

10/3/2017

18

Conditional GET Goal: don’t send object if

cache has up-to-date cached version

cache: indicates date of

cache serverHTTP request msg cache: indicates date of

cached copy in HTTP request to serverIf-modified-since:

<date>

server: response contains no object if cached copy is up-to-date:

q gIf-modified-since:

<date>

HTTP responseHTTP/1.1

304 Not Modified

object not

modified

HTTP request msg

Application Layer (SSL) 35

HTTP/1.1 304 Not Modified

HTTP request msgIf-modified-since:

<date>

HTTP responseHTTP/1.1 200 OK

<data>

object modified

10/3/2017

Chapter 2: outline

2.1 principles of network

2.5 P2P applications2 6 id t inetwork

applications2.2 Web and HTTP2.3 electronic mail

• SMTP2 4 DN

2.6 video streaming and content distribution networks (CDNs)

2.7 socket programming with

Application Layer 2-36

2.4 DNS programming with UDP and TCP

19

Electronic MailMajor components: user agents mail servers simple mail transfer protocol:

P

user mailbox

outgoing message queue

mail

useragent

SMTP

User Agent a.k.a. “mail reader” composing, editing, reading mail

messagese.g., Outlook, alpine, Mozilla

mailserver

useragent

useragent

usermail

mailserver

SMTP

SMTP

SMTP

Application Layer (SSL) 37

Thunderbird, iPhone mail client agentmail

server

useragent

useragent

10/3/2017

Electronic Mail: mail serversMail Servers mailbox contains incoming

messages for user ss f t i il

useragent

message queue of outgoing (to be sent) mail messages

SMTP protocolbetween mail servers to send email messages “client”: sender

mailserver

useragent

useragent

usermail

mailserver

SMTP

SMTP

SMTP

Application Layer (SSL) 38

client : sender “server”: receiver

u ragent

mailserver

useragent

useragent

10/3/2017

Looks like it is the very first (hybrid) P2P system!

20

Mail access protocols

useragentuser

agent

SMTP SMTP Mail accessprotocol

SMTP: for delivery to receiver’s server Mail access protocol: for retrieval from server

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

sender’s mail server

g

receiver’s mail server

Application Layer (SSL) 39

authorization (agent < >server) and download IMAP: Internet Mail Access Protocol [RFC 3501]

• more features (keeps user state across sessions)• manipulation of stored msgs in folders on server

Web email: use HTTP for both send and receive10/3/2017

Electronic Mail: SMTP uses TCP to reliably transfer email message from

client to server, port 25 direct transfer: sending server to receiving serverg g three phases of transfer

handshaking (greeting) transfer of messages (persistent connection) closure

command/response interaction

Application Layer (SSL) 40

commands: ASCII text response: status code and phrase

messages must be in 7-bit ASCII

10/3/2017

21

Sample smtp interaction(after TCP connection established)S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: <[email protected]> S: 250 [email protected]... Sender ok C: RCPT TO: <[email protected]> S: 250 [email protected] ... Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: Do you like ketchup? C: How about pickles?

Application Layer (SSL) 41

C: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 hamburger.edu closing connection

10/3/2017

Try SMTP interaction for yourself:

telnet servername 25

see 220 reply from server see 220 reply from server enter HELO, MAIL FROM, RCPT TO, DATA, QUIT

commandsabove lets you send email without using email client

(reader)

Application Layer (SSL) 4210/3/2017

Log on a UTCS linux machine. Then dotelnet mailbox2.cs.utexas.edu 25 (opens TCP conn.)

22

Mail message formatSMTP (rfc 5321): protocol for

exchanging email msgsrfc 5322: standard for text

m ss f m t:header

blankmessage format:

header lines, e.g., To: From: Subject:different from SMTP

body

blankline

Application Layer (SSL) 43

different from SMTP commands and responses

body the “message”, ASCII

characters only

10/3/2017

Message format: multimedia extensions

Multipurpose Internet Mail Extensions (MIME) additional lines in msg header declare media

content types (also multipart content types)content types (also multipart content types)

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg multimedia data

method usedto encode data

MIME version

Application Layer (SSL) 44

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

multimedia datatype, subtype,

parameter declaration

encoded data

10/3/2017

23

Chapter 2: outline

2.1 principles of network

2.5 P2P applications2 6 id t inetwork

applications2.2 Web and HTTP2.3 electronic mail

• SMTP2 4 DN

2.6 video streaming and content distribution networks (CDNs)

2.7 socket programming with

Application Layer 2-45

2.4 DNS programming with UDP and TCP

DNS: Domain Name SystemPeople: many identifiers:

SSN, name, passport #Internet hosts routers:

Domain Name System: distributed database

implemented as a hierarchyInternet hosts, routers: IP address (32 bit)

- used for addressing datagrams

“name”, e.g., www.yahoo.com - used by humans

implemented as a hierarchy of many name servers

application-layer protocolused to resolve names (address/name translation) note: core Internet function,

implemented as application-

Application Layer (SSL) 46

Required: map between name and IP addresses

implemented as application-layer protocol

complexity at network’s “edge”

10/3/2017

24

DNS Why not centralized DNS? single point of failure traffic volume

DNS services Hostname to IP

address translation traffic volume distant centralized

database maintenance/update

doesn’t scale!

address translat on Host alias

Canonical and alias names

Mail server alias Load distribution

Application Layer (SSL) 47

Replicated Web server: a set of IP addresses for one canonical host name

10/3/2017

Root DNS Servers

DNS org DNS servers edu DNS servers

Distributed, Hierarchical Database

Top-level domains

.com DNS servers .org DNS servers .edu DNS servers

poly.eduDNS servers

umass.eduDNS serversyahoo.com

DNS serversamazon.comDNS servers

pbs.orgDNS servers

Client wants IP address for www.amazon.com: 1st approx: Client queries a root server to find .com DNS server

Application Layer (SSL) 48

Client queries .com DNS server to get amazon.com DNS server

Client queries amazon.com DNS server to get IP address for www.amazon.com

10/3/2017

25

DNS: root name servers 13 root name “servers”worldwide

k. RIPE London (17 other

c. Cogent, Herndon, VA (5 other sites)d. U Maryland College Park, MDh ARL Aberdeen MD

a. Verisign, Los Angeles (5 other sites)

b. USC-ISI Marina del Rey, CAl. ICANN Los Angeles, CA

e. NASA Mt View, CAf. Internet Software C.Palo Alto, CA (and 48 other sites)

i. Netnod, Stockholm (37 other sites)

sites)

m. WIDE Tokyo(5 other sites)

h. ARL Aberdeen, MDj. Verisign, Dulles VA (69 other sites )

Application Layer (SSL) 49

l. ICANN Los Angeles, CA(41 other sites)

10/3/2017

g. US DoD Columbus, OH (5 other sites)

TLD and Authoritative Servers Top-level domain (TLD) servers: responsible

for .com, .org, .net, .edu, …, and all top-level country domains .uk, .fr, .ca, .jp Verisign maintains servers for .com TLD Educause for .edu TLD

Authoritative DNS servers: organization’s DNS servers, providing authoritative hostname-to-IP mappings for organization’s named hosts (e.g., Web and mail).

Application Layer (SSL) 50

named hosts (e.g., Web and mail). Can be locally maintained by organization or a

service provider

10/3/2017

26

Local Name Server

does not strictly belong to hierarchy h ISP ( id ti l ISP each ISP (residential ISP, company,

university) has one. also called “default name server”

when host makes DNS query, query is sent to its local DNS server

hi h t f d i t

Application Layer (SSL) 51

which acts as proxy, forwards query into hierarchy

10/3/2017

root DNS server

23

4TLD DNS server

DNS name resolution example Host at cis.poly.edu

wants IP address for d

local DNS serverdns.poly.edu

1

4

5

6

authoritative DNS server

78

gaia.cs.umass.edu It sends a recursive

query to local DNS server

iterated query: contacted server

Application Layer (SSL) 52

requesting hostcis.poly.edu

gaia.cs.umass.edu

authoritative DNS serverdns.cs.umass.edureplies with name of

server to contact“I don’t know this name, but ask this other server”

10/3/2017

27

DNS: caching when (any) name server learns mapping, it caches

mapping cached entries timeout (disappear) after pp

some time (e.g., 2 days) TLD servers typically cached in local name

servers -Thus root name servers not often visited

cached entries may be out-of-date (best effort service)

Application Layer (SSL) 53

service) if host changed IP address, this may not be

known Internet-wide until all TTLs expire

10/3/2017

DNS recordsDNS: distributed db storing resource records (RR)

RR format: (name, value, type, ttl)

Type=NS name is domain (e.g.

Type=A name is hostname value is IP address

Type=CNAME name is alias name for some

“canonical” (the real) namee.g., www.ibm.com is reallyservereast.backup2.ibm.com

value is canonical name

Application Layer (SSL) 54

foo.com) value is hostname of

authoritative name server for this domain

Type=MX value is host name of mail

server associated with name

10/3/2017

28

DNS protocol messagesDNS protocol : query and reply messages, both with

same message format

ms headermsg header identification: 16 bit #

for query, reply to query uses same #

flags: query or reply recursion desired

Application Layer (SSL) 55

recursion available reply is authoritative

10/3/2017

DNS protocol messages (cont.)

Name, type fieldsffor a query

RRs in responseto query

records forauthoritative servers

Application Layer (SSL) 56

additional “helpful”info that may be used

10/3/2017

29

Inserting records into DNS Example: just created startup “Network Utopia” Register name networkutopia.com at a registrar (e.g.,

Network Solutions) Need to provide registrar with names and IP addresses of Need to provide registrar with names and IP addresses of

your authoritative name servers (primary and secondary)

Registrar inserts NS and A resource records for each authoritative server into .com TLD servers:(networkutopia.com, dns1.networkutopia.com, NS)(dns1.networkutopia.com, 212.212.212.1, A)

Put into authoritative servers CNAME record for

Application Layer (SSL) 57

Put into authoritative servers, CNAME record for www.networkutopia.com, MX record for networkutopia.com, and …

How do people get the IP address of your Web site?10/3/2017

Chapter 2: outline

2.1 principles of network

2.5 P2P applications2 6 id t inetwork

applications2.2 Web and HTTP2.3 electronic mail

• SMTP2 4 DN

2.6 video streaming and content distribution networks (CDNs)

2.7 socket programming with

Application Layer 2-58

2.4 DNS programming with UDP and TCP

30

P2P architecture no always-on server arbitrary end systems

directly communicatedirectly communicate peers are intermittently

connected and change IP addresses

Hybrid deployment examples: File distribution e

peer-peer

Application Layer (SSL) 59

File distribution, e.g., BitTorrent (has trackers)

Internet telephony, e.g., original Skype (had super peers),

10/3/2017

File Distribution: Client-Server vs P2PQuestion : How much time to distribute a file

from one server to N peers?u server upload

us

u2d1 d2u1

Server

File, size F

us server upload capacity (bps)ui peer i upload capacity (bps)di peer i download capacity (bps)

Application Layer (SSL) 60

uN

dN Network (with abundant bandwidth)

10/3/2017

31

Time to distribute file to N users : Client-Server

uu2d1 d2

u1

Server

F

server sequentially sends N copies: NF/us time us

d2

uN

dNNetwork (with abundant bandwidth)

s

client i takes F/di time to download

Time to distribute F

Application Layer (SSL) 6161

When N is large, min(di) > us/N

Tcs ≥ max { NF/us , F/min(di) }i

to N clients is(lower bound)

10/3/2017i

Time to distribute file to N users: P2P

uu2d1 d2

u1

Server

F

server must send one copy: F/us time

client i takes F/d time to usd2

uN

dNNetwork (with abundant bandwidth)

client i takes F/di time to download

NF bits must be uploaded (aggregate)

fastest possible upload rate: us + Σ1≤i≤N-1 ui

Application Layer (SSL) 6262

TP2P ≥ max { F/us , F/min(di) , NF/(us + Σui) }i

10/3/2017

us > (us + Σui)/N and, for large N, min(di) > (us + Σui)/Ni

Largest value as N ↑

32

3

3.5

me P2P

Client-Server

Client-server vs. P2P: exampleClient upload rate = u for all i, F/u = 1 min., us = 10u, dmin ≥ u

0 5

1

1.5

2

2.5M

inim

um D

istri

butio

n Ti

m

/ / (10 )/10 min.

sNF u NF uN

==

1

1

as

/ ( ) 1 min.N

s ii

N

NF u u = F / u−

=

→ ∞

+ =

2 servers

Application Layer (SSL) 63

0

0.5

0 5 10 15 20 25 30 35

M

N

10/3/2017

What if more than 1 server? I.e., a data center

Chapter 2: outline

2.1 principles of network

2.5 P2P applications2 6 id t inetwork

applications2.2 Web and HTTP2.3 electronic mail

• SMTP2 4 DN

2.6 video streaming and content distribution networks (CDNs)

2.7 socket programming with

Application Layer 2-64

2.4 DNS programming with UDP and TCP

33

Sockets process sends/receives

messages to/from its socket

socket analogous to “door”

host orserver

host orserver

socket analogous to door sending process shoves

message out of door it relies on transport

infrastructure on other side of door which d li s m ss t

process

TCP withbuffers,variables

socket

process

TCP withbuffers,variables

socket

Internet

controlled byapp developer

Application Layer (SSL) 65

delivers message to socket at receiving process

controlledby OS

10/3/2017

Socket programmingGoal: learn how to write client and server programs

which communicate by sending data into sockets, reading data out of sockets

Socket API introduced in BSD4.1 UNIX, 1981 sockets are explicitly created, used, then

released by applications client/server paradigm API: choice of a transport protocol and ability

Application Layer (SSL) 66

API: choice of a transport protocol and ability to specify a few parameters reliable byte stream unreliable datagram

10/3/2017

34

Socket programming with TCPBefore client contact: server process must first

be running server must have created

When contacted by client, server TCP creates a new connection socket for server process to communicate with li server must have created

socket (door) that welcomes client’s contact

Client contacts server by: creating client-local TCP

socket specifying IP address, port

b f

client allows server to talk with

multiple clients source IP address and port

number used to distinguish clients (more in Chap 3)

application viewpoint

Application Layer (SSL) 67

number of server process When client makes connect

call: client TCP establishes connection to server TCP

TCP provides reliable, in-ordertransfer of byte stream

between client and server

application viewpoint

10/3/2017

Socket API for TCP (BSD Unix) Client side

socket(), returns client socket id

connect() need to

Server side socket(), returns server

socket id bind(), binds server socket

connect(), need to specify server IP address and port, sends conn req

send(), sends to client socket

recv(), receives from client socket

to server IP address and port

listen(), willing to accept conn req on server socket

accept(), accepts new conn req and returns its connection socket id

Application Layer (SSL) 68

client socket close(), closes

connection

note: OS supplies local IP address and port for client

recv(), receives from connection socket

send(), sends to connection socket

close(), closes connection10/3/2017

35

Client/server socket interaction: TCP

create socket: port=xserverSocket = socket()serverSocket.bind()serverSocket listen()

server (running on hostid) client

wait for incoming connection requestconnectionSocket =serverSocket.accept()

serverSocket.listen()create socket:

connect to hostid, port=xclientSocket = socket()

send request usingclientSocketrecv request from

ti S k t

TCP connection setup

Application Layer

connectionSocket

send reply toconnectionSocket

closeconnectionSocket

recv reply fromclientSocket

closeclientSocket

10/3/2017

69Note: syntax is neither complete nor precise

Socket programming with UDPUDP: no “connection”

between client and server no handshaking

application viewpoint

UDP provides unreliable transferof groups of bytes (“datagrams”)

sender explicitly attaches IP address and port of destination to every packet

server must extract IP address, port of sender from every received packet

UDP: transmitted data may

g p y gbetween client and server

Application Layer (SSL) 70

UDP: transmitted data may be received out of order, or lost

10/3/2017

36

Socket API for UDP (BSD Unix) Client side

socket(), returns client socket id

sendto() sends to client

Server side socket(), returns server

socket id bind() binds server sendto(), sends to client

socket, need to specify destination’s IP address and port

recvfrom(), receives from client socket: data and sender’s IP address and port

bind(), binds server socket to server IP address and port

recvfrom(), receives from server socket: data and sender’s IP address and port

sendto(), sends to

Application Layer (SSL) 71

bind(), optional note: needs timeout

management;OS supplies local IP address and port for client if bind() not used

sendto(), sends to server socket, need to specify destination’s IP address and port

10/3/2017

Client/server socket interaction: UDP

create socket:clientSocket =socket(AF INET SOCK DGRAM)

create socket: port= xserverSocket =socket(AF_INET, SOCK_DGRAM)

server (running on serverIP) client

socket(AF_INET, SOCK_DGRAM)

create datagram with server IP address and port=x; send datagramto clientSocket

recv datagram with ’ dd f

( )serverSocket.bind()

recv datagram with client’s address fromserverSocket

send reply withserver’s address fromclientSocket

closeclientSocket

p yclient’s address toserverSocket

10/3/201772Application Layer

Note: syntax is neither complete nor precise

37

Chapter 2: outline

2.1 principles of network

2.5 P2P applications2 6 id t inetwork

applications2.2 Web and HTTP2.3 electronic mail

• SMTP, POP3, IMAP2 4 DNS

2.6 video streaming and content distribution networks (CDNs)

2.7 socket programming with

Application Layer 2-73

2.4 DNS programming with UDP and TCP

Video Streaming and CDNs: context

• Netflix, YouTube: 37%, 16% of downstream residential ISP traffic in 2015

video traffic: major consumer of Internet bandwidth

residential ISP traffic in 2015• ~1B YouTube users, ~75M Netflix users

challenge: scale ~1B users?• single mega-video server won’t work

challenge: heterogeneity different users have different capabilities

Application Layer

2-74

pand bandwidths (e.g., wired versus mobile)

solution: distributed, application-level infrastructure

38

Multimedia: video CBR: (constant bit rate): video

encoding rate fixed ……………………..

spatial coding example: instead of sending N values of same color (all purple), send only two values: color value (purple) and number of repeated values (N)

……………….…….

VBR: (variable bit rate): video encoding rate changes as amount of spatial, temporal coding changes examples:• MPEG-1 (CD-ROM) 1.5

Mbps

frame i

Mbps• MPEG-2 (DVD) 3-6 Mbps• MPEG-4 (often used in

Internet < 1 Mbps)frame i+1

temporal coding example: instead of sending complete frame at i+1, send only differences from frame i

Application Layer

2-75

Streaming stored video:

simple scenario:

video server(stored video)

client

Internet

Video can be compressed to essentially any bit

Application Layer

2-76

Video can be compressed to essentially any bit rate by trading image qualityE.g., Internet video from 100Kbps for low quality

to over 3 Mbps for high-definition movies

39

Streaming multimedia: DASH Dynamic, Adaptive Streaming over HTTP server:

divides video file into multiple chunks chunks stored, encoded at different rates manifest file: provides URLs for different chunks

client: periodically measures server-to-client bandwidth consulting manifest, requests one chunk at a time

h d bl• chooses maximum coding rate sustainable at current bandwidth

• can choose different coding rates at different points in time

Application Layer

2-77

Streaming multimedia: DASH (cont.) “intelligence” at client:

client determinesh t t h k th t b ff when to request chunk - so that buffer

starvation, or overflow does not occur what encoding rate to request - higher quality

when more bandwidth available

where to request chunk – may possibly request q y p y qfrom another server that has higher available bandwidth (less congested path) [actually client will need help from CDN]

Application Layer

2-78

40

Content distribution networkschallenge: how to stream content (selected

from millions of videos) to hundreds of thousands of simultaneous users?thousands of simultaneous users?

option 1: single, large “mega-server”single point of failurepoint of network congestionlong path to distant clientslong path to distant clientsmultiple copies of same video sent over outgoing

links….this solution doesn’t scale

Application Layer

2-79

Content distribution networks option 2: third-party CDN multiple copies

of videos at geographically distributed , store/serve sites: enter deep: place CDN servers deep into many

access networks • close to users• e.g., used by Akamai, 1700 locations

bring home: smaller number (10’s) of larger clusters in IXPs/POPs near (but not within)

kaccess networks• e.g., used by Limelight

option 3: private CDN, e.g., Google and NetFlix– use both enter-deep and bring-home servers

Application Layer 2-80

41

CDN content access: DNS redirectBob (client) requests video http://video.netcinema.com/6Y7B23V video stored in KingCDN.com

11. Bob clicks on URL for video http://video.netcinema.com/6Y7B23V

on netcinema.com web page2

2. Client resolves video.netcinema.comvia local DNS

4&5. Local DNS resolves 1105.KingCDN.comfrom KingCDN’s authoritative DNS, which returns the IP address of a

56. request video fromKINGCDN server,streamed via HTTP

Bob’s local DNSserver

netcinema.com

KingCDN.com

netcinema’sauthoratative DNS

3

3. netcinema’s DNS returns hostname 1105.KingCDN.com 4

which returns the IP address of a KingCDN server

Bob’s client then establishes a direct TCP connection with the KingCDN server and issues an HTTP GET request for video

KingCDNauthoritative DNS Application

Layer2-81

Cluster selection strategy (proprietary)

subscriber requests content from CDN

copies of content stored at CDN servers

di t d t b t i t t• directed to nearby copy, retrieves content• may choose different copy if network path is

congested

where’s Madmen?manifest file

Application Layer

2-82

42

Case study: Netflix

Amazon cloud

upload copies of multiple versions of video to CDN servers

Netflix

1

Netflix registration,accounting servers

cloud CDNserver

22. Bob browses

Netflix video 3

3. Manifest file

returned for

requested video

video to CDN servers

CDNserver

1. Bob manages Netflix account

4. DASH streaming

CDNserver

Application Layer

2-83

End of Chapter 2

Application Layer (SSL) 8410/3/2017