Computer Networks
Computer Networks
2-1
Network Models
2-2
Network Models
2-3
Network Models
2-4
Network Models
2-5
Application Layer
2-6
Introduction
2-7
Introduction …
1-8
Introduction …
2-9
Introduction …
2-10
Introduction …
2-11
Introduction …
Introduction …
2-13
Introduction …
2-14
Introduction …
2-15
Introduction …
2-16
Introduction …
2-17
Introduction …
2-18
Introduction …
2-19
Outline
2.1 principles of network
applications
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
2-20
Application layer
our goals: learn about protocols by
conceptual, examining popular
implementation aspects application-level
of network application protocols
protocols HTTP
transport-layer FTP
service models SMTP / POP3 / IMAP
client-server DNS
paradigm creating network
peer-to-peer applications
paradigm socket API
2-21
Some network apps
e-mail voice over IP (e.g., Skype)
web real-time video
text messaging conferencing
remote login social networking
P2P file sharing …
multi-user network games …
streaming stored video
(YouTube, Hulu, Netflix)
2-22
Creating a network app application
transport
network
data link
2-24
Client-server architecture : email,
network printing, and the World Wide Web
server:
always-on host
permanent IP address
data centers for scaling
clients:
communicate with server
client/server may be intermittently
connected
may have dynamic IP
addresses
do not communicate directly
with each other
2-25
P2P architecture : (Gnutella, Kazaa, BitTorrent, Skype)
no always-on server peer-peer
arbitrary end systems directly
communicate
peers request service from
other peers, provide service in
return to other peers
self scalability – new peers
bring new service capacity,
as well as new service
demands
peers are intermittently
connected and change IP
addresses
complex management
2-26
P2P architecture
Main challenges met in developing P2P
application
A computer can be accessed anytime.
Network security must be applied to each computer
separately.
Backup must be performed on each computer
ISP throttling/blocking: Some ISP block or throttle p2p
traffic by ports or deep packet inspection
Single points of failure: p2p networks still rely on a
centralized bootstrap and update server.
Distribution: P2P infrastructure is dependent on user
adaption
2-27
Processes communicating
process: program running clients, servers
within a host client process: process that
within same host, two initiates communication
processes communicate server process: process that
using inter-process waits to be contacted
communication (defined by
OS)
processes in different hosts
communicate by exchanging aside: applications with P2P
messages architectures have client
processes & server
processes
2-28
Sockets
process sends/receives messages to/from its socket
socket analogous to door
sending process shoves message out door
sending process relies on transport infrastructure on
other side of door to deliver message to socket at
receiving process
application application
socket controlled by
process process app developer
transport transport
network network controlled
link by OS
link Internet
physical physical
2-29
Addressing processes
to receive messages, process identifier includes both IP
must have identifier address and port numbers
host device has unique 32-bit associated with process on
IP address host.
Q: does IP address of host example port numbers:
on which process runs suffice HTTP server: 80
for identifying the process? mail server: 25
to send HTTP message to
A: no, many processes gaia.cs.umass.edu web
can be running on same server:
host IP address: 128.119.245.12
port number: 80
2-30
App-layer protocol defines
types of messages open protocols:
exchanged, defined in RFCs
e.g., request, response allows for interoperability
message syntax: e.g., HTTP, SMTP
what fields in messages proprietary protocols:
& how fields are
e.g., Skype
delineated
message semantics
meaning of information
in fields
rules for when and how
processes send & respond
to messages
2-31
What transport service does an app need?
data integrity throughput
some apps (e.g., file transfer, some apps (e.g.,
web transactions) require multimedia) require
100% reliable data transfer minimum amount of
other apps (e.g., audio) can
throughput to be
tolerate some loss “effective”
other apps (“elastic apps”)
2-32
Transport service requirements: common apps
2-33
Internet transport protocols services
2-34
Internet apps: application, transport protocols
application underlying
application layer protocol transport protocol
2-35
Application-Layer Protocols
Application-layer protocol defines:
2-36
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
app architectures with UDP and TCP
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
2-37
Web and HTTP
First, a review…
web page consists of objects
object can be HTML file, JPEG image, Java applet,
audio file,…
web page consists of base HTML-file which
includes several referenced objects
each object is addressable by a URL, e.g.,
www.someschool.edu/someDept/pic.gif
2-38
HTTP overview
HTTP: hypertext
transfer protocol
Web’s application layer
protocol PC running
client/server model Firefox browser
2-39
HTTP overview (continued)
uses TCP: HTTP is “stateless”
client initiates TCP server maintains no
connection (creates information about past
socket) to server, port 80 client requests
server accepts TCP
connection from client aside
protocols that maintain
HTTP messages “state” are complex!
(application-layer protocol
past history (state) must be
messages) exchanged maintained
between browser (HTTP if server/client crashes, their
client) and Web server views of “state” may be
(HTTP server) inconsistent, must be
TCP connection closed reconciled
2-40
HTTP overview (continued)
2-41
HTTP overview (continued)
Stateless Protocol Stateful Protocol
Stateless Protocol does not require the server to Stateful Protocol require server to save the status
retain the server information or session details. and session information.
In Stateless Protocol, there is no tight dependency In Stateful protocol, there is tight dependency
between server and client. between server and client
simplify the server design. design of server very complex and heavy.
Stateless Protocols works better at the time of Stateful Protocol does not work better at the time
crash because there is no state that must be of crash because stateful server have to keep the
restored, a failed server can simply restart after a information of the status and session details of the
crash. internal states.
Stateless Protocols handle the transaction very Stateful Protocols handle the transaction very
fastly. slowly.
Stateless Protocols are easy to implement in Stateful protocols are logically heavy to implement
Internet. in Internet.
To process different information at a time , To process every request , the same server must
different servers can be used. be utilized.
Example of Stateless are UDP , DNS , HTTP , etc. Example of Stateful are FTTP , Telnet , etc.
2-42
HTTP connections
2-43
HTTP connections
Http 1.0 is a non-persistent connection, and http 1.1 is persistent
connection
HTTP/1.0 was designed to close the connection after every request
between client and server
2-44
HTTP connections
non-persistent HTTP persistent HTTP
at most one object multiple objects can
sent over TCP be sent over single
connection TCP connection
connection then between client, server
closed
downloading multiple
objects required
multiple connections
2-45
Non-persistent HTTP
suppose user enters URL: (contains text,
www.someSchool.edu/someDepartment/home.index references to 10
jpeg images)
1a. HTTP client initiates TCP
connection to HTTP server
(process) at 1b. HTTP server at host
www.someSchool.edu on port www.someSchool.edu waiting
80 for TCP connection at port 80.
“accepts” connection, notifying
2. HTTP client sends HTTP request client
message (containing URL) into
TCP connection socket. 3. HTTP server receives request
Message indicates that client message, forms response
wants object message containing requested
someDepartment/home.index object, and sends message into
its socket
time
2-46
Non-persistent HTTP (cont.)
4. HTTP server closes TCP
connection.
5. HTTP client receives response
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects
time
6. Steps 1-5 repeated for each of
10 jpeg objects
2-47
Non-persistent HTTP: response time
connection RTT
time time
2-49
Persistent and Non-persistent HTTP
2-50
Persistent and Non-persistent HTTP
2-51
Persistent and Non-persistent HTTP
2-52
Persistent and Non-persistent HTTP
2-53
Persistent and Non-persistent HTTP
2-54
Persistent and Non-persistent HTTP
Assume that you have base HTML file with 30 embedded images, images &
base file are small enough to fit in one TCP segment.
How many RTT are required to retrieve base file & images under-following
condition :
2-55
Persistent and Non-persistent HTTP
2RTT is the initial required connection one for TCP connection and one
for HTML base file.
Total time = 2RTT + transmit time
Non-Persistent connection with no parallel connection :
Here for each image 2 RTT are required one for TCP connection and
one for image to send.
So transmit time for 30 images = 2*(30 RTT) = 60 RTT
Total time = 2 RTT+60 RTT = 62RTT
Non-persistent connection with 10 parallel connection :
Here 10 images can be send simultaneously.
So for 30 images it required -> 2*(30/10) = 6RTT
Total time = 2 RTT + 6 RTT = 8RTT
Persistent connection without pipelining :
Here TCP connection is required again and again.
So for 30 images it requires -> 30 RTTs
Total time = 2 RTT + 30 RTT = 32RTT
2-56
Persistent and Non-persistent HTTP
Persistent connection with pipe-lining :
Since it is Persistent connection TCP connection is not required again
and again.
Pipe-lining means in one packet only images which can fit, can be send.
In Pipe-lining connection we can send all images in 1RTT.
Total time = 2 RTT + 1 RTT = 3RTT
2-57
HTTP messages
2-58
HTTP request message
2-60
Uploading form input
POST method:
web page often includes
form input
input is uploaded to
server in entity body
URL method:
uses GET method
input is uploaded in URL
field of request line:
www.somesite.com/animalsearch?monkeys&banana
2-61
Method types
HTTP/1.0: HTTP/1.1:
GET GET, POST, HEAD
POST PUT
HEAD uploads file in entity
asks server to leave body to path specified
requested object out in URL field
of response DELETE
deletes file specified in
the URL field
2-62
Method types
2-63
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK\r\n
status phrase) Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02
GMT\r\n
header ETag: "17dc6-a5c-bf716880"\r\n
Accept-Ranges: bytes\r\n
lines Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-8859-1\r\n
\r\n
data data data data data ...
data, e.g.,
requested
HTML file
2-64
HTTP response message (General Format)
2-65
HTTP response status codes
status code appears in 1st line in server-to-
client response message.
some sample codes:
200 OK
request succeeded, requested object later in this msg
301 Moved Permanently
requested object moved, new location specified later in this msg
(Location:)
400 Bad Request
request msg not understood by server
404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
2-66
HTTP response status codes
2-67
Trying out HTTP (client side) for yourself
1. Telnet to your favorite Web server:
2-69
User-server state: cookies
example:
many Web sites use cookies Susan always access Internet
four components: from PC
1) cookie header line of visits specific e-commerce
HTTP response site for first time
message when initial HTTP requests
2) cookie header line in arrives at site, site creates:
next HTTP request unique ID
message entry in backend
3) cookie file kept on database for ID
user’s host, managed
by user’s browser
4) back-end database at
Web site
2-70
Cookies: keeping “state” (cont.)
client server
ebay 8734
usual http request msg Amazon server
cookie file creates ID
usual http response
1678 for user create backend
ebay 8734
set-cookie: 1678 entry database
amazon 1678
usual http request msg
cookie: 1678 cookie- access
specific
usual http response msg action
2-72
Web caches (proxy server)
Web caches (proxy server)
goal: satisfy client request without involving origin server
user sets browser:
Web accesses via cache
browser sends all HTTP proxy
requests to cache server
object in cache: client
origin
cache returns object server
else cache requests
object from origin
server, then returns
object to client
client origin
server
2-74
More about Web caching
cache acts as both why Web caching?
client and server reduce response time
server for original for client request
requesting client
client to origin server reduce traffic on an
typically cache is institution’s access link
installed by ISP Internet dense with
(university, company, caches: enables “poor”
residential ISP) content providers to
effectively deliver
content
2-75
Conditional GET
client server
Goal: don’t send object
if cache has up-to-date
cached version HTTP request msg
object
If-modified-since: <date>
no object transmission not
delay modified
lower link utilization HTTP response
before
HTTP/1.0
cache: specify date of 304 Not Modified
<date>
cached copy in HTTP
request
If-modified-since:
<date> HTTP request msg
server: response contains If-modified-since: <date> object
modified
no object if cached copy after
HTTP response
is up-to-date: HTTP/1.0 200 OK <date>
HTTP/1.0 304 Not <data>
Modified
2-76
Conditional GET
2-77
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
app architectures with UDP and TCP
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
2-78
FTP: the file transfer protocol
file transfer
FTP FTP FTP
user client server
interface
user
at host remote file
local file system
system
2-80
FTP: the file transfer protocol
2-81
FTP: the file transfer protocol
2-82
FTP: the file transfer protocol
2-83
FTP commands, responses
sample commands: sample return codes
sent as ASCII text over status code and phrase (as
control channel in HTTP)
USER username 331 Username OK,
PASS password password required
LIST return list of file in 125 data
current directory connection
already open;
RETR filename transfer starting
retrieves (gets) file 425 Can’t open
STOR filename stores data connection
(puts) file onto remote 452 Error writing
host file
2-84
FTP commands, responses
2-85
FTP commands, responses
2-86
2-87
2-88
PARAMETER FTP HTTP
Full Form File Transfer Protocol Hyper Text Transfer Protocol
Port Number TCP port no 20 and 21 TCP port no 80 and 8080
Used to transfer files from remote Used to transfer web pages from
Philosophy computer after connection is remote server after internet
established connection is established.
1-way communication system where
2-way communication system where
content including pictures and texts
Communication upload and download of files from
can be transferred from server to
client to server can occur.
client.
HTTP is faster than FTP when
Speed of downloading one big file. HTTP can
FTP is slower than HTTP
download use parallel chunk download which
makes it 6x times faster than FTP
Applicability Used to access and transfer files. HTTP is used to view websites.
FTP can be accessed via the command The common HTTP client is the
Client
line or a GUI browser
Usage Used by fewer people Most widely used
Requires username and password for Does not requires username and
Authentication
authentication password for authentication
2-89
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
app architectures with UDP and TCP
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
2-90
Electronic mail
Electronic mail outgoing
message queue
user mailbox
Three major components: user
agent
user agents
mail servers mail user
server agent
simple mail transfer
protocol: SMTP SMTP mail user
server agent
2-93
Electronic Mail: SMTP [RFC 2821]
uses TCP to reliably transfer email message from
client to server, port 25
direct transfer: sending server to receiving server
three phases of transfer
handshaking (greeting)
transfer of messages
closure
command/response interaction (like HTTP, FTP)
commands: ASCII text
response: status code and phrase
messages must be in 7-bit ASCI
2-94
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s
message “to” message over the TCP
[email protected] connection
2) Alice’s UA sends message 5) Bob’s mail server places the
to her mail server; message message in Bob’s mailbox
placed in message queue 6) Bob invokes his user agent
3) client side of SMTP opens to read message
TCP connection with Bob’s
mail server
2-96
SMTP: final words
SMTP uses persistent comparison with HTTP:
connections
HTTP: pull
SMTP requires message
(header & body) to be in SMTP: push
7-bit ASCII both have ASCII
SMTP server uses command/response
CRLF.CRLF to interaction, status codes
determine end of message
HTTP: each object
encapsulated in its own
response msg
SMTP: multiple objects sent
in multipart msg
2-97
SMTP: final words
2-98
HTTP and SMTP
2-99
2-100
HTTP and SMTP
# HTTP SMTP
HTTP stands for Hypertext transfer SMTP stands for simple mail transfer
1
protocol. protocol.
2 HTTP is used for data and file transfer SMTP is used for mail services.
3 HTTP uses port no 80 SMTP uses port no 25.
HTTP uses TCP connection as Persistent and SMTP uses persistent TCP connection
4
non-persistent only.
HTTP transfers files and data |information SMTP uses mail servers to transfer
5
from a web server to web clients emails from one inbox to another.
6 HTTP uses the Pull protocol SMTP uses push protocol.
7 HTTP uses band type in-band SMTP uses band type in-band.
SMTP requires 7-bit ASCII [American
8 HTTP does not require 7-bit ASCII Standard Code of Information and
interchange].
“telnet HTTP server” command is used to
9 “telnet SMTP server” is used in SMTP.
interact with them in HTTP
HTTP encapsulates each object in its own SMTP places all of the message’s
10
HTTP response message objects into one message. 2-101
Mail message format
2-102
Mail access protocols
user
mail access user
SMTP SMTP protocol
agent agent
(e.g., POP,
IMAP)
2-103
POP3 protocol (110)
S: +OK POP3 server ready
C: user bob
authorization phase S:
C:
+OK
pass hungry
client commands: S: +OK user successfully logged on
user: declare username
pass: password C: list
S: 1 498
server responses
S: 2 912
+OK S: .
-ERR C: retr 1
transaction phase, client: S:
S:
<message 1 contents>
.
list: list message numbers C: dele 1
retr: retrieve message by C: retr 2
number S: <message 1 contents>
dele: delete S: .
quit C: dele 2
C: quit
S: +OK POP3 server signing off
2-104
POP3 protocol (110)
2-105
POP3 (more) and IMAP
more about POP3 IMAP
previous example uses keeps all messages in one
POP3 “download and place: at server
delete” mode allows user to organize
Bob cannot re-read e- messages in folders
mail if he changes keeps user state across
client sessions:
POP3 “download-and- names of folders and
keep”: copies of mappings between
messages on different message IDs and folder
clients name
POP3 is stateless across
sessions
2-106
POP3 and IMAP
2-107
POP3 and IMAP
2-108
POP3 (more) and IMAP
2-109
Chapter 2: outline
2.1 principles of network 2.6 P2P applications
applications 2.7 socket programming
app architectures with UDP and TCP
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 electronic mail
SMTP, POP3, IMAP
2.5 DNS
2-110
DNS: domain name system
people: many identifiers: Domain Name System:
SSN, name, passport # distributed database
Internet hosts, routers: implemented in hierarchy of
IP address (32 bit) - many name servers
used for addressing application-layer protocol:
datagrams hosts, name servers
“name”, e.g., communicate to resolve names
www.yahoo.com - (address/name translation)
used by humans
Q: how to map between IP
address and name, and
vice versa ?
2-111
DNS: domain name system
2-112
DNS: services, structure
DNS services why not centralize DNS?
hostname to IP address single point of failure
translation traffic volume
host aliasing distant centralized database
canonical, alias names maintenance
mail server aliasing
load distribution
replicated Web
servers: many IP
addresses correspond to
one name
relay1.west-coast.enterprise.com could have, say, two aliases such as
enterprise.com and www.enterprise.com
hotmail.com (relay1.west-coast.hotmail.com)
2-113
DNS: a distributed, hierarchical database
Root DNS Servers
… …
2-114
DNS: a distributed, hierarchical database
2-115
DNS: root name servers
contacted by local name server that can not resolve name
root name server:
contacts authoritative name server if name mapping not known
gets mapping
returns mapping to local name server
2-116
DNS: root name servers
2-117
DNS: root name servers
2-118
TLD, authoritative servers
top-level domain (TLD) servers:
responsible for com, org, net, edu, aero, jobs,
museums, and all top-level country domains,
e.g.: uk, fr, ca, jp
Network Solutions maintains servers for .com
TLD
Educause for .edu TLD
authoritative DNS servers:
organization’s own DNS server(s), providing
authoritative hostname to IP mappings for
organization’s named hosts
can be maintained by organization or service
provider
2-119
Local DNS name server
does not strictly belong to hierarchy
each ISP (residential ISP, company, university) has
one
also called “default name server”
when host makes DNS query, query is sent to its
local DNS server
has local cache of recent name-to-address translation
pairs (but may be out of date!)
acts as proxy, forwards query into hierarchy
2-120
DNS
2-121
DNS
2-122
DNS name root DNS server
resolution example
2
host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5
gaia.cs.umass.edu
2-123
DNS name root DNS server
resolution example
2 3
recursive query: 7
6
puts burden of name TLD DNS
server
resolution on
contacted name local DNS server
server dns.poly.edu 5 4
gaia.cs.umass.edu
2-124
root DNS server root DNS server
2 2 3
3 7
TLD DNS server 6
4
TLD DNS
5 server
gaia.cs.umass.edu gaia.cs.umass.edu
2-125
DNS
2-126
DNS: caching, updating records
once (any) name server learns mapping, it caches
mapping
cache entries timeout (disappear) after some time (TTL)
TLD servers typically cached in local name servers
• thus root name servers not often visited
cached entries may be out-of-date (best effort
name-to-address translation!)
if name host changes IP address, may not be known
Internet-wide until all TTLs expire
update/notify mechanisms proposed IETF standard
RFC 2136
2-127
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type, ttl)
type=A type=CNAME
name is hostname name is alias name for some
value is IP address “canonical” (the real) name
type=NS www.ibm.com is really
name is domain (e.g., servereast.backup2.ibm.com
foo.com) value is canonical name
value is hostname of
authoritative name type=MX
server for this domain value is name of mailserver
associated with name
2-128
DNS records
RR format: (name, value, type, ttl)
2-129
DNS records
RR format: (name, value, type, ttl)
2-130
DNS records
RR format: (name, value, type, ttl)
2-131
DNS records
RR format: (name, value, type, ttl)
2-132
DNS protocol, messages
2-133
DNS protocol, messages
query and reply messages, both with same message
format 2 bytes 2 bytes
2-134
DNS protocol, messages
2 bytes 2 bytes
identification flags
2-136
Inserting records into DNS
example: new startup “Network Utopia”
register name networkuptopia.com at DNS
registrar (e.g., Network Solutions)
provide names, IP addresses of authoritative name server
(primary and secondary)
registrar inserts two RRs into .com TLD server:
(networkutopia.com, dns1.networkutopia.com, NS)
(dns1.networkutopia.com, 212.212.212.1, A)
create authoritative server type A record for
www.networkuptopia.com; type MX record for
networkutopia.com
2-137
Attacking DNS
DDoS attacks Redirect attacks
Bombard root servers Man-in-middle
with traffic Intercept queries
Not successful to date DNS poisoning
Traffic Filtering Send bogus relies to
Local DNS servers DNS server, which
cache IPs of TLD caches
servers, allowing root Exploit DNS for DDoS
server bypass
Send queries with
Bombard TLD servers
spoofed source address:
Potentially more
dangerous target IP
2-138
Recap…
2-139