You are on page 1of 84

Department of IT

Unit No:2
Application Layer
Computer
Networks(3150710)

Prof.Abhishek Tiwari
 It should be clear that to use the Internet we need two
application programs to interact with each other:
 one running on a computer somewhere in the world.

Application-  the other running on another computer somewhere


else in the world.
Layer  The two programs need to send messages to each
Paradigm other through the Internet infrastructure.
 However, we have not discussed what the relationship
should be between these programs. Should both
application programs be able to request services and
provide services, or should the application programs
just do one or the other?
Figure :
Example of a
client-server
paradigm
 In this paradigm, communication at the application
layer is between two running application programs
called processes: a client and a server.
Client-server
Paradigm  A client is a running program that initializes the
communication by sending a request;

 a server is another application program that waits for a


request from a client.
Figure:
Example of a
peer-to-peer
paradigm
• In this section, we first introduce the World Wide Web
World Wide (abbreviated WWW or Web).
Web and
HTTP • We then discuss the Hyper Text Transfer Protocol
(HTTP), the most common client-server application
program used in relation to the Web.
Figure :
Example
(Retrieving
two files and
one image)
 Browser: A web browser or Internet browser is a software
application for retrieving, presenting, and traversing information
resources on the World Wide Web.

Figure :
Browser:
 The URL http://www.mhhe.com/compsci/forouzan/
defines the web page related to one of the of the
computer in the McGraw-Hill company
 (the three letters www are part of the host name and
Example are added to the commercial host).

 The path is compsci / forouzan /, which defines


Forouzan’s web page under the directory compsci
(computer science).
HTTP
1) non-persistent HTTP
 at most one object sent over TCP connection
 connection then closed
 downloading multiple objects required multiple
connections
HTTP Types
2) persistent HTTP
 multiple objects can be sent over single TCP
connection between client, server
Figure :
Non
Persistent
connection
Example
Non-
persistent
HTTP
Continue…
Continue..
RTT
Figure :
Persistent
Connection
Example
 server leaves TCP connection open after
sending response
 subsequent HTTP messages between
same client/server sent over open
persistent connection
HTTP:  client sends requests as soon as it
encounters a referenced object
 as little as one RTT for all the referenced
objects
HTTP request
message
POST method:
 web page often includes form input
 input is uploaded to server in entity body
Uploading
form input URL method:
 uses GET method
 input is uploaded in URL field of request line:
HTTP
response
message
 status code appears in 1st line in server-to-client response
message.
 some sample codes:
200 OK
 request succeeded, requested object later in this msg

HTTP 301 Moved Permanently


 requested object moved, new location specified later in this
response msg (Location:)
status codes 400 Bad Request
 request msg not understood by server
404 Not Found
 requested document not found on this server
505 HTTP Version Not Supported
Web caches
(proxy server)
 cache acts as both client and server
 server for original requesting client
 client to origin server
why Web caching?
 reduce response time for client request
Continue..
 reduce traffic on an institution’s access link
 Internet dense with caches: enables “poor”
content providers to effectively deliver content
(so too does P2P file sharing)
FTP: the file
transfer
protocol
Continue…
 FTP client contacts FTP server at port 21, using TCP
 client authorized over control connection
 client browses remote directory, sends commands over control
connection
 when server receives file transfer command, server opens 2nd TCP
data connection (for file) to client
Continue..  after transferring one file, server closes data connection
 server opens another TCP data connection to transfer another file
 control connection: “out of band”
 FTP server maintains “ state” : current directory, earlier
authentication
sample commands:
 sent as ASCII text over control channel
 USER username
FTP  PASS password
commands,  LIST return list of file in current directory
responses  RETR filename retrieves (gets) file
 STOR filename stores (puts) file onto
remote host
sample return codes
 status code and phrase (as in HTTP)
 331 Username OK, password
required
 125 data connection already
open; transfer starting
 425 Can’t open data connection
 452 Error writing file
 Electronic mail (or e-mail) allows users to exchange
messages.

2.3.3  The nature of this application, however, is different


Electronic from other applications discussed so far. In an
application such as HTTP or FTP, the server program is
Mail running all the time, waiting for a request from a client.

 When the request arrives, the server provides the


service. In the case of electronic mail, the situation is
different.
 First, e-mail is considered a one-way transaction.
 When Alice sends an e-mail to Bob, she may expect a
response, but this is not a mandate.
 Bob may or may not respond. If he does respond, it is
another one-way transaction.
2.3.3  Second, it is neither feasible nor logical for Bob to run a
Continued server program and wait until someone sends an e-mail
to him.
 Bob may turn off his computer when he is not using it.
 This means that the idea of client/ server programming
should be implemented in another way: using some
intermediate computers (servers).
 Architecture

 User Agent
2.3.3
(continued)  Sending Mail
 Receiving Mail
 Addresses
 Mailing List or Group List
 MIME(Multipurpose Internet Mail Extensions)
 MIME Headers

2.3.1  Web-Based Mail


(continued)
 Case I
 Case II
 E-Mail Security
 Message Transfer Agent: SMTP

 Commands and Responses


 Mail Transfer Phases
2.3.1  Message Access Agent: POP and IMAP
(continued)
 POP3
 IMAP4
POP3(Post Office Protocol) and IMAP(Internet Message Access Protocol ) are two
different protocols (methods) used to access email. Of the two, IMAP is the better option - and
the recommended option - when you need to check your emails from multiple devices, such as
a work laptop, a home computer, or a tablet, smart phone, or other mobile device.
Figure 2.19:
Common
scenario
Figure 2.21:
E-mail
address
Figure 2.22:
Protocols
used in
electronic ma
Table 2.6:
SMTP
Commands
Table 2.7:
SMTP
responses
Table 2.7:
SMTP
responses
(continued)
 To show the three mail transfer phases, we show all of
the steps described above using the information
depicted in Figure 2.23.
 In the figure, we have separated the messages related
to the envelope, header, and body in the data transfer
section.
Example 2.13  Note that the steps in this figure are repeated two times
in each e-mail transfer:
 one from the e-mail sender to the local mail server
 one from the local mail server to the remote mail server.
 The local mail server, after receiving the whole e-mail
message, may spool it and send it to the remote mail
server at another time.
Figure 2.23:
Example 2.13
Figure 2.24:
POP3
Multipurpose Internet Mail Extensions:


MIME is a specification for formatting non-ASCII
messages so that they can be sent over the Internet.
MIME :

Many e-mail clients now support MIME, which enables
them to send and receive graphics, audio, and video
files via the Internet mail system.

Servers insert the MIME header at the beginning of any Web
transmission.

Clients use this header to select an appropriate "player"
application for the type of data the header indicates.

Some of these players are built into the Web client or browser (for
example, all browsers come with GIF and JPEG image players as
Figure 2.25: well as the ability to handle HTML files); other players may need
to be downloaded.
MIME :
Figure 2.26:
MIME header
Table 2.8:
Data Types
and Subtypes
in MIME
Table 2.9:
Methods for
Content-
Transfer-
Encoding
Figure 2.27:
Base64
conversion
Table 2.10:
Base64
Converting
Table
Post Office Protocol (POP3) Internet Message Access Protocol (IMAP)

POP is a simple protocol that only allows


IMAP is much more advanced and allows you
downloading messages from your Inbox to
the user to see all the folders on the mail server.
your local computer.

The POP server listens on port 110, and the he IMAP server listens on port 143, and the
POP with SSL secure(POP3DS) server IMAP with SSL secure(IMAPDS) server listens
listens on port 995 on port 993.

In POP3 the mail can only be accessed from Messages can be accessed across multiple
a single device at a time. devices

To read the mail it has to be downloaded on The mail content can be read partially before
the local system. downloading.

The user can not organize mails in the The user can organize the emails directly on the
mailbox of the mail server. mail server.

The user can not create, delete or rename The user can create, delete or rename email on
email on the mail server. the mail server.
Figure 2.29:
Web-based e-
mail, cases I HTTP Protocol: This is not a dedicated protocol for email communications, but it can be used for accessing your
mailbox also called web based email, this can be used to compose or retrieve emails from an your account. Hotmail
and II is a good example of using HTTP as an email protocol.
• A server program can provide a specific service to its
corresponding client program.
• However, it is impossible to have a client/server pair for
each type of service we need.
• Another solution is to have a specific client/server
program for a set of common scenarios, but to have
2.3.4 TELNET some generic client/server programs that allow a user
on the client site to log into the computer at the server
site and use the services available there.
• We refer to these generic client/server pairs as remote
logging applications.
• One of the original remote logging protocols is
TELNET.
 Local versus Remote Logging

 Network Virtual Terminal (NVT)


2.3.4
(continued)  Options

 User Interface
Figure 2.30:
Local versus
remote
logging
Figure 2.31:
Concept of
NVT
Table 2.11:
Examples of
interface
commands
 Although Secure Shell (SSH) is a secure application
program that can be used today for several purposes
such as remote logging and file transfer, it was
originally designed to replace TELNET.
2.3.5 Secure
Shell (SSH) /  There are two versions of SSH: SSH-1 and SSH-2, which
are totally incompatible. The first version, SSH-1, is
(SSh) now deprecated(not-approved) because of security
flaws in it.

 In this section, we discuss only SSH-2.


 Components
 SSH Transport-Layer Protocol (SSH-TRANS)
 SSH Authentication Protocol (SSH-AUTH)
 SSH Connection Protocol (SSH-CONN)
2.3.5
 Applications
(continued)
 SSH for Remote Logging(TErminaL NETwork)
 SSH for File Transfer

 Port Forwarding

 Format of the SSH Packets


Figure 2.32:
Components
of SSH
SFTP is not the FTP protocol running over SSH, but a different file
transfer protocol developed as an extension for SSH-2.

Figure 2.33:
Port
Forwarding:
Figure 2.34:
SSH Packet
Format
Sockets
Two socket types for two transport services:
 UDP: unreliable datagram
 TCP: reliable, byte stream-oriented

Application Example:
1. Client reads a line of characters (data) from its
Socket keyboard and sends the data to the server.
programming 2. The server receives the data and converts characters
to uppercase.
3. The server sends the modified data to the client.
4. The client receives the modified data and displays the
line on its screen.
Client/server
socket
interaction:
UDP
Client/server
socket
interaction:
TCP
• To identify an entity, TCP/IP protocols use the IP
address, which uniquely identifies the connection of a
host to the Internet.
• However, people prefer to use names instead of
Domain numeric addresses.
• Therefore, the Internet needs to have a directory
Name System system that can map a name to an address.
(DNS): • This is analogous to the telephone network.
• A telephone network is designed to use
telephone numbers, not names.
• People can either keep a private file to map a
name to the corresponding telephone number or can call
the telephone directory to do so.
 Name Space

 Domain Name Space


 Domain
 Distribution of Name Space
2.3.6  Zone
(continued)  Root Server

 DNS in the Internet

 Generic Domains
 Country Domains
 Resolution
 Recursive Resolution
 Iterative Resolution
 Caching
2.3.1  Resource Records
(continued)  DNS Messages
 Encapsulation
 Registrars
 DDNS
 Security of DNS
Figure 2.35:
Purpose of
DNS
 Figure 2.36: Domain name space:
 Domain namespace. Alternatively referred to as a namespace, a
domain namespace is a name service provided by the Internet for
Transmission Control Protocol and Networks/Internet Protocol
(TCP/IP).
 DNS is broken up into domains, a logical organization of
computers that exist in a larger network.
Figure 2.36:
Domain name
space:
Figure 2.37:
Domain
names and
labels
Figure 2.38:
Domains
Figure 2.39:
Hierarchy of
name servers
 For example, the Domain Microsoft.com may contain all of the
data for Microsoft.com, Marketing.microsoft.com and
Development.microsoft.com. However, the zone
Microsoft.com contains only information for Microsoft.com and
Figure 2.40: references to the authoritative name servers for the sub-domains.

Zone : A zone
is simply a
portion of a
domain
Figure 2.41:
Generic
domains
Table 2.12:
Generic
domain labels
Figure 2.42:
Country
domain
top-level domain (TLD) servers:
 responsible for com, org, net, edu, aero,
jobs, museums, and all top-level country
domains, e.g.: uk, fr, ca, jp
Continue..  Network Solutions maintains servers
for .com TLD
 Educause for .edu TLD
authoritative DNS servers:
 organization’s own DNS server(s), providing
authoritative hostname to IP mappings for
Continue.. organization’s named hosts

 can be maintained by organization or


service provider
 does not strictly belong to hierarchy
 each ISP (residential ISP, company, university) has one
 also called “default name server”

Local DNS  when host makes DNS query, query is sent to its local
DNS server
name server  has local cache of recent name-to-address
translation pairs (but may be out of date!)
 acts as proxy, forwards query into hierarchy
recursive
query:
iterated query:
DNS Records

You might also like