0% found this document useful (0 votes)
22 views53 pages

IST2045#5 Application Layer

The document provides an overview of the application layer in computer networking, detailing key protocols such as HTTP, SMTP, IMAP, and DNS. It discusses the client-server and peer-to-peer paradigms, the process of creating network applications, and the importance of sockets for communication. Additionally, it covers HTTP's structure, types of connections, request/response messages, and the use of cookies for maintaining user state.

Uploaded by

tapiwamla66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views53 pages

IST2045#5 Application Layer

The document provides an overview of the application layer in computer networking, detailing key protocols such as HTTP, SMTP, IMAP, and DNS. It discusses the client-server and peer-to-peer paradigms, the process of creating network applications, and the importance of sockets for communication. Additionally, it covers HTTP's structure, types of connections, request/response messages, and the use of cookies for maintaining user state.

Uploaded by

tapiwamla66
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Application Layer

Computer Networking: A
Top-Down Approach
8th edition n
Jim Kurose, Keith Ross
Pearson, 2020
Application Layer: 2-1
Application layer: overview

▪ Principles of network
applications
▪ Web and HTTP
▪ E-mail, SMTP, IMAP
▪ The Domain Name System
DNS

Application Layer: 2-2


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

Application Layer: 2-3


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

Application Layer: 2-4


Creating a network app
application
transport
write programs that: mobile network
network
data link
physical
▪ run on (different) end systems national or global ISP

▪ communicate over network


▪ e.g., web server software
communicates with browser software
local or
no need to write software for regional ISP

network-core devices home network content


application
▪ network-core devices do not run user transport
network
provider
network datacenter
application
applications data link
physical
transport
network
network

▪ applications on end systems allows data link


physical

for rapid app development, enterprise


propagation network

Application Layer: 2-5


Client-server paradigm
server: mobile network
▪ always-on host national or global ISP

▪ permanent IP address
▪ often in data centers, for scaling
clients: local or
regional ISP
▪ contact, communicate with server
▪ may be intermittently connected home network content
provider
▪ may have dynamic IP addresses network datacenter
network

▪ do not communicate directly with


each other
enterprise
▪ examples: HTTP, IMAP, FTP network

Application Layer: 2-6


Peer-peer architecture
▪ no always-on server mobile network
▪ arbitrary end systems directly national or global ISP

communicate
▪ peers request service from other
peers, provide service in return to
other peers local or
regional ISP
• self scalability – new peers bring new
service capacity, as well as new service home network content
demands provider
network datacenter

▪ peers are intermittently connected network

and change IP addresses


• complex management enterprise
▪ example: P2P file sharing
network

Application Layer: 2-7


Processes communicating
process: program running clients, servers
within a host client process: process that
initiates communication
▪within same host, two server process: process
processes communicate that waits to be contacted
using inter-process
communication (defined by
OS) ▪ note: applications with
P2P architectures have
▪processes in different hosts client processes &
communicate by exchanging server processes
messages
Application Layer: 2-8
Sockets
▪ 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
socket controlled by
process process app developer

transport transport
network network controlled
link by OS
link Internet
physical physical

Application Layer: 2-9


Addressing processes
▪ to receive messages, process ▪ identifier includes both IP address
must have identifier and port numbers associated with
▪ host device has unique 32-bit process on host.
IP address ▪ example port numbers:
▪ Q: does IP address of host on • HTTP server: 80
which process runs suffice for • mail server: 25
identifying the process? ▪ to send HTTP message to
▪ A: no, many processes gaia.cs.umass.edu web server:
can be running on • IP address: 128.119.245.12
same host • port number: 80
▪ more shortly…
Application Layer: 2-10
An application-layer protocol defines:
▪ types of messages exchanged, open protocols:
• e.g., request, response ▪ defined in RFCs, everyone
▪ message syntax: has access to protocol
• what fields in messages & definition
how fields are delineated ▪ allows for interoperability
▪ message semantics ▪ e.g., HTTP, SMTP
• meaning of information in proprietary protocols:
fields
▪ e.g., Skype
▪ rules for when and how
processes send & respond to
messages
Application Layer: 2-11
What transport service does an app need?
data integrity throughput
▪ some apps (e.g., file transfer, ▪ some apps (e.g., multimedia)
web transactions) require require minimum amount of
100% reliable data transfer throughput to be “effective”
▪ other apps (e.g., audio) can ▪ other apps (“elastic apps”)
tolerate some loss make use of whatever
throughput they get
timing
▪ some apps (e.g., Internet security
telephony, interactive games) ▪ encryption, data integrity,
require low delay to be “effective” …
Application Layer: 2-12
Transport service requirements: common apps

application data loss throughput time sensitive?

file transfer/download no loss elastic no


e-mail no loss elastic no
Web documents no loss elastic no
real-time audio/video loss-tolerant audio: 5Kbps-1Mbps yes, 10’s msec
video:10Kbps-5Mbps
streaming audio/video loss-tolerant same as above yes, few secs
interactive games loss-tolerant Kbps+ yes, 10’s msec
text messaging no loss elastic yes and no
Application Layer: 2-13
Internet transport protocols services
TCP service: UDP service:
▪ reliable transport between sending ▪ unreliable data transfer
and receiving process between sending and receiving
▪ flow control: sender won’t process
overwhelm receiver ▪ does not provide: reliability,
▪ congestion control: throttle sender flow control, congestion
when network overloaded control, timing, throughput
guarantee, security, or
▪ does not provide: timing, minimum connection setup.
throughput guarantee, security
▪ connection-oriented: setup required Q: why bother? Why
between client and server processes is there a UDP?
Application Layer: 2-14
Internet transport protocols services
application
application layer protocol transport protocol

file transfer/download FTP [RFC 959] TCP


e-mail SMTP [RFC 5321] TCP
Web documents HTTP 1.1 [RFC 7320] TCP
Internet telephony SIP [RFC 3261], RTP [RFC TCP or UDP
3550], or proprietary
streaming audio/video HTTP [RFC 7320], DASH TCP
interactive games WOW, FPS (proprietary) UDP or TCP

Application Layer: 2-15


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

Application Layer: 2-16


Application layer: overview
▪ P2P applications
▪ Principles of network ▪ video streaming and content
applications distribution networks
▪ Web and HTTP ▪ socket programming with
▪ E-mail, SMTP, IMAP UDP and TCP
▪ The Domain Name System
DNS

Application Layer: 2-17


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

host name path name

Application Layer: 2-18


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

Application Layer: 2-19


HTTP overview (continued)
HTTP uses TCP: HTTP is “stateless”
▪ client initiates TCP connection ▪ server maintains no
(creates socket) to server, port 80 information about past client
▪ server accepts TCP connection requests
from client aside
protocols that maintain “state”
▪ HTTP messages (application-layer are complex!
protocol messages) exchanged
▪ past history (state) must be
between browser (HTTP client) and maintained
Web server (HTTP server) ▪ if server/client crashes, their views
▪ TCP connection closed of “state” may be inconsistent,
must be reconciled

Application Layer: 2-20


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

Application Layer: 2-21


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 1b. HTTP server at host
(process) at www.someSchool.edu on www.someSchool.edu waiting for TCP
port 80 connection at port 80 “accepts”
connection, notifying client
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection 3. HTTP server receives request message,
socket. Message indicates forms response message containing
time that client wants object requested object, and sends message
someDepartment/home.index into its socket
Application Layer: 2-22
Non-persistent HTTP: example (cont.)
User enters URL: www.someSchool.edu/someDepartment/home.index
(containing text, references to 10 jpeg images)

4. HTTP server closes TCP


5. HTTP client receives response connection.
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: 2-23


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

time time
Non-persistent HTTP response time = 2RTT+ file transmission time
Application Layer: 2-24
Persistent HTTP (HTTP 1.1)
Non-persistent HTTP issues: Persistent HTTP (HTTP1.1):
▪ requires 2 RTTs per object ▪ server leaves connection open after
▪ OS overhead for each TCP sending response
connection ▪ subsequent HTTP messages
▪ browsers often open multiple between same client/server sent
parallel TCP connections to over open connection
fetch referenced objects in ▪ client sends requests as soon as it
parallel encounters a referenced object
▪ as little as one RTT for all the
referenced objects (cutting
response time in half)
Application Layer: 2-25
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,
GET /index.html HTTP/1.1\r\n
HEAD commands) Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
header Accept-Language: en-us,en;q=0.5\r\n
lines 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
carriage return, line feed \r\n
at start of line indicates
end of header lines * Check out the online interactive exercises for more
examples: http://gaia.cs.umass.edu/kurose_ross/interactive/ Application Layer: 2-26
Other HTTP request messages
POST method: HEAD method:
▪ web page often includes form ▪ requests headers (only) that
input would be returned if specified
▪ user input sent from client to URL were requested with an
server in entity body of HTTP HTTP GET method.
POST request message
PUT method:
▪ uploads new file (object) to server
GET method (for sending data to server): ▪ completely replaces file that exists
▪ include user data in URL field of HTTP at specified URL with content in
GET request message (following a ‘?’): entity body of POST HTTP request
www.somesite.com/animalsearch?monkeys&banana
message

Application Layer: 2-27


HTTP response status codes
▪ status code appears in 1st line in server-to-client response message.
▪ some sample codes:
200 OK
• 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-28
Maintaining user/server state: cookies
Web sites and client browser use Example:
cookies to maintain some state ▪ Susan uses browser on laptop,
visits specific e-commerce site
between transactions for first time
four components: ▪ when initial HTTP requests
1) cookie header line of HTTP response arrives at site, site creates:
message • unique ID (aka “cookie”)
• entry in backend database
2) cookie header line in next HTTP for ID
request message
• subsequent HTTP requests
3) cookie file kept on user’s host, from Susan to this site will
managed by user’s browser contain cookie ID value,
4) back-end database at Web site allowing site to “identify”
Susan
Application Layer: 2-29
HTTP cookies: comments
aside
What cookies can be used for: cookies and privacy:
▪ authorization ▪ cookies permit sites to
▪ shopping carts learn a lot about you on
their site.
▪ recommendations
▪ third party persistent
▪ user session state (Web e-mail) cookies (tracking cookies)
allow common identity
(cookie value) to be
Challenge: How to keep state: tracked across multiple
▪ protocol endpoints: maintain state at
web sites
sender/receiver over multiple transactions
▪ cookies: HTTP messages carry state

Application Layer: 2-30


Web caches (proxy servers)
Goal: satisfy client request without involving origin server
▪ user configures browser to
point to a Web cache proxy
▪ browser sends all HTTP server
requests to cache client
origin
• if object in cache: cache server

returns object to client


• else cache requests object
from origin server, caches
received object, then client
returns object to client origin
server

Application Layer: 2-31


Web caches (proxy servers)
▪ Web cache acts as both Why Web caching?
client and server ▪ reduce response time for client
• server for original request
requesting client
• cache is closer to client
• client to origin server
▪ reduce traffic on an institution’s
▪ typically cache is access link
installed by ISP
(university, company, ▪ Internet is dense with caches
residential ISP) • enables “poor” content providers
to more effectively deliver content

Application Layer: 2-32


HTTP/2
Key goal: decreased delay in multi-object HTTP requests
HTTP1.1: introduced multiple, pipelined GETs over single TCP
connection
▪ server responds in-order (FCFS: first-come-first-served scheduling) to
GET requests
▪ with FCFS, small object may have to wait for transmission (head-of-
line (HOL) blocking) behind large object(s)
▪ loss recovery (retransmitting lost TCP segments) stalls object
transmission

Application Layer: 2-33


HTTP/2
Key goal: decreased delay in multi-object HTTP requests

HTTP/2: [RFC 7540, 2015] increased flexibility at server in sending


objects to client:
▪ methods, status codes, most header fields unchanged from HTTP 1.1
▪ transmission order of requested objects based on client-specified
object priority (not necessarily FCFS)
▪ push unrequested objects to client
▪ divide objects into frames, schedule frames to mitigate HOL blocking

Application Layer: 2-34


HTTP/2 to HTTP/3
Key goal: decreased delay in multi-object HTTP requests

HTTP/2 over single TCP connection means:


▪ recovery from packet loss still stalls all object transmissions
• as in HTTP 1.1, browsers have incentive to open multiple parallel
TCP connections to reduce stalling, increase overall throughput
▪ no security over vanilla TCP connection
▪ HTTP/3: adds security , per object error- and congestion-
control (more pipelining) over UDP
• more on HTTP/3 in transport layer

Application Layer: 2-35


Application layer: overview
▪ P2P applications
▪ Principles of network ▪ video streaming and content
applications distribution networks
▪ Web and HTTP ▪ socket programming with
▪ E-mail, SMTP, IMAP UDP and TCP
▪ The Domain Name System
DNS

Application Layer: 2-36


outgoing
E-mail message queue
user mailbox
user
Three major components: agent

▪ user agents mail user


server
▪ mail servers agent

▪ simple mail transfer protocol: SMTP SMTP mail user


server agent
SMTP
User Agent SMTP user
▪ a.k.a. “mail reader” mail agent
server
▪ composing, editing, reading mail messages user
▪ e.g., Outlook, iPhone mail client agent
user
▪ outgoing, incoming messages stored on agent
server
Application Layer: 2-37
outgoing
E-mail: mail servers message queue
user mailbox
user
mail servers: agent

▪ mailbox contains incoming mail


server
user
agent
messages for user
SMTP mail user
▪ message queue of outgoing (to server agent
be sent) mail messages SMTP
▪ SMTP protocol between mail SMTP user
agent
servers to send email messages mail
server
• client: sending mail server user
agent
• “server”: receiving mail server user
agent

Application Layer: 2-38


E-mail: the RFC (5321)
▪ uses TCP to reliably transfer email message from client (mail server
initiating connection) to server, port 25
▪ direct transfer: sending server (acting like client) to receiving server
▪ three phases of transfer
• handshaking (greeting)
• transfer of messages
• closure
▪ command/response interaction (like HTTP)
• commands: ASCII text
• response: status code and phrase
▪ messages must be in 7-bit ASCI

Application Layer: 2-39


Scenario: Alice sends e-mail to Bob
1) Alice uses UA to compose e-mail 4) SMTP client sends Alice’s message
message “to” [email protected] over the TCP connection
2) Alice’s UA sends message to her 5) Bob’s mail server places
mail server; message placed in the message in Bob’s
message queue mailbox
3) client side of SMTP opens TCP 6) Bob invokes his user
connection with Bob’s mail server agent to read message

1 user mail user


mail agent
agent server server
2 3 6
4
5
Alice’s mail server Bob’s mail server
Application Layer: 2-40
SMTP: closing observations
comparison with HTTP: ▪ SMTP uses persistent
connections
▪ HTTP: pull
▪ SMTP requires message
▪ SMTP: push (header & body) to be in
▪ both have ASCII command/response 7-bit ASCII
interaction, status codes ▪ SMTP server uses
CRLF.CRLF to determine
▪ HTTP: each object encapsulated in its end of message
own response message
▪ SMTP: multiple objects sent in
multipart message
Application Layer: 2-41
Mail message format
SMTP: protocol for exchanging e-mail
messages, defined in RFC 531 (like HTTP)
RFC 822 defines syntax for e-mail message
itself (like HTML)
▪ header lines, e.g., header
• To: blank
line
• From:
• Subject:
these lines, within the body of the email body
message area different from SMTP MAIL FROM:,
RCPT TO: commands!
▪ Body: the “message” , ASCII characters only
Application Layer: 2-42
Mail access protocols
user
e-mail access user
SMTP SMTP protocol
agent agent
(e.g., IMAP,
HTTP)

sender’s e-mail receiver’s e-mail


server server

▪ SMTP: delivery/storage of e-mail messages to receiver’s server


▪ mail access protocol: retrieval from server
• IMAP: Internet Mail Access Protocol [RFC 3501]: messages stored on server, IMAP
provides retrieval, deletion, folders of stored messages on server
▪ HTTP: gmail, Hotmail, Yahoo!Mail, etc. provides web-based interface on
top of STMP (to send), IMAP (or POP) to retrieve e-mail messages
Application Layer: 2-43
Application Layer: Overview
▪ P2P applications
▪ Principles of network ▪ video streaming and content
applications distribution networks
▪ Web and HTTP ▪ socket programming with
▪ E-mail, SMTP, IMAP UDP and TCP
▪ The Domain Name System
DNS

Application Layer: 2-44


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

Application Layer: 2-45


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

Application Layer: 2-46


DNS: a distributed, hierarchical database
Root DNS Servers Root
… …
.com DNS servers .org DNS servers .edu DNS servers Top Level Domain
… … … …
yahoo.com amazon.com pbs.org nyu.edu umass.edu
DNS servers DNS servers DNS servers DNS servers DNS servers Authoritative

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-47
DNS: root name servers
▪ official, contact-of-last-resort by
name servers that can not 13 logical root name “servers”
worldwide each “server” replicated
resolve name many times (~200 servers in US)
▪ 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
Application Layer: 2-48
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-49


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


DNS security
DDoS attacks Redirect attacks
▪ bombard root servers with ▪ man-in-middle
traffic • intercept DNS queries
• not successful to date ▪ DNS poisoning
• traffic filtering • send bogus relies to DNS DNSSEC
• local DNS servers cache IPs of TLD server, which caches [RFC 4033]
servers, allowing root server Exploit DNS for DDoS
bypass
▪ send queries with spoofed
▪ bombard TLD servers source address: target IP
• potentially more dangerous ▪ requires amplification

Application Layer: 2-51


Summary
our study of network application layer is now complete!
▪ application architectures ▪ specific protocols:
• client-server • HTTP
• P2P • SMTP, IMAP
• DNS
▪ application service requirements:
• reliability, bandwidth, delay
▪ Internet transport service model
• connection-oriented, reliable: TCP
• unreliable, datagrams: UDP

Application Layer: 2-52


Summary
Most importantly: learned about protocols!
▪ typical request/reply message important themes:
exchange: ▪ centralized vs. decentralized
• client requests info or service ▪ stateless vs. stateful
• server responds with data, status code ▪ scalability
▪ message formats: ▪ reliable vs. unreliable
• headers: fields giving info about data message transfer
• data: info(payload) being ▪ “complexity at network
communicated
edge”

Application Layer: 2-53

You might also like