BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Principles of Network Application:
Program should be written at the core of network application development that
run on different end systems and communicate with each other over the network
i.e., web browser program running in the users host(host, laptop) and the web
server program running in the server host
Examples:
1. Electronic Mail
4. P2P File Sharing
2. The Web
5. Multi-User Network games
3. Instant Message
6. Streaming Stored video clips
Network Application Architecture:
1. Client / server (Client talk to Server)
2. Peer to Peer (Client talk to another Client)
Client / Server: Main Features:
Need Server and Server OS
No client-to-client communication
In a Client-Server architecture, there is an always-on host, called Server
Which services request from many other hosts, called Clients
1. A client that
interacts with the user
2. An
application
server that contains the
business logic of the
application
3. A
resource
manager that stores
data
4. Note:
Application server and
the data store is alwayson
pg. 1
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Advantage:
Performance
Administration
Dis-Advantages
Cost
Complexity
P2P Architecture: Peer to peer:
Main Features:
All devices acts as both Client and Server. I.e., everyone talks to everyone
There isnt an always-on server at the center of the application (No Server &
Server OS needed)
Instead, arbitrary pairs of hosts, called Peers, communicate directly with each
other client hosts.
Peers are intermediately connected and the hosts may change IP address each
time it comes on.
One of the greatest strength is the Scalability- millions of peers may participate
in the file sharing community with each one functioning as a server and
contributing resource to the community
pg. 2
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Advantage:
Easy to deploy
Low cost
Dis-advantage:
Difficult to administration (Application has to be updated to all the clients whereas
with the client / server the updates can be done only to the Server)
Difficult to secure
Instant Message:
The chatting between two users is typically P2P; that is the text sent between the
two users does not pass through an always-on, intermediate server.
However, when User1 launches the instant messaging application, he/she
registers themselves at a central server; and when User2 wants to chat with
someone on host buddy list, User2 instant messaging client contacts the central
server to find out which buddies are currently online and available
Process Communicating:
Process on two different end system communicate with each other by
exchanging messages across the network
A sending process creates and sends message into the network
A receiver process receives these messages and possibly responds by sending
the message back
The above processes communicate with each other by using the application
layer of the five-layer protocol stack.
SOCKETS:
When a process sends messages into, and receives from, the network through
its Sockets
Example on how sockets works: (Just like how we send a letter to another
person)
When a process wants to send a message to another process on another host, it
pulls the message out its door(Socket) and into the network.
The sending process assumes that there is a transportation infrastructure on the
other side of its door that will transport the message across the door the network
to the door of the destination process.
pg. 3
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Once the message arrives at the destination host, the message through the
receiving processs door (Socket) and the receiving process acts on the message
API
(Application
Interface):
Programming
API is an interface between the
application layer and the network layer.
API chooses
Protocol
the
Transportation
API also fixes a few Transport-layer
parameters such as maximum buffer
and minimum segment sizes
Address Processing:
In order to process on one host to send a message to another host, the sender process
must identify the receiving process
To identify the receiving process, two pieces of information need to be specified
1. The name or address of the host and
2. An identifier that specifies the receiving process in the destination host
pg. 4
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Host device serves unique 32-bit quantity IP address.
In this case the identifier includes both IP address and port numbers
associated with process on host.
Example: a web server (IP address: [Link] is identified by port
number 80. A mail server process (using the SMTP protocol) is identified by port
number 25.
Each of the Port numbers are assigned by the Network application developer
while creating a new network application
Application-Layer Protocols:
Determines Types of messages exchanged,
e.g., request, response
Message Syntax: determines the various message types, such as the fields in
the message and how the fields are allocated.
Message Semantics: has the meaning of the information in the fields
Rules for determining when and how a process sends messages and responds
to messages
Public Domain Protocols:
Defined in RFC (Request For Comments)
It is a web application protocol
e.g., HTTP, SMTP
Internet apps: application, transport protocols:
TCP:
Connection
Oriented
Protocol
(Reliable
transmission
or
Guaranteed
Transmission)
UDP:
Connectionless
Protocol
(UnReliable
transmission or unguaranteed Transmission)
pg. 5
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
WEB and HTTP:
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: [Link]/someDept/[Link]
HTTP: hypertext transfer protocol
Webs application layer protocol
client/server model
client: browser that requests, receives,
displays Web objects
server: Web server sends objects in
response to requests
It 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
HTTP connections:
Non-persistent HTTP:
At most one object is sent over a TCP connection.
Example:
Suppose
user
[Link]/someDepartment/[Link]
enters
URL
pg. 6
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Non-Persistent HTTP: Response time:
Definition of RTT (Round Trip Time): time for a
small packet to travel from client to server and
back from server to client.
Response time:
one RTT to initiate TCP connection
one RTT for HTTP request and first few
bytes of HTTP response to return
pg. 7
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
file transmission time
total = 2RTT+transmit time (2RTT 1st RTT is from Initiate TCP till 1st request file
and 2nd RTT if from file request till file received)
Non-persistent HTTP issues:
requires 2 RTTs per object
browsers often open parallel TCP connections to fetch referenced objects
Persistent HTTP
Multiple objects can be sent over single TCP connection between client and
server.
server leaves connection open after sending response
subsequent HTTP messages
connection
client sends requests as soon as it encounters a referenced object as little as
one RTT for all the referenced objects
between same client/server sent over open
User-server state: cookies
Allow sites to keep track of users. Although not all sites use cookies, most major
portal (like YAHOO), e-commerce (AMAZON) sites makes extensive use of
Cookies
Four Cookie Technology:
1) cookie header line of HTTP response message
2) cookie header line in HTTP request message
3) cookie file kept on users host, managed by users browser
4) back-end database at Web site
Example:
Susan who always access the Web using Internet Explorer from her home PC
Visits specific e-commerce site for first time and this sites uses cookies
When the request comes into the Web server, the Web site creates a unique
identification number and creates an entry in its back-end database, that is
pg. 8
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
indexed by the identification number (i.e., when initial HTTP requests arrives at
site, site creates:
unique ID
entry in backend database for ID )
The server then responds to Susans browser, including in the HTTP response a
Set-cookie: header, which contains the identification number. For example
Set-Cookie: 1678453
When Susans browser receives the HTTP response message, it sees the SetCookie: header each time.
What cookies can bring:
Authorization
Shopping carts
Recommendations
User session state (Web e-mail)
Cookies and privacy:
cookies permit sites to learn a lot about you
you may supply name and e-mail to sites
pg. 9
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Web Caching or Proxy Server:
Goal: satisfy client request without involving origin server
1. The browser establishes a TCP connection to the Web cache (Proxy server) and
sends an
HTTP request for the object to the
Web cache
2. The Web cache (Proxy
server) checks to see if it has a
copy of the object stored locally. If
it does, the Web cache forwards
the object within an HTTP
response message to the client
browser
3. If the Web cache does not have the object, the Web cache opens a TCP
connection to the Origin Server , that is to [Link] . The cache
then sends an HTTP request for the object into the TCP connection. After
receiving the request the origin server sends the object within an HTTP response
to the web cache
4. When the Web cache receives the object, it stores a copy in its local storage and
forwards a copy, within an HTTP response message, to the client browser
More about Web caching
cache acts as both client and server
typically cache is installed by ISP (university, company, residential ISP)
Why Web caching?
reduce response time for client request
reduce traffic on an institutions access link.
Internet dense with caches: enables poor content providers to effectively deliver
content (but so does P2P file sharing)
Caching example: Assumptions
Requesting an average object size = 100,000 bits (100Kbits)
Router connection link = 1.5Mbps
pg. 10
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
avg. request rate from institutions browsers to origin servers = 15 request/sec
Consequences
utilization on LAN = 15 request /sec
utilization on access link (for each request on LAN) = 100 Kbits / request
Traffic intensity of the access link delay = (15 req/sec) * (100 Kbits/sec) / (1.5
Mbps)
= (15 req/sec) * (100 Kbits/sec) / (1500 Kbps)
= 1sec
Possible solution:
increase bandwidth of access link to, say, 10 Mbps
Consequences:
utilization on LAN = 15 request /sec
utilization on access link (for each request on LAN) = 100 Kbits / request
Traffic intensity of the access link delay = (15 req/sec) * (100 Kbits/sec) / (10
Mbps)
= (15 req/sec) * (100 Kbits/sec) / (15000 Kbps)
= 0.1sec
FTP: File transfer protocol:
Transfer files to and from a remote host
To do so, user must provide identification and a password
When user provides authentication information, the user can transfer files from
the local file system with FTP through an FTP agent.
The user first provides the host name of the remote host, causing the FTP client
process on the local host to establish TCP connection with FTP server process in
the remote host.
The user provides the identification and password, which get sent over the
TCP connection as part of commands. Once the server has the authorized user,
pg. 11
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
the user copies one or more files stored in the file system in to the remote file
system
Here, HTTP and FTP are both files transfer protocols and have many common
characteristics; for example, they both run on top of TCP. However, the two
application layers have some important differences.
The most important differences, FTP uses two parallel TCP connections to
transfer a file, control connection and a data connection.
The control connection is used for sending control information between the
two hosts. i.e., the information such as identification, password, commands to
change remote directory and commands to Put and get files.
The data connection is used actually to send a File
FTP Commands and Replies:
HTTP and FTP commands are readable by people
USER username: use to send the user identification to the server
PASS Password: Use to send the user password to the server
LIST: use to ask the server to send back a list of all the files in the current remote
directory
RETR filename: used to retrieve file from the current directory of the remote host
STOR filename: Used to store a file onto the current directory of the remote host
pg. 12
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Electronic Mail:
E-mail is a asynchronous medium
(user can send and read message)
Three Major Components: user agents,
Mail servers and the simple mail
transfer protocol (SMTP)
user agents are sometimes called as
Mail readers
User agents allow user to read and
reply to, forward, save and compose
messages
Mail Server: each recipient has mail box located in one of the mail servers.
The mail box manages and maintains the messages that have been sent to the
recipient
A typical message starts its journey in the sender user agent, travel to the
senders mail server and travels to the receivers mail server.
Mailbox contains incoming messages for user
message queue of outgoing (to be sent) mail messages
Electronic Mail: SMTP [RFC 2821]:
SMTP transfers message from senders mail server to the recipient mail server.
Uses TCP to reliably transfer email message from client to server, port 25
direct transfer: sending server to receiving server
Three phases of transfer:
handshaking (greeting) exchange control packet followed by the data.
transfer of messages
closure
Scenario: Alice sends message to Bob:
1) Alice uses UA to compose message and to bob@[Link]
2) Alices UA sends message to her mail server; message placed in message
queue
3) Client side of SMTP opens TCP connection with Bobs mail server
pg. 13
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
4) SMTP client sends Alices message over the TCP connection
5) Bobs mail server places the message in Bobs mailbox
6) Bob invokes his user agent to read message
Sample SMTP interaction:
S: 220 [Link]
C: HELO [Link]
S: 250 Hello [Link], pleased to meet you
C: MAIL FROM: <alice@[Link]>
S: 250 alice@[Link]... Sender ok
C: RCPT TO: <bob@[Link]>
S: 250 bob@[Link] ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 [Link] closing connection
Cont.,
SMTP uses persistent connections
pg. 14
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
SMTP requires message (header & body) to be in 7-bit ASCII
SMTP server uses [Link] to determine end of message
Comparison HTTP and SMTP:
HTTP: PULLS Transfers files (called as objects) from the web server to the web client
SMTP: PUSH Transfers files (that is e-mail message) from one mail server to another
mail server.
Mail message format:
pg. 15
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
MIME: Multipurpose Internet Mail Extensions (Headers to support multimedia)
SMTP: delivery/storage to receivers server
Mail access protocol: retrieval from server
POP: Post Office Protocol [RFC 1939]
It is an Application Layer Protocol
Used by clients to retrieve emails from the server using TCP/IP
protocol
IMAP: Internet Mail Access Protocol [RFC 1730]
Keep all messages in one place: the remote server
Allows user to organize messages in folders
IMAP keeps user state across sessions:
DNS: The internets directory service
human beings can ne identified by the names and social society numbers
internet can identify the hosts by its host name, such as [Link] and
[Link]
hosts names can consist of variable length alphanumeric characters, they would
be difficult to process by routers, for those reasons, hosts are also identified by
so-called IP address (32 bit)
Services provided by DNS
router prefer fixed-length, hierarchy structured IP addresses
in order to reconcile these preferences, we need Directory service that
translate host names to IP address
this is the main task of the internets domain name system (DNS)
DNS is commonly employed by other application-layer protocols-including HTTP,
SMTP, and FTP to supply user-supplied hostnames to IP addresses
Example: Users host request URL [Link]
In order users host to be able to send an HTTP request message to the
web server [Link] , the user host must first obtain the IP
address of [Link]
pg. 16
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Why not centralize DNS?
If single point of failure cause the entire system down
traffic volume is high
Maintenance is high
Distributed, Hierarchical Database:
Client wants IP for [Link]; 1st approx:
client queries a root server to find .com DNS server
client queries .com DNS server to get [Link] DNS server
client queries [Link] DNS server to get IP address for [Link]
DNS: Root name servers:
In the internet there are 13 root DNS servers (labeled A through M), most of which are
located in North America.
A list of current root DNS servers is available via root servers. These servers is actually
a cluster of replicated servers, for both security and reliability purposes.
pg. 17
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
Top-level Domain:
These servers are responsible for top-level domain such as com, org, net, edu, and
gov, and all the country domains such as uk, fr, ca and jp.
Authoritative DNS server:
Every organization with publicly accessible hosts (such as Company web servers and
company mail servers) on the internet must provide publicly accessible DNS records that
map the names of those hosts IP addresses .
Local Name Server:
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
acts as proxy, forwards query into hierarchy
DNS Name Resolution Example:
Host at [Link] wants IP address for [Link]
Iterated query:
contacted server replies with name of server to contact
I dont know this name, but ask this server
TLD Top Level Domain
---END---
pg. 18
BIT3273 COMPUTER NETWORKS
CHAPTER 2- APPLICATION LAYER
pg. 19