Friday, December 20, 2024 10:44 AM
application layer protocol
topic: application layer
(i) email (electronic mail)
pull(pop or imap-4)
push(smtp) download
push(smtp)
push(smtp) pull(pop or imap-4)
push(smtp)
"smtp" transfer the mail from sender's mail server to receiver's mail server.
while sending the mail ,"smtp" is used two times:
(i) between the sender and sender's mail server
(ii) between the sender's mail server and receiver's mail server
to receive or download the email:
- another protocol is needed between the receiver mail server and receiver.
the most commonly used protocols are "pop3" and "imap4".
concept: "smtp" (simple mail transfer protocol)
message transfer agent
Chapter - 10 (Application layer protocol) Page 1
(i) the objective of smtp is to transfer the email reliably and efficiently.
(ii) it uses port number 25 at tcp.
(iii) in smtp there are two components:
- user agent (ua)
- mail transfer agent (mta)
(iv) user agent prepares the message, creates the envelope, and puts the message in the envelope.
(v) mail transfer agent transfers the mail across the internet, i.e., actual mail transfer is done through mta.
(vi) to send mail, the system must have a client mta, and to receive the mail, it must have a server mta.
(vii) smtp is a text-based protocol.
(viii) with the help of smtp and pop, we can send only text messages.
(ix) smtp can only handle the message containing 7-bit ascii text.
(x) smtp cannot transfer other types of data like images, video, audio, etc.
(xi) smtp cannot transfer binary files or executable files.
(xi) smtp cannot transfer the text data for languages other than english (such as french, japanese, and
chinese etc.).
(xii) only smtp is not sufficient to send binary files or to send videos or audio, so we require mime
(multipurpose internet mail extension).
(xiii) mime is a supplementary protocol that allows non-ascii data to be sent through smtp.
(xiv) mime is a set of software functions that transforms non-ascii data to ascii data or vice versa.
Chapter - 10 (Application layer protocol) Page 2
(xiv) mime is a set of software functions that transforms non-ascii data to ascii data or vice versa.
(xv) mime is used to convert non-text data to text data and text data to non-text data.
(xvi) smtp is a stateless protocol. it does not maintain any information about the user. if an email is asked to
be sent twice, the server resends it without saying that the email has already been sent.
(xvii) smtp is a connection-oriented protocol.
(xviii) smtp uses persistent tcp connections, so it can send multiple emails at once.
(xix) smtp is an "in-band" protocol.
(xx) smtp is used for pushing the email.
(xxi) smtp pushes the mail from client to server; on the other hand, it needs a pull protocol (download).
(xxii) pop3 and imap4 are used for pulling the email.
- pop3 (post office protocol version 3)
- imap4 (internet mail access protocol version 4)
point to remember:
transfer the message from sending mail server to receiving mail server is done through "smtp". finally the
message from receiving server to web browser is done through "http" only.
concept: in-band and out-band communication
(i) in-band communication
communication that occurs over the same channel or pathway as the main data or primary
communication.
- shared channel: both control signals (e.g., commands, configuration data) and operational data are
sent over the same medium.
(ii) out-of-band communication
communication that occurs over a separate, dedicated channel distinct from the primary data
communication.
- dedicated channel: control, management, or signaling data is sent via a different medium or
connection than the operational data.
concept: pop3 (post office protocol version-3)
Chapter - 10 (Application layer protocol) Page 3
(i) it is a message access protocol.
(ii) it is a pull protocol.
(iii) pop3 uses port number 110 at tcp.
(iv) pop3 is a connection-oriented protocol.
(v) pop3 uses persistent tcp connection.
(vi) pop3 is a stateful protocol.
(vii) pop3 is an "in-band" protocol.
(viii) pop3 does not allow users to partially check the content of the mail before downloading.
(ix) pop3 does not allow users to organize the mail on the mail server.
- pop3 modes:
delete mode: the mail is deleted from the mailbox after each retrieval.
keep mode: the mail remains in the mailbox after retrieval.
concept: imap-4 (internet mail access protocol version-4)
imap-4 is similar to pop3 but has more features; it is more powerful and complex.
- additional features of imap-4:
(i) users can check the email header prior to downloading.
(ii) users can search the content of the email for specific strings or characters before downloading.
(iii) users can partially download emails.
(iv) users can create, delete, or rename mailboxes on the mail server.
(v) users can create a hierarchy of mailboxes in folders for email storage.
- characteristics of imap:
(i) imap is a pull protocol.
(ii) imap uses port number 143 at tcp.
(iii) imap is a connection-oriented protocol.
(iv) imap uses persistent tcp connection.
(v) imap is a stateful protocol.
(vi) imap is an "in-band" protocol.
difference between imap-4 and pop-3
Chapter - 10 (Application layer protocol) Page 4
(i) if we are using pop-3
(mobile)
push(smtp) - once the mail is downloaded from
pull(pop or imap-4)
mobile, the mail copy will be
push(smtp)
deleted from server and there will
be no way to access the mail from
laptop.
mail stored here (laptop)
(ii) if we are using imap-4
(mobile) - once the mail is downloaded from
push(smtp) mobile, it will be downloaded in
laptop automatically because imap-4
pull(pop or imap-4)
push(smtp) is a synchronized protocol.
synchronized
- the copy does not delete
mail stored here (laptop)
automatically.
concept: base64 encoding
(xy)64
Chapter - 10 (Application layer protocol) Page 5
(xy)64
x: 0-63
y: 0, 63
6bit:
000000: 0
.
.
.
111111: 63
any text data converts into base 64 encoding by smtp.
Chapter - 10 (Application layer protocol) Page 6
text data : "A n d"
(i) converts to ASCII
A n d
65 110 100
(ii) write in 8bit
A n d
65 110 100
01000001 01101110 01100100
(iii) base64 (0-63)
write in 6bit
A n d
65 110 100
01000001 01101110 01100100
(8bit) (8bit) (8bit)
010000 010110 111001 100100
(6bit) (6bit) (6bit) (6bit)
(iv)base64 encoding
A n d
65 110 100
Chapter - 10 (Application layer protocol) Page 7
A n d
65 110 100
01000001 01101110 01100100
(8bit) (8bit) (8bit)
010000 010110 111001 100100
(6bit) (6bit) (6bit) (6bit)
16 22 57 36
Q W 5 k
"A n d" base64 encoding QW5k
(input) (output)
text data : "g"
(i) converts to ASCII
g
103
(ii) write in 8bit
g
103
01100111
(8bit)
(iii) base64 (0-63)
write in 6bit
103
01100111
(8bit)
011001 110000
(6bit) (6bit)
(iv)base64 encoding
Chapter - 10 (Application layer protocol) Page 8
103
01100111
(8bit)
011001 110000 add padding
(6bit) (6bit)
a
25 48
Q W
- add padding:
since the original input was only one character (8 bits), the base64 encoding requires two
padding characters (=,=) to make the output a multiple of 6 bits.
therefore, the complete base64 encoded representation of "g" is "Zw=="
011001 110000 000000 000000
6bits 6bits 6bits 6bits
Z w = =
smtp commands:
Chapter - 10 (Application layer protocol) Page 9
concept: domain name system (dns)
Chapter - 10 (Application layer protocol) Page 10
(i) easy to remember the domain names
(ii) ip addreses are not static (location change-ip change)
(iii) dns protocol is used to convert domain name to ip address.
Chapter - 10 (Application layer protocol) Page 11
root server
root DNS server
tld server
com DNS server org DNS server edu DNS server
[Link] DNS amazon. com [Link] DNS [Link] DNS [Link] DNS
server DNS server server server server
authoritative server
there are many websites in the entire world
how the database of the website is organised that i can search any website within few seconds?
- distributed database.
root DNS server have infomation of top level domain server
com, edu, org
tld server have infomation of authoritative server
[Link]
Chapter - 10 (Application layer protocol) Page 12
[Link]
request goes to root dns server :
- dns dont have ip address but it can help you regarding edu dns server
- dns server can give ip address of edu dns server at tld server.
- when you request from tld server it does not have information of [Link] but can help with iisc server
(authoritaitve server)
- in this server a list is being maintained (domain name, ip address, validity)
iterative queries
root DNS server
host local DNS server top level DNS server
authoritative DNS server
accessing for the first time : [Link]
(i) request goes to local dns server, if info available in local dns(local dns server saves the address for a
limited amount of time that we are frequently accessing) it will give but we are accessing for the first
time.
Chapter - 10 (Application layer protocol) Page 13
root DNS server
host local DNS server top level DNS server
authoritative DNS server
(ii) request goes to root dns server, dns server have info regarding edu (gives the ip address of edu)
root DNS server
host local DNS server top level DNS server
authoritative DNS server
(iii) local dns server request goes to top level dns server (no ip. address of [Link] but can help
regarding iisc server)
root DNS server
host local DNS server top level DNS server
authoritative DNS server
(iv) local dns server request goes to authoriative dns (it have list of domain name, ip address, validity so
it sends the ip address to local dns server)
root DNS server
Chapter - 10 (Application layer protocol) Page 14
root DNS server
host local DNS server top level DNS server
authoritative DNS server
(v) local dns server gives ip address to host
root DNS server
host local DNS server top level DNS server
authoritative DNS server
accessing for the second time : [Link]
- request goes to local dns server, if info available in local dns(local dns server saves the address for a
limited amount of time that we are frequently accessing) it will give because we are accessing it for
second time in short period.
root DNS server
host local DNS server top level DNS server
authoritative DNS server
recursive queries
Chapter - 10 (Application layer protocol) Page 15
it does not directly reply to local dns server
root DNS server
host local DNS server top level DNS server
authoritative DNS server
access:
- local dns server contact to root dns server.
- root dns server contact to top level dns server.
- top level dns server contact to authoritative dns server.
root DNS server
host local DNS server top level DNS server
authoritative DNS server
Chapter - 10 (Application layer protocol) Page 16
reply:
- local dns server contact to root dns server.
- root dns server contact to top level dns server.
- authoritative dns server replies to
root DNS server
host local DNS server top level DNS server
authoritative DNS server
root DNS server:
root name servers play a key role in resolving any dns query. there are 13 root name servers
worldwide. if a situation arises that the entire 13 root name servers are unreachable, the internet
would fail. usually a host sends a query to-its-nearest-root-name-server. if any one of these
servers fails the requests are diverted to another nearest server.
example: if you are in india the nearest root name server is at tokyo. if the root name server at
tokyo is down, all the DNS queries or traffic is diverted to server at europe, which is the next
nearest server to india.
point to remember:
- by default DNS uses udp at transport layer.
- DNS can use either UDP or TCP.
- in both cases the well known port number used by the server is port number- 53.
- DNS query size<512 byte: UDP
- DNS query byte>512 byte: TCP
concept: file transfer protocol (ftp)
(i) ftp is a standard internet protocol used for transferring files between computers over a tcp/ip
connection.
(ii) it uses port numbers 20 (data connection) and 21 (control connection).
(iii) ftp has two types of connections:
- control connection (port number 21):
- remains active during the entire interactive ftp session.
- data connection (port number 20):
Chapter - 10 (Application layer protocol) Page 17
- data connection (port number 20):
- opened and closed for each file transfer activity.
- can be opened and closed multiple times if several files are transferred in a single session.
key characteristics:
(i) ftp uses persistent tcp connections for control information.
(ii) ftp uses non-persistent tcp connections for data transfer.
(iii) ftp is a connection-oriented protocol.
(iv) ftp is considered an "out-of-band" protocol as control and data information flow over separate
connections.
(v) ftp is a stateful protocol.
in-band vs out-of-band protocols
- protocols that send requests and data in the same tcp connection are referred to as in-band protocols.
- examples: http, smtp
- ftp, on the other hand, is an out-of-band protocol.
concept: transmission modes in ftp
ftp can transfer a file across the data connection using one of the following transmission modes:
(i) stream mode (default):
- data is delivered as a continuous stream of bytes from ftp to tcp.
(ii) block mode:
- data is delivered in blocks, with each block preceded by a 3-byte header:
- the first byte specifies the block descriptor, and the next two bytes define the size of the block.
(iii) compressed mode:
- data is compressed for transfer.
- in text files, spaces (blanks) are typically compressed; in binary files, null characters are used.
concept: data structures in ftp
ftp can interpret the structure of transferred data in three ways:
(i) file structure:
- used by default; treats data as a continuous stream of bytes.
(ii) record structure:
- divides the file into records. useful for text files.
(iii) page structure:
- divides the file into pages, each with a page number and page header.
- pages can be accessed randomly or sequentially.
Chapter - 10 (Application layer protocol) Page 18
commands in ftp
concept: http protocols
(i) "http" protocol used mainly to access data on word wide web (www)
(ii) it is client server protocol using port No-80 on TCP
(iii) "http" is "in-band" protocol i.e. both request and data we will send only-in-one-
connection.
(iv) "http" is a stateless protocol i.e. it does not maintain any information of user.
(v) there are two types of "http" protocol
- non persistent (1.0)
- persistent (1.1)
(i) non-persistent (1.0)
in a non-persistent connection one TCP connection is made for eachrequest/response.
this strategy follow the following steps :-
(i) the client opens a TCP connection and sends a request.
(ii) server sends the response and closes the connection.
(iii) in this strategy, if a file contains link to N-different pictures in different
files(all located on same server) the connection must be opened and closed N+1 times.
for each file: connection open - connection close.
(ii) persistent (1.1)
(a) in a persistent connection the server leaves the connection open for more request after
Chapter - 10 (Application layer protocol) Page 19
(a) in a persistent connection the server leaves the connection open for more request after
sending a response.
(b) the server closes the connection at the request of client or time out has been reached.
important table:
protocols used by tcp and udp:
Chapter - 10 (Application layer protocol) Page 20
Chapter - 10 (Application layer protocol) Page 21
Chapter - 10 (Application layer protocol) Page 22
Chapter - 10 (Application layer protocol) Page 23