CS 31204: Computer Networks – Application Layer
INDIAN INSTITUTE OF TECHNOLOGY
KHARAGPUR
Department of Computer Science and Engineering
Abhijnan Chakraborty
Protocol Stack Implementation in a Host
Software, Kernel
Firmware, Device Driver
Hardware
Physical
Data Link
Network
Transport
Application
Indian Institute of Technology Kharagpur
Some Network Applications
Indian Institute of Technology Kharagpur
Creating a Network App
mobile network
home network
enterprise
network
national or global ISP
local or regional ISP
datacenter
network
content
provider
network
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
write programs that:
no need to write software for network-core devices
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Client-server Paradigm
mobile network
home network
enterprise
network
national or global ISP
local or regional ISP
datacenter
network
content
provider
network
Server:
Clients:
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Peer-peer Architecture
mobile network
home network
enterprise
network
national or global ISP
local or regional ISP
datacenter
network
content
provider
network
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Processes Communicating
Process: program running within a host
client process: process that initiates communication
server process: process that waits to be contacted
clients, servers
Indian Institute of Technology Kharagpur
Sockets
Internet
controlled
by OS
controlled by
app developer
transport
application
physical
link
network
process
transport
application
physical
link
network
process
socket
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Addressing Processes
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
An Application-layer Protocol Defines
Open protocols:
Proprietary protocols:
Indian Institute of Technology Kharagpur
What Transport Service does an App Need?
Data Integrity
Timing
Throughput
Security
Indian Institute of Technology Kharagpur
Transport Service Requirements: Common Apps
application
file transfer/download
Web documents
real-time audio/video
streaming audio/video
interactive games
text messaging
data loss
no loss
no loss
no loss
loss-tolerant
loss-tolerant
loss-tolerant
no loss
throughput
elastic
elastic
elastic
audio: 5Kbps-1Mbps
video:10Kbps-5Mbps
same as above
Kbps+
elastic
time sensitive?
no
no
no
yes, 10’s msec
yes, few secs
yes, 10’s msec
yes and no
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Internet Transport Protocols Services
TCP service:
UDP service:
Q: why bother? Why is there a UDP?
Indian Institute of Technology Kharagpur
Internet Applications, and Transport Protocols
application
file transfer/download
Web documents
Internet telephony
streaming audio/video
interactive games
application
layer protocol
FTP [RFC 959]
SMTP [RFC 5321]
HTTP 1.1 [RFC 7320]
SIP [RFC 3261], RTP [RFC 3550], or proprietary HTTP [RFC 7320], DASH
WOW, FPS (proprietary) �
transport protocol
TCP
TCP
TCP
TCP or UDP
TCP
UDP or TCP
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
How Application Data Passes Through Different Layers
Physical
Data Link
Network
Transport
Application
HTTP Data
HTTP Header
HTTP Data
HTTP Header
TCP Header
HTTP Data
HTTP Header
TCP Header
IP Header
HTTP Data
HTTP Header
TCP Header
IP Header
MAC Header
HTTP Data
HTTP Header
TCP Header
IP Header
MAC Header
PHY Header
PHY Trailer
Indian Institute of Technology Kharagpur
Application Layer Interfacing
UDP
End to end packet delivery
TCP
Connection Establishment
Reliable Data Delivery
Flow and Congestion Control
Ordered Packet Delivery
Network
Transport
Application - 1
Data Link
Application - 2
Application - 3
Application - 4
Indian Institute of Technology Kharagpur
Application Layer Interfacing
UDP
End to end packet delivery
TCP
Connection Establishment
Reliable Data Delivery
Flow and Congestion Control
Ordered Packet Delivery
Network
Transport
Name Service
(DNS)
Data Link
Web
(HTTP)
(SMTP, POP, IMAP)
File Transfer
(FTP)
Indian Institute of Technology Kharagpur
The Web – Hypertext Transfer Protocol (HTTP)
Indian Institute of Technology Kharagpur
Differences between HTML Versions
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
A History of the Web
Indian Institute of Technology Kharagpur
The Web – Architectural Overview
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
HTTP – The Client Side
http://cse.iitkgp.ac.in/~sandipc/courses.html
Indian Institute of Technology Kharagpur
The Steps When You Click http://cse.iitkgp.ac.in/~sandipc/courses.html
Indian Institute of Technology Kharagpur
The Steps When You Click http://cse.iitkgp.ac.in/~sandipc/courses.html
Indian Institute of Technology Kharagpur
The Steps When You Click http://cse.iitkgp.ac.in/~sandipc/courses.html
Indian Institute of Technology Kharagpur
Uniform Resource Identifier (URI)
Indian Institute of Technology Kharagpur
HTTP – The Server Side
Indian Institute of Technology Kharagpur
Multi-Threaded Server
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Serves multiple client requests simultaneously
Indian Institute of Technology Kharagpur
Connections
Indian Institute of Technology Kharagpur
Connections
HTTP 1.0
HTTP 1.1 – Persistent Connections
HTTP 1.1 – Persistent Connections (Pipelined)
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Persistent Connections: Set at keep-alive information in the HTTP header (HTTP 1.0)
HTTP 1.1 – All connections are by default persistent
Indian Institute of Technology Kharagpur
Non-persistent HTTP: Response Time
RTT (definition): time for a small packet to travel from client to server and back
HTTP response time (per object):
time to
transmit
file
initiate TCP
connection
RTT
request file
RTT
file received
time
time
Non-persistent HTTP response time = 2RTT+ file transmission time
Indian Institute of Technology Kharagpur
Persistent HTTP (HTTP 1.1)
Non-persistent HTTP issues:
Persistent HTTP (HTTP1.1):
Indian Institute of Technology Kharagpur
HTTP Request Methods
Indian Institute of Technology Kharagpur
HTTP Request Header Fields (Partial List)
Indian Institute of Technology Kharagpur
HTTP Response
Indian Institute of Technology Kharagpur
HTTP Response Header Fields (Partial List)
Indian Institute of Technology Kharagpur
Dynamic Web Applications
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
HTTP Caching
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Web Caches (aka Proxy Servers)
Why Web caching?
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Caching Example
origin
servers
public
Internet
institutional
network
1 Gbps LAN
1.54 Mbps
access link
Performance:
access link delay + LAN delay
= 2 sec + minutes + usecs
Scenario:
problem: large queueing delays at high utilization!
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Option 1: Buy a Faster Access Link
Performance:
access link delay + LAN delay
= 2 sec + minutes + usecs
origin
servers
public
Internet
institutional
network
1 Gbps LAN
1.54 Mbps
access link
Scenario:
154 Mbps
154 Mbps
.0097
msecs
Cost: faster access link (expensive!)
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Option 2: Install a Web Cache
Performance:
origin
servers
public
Internet
institutional
network
1 Gbps LAN
1.54 Mbps
access link
Scenario:
How to compute link
utilization, delay?
Cost: web cache (cheap!)
local web cache
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Calculating Access Link Utilization, End-end Delay with Cache
origin
servers
public
Internet
institutional
network
1 Gbps LAN
1.54 Mbps
access link
local web cache
suppose cache hit rate is 0.4:
= 0.6 * 1.50 Mbps = .9 Mbps
= 0.6 * (delay from origin servers)
+ 0.4 * (delay when satisfied at cache)
= 0.6 (2.01) + 0.4 (~msecs) = ~ 1.2 secs
lower average end-end delay than with 154 Mbps link (and cheaper too!)
Indian Institute of Technology Kharagpur
Conditional GET
Goal: don’t send object if cache has up-to-date cached version
If-modified-since: <date>
HTTP/1.1 304 Not Modified
HTTP request msg
If-modified-since: <date>
HTTP response
HTTP/1.0
304 Not Modified
object
not
modified
after
<date>
HTTP request msg
If-modified-since: <date>
HTTP response
HTTP/1.0 200 OK
<data>
object
modified
after
<date>
client
server
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Stateless HTTP
HTTP is “stateless”
protocols that maintain “state” are complex!
aside
Indian Institute of Technology Kharagpur
Cookies
Indian Institute of Technology Kharagpur
Maintaining User/Server State: Cookies
Web sites and client browser use cookies to maintain some state between transactions
four components:
1) cookie header line of HTTP response message
2) cookie header line in next HTTP request message
3) cookie file kept on user’s host, managed by user’s browser
4) back-end database at website
Example:
Indian Institute of Technology Kharagpur
Maintaining User/Server State: Cookies
client
server
usual HTTP response msg
usual HTTP response msg
cookie file
one week later:
usual HTTP request msg
cookie: 1678
cookie-
specific
action
access
ebay 8734
usual HTTP request msg
Amazon server
creates ID
1678 for user
create
entry
usual HTTP response
set-cookie: 1678
ebay 8734
amazon 1678
usual HTTP request msg
cookie: 1678
cookie-
specific
action
access
ebay 8734
amazon 1678
backend
database
time
time
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
HTTP cookies: comments
What cookies can be used for:
cookies and privacy:
aside
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
Application Layer Interfacing
UDP
End to end packet delivery
TCP
Connection Establishment
Reliable Data Delivery
Flow and Congestion Control
Ordered Packet Delivery
Network
Transport
Name Service
(DNS)
Data Link
Web
(HTTP)
(SMTP, POP, IMAP)
File Transfer
(FTP)
Indian Institute of Technology Kharagpur
DNS: Domain Name System
People: many identifiers:
Internet hosts, routers:
Q: how to map between IP address and name, and vice versa ?
Domain Name System (DNS):
Indian Institute of Technology Kharagpur
DNS: Services, Structure
Why not centralize DNS?
DNS services:
Doesn't scale!
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
DNS: A Distributed, Hierarchical Database
Client wants IP address for www.amazon.com; 1st approximation:
.com DNS servers
.org DNS servers
.edu DNS servers
…
…
Top Level Domain
Root DNS Servers
Root
nyu.edu
DNS servers
umass.edu
DNS servers
yahoo.com
DNS servers
amazon.com
DNS servers
pbs.org
DNS servers
Authoritative
…
…
…
…
Indian Institute of Technology Kharagpur
DNS: Root Name Servers
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
logical names in the form letter.root-servers.net, where letter ranges from a to m
Indian Institute of Technology Kharagpur
Top-Level Domain (TLD) servers
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
registry.in
Indian Institute of Technology Kharagpur
Operations of NIXI
Indian Institute of Technology Kharagpur
Registers under NIXI
Indian Institute of Technology Kharagpur
Elements of DNS (RFC 1034)
Indian Institute of Technology Kharagpur
Name Servers
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Elements of DNS (RFC 1034)
Indian Institute of Technology Kharagpur
Local DNS name servers
Indian Institute of Technology Kharagpur
Domain Resource Records
Indian Institute of Technology Kharagpur
Domain Resource Records
Indian Institute of Technology Kharagpur
Domain Resource Records
Indian Institute of Technology Kharagpur
Name Resolution (nslookup)
One of the name servers for IITKGP
Indian Institute of Technology Kharagpur
Name Resolution (dig)
An authoritative record is one that comes from the authority that manages the record, and thus is always correct
UDP Message for 4096 bytes
Indian Institute of Technology Kharagpur
Sample DNS Database – IITKGP (dig from KGP Network)
Indian Institute of Technology Kharagpur
Sample DNS Database – IITKGP (dig from Airtel Network)
Indian Institute of Technology Kharagpur
Sample DNS Database – IITKGP (dig from Jio Network)
Indian Institute of Technology Kharagpur
DNS Name Resolution: Iterated Query
Example: host at cse.iitkgp.ac.in
wants IP address for gaia.cs.umass.edu
Iterated query:
requesting host at
cse.iitkgp.ac.in
gaia.cs.umass.edu
root DNS server
a.root-servers.net
local DNS server
ns1.iitkgp.ac.in
1
2
3
4
5
6
authoritative DNS server
dns.cs.umass.edu
7
8
TLD DNS server
a.edu-servers.net
Source: Computer Networking: A Top-Down Approach (8th Ed) by Jim Kurose, Keith Ross
Indian Institute of Technology Kharagpur
DNS Name Resolution: Recursive Query
requesting host at
cse.iitkgp.ac.in
gaia.cs.umass.edu
root DNS server
a.root-servers.net
local DNS server
ns1.iitkgp.ac.in
1
2
3
4
5
6
authoritative DNS server
dns.cs.umass.edu
7
8
TLD DNS server
a.edu-servers.net
Recursive query:
Example: host at cse.iitkgp.ac.in
wants IP address for gaia.cs.umass.edu
Indian Institute of Technology Kharagpur
DNS Packet Structure
Indian Institute of Technology Kharagpur
Why DNS Uses UDP
Indian Institute of Technology Kharagpur
Getting Your info into the DNS
Example: you have created a new startup “KGP Ideas”
(kgpideas.com, dns1.kgpideas.com, NS)
(dns1.kgpideas.com, 212.212.212.1, A)
Indian Institute of Technology Kharagpur
Application Layer Interfacing
UDP
End to end packet delivery
TCP
Connection Establishment
Reliable Data Delivery
Flow and Congestion Control
Ordered Packet Delivery
Network
Transport
Name Service
(DNS)
Data Link
Web
(HTTP)
(SMTP, POP, IMAP)
File Transfer
(FTP)
Indian Institute of Technology Kharagpur
File Transfer Protocol (FTP)
File Server
(FTP Server)
User
(FTP Client)
File Request
File Response Status
File Data
Indian Institute of Technology Kharagpur
Active and Passive Modes of File Transfer
FTP server uses two different ports:
Port 21 (Command or Control Port): For command message transfer
Port 20 or Client assigned (Data Port): For data transfer
Image Source: http://henrydu.com/blog/how-to/ftp-active-mode-vs-passive-mode-106.html
Indian Institute of Technology Kharagpur
Why There are Two Channels – Command Channel and Data Channel
Indian Institute of Technology Kharagpur
Why There are Two Modes in FTP?
Active Mode: Client informs the port number where it is listening, and the server initiates the TCP connection to that port (TCP server is running at the client side)
What If the client is behind a firewall and can not accept a connection?
Indian Institute of Technology Kharagpur
Why There are Two Modes in FTP?
Passive Mode: The server selects a random port, and the client initiates a TCP connection to that server port.
The server can serve multiple clients at different server data ports through different threads.
The clients always initiate the command and the data transfer.
Image Source: http://henrydu.com/blog/how-to/ftp-active-mode-vs-passive-mode-106.html
Indian Institute of Technology Kharagpur
FTP Data Transfer Modes
Source: Wikipedia
Indian Institute of Technology Kharagpur
FTP Sample Commands and Response Codes
Indian Institute of Technology Kharagpur
Application Layer Interfacing
UDP
End to end packet delivery
TCP
Connection Establishment
Reliable Data Delivery
Flow and Congestion Control
Ordered Packet Delivery
Network
Transport
Name Service
(DNS)
Data Link
Web
(HTTP)
(SMTP, POP, IMAP)
File Transfer
(FTP)
Indian Institute of Technology Kharagpur
Electronic Mails – Architecture and Services
sandipc@cse.iitkgp.ac.in
sukumar@iitg.ac.in
cse.iitkgp.ac.in
iitg.ac.in
Indian Institute of Technology Kharagpur
Message Transfer Agents
Indian Institute of Technology Kharagpur
Message Format (RFC 5322)
Indian Institute of Technology Kharagpur
The Internet Message Format (RFC 5322)
Indian Institute of Technology Kharagpur
The Internet Message Format (RFC 5322)
Indian Institute of Technology Kharagpur
MIME – The Multipurpose Internet Mail Extension
Indian Institute of Technology Kharagpur
Message Transfer
SMTP Server
(Port 25)
SMTP Client (Port ANY)
SMTP Server
(Port 25)
SMTP Client (Port ANY)
UA – SMTP Client
Port ANY
TCP
TCP
sandipc@cse.iitkgp.ac.in
cse.iitkgp.ac.in
iitg.ac.in
SMTP
SMTP
Indian Institute of Technology Kharagpur
Message Transfer (SMTP)
Source: Computer Networks (5th Edition) by Tanenbaum, Wetherell
Indian Institute of Technology Kharagpur
Final Delivery
Indian Institute of Technology Kharagpur
IMAP (Version 4) Commands
Indian Institute of Technology Kharagpur
Retrieving email: mail access protocols
IMAP: Internet Mail Access Protocol [RFC 3501]: messages stored on server, IMAP provides retrieval, deletion, folders of stored messages on server
Indian Institute of Technology Kharagpur
Indian Institute of Technology Kharagpur