CS代考 RFC 959]

Application Layer
Selected Slides from TextBook
Computer Networking: A Top-Down Approach
8th edition

Copyright By PowCoder代写 加微信 powcoder

, Pearson, 2020
Application Layer: 2-1

Application layer: overview
▪ Principles of network applications
▪ Web and HTTP
▪ E-mail, SMTP, IMAP, POP3
▪ The Domain Name System DNS
Application Layer: 2-2

Application layer: overview
Our goals:
▪ conceptual and implementation aspects of application-layer protocols
• transport-layer service models
• client-server paradigm • peer-to-peer paradigm
▪ learn about protocols by examining popular application-layer protocols • HTTP
• SMTP, IMAP • DNS
Application Layer: 2-3

Some network apps
▪ social networking
▪ text messaging
▪ multi-user network games
▪ streaming stored video
(YouTube, Hulu, Netflix)
▪ P2P file sharing
▪ voice over IP (e.g., Skype)
▪ real-time video conferencing ▪ Internet search
▪ remote login
Q: your favorites?
Application Layer: 2-4

Creating a network app
write programs that:
▪ run on (different) end systems
▪ communicate over network
▪ e.g., web server software communicates with browser software
no need to write software for network-core devices
▪ network-core devices do not run user applications
▪ applications on end systems allows for rapid app development, propagation
application
mobile network
national or global ISP
local or regional ISP
home network
enterprise network
application
datacenter
application
Application Layer: 2-5

Client-server paradigm
▪always-on host
▪permanent IP address
▪often in data centers, for scaling
▪contact, communicate with server
▪may be intermittently connected
▪may have dynamic IP addresses
▪do not communicate directly with each other
▪examples: HTTP, IMAP, FTP
mobile network
national or global ISP
local or regional ISP
home network
enterprise network
content provider network
datacenter network
Application Layer: 2-6

Peer-peer architecture
▪no always-on server ▪arbitrary end systems directly
communicate
▪peers request service from other peers, provide service in return to other peers
• self scalability – new peers bring new service capacity, as well as new service demands
▪peers are intermittently connected and change IP addresses
• complex management ▪example: P2P file sharing
mobile network
national or global ISP
local or regional ISP
home network
enterprise network
content provider network
datacenter network
Application Layer: 2-7

Hybrid of client-server and P2P
◼voice-over-IP P2P application
◼centralized server: finding address of remote party: ◼client-client connection: direct (not through server)
Instant messaging
◼chatting between two users is P2P
◼centralized service: client presence detection/location ◼user registers its IP address with central server when it comes online
◼user contacts central server to find IP addresses of buddies
Application Layer: 2-8

Processes communicating
process: program running within a host
▪within same host, two processes communicate using inter-process communication (defined by OS)
▪processes in different hosts communicate by exchanging messages
clients, servers
client process: process that initiates communication
server process: process that waits to be contacted
▪ note: applications with P2P architectures have client processes & server processes
Application Layer: 2-9

▪ process sends/receives messages to/from its socket ▪ socket analogous to door
• sending process shoves message out door
• sending process relies on transport infrastructure on other side of
door to deliver message to socket at receiving process • two sockets involved: one on each side
application
application
controlled by app developer
controlled by OS
Application Layer: 2-10

Addressing processes
▪to receive messages, process must have identifier
▪host device has unique 32-bit IP address
▪Q: does IP address of host on which process runs suffice for identifying the process?
▪ A: no, many processes can be running on same host
▪identifier includes both IP address and port numbers associated with process on host.
▪example port numbers: • HTTP server: 80
• mail server: 25
▪to send HTTP message to gaia.cs.umass.edu web server:
• IP address: 128.119.245.12 • port number: 80
▪more shortly…
Application Layer: 2-11

An application-layer protocol defines:
▪types of messages exchanged, • e.g., request, response
▪message syntax:
• what fields in messages &
how fields are delineated
▪message semantics
• meaning of information in
▪rules for when and how processes send & respond to messages
open protocols:
▪defined in RFCs, everyone has access to protocol definition
▪allows for interoperability ▪e.g., HTTP, SMTP proprietary protocols: ▪e.g., Skype
Application Layer: 2-12

What transport service does an app need?
data integrity
▪some apps (e.g., file transfer, web transactions) require
100% reliable data transfer
▪other apps (e.g., audio) can tolerate some loss
▪some apps (e.g., Internet telephony, interactive games) require low delay to be “effective”
throughput
▪ some apps (e.g., multimedia) require minimum amount of throughput to be “effective”
▪ other apps (“elastic apps”) make use of whatever throughput they get
▪ encryption, data integrity, …
Application Layer: 2-13

Transport service requirements: common apps
application
file transfer/download e-mail Web documents real-time audio/video
streaming audio/video interactive games text messaging
no loss loss-tolerant
loss-tolerant loss-tolerant no loss
throughput
audio: 5Kbps-1Mbps video:10Kbps-5Mbps same as above Kbps+
time sensitive?
yes, 10’s msec
yes, few secs yes, 10’s msec yes and no
Application Layer: 2-14

Internet transport protocols services
TCP service:
▪reliable transport between sending and receiving process
▪flow control: sender won’t overwhelm receiver
▪congestion control: throttle sender when network overloaded
▪does not provide: timing, minimum throughput guarantee, security
▪connection-oriented: setup required between client and server processes
UDP service:
▪unreliable data transfer between sending and receiving process
▪does not provide: reliability, flow control, congestion control, timing, throughput guarantee, security, or connection setup.
Q: why bother? Why is there a UDP?
Application Layer: 2-15

Internet transport protocols services
application
file transfer/download e-mail Web documents Internet telephony
streaming audio/video interactive games
application layer protocol
FTP [RFC 959]
SMTP [RFC 5321]
HTTP 1.1 [RFC 7320]
SIP [RFC 3261], RTP [RFC 3550], or proprietary HTTP [RFC 7320], DASH WOW, FPS (proprietary)
transport protocol
TCP TCP TCP
TCP or UDP
TCP UDP or TCP
Application Layer: 2-16

Securing TCP
Vanilla TCP & UDP sockets:
▪no encryption
▪cleartext passwords sent into socket
traverse Internet in cleartext (!)
Transport Layer Security (TLS) ▪provides encrypted TCP connections ▪data integrity
▪end-point authentication
TSL implemented in application layer
▪apps use TSL libraries, that use TCP in turn
TLS socket API
▪cleartext sent into socket traverse Internet encrypted
▪see Chapter 8
Application Layer: 2-17

Application layer: overview
▪ Principles of network applications
▪ Web and HTTP
▪ E-mail, SMTP, IMAP
▪ The Domain Name System DNS
Application Layer: 2-18

Web and HTTP
First, a quick review…
▪ web page consists of objects, each of which can be stored on different Web servers
▪ object can be HTML file, JPEG image, Java applet, audio file,… ▪ web page consists of base HTML-file which includes several
referenced objects, each addressable by a URL, e.g., www.someschool.edu/someDept/pic.gif
Application Layer: 2-19

HTTP overview
HTTP: hypertext transfer protocol
▪ Web’s application layer protocol
▪ client/server model:
• client: browser that requests, receives, (using HTTP protocol) and “displays” Web objects
• server: Web server sends (using HTTP protocol) objects in response to requests
PC running Firefox browser
server running Apache Web server
iPhone running Safari browser
Application Layer: 2-20

HTTP overview (continued)
HTTP 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
protocols that maintain “state” are complex!
▪ past history (state) must be maintained
▪ if server/client crashes, their views of “state” may be inconsistent, must be reconciled
Application Layer: 2-21

HTTP connections: two types
Non-persistent HTTP
1. TCP connection opened
2. at most one object sent
over TCP connection
3. TCP connection closed
downloading multiple objects required multiple connections
Persistent HTTP
▪TCP connection opened to a server
▪multiple objects can be sent over single TCP connection between client, and that server
▪TCP connection closed
Application Layer: 2-22

Non-persistent HTTP: example
User enters URL:
www.someSchool.edu/someDepartment/home.index
(containing 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 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
Application Layer: 2-23

Non-persistent HTTP: example (cont.)
User enters URL:
www.someSchool.edu/someDepartment/home.index
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
(containing text, references to 10 jpeg images)
4. HTTP server closes TCP connection.
Application Layer: 2-24

Non-persistent HTTP: response time
RTT (definition): time for a small packet to travel from client to server and back
HTTP response time (per object):
▪one RTT to initiate TCP connection ▪one RTT for HTTP request and first few
bytes of HTTP response to return ▪obect/file transmission time
initiate TCP connection
request file
file received
time to transmit file
Non-persistent HTTP response time = 2RTT+ file transmission time
Application Layer: 2-25

Persistent HTTP (HTTP 1.1)
Non-persistent HTTP issues:
▪requires 2 RTTs per object ▪OS overhead for each TCP
connection
▪browsers often open multiple parallel TCP connections to fetch referenced objects in parallel
Persistent HTTP (HTTP1.1):
▪server leaves connection open after sending response
▪subsequent HTTP messages between same client/server sent over open connection
▪client sends requests as soon as it encounters a referenced object
▪as little as one RTT for all the referenced objects (cutting response time in half)
Application Layer: 2-26

HTTP request message
▪two types of HTTP messages: request, response ▪HTTP request message:
• ASCII (human-readable format)
carriage return character line-feed character
request line (GET, POST, HEAD commands)
header lines
carriage return, line feed at start of line indicates end of header lines
GET /index.html HTTP/1.1\r\n
Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n Keep-Alive: 115\r\n
Connection: keep-alive\r\n \r\n
* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Application Layer: 2-27

HTTP request message: general format
header field name
request line
header lines
header field name
~ entity body ~~
Application Layer: 2-28

Other HTTP request messages
POST method:
▪ web page often includes form input
▪ user input sent from client to server in entity body of HTTP POST request message
GET method (for sending data to server): ▪ include user data in URL field of HTTP
GET request message (following a ‘?’):
www.somesite.com/animalsearch?monkeys&banana
HEAD method:
▪ requests headers (only) that would be returned if specified URL were requested with an HTTP GET method.
PUT method:
▪ uploads new file (object) to server
▪ completely replaces file that exists at specified URL with content in entity body of POST HTTP request message
Application Layer: 2-29

HTTP response message
status line (protocol status code status phrase)
header lines
HTTP/1.1 200 OK\r\n
Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n Server: Apache/2.0.52 (CentOS)\r\n Last-Modified: Tue, 30 Oct 2007 17:00:02
ETag: “17dc6-a5c-bf716880″\r\n Accept-Ranges: bytes\r\n
Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-8859-
1\r\n \r\n
data data data data data …
data, e.g., requested HTML file
* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Application Layer: 2-30

HTTP response status codes
▪ status code appears in 1st line in server-to-client response message. ▪ some sample codes:
• request succeeded, requested object later in this message 301 Moved Permanently
• requested object moved, new location specified later in this message (in Location: field)
400 Bad Request
• request msg not understood by server 404 Not Found
• requested document not found on this server 505 HTTP Version Not Supported
Application Layer: 2-31

Trying out HTTP (client side) for yourself
1. Telnet to your favorite Web server:
telnet gaia.cs.umass.edu 80
2. type in a GET HTTP request:
▪ opens TCP connection to port 80 (default HTTP server port) at gaia.cs.umass. edu.
▪ anything typed in will be sent to port 80 at gaia.cs.umass.edu
GET /kurose_ross/interactive/index.php HTTP/1.1
Host: gaia.cs.umass.edu
▪ by typing this in (hit carriage return twice), you send this minimal (but complete) GET request to HTTP server
3. look at response message sent by HTTP server!
(or use Wireshark to look at captured HTTP request/response)
Application Layer: 2-32

Application Layer: Overview
▪ Principles of network applications
▪ Web and HTTP
▪ The Domain Name System DNS
Application Layer: 2-33

DNS: Domain Name System
people: many identifiers:
• SSN, name, passport #
Internet hosts, routers:
• IP address (32 bit) – used for addressing datagrams
• “name”, e.g., cs.umass.edu – used by humans
Q: how to map between IP address and name, and vice versa ?
Domain Name System:
▪distributed database implemented in hierarchy of many name servers
▪application-layer protocol: hosts, name servers communicate to resolve names (address/name translation)
• note: core Internet function, implemented as application-layer protocol
• complexity at network’s “edge”
Application Layer: 2-34

DNS: services, structure
DNS services
▪hostname to IP address translation ▪host aliasing
• canonical, alias names
▪ mail server aliasing
▪ load distribution
• replicated Web servers: many IP addresses correspond to one name
Q: Why not centralize DNS?
▪single point of failure ▪traffic volume
▪distant centralized database ▪ maintenance
A: doesn‘t scale!
▪ Comcast DNS servers
alone: 600B DNS queries per day
Application Layer: 2-35

DNS: a distributed, hierarchical database
Root DNS Servers
.com DNS servers .org DNS servers .edu DNS servers
Top Level Domain Authoritative
yahoo.com DNS servers
………… amazon.com pbs.org nyu.edu
DNS servers DNS servers DNS servers
umass.edu DNS servers
Client wants IP address for www.amazon.com; 1st approximation:
▪client queries root server to find .com DNS server
▪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 Application Layer: 2-36

DNS: root name servers
▪ official, contact-of-last-resort by name servers that can not resolve name
▪ incredibly important Internet function
• Internet couldn’t function without it!
• DNSSEC – provides security (authentication and message integrity)
▪ ICANN (Internet Corporation for Assigned Names and Numbers)
manages root DNS domain
13 logical root name “servers” worldwide each “server” replicated many times (~200 servers in US)
Application Layer: 2-37

TLD: authoritative servers
Top-Level Domain (TLD) servers:
▪ responsible for .com, .org, .net, .edu, .aero, .jobs, .museums, and all top-level country domains, e.g.: .cn, .uk, .fr, .ca, .jp
▪ Network Solutions: authoritative registry for .com, .net TLD
▪ Educause: .edu TLD
Authoritative DNS servers:
▪ organization’s own DNS server(s), providing authoritative hostname to IP mappings for organization’s named hosts
▪ can be maintained by organization or service provider
Application Layer: 2-38

Local DNS name servers
▪does not strictly belong to hierarchy
▪ 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
• has local cache of recent name-to-address translation pairs (but may be out of date!)
• acts as proxy, forwards query into hierarchy
Application Layer: 2-39

DNS name resolution: iterated query
Example: host at engineering.nyu.edu wants IP address for gaia.cs.umass.edu
root DNS server
Iterated query:
▪ contacted server replies with name of server to contact
▪ “I don’t know this name, but ask this server”
TLD DNS server
requesting host at
engineering.nyu.edu
local DNS server
dns.nyu.edu
gaia.cs.umass.edu
authoritative DNS server
dns.cs.umass.edu
Application Layer: 2-40

DNS name resolution: recursive query
Example: host at engineering.nyu.edu wants IP address for gaia.cs.umass.edu
root DNS server
Recursive query:
▪ puts burden of name resolution on contacted name server
▪ heavy load at upper levels of hierarchy?
local DNS server
dns.nyu.edu
TLD DNS server
requesting host at
engineering.nyu.edu
gaia.cs.umass.edu
authoritative DNS server
dns.cs.umass.edu
Application Layer: 2-41

Caching, Updating DNS Records
▪ once (any) name server learns mapping, it caches mapping
• cache entries timeout (disappear) after some time (TTL)
• TLD servers typically cached in local name servers • thus root name servers not often visited
▪ cached entries may be out-of-date (best-effort name-to- address translation!)
• if name host changes IP address, may not be known Internet-wide until all TTLs expire!
▪update/notify mechanisms proposed IETF standard • RFC 2136
Application Layer: 2-42

DNS records
DNS: distributed database storing resource records (RR) RR format: (name, value, type, ttl)
▪ name is hostname ▪ value is IP address
▪ name is domain (e.g., foo.com)
▪ value is hostname of authoritative name server for this domain
type=CNAME
▪ name is alias name for some “canonical” (the real) name
▪ www.ibm.com is really servereast.backup2.ibm.com ▪ value is canonical name
▪ value is name of mailserver associated with name
Application Layer: 2-43

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com