1.CN DC unit 5
1.CN DC unit 5
proceeding:
This document is confidential and intended solely for the educational purpose
of RMK Group of Educational Institutions. If you have received this document
through email in error, please notify the system manager. This document
contains proprietary information and is intended only to the respective group /
learning community as intended. If you are not the addressee you should not
disseminate, distribute or copy through e-mail. Please notify the sender
immediately by e-mail if you have received this document by mistake and
delete this document from your system. If you are not the intended recipient
you are notified that disclosing, copying, distributing or taking any action in
reliance on the contents of this information is strictly prohibited.
22EC503– Computer Networks
UNIT - 5
APPLICATION LAYER
1 Course Objectives 7
2 Pre Requisites 9
3 Syllabus 11
4 Course Outcomes 13
5 CO - PO / PSO Mapping 15
Unit - V APPLICATION LAYER
Lecture Plan 17
Activity Based Learning 19
Lecture Notes 20
Introduction to Application Layer 21
Application Layer Paradigm 22
Client - Server Programming 26
World Wide Web and HTTP 38
Domain Name System (DNS) 49
Electronic Mail (e-Mail) 61
Introduction to Peer to Peer Networks 77
Need for Cryptography and Network Security 83
Firewalls 89
6 Links for Online Lecture Videos and Lecture PPTs 94
7 Assignments 96
8 Part - A Q & A (With K - Level and CO) 99
9 Part - B Q's (With K - Level and CO) 107
10 Supportive Online Certification Courses 110
11 Real Time Applications 112
12 Content Beyond Syllabus 114
13 Assessment Schedule 116
14 Text Book and Reference Books 118
15 Mini Project Ideas 120
1.Course Objectives
Course Objectives
The student should be made to:
• To study the fundamental concepts of computer networks and
physical layer.
• To gain the knowledge of various protocols and techniques used in
the data link layer.
• To learn the services of network layer and network layer protocols.
• To describe different protocols used in the transport layer.
• To understand the application layer protocols
2.Pre Requisites (Course Names with Code)
Pre Requisites
S.No Course Course Name
Code
1 EC8392 DIGITAL ELECTRONICS
9
3.Syllabus
SYLLABUS
TOTAL: 45 PERIODS
4.Course Outcomes
Course Outcomes for
22EC503– Computer Networks
Highest
# Course Outcomes Cognitive
Level
C304.3 Learn the network layer services and network layer protocols. K3
Outcomes
Program
Specific
Level of CO
Program Outcomes
K3 K4 K4 K5 K6 A3 A2 A3 A3 A3 A3 A2 K5 K5 K3
PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PO- PSO PSO PSO
1 2 3 4 5 6 7 8 9 10 11 12 -1 -2 -3
C304.1 K2 2 1 - - - - - - - - - - - - 2
C304.2 K2 2 1 - - - - - - - - - - - - 2
C304.3 K3 3 2 2 1 1 - - - - - - - - - 3
C304.4 K2 2 1 - - - - - - - - - - - - 2
C304.5 K2 2 1 1 1 - - - - - - - - - - 2
CO Avg
3 2 2 1 1 - - - - - - - - - 3
C304
LECTURE PLAN
UNIT - V - APPLICATION LAYER
LECTURE PLAN
UNIT - V - APPLICATION LAYER
Mode of Delivery
Taxonomy level
Proposed Date
No. of Periods
Pertaining CO
Actual Date
Reason for
Deviation
S.No
Topic
Total No.of.hours : 09
ACTIVITY BASED LEARNING
UNIT - V - APPLICATION LAYER
ACTIVITY BASED LEARNING
Dear students,
Configure the Microsoft Outlook with your email id in your Desktop / Laptop
Computer and mention the port number and assign the address for Incoming and
Outgoing mail server and all necessary details. Now using Microsoft outlook try to
send and receive the mail.
Set up a shared folder in your laptop and try to access the files in the
shared folder from other devices using your home network. Also try
remotely accessing your friends laptop from your home
Activity:2
5.1 INTRODUCTION TO
APPLICATION LAYER
INTRODUCTION TO APPLICATION LAYER
➢ The whole Internet, hardware and software, was designed and developed to
provide services at the application layer. The application layer provides services to
the user.
➢ Since the application layer is the only layer that provides services to the Internet
user, the flexibility of the application layer, as described above, allows new
application protocols to be easily added to the Internet, which has been occurring
during the lifetime of the Internet.
➢ The application layer, however, is somewhat 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 removed from this layer easily.
➢ New protocols can be also added to this layer as long as the new protocols can
use the services provided by one of the transport-layer protocols.
5.2 APPLICATION LAYER
PARADIGMS
To use the Internet we need two application programs to interact with each other:
one running on a computer somewhere in the world, the other running
on another computer somewhere else in the world.
These two programs need to send messages to each other through the Internet
infrastructure
To serve this purpose, Two paradigms have been developed during the lifetime of
the Internet:-
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.
The server process must be running all the time; the client process is started when
the client needs to receive service.
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.
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.
Several traditional services are still using this paradigm, including the World Wide
Web (WWW) and its vehicle HyperText Transfer Protocol (HTTP), file transfer
protocol (FTP), secure shell (SSH), e-mail, and so on.
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.
no party needs to be running forever waiting for the other party to call.
APPLICATION LAYER PARADIGMS
➢ If an Internet user has a file available to share with other Internet users, there is
no need for the file holder to become a server and run a server process all the
time waiting for other users to connect and retrieve the file.
➢ Although the peer-to-peer paradigm has been proved to be easily scalable and
cost-effective in eliminating the need for expensive servers to be running and
maintained all the time, there are also some challenges.
➢ The main challenge has been security; it is more difficult to create secure
communication between distributed services than between those controlled by
some dedicated servers.
➢ The other challenge is applicability; it appears that not all applications can use this
new paradigm.
➢ There are some new applications, such as BitTorrent, Skype, IPTV, and Internet
telephony, that use this paradigm.
5.3 CLIENT - SERVER
PROGRAMMING
5.3.1 Application Programming Interface
5.3.2 Using Services of the Transport Layer
5.3.3 Iterative Communication Using UDP
5.3.4 Iterative Communication Using TCP
5.3.5 Concurrent Communication
CLIENT - SERVER PROGRAMMING
The server handles the request received from a client, prepares a result, and sends the
result back to the client.
This definition of a server implies that a server must be running when a request from a
client arrives, but the client needs to be run only when it is needed. This means that if we
have two computers connected to each other somewhere, we can run a client process on
one of them and the server on the other.
However, we need to be careful that the server program is started before we start
running the client program.
Several APIs have been designed for communication. Three among them are
common: socket interface, Transport Layer Interface (TLI), and STREAM.
The idea of sockets allows us to use the set of all instructions already designed in
a programming language for other sources and sinks.
For example, in most computer languages, like C, C++, or Java, we have several
instructions that can read and write data to other sources and sinks such as a
keyboard (a source), a monitor (a sink), or a file (source and sink).
Figure 5.4 shows the idea and compares the sockets with other sources and sinks.
Fig 5.4 : Sockets used the same way as other sources and sinks
Sockets
▪ 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 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.
• The local (server) socket address is provided by the operating system. The
operating system knows the IP address of the computer on which the server
process is running.
• For example, the assigned port number for a Hypertext Transfer Protocol (HTTP)
is the integer 80, which cannot be used by any other process.
• If the server process is not standard, the designer of the server process can
choose a port number, in the range defined by the Internet authority, and assign
it to the process.
• The remote socket address for a server is the socket address of the client that
makes the connection.
• Since the server can serve many clients, it does not know beforehand the remote
socket address for communication. The server can find this socket address when
a client tries to connect to the server.
• The client socket address, which is contained in the request packet sent to the
server, becomes the remote socket address that is used for responding to the
client.
CLIENT-SERVER PROGRAMMING
Client Site
The client also needs a local (client) and a remote (server) socket address
for communication.
• The local (client) socket address is also provided by the operating system.
The operating system knows the IP address of the computer on which the
client is running.
• The port number needs to be assigned from a set of integers defined by the
Internet authority and called the ephemeral (temporary) port numbers.
• The operating system, however, needs to guarantee that the new port
number is not used by any other running client process.
Finding the remote (server) socket address for a client, however, needs
more work. When a client process starts, it should know the socket address
of the server it wants to connect to. We will have two situations in this
case.
i. Sometimes, the user who starts the client process knows both the server port number and IP
address of the computer on which the server is running.
ii. Although each standard application has a well-known port number, most of the time, we do
not know the IP address.
CLIENT-SERVER PROGRAMMING
▪ In these situations, the server has a name, an identifier that uniquely defines
the server process. Examples of these identifiers are URLs, such as
www.xxx.yyy, or e-mail addresses, such as [email protected].
▪ The client process should now change this identifier (name) to the
corresponding server socket address.
▪ The client process normally knows the port number because it should be a
well-known port number, but the IP address can be obtained using another
client-server application called the Domain Name System (DNS).
▪ DNS acts as directory in the internet. It maps the server name to the IP
address of the computer running that server.
• Pair of processes need to use the services provided by the transport layer for
communication because there is no physical communication at the application
layer.
• There are three common transport-layer protocols in the TCP/IP suite: UDP,
TCP, and SCTP.
UDP Protocol
TCP Protocol
SCTP Protocol
SCTP provides a service which is a combination of the two other protocols. Like
TCP, SCTP provides a connection-oriented, reliable service, but it is not byte
stream oriented. It is a message-oriented protocol like UDP.
• The received and queued requests are handled in the first-in, first-out fashion.
• In UDP communication, the client and server use only one socket each. The
socket created at the server site lasts forever; the socket created at the client site
is closed (destroyed) when the client process terminates.
• Figure 5.7 shows the lifetime of the sockets in the server and client processes.
Flow Diagram
UDP provides a connectionless service, in which a client sends a request and the
server sends back a response. Figure 5.8 shows a simplified flow diagram for
iterative communication.
▪ There are multiple clients, but only one server. Each client is served in each
iteration of the loop in the server.
The TCP server uses two different sockets, one for connection establishment and
the other for data transfer.
We call the first one the listen socket and the second the socket. The reason
for having two types of sockets is to separate the connection phase from the data
exchange phase.
Flow Diagram
Figure 5.10 shows a simplified flow diagram for iterative communication using
TCP. There are multiple clients, but only one server.
• A concurrent server can process several client requests at the same time. This
can be done using the available provisions in the underlying programming
language.
• In C, a server can create several child processes, in which a child can handle a
client.
▪ The idea of the Web was first proposed by Tim Berners-Lee in 1989 at CERN, the
European Organization for Nuclear Research.
▪ The Web today is a repository of information in which the documents, called web
pages, are distributed all over the world and related documents are linked
together
▪ The popularity and growth of the Web can be related to two terms in the above
statement: distributed and linked.
▪ Linking allows one web page to refer to another web page stored in another
server
▪ The linking of web pages was achieved using a concept called hypertext
▪ The term hypertext, coined, has been changed to hypermedia, to show that a
web page can be a text document, an image, an audio file, or a video file.
ARCHITECTURE
▪ The service provided is distributed over many locations called sites. Each site
holds one or more web pages
▪ A web page can be simple or composite. A simple web page has no links to
other web pages; a composite web page has one or more links to other web
pages. Each web page is a file with a name and address.
WORLD WIDE WEB
▪ The main document and the image are stored in two separate files (file A and file
B) in the same site; the referenced text file (file C) is stored in another site.
▪ Since we are dealing with three different files, we need three transactions if we
want to see the whole document.
▪ The first transaction retrieves a copy of the main document (file A), which has
references (pointers) to the second and third files.
▪ When a copy of the main document is retrieved and browsed, the user can click
on the reference to the image to invoke the second transaction and retrieve a
copy of the image (file B).
▪ If the contents of the referenced text file need to be viewed, the user can click
on its reference (pointer) invoking the third transaction and retrieving a copy of
file C.
▪ A very important point we need to remember is that file A, file B, and file C are
independent web pages, each with independent names and addresses.
WORLD WIDE WEB
Browsers usually interpret and display a web page. Each browser usually consists of
three parts: a controller, client protocols, and interpreters as in the figure
5.12
▪ The controller receives input from the keyboard or the mouse and uses the client
programs to access the document.
▪ After the document has been accessed, the controller uses one of the interpreters
to display the document on the screen.
▪ The client protocol can be one of the protocols such as HTTP or FTP. The
interpreter can be HTML, Java, or JavaScript, depending on the type of document.
Web Server
▪ The web page is stored at the server. Each time a request arrives, the
corresponding document is sent to the client. To improve efficiency, servers
normally store requested files in a cache in memory; memory is faster to access
than a disk.
▪ Some popular web servers include Apache and Microsoft Internet Information
Server.
WORLD WIDE WEB
• To define a web page, we need three identifiers: host, port, and path.
• However, before defining the web page, we need to tell the browser what client-
server application we want to use, which is called the protocol.
Protocol: The first identifier is the abbreviation for the client-server program that
we need in order to access the web page. Although most of the time the protocol
is HTTP but FTP can also be used.
Host: The host identifier can be the IP address of the server or the unique name
given to the server. IP addresses can be defined in dotted decimal notation.
Port: The port, a 16-bit integer, is normally predefined for the client-server
application. For example, if the HTTP protocol is used for accessing the web page,
the well-known port number is 80
Path: The path identifies the location and the name of the file in the underlying
operating system. The format of this identifier normally depends on the operating
system.
Web Documents
The documents in the WWW can be grouped into three broad categories: static,
dynamic, and active.
Static Documents
• Static documents are fixed-content documents that are created and stored in a
server. The client can get a copy of the document only.
WORLD WIDE WEB
• Static documents are prepared using one of several languages: Hypertext Markup
Language (HTML), Extensible Markup Language (XML), Extensible Style Language
(XSL), and Extensible Hypertext Markup Language (XHTML).
Dynamic Documents
• A very simple example of a dynamic document is the retrieval of the time and
date from a server.
• Although the Common Gateway Interface (CGI) was used to retrieve a dynamic
document in the past, today’s options include one of the scripting languages such
as Java Server Pages (JSP), which uses the Java language for scripting, or Active
Server Pages (ASP), a Microsoft product that uses Visual Basic language for
scripting.
Active Documents
• For many applications, we need a program or a script to be run at the client site.
These are called active documents.
• One way to create an active document is to use Java applets, a program written
in Java on the server.
HTTP
• The HyperText Transfer Protocol (HTTP) is used to define how the client-server
programs can be written to retrieve web pages from the Web.
• An HTTP client sends a request; an HTTP server returns a response. The server
uses the port number 80; the client uses a temporary port number. HTTP uses the
services of TCP, which is a connection-oriented and reliable protocol.
• This means that, before any transaction between the client and the server can
take place, a connection needs to be established between them. After the
transaction, the connection should be terminated.
• However, if some of the objects are located on the same server, we have two
choices: to retrieve each object using a new TCP connection or to make a TCP
connection and retrieve them all.
3. The client reads the data until it encounters an end-of-file marker; it then closes
the connection
HTTP
Persistent Connections
• The server can close the connection at the request of a client or if a time-out has
been reached.
• Time and resources are saved using persistent connections. Only one set of
buffers and variables needs to be set for the connection at each site. The round
trip time for connection establishment and connection termination is saved.
HTTP
Message Formats
The HTTP protocol defines the format of the request and response messages, as
shown in Figure 5.15
In figure 5.15, We have two formats next to each other for comparison. Each
message is made of four sections. The first section in the request message is called
the request line; the first section in the response message is called the status
line.
▪ HTTP supports proxy servers. A proxy server is a computer that keeps copies of
responses to recent requests.
▪ The HTTP client sends a request to the proxy server. The proxy server checks its
cache. If the response is not stored in the cache, the proxy server sends the
request to the corresponding server.
▪ Incoming responses are sent to the proxy server and stored for future requests
from other clients.
▪ The proxy server reduces the load on the original server, decreases traffic, and
improves latency. However, to use the proxy server, the client must be configured
to access the proxy instead of the target server.
The proxy servers are normally located at the client site. This means that we can
have a hierarchy of proxy servers, as shown below:
1. A client computer can also be used as a proxy server, in a small capacity, that
stores responses to requests often invoked by the client.
3. An ISP with many customers can install a proxy server to reduce the load going
out of and coming into the ISP network.
HTTP
Cache Update
▪ A very important question is how long a response should remain in the proxy
server before being deleted and replaced.
▪ One solution is to store the list of sites whose information remains the same for a
while.
▪ The proxy server can then use the information in this header to guess how long
the information would be valid.
HTTP Security
▪ HTTP does not provide security but it can be run over the Secure Socket Layer
(SSL).
▪ 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.
▪ 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).
Figure 5.17 shows how TCP/IP uses a DNS client and a DNS server to map a name
to an address.
A user wants to use a file transfer client to access the corresponding file transfer
server running on a remote host. The user knows only the file transfer server name.
However, the TCP/IP suite needs the IP address of the file transfer server to make
the connection. 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. Each computer, after being booted, knows the address of one DNS server. 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 server 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
▪ A name space maps each address to a unique name that can be organized in two
ways: flat or hierarchical.
▪ 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. In this case,
the authority to assign and control the name spaces can be decentralized.
DOMAIN NAME SYSTEM (DNS)
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 as in figure 5.18
Label
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).
Domain Name
Each node in the tree has a domain name. A full domain name is a sequence of
labels separated by dots (.). Figure 5.19 shows some Domain names
The domain names are always read from the node up to the root. The last label is
the label of the root (null).
Domain
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. Figure 5.20 shows some domains.
Note that a domain may itself be divided into domains.
The information contained in the domain name space must be stored. However, it
is very inefficient and also not reliable to have just one computer store such a
huge amount of information.
Zone
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.
Root Server
A root server is a server whose zone consists of the whole tree. A root server
usually does not store any information about domains but delegates its authority
to other servers, keeping references to those servers. The root servers are
distributed all around the world.
▪ 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 primary server loads all information from the disk file; the secondary
server loads all information from the primary server.
In the Internet, the domain name space (tree) was originally divided into three
different sections: generic domains, country domains, and the inverse
domains. ( The inverse domains are now deprecated)
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 (Figure 5.23).
DOMAIN NAME SYSTEM (DNS)
Country Domains
The country domains section uses two-character country abbreviations (e.g., us for
United States). Figure 5.24 shows the country domains section. The address
uci.ca.us. can be translated to University of California, Irvine, in the state of
California in the United States.
Resolution
A host that needs to map an address to a name or a name to an address calls a DNS
client called a resolver.
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. Figure 5.26 shows
the flow of information in an iterative resolution in the same scenario as the one
depicted in Figure 5.25.
Caching
Each time a server receives a query for a name that is not in its domain, it needs to
search its database for a server IP address. Reduction of this search time would
increase efficiency. DNS handles this with a mechanism called caching.
▪ When a server asks for a mapping from another server and receives the response,
it stores this information in its cache memory before sending it to the client.
▪ If a server caches a mapping for a long time, it may send an outdated mapping to
the client. To counter this, two techniques are used. First, the authoritative server
always adds information to the mapping called time to live (TTL).
▪ Second, DNS requires that each server keep a TTL counter for each mapping it
caches.
Resource Records
The value defines the information kept about the domain name.
The TTL defines the number of seconds for which the information is valid.
DNS Messages
To retrieve information about hosts, DNS uses two types of messages: query and
response. Both types have the same format as shown in Figure 5.27.
DOMAIN NAME SYSTEM (DNS)
• The identification field is used by the client to match the response with the query.
• The flag field defines whether the message is a query or response. It also
includes status of error. The next four fields in the header define the number of
each record type in the message.
• The answer section consists of one or more resource records. It is present only in
response messages.
• The authoritative section gives information (domain name) about one or more
authoritative servers for the query.
• The additional information section provides additional information that may help
the resolver.
Encapsulation
DNS can use either UDP or TCP. In both cases the well-known port used by the
server is port 53.
UDP is used when the size of the response message is less than 512 bytes. If the
size of the response message is more than 512 bytes, a TCP connection is used.
DOMAIN NAME SYSTEM (DNS)
Registrars
DDNS
• In DNS, when there is a change, such as adding a new host, removing a host, or
changing an IP address, the change must be made to the DNS master file.
• These types of changes involve a lot of manual updating. The size of today’s
Internet does not allow for this kind of manual operation. The DNS master file
must be updated dynamically. The Dynamic Domain Name System (DDNS)
therefore was devised to respond to this need.
Security of DNS
1. The attacker may read the response of a DNS server to find the nature or names
of sites the user mostly accesses.
2. The attacker may intercept the response of a DNS server and change it or create
a totally new bogus response to direct the user to the site or domain the attacker
wishes the user to access.
3. The attacker may flood the DNS server to overwhelm it or eventually crash it. This
type of attack can be prevented using the provision against denial-of-service
attack.
To protect DNS, IETF has devised a technology named DNS Security (DNSSEC)
that provides message origin authentication and message integrity using a
security service called digital signature.
5.6 ELECTRONIC MAIL
ELECTRONIC MAIL
▪ Here two message transfer agents are needed: one client and one server.
▪ Like most client-server programs on the Internet, the server needs to run all the
time because it does not know when a client will ask for a connection.
▪ The client, on the other hand, can be triggered by the system when there is a
message in the queue to be sent.
▪ The user agent at the Bob site allows Bob to read the received message. Bob
later uses an MAA client to retrieve the message from an MAA server running on
the second server.
User Agent
The first component of an electronic mail system is the user agent (UA).
▪ It provides service to the user to make the process of sending and receiving a
message easier.
▪ A user agent is a software package (program) that composes, reads, replies to,
and forwards messages. It also handles local mailboxes on the user computers.
Command driven user agents belong to the early days of electronic mail
A command-driven user agent normally accepts a one character command from the
keyboard to perform its task.
For example, a user can type the character r, at the command prompt, to reply to the
sender of the message, or type the character R to reply to the sender and all recipients.
Sending Mail
▪ To send mail, the user, through the UA, creates mail that looks very similar to postal
mail. It has an envelope and a message.
▪ The envelope usually contains the sender address, the receiver address, and other
information.
▪ The message contains the header and the body.
▪ The header of the message defines the sender, the receiver, the subject of the message,
and some other information. The body of the message contains the actual information to
be read by the recipient.
Receiving Mail
▪ The user agent is triggered by the user (or a timer). If a user has mail, the UA informs
the user with a notice.
▪ If the user is ready to read the mail, a list is displayed in which each line contains a
summary of the information about a particular message in the mail box.
▪ The summary usually includes the sender mail address, the subject, and the time the mail
was sent or received. The user can select any of the messages and display its contents
on the screen.
Addresses
▪ To deliver mail, a mail handling system must use an addressing system with unique
addresses.
▪ In the Internet, the address consists of two parts: a local part and a domain name,
separated by an @ sign
▪ The local part defines the name of a special file, called the user mailbox, where all the
mail received for a user is stored for retrieval by the message access agent.
▪ The second part of the address is the domain name. An organization usually selects one
or more hosts to receive and send e-mail; they are sometimes called mail servers or
exchangers.
▪ The domain name assigned to each mail exchanger either comes from the DNS database
or is a logical name.
Mailing List or Group List
▪ 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.
Message Transfer Agent: SMTP
▪ An e-mail is one of those applications that needs three uses of client-server paradigms to
accomplish its task.
▪ We refer to the first and the second as Message Transfer Agents (MTAs), the third as
Message Access Agent (MAA).
▪ 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 and between
the two mail servers.
▪ Another protocol is needed between the mail server and the receiver.
▪ SMTP simply defines how commands and responses must be sent back and forth.
ELECTRONIC MAIL
Responses
Responses are sent from the server to the client. A response is a three digit code
that may be followed by additional textual information. Table below shows the most
common response types. Table 5.2: Responses
Code Description
Connection Establishment
After a client has made a TCP connection to the wellknown 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. This step is necessary 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
After connection has been established between the SMTP client and server, a single
message between a sender and one or more recipients can be exchanged.
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.
ELECTRONIC MAIL
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. Each line is terminated
by a two-character end-of-line token (carriage return and line feed). 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.
2. The server responds with code 221 or some other appropriate code.
▪ However, SMTP is not involved in the third stage because SMTP is a push protocol; it
pushes the message from the client to the server.
▪ In other words, the direction of the bulk data (messages) is from the client to the server.
▪ On the other hand, the third stage needs a pull protocol; the client must pull messages
from the server. The direction of the bulk data is from the server to the client. The third
stage uses a message access agent.
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 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.
IMAP4
Another mail access protocol is 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:
1. A user can check the e-mail header prior to downloading.
2. A user can search the contents of the e-mail for a specific string of characters
prior to downloading.
3. 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.
4. A user can create, delete, or rename mailboxes on the mail server.
5. A user can create a hierarchy of mailboxes in a folder for e-mail storage.
MIME
Electronic mail has a simple structure. Its simplicity, however, comes with a price. It
can send messages only in NVT 7-bit ASCII format.
In other words, it has some limitations. It cannot be used for languages other than
English (such as French, German, Hebrew, Russian, Chinese, and Japanese). Also, 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 to the client MTA to be sent through the Internet.
▪ The message at the receiving site is transformed back to the original data.
MIME defines five headers, as shown in Figure below which can be added to the
original e-mail header section to define the transformation parameters:
MIME-Version
This header defines the version of MIME used. The current version is 1.1.
Content-Type
This header defines the type of data used in the body of the message. The content
type and the content subtype are separated by a slash. Depending on the subtype,
the header may contain other parameters.
MIME allows seven different types of data, listed in Table in next page:
ELECTRONIC MAIL
Plain Unformatted
Text
HTML HTML format
Body contains ordered parts of different
Mixed
data types
Parallel Same as above, but no order
Multipart Similar to Mixed, but the default is
Digest
message/RFC822
Alternative Parts are different versions of the same
message
RFC822 Body is an encapsulated message
Message Partial Body is a fragment of a bigger message
External-Body Body is a reference to another message
JPEG Image is in JPEG format
Image
GIF Image is in GIF format
Video MPEG Video is in MPEG format
Content-Transfer-Encoding
This header defines the method used to encode the messages into 0s and 1s for
transport. The five types of encoding methods are listed in Table
The last two encoding methods are interesting. In the Base64 encoding, data, as a
string of bits, is first divided into 6-bit chunks as shown in Figure
▪ Base64 is a redundant encoding scheme; that is, every six bits become one
ASCII character and are sent as eight bits. We have an overhead of 25 percent.
▪ If the data consist mostly of ASCII characters with a small non-ASCII portion, we
can use quoted-printable encoding.
Content-ID
This header uniquely identifies the whole message in a multiple message
environment.
Content-Description
This header defines whether the body is image, audio, or video.
********************************************************************
5.7 INTRODUCTION TO PEER TO
PEER NETWORKS
INTRODUCTION TO P2P NETWORKS
• Internet users that are ready to share their resources become peers and form a
network.
• When a peer in the network has a file (for example, an audio or video file) to
share, it makes it available to the rest of the peers.
• An interested peer can connect itself to the computer where the file is stored and
download it.
• After a peer downloads a file, it can make it available for other peers to download.
• As more peers join and download that file, more copies of the file become
available to the group.
• Since lists of peers may grow and shrink, to keeps track of loyal peers and the
location of the files. we first need to divide the P2P networks into two categories:
Centralized Networks
• In a centralized P2P network, the directory system ⎯ listing of the peers and what
they offer ⎯ uses the client-server paradigm, but the storing and downloading of
the files are done using the peer-to-peer paradigm. For this reason, a centralized
P2P network is sometimes referred to as a hybrid P2P network.
• A peer, looking for a particular file, sends a query to a central server. The server
searches its directory and responds with the IP addresses of nodes that have a
copy of the file.
• The peer contacts one of the nodes and downloads the file. The directory is
constantly updated as nodes join or leave the peer.
INTRODUCTION TO P2P NETWORKS
• Centralized networks make the maintenance of the directory simple but have
several drawbacks.
• Accessing the directory can generate huge traffic and slow down the system. The
central servers are vulnerable to attack, and if all of them fail, the whole system
goes down.
Decentralized Network
Unstructured networks
Gnutella
• When node A wants to access an object (such as a file), it contacts one of its
neighbors. A neighbor, in this case, is any node whose address is known to node
A.
• Node A sends a query message to the neighbor, node W. The query includes the
identity of the object (for example, file name).
• If node W knows the address of node X, which has the object, it sends a response
message that includes the address of node X.
• Node A now can use the commands defined in a transfer protocol such as HTTP
to get a copy of the object from node X.
• If node W does not know the address of node X, it floods the request from A to
all its neighbors.
• Eventually one of the nodes in the network responds to the query message, and
node A can get access to node X.
• One of the problems with the Gnutella network is the lack of scalability because of
flooding. To make the query more efficient, the new version of Gnutella
implemented a tiered system of ultra nodes and leaves.
• A node entering into the network is a leaf, not responsible for routing; nodes
which are capable of routing are promoted to ultra nodes.
Structured Networks
A structured network uses a predefined set of rules to link nodes so that a query
can be effectively and efficiently resolved. The most common technique used for
this purpose is the Distributed Hash Table (DHT).
A Distributed Hash Table (DHT) distributes data among a set of nodes according
to some predefined rules. Each peer in a DHT-based network becomes
responsible for a range of data items.
DHT-based networks allow each peer to have a partial knowledge about the whole
network to avoid the flooding overhead.
Address Space
In a DHT-based network, each data item and the responsible peer is mapped to a
point in a large address of size 2m. The address space is distributed evenly on a
circle with 2m points (0 to 2m − 1) using clockwise direction as shown in Figure
5.37. Most of the DHT implementations use m = 160.
The first step in creating the DHT system is to place all peers on the address space
ring. This is normally done by using a hash function that hashes the peer identifier,
normally its IP address, to an m-bit integer, called a node ID.
The name of the object (a file) to be shared is also hashed to an m-bit integer in the
same address space. The result in DHT parlance is called a key.
There are two strategies for storing the object: the direct method and the
indirect method.
In the direct strategy, we create a relationship between the node ID that stores the
object and the key of the object; in the indirect strategy, we create a relationship
between the reference (pointer) to the object and the node that stores that
reference.
Routing
DHT’s main function is to route a query to the node responsible for storing the
reference to an object.
A DHT implementation needs to have a clear and efficient strategy to handle arrival
or departure of the nodes and the effect of this on the rest of the peers. Most DHT
implementations treat the failure of a node as a departure.
5.8 Simple Network
Management Protocol (SNMP)
Simple Network Management Protocol (SNMP)
INTRODUCTION
If an organization has 1000 devices then to check all devices, one by one every day, are
working properly or not is a hectic task. To ease these up, a Simple Network Management
Protocol (SNMP) is used
SNMP is an application layer protocol that uses UDP port number 161/162.SNMP is used to
monitor the network, detect network faults, and sometimes even to configure remote
devices.
Components of SNMP
There are mainly three components of SNMP:
1. SNMP Manager –
It is a centralized system used to monitor the network. It is also known as a Network
Management Station (NMS). A router that runs the SNMP server program is called an agent,
while a host that runs the SNMP client program is called a manager.
2. SNMP agent –
It is a software management software module installed on a managed device. The manager
accesses the values stored in the database, whereas the agent maintains the information in
the database. To ascertain if the router is congested or not, for instance, a manager can
examine the relevant variables that a router stores, such as the quantity of packets received
and transmitted.
SNMP messages
• GetNextRequest : To get the value of a variable, the manager sends the agent
the GetNextRequest message. The values of the entries in a table are retrieved
using this kind of communication. The manager won’t be able to access the
values if it doesn’t know the entries’ indices. The GetNextRequest message is
used to define an object in certain circumstances.
• Trap : These are the message sent by the agent without being
requested by the manager. It is sent when a fault has occurred.
Versions of SNMP
There are three versions of SNMP including the below ones:
1. SNMPv1 –
It uses community strings for authentication and uses UDP only. SNMPv1
is the first version of the protocol. It is described in RFCs 1155 and 1157
and is simple to set up.
2. SNMPv2c –
It uses community strings for authentication. It uses UDP but can be
configured to use TCP. Improved MIB structure elements, transport
mappings, and protocol packet types are all included in this updated
version. However, it also makes use of the current “community-based”
SNMPv1 administrative structure, which is why the version is called
SNMPv2c. RFC 1901, RFC 1905, and RFC 1906 all describe it.
3. SNMPv3 –
It uses Hash-based MAC with MD5 or SHA for authentication and DES-56
for privacy. This version uses TCP. Therefore, the conclusion is the higher
the version of SNMP, the more secure it will be. NMPv3 provides the
remote configuration of SNMP entities. This is the most secure version to
date because it also includes authentication and encryption, which may be
used alone or in combination. RFC 1905, RFC 1906, RFC 2571, RFC 2572,
RFC 2574, and RFC 2575.6 are the RFCs for SNMPv3.
Advantages of SNMP
• 1. It is simple to implement.
• 2. Agents are widely implemented.
• 3. Agent level overhead is minimal.
• 4. It is robust and extensible.
• 5. Polling approach is good for LAN based managed object.
• 6. It offers the best direct manager agent interface.
• 7. SNMP meet a critical need.
Limitation of SNMP
• 1. It is too simple and does not scale well.
• 2. There is no object orietned data view.
• 3. It has no standard control definition.
• 4. It has many implementation specific (private MIB) extensions.
• 5. It has high communication overhead due to polling
File Transfer Protocol (FTP)
The above figure shows the basic model of the FTP. The FTP client has three
components: the user interface, control process, and data transfer process.
The server has two components: the server control process and the server
data transfer process.
• It is designed to forward some packets and filter others. Figure 5.39 shows a
firewall.
• For example, a firewall may filter all incoming packets destined for a specific host
or a specific server such as HTTP.
• A firewall can be used to deny access to a specific host or a specific service in the
organization.
Packet-Filter Firewall
A firewall can be used as a packet filter. It can forward or block packets based on
the information in the network-layer and transport-layer headers: source and
destination IP addresses, source and destination port addresses, and type of
protocol (TCP or UDP).
FIREWALLS
2. Incoming packets destined for any internal TELNET server (port 23) are blocked.
3. Incoming packets destined for internal host 194.78.20.8 are blocked. The
organization wants this host for internal use only.
4. Outgoing packets destined for an HTTP server (port 80) are blocked. The
organization does not want employees to browse the Internet.
Proxy Firewall
• The packet-filter firewall is based on the information available in the network layer
and transport layer headers (IP and TCP/UDP). However, sometimes we need to
filter a message based on the information available in the message itself (at the
application layer).
• When the user client process sends a message, the application gateway runs a
server process to receive the request.
• The server opens the packet at the application level and finds out if the request is
legitimate. If it is, the server acts as a client process and sends the message to
the real server in the corporation.
• If it is not, the message is dropped and an error message is sent to the external
user. In this way, the requests of the external users are filtered based on the
contents at the application layer. Figure 5.41 shows an application gateway
implementation for HTTP.
No Assignments Course K-
Outcome Level
1 Assume there is a server with the domain name CO5 K4
www.common.com.
a. Show an HTTP request that needs to retrieve
the document /usr/users/doc.
The client accepts MIME version 1, GIF or JPEG
images, but the document should not be more
than 4 days old.
b. Show the HTTP response to part a for a
successful request.
2. In HTTP, draw a figure to show the application of CO5 K3
cookies in a scenario in which the server allows
only the registered customer to access the server.
No Assignment Course K-
Outcome Level
9. Write a method in Java to accept a string CO5 K4
representing an IP address in the form “x.y.z.t”
and change it to an unsigned integer.
10. Write a method in Java to extract the prefix of an CO5 K4
address (as an integer) given a string
representing a CIDR notation in the form
“x.y.z.t/n”.
Part A Q & A (With K - Level and CO)
Part-A Q & Ans
Course
Q.No Question K-Level
Outcome
1. What is the mail transfer protocol used in the CO5 K2
Internet?
20 Define MIME.
____________________________________________________________________
2 First internal
Assessment Test 23.08.24
4 Second Internal
Assessment Test 04.10.24
Project - 1
Objective:
To use HTTPS in this Project and capture the packet with Wireshark and to examine
the contents of the SSL/TLS packets when used with HTTPS.
Description:
HTTP, the protocol used to access web pages from the Internet. HTTP per se does
not provide security. However, we can combine HTTP and SSL/TLS to add security to
HTTP. The new protocol is called HyperText Transfer Protocol Secure (HTTPS).
(Generate the report for this examined SSL/TLS Packets when using HTTPS.)
______________________________________________________________________
_
Project - 2
Dictionary Bot
Objective:
To develop the Dictionary bot on the programming language of your choice.
Description:
English words and its meanings can be updated in the Bot and Search option for the
user can be enabled for different words. Choose the programming language of your
choice to develop the project.
____________________________________________________________________
120
Projects to be Carried out
Project - 3
Objective:
To Detect the Flood and alert the public using IOT sensor Technology.
Description:
To detect a flood the system observes various natural factors, which includes
humidity, temperature, water level and flow level. To collect data of mentioned
natural factors the system consist of different sensors which collects data for
individual parameters.
___________________________________________________________________
Project – 4
SMART HOME AUTOMATION SYSTEM
Description:
implement a entire home automation system controlled by an raspberrypi board and
demonstrate the automation process with simple home appliances.
121
Thank you
Disclaimer:
This document is confidential and intended solely for the educational purpose of RMK Group of
Educational Institutions. If you have received this document through email in error, please notify the
system manager. This document contains proprietary information and is intended only to the
respective group / learning community as intended. If you are not the addressee you should not
disseminate, distribute or copy through e-mail. Please notify the sender immediately by e-mail if you
have received this document by mistake and delete this document from your system. If you are not
the intended recipient you are notified that disclosing, copying, distributing or taking any action in
reliance on the contents of this information is strictly prohibited.
122