Module 1 part 2
Module 1 part 2
Application Layer
• The fifth layer of the TCP/IP protocol suite
• The application layer provides services to the user.
• The communication at the application layer is logical, not physical.
• The application layer different from other layers in that it is the highest
layer in the suite.
• The protocols in this layer do not provide services to any other protocol in
the suite; they only receive services from the protocols in the transport
layer.
• This means that protocols can be added or removed from this layer easily.
• the application-layer protocols can be both standard and nonstandard.
Application-Layer Paradigms
• client-server paradigm
• peer-to-peer paradigm
Traditional Paradigm: Client-Server
• In this paradigm, the service provider is an application program,
called the server process;
• It runs continuously, waiting for another application program, called
the client process, to make a connection through the Internet and ask
for service.
• There are normally some server processes that can provide a specific
type of service, but there are many clients that request service from
any of these server processes.
• The server process must be running all the time; the client process is
started when the client needs to receive service.
Example of a client-server paradigm
• One problem with this paradigm is that the concentration of the
communication load is on the shoulder of the server,
• which means the server should be a powerful computer.
• Even a powerful computer may become overwhelmed if a large
number of clients try to connect to the server at the same time.
• Another problem is that there should be a service provider willing to
accept the cost and create a powerful server for a specific service,
• which means the service must always return some type of income for
the server in order to encourage such an arrangement.
• World Wide Web (WWW) , HyperText Transfer Protocol (HTTP), file
transfer protocol (FTP), secure shell (SSH), e-mail, and so on uses this
paradigm.
New Paradigm: Peer-to-Peer
• P2P paradigm
• In this paradigm, there is no need for a server process to be running
all the time and waiting for the client processes to connect.
• The responsibility is shared between peers.
• A computer connected to the Internet can provide service at one time
and receive service at another time.
• A computer can even provide and receive services at the same time.
• Internet telephony and file sharing is indeed a peer-to-peer activity.
Example of a peer-to-peer paradigm
• Easily scalable and cost-effective in eliminating the need for expensive
servers.
• The main challenge has been security;
• It is more difficult to create secure communication between
distributed services.
• The other challenge is applicability;
• it appears that not all applications can use this new paradigm.
• BitTorrent, Skype, IPTV, and Internet telephony, use this paradigm.
Mixed Paradigm
• combining the advantages of both.
• For example, a light-load client-server communication can be used to
find the address of the peer that can offer a service.
• When the address of the peer is found, the actual service can be
received from the peer by using the peer-to peer paradigm.
CLIENT-SERVER PARADIGM working
• In a client-server paradigm, communication at the application layer is
between two running application programs called processes: a client
and a server.
• 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.
• The server handles the request received from a client, prepares a
result, and sends the result back to the client.
• The lifetime of a server is infinite
• The lifetime of a client is finite.
How can a client process communicate with a
server process?
• We need a new set of instructions to tell the lowest four layers of the
TCP/IP suite to open the connection, send and receive data from the
other end, and close the connection.
• A set of instructions of this kind is normally referred to as Application
Programming Interface(API).
• A computer manufacturer needs to build the first four layers of the
suite in the operating system and include an API.
• The operating system encapsulates the first four layers.
• Socket interface, Transport Layer Interface (TLI), and STREAM are
some APIs.
Socket interface
• It is an API (Application Programming Interface)
• Socket interface started in the early 1980s at UC Berkeley as part of a
UNIX environment.
• The socket interface is a set of instructions that provide
communication between the application layer and the operating
system.
• It is a set of instructions that can be used by a process to
communicate with another process.
• Sockets allows us to use the set of all instructions already designed in
a programming language.
Sockets
• A socket behave like a terminal or a file, but it is not a physical entity
like them; it is an abstraction.
• It is a data structure that is created and used by the application
program.
Position of the socketinterface
• Communication between a client process and server process is
communication between two sockets, created at two ends.
• The client thinks that the socket is the entity that receives the request
and gives the response;
• the server thinks that the socket is the one that has a request and
needs the response.
• If we create two sockets, one at each end, and define the source and
destination addresses correctly, we can use the available instructions
to send and receive data.
• The rest is the responsibility of the operating system and the
embedded TCP/IP protocol.
Socket Addresses
• The interaction between a client and a server is two-way
communication.
• In a two-way communication, we need a pair of addresses: local
(sender) and remote (receiver).
• The local address in one direction is the remote address in the other
direction and vice versa.
• Since communication in the client-server paradigm is between two
sockets, we need a pair of socket addresses for communication: a
local socket address and a remote socket address.
• A socket address should first define the computer on which a client or
a server is running.
• a computer in the Internet is uniquely defined by its IP address, a 32-
bit integer.
• However, several client or server processes may be running at the
same time on a computer, which means that we need another
identifier to define the specific client or server involved in the
communication.
• An application program can be defined by a port number, a 16-bit
integer.
• This means that a socket address should be a combination of an IP
address and a port number.
Finding Socket Addresses
• The situation is different for each site.
• The server needs a local (server) and a remote (client) socket address for
communication.
• The client also needs a local (client) and a remote (server) socket address
for communication.
• The local (server) socket address is provided by the operating system.
• The remote socket address for a server is the socket address of the client
that makes the connection.
• The local (client) socket address is also provided by the operating system.
• DNS maps the remote server name to the IP address of the computer
running that server.
Using Services of the Transport Layer
• Since there is no physical communication at the application layer,
need to use the services provided by the transport layer.
• there are three common transport layer protocols in the TCP/IP suite:
UDP, TCP, and SCTP.
• Most standard applications have been designed to use the services of
one of these protocols.
• The choice of the transport layer protocol seriously affects the
capability of the application processes.
UDP Protocol
• User Datagram Protocol provides connectionless, unreliable,
datagram service.
• Connectionless service means that there is no logical connection
between the two ends exchanging messages.
• Each message is an independent entity encapsulated in a packet
called a datagram.
• UDP does not see any relation (connection) between consequent
datagrams coming from the same source and going to the same
destination.
• UDP is not a reliable protocol.
• Although it may check that the data is not corrupted during the
transmission,
• it does not ask the sender to resend the corrupted or lost datagram.
• For some applications, UDP has an advantage: it is message-oriented.
• It gives boundaries to the messages exchanged.
• An application program may be designed to use UDP if it is sending
small messages.
• the simplicity and speed is more important for the application than
reliability.
• For example, some management and multimedia applications.
TCP Protocol
• Transmission Control Protocol provides connection-oriented, reliable,
byte-stream service.
• TCP requires that two ends first create a logical connection between
themselves by exchanging some connection-establishment packets.
• This phase is sometimes called handshaking.
• Establishes some parameters between the two ends including the size
of the data packets to be exchanged, the size of buffers to be used for
holding the chunks of data until the whole message arrives, and so
on.
• After the handshaking process, the two ends can send chunks of data
in segments in each direction.
• By numbering the bytes exchanged, the continuity of the bytes can be
checked.
• For example, if some bytes are lost or corrupted, the receiver can
request the resending of those bytes, which makes TCP a reliable
protocol.
• TCP also can provide flow control and congestion control .
• One problem with the TCP protocol is that it is not message-oriented;
it does not put boundaries on the messages exchanged.
• Most of the standard applications that need to send long messages
and require reliability may benefit from the service of the TCP.
SCTP Protocol
• Stream Control Transmission Protocol provides a service which is a
combination of TCP and UDP.
• Like TCP, SCTP provides a connection-oriented, reliable service, but it
is not byte-stream oriented.
• It is a message-oriented protocol like UDP.
• In addition, SCTP can provide multistream service by providing
multiple network-layer connections.
• SCTP is normally suitable for any application that needs reliability and
at the same time needs to remain connected, even if a failure occurs
in one network-layer connection.
STANDARD CLIENT-SERVERAPPLICATIONS
• An organization usually selects one or more hosts to receive and send e-mail; they
are sometimes called mail servers or exchangers.
Mailing List or GroupList
• Electronic mail allows one name, an alias, to represent several different
e-mail addresses;
• this is called a mailing list.
• Every time a message is to be sent, the system checks the recipient’s name
against the alias database;
• if there is a mailing list for the defined alias, separate messages, one for each
entry in the list, must be prepared and handed to the MTA.
Protocols used in electronicmail
Message Transfer Agent:SMTP
• The formal protocol that defines the MTA client and server in the Internet is
called Simple Mail Transfer Protocol (SMTP).
• SMTP is used two times,
• Between the sender and the sender’s mail server
• Between the two mail servers.
• SMTP simply defines how commands and responses must be sent back and forth.
• SMTP uses commands and responses to transfer messages between an MTA
client and an MTA server.
• The command is from an MTA client to an MTA server; the response is from an
MTA server to the MTA client.
• Each command or reply is terminated by a two character (carriage return and
line feed) end-of-line token.
SMTP Commands
• It consists of a keyword followed by zero or more arguments. SMTP defines 14
commands.
SMTP Responses
• A response is a three digit code that may be followed by additional textual
information.
Mail TransferPhases
• The process of transferring a mail message occurs in three phases:
• Connection establishment
• Mail transfer.
• Connection termination
Connection Establishment
• After a client has made a TCP connection to the port 25,
• the SMTP server starts the connection phase.
• This phase involves the following three steps:
• 1. The server sends code 220 (service ready) to tell the client that it is
ready to receive mail. If the server is not ready, it sends code 421
(service not available).
• 2. The client sends the HELO message to identify itself, using its
domain name address to inform the server of the domain name of
the client.
• 3. The server responds with code 250 (request command completed)
or some other code depending on the situation.
Message Transfer
• This phase involves eight steps.
• Steps 3 and 4 are repeated if there is more than one recipient.
• 1. The client sends the MAIL FROM message to introduce the sender of the
message. It includes the mail address of the sender (mailbox and the domain
name). This step is needed to give the server the return mail address for
returning errors and reporting messages.
• 2. The server responds with code 250 or some other appropriate code.
• 3. The client sends the RCPT TO (recipient) message, which includes the mail
address of the recipient.
• 4. The server responds with code 250 or some other appropriate code.
• 5. The client sends the DATA message to initialize the message transfer.
• 6. The server responds with code 354 (start mail input) or some other
appropriate message.
• 7. The client sends the contents of the message in consecutive lines. The message
is terminated by a line containing just one period.
• 8. The server responds with code 250 (OK) or some other appropriate code.
Connection Termination
• After the message is transferred successfully, the client terminates
the connection.
• This phase involves two steps.
• 1. The client sends the QUIT command.
• 2. The server responds with code 221 or some other appropriate
code.
Message Access Agent: POP andIMAP
• SMTP is a push protocol; it pushes the message from the client to the
server.
• The receiver needs a pull protocol; the client must pull messages from
the server.
• Two message access protocols are available: Post Office Protocol
version 3 (POP3) and Internet Mail Access Protocol version 4 (IMAP4).
POP3
• Post Office Protocol, version 3 (POP3) is simple but limited in
functionality.
• The client POP3 software is installed on the recipient computer; the
server POP3 software is installed on the mail server.
• Mail access starts with the client when the user needs to download its
e-mail from the mailbox on the mail server.
• The client opens a connection to the server on TCP port 110.
• It then sends its user name and password to access the mailbox.
• The user can then list and retrieve the mail messages, one by one.
• POP3 has two modes: the delete mode and the keep mode.
• In the delete mode, the mail is deleted from the mailbox after each
retrieval.
• In the keep mode, the mail remains in the mailbox after retrieval.
• The delete mode is normally used when the user is working at her
permanent computer and can save and organize the received mail
after reading or replying.
• The keep mode is normally used when the user accesses her mail
away from her primary computer (for example, from a laptop). The
mail is read but kept in the system for later retrieval and organizing.
• POP3 is deficient in several ways.
• It does not allow the user to organize her mail on the server;
• the user cannot have different folders on the server.
• In addition, POP3 does not allow the user to partially check the
contents of the mail before downloading.
IMAP4
• Internet Mail Access Protocol, version 4 (IMAP4).
• IMAP4 is similar to POP3, but it has more features;
• IMAP4 is more powerful and more complex.
• IMAP4 provides the following extra functions:
• A user can check the e-mail header prior to downloading.
• A user can search the contents of the e-mail for a specific string of
characters prior to downloading.
• A user can partially download e-mail. This is especially useful if bandwidth
is limited and the e-mail contains multimedia with high bandwidth
requirements.
• A user can create, delete, or rename mailboxes on the mail server.
• A user can create a hierarchy of mailboxes in a folder for e-mail storage.
MIME
• Multipurpose Internet Mail Extensions (MIME) is a supplementary protocol that
allows non-ASCII data to be sent through e-mail.
• MIME is a set of software functions that transforms non-ASCII data to ASCII
data and vice versa.
• Normally E-mail can send messages only in NVT 7-bit ASCII format.
• It cannot be used for languages other than English.
• It cannot be used to send binary files or video or audio data.
• MIME transforms non-ASCII data at the sender site to NVT ASCII data and
delivers it . The message at the receiving site is transformed back to the original
data.
MIME
• After the secured channel is established and both server and client are
authenticated for each other, SSH can call a piece of software that
implements the third protocol, SSH-CONN.
• One of the services provided by the SSH-CONN protocol
is multiplexing.
• SSH-CONN takes the secure channel established by the two previous
protocols and lets the client create multiple logical channels over it.
• Each channel can be used for a different purpose, such as remote
logging, file transfer, and so on.
Applications ofSSH
• SSH is, in fact, a general-purpose protocol that provides a secure connection
between a client and server.
• Several free and commercial applications use SSH for remote logging. PuTTy and
Tectia are SSH programs that can be used for remote logging
• The Secure File Transfer Program (sftp) uses one of the channels provided
by the SSH to transfer files.
• Another common application is called Secure Copy (scp).
• This application uses the same format as the UNIX copy command, cp, to
copy files.
PortForwarding
• One of the services provided by the SSH protocol is port forwarding.
• The SSH port forwarding mechanism creates a tunnel through which
the messages belonging to other protocols can travel.
• For this reason, this mechanism is sometimes referred to as SSH
tunneling.
Format of the SSHPackets
• The data field is the data transferred by the packet in different protocols.
• The length field defines the length of the packet but does not include the
padding.
• One to eight bytes of padding is added to the packet to make the attack on
the security provision more difficult.
• The cyclic redundancy check (CRC) field is used for error detection.
• The type field designates the type of the packet used in different SSH
protocols.
Domain Name System(DNS)
• This is a client-server application program designed to help other
application programs.
• 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 numeric addresses.
• Therefore, the Internet needs to have a directory system that can
map a name to an address.
• Since the Internet is so huge today, a central directory system cannot
hold all the mapping.
• In addition, if the central computer fails, the whole communication
network will collapse.
• A better solution is to distribute the information among many
computers in the world.
• In this method, the host that needs mapping can contact the closest
computer holding the needed information.
• This method is used by the Domain Name System (DNS).
Steps : Hostname to IP address
• The following six steps map the host name to an IP address:
• 1. The user passes the host name to the file transfer client.
• 2. The file transfer client passes the host name to the DNS client.
• 3. The DNS client sends a message to a DNS server with a query that
gives the file transfer server name using the known IP address of the
DNS server.
• 4. The DNS server responds with the IP address of the desired file
transfer server.
• 5. The DNS client passes the IP address to the file transfer client.
• 6. The file transfer client now uses the received IP address to access
the file transfer server.
Name Space
• The names assigned to machines must be unique because the addresses
are unique.
• A name space that maps each address to a unique name can be organized
in two ways: flat or hierarchical.
• In a flat name space, a name is a sequence of characters without structure.
• The main disadvantage of a flat name space is that it cannot be used in a
large system such as the Internet because it must be centrally controlled to
avoid ambiguity and duplication.
• In a hierarchical name space, each name is made of several parts.
• The first part can define the nature of the organization, the second part can
define the name of an organization, the third part can define departments
in the organization, and so on.
• Examples: ceasar.first.com and ceasar.second.com.
Domain Name Space
• To have a hierarchical name space, a domain name space was
designed.
• In this design the names are defined in an inverted-tree structure
with the root at the top.
• The tree can have only 128 levels: level 0 (root) to level 127
• Each node in the tree has a label, which is a string with a maximum of 63
characters.
• The root label is a null string (empty string).
• DNS requires that children of a node have different labels, which guarantees the
uniqueness of the domain names.
• Each node in the tree has a domain name.
• A full domain name is a sequence of labels separated by dots (.).
• The domain names are always read from the node up to the root.
• This means that a full domain name always ends in a null label, which means the
last character is a dot because the null string is nothing.
• If a label is terminated by a null string that is dot, it is called a fully qualified
domain name (FQDN).
• If a label is not terminated by a null string, it is called a partially qualified domain
name (PQDN).
• A PQDN starts from a node, but it does not reach the root.
• It is used when the name to be resolved belongs to the same site as the client.
• Here the resolver can supply the missing part, called the suffix, to create an
FQDN.
Example for domain name
• A domain is a subtree of the domain name space.
• The name of the domain is the name of the node at the top of the
subtree.
• A domain may itself be divided into domains.
Distribution of Name Space
• It is very inefficient and also not reliable to have just one computer
store such a huge amount of information.
• It is inefficient because responding to requests from all over the world
places a heavy load on the system.
• It is not reliable because any failure makes the data inaccessible.
• The solution to these problems is to distribute the information among
many computers called DNS servers.
• A hierarchy of servers in the same way that we have a hierarchy of
names.
• Since the complete domain name hierarchy cannot be stored on a
single server, it is divided among many servers.
• What a server is responsible for or has authority over is called a zone.
• We can define a zone as a contiguous part of the entire tree.
• A root server is a server whose zone consists of the whole tree.
Primary and Secondary Servers
• DNS defines two types of servers: primary and secondary.
• A primary server is a server that stores a file about the zone for which it is an
authority.
• It is responsible for creating, maintaining, and updating the zone file.
• It stores the zone file on a local disk.
• A secondary server is a server that transfers the complete information about a
zone from another server (primary or secondary) and stores the file on its local
disk.
• The secondary server neither creates nor updates the zone files.
• If updating is required, it must be done by the primary server, which sends the
updated version to the secondary.
• This is to create redundancy for the data so that if one server fails, the other can
continue serving clients.
• A primary server loads all information from the disk file;
• the secondary server loads all information from the primary server.
DNS in the Internet
• In the Internet, the domain name space (tree) was originally divided
into three different sections: generic domains, country domains, and
the inverse domain.
• Due to the rapid growth of the Internet, it became extremely difficult
to keep track of the inverse domains, which could be used to find the
name of a host when given the IP address.
Generic Domains
• The generic domains define registered hosts according to their
generic behavior. Each node in the tree defines a domain, which is an
index to the domain name space database.
Country Domains
• The country domains section uses two-character country abbreviations (e.g., us for United States).
• Second labels can be organizational, or they can be more specific, national designations.
• uci.ca.us. can be translated to University of California.
What is Resolution
• Mapping a name to an address is called name-address resolution.
• DNS is designed as a client-server application.
• A host that needs to map an address to a name or a name to an address
calls a DNS client called a resolver.
• The resolver accesses the closest DNS server with a mapping request.
• If the server has the information, it satisfies the resolver;
• otherwise, it either refers the resolver to other servers or asks other
servers to provide the information.
• After the resolver receives the mapping, it interprets the response to see if
it is a real resolution or an error, and finally delivers the result to the
process that requested it.
• A resolution can be either recursive or iterative.
Recursive Resolution
Iterative Resolution
• In iterative resolution, each server that does not know the mapping
sends the IP address of the next server back to the one that
requested it.
Caching
• When a server asks for a mapping from another server and receives
the response, it stores this information in its cache memory.
• Caching speeds up resolution, but it can also be problematic.
• If a server caches a mapping for a long time, it may send an outdated
mapping to the client.
• To solve this, the server always adds information to the mapping
called time to live (TTL).
• It defines the time in seconds that the receiving server can cache the
information.
• After that time, the mapping is invalid.
DNS Resource Records