0% found this document useful (0 votes)
21 views

UNIT 2-2

The document discusses the application layer of network applications, detailing various types such as email, web browsing, and file sharing, along with their underlying protocols like HTTP and SMTP. It explains network application architectures, including client-server and peer-to-peer models, and covers the importance of ports and sockets in facilitating communication. Additionally, it outlines the structure of HTTP messages, the differences between non-persistent and persistent connections, and the role of cookies in maintaining user sessions.

Uploaded by

Purahar sathya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

UNIT 2-2

The document discusses the application layer of network applications, detailing various types such as email, web browsing, and file sharing, along with their underlying protocols like HTTP and SMTP. It explains network application architectures, including client-server and peer-to-peer models, and covers the importance of ports and sockets in facilitating communication. Additionally, it outlines the structure of HTTP messages, the differences between non-persistent and persistent connections, and the role of cookies in maintaining user sessions.

Uploaded by

Purahar sathya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 118

UNIT - 2

Application Layer
Application Layer
Principles of Network Applications,
The Web and HTTP,
Electronic Mail in the Internet,
DNS-
The Internet’s Directory Service,
Socket Programming: Creating
Network Applications
The application layer allows users to
send each other files through a
network.

Network Application

A network application is a software


program that uses a computer network
to communicate and perform tasks like
sending messages, sharing files, or
streaming videos.
Network Application
Example
• e-mail
• web
• text messaging
• remote login
• P2P file sharing
• multi-user network games
• streaming stored video (YouTube,
Hulu, Netflix)
• voice over IP (e.g., Skype)
• real-time video conferencing
• social networking
• search
Examples of Network Applications
1.Web Browsers: Applications like Google
Chrome or Mozilla Firefox use the HTTP/HTTPS
protocol to fetch and display web pages.
2.Email Clients: Applications like Microsoft
Outlook or Gmail use protocols like SMTP,
IMAP, or POP3 to send and receive emails.
3.File Sharing Applications: Tools like
Dropbox or Google Drive allow users to share
and sync files over the network.
4.Video Streaming Services: Platforms like
Netflix or YouTube stream video content using
protocols such as DASH, HLS, or RTP.
5.Messaging Applications: Apps like
WhatsApp or Slack enable real-time text,
audio, and video communication using
HTTPS- Hyper Text Transfer Protocol
Secure
SMTP: Simple Mail Transfer Protocol
IMAP: Internet Message Access
Protocol
POP3: Post Office Protocol version 3
DASH: Dynamic Adaptive Streaming
over HTTP
HLS: HTTP Live Streaming
RTP: Real-time Transport Protocol
WebRTC: Web Real-Time
Communication
XMPP: Extensible Messaging and
Network Application
Architectures

⮚Network application architectures


refer to the design and structure
of software systems that operate
over computer networks.
⮚ Types are
⚫Client-Server
⚫Peer-to-Peer (P2P)
Client-server architecture
 The application is split into two parts:
the client and the server.
Client: Sends requests for services or
data to the server.
Server: Processes these requests and
sends back the required information.
 Examples:
Web Browsers (clients) interacting
with web servers (servers) to
client/ display websites.
server Email Clients (like Outlook)
communicating with email servers
(like Gmail).
 Advantages:
Scalable
Secure: Centralized data storage
Easier Maintenance

P2P Architecture
all devices on the network act as
both clients and servers.
 Peers: Directly share resources
with each other without a central
server.
 Examples: File Sharing
Applications like BitTorrent,
where users share parts of a file
directly with each other.
Messaging Apps like Skype, where
users can communicate directly
without a server in between.
 Advantages:
Decentralized
Scalable
P2P Applications
Challenges
1.ISP Friendly. Most residential ISPs are set up
to prioritize more download (downstream) traffic
than upload (upstream) traffic. This can make it
difficult for P2P applications that need to upload a
lot of data.
2. Security. P2P networks are open and
distributed, which makes them vulnerable to
security issues like data breaches or malicious
attacks.
3. Incentives. For P2P applications to work
well, users need to be willing to share their
resources like bandwidth and storage. Creating
incentives to encourage this sharing is an
ongoing challenge.
What is process ?

 Process is a program running in a


computer (or)
Program under execution

 Within same host, two processes


communicate using inter-process
communication (defined by OS)eg .
sockets, pipes, signals, shared memory
Port
• a port is a number that identifies a specific
service or application on a device, allowing
multiple applications to use the network
simultaneously.
• For example, port 80 is used for HTTP (web
browsing), and port 443 is used for HTTPS
(secure web browsing).
Ports range from 0 to 65535, divided into:

• Well-Known Ports (0–1023)


• Registered Ports (1024–49151)
• Dynamic/Private Ports (49152–65535)
1.Well-Known Ports (0–1023)
These are reserved for widely used protocols and services.
Examples:
•Port 80: HTTP (Web traffic)
•Port 443: HTTPS (Secure web traffic)
•Port 22: SSH (Secure Shell)
•Port 25: SMTP (Email sending)
•Port 53: DNS (Domain Name System)
2.Registered Ports (1024–49151)
These are used by user-registered or proprietary applications.
Examples:
•Port 3306: MySQL Database
•Port 5432: PostgreSQL Database
•Port 8080: Alternate HTTP (commonly used by web servers)
•Port 27017: MongoDB
3.Dynamic/Private Ports (49152–65535)
These are assigned dynamically to client applications when they connect
to servers. Often used in temporary connections.
Examples:
•A web browser connecting to a web server on port 80 might use port
50000.
•Skype or other VoIP clients use these for peer-to-peer communication.
Socket

• A socket is an endpoint for sending or


receiving data across a network. It is a
combination of:
• IP address (identifies the device),
• Port number (identifies the service).
• Socket Structure:
IP:Port (e.g., 192.168.1.1:80).
Addressing processes
● To receive messages, process must have identifier.

● Host device has unique 32-bit IP address

● Q: Is IP address of host on which process runs sufficient for


identifying the process?
● A: no, many processes can be running on same host

● identifier includes both IP address and port numbers


associated with process on host.

● example port numbers:


● HTTP server: 80
● mail server: 25

● to send HTTP message to gaia.cs.umass.edu web server:


● IP address: 128.119.245.12
Application-layer protocol
An application-layer protocol is like a set of rules
that helps different applications on separate devices
talk to each other. It defines:
1.Types of messages: What kinds of messages can
be sent (e.g., requests or responses).
2.Message format(syntax): How the message is
structured (e.g., what parts it has and how they are
arranged).
3.Message meaning(semantics): What each part
of the message means.
4.Communication rules: When and how messages
should be sent or replied to.
• For example, in a web browser, the protocol HTTP
defines how the browser asks for a webpage and
how the server responds.
The Web and HTTP:
• HTTP (Hypertext Transfer Protocol):
• Request Methods: GET, POST, PUT,
DELETE, etc.
• Status Codes: Informational (100–
199), Success (200–299), Redirection
(300–399), Client Errors (400–499),
Server Errors (500–599).
• HTTP Headers: Used to specify data
like content type, cache control, and
authentication.
• Cookies: Used for maintaining session
state across multiple HTTP requests.
• HTML and CSS: Foundation of web
Web
 Early 1990, Internet was used only by researchers,
academics, and university students.

 New application WWW arrived in 1994 by Tim Berners-


Lee.

 World Wide Web - is an information where


documents and other web resources are identified
by URL, interlinked by hypertext links, and can be
accessed via the Internet.

 On demand available, What they want, When they want


it.

 Unlike TV and Radio.

 Navigate through Websites.


Web
 Web page consists of objects.

 Object can be HTML file, JPEG image, Java


applet, audio file etc.…

 Web page consists of base HTML-file which


includes several referenced objects.

 Each object is addressable by a Uniform


Resource Locator (URL), like;
Fig: URL
HTTP
 Hyper Text Transfer Protocol – Application layer
protocol.

 It is implemented in two programs.


 Client Program
 Server Program

 Exchanging HTTP message each others.

 HTTP defines the structure of these messages


and how web client – web server exchange
messages.
• Fig: HTTP Protocol
 A client initiates TCP connection
(creates socket) to server using port
80.

 A server accepts TCP connection from


client.

 HTTP messages (application-layer


protocol messages) exchanged
between browser (HTTP client) and
Web server (HTTP server).
HTTP is “stateless protocol”, server
maintains no information about past
client requests.

HTTP connection types are:

1.Non-persistent HTTP
2.Persistent HTTP
Non-Persistent HTTP:
• For each request, a new
connection is established.
• Once the server sends the response,
the connection is closed.
• If multiple objects (like images, CSS
files) are needed, a separate
connection is created for each.
• Slower, as connection setup (like
TCP handshake) happens repeatedly.
• Example: Older HTTP versions, like
HTTP/1.0.
Fig: Non – persistent HTTP
RTT (Round-Trip Time) is the time it takes for a signal (such as
a packet of data) to travel from a sender (e.g., a client) to a
receiver (e.g., a server) and back again to the sender.

Non-Persistent HTTP:

1.Connection Establishment:
For each request, a new connection is established using TCP,
which requires a 3-way handshake (1 RTT).
2.Request and Response:
After the connection is established, the client sends the
request, and the server sends the response (another RTT).
3.Closing the Connection:
Once the response is received, the connection is closed. If
there are multiple objects (e.g., images, stylesheets), the
above process is repeated for each object.
4.Total RTT for each object = 2 RTTs (1 for handshake +
1 for request/response).
For multiple objects, the RTT multiplies quickly since each
object needs its own connection.
Persistent HTTP:

• A single connection is used for


multiple requests and responses.
• The connection remains open until it
is explicitly closed by the client or
server.
• Reduces overhead, as no need to
establish a new connection for each
object.
• Faster, as it avoids repeated
connection setups.
• Example: Common in modern HTTP
Fig: Persistent HTTP
RTT for Persistent HTTP:
1.Connection Establishment:
A single TCP connection is established (1 RTT
for the 3-way handshake).
2.Request and Response:
Multiple requests and responses can be
exchanged over the same connection
without needing additional handshakes.
3.Closing the Connection:
The connection remains open for reuse until
explicitly closed.
4.Total RTT for the first request = 2
RTTs (1 for handshake + 1 for
request/response).
For subsequent requests = 1 RTT per
Example (Loading a Webpage with
6 Objects):

Non-Persistent HTTP:
6 Connections = 6 x (1 RTT for
handshake + 1 RTT for
request/response) = 12 RTTs.

Persistent HTTP:
1 Connection = 1 RTT (handshake)
+ 6 x (1 RTT for request/response) =
7 RTTs.
HTTP Message Format

Two types:
1.Request Message
2.Response Message
1. HTTP Request Message
 It is in ASCII format which means that human-
readable format.
 HTTP request message consist three part:
 Request line
 Header line
 Carriage return
 Each message is followed by a carriage
return and a line feed.

 The last line is followed by an additional


carriage return and line feed.

 The first line of an HTTP request message is


called the request line.

 The request line has three fields: the method


field, the URL field, and the HTTP version field.

 The subsequent lines are called the header


lines.
HTTP Request message: General
format
Key Components of an HTTP Request:
Method: Tells the server what action you want to
perform.
Example: GET, POST, PUT, DELETE
URL: The address or location of the resource you're
accessing.
Example: http://example.com
Version: The version of the HTTP protocol being used.
Example: HTTP/1.1
Header Fields: Extra details about the request (like
what browser you're using).
Example: Host: example.com,
SP (space) separates the method, URL, and protocol
version; CR (carriage return) and LF (line feed)
together (\r\n) denote the end of each line in the
request, including headers and the final blank line
signaling the end of the request.
Value: It is the specific information for a header, like
HTTP Response message

heade
r
lines
1.Status Line:
•HTTP/1.1: The version of the HTTP protocol.
•200: The status code, meaning "OK" (the request
was successful).
•OK: phrase describing the status.
2.Header Lines:
•Extra details about the response:
•Connection: Tells the browser to close the
connection after sending.
•Date: When the response was sent.
•Server: The type of server (e.g., Apache).
•Last-Modified: When the requested file was
last updated.
•Content-Length: Size of the response in bytes
(here, 6821).
•Content-Type: The type of content being sent
(e.g., text/html).
3.Data:
•The actual file or data the browser asked for (e.g.,
an HTML webpage).
General format of an HTTP response
message
 In below example, the status line indicates
that the server is using HTTP/1.1 and that
everything is OK.
1. HTTP/1.1 200 OK
HTTP/1.1: Indicates the HTTP version used.
200 OK: Status code indicating the request was successful.
2. Date:
Indicates the date and time the response was generated (Sun, 26 Sep
2010 20:09:20 GMT).
3. Server:
Provides information about the server software (Apache/2.0.52 with
CentOS).
4. Last-Modified:
The timestamp of when the requested resource was last modified (Tue,
30 Oct 2007 17:00:02 GMT).
5. ETag:
A unique identifier for the specific version of the resource ("17dc6-a5c-
bf716880").
6. Accept-Ranges:
Indicates whether the server accepts partial requests for the resource
(bytes).
7.Content-Length:
The size of the response body in bytes (2652).
8.Keep-Alive:
Details about the connection persistence:
 timeout=10: The server will keep the connection open for 10
seconds.
 max=100: The maximum number of requests allowed on this
connection.
9.Connection:
States whether the connection should remain open (Keep-Alive).
10.Content-Type:
Specifies the media type of the response (text/html) and the
character set (ISO-8859-1).
11.Data:
The actual content or body of the response follows the headers
(e.g., data data data ...).
User-Server interactions: Cookie
HTTP cookies (also called web cookies, Internet
cookies, browser cookies, or simply cookies)
are small blocks of data created by a web server while
a user is browsing a website and placed on the user's
computer or other device by the user's web browser.
Cookies are placed on the device used to access a
website, and more than one cookie may be placed on a
user's device during a session.

Cookies enable web servers to store stateful


information (such as items added in the shopping cart
in an online store) on the user's device or to track the
user's browsing activity (including clicking particular
buttons, logging in, or recording which
pages were visited in the past).They can also be used
to save information that the user previously entered
into form fields, such as names, addresses, passwords,
The cookie has four components:
 A cookie header line in the HTTP
response message
 A cookie header line in the HTTP
request message
 A cookie file kept on the user’s end
system and managed by the user’s
browser
 A back-end database at the Web
site- it stores cookie ID
Example:
 Susan always access Internet from PC

 Visits specific e-commerce site for first


time

 When initial HTTP requests arrives at


site, site creates:

 Unique ID
 Entry in backend database for ID
Web caches (proxy server)

 Goal: Satisfy client request without involving origin


server
 The Web cache has its own disk storage and keeps
copies of recently requested objects in this
storage.
• Web caches are intermediary systems that store
copies of web content. When a user requests a
webpage, the web cache serves the content if it's
available, rather than fetching it directly from the
origin server. This reduces latency and saves
bandwidth.
• Web caches are installed by ISPs (Internet service
providers), Universities, or even Corporate Offices,
wherein multiple end hosts are connected to the
proxy server.
Why Web caching ?

 Reduce response time for client request.

 Reduce traffic on an institution’s access


link.

 A content delivery network, or content


distribution network(CDN), is a
geographically distributed network of
proxy servers and their data centers.
Example: Institutional Network and Internet
Conditional GET

 is used to ensure cached objects are up-to-date.

 When a client (e.g., a browser) has a cached version


of a file (like an image or webpage), it wants to
confirm if the file on the server has changed since it
was cached.
Conditional GET is an HTTP mechanism where:
 The client sends a GET request to the server.
 The request includes an If-Modified-Since header
with the date of the cached object.
 The server checks the modification date of the file:If
the file has not been modified, the server responds
with a small message saying, "No need to download
again" (status 304 Not Modified).
 If the file has been modified, the server sends the
updated file.
Step-by-Step Process:
1.First Request (Cache Miss):
 A browser requests an image (kiwi.gif) from the website
www.exotiquecuisine.com.
 The proxy cache (a middle server) sends this request to the
web server
GET /fruit/kiwi.gif HTTP/1.1
Host: www.exotiquecuisine.com

 The web server sends the image to the cache with details
like the last-modified date.
HTTP/1.1 200 OK
Date: Sat, 8 Oct 2011 15:39:29

 The cache saves the image and its last-modified date, then
forwards the image to the browser.
2.One Week Later (Cache Check):
 Another browser requests the same image (kiwi.gif).
 The image is already in the cache, but the cache checks if
the image has been updated on the web server since the
last time it was cached.
3.Conditional GET:

 The cache sends a request to the web server, asking


if the image has changed since the last-modified date
it stored:
GET /fruit/kiwi.gif HTTP/1.1
Host: www.exotiquecuisine.com
If-Modified-Since: Wed, 7 Sep 2011 09:23:24

 If the image hasn’t changed, the server replies with


HTTP/1.1 304 Not Modified

 The cache uses the stored version of the image


without downloading it again.
 This process is called Conditional GET and ensures
that cached objects are up-to-date without
downloading the same content unnecessarily. It saves
bandwidth and speeds up loading!
FTP(File Transfer Protocol)
FTP (File Transfer Protocol) is a way to transfer files between two
computers (hosts) over the internet or a network. It lets you upload files
from your computer to a server or download files from a server to
your computer.
Example
1.Two Computers Involved:
1. Local Computer: Your personal computer.
2. Remote Server: The other computer where files are stored or need
to be stored.
2.Login:
To connect to the remote server, you need a username and password
for security.
3.File Transfer:
1. Upload: Sending files from your computer to the server.
2. Download: Getting files from the server to your computer.
4.Tools:
You can use FTP software like FileZilla, web browsers, or command-line
tools to transfer files.
Example:
• You want to upload your "resume.pdf" to a company's server:
• Open an FTP client.
• Enter the server address, username, and password.
• Click "Upload" and select "resume.pdf" from your computer.
 File Transfer Protocol (FTP) is the commonly
used protocol for exchanging files over the
Network or Internet. Example: Filezilla

 FTP uses the Internet's TCP/IP protocols to


enable data transfer and uses client-server
architecture.

 FTP promotes sharing of files via remote


computers with reliable and efficient data
transfer.
 FTP client connect FTP server at port 21 using
TCP.

 FTP uses two parallel TCP connections to


transfer a file,
Control Connection: Used for sending control
information between two hosts.
Data Connection: To send a file.
File Transfer Protocol (FTP), which operates over TCP.

1.TCP Control Connection (Port 21):


1. Used for commands and responses between the FTP
client and server.
2. This connection remains active throughout the FTP
session.
2.TCP Data Connection (Port 20):
1. Used for transferring data (e.g., files, directories).
2. The connection is established as needed, typically
during file transfers or directory listing requests.
3.FTP Roles:
1.FTP Client: Initiates the connection and sends requests
for file transfer.
2.FTP Server: Listens on specific ports (usually 21 for
control and 20 for data) to respond to client requests.
FTP operates in two modes:
• Active Mode: The server actively connects back to the
client for data transfer (shown in the image).
• Passive Mode: Used when the client initiates both control
and data connections to avoid firewall issues.
 Control Information like user identification,
password, commands to change remote
directory, commands to “put” and “get” files.

 Client will browse remote file directory, sends


commands over control connection.

 FTP server maintains “state” about user like


current directory, earlier authentication.

 Difference between FTP and HTTP is 2


connections in ftp and only one
connection in http. But both are meant for
data exchange
FTP Commands and Replies

 USER username: Used to send the user


identification to the server.

 PASS password: Used to send the user


password to the server.

 LIST: Used to ask the server to send back a list of


all the files in the current remote directory. The
list of files is sent over a (new and non-persistent)
data connection rather than the control TCP
connection.

 RETR filename: Used to retrieve (that is, get) a


file from the current directory of the remote host.
This command causes the remote host to initiate
a data connection and to send the requested file
over the data connection.
 STOR filename: Used to store (that is, put)
a file into the current directory\ of the
remote host.

 Status code and phrase in the status line of


the HTTP response message

 331 Username OK, password required


 125 Data connection already open; transfer
starting
◦ 425 Can’t open data connection
◦ 452 Error writing file
Real-World Examples of FTP:
1.Backup Systems:
Businesses use FTP to transfer large datasets or system
backups to remote servers for safekeeping.
2.File Sharing in Companies:
Teams share large files between departments using FTP
servers.
3.Media and Content Delivery:
News agencies upload high-resolution images and videos to
FTP servers for clients to download.
4.Software Distribution:
Software companies (like Linux distributions) allow users to
download large files via FTP servers.
5.Log File Access:
Website administrators use FTP to download server logs for
analysis and debugging.
6.when a web developer uploads website files to a web
server.
Website Deployment
A company hires a web developer to create their website. After
developing the site on their local computer, the developer
needs to upload the files to the web server so the website
Electronic Mail in the Internet:
• SMTP (Simple Mail Transfer
Protocol): Used for sending emails.
• POP3 (Post Office Protocol version
3) and IMAP (Internet Mail Access
Protocol): Used for retrieving emails
from the server.
• MIME (Multipurpose Internet Mail
Extensions): Allows sending multimedia
content (images, videos) via email.
• SPF (Sender Policy Framework) and
DKIM (DomainKeys Identified Mail):
Authentication methods to prevent email
Electronic Mail (Email)
Email is an asynchronous communication medium(allows
people to send and read messages at their convenience,
without requiring both sender and receiver to be online at
the same time.)
Modern Features of Email:
• Attachments:
• You can send files (like documents or images) along
with your message.
• Hyperlinks:
• Links to websites or resources can be included.
• HTML-Formatted Text:
• Emails can have styled text (e.g., bold, colors) for
better presentation.
• Embedded Photos:
• Pictures can appear directly in the email body.
Components of the Email System:

User Agents:
Applications that allow users to compose,
send, and read emails (e.g., Gmail,
Outlook).

Mail Servers:
Servers that store and forward email
messages between users.

SMTP (Simple Mail Transfer Protocol):


A protocol used to send and relay emails
over the internet.
Above is email composition window, where someone is writing and sending an
email.
Components are

1.From:
Displays the sender's email address (e.g., "Kræn Vesterberg Hansen
[email protected]"). This is the person sending the email.
2.To:
The recipient's email address (e.g., "[email protected]"). This is where the email
will be delivered.
3.Cc (Carbon Copy):
Additional email addresses (e.g., "[email protected]") where a copy of the email will
be sent. Everyone on the "Cc" list will see the email.
4.Bcc (Blind Carbon Copy):
Another list of email addresses (e.g., "[email protected]"). People here will also
receive a copy, but their addresses will stay hidden from other recipients.
5.Subject:
A short title or description of the email (e.g., "It works with a subject"). This
helps the recipient understand what the email is about.
6.Body:
The main content of the email. In this case, the text says, "It works with a body
as well."
7.Formatting Toolbar:
Tools to format the email content, such as bold, italic, underline, text alignment,
adding links, etc.
8.Buttons:
1. Send: Sends the email to the recipients.
2. Save Now: Saves the draft of the email to edit or send later.
Email
user
agent

mail user
server agent
SMTP mail user
server agent
SMTP
SMTP user
agent
mail
server
user
agent
user
agent
Outgoing
message queue
user mailbox
1.User Agent (Sender):
You use an email app like Gmail or Outlook to write and send an
email.
2.Sender's Mail Server:
After you click "Send," your email goes to your mail server. The
mail server holds your email for a short time in its outgoing
queue.
3.SMTP (Mail Transfer):
The SMTP protocol is like a mailman. It takes your email from
your mail server and delivers it to the recipient's mail server.
4.Recipient's Mail Server:
The recipient's mail server receives your email and stores it in
the recipient’s inbox.
5.User Agent (Recipient):
The recipient opens their email app (like Yahoo Mail) to read the
email.

Email Flow

Your Email App → Your Mail Server → SMTP → Recipient’s


Mail Server → Recipient’s Email App
SMTP
 Simple Mail Transfer Protocol used in sending
and receiving e-mail.

 It use TCP to reliably transfer email message from


client to server using port 25.

 It restricts the body (not just the headers) of all


mail messages to simple 7-bit ASCII.

 SMTP does not use intermediate mail servers for


sending mail.

 If receiving end mail server is down, the message


remains in sending end mail server and waits for a
new attempt.
Scenario: Alice sends message to Bob

1) Alice uses UA to 4) SMTP client sends


compose message “to” Alice’s message over
[email protected] the TCP connection
2) Alice’s UA sends 5) Bob’s mail server
message to her mail
places the message
server; message placed
in message queue in Bob’s mailbox
3) client side of SMTP 6) Bob invokes his user
opens TCP connection agent to read
with Bob’s mail server message

1user mail user


mail agent
agent server server
2 3 6
4
5
Alice’s mail server
Bob’s mail erver
Mail Access Protocols (POP3 and
IMAP)

POP3
 Post Office Protocol – Version 3. POP3 ports are 110 and 995. Port
110 is the default, non-encrypted port, while port 995 is the encrypted
port.

IMAP
 Internet Mail Access Protocol.ports
are 143 for unencrypted
communication and 993 for encrypted communication

 A mail access protocol, such as POP3, is used to transfer mail


from the recipient’s mail server to the recipient’s user agent.
POP3 (Post Office Protocol 3):
• How it works: POP3 downloads your emails
from the mail server to your device
(computer, phone, etc.) and then removes
them from the server.
• What it means for you:
• Emails are stored locally on your device, so
you can access them even without an
internet connection.
• Once downloaded, the email is no longer
on the server, so you can't access it from
other devices.
• Best for: People who want to access emails
from only one device and don't need to keep
emails synchronized across multiple devices.
IMAP (Internet Message Access Protocol):
• How it works: IMAP keeps your emails on the server
and allows you to view and manage them from
multiple devices (e.g., phone, laptop, tablet).
• What it means for you:
• Emails are synced between your devices and the
server, so any action (like deleting or moving
emails) is reflected everywhere.
• You need an internet connection to access your
emails, as they remain on the server.
• Best for: People who want to access their emails
from multiple devices and keep everything
synchronized.
Differences:
• POP3: Downloads emails to your device, removing
them from the server.
• IMAP: Keeps emails on the server and syncs across
multiple devices.
 Video clip

POP and IMAP:


 https://www.youtube.com/watch?v=bKECC0DHe9Y

SMTP
 https://www.youtube.com/watch?v=bKECC0DHe9Y
DNS - Domain Name System

Alphabetic name
IP Address
remember by human

 DNS is application-layer protocol which


translate the domain name into the
corresponding IP address.

 In DNS system, If one DNS server doesn't know


how to translate a particular domain name, it
asks another one, and so on, until the correct
IP address is returned.

 DNS runs over UDP and uses port no 53.


DNS Servers
Top-Level Domain (TLD) Servers:
Responsible for managing domains
like .com, .org, .edu, or country-specific domains
like .in, .uk, .jp.
For example:.com domains are managed by Network
Solutions..edu domains are handled by specific
educational organizations.
Authoritative DNS Servers:
Maintained by an organization or a service
provider.Stores the official hostname-to-IP mapping for
specific domain names of the organization.
For example, Amazon’s authoritative DNS server
provides the IP for www.amazon.com.
Local DNS Name Servers:
Acts as a middleman (proxy) between the user and the
DNS hierarchy.When your device queries a hostname,
the query goes first to the local DNS server.It forwards
DNS –Hierarchical database

 DNS client wants to determine the IP address for the hostname


www.amazon.com

 The client first contacts one of the root servers(tells the DNS
client where to find the Top-Level Domain (TLD) server
(e.g., .com, .org, .net), which returns IP addresses for TLD
servers - top-level domain .com.

 Then contacts TLD servers, which returns the IP address of an


authoritative server for www.amazon.com

 Finally, contacts one of the authoritative servers for


www.amazon.com, which returns the IP address for the
hostname www.amazon.com.
DNS: A distributed - hierarchical
database (13 root DNS servers)
T DNS Servers – Total 13

"a Verisign, Dulles, VA": Refers to the root server managed by Verisign in Dulles, Virginia.“
m WIDE Tokyo": Refers to a root server operated by the WIDE project in Tokyo.
Why Distributed DNS is Preferred Over
Centralized DNS:
Avoid Single Point of Failure:If one DNS server
crashes, the entire Internet doesn’t go down.A
distributed system ensures that other servers can
handle the load and queries.
Handles High Traffic:Millions of devices globally use
DNS at the same time.A single server would get
overloaded, but distributing the load across multiple
servers prevents this.
Faster Response for Clients:A single server (e.g., in
New York) cannot be "close" to all users
worldwide.Queries from distant places like Australia
would face delays over slow or congested
networks.With distributed DNS, users are directed to
nearby servers, reducing latency.
Easier Maintenance:A centralized server would need
DNS name resolution
example root DNS server

 Iterated query:(In an
iterative query, the 2
3
DNS resolver asks TLD DNS server
4
multiple DNS servers
one by one until it 5
gets the answer.) local DNS server
 A host at cis.poly.edu dns.poly.edu
7 6
wants IP address for 1 8
gaia.cs.umass.edu
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu

gaia.cs.umass.edu
DNS name resolution
example root DNS server
 Recursive query:(the
2 3
DNS resolver asks a 7
server to handle the 6
entire process of TLD DNS
server
finding the answer.)
 A host at local DNS server
dns.poly.edu 5 4
cis.poly.edu wants IP
address for 1 8
gaia.cs.umass.edu
authoritative DNS server
 Heavy load at upper dns.cs.umass.edu
level of hierarchy. requesting host
cis.poly.edu

gaia.cs.umass.edu
DNS Services
Real-World Applications of DNS
1.Host Aliasing
A complicated hostname like server1234.us-east-
2.aws.amazon.com can have a simple alias like
aws.amazon.com for users to remember.
2.Mail Server Aliasing
Email applications like Gmail use DNS to map
smtp.gmail.com to the server's IP address (e.g.,
142.250.115.109) for sending and receiving emails.
3.Load Distribution
Popular websites like YouTube or Netflix use DNS to
balance traffic between multiple servers.
•For example:
•www.netflix.com can resolve to
52.94.163.12 and 52.94.165.21, directing
users to different servers to avoid
overloading one server.
DNS Records
1.A Record (Address Record)
Maps a domain name to an IPv4 address.
• Example:
example.com IN A 93.184.216.34
2.AAAA Record (IPv6 Address Record)
Maps a domain name to an IPv6 address.
• Example
example.com IN AAAA
2606:2800:220:1:248:1893:25c8:1946
3.CNAME Record (Canonical Name Record)
Maps an alias domain name to the canonical domain
name.
• Example:
www.example.com IN CNAME example.com
4.MX Record (Mail Exchange Record)
Directs email to the correct mail servers for a domain.
Example:
example.com IN MX 10 mail.example.com
5.SOA Record (Start of Authority Record)
• Purpose: Provides administrative information about the
domain, including the primary DNS server and contact details.
• Example:
example.com IN SOA ns1.example.com. admin.example.com.
(
2025010801 ; Serial number
3600 ; Refresh time
1800 ; Retry time
1209600 ; Expiry time
86400 ) ; Minimum TTL
6.PTR Record (Pointer Record)
• Purpose: Maps an IP address to a domain name for reverse
DNS lookups.
• Example:
34.216.184.93.in-addr.arpa IN PTR example.com
7.SRV Record (Service Record)
• Purpose: Specifies a server for specific services, such as SIP( or
XMPP.
• Example:
_sip._tcp.example.com IN SRV 10 60 5060
SIP: Session Initiation Protocol
A signaling protocol used to initiate, maintain, and terminate real-time
communication sessions such as voice, video calls, and instant
messaging over IP networks.
XMPP: Extensible Messaging and Presence Protocol
A communication protocol for message-oriented middleware based on
XML, used for real-time messaging, presence information, and
collaboration (e.g., chat applications like WhatsApp or Slack).
DNS records
DNS: distributed database storing resource records (RR)
RR format: (name, value, type,
TTL)
type=A
▪ name is hostname
▪ value is IP address
type=NS
● name is domain (e.g., foo.com)
● value is hostname of authoritative name server for this domain

type=CNAME
▪ name is alias name for some “canonical” (the real)
name
▪ www.ibm.com is really
servereast.backup2.ibm.com
▪ value
type=MX : value is namename
is canonical of mailserver associated with
name
DNS: Caching, Updating Records
DNS Caching:
When a DNS server finds the IP address of a domain
(like "example.com"), it saves the information
temporarily to respond faster to future requests. This
saved data disappears after a set time, called TTL
(Time To Live).

TLD and Root Servers:


Local DNS servers often store information about TLDs
(e.g., .com, .org) to avoid frequently asking root
servers for this information.

Outdated Data:
If a website’s IP address changes, cached information
may still show the old IP until it updates. This can cause
delays.

Proposed Updates:
DNS protocol, messages
● query and reply messages, both with same
message format

❖ Msg header
Inserting records into DNS
1.Register the Domain Name:

• The startup "Network Utopia" decides to register the domain name


networkutopia.com through a DNS registrar (like Network Solutions
or GoDaddy).
• They provide the registrar with the names and IP addresses of their
authoritative name servers (primary and secondary).

2.What the Registrar Does:

• The registrar adds two Resource Records (RRs) to the .com Top-
Level Domain (TLD) server:
• NS Record: Specifies the name server responsible for the domain.
Example:(networkutopia.com, dns1.networkutopia.com, NS)
• A Record: Links the name server's domain to its IP
address.Example:(dns1.networkutopia.com, 212.212.212.1, A)

3.Create Authoritative Records:

In their authoritative DNS server, the startup adds:


A Record: Maps the website www.networkutopia.com to its IP address.
Example:(www.networkutopia.com, 212.212.212.2, A)
MX Record: Specifies where emails for networkutopia.com should go.
Socket Programming:

Sockets: Interfaces between a program and the


network, allowing it to send and receive data.

Types of Sockets:

• Stream Sockets (TCP): Connection-oriented,


reliable.
• Datagram Sockets (UDP): Connectionless, faster
but unreliable.

Creating a Simple Client-Server Application:

• Client: Establishes a connection to the server and


sends data.
• Server: Waits for incoming connections, processes
them, and sends responses.
Socket programming
Goal: learn how to build client/server applications
that communicate using sockets

Socket: door between application process and


end-end-transport protocol

application application
socke proc controlled by
proc app
ess
t ess developer
transport transport

network network controlle


d
link Interne link by OS
t physical
physical
Socket is interface between application and
network.
 An application creates a socket.
 Two type of socket:
 TCP Socket – Reliable Transmission
 UDP Socket – Unreliable Transmission

 Once configured the application can pass data


to the socket for transmission and receive
data from the socket (transmitted through the
network by some other host).
application application
proc socke proc controlled by
ess t ess app
developer
transport transport
network network controlle
Interne link d
link
t by OS
physical physical
Type of Socket
SOCK_STREAM SOCK_DGRAM
 E.g. TCP  E.g. UDP
 Reliable delivery  Unreliable
 In-order guaranteed delivery
 Connection-  No order
oriented guarantees
 Bidirectional  Connection-less
App  Unidirectional
D1
App
3 2 3 2
1 socket 1 D2
Dest. socket
D3
Aspect SOCK_STREAM (TCP) SOCK_DGRAM (UDP)

TCP (Transmission UDP (User Datagram


Protocol
Control Protocol) Protocol)

Connection Type Connection-Oriented Connectionless

Reliable (ensures Unreliable (no


delivery and order, guarantee of delivery
Reliability
retransmission for lost or order, no
packets) retransmission)

Slower due to Faster due to minimal


Speed
overhead overhead

Web browsing, file


Live video streaming,
Use Case transfer (e.g., FTP,
online gaming
HTTP)

File upload to a server Live sports streaming


Real-Life Example
(e.g., FTP) (e.g., YouTube Live)

Sequential, with Broadcast or unicast,


Handling of Data acknowledgment for with no
each packet acknowledgment
Socket programming with UDP
❖ UDP: no “connection” between client & server
● no handshaking before sending data
● sender explicitly attaches IP destination address
and port # to each packet
● Reciever extracts sender IP address and port#
from received packet.

❖ UDP: transmitted data may be lost or received


out-of-order
Application viewpoint:
● UDP provides unreliable transfer of groups of
bytes (“datagrams”) between client and server
Client/server socket interaction: UDP
server (running on clie
serverIP) nt
create socket:
create socket, port= x: clientSocket =
serverSocket =
socket(AF_INET,SOCK_DGRAM)
socket(AF_INET,SOCK_DGRAM)
Create datagram with server IP and
port=x; send datagram via
read datagram from clientSocket
serverSocket

write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
Example app: UDP client
Python UDPClient
include Python’s socket
library from socket import *
serverName = ‘hostname’

create UDP socket for


serverPort = 12000
server
clientSocket = socket(socket.AF_INET,
get user keyboard
input socket.SOCK_DGRAM)
Attach server name, port to
message; send into socket message = raw_input(’Input lowercase sentence:’)
read reply characters from clientSocket.sendto(message,(serverName, serverPort))
socket into string
modifiedMessage, serverAddress =
print out received string
and close socket clientSocket.recvfrom(2048)
print modifiedMessage
clientSocket.close()
Example app: UDP server
Python UDPServer
from socket import *
serverPort = 12000
create UDP socket
bind socket to local port serverSocket = socket(AF_INET, SOCK_DGRAM)
number 12000
serverSocket.bind(('', serverPort))

loop forever print “The server is ready to receive”


Read from UDP socket into while 1:
message, getting client’s
address (client IP and port) message, clientAddress = serverSocket.recvfrom(2048)
send upper case string
back to this client
modifiedMessage = message.upper()
serverSocket.sendto(modifiedMessage, clientAddress)
Socket programming with TCP
client must contact server ● when contacted by client, server
● server process must first TCP creates new socket for
be running server process to communicate
● server must have created with that particular client
socket (door) that ●allows server to talk with
welcomes client’s contact multiple clients
client contacts server by: ●source port numbers used to
distinguish clients
● Creating TCP socket,
specifying IP address, port Application
number of server process TCP provides reliable, in-
viewpoint:
● when client creates order
socket: client TCP byte-stream transfer
establishes connection to (“pipe”)
server TCP
between client and
server
Client/server socket interaction:
TCP
server (running on clie
hostid) nt
create socket,
port=x, for incoming
request:
serverSocket = socket()

wait for incoming create socket,


connection TCP connect to hostid,
connectionSocket = connection setup
request port=x
clientSocket = socket()
serverSocket.accept()

read request send request


from using
connectionSocke clientSocket
t
write reply to
connectionSocke read reply
t from
close clientSocket
connectionSocke close
t clientSocke
t
Example app: TCP client
Python TCPClient
from socket import *
serverName = ’servername’
create TCP socket for
server, remote port 12000 serverPort = 12000
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((serverName,serverPort))
No need to attach server sentence = raw_input(‘Input lowercase sentence:’)
name, port
clientSocket.send(sentence)
modifiedSentence = clientSocket.recv(1024)
print ‘From Server:’, modifiedSentence
clientSocket.close()
Example app: TCP server
Python TCPServer
from socket import *
create TCP welcoming
serverPort = 12000
socket serverSocket = socket(AF_INET,SOCK_STREAM)
serverSocket.bind((‘’,serverPort))
server begins listening for
incoming TCP requests
serverSocket.listen(1)
print ‘The server is ready to receive’
loop forever while 1:
server waits on accept() connectionSocket, addr = serverSocket.accept()
for incoming requests, new
socket created on return
sentence = connectionSocket.recv(1024)
read bytes from socket
(but not address as in capitalizedSentence = sentence.upper()
UDP)
close connection to this
connectionSocket.send(capitalizedSentence)
client (but not welcoming connectionSocket.close()
socket)

You might also like