Application Layer - Unit 5
Application Layer - Unit 5
Application Layer
Application Layer: OSI and TCP/IP Models
2
Email
HTTP HTTP
HTTP
(www)
Note: Usually a
single server will
function as a server
for multiple
applications
8
Application Layer
Software User
applications
Network-Aware Applications
Applications are the software programs used by people to
communicate over the network.
They implement the application layer protocols and are able to
communicate directly with the lower layers of the protocol stack.
Email Clients
Web Browsers
9
Application Layer Software
User
applications
Services
System
Operations
Bottom line:
When discussing an application like "Telnet" we could be referring
to the application, the service, or the protocol. 11
Application Layer Protocol Functions
13
Client Server Model
16
Application Layer Services
and Protocols
FTP
(file transfer) DNS
(domain name
resolution)
SMTP SMB
(email) (file sharing)
P2P
Telnet (file sharing)
(remote login)
23
Application Layer Protocols :
The application layer provides several protocols which allow any software to easily send and
receive information and present meaningful data to its users.
The following are some of the protocols which are provided by the application layer-
1.TELNET –
Telnet stands for Telecommunications Network. This protocol is used for managing files over the
Internet. It allows the Telnet clients to access the resources of Telnet server. Telnet uses port
number 23.
2.DNS –
DNS stands for Domain Name System. The DNS service translates the domain name (selected by
user) into the corresponding IP address. For example- If you choose the domain name as
www.abcd.com, then DNS must translate it as 192.36.20.8 (random IP address written just for
understanding purposes). DNS protocol uses the port number 53.
3.DHCP –
DHCP stands for Dynamic Host Configuration Protocol. It provides IP addresses to hosts.
Whenever a host tries to register for an IP address with the DHCP server, DHCP server provides
lots of information to the corresponding host. DHCP uses port numbers 67 and 68.
• FTP –
FTP stands for File Transfer Protocol. This protocol helps to transfer different files from one
device to another. FTP promotes sharing of files via remote computer devices with reliable,
efficient data transfer. FTP uses port number 20 for data access and port number 21 for data
control.
• SMTP –
SMTP stands for Simple Mail Transfer Protocol. It is used to transfer electronic mail from
one user to another user. SMTP is used by end users to send emails with ease. SMTP uses
port numbers 25 and 587.
• HTTP –
HTTP stands for Hyper Text Transfer Protocol. It is the foundation of the World Wide Web
(WWW). HTTP works on the client server model. This protocol is used for transmitting
hypermedia documents like HTML. This protocol was designed particularly for the
communications between the web browsers and web servers, but this protocol can also be
used for several other purposes. HTTP is a stateless protocol (network protocol in which a
client sends requests to server and server responses back as per the given state), which
means the server is not responsible for maintaining the previous client’s requests. HTTP
uses port number 80.
• NFS –
NFS stands for Network File System. This protocol allows remote hosts to
mount files over a network and interact with those file systems as though
they are mounted locally. NFS uses the port number 2049.
• SNMP –
SNMP stands for Simple Network Management Protocol. This protocol
gathers data by polling the devices from the network to the management
station at fixed or random intervals, requiring them to disclose certain
information. SNMP uses port numbers 161 (TCP) and 162 (UDP).
•
Reminder of encapsulation/decapsulation
Data Link IP TCP HTTP Data Link
Data Trailer
Header Header Header Header
27
Focus on Application Header and/or Data
HTTP
HTTP
HTTP
HTTP
Client
Server
29
HTTP (HyperText Transfer Protocol)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Paul Morris, MHCC</title><style type="text/css">
<!--
body {
margin-left: 0px;
The base HTML file references other
margin-top: 0px; objects in the page.
margin-right: 0px;
margin-bottom: 0px;
CIS151
Web page (also called a html document)
Web page consists of objects CIS152
Objects (examples):
CIS154
HTML file
JPEG image
GIF image
JAVA applet
Audio file
30
Web Browser - Client
HTTP
Client
HTTP
Server
27.33
Figure 27.12 HTTP transaction
27.34
Figure 27.13 Request and response messages
27.35
Figure 27.14 Request and status lines
27.36
Table 27.1 Methods
27.37
Table 27.2 Status codes
27.38
Table 27.2 Status codes (continued)
27.39
HTTP messages
• HTTP is the language that web clients and
web servers use to talk to each other
• Each message, whether a request or a
response, has three parts:
1. The request or the response line
2. A header section
3. The body of the message
What the client does, Part 1
• Server: NCSA/1.3
– Name and version of the server
• Content-Type: type/subtype
– Should be of a type and subtype specified by
the client’s Accept header
• Set-Cookie: name=value; options
– Requests the client to store a cookie with the
given name and value
What the server does, part III
• The third part of a server
response is the entity body
• This is often an HTML page
– But it can also be a jpeg, a gif, plain text,
etc.--anything the browser (or other client) is
prepared to accept
HTTP Request Message
GET /content.html / HTTP/1.1
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET
CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; InfoPath.1)
Host: www.lukenetwalker.com
Connection: Keep-Alive
HTTP
Server
HTTP Client
Request Message
Request line
Header lines
ASCII Text
Request line: Method field
GET, POST and HEAD
The great majority of Requests are GETs 50
HTTP Request Message
GET /content.html/ HTTP/1.1
Request Line
GET - Browser/client is requesting an object
/content.html / - Browser is requesting this object in
this directory (default is index.html)
HTTP/1.1 - Browser implements the HTTP/1.1 (1.1 is
backwards compatible with 1.0)
51
HTTP Response Message
HTTP/1.1 200 OK
Date: Fri, 22 Feb 2008 16:34:18 GMT
Server: Apache/2.0.52 (Red Hat)
Last-Modified: Thu, 15 Nov 2007 19:33:12 GMT
Content-Length: 15137
Connection: close
Content-Type: text/html
Response message:
Status line
Header lines
Entity body
52
HTTP Response Message
HTTP/1.1 200 OK
Date: Fri, 22 Feb 2008 16:34:18 GMT
Server: Apache/2.0.52 (Red Hat)
Last-Modified: Thu, 15 Nov 2007 19:33:12 GMT
Content-Length: 15137
Connection: close
Content-Type: text/html
Status Line
HTTP/1.1 – Server is using HTTP/1.1
200 OK - Status code, request succeeded and information is
returned in response
53
HTTP Response Message
HTTP/1.1 404
Status Codes
200 OK
- Status code, request succeeded and information is returned in response.
301 Moved Permanently
- Requested object has been permanently moved.
400 Bad Request
- Generic error message, request not understood by server.
404 Not Found:
-The requested document does not exist on server.
505 HTTP Version Not Supported
- The requested HTTP protocol version not supported by server.
54
HTTP Response Message
HTTP/1.1 200 OK
Date: Fri, 22 Feb 2008 16:34:18 GMT
Server: Apache/2.0.52 (Red Hat)
Last-Modified: Thu, 15 Nov 2007 19:33:12 GMT
Content-Length: 15137
Connection: close
Content-Type: text/html
Header Lines
Date: – Server is using HTTP/1.1
Server: - Status code, request succeeded and
information is returned in response
Last-Modified: – Date/time when object created or
modified
Content-Length: – Number of bytes in object being sent
Connection: – Server going to close TCP connection after
sending the requested object.
Content-Type: – Object in entity body is HTML text 55
HTTP Response Message
HTTP/1.1 200 OK
Date: Fri, 22 Feb 2008 16:34:18 GMT
Server: Apache/2.0.52 (Red Hat)
Last-Modified: Thu, 15 Nov 2007 19:33:12 GMT
Content-Length: 15137
Connection: close
Content-Type: text/html
Entity Body
56
HTTP Request and Response Messages
GET /content.html / HTTP/1.1
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET
CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; InfoPath.1)
Host: www.lukenetwalker.com
Connection: Keep-Alive
HTTP
HTTP
HTTP
Server
HTTP Client
HTTP/1.1 200 OK
Date: Fri, 22 Feb 2008 16:34:18 GMT
Server: Apache/2.0.52 (Red Hat)
Last-Modified: Thu, 15 Nov 2007 19:33:12 GMT
Content-Length: 15137
Connection: close
Content-Type: text/html
58
User-Server Interaction: Cookies
HTTP Requests: GET
(first time)
HTTP Response
HTTP
HTTP Request
Request
Orgin HTTP Response
Server HTTP Response
Client
61
HTTPS
62
FTP (File Transfer Protocol)
FTP FTP
Client Server
FTP was developed to allow for file transfers between a client and a
server.
Used to push and pull files from a server running the FTP daemon
(FTPd).
Uses get and put commands.
RFC 959
63
TCP control connection port 21
Username and password
Change directory on Server
POP3
User Mail Mail User
IMAP
agent server server agent
POP3
IMAP
SMTP
RFC 2821
Transfers messages from sender’s mail server to recipient’s mail
server
Push protocol, not a pull protocol
Push (from client to server or server to server)
Pull (from server to client)
Retrieving email
Historically, users would log into local mail server to read mail.
Since early 1990’s, clients use mail access protocols:
POP3
IMAP
HTTP 67
SMTP – Simple Mail Transfer Protocol
IMAP
HTTP
Web-based email
Introduced with Hotmail in mid-1990’s
Communicates with remote mailbox using HTTP
HTTP is used to push (client to server) and pull the email (server to
client) 69
SMTP
MTA
receives email from the
client's MUA
passes email to the MDA
for final delivery
uses SMTP to route email
between servers
Server
71
Telnet
Telnet Telnet
Server
76
DNS – Domain Name System
77
Name Resolution
Resolver
DNS client programs used to look up DNS name
information.
Name Resolution
The two types of queries that a DNS resolver (either a
DNS client or another DNS server) can make to a DNS
server are the following:
Recursive queries
Queries performed by Host to Local DNS Server
Iterative queries
Queries performed Local DNS server to other servers
78
DNS Name Resolution
Step 1.
The DNS resolver on the DNS client sends a recursive
query to its configured Local DNS server.
Requests IP address for "www.example.com".
The DNS server for that client is responsible for
resolving the name
Cannot refer the DNS client to another DNS server.
79
2
3 2
Step 2.
Local DNS Server forwards the query to a Root DNS
server.
Step 3.
Root DNS server
Makes note of .com suffix
Returns a list of IP addresses for TLD (Top Level Domain Servers)
responsible for .com.
80
DNS Name Resolution
Step 4.
The local DNS server sends query for www.example.com to
one of the TLD servers.
Step 5.
TLD Server
Makes note of example.com
Returns IP address for authoritative server example.com (such as
dns.example.com server)
82
DNS Name Resolution
6
6
7
Step 6.
Local DNS server sends query for www.example.com
directly to DNS server for example.com
Step 7.
example.com DNS server responds with its IP address for
www.example.com
83
DNS Name Resolution
8
Step 8.
Local DNS server sends the IP address of www.example.com
to the DNS client.
DNS Caching
When a DNS server receives a DNS reply (mapping hostname
to an IP address) it can cache the information in its
local memory.
DNS servers discard cached information after a period of
time (usually 2 days)
A local DNS server can cache TLD server addresses,
bypassing the root DNS servers in the query chain. 84
DNS Name Resolution
In the worst cases, you'll
get a dialog box that says
the domain name doesn't exist
- even though you know it
does.
This happens because the
authoritative server is slow
replying to the first, and
your computer gets tired of
waiting so it times-out
(drops the connection) or the
domain name does not exist.
But if you try again, there's
a good chance it will work,
because the authoritative
server has had enough time to
reply, and your name server
has stored the information in
its cache.
85
nslookup
nslookup
Displays default DNS server for your host
Can be used to query a domain name and get the IP
address
86
DNS Name
Resolution
ipconfig /displaydns
After a certain amount of time, specified in the Time to Live (TTL)
associated with the DNS resource record, the resolver discards the
record from the cache.
ipconfig /flushdns – Manually deletes entries
The default TTL for positive responses is 86,400 seconds
(1 day).
The default TTL for negative responses is 300 seconds. 87
(Missing Info) DNS: 204.127.199.8
88
89
90
91
SMB – Server Message Block Protocol
92
SMB
Request-response protocol .
Unlike FTP, clients establish a long term connection to
servers.
Client can access the resources on the server as if the
resource is local to the client host.
SMB is sent over TCP
Prior to Windows 2000 windows used a proprietary protocol
(NETBIOS) to send SMB.
Linux/UNIX have similar protocol: SAMBA
93
SMB
94
Peer-to-Peer (P2P) Networking and Applications
and Update
1 – I n f or m Peer
pdate
Centralized 1– Inform and U Peer
Directory
1 – Inform and Update 3 – File Transfer
Server
1 – Inform
and Upda Peer
te
2 – Q uer y
for conten
t
Napster
and Update
1 – I n f or m Peer
pdate
Centralized 1– Inform and U Peer
Directory
1 – Inform and Update 3 – File Transfer
Server
1 – Inform
and Upda Peer A
te
2 – Q uer y
for conten
t
1. Peer A starts P2P application
2. Informs centralized directory server of its:
IP address
Names of objects making available for sharing (MP3, videos, etc.)
3. Directory server collects information from each peer that
becomes active.
Dynamic database
Maps IP addresses with object names
4. Peer A queries directory server for IP addresses of other peers
for specific content
Directory Server returns IP addresses for those peers (Peer B)
5. Peer A establishes TCP connection and downloads file (i.e. HTTP
GET) from other peer, Peer B.
6. Directory server removes Peer from database when Peer closes
application or disconnects from Internet 99
Query
P2P – Query
Flooding ry Query hit
Que
t Peer B Peer C
e r y hi
Qu File
r
Query transfe
Query
Peer A Peer D
Que Peer E
ry
Que
ry h
it
Peer F
Gnutella
100
Query
P2P – Query
Flooding ry Query hit
Que
t Peer B Peer C
e r y hi
Qu File
r
Query transfe
Query
Peer A Peer D
Que Peer E
ry
Que
ry h
it
Kazaa
Query Group
Leade
Q ue r y r
ry Reply
Q ue
File Transfer