Chapter2 Application Layer1
Download
Report
Transcript Chapter2 Application Layer1
Application Layer
CS 381
2/7/2017
Application Layer
2-1
Chapter 2: outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 Electronic mail
2.4 DNS
2.5 P2P applications
2.6 Video streaming and content distribution networks
2.7 socket programming with UDP and TCP
Application Layer
2-2
Chapter 2: application layer
Goals:
• Conceptual, implementation of network application protocols
• Application-layer services
• Overview of transport-layer service models
• client-server paradigm
• peer-to-peer paradigm
Application Layer
2-3
Chapter 2: application layer
• Learn about popular application-level protocols
• HTTP
• Request/response protocol for exchanging information
• FTP
• Transfer files
• SMTP / POP3 / IMAP
• Email
• DNS
• Domain name to IP conversions
• Create network applications
• socket API
Application Layer
2-4
Application Layer: OSI Model
• The Application layer, layer five, is the top layer of the Open Systems Interconnection (OSI)
model.
• Provides the interface between the applications we use to communicate and the underlying
network.
2-5
Application Layer Software
Within the Application layer, there are
two forms of software programs or
processes that provide access to the
network:
Applications – front-end user
interactions
Services – back-end, OS
controlled software
• Network-Aware Applications
• Applications are the software
programs used by people to
communicate over the network.
• Email Clients
• Web Browsers
Application Layer Protocol Functions
• Application layer protocols are used by both source and destination devices.
• The application layer protocols implemented on the source and destination host must
match.
• Protocols: (This will become clearer later! Herding cats.)
• Establish consistent rules for exchanging data.
• Specify the structure and type of messages that are exchanged.
• Types: Request, response, acknowledgement, error message, etc.
2-7
Processes communicating
• Process:
• program running within a host
• Client process:
• initiates communication
• Server process:
• waits to be contacted
host or
server
host or
server
process
controlled by
app developer
process
socket
socket
TCP with
buffers,
variables
Internet
TCP with
buffers,
variables
Controlled by OS
• process sends/receives messages to/from its socket
• Identifier includes both IP address and port numbers associated with
process on host.
2: Application Layer
2-8
Application Layer Protocol Functions
• Applications and services can use multiple protocols.
• Encapsulate the protocol or encapsulated by this protocol
• Invoke other protocols
• Using a web browser (HTTP):
• May invoke:
• DNS, ARP, ICMP
• May use:
• TCP, UDP, Ethernet, Wi-Fi
• Uses
• IP
2-9
Some network apps
• e-mail
• web
• text messaging
• remote login
• P2P file sharing
• multi-user network games
• streaming stored video
(YouTube, Hulu, Netflix)
• voice over IP (e.g., Skype)
• real-time video conferencing
• social networking
• search
•…
Application Layer
2-10
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 (switches/routers) do
not run user applications
Application Layer
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
2-11
Application architectures
Possible structure of applications:
• client-server
• peer-to-peer (P2P)
Application Layer
2-12
Client-server architecture
Server:
• always-on host
• permanent IP address
• data centers for scaling
Clients:
client/server
• communicate with server
• may be intermittently connected
• may have dynamic IP addresses
• do not communicate directly with each other
Application Layer
2-13
Servers
• A server is usually a computer that
contains information to be shared
with many client systems.
• Web server
• Email server
• File or database server
• Applications server
• Some servers may require
authentication of user account
information.
• Example
• FTP Server, DB Server
2-13
Application Layer Services and Protocols
• Servers typically have multiple
clients requesting information at
the same time.
• Example: Telnet
• Individual requests must be
handled simultaneously and
separately for the network to
succeed.
• This is a feature of “network-edge”
devices, not “network-core”
devices
2-14
P2P architecture
peer-peer
• 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 decentralized management
Application Layer
2-16
Processes communicating
clients, servers
client process: process
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
• Socket programming
that initiates
communication
server process: process
that waits to be contacted
Note: Applications with
P2P architectures have
client processes & server
processes
Application Layer
2-17
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
application
process
socket
application
process
transport
transport
network
network
link
Internet
link
controlled by
app developer
controlled
by OS
physical
physical
Application Layer
2-18
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
• Identifiers include 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 wku.edu
web server:
• IP address: 161.6.94.21
• port number: 80
• More shortly…
Application Layer
2-19
App-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
fields
• Rules for when and how
processes send & respond to
messages
Open protocols:
• defined in RFCs
• allows for interoperability
• HTTP, SMTP
Proprietary protocols:
• Ex: Skype
Application Layer
2-20
What transport service does an app need?
Data Integrity
Throughput
• some apps (e.g., file transfer, web
transactions) require 100% reliable data
transfer
• other apps (e.g., audio) can tolerate
some loss
•
Timing
Security
• some apps (e.g., Internet telephony,
interactive games) require low delay to
be “effective”
•
•
Application Layer
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, authentication, …
2-21
Transport service requirements: common apps
Application
Data Loss
Throughput
Time Sensitive
file transfer
e-mail
Web documents
real-time audio/video
no loss
no loss
no loss
loss-tolerant
no
no
no
yes, 100’s msec
stored audio/video
interactive games
text messaging
loss-tolerant
loss-tolerant
no loss
elastic
elastic
elastic
audio: 5kbps-1Mbps
video:10kbps-25Mbps
same as above
few kbps up
elastic
Application Layer
yes, few secs
yes, 100’s msec
yes and no
2-22
Internet transport protocols services
Transmission Control Protocol (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
Application Layer
2-23
Internet transport protocols services
User Datagram Protocol (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-24
Internet apps: application, transport protocols
application
e-mail
remote terminal access
Web
file transfer
streaming multimedia
Internet telephony
application
layer protocol
underlying
transport protocol
SMTP [RFC 2821]
Telnet [RFC 854]
HTTP [RFC 2616]
FTP [RFC 959]
HTTP (e.g., YouTube),
RTP [RFC 1889]
SIP, RTP, proprietary
(e.g., Skype)
TCP
TCP
TCP
TCP
TCP or UDP
Application Layer
TCP or UDP
2-25
Securing TCP
TCP & UDP
• No encryption
• Clear text passwords sent into socket traverse Internet in clear
text
SSL
• Provides encrypted TCP connection
• Data integrity
• End-point authentication
SSL is at app layer
• Apps use SSL libraries, which “talk” to TCP
Application Layer
2-26
Chapter 2: outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 Electronic mail
2.4 DNS
2.5 P2P applications
2.6 Video streaming and content distribution networks
2.7 socket programming with UDP and TCP
Application Layer
2-27
Web and HTTP
First, a review…
• A web page consists of objects
• Object can be HTML file, JPEG image, Java applet, audio file,…
• Web page consists of base HTML-file which includes several
referenced objects
• Each object is addressable by a URL:
www.someschool.edu/someDept/pic.gif
host name
path name
Application Layer
2-28
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-29
HTTP overview (continued)
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)
Note
protocols that maintain
• TCP connection closed
“state” are complex!
•
HTTP is “stateless”
• server maintains no information about past
client requests
Application Layer
•
past history (state) must
be maintained
if server/client crashes,
their views of “state” may
be inconsistent.
2-30
HTTP connections
Non-persistent HTTP
• at most one object sent over TCP connection
• connection then closed
• downloading multiple objects required multiple connections
Persistent HTTP
• multiple objects can be sent over single TCP connection
between client, server
Application Layer
2-31
Non-persistent HTTP: response time
Round Trip Time (RTT):
• time for a small packet to travel from client to server
and back
initiate TCP
connection
HTTP response time:
• one RTT to initiate TCP connection
• one RTT for HTTP request and first few bytes of
HTTP response to return
• file transmission time
• non-persistent HTTP response time =
2RTT+ file transmission time
Application Layer
RTT
request
file
time to
transmit
file
RTT
file
received
time
time
2-32
Non-persistent vs. Persistent HTTP
Non-persistent HTTP issues:
• Requires 2 RTTs per object
• OS overhead for each TCP connection
• Browsers often open parallel TCP connections to fetch referenced
objects
Persistent HTTP:
• Server leaves connection open after sending response
• Subsequent HTTP messages between same client/server sent over
open connection
• As little as one RTT for all the referenced objects
Application Layer
2-33
HTTP
HTTP/1.0:
• GET
• POST
• Non-idempotent request that updates a given resource (Think append, X++, etc.)
• HEAD
• Gives information about a URL without actually downloading its contents
HTTP/1.1:
• GET, POST, HEAD
• PUT
• Idempotent request that completely replaces or creates a new resource (Think
assignment, clicking “clear” on a calculator multiple times, etc.)
• DELETE
• deletes file specified in the URL field
Application Layer
2-34
HTTP response status codes
status code appears in 1st line of the server-to-client response
message.
• some sample codes:
200 OK
•
• request succeeded, requested object later in this msg
301 Moved Permanently
• requested object moved, new location specified later in this msg (Location:)
400 Bad Request
• request msg not understood by server
404 Not Found
• requested document not found on this server
505 HTTP Version Not Supported
2-35
User-server state: cookies
• Application servers keep user state at client devices.
• HTTP messages carry state info, but HTTP is stateless.
• What cookies can bring:
cookies and privacy:
• Authorization
• Shopping carts
• Recommendations
cookies permit sites to
learn a lot about you
you may supply name
and e-mail to sites
• Cookies and privacy:
• Cookies permit sites, including 3rd parties, to learn a lot about you
Application Layer
2-36
Web caches (proxy server)
Goal: satisfy client request without involving origin server
• User’s browser: Web accesses via cache
• Browser sends all HTTP requests to proxy server
• Object in cache: cache returns object
• Else cache requests object from origin server, then returns object to client
proxy
server
client
origin
server
client
Application Layer
origin
server
2-37
More about Web caching
• Cache acts as both client and server
• Server for original requesting client
• Client to origin server
• Typically cache is installed by local ISP
• university, company, residential ISP
• Why Web caching?
• Reduce response time for client request
• Reduce traffic on an institution’s access link
• Internet has many proxy servers: enables “poor” content providers to
effectively deliver content
Application Layer
2-38
Assumptions:
•
•
•
•
Caching example:
Avg object size:
1 Mb
Avg request rate from browsers to origin servers:
15/sec
Internet delay (ISP router to any origin server
and back):
2 sec
Access link rate:
15 Mbps
Consequences:
•
•
•
LAN utilization:
15%
Access link utilization = 100%
Problem!
Total delay = Internet delay + access delay +
LAN delay
= 2 sec + minutes + usecs
Application Layer
origin
servers
public
Internet
15 Mbps
access link
institutional
network
100 Mbps LAN
2-39
Caching example: fatter access link
Possible solution:
•
Increase bandwidth of access link to,
say, 100 Mbps
origin
servers
Consequences:
•
•
•
public
Internet
LAN utilization:
15%
Access link utilization = 15%
Total delay = Internet delay + access delay +
LAN delay
= 2 sec + usecs + usecs
100 Mbps
access link
institutional
network
100 Mbps LAN
Cost: Increased access link speed (not cheap!)
Application Layer
2-40
Caching example: install local cache
Calculating access link utilization, delay with
cache:
• Suppose cache hit rate is 0.4
• 40% requests satisfied at cache, 60% requests satisfied at
origin
origin
servers
Consequence
•
•
•
•
public
Internet
40% of requests will be satisfied almost immediately
60% of requests satisfied by origin server
Utilization of access link reduced to 60%
• Resulting in negligible delay (say 70ms)
Average total delay:
• Internet delay + access link delay + LAN delay
• = 0.6(2 + 0.14 + 0.02) +
0.4(0 + 0 + 0.02) seconds
= ~1.3 seconds
15 Mbps
access link
institutional
network
100 Mbps LAN
local web
cache
Cost: Proxy server (cheap!)
Application Layer
2-41
Chapter 2: outline
2.1 Principles of network applications
2.2 Web and HTTP
2.3 Electronic mail
2.4 DNS
2.5 P2P applications
2.6 Video streaming and content distribution networks
2.7 socket programming with UDP and TCP
Application Layer
2-42