You are on page 1of 97

WEL COME

CODE : 7SR3
SUBJECT: COMPUTER NETWORK & INTERNET (CNI)
SECTION-A
Unit-I: Introduction, Brief history of the computer networks & Internet, Layered
architecture, Internet Protocol stack, Network entities & Layers, Application Layer:
Principal of protocols HTTP, FTP, SMTP and DNS protocols.
Unit-II: Transport Layer: Services & Principals, Multiplexing & Demultiplexing
applications, UDP, Principals of reliable data transfer, TCP details, Principals of
Congestion control, TCP congestion control
Unit-III: N/W layer: Introduction, N/W Service model, Routing Principals, Hierarchical
routing, Internet Protcol IP, ICMP details, Routing in internet, Router internals, Ipv6
SECTION-B
Unit-IV: Link Layer: Introduction, Services, Error detection & correction techniques,
Multiple Access Protocols, LAN address & ARP, CSMA/CD, PPP details, Multimedia
networking and RTSP protocol, RTP details.
Unit-V: N/W security: Basic issues, principals of cryptograghy, Authenticaion &
authenticaion protocol versions, Integrity: Digital signatures, message digests, hash
function algorithms, Key distribution & certification, Secure e-mail, e-commerce: SSL
& SET, IPSec details.
Unit-VI: Network Management: Basic principals, Infrastructure 4 n/w management,
The internet netowrk management framework: SMI, MIB, SNMP details, Security &
administration, ASN.1, Firewalls: Packet filtering and application Gateways
Computer Network & Internet

Text Book:
James F Kurose, KW Ross - Computer Networking, LPE

Reference:
D E Comer: Computer Networks & Internet, Addison-Wesley
A S Tananbaum: Computer Networks, TMH
W Stallings: Data & Communication, 6/e LPE

Other Most Important Refernce Books


1. R. Stevens: Unix Network Programming (PHI) Vol-I
2. R. Stevens: Unix Network Programming (PHI) Vol- II
3. D.E.Comer: Internetworking with TCP/IP (PHI) Vol I, II & III
4. M.S. Bach - Design of Unix OS (PHI)
5. John Goerzen: Linux programming bible (IDG)
7SR3
CNI
U-I http://www.ssgmce.ac.in/~cmmankar/
Computer Network & Internet

Unit-I: Introduction, Brief history of the computer networks & Internet, Layered
architecture, Internet Protocol stack, Network entities & Layers, Application Layer:
Principal of protocols HTTP, FTP, SMTP and DNS protocols.

Why Study “Internet and Intranet Protocols and Applications”?


– Same systems used in the two major types of networks,
the public Internet and internal (corporate) Intranets
– Accessible for study, because protocol standards are
published and their design is publicly debated (accepted)

7SR3
CNI
U-I
WHAT IS CNI? Computer Network & Internet
• CNI Objective: Have some fun, and learn about how modern
networks work, with emphasis on the practical
applications that most of you see and use every day.
• NOT a study of the OSI model, or older technologies and
protocols.
• NOT a certification course for Network Specialists.
• NOT a study of network hardware or data communications
equipment
?

SUBJECT WEBSITE
For assignments, notes, notices, test results, syllabus, schedules, etc…

http://www.ssgmce.ac.in/~cmmankar/
Or
http://www.ssgmce.ac.in/cmmankar/
WHAT IS CNI?

Some network applications


 E-mail  Internet telephone
 Web  Real-time video
 Instant messaging conference
 Remote login  Massive parallel
 computing
P2P file sharing
 Multi-user network
games
 Streaming stored
video clips

http://www.ssgmce.ac.in/~cmmankar/
WHAT IS CNI? What’s this all about??

application
transport
network
• What really happens when data link
physical

I………? request
• How does my email get
from point a to point b?
• What do all these network
“buzzwords” mean to me? reply
• Why does my browser application
transport

respond slowly at times? network


data link
physical
• How does an IP address
actually find a web site?

http://www.ssgmce.ac.in/~cmmankar/
Computer Network & Internet

Why learn about computer networks?


• Almost all modern software applications are distributed
– from enterprise applications to video games
• General useful principles:
– dealing with asynchronicity
– unreliable components  predictable end systems
– (network) life is random and unpredictable
– work with other implementations that you have never met before

What is the Internet?


What is a protocol?
The network edge, core, and access
Introduction networks
Physical media
Delay and loss in Packet-Switched Networks
Protocol layers, service models
Internet backbones, NAPs and ISPs
7SR3
CNI
Standardization
U-I A brief history of computer networking &
http://www.ssgmce.ac.in/~cmmankar/
Computer Network & Internet

Communication Link
• protocols: control sending,
receiving of messages
– e.g., TCP, IP, HTTP,
FTP, PPP
• Internet: “network of
networks”
– loosely hierarchical
– public Internet versus
private intranet
• Internet standards
– RFC: Request for
comments
– IETF: Internet
Engineering Task
Force

7SR3 Network
CNI
U-I http://www.ssgmce.ac.in/~cmmankar/
Computer Network & Internet

• millions of connected
computing devices: hosts,
end-systems router workstation
– pc’s workstations, servers
server
– PDA’s phones, etc… mobile
local ISP
running network apps

• communication links regional ISP


– fiber, copper, radio,
satellite

• routers: forward packets


(chunks) of data thru company
network
network
http://www.ssgmce.ac.in/~cmmankar/
Internet Services

• communication infrastructure enables distributed applications:


– WWW, email, games, e-commerce, databases, voting,
telephony, multimedia, IM, …
– more?
• communication services provided:
– connectionless
– connection-oriented
WHAT IS PROTOCOL ?

Hi TCP conx’n
request
T T
Hi TCP conx’n
I I
response
What’s time? M http://www.ssgmce.org M
E E
2:00 <file>

Human Protocol Network Protocol

http://www.ssgmce.ac.in/~cmmankar/
WHAT IS PROTOCOL ?

… specific msgs sent


… specific actions taken when msgs received, or other events

network protocols
Protocols define format &
• machines rather than
order of messages sent and
humans received among network
• all communication entities, and actions taken on
activity in Internet message transmission and
governed by protocols receipt.

• network edge: applications and


hosts
• network core:
– routers
– network of networks
• access networks, physical media:
communication links http://www.ssgmce.ac.in/~cmmankar/
Computer Network & Internet
• roughly hierarchical
• national/international backbone providers
(NBPs)
– e.g. Genuity/Level 3, Sprint, AT&T, IBM, UUNet, MCI
– interconnect (peer) with each other
privately,
or
at public Network Access Point (NAPs)

• regional ISPs
– connect into NBPs
Network PROTOCOL specifies:
• local ISP, company
 Format of messages
– connect into regional ISPs
Reliance – VPN facility  Meaning of messages
BSNL -- ISP
VSNL -- ISP  Rules for exchange
7SR3
CNI
 Procedures for handling problems
U-I Depends on type of service ?
Network review

Layered protocol model of computer networks


– Reduce complexity by “layering” protocols
– Solve at most a few challenges in each layer
– E.g.
• Lower layer eliminates all physical noise errors
• Upper layer resends lost messages
– Each layer offers services to the layer above
– Enable improvements to PART of the network

Layers And Protocol Software


• Protocol software follows layering model
• One software module per layer
• Modules cooperate
• Incoming or outgoing data passes from one module to another
• Entire set of modules known as stack SAP =
Service Access Points
http://www.ssgmce.ac.in/~cmmankar/
Internet Standardization
• International Telecommunications Union (ITU)
– United Nations treaty organization
– Transmission standards (e.g., modem: V.90)
– Traditional telephone services, fax
• Internet Engineering Task Force (IETF)
– Core: Internet Protocol, transport (TCP)
– Applications: email, HTTP, ftp, ssh, NFS, VoIP
– Not: HTML, APIs
• W3C
– HTML, XML, schema, SOAP, semantic web, …
• OASIS
– XML schema for specific applications
• Lots of other organizations: component vs. system
engineering
CREATING Network application ?

Write programs that


– run on different end systems
and application
transport
– communicate over a network
data link
network. physical

– e.g., Web: Web server


software communicates with
browser software
No software written for
devices in network core
– Network core devices do not
application
function at app layer application
transport
transport
network
network
• but often have supporting data link
data link
physical
application-layer functions physical

(e.g., web server)


– This design allows for rapid
app development
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

server:
– always-on host
– permanent IP address
– server farms for scaling
clients:
– communicate with server
– may be intermittently connected
– may have dynamic IP addresses
– do not communicate directly with each other

http://www.ssgmce.ac.in/~cmmankar/
PROCESS COMMUNICATING

host or host or
server server
Process: program running
within a host. controlled by
app developer
process process
• within same host, two socket socket
processes communicate using TCP with TCP with
inter-process communication buffers, Internet buffers,
variables variables
(defined by OS).
IPC controlled
by OS

• processes in different hosts


communicate by exchanging Client process: process that
messages initiates communication
Server process: process that
waits to be contacted
http://www.ssgmce.ac.in/~cmmankar/
Sockets : Client-Server Architecture

• process sends/receives
messages to/from its socket
host or host or
• socket analogous to door server server
– sending process shoves
controlled by
message out door app developer
process process
– sending process relies on
socket socket
transport infrastructure on
TCP with TCP with
other side of door which buffers, Internet buffers,
brings message to socket variables variables

at receiving process
controlled
by OS

• API: (1) choice of transport protocol; (2) ability to fix


a few parameters
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

ADDRESSING PROCESSES

• For a process to receive • Identifier includes


messages, it must have an both the IP address
identifier
• A host has a unique 32-bit
and port numbers
IP address associated with the
process on the host.
• Q: does the IP • Example port
address of the host numbers:
on which the process
runs suffice for – HTTP server: 80
identifying the – Mail server: 25
process?
• More on this later
• Answer: No, many
processes can be
running on same host http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

App-layer protocol defines


• Types of messages exchanged, Public protocols:
e.g., request & response • defined in RFCs
messages
• allows for interoperability
• Syntax of message types: what
fields in messages & how fields • public process for
are delineated adoption and change
• Semantics of the fields, ie, • e.g., HTTP, SMTP
meaning of information in Proprietary protocols:
fields
• e.g., KaZaA
• Rules for when and how
– some are (partially)
processes send & respond to
documented
messages

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

What transport service does an app need?


Data loss Bandwidth
• some apps (e.g., audio) can
tolerate some loss • some apps (e.g.,
• other apps (e.g., file transfer, multimedia) require
telnet) require 100% reliable minimum amount of
data transfer bandwidth to be
“effective”
Timing
• some apps (e.g., Internet
• other apps (“elastic apps”)
telephony, interactive make use of whatever
games) require low delay bandwidth they get
to be “effective”

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Transport service requirements of common apps

Application Data loss Bandwidth Time Sensitive

file transfer no loss elastic no


e-mail no loss elastic no
Web documents no loss elastic no
real-time audio/video loss-tolerant audio: 5kbps-1Mbps yes, 100’s msec
video:10kbps-5Mbps
stored audio/video loss-tolerant same as above yes, few secs
interactive games loss-tolerant few kbps up yes, 100’s msec
instant messaging no loss elastic yes and no

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Internet transport protocols services


UDP service:
TCP service: • unreliable data transfer
• connection-oriented: setup between sending and
required between client and server receiving process
processes • does not provide: connection
• reliable transport between setup, reliability, flow control,
sending and receiving process congestion control, timing, or
bandwidth guarantee
• flow control: sender won’t
overwhelm receiver
• congestion control: throttle sender Q: why bother? Why is there a
when network overloaded UDP?
• does not provide: timing,
minimum bandwidth guarantees

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Internet apps: application, transport protocols


Application Underlying
Application layer protocol transport protocol

e-mail SMTP [RFC 2821] TCP


remote terminal access Telnet [RFC 854] TCP
Web HTTP [RFC 2616] TCP
file transfer FTP [RFC 959] TCP
streaming multimedia proprietary TCP or UDP
(e.g. RealNetworks)
Internet telephony proprietary
(e.g., Dialpad) typically UDP

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Web and HTTP

• 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
• Example URL:
www.someschool.edu/someDept/pic.gif

host name path name


http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

HTTP overview
HTTP: hypertext transfer protocol HT
TP
• req
Web’s application layer protocol PC running HT ues
TP t
• client/server model Explorer r esp
ons
– client: browser that requests, e
receives, “displays” Web
objects st
q ue
e
– server: Web server sends T Pr o nse Server
objects in response to requests HT r es
p running
T P Apache Web
• HTTP 1.0: RFC 1945 HT
server
• HTTP 1.1: RFC 2068
Mac running
Navigator

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

HTTP overview (continued)


Uses TCP: HTTP is “stateless”
• client initiates TCP connection • server maintains no
information about past client
(creates socket) to server, port 80
requests
• server accepts TCP connection
aside
from client Protocols that maintain “state” are
• HTTP messages (application- complex!
layer protocol messages) • past history (state) must be
exchanged between browser maintained
(HTTP client) and Web server • if server/client crashes, their
(HTTP server) views of “state” may be
• TCP connection closed inconsistent, must be
reconciled

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

HTTP connections
Nonpersistent HTTP Persistent HTTP
• At most one object is • Multiple objects can
sent over a TCP be sent over single
connection. TCP connection
• HTTP/1.0 uses between client and
nonpersistent HTTP server.
• HTTP/1.1 uses
persistent connections
in default mode

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Nonpersistent HTTP (contains text,


Suppose user enters URL references to 10
www.someSchool.edu/someDepartment/home.index jpeg images)

1a. HTTP client initiates TCP 1b. HTTP server at host


connection to HTTP server www.someSchool.edu waiting
(process) at for TCP connection at port 80.
www.someSchool.edu on port 80 “accepts” connection, notifying
2. HTTP client sends HTTP client
request message (containing
URL) into TCP connection 3. HTTP server receives request
socket. Message indicates that message, forms response
client wants object message containing requested
someDepartment/home.index object, and sends message into
its socket
time
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Nonpersistent 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
time objects
6. Steps 1-5 repeated for each of
10 jpeg objects

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Response time modeling


Definition of RTT: time to send
a small packet to travel from
client to server and back.
initiate TCP
Response time: connection
• one RTT to initiate TCP RTT
connection request
file
• one RTT for HTTP request RTT
time to
transmit
and first few bytes of HTTP file
response to return file
received
• file transmission time
total = 2RTT+transmit time time time

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Persistent HTTP
Nonpersistent HTTP issues: Persistent without pipelining:
• requires 2 RTTs per object • client issues new request only
• OS must work and allocate host when previous response has
resources for each TCP been received
connection • one RTT for each referenced
• but browsers often open parallel object
TCP connections to fetch
referenced objects Persistent with pipelining:
Persistent HTTP • default in HTTP/1.1
• server leaves connection open • client sends requests as soon as
after sending response it encounters a referenced
• subsequent HTTP messages object
between same client/server are • as little as one RTT for all the
sent over connection referenced objects

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

HTTP request message


• two types of HTTP messages: request, response
• HTTP request message:
– ASCII (human-readable format)
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr

Carriage return,
(extra carriage return, line feed)
line feed
indicates end
of message
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

HTTP request message: general format

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Uploading form input


Post method:
• Web page often URL method:
includes form input • Uses GET method
• Input is uploaded to • Input is uploaded in URL
server in entity body field of request line:

www.somesite.com/animalsearch?monkeys&banana

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

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 of in URL field
response • DELETE
– deletes file specified in
the URL field

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

HTTP response message


status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
header Server: Apache/1.3.0 (Unix)
lines Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html

data, e.g., data data data data data ...


requested
HTML file

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

HTTP response status codes


In first line in server  client response message.
A few sample codes:
200 OK
– request succeeded, requested object later in this message
301 Moved Permanently
– requested object moved, new location specified later in this message
(Location:)
400 Bad Request
– request message not understood by server
404 Not Found
– requested document not found on this server
505 HTTP Version Not Supported
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Trying out HTTP (client side) for yourself

1. Telnet to your favorite Web server:


telnet cis.poly.edu 80 Opens TCP connection to port 80
(default HTTP server port) at cis.poly.edu.
Anything typed in sent
to port 80 at cis.poly.edu

2. Type in a GET HTTP request:


GET /~ross/ HTTP/1.1 By typing this in (hit carriage
Host: cis.poly.edu return twice), you send
this minimal (but complete)
GET request to HTTP server

3. Look at response message sent by HTTP server!

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

User-server state: cookies


Many major Web sites use Example:
cookies – Susan access Internet
Four components: always from same PC
1) cookie header line in the – She visits a specific e-
HTTP response message commerce site for first time
2) cookie header line in HTTP – When initial HTTP requests
request message arrives at site, site creates a
3) cookie file kept on user’s unique ID and creates an
host and managed by user’s entry in backend database
browser for ID
4) back-end database at Web
site

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Cookies: keeping “state” (cont.)


client server
Cookie file usual http request msg server n e
da try i
tab n b
usual http response + creates ID as a c
e ke
ebay: 8734 Set-cookie: 1678 1678 for user nd

Cookie file
usual http request msg
amazon: 1678 cookie: 1678 cookie- ss
ebay: 8734 specific acce
usual http response msg action

ss
one week later:

ce
ac
usual http request msg
Cookie file cookie-
cookie: 1678
amazon: 1678 spectific
ebay: 8734 usual http response msg action

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Cookies (continued) aside


What cookies can bring: Cookies and privacy:
• cookies permit sites to
• authorization
learn a lot about you
• shopping carts • you may supply name and
• recommendations e-mail to sites
• user session state • search engines use
redirection & cookies to
(Web e-mail)
learn yet more
• advertising companies
obtain info across sites

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Web caches (proxy server)


Goal: satisfy client request without involving origin
server
origin
server
• user sets browser: Web
accesses via cache HT Proxy
TP
req server quest
e
• browser sends all HTTP clientHTTP ues T Pr n se
t H T po
res
pon P res
requests to cache se HT
T
– object in cache: cache e st
u
P req nse
returns object T po
HT r es
– else cache requests object T TP
H
from origin server, then
returns object to client client
origin
server

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

More about Web caching


• Cache acts as both Why Web caching?
client and server • Reduce response time for
• Typically cache is client request.
installed by ISP • Reduce traffic on an
institution’s access link.
(university, company,
• Internet dense with caches
residential ISP)
enables “poor” content
providers to effectively
deliver content (but so
does P2P file sharing)

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Caching example origin


Assumptions
servers
• average object size = 100,000 bits
• avg. request rate from institution’s public
browsers to origin servers = 15/sec Internet

• delay from institutional router to any


origin server and back to router = 2
sec 1.5 Mbps
Consequences access link
• utilization on LAN = 15% institutional
• utilization on access link = 100% network
10 Mbps LAN
• total delay = Internet delay + access delay
+ LAN delay
= 2 sec + minutes + milliseconds

institutional
cache

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Caching example (cont) origin


Possible solution servers
• increase bandwidth of access public
link to, say, 10 Mbps Internet

Consequences
• utilization on LAN = 15%
10 Mbps
• utilization on access link = 15% access link
• Total delay = Internet delay + institutional
access delay + LAN delay network
10 Mbps LAN
= 2 sec + msecs + msecs
• often a costly upgrade

institutional
cache

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Caching example (cont) origin


servers
Install cache public
• suppose hit rate is .4 Internet

Consequence
• 40% requests will be satisfied
almost immediately 1.5 Mbps
• 60% requests satisfied by origin access link
server
institutional
• utilization of access link reduced network
to 60%, resulting in negligible 10 Mbps LAN
delays (say 10 msec)
• total avg delay = Internet delay
+ access delay + LAN delay =
.6*(2.01) secs + milliseconds < institutional
1.4 secs cache

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Conditional GET
• Goal: don’t send object if cache server
cache has up-to-date cached HTTP request msg
version If-modified-since:
object
<date>
• cache: specify date of not
cached copy in HTTP HTTP response modified
request HTTP/1.0
304 Not Modified
If-modified-since:
<date>
• server: response contains no HTTP request msg
object if cached copy is up- If-modified-since:
<date> object
to-date: modified
HTTP/1.0 304 Not HTTP response
Modified HTTP/1.0 200 OK
<data>

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

FTP: THE FILE TRANSFER


PROTOCOL
FTP file transfer
FTP FTP
user client server
interface
user
at host local file remote file
system system

• transfer file to/from remote host


• client/server model
– client: side that initiates transfer (either to/from remote)
– server: remote host
• ftp: RFC 959
• ftp server: port 21

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

FTP: separate control, data connections


TCP control connection
port 21
• FTP client contacts FTP server at
port 21, specifying TCP as
TCP data connection
transport protocol FTP port 20 FTP
• Client obtains authorization over client server
control connection
• Client browses remote directory • Server opens a second TCP
by sending commands over
control connection.
data connection to transfer
• When server receives a command another file.
for a file transfer, the server opens • Control connection: “out of
a TCP data connection to client
band”
• After transferring one file, server
closes connection. • FTP server maintains
“state”: current directory,
earlier authentication
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

FTP commands, responses


Sample commands: Sample return codes
• sent as ASCII text over control • status code and phrase (as in
channel HTTP)
• USER username • 331 Username OK,
• PASS password password required
• LIST return list of file in • 125 data connection
current directory already open;
transfer starting
• RETR filename retrieves
• 425 Can’t open data
(gets) file connection
• STOR filename stores • 452 Error writing
(puts) file onto remote host file

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

outgoing
message queue
Electronic Mail user mailbox
user
agent
Three major components: mail
user
• user agents server
agent
• mail servers SMTP mail
• simple mail transfer protocol: SMTP
server user
User Agent SMTP agent

• a.k.a. “mail reader”


SMTP
• composing, editing, reading mail user
mail
messages server agent
• e.g., Eudora, Outlook, elm, Netscape
Messenger, Thunderbird user
• outgoing, incoming messages stored agent
user
on server
agent

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Electronic Mail: mail servers


Mail Servers user
agent
• mailbox contains incoming
mail
messages for user server
user
agent
• message queue of outgoing
(to be sent) mail messages SMTP mail
server user
• SMTP protocol between mail
SMTP agent
servers to send email
messages SMTP
mail user
– client: sending mail server agent
server
– “server”: receiving mail
server user
agent
user
agent

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

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
– commands: ASCII text
– response: status code and phrase
• messages must be in 7-bit ASCII (mostly)

http://www.ssgmce.ac.in/~cmmankar/
Scenario: Alice sends message to Bob
1) Alice uses UA to compose 4) SMTP client sends Alice’s
message and “to” message over the TCP
bob@someschool.edu connection
2) Alice’s UA sends message to 5) Bob’s mail server places the
her mail server; message placed message in Bob’s mailbox
in message queue 6) Bob invokes his user agent to
3) Client side of SMTP opens TCP read message
connection with Bob’s mail
server

1 mail
mail
server user
user server
2 agent
agent 3 6
4 5
Client-Server Architecture

Sample SMTP interaction


S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Try SMTP interaction for yourself:

• telnet servername 25
• see 220 reply from server
• enter HELO, MAIL FROM, RCPT TO, DATA,
QUIT commands
above lets you send email without using email client
(reader)

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

SMTP: final words


• SMTP uses persistent Comparison with HTTP:
connections • HTTP: pull
• SMTP requires message • SMTP: push
(header & body) to be in
• both have ASCII
7-bit ASCII
command/response interaction,
• SMTP server uses status codes
CRLF.CRLF to determine
• HTTP: each object
end of message encapsulated in its own
response msg
• SMTP: multiple objects sent in
multipart msg

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Mail message format


SMTP: protocol for exchanging header
blank
email messages
line
RFC 2822: standard for text
message format:
• header lines, e.g., body
– To:
– From:
– Subject:
different from SMTP commands!
• body
– the “message”, ASCII
characters only (mostly)

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Message format: multimedia extensions


• MIME: multimedia mail extension, RFC 2045, 2056
• additional lines in msg header declare MIME content
type
From: alice@crepes.fr
MIME version To: bob@hamburger.edu
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Mail access protocols


SMTP SMTP access user
user
agent protocol agent

sender’s mail receiver’s mail


server server

• SMTP: delivery/storage to receiver’s server


• Mail access protocol: retrieval from server
– POP: Post Office Protocol [RFC 1939]
• authorization (agent <-->server) and download
– IMAP: Internet Mail Access Protocol [RFC 1730]
• more features (more complex)
• manipulation of stored msgs on server
– HTTP: Hotmail , Yahoo! Mail, etc.

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

POP3 protocol S:
C:
+OK POP3 server ready
user bob
authorization phase S: +OK
C: 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
S: <message 1 contents>
transaction phase, client: S: .
• 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

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

POP3 (more) and IMAP


More about POP3 IMAP
• Previous example uses • Keep all messages in one
“download and delete” place: the server
mode. • Allows user to organize
• Bob cannot re-read e-mail messages in folders
if he changes client • IMAP keeps user state
• “Download-and-keep”: across sessions:
copies of messages on – names of folders and
different clients mappings between message
IDs and folder name
• POP3 is stateless across
sessions

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

DNS: DOMAIN NAME SYSTEM

People: many identifiers: Domain Name System:


– SSN, name, passport #, CU • distributed database implemented
ID #, postal address, DNA, in hierarchy of many name servers
fingerprint, … • application-layer protocol host,
routers, name servers to
Internet hosts, routers:
communicate to resolve names
– IP address (32 bit) - used for (address/name translation)
addressing datagrams
– note: core Internet function,
– “name”, e.g., ww.yahoo.com implemented as application-
- used by humans layer protocol
Q: map between IP addresses – complexity at network’s
and name ? “edge”

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

DNS
DNS services Why not centralize DNS?
• Hostname to IP address • single point of failure
translation • traffic volume
• Host aliasing • distant centralized database
– Canonical and alias names • maintenance
• Mail server aliasing
• Load distribution doesn’t scale!
– Replicated Web servers: set
of IP addresses for one
canonical name

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Distributed, Hierarchical
Root DNS Servers
Database

com DNS servers org DNS servers edu DNS servers

pbs.org columbia.edu yale.edu


yahoo.com amazon.com
DNS servers DNS servers DNS servers
DNS servers DNS servers
Client wants IP for www.amazon.com; 1st approx:
• Client queries a root server to find com DNS server
• Client queries com DNS server to get amazon.com DNS
server
• Client queries amazon.com DNS server to get IP address
for www.amazon.com

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

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
a Verisign, Dulles, VA
c Cogent, Herndon, VA (also Los Angeles)
d U Maryland College Park, MD k RIPE London (also Amsterdam,
g US DoD Vienna, VA Frankfurt) Stockholm (plus 3
h ARL Aberdeen, MD i Autonomica,
j Verisign, ( 11 locations) other locations)

m WIDE Tokyo
e NASA Mt View, CA
f Internet Software C. Palo Alto,
CA (and 17 other locations)

13 root name
b USC-ISI Marina del Rey, CA
servers
l ICANN Los Angeles, CA
worldwide

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

TLD and Authoritative Servers


• Top-level domain (TLD) servers: responsible for com, org,
net, edu, etc, and all top-level country domains uk, fr, ca, jp.
– Verisign maintains servers for com TLD
– PIR for .org
– Educause for edu TLD
• Process managed by ICANN: registries  registrars
• Authoritative DNS servers: organization’s DNS servers,
providing authoritative hostname to IP mappings for
organization’s servers (e.g., Web and mail).
– Can be maintained by organization or service provider

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Local Name Server


• Does not strictly belong to hierarchy
• Each ISP (residential ISP, company,
university) has one.
– Also called “default name server”
• When a host makes a DNS query, query is
sent to its local DNS server
– Acts as a proxy, forwards query into hierarchy.

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

root DNS server

Example
2
• Host at cis.poly.edu 3
TLD DNS server
wants IP address for 4

gaia.cs.umass.edu 5

local DNS server


dns.poly.edu
7 6
1 8

authoritative DNS server


dns.cs.umass.edu
requesting host
cis.poly.edu

gaia.cs.umass.edu

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

root DNS server


Recursive queries
recursive query:
2 3
• puts burden of name
resolution on contacted 7 6
name server TLD DNS serve
• heavy load?

iterated query: local DNS server


dns.poly.edu 5 4
• contacted server replies
with name of server to 1 8
contact
• “I don’t know this name, authoritative DNS server
dns.cs.umass.edu
but ask this server” requesting host
cis.poly.edu

gaia.cs.umass.edu

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

DNS: caching and updating records


• once (any) name server learns mapping, it caches
mapping
– cache entries timeout (disappear) after some time
– TLD servers typically cached in local name servers
• Thus root name servers not often visited
• update/notify mechanisms under design by IETF
– RFC 2136
– http://www.ietf.org/html.charters/dnsind-charter.html

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

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 “cannonical” (the real) name
www.ibm.com is really
• Type=NS
servereast.backup2.ibm.com
– name is domain (e.g. foo.com)
– value is cannonical name
– value is IP address of
authoritative name server for • Type=MX
this domain – value is name of mailserver
associated with name

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

DNS protocol, messages


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

msg header
• identification: 16 bit # for
query, reply to query uses
same #
• flags:
– query or reply
– recursion desired
– recursion available
– reply is authoritative

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

DNS protocol, messages


Name, type fields
for a query

RRs in reponse
to query

records for
authoritative servers

additional “helpful”
info that may be used

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Inserting records into DNS


• Example: just created startup “Network Utopia”
• Register name networkuptopia.com at a registrar (e.g.,
Network Solutions)
– Need to provide registrar with names and IP addresses of your
authoritative name server (primary and secondary)
– Registrar inserts two RRs into the com TLD server:

(networkutopia.com, dns1.networkutopia.com, NS)


(dns1.networkutopia.com, 212.212.212.1, A)

• Put in authoritative server Type A record for


www.networkuptopia.com and Type MX record for
networkutopia.com
• How do people get the IP address of your Web site?

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Socket programming
Goal: learn how to build client/server application that
communicate using sockets
socket
Socket API
• introduced in BSD4.1 UNIX,
1981 a host-local, application-
• explicitly created, used, released created, OS-controlled
by apps interface (a “door”) into
• client/server paradigm which application process
• can both send and receive
two types of transport service via
socket API: messages to/from
– unreliable datagram another application
process
– reliable, byte stream-oriented

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Socket-programming using TCP


Socket: a door between application process and end-
end-transport protocol (UCP or TCP)
TCP service: reliable transfer of bytes from one
process to another

controlled by
controlled by process application
application process
developer
developer socket socket
TCP with TCP with controlled by
controlled by
buffers, operating
operating buffers, internet system
system variables variables

host or host or
server server

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Socket programming with TCP


Client must contact server • When contacted by client, server
• server process must first be TCP creates new socket for
running server process to communicate
• server must have created socket with client
(door) that welcomes client’s – allows server to talk with
contact multiple clients
– source port numbers used to
Client contacts server by:
distinguish clients (more in
• creating client-local TCP socket
Chap 3)
• specifying IP address, port
number of server process application viewpoint
• When client creates socket: TCP provides reliable, in-order
client TCP establishes transfer of bytes (“pipe”)
connection to server TCP between client and server

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Stream ?????
• A stream is a sequence of characters that
flow into or out of a process.
• An input stream is attached to some input
source for the process, eg, keyboard or
socket.
• An output stream is attached to an output
source, eg, monitor or socket.

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Socket programming with TCP keyboard monit or

Example client-server app:


1) client reads line from standard
input (inFromUser stream) ,

inFromUser
input
stream
sends to server via socket Client
(outToServer stream) Process
process
2) server reads line from socket
3) server converts line to uppercase,
sends back to client
4) client reads, prints modified line

inFromServer
outToServer
output input

from socket (inFromServer stream stream

stream)
client
clientSocket
TCP
socket TCP
socket

to network from network

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Client/server socket interaction: TCP


Server (running on hostid) Client
create socket,
port=x, for
incoming request:
welcomeSocket =
ServerSocket()

TCP create socket,


wait for incoming
connection request connection setup connect to hostid, port=x
connectionSocket = clientSocket =
welcomeSocket.accept() Socket()

send request using


read request from clientSocket
connectionSocket

write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java client (TCP)


import java.io.*;
import java.net.*;
class TCPClient {

public static void main(String argv[]) throws Exception


{
String sentence;
String modifiedSentence;
Create
input stream BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
Create
client socket, Socket clientSocket = new Socket("hostname", 6789);
connect to server
Create DataOutputStream outToServer =
output stream new DataOutputStream(clientSocket.getOutputStream());
attached to socket

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java client (TCP), cont.


Create BufferedReader inFromServer =
input stream new BufferedReader(new
attached to socket InputStreamReader(clientSocket.getInputStream()));

sentence = inFromUser.readLine();
Send line
to server outToServer.writeBytes(sentence + '\n');

Read line modifiedSentence = inFromServer.readLine();


from server
System.out.println("FROM SERVER: " + modifiedSentence);

clientSocket.close();

}
}

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java server (TCP)


import java.io.*;
import java.net.*;

class TCPServer {

public static void main(String argv[]) throws Exception


{
String clientSentence;
Create String capitalizedSentence;
welcoming socket
ServerSocket welcomeSocket = new ServerSocket(6789);
at port 6789
while(true) {
Wait, on welcoming
socket for contact Socket connectionSocket = welcomeSocket.accept();
by client
BufferedReader inFromClient =
Create input new BufferedReader(new
stream, attached InputStreamReader(connectionSocket.getInputStream()));
to socket

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java server (TCP), cont


Create output
stream, attached DataOutputStream outToClient =
to socket new DataOutputStream(connectionSocket.getOutputStream());
Read in line
from socket clientSentence = inFromClient.readLine();

capitalizedSentence = clientSentence.toUpperCase() + '\n';


Write out line
outToClient.writeBytes(capitalizedSentence);
to socket
}
}
} End of while loop,
loop back and wait for
another client connection

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Socket programming with UDP


UDP: no “connection” between
client and server
• no handshaking application viewpoint
• sender explicitly attaches IP UDP provides unreliable transfer
address and port of destination of groups of bytes (“datagrams”)
to each packet between client and server
• server must extract IP address,
port of sender from received
packet
UDP: transmitted data may be
received out of order, or lost

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Client/server socket interaction: UDP


Server (running on hostid) Client

create socket,
port=x, for create socket,
clientSocket =
incoming request: DatagramSocket()
serverSocket =
DatagramSocket()
Create, address (hostid, port=x,
send datagram request
using clientSocket
read request from
serverSocket

write reply to
serverSocket
specifying client read reply from
host address, clientSocket
port number close
clientSocket

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java client (UDP) keyboard monitor

inFromUser
input
stream

Client
Process
Input: receives
process
packet (TCP
Output: sends received “byte
packet (TCP sent stream”)

receivePacket
sendPacket
“byte stream”) UDP UDP
packet packet

client
clientSocket UDP
socket UDP
socket

to network from network

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java client (UDP)


import java.io.*;
import java.net.*;

class UDPClient {
public static void main(String args[]) throws Exception
{
Create
input stream BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
Create
client socket DatagramSocket clientSocket = new DatagramSocket();
Translate
InetAddress IPAddress = InetAddress.getByName("hostname");
hostname to IP
address using DNS byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];

String sentence = inFromUser.readLine();


sendData = sentence.getBytes();

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java client (UDP), cont.


Create datagram
with data-to-send, DatagramPacket sendPacket =
length, IP addr, port new DatagramPacket(sendData, sendData.length, IPAddress, 9876);

Send datagram clientSocket.send(sendPacket);


to server
DatagramPacket receivePacket =
new DatagramPacket(receiveData, receiveData.length);
Read datagram
clientSocket.receive(receivePacket);
from server
String modifiedSentence =
new String(receivePacket.getData());

System.out.println("FROM SERVER:" + modifiedSentence);


clientSocket.close();
}
}

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java server (UDP)


import java.io.*;
import java.net.*;

class UDPServer {
public static void main(String args[]) throws Exception
Create {
datagram socket
DatagramSocket serverSocket = new DatagramSocket(9876);
at port 9876
byte[] receiveData = new byte[1024];
byte[] sendData = new byte[1024];

while(true)
{
Create space for
DatagramPacket receivePacket =
received datagram
new DatagramPacket(receiveData, receiveData.length);
Receive serverSocket.receive(receivePacket);
datagram
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Example: Java server (UDP), cont


String sentence = new String(receivePacket.getData());
Get IP addr
InetAddress IPAddress = receivePacket.getAddress();
port #, of
sender int port = receivePacket.getPort();

String capitalizedSentence = sentence.toUpperCase();

sendData = capitalizedSentence.getBytes();
Create datagram
DatagramPacket sendPacket =
to send to client new DatagramPacket(sendData, sendData.length, IPAddress,
port);
Write out
datagram serverSocket.send(sendPacket);
to socket }
}
} End of while loop,
loop back and wait for
another datagram
http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Building a simple Web server


• after creating server, you
• handles one HTTP request can request file using a
• accepts the request browser (e.g., IE Explorer
or Firefox)
• parses header
• see text for details
• obtains requested file from
server’s file system
• creates HTTP response
message:
– header lines + file
• sends response to client

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

SUMMARY
• specific protocols:
• Application architectures – HTTP
– client-server – FTP
– P2P – SMTP, POP, IMAP
– hybrid – DNS
• application service • socket programming
requirements:
– reliability, bandwidth, delay
• Internet transport service model
– connection-oriented, reliable:
TCP
– unreliable, datagrams: UDP

http://www.ssgmce.ac.in/~cmmankar/
Client-Server Architecture

Summary

• typical request/reply • control vs. data messages


message exchange: – in-band, out-of-band
– client requests info or • centralized vs. decentralized
service • stateless vs. stateful
– server responds with data, • reliable vs. unreliable message
status code
transfer
• message formats: • “complexity at network edge”
– headers: fields giving info
about data
– data: info being
communicated

http://www.ssgmce.ac.in/~cmmankar/

You might also like