CS234 – Internet Technology
Tuesdays, Thursdays 3:30-4:50p.m.
Prof. Nalini Venkatasubramanian
nalini@ics.uci.edu
(with slides from Kurose/Ross book, Prof. Zhang -UMN, Van
Jacobsen’s clean slate design talk
Prof. Scott Jordon -UCI etc.)
Class Presentation Topics
1. Internet - Traffic measurements(Tue-Week 2)
2. Web Caching (Thu-Week 2)
3. Unstructured P2P
4. Structured P2P
5. Application Layer Multicasting
6. Multimedia Networking Systems
7. QoS based Streaming
8. Cellular Networks
9. WiFi Networks
10. WiFi Ad Hoc Networks
11. Disruption Tolerant Networks
12. Sensor Networks
13. Pervasive Networking Technologies
14. Smartphone Power Awareness
15. Hybrid Networks
16. Mobile Cloud Computing
Network Evolution

Generation1: The phone system - focus on the wires.

Running a pair of wires to every home & office; dynamically constructing
a path from caller to callee.

Generation 2: The Internet - focus on the machines
connected to the wires.


Packet switching: Data sent in independent chunks and each chunk cont
ains the name of the final destination.
Generation 3? Information-centric- focus on the data flowing
between the machines connected to the wires.
(cf: Van Jacobsen)
Introduction
1-3
Network Architecture
What is (Network) Architecture?


not the implementation itself
“design blueprint” on how to “organize” implementations



what interfaces are supported
where functionality is implemented
Some basic Architectural Principles of network design

Modularity (e.g., layering)


End-to-End Argument


where to implement functionality
Separating policies from mechanisms


how to break network functionality into modules
decouple control from data; “semantics-free”
Design for scale

hierarchy, aggregation, …
CSci5221: Zhi-Li Zhang
t Design
Interne
4
Chapter 1,2
Introduction,
Applications
A note on the use of these ppt slides:
We’re making these slides freely available to all (faculty, students, readers).
They’re in PowerPoint form so you can add, modify, and delete slides
(including this one) and slide content to suit your needs. They obviously
represent a lot of work on our part. In return for use, we only ask the
following:
 If you use these slides (e.g., in a class) in substantially unaltered form, that
you mention their source (after all, we’d like people to use our book!)
 If you post any slides in substantially unaltered form on a www site, that
you note that they are adapted from (or perhaps identical to) our slides, and
note our copyright of this material.
Computer Networking:
A Top Down Approach ,
5th edition.
Jim Kurose, Keith Ross
Addison-Wesley, April
2009.
Thanks and enjoy! JFK/KWR
All material copyright 1996-2010
J.F Kurose and K.W. Ross, All Rights Reserved
Introduction 1-5
Chapter 1: roadmap
1.1 What is the Internet?
1.2 Network edge
 end systems, access networks, links
1.3 Network core
 circuit switching, packet switching, network structure
1.4 Delay, loss and throughput in packet-switched
networks
1.5 Protocol layers, service models
1.6 Networks under attack: security
1.7 History
Introduction 1-6
What’s the Internet: “nuts and bolts” view
 millions
PC
server
wireless
laptop
cellular
handheld
of connected
computing devices:
hosts = end systems
 running network apps
 communication
access
points
wired
links
router
links
 fiber, copper,
radio, satellite
 transmission
rate = bandwidth
 routers: forward
packets (chunks of
data)
Mobile network
Global ISP
Home network
Regional ISP
Institutional network
Introduction 1-7
“Fun” internet appliances
Web-enabled toaster +
weather forecaster
IP picture frame
http://www.ceiva.com/
Slingbox: watch,
control cable TV remotely
Internet
refrigerator
Internet phones
Introduction 1-8
What’s the Internet: “nuts and bolts” view

protocols control sending,
receiving of msgs
Mobile network
Global ISP
 e.g., TCP, IP, HTTP, Skype,
Ethernet

Internet: “network of
networks”
 loosely hierarchical
 public Internet versus
private intranet

Home network
Regional ISP
Institutional network
Internet standards
 RFC: Request for comments
 IETF: Internet Engineering
Task Force
Introduction 1-9
What’s the Internet: a service view


communication
infrastructure enables
distributed applications:
 Web, VoIP, email, games,
e-commerce, file sharing
communication services
provided to apps:
 reliable data delivery
from source to
destination
 “best effort” (unreliable)
data delivery
Introduction 1-10
What’s a protocol?
human protocols:
network protocols:
Hi
TCP connection
request
Hi
TCP connection
response
Got the
time?
<file>
2:00

… specific msgs sent
… specific actions taken
when msgs received,
or other events
all communication activity in
Internet governed by
protocols
protocols define format, order of
msgs sent and received among
network entities, and actions
taken on msg transmission, receipt
Introduction 1-11
Chapter 1: roadmap
1.1 What is the Internet?
1.2 Network edge

end systems, access networks, links
1.3 Network core

circuit switching, packet switching, network structure
1.4 Delay, loss and throughput in packet-switched
networks
1.5 Protocol layers, service models
1.7 History
Introduction 1-12
A closer look at network structure:
network edge:
applications and
hosts
 access networks,
physical media:
wired, wireless
communication links


network core:
 interconnected
routers
 network of
networks
Introduction 1-13
The network edge:

end systems (hosts):
 run application programs
 e.g. Web, email
 at “edge of network”

peer-peer
client/server model
 client host requests, receives
service from always-on server
client/server
 e.g. Web browser/server;
email client/server

peer-peer model:
 minimal (or no) use of
dedicated servers
 e.g. Skype, BitTorrent
Introduction 1-14
Access networks and physical media
Q: How to connect end
systems to edge router?
 residential access nets
 institutional access
networks (school,
company)
 mobile access networks
Keep in mind:
 bandwidth (bits per
second) of access
network?
 shared or dedicated?
Introduction 1-15
Dial-up Modem
central
office
home
PC



home
dial-up
modem
telephone
network
Internet
ISP
modem
(e.g., AOL)
uses existing telephony infrastructure
 home directly-connected to central office
up to 56Kbps direct access to router (often less)
can’t surf, phone at same time: not “always on”
Introduction 1-16
Digital Subscriber Line (DSL)
Existing phone line:
0-4KHz phone; 4-50KHz
upstream data; 50KHz-1MHz
downstream data
home
phone
Internet
DSLAM
telephone
network
splitter
DSL
modem
home
PC
central
office
uses existing telephone infrastructure
 up to 1 Mbps upstream (today typically < 256 kbps)
 up to 8 Mbps downstream (today typically < 1 Mbps)
 dedicated physical line to telephone central office

Introduction 1-17
Residential access: cable modems



uses cable TV infrastructure, rather than
telephone infrastructure
HFC: hybrid fiber coax
 asymmetric: up to 30Mbps downstream, 2
Mbps upstream
network of cable, fiber attaches homes to ISP
router
 homes share access to router
 unlike DSL, which has dedicated access
Introduction 1-18
Residential access: cable modems
Diagram: http://www.cabledatacomnews.com/cmic/diagram.html
Introduction 1-19
Cable Network Architecture: Overview
Typically 500 to 5,000 homes
cable headend
cable distribution
network (simplified)
home
Introduction 1-20
Cable Network Architecture: Overview
server(s)
cable headend
cable distribution
network
home
Introduction 1-21
Cable Network Architecture: Overview
cable headend
cable distribution
network (simplified)
home
Introduction 1-22
Cable Network Architecture: Overview
FDM (more shortly):
V
I
D
E
O
V
I
D
E
O
V
I
D
E
O
V
I
D
E
O
V
I
D
E
O
V
I
D
E
O
D
A
T
A
D
A
T
A
C
O
N
T
R
O
L
1
2
3
4
5
6
7
8
9
Channels
cable headend
cable distribution
network
home
Introduction 1-23
Fiber to the Home
ONT
optical
fibers
Internet
OLT
ONT
optical
fiber
central office
optical
splitter
ONT


optical links from central office to the home
two competing optical technologies:
 Passive Optical network (PON)
 Active Optical Network (PAN)

much higher Internet rates;


fiber also carries television and phone services
AT&T, Verizon etc.. (FTTH)
Introduction 1-24
Ethernet Internet access
100 Mbps
Ethernet
switch
institutional
router
to institution’s
ISP
100 Mbps
1 Gbps
100 Mbps



server
typically used in companies, universities, etc
10 Mbps, 100Mbps, 1Gbps, 10Gbps Ethernet
today, end systems typically connect into Ethernet
switch
Introduction 1-25
Wireless access networks

shared wireless access
network connects end system
to router
 via base station aka “access
point”

wireless LANs:


802.11b/g /n (WiFi): 11/54/72
Mbps
router
base
station
wider-area wireless access
 provided by telco operator
 ~1-2Mbps over cellular system
(EVDO, HSDPA, EGDE, LTE, LTEAdvanced)
 WiMAX (10’s Mbps) over wide
area
mobile
hosts
Introduction 1-26
Home networks
Typical home network components:
 DSL or cable modem
 router/firewall/NAT
 Ethernet
 wireless access point
to/from
cable
headend
cable
modem
router/
firewall
Ethernet
wireless
laptops
wireless
access
point
Introduction 1-27
Physical Media



bit: propagates between
transmitter/rcvr pairs
physical link: what lies
between transmitter &
receiver
guided media:
 signals propagate in solid
media: copper, fiber, coax

Twisted Pair (TP)
 two insulated copper
wires
 Category 3: traditional
phone wires, 10 Mbps
Ethernet
 Category 5:
100Mbps Ethernet
unguided media:
 signals propagate freely,
e.g., radio
Introduction 1-28
Physical Media: coax, fiber
Coaxial cable:



Fiber optic cable:
two concentric copper
conductors
bidirectional
baseband:

broadband:


 high-speed point-to-point
transmission (e.g., 10’s100’s Gpbs)
 single channel on cable
 legacy Ethernet

 multiple channels on
cable
 HFC
glass fiber carrying light
pulses, each pulse a bit
high-speed operation:
low error rate: repeaters
spaced far apart ; immune
to electromagnetic noise
Introduction 1-29
Physical media: radio




signal carried in
electromagnetic
spectrum
no physical “wire”
bidirectional
propagation
environment effects:
 reflection
 obstruction by objects
 interference
Radio link types:

terrestrial microwave
 e.g. up to 45 Mbps channels

LAN (e.g., WiFi)
 11Mbps, 54 Mbps

wide-area (e.g., cellular)
 3G cellular: ~ 1 Mbps

satellite
 Kbps to 45Mbps channel (or
multiple smaller channels)
 270 msec end-end delay
 geosynchronous versus low
altitude
Introduction 1-30
Chapter 1: roadmap
1.1 What is the Internet?
1.2 Network edge

end systems, access networks, links
1.3 Network core

circuit switching, packet switching, network structure
1.4 Delay, loss and throughput in packet-switched
networks
1.5 Protocol layers, service models
1.6 Networks under attack: security
1.7 History
Introduction 1-31
The Network Core


mesh of interconnected
routers
the fundamental
question: how is data
transferred through net?
 circuit switching:
dedicated circuit per
call: telephone net
 packet-switching: data
sent thru net in
discrete “chunks”
Introduction 1-32
Network Core: Circuit Switching
end-end resources
reserved for “call”




link bandwidth, switch
capacity
dedicated resources:
no sharing
circuit-like
(guaranteed)
performance
call setup required
Introduction 1-42
Network Core: Circuit Switching
network resources
(e.g., bandwidth)
divided into “pieces”


pieces allocated to calls
resource piece idle if
not used by owning call
(no sharing)

dividing link bandwidth
into “pieces”
 frequency division
 time division
Introduction 1-43
Circuit Switching: FDM and TDM
Example:
FDM
4 users
frequency
time
TDM
frequency
time
Introduction 1-44
Numerical example

How long does it take to send a file of
640,000 bits from host A to host B over a
circuit-switched network?
 all link speeds: 1.536 Mbps
 each link uses TDM with 24 slots/sec
 500 msec to establish end-to-end circuit
Introduction 1-45
Network Core: Packet Switching
each end-end data stream
divided into packets
 user A, B packets share
network resources
 each packet uses full link
bandwidth
 resources used as needed
Bandwidth division into “pieces”
Dedicated allocation
Resource reservation
resource contention:
 aggregate resource
demand can exceed
amount available
 congestion: packets
queue, wait for link use
 store and forward:
packets move one hop
at a time
 node receives complete
packet before
forwarding
Introduction 1-46
(cf: Van Jacobsen)
Introduction 1-47
Packet Switching: Statistical Multiplexing
100 Mb/s
Ethernet
A
B
statistical multiplexing
1.5 Mb/s
queue of packets
waiting for output
link
D

C
E
sequence of A & B packets has no fixed timing pattern
 bandwidth shared on demand: statistical multiplexing.
Introduction 1-48
Packet-switching: store-and-forward
L
R



R
takes L/R seconds to
transmit (push out)
packet of L bits on to
link at R bps
store and forward:
entire packet must
arrive at router before
it can be transmitted
on next link
delay = 3L/R (assuming
zero propagation delay)
R
Example:
 L = 7.5 Mbits
 R = 1.5 Mbps
 transmission delay = 15
sec
Introduction 1-49
Packet switching versus circuit switching
Packet switching allows more users to use network!
Example:
 1 Mb/s link
 each user:

• 100 kb/s when “active”
• active 10% of time


circuit-switching:
 10 users

packet switching:

with 35 users, probability >
10 active at same time is
less than .0004
N
users

great for bursty data
 resource sharing
 simpler, no call setup
excessive congestion: packet
delay and loss
 protocols needed for reliable
data transfer, congestion
control
Issue: How to provide circuitlike behavior?
 bandwidth guarantees
needed for audio/video apps
 still an unsolved problem
1 Mbps link
Introduction 1-50
Internet structure: network of networks


roughly hierarchical
at center: small # of well-connected large networks
 “tier-1” commercial ISPs (e.g., Verizon, Sprint, AT&T, Qwest,
Level3), national & international coverage
 large content distributors (Google, Akamai, Microsoft)
 treat each other as equals (no charges)
IXP
Tier-1 ISPs &
Content
Distributors,
interconnect
(peer) privately
… or at Internet
Exchange Points
IXPs
Large Content
Distributor
(e.g., Akamai)
IXP
Tier 1 ISP
Tier 1 ISP
Large Content
Distributor
(e.g., Google)
Tier 1 ISP
Introduction 1-51
Tier-1 ISP: e.g., Sprint
POP: point-of-presence
to/from backbone
peering
…
…
.
…
…
…
to/from customers
Introduction 1-52
Sprint
Network
Seattle
Tacoma
Legend
Click here for
a closer look
at the Sprint
network on the
East Coast
Click here for a closer look at the
Sprint network in Washington state
Stockton
San Jose
Click here for
a closer look
at the Sprint
network in
Northern
California
DS3
OC3
OC12
OC48
Cheyenne
Kansas City
New York
Pennsauken
Relay
Wash. DC
Chicago
Roachdale
Anaheim
Atlanta
Pearl City in Hawaii is
a future network location
Fort Worth
Orlando
CSci5221:
Introduction
53
CSci5221:
Introduction
OC1 (45 Mbps), OC2 (155 Mbps), …, OC192 (10 Gbps)
54
UUNET Global BackBone
CSci5221:
Introduction
55
UUNET North America
Backbone
CSci5221:
Introduction
56
UUNET Europe
CSci5221:
Introduction
57
Internet structure: network of networks
“tier-2” ISPs: smaller (often regional) ISPs
 connect to one or more tier-1 (provider) ISPs
 each tier-1 has many tier-2 customer nets
 tier 2 pays tier 1 provider
 tier-2
nets sometimes peer directly with each other
(bypassing tier 1) , or at IXP
IXP
Large Content
Distributor
(e.g., Akamai)
Tier 2
Tier 2 ISP Tier 2
ISP
ISP
IXP
Tier 1 ISP
Tier 2
Tier 1 ISP
ISP Tier 2
Tier 2
ISP
ISP
Large Content
Distributor
(e.g., Google)
Tier 1 ISP
Tier 2
ISP
Tier 2
ISP
Tier 2
ISP
Introduction 1-58
Internet structure: network of networks


“Tier-3” ISPs, local ISPs
customer of tier 1 or tier 2 network
 last hop (“access”) network (closest to end systems)
IXP
Large Content
Distributor
(e.g., Akamai)
Tier 2
Tier 2 ISP Tier 2
ISP
ISP
IXP
Tier 1 ISP
Tier 2
Tier 1 ISP
ISP Tier 2
Tier 2
ISP
ISP
Large Content
Distributor
(e.g., Google)
Tier 1 ISP
Tier 2
ISP
Tier 2
ISP
Tier 2
ISP
Introduction 1-59
Internet structure: network of networks

a packet passes through many networks from source
host to destination host
IXP
Large Content
Distributor
(e.g., Akamai)
Tier 2
Tier 2 ISP Tier 2
ISP
ISP
IXP
Tier 1 ISP
Tier 2
Tier 1 ISP
ISP Tier 2
Tier 2
ISP
ISP
Large Content
Distributor
(e.g., Google)
Tier 1 ISP
Tier 2
ISP
Tier 2
ISP
Tier 2
ISP
Introduction 1-60
Internet History
1961-1972: Early packet-switching principles




1961: Kleinrock - queueing
theory shows
effectiveness of packetswitching
1964: Baran - packetswitching in military nets
1967: ARPAnet conceived
by Advanced Research
Projects Agency
1969: first ARPAnet node
operational

1972:
 ARPAnet public demonstration
 NCP (Network Control Protocol)
first host-host protocol
 first e-mail program
 ARPAnet has 15 nodes
Introduction 1-67
Internet Evolution
1972-1980: Internetworking, new and proprietary nets






1970: ALOHAnet satellite
network in Hawaii
1974: Cerf and Kahn architecture for
interconnecting networks
1976: Ethernet at Xerox
PARC
late70’s: proprietary
architectures: DECnet, SNA,
XNA
late 70’s: switching fixed
length packets (ATM
precursor)
1979: ARPAnet has 200 nodes
Cerf and Kahn’s
internetworking principles:
 minimalism, autonomy no internal changes
required to
interconnect networks
 best effort service
model
 stateless routers
 decentralized control
define today’s Internet
architecture
Introduction 1-68
Internet evolution
1980-1990: new protocols, a proliferation of networks





1983: deployment of
TCP/IP
1982: smtp e-mail
protocol defined
1983: DNS defined
for name-to-IPaddress translation
1985: ftp protocol
defined
1988: TCP congestion
control


new national networks:
Csnet, BITnet,
NSFnet, Minitel
100,000 hosts
connected to
confederation of
networks
Introduction 1-69
Internet Evolution
1990, 2000’s: commercialization, the Web, new apps
 early
1990’s: ARPAnet
decommissioned
 1991: NSF lifts restrictions on
commercial use of NSFnet
(decommissioned, 1995)
 early 1990s: Web
 hypertext [Bush 1945, Nelson
1960’s]
 HTML, HTTP: Berners-Lee
 1994: Mosaic, later Netscape
 late 1990’s: commercialization
late 1990’s – 2000’s:




more killer apps: instant
messaging, P2P file sharing
network security to
forefront
est. 50 million host, 100
million+ users
backbone links running at
Gbps
of the Web
Introduction 1-70
Internet Evolution
2010:
 ~750 million hosts
 voice, video over IP
 P2P applications: BitTorrent
(file sharing) Skype (VoIP),
PPLive (video)
 more applications: YouTube,
gaming, Twitter
 wireless, mobility
Introduction 1-71
Original Internet Design Goals
[Clark’88]
In order of importance:
0
Connect existing networks

1.
initially ARPANET and ARPA packet radio network
Survivability
ensure communication service even with network
and router failures
Support multiple types of services
TCP UDP
-
2.
6.
Must accommodate a variety of networks
Allow distributed management
Allow host attachment with a low level of effort
Be cost effective
7.
Allow resource accountability
3.
4.
5.
Outcome: A packet-switched datagram network with
IP as the Compatibility layer
CSci5221:
Internet Design
IP
Satellite
Ethernet ATM
72
Motivation: Clean Slate design
 TCP/IP Advantages
• Adaptive routing lets system repair failures and hook itself up
initially.
• Reliability increases exponentially with system size.
• No call setup means high efficiency at any bandwidth.
• Distributed routing supports any topology and tends to spread load
and avoid a hierarchy ’s hotspots.
 TCP/IP Issues Problems
• Connectedness is a binary attribute: “in” or “out”
– Requires a globall y unique, globally known IP address that ’s
topologically stable on routing time scales (minutes to hours).
– Connecting is a heavyweight - doesn ’t like things that move
• Security is an afterthought. Channels are secured not data - no way to know
if what you got is complete, consistent or even what you asked for.
 Design criteria
• Originally – few machines, many users; Today – many machines per user
• Originally – conversations ; Today – access to data matters, not who give it
to you
Introduction
1-73
Requirements for Today’s Internet
Some key requirements (“-ities”)
 Availability and reliability

“Always on”, fault-tolerant, fast recovery from failures, …

fast response time, adequate quality for VoIP, IPTV, etc.

millions or more of users, devices, …

untethered access, mobile users, devices, …

protect against malicious attacks, accountability of user actions?
 Quality-of-service (QoS) for applications
 Scalability
 Mobility
 Security (and Privacy?)
 Manageability


configure, operate and manage networks
trouble-shooting network problems
 Flexibility, Extensibility, Evolvability, ……?


ease of new service creation and deployment?
evolvable to meet future needs?
CSci5221:
Internet Design
74
Chapter 1: roadmap
1.1 What is the Internet?
1.2 Network edge

end systems, access networks, links
1.3 Network core

circuit switching, packet switching, network structure
1.4 Delay, loss and throughput in packet-switched
networks
1.5 Protocol layers, service models
1.6 Networks under attack: security
1.7 History
Introduction 1-75
Protocol “Layers”
Networks are complex,
with many “pieces”:
 hosts
 routers
 links of various
media
 applications
 protocols
 hardware,
software
Question:
Is there any hope of
organizing structure of
network?
Or at least our discussion
of networks?
Introduction 1-76
Layering – Systems/Functionality
departure
airport
intermediate air-traffic
control centers
arrival
airport
ticket (purchase)
ticket (complain)
ticket
baggage (check)
baggage (claim
baggage
gates (load)
gates (unload)
gate
runway (takeoff)
runway (land)
takeoff/landing
airplane routing
airplane routing
airplane routing
airplane routing
airplane routing
Layers: each layer implements a service
 via its own internal-layer actions
 relying on services provided by layer below
Introduction 1-77
Why layering?
Dealing with complex systems:



explicit structure allows identification,
relationship of complex system’s pieces
 layered reference model for discussion
modularization eases maintenance, updating of
system
 change of implementation of layer’s service
transparent to rest of system
 e.g., change in gate procedure doesn’t affect
rest of system
layering considered harmful?
Introduction 1-78
Internet protocol stack

application: supporting network
applications
 FTP, SMTP, HTTP

transport: process-process data
transfer
 TCP, UDP

network: routing of datagrams from
source to destination
 IP, routing protocols

link: data transfer between
neighboring network elements
application
transport
network
link
physical
 Ethernet, 802.111 (WiFi), PPP

physical: bits “on the wire”
Introduction 1-79
ISO/OSI reference model



presentation: allow applications to
interpret meaning of data, e.g.,
encryption, compression, machinespecific conventions
session: synchronization,
checkpointing, recovery of data
exchange
Internet stack “missing” these
layers!
 these services, if needed, must
be implemented in application
 needed?
application
presentation
session
transport
network
link
physical
Introduction 1-80
Encapsulation
source
message
segment
M
Ht
M
datagram Hn Ht
M
frame Hl Hn Ht
M
application
transport
network
link
physical
link
physical
switch
destination
M
Ht
M
Hn Ht
Hl Hn Ht
M
M
application
transport
network
link
physical
Hn Ht
Hl Hn Ht
M
M
network
link
physical
Hn Ht
M
router
Introduction 1-81
Chapter 2: Application Layer
Our goals:
 conceptual,
implementation
aspects of network
application protocols
 transport-layer
service models
 client-server
paradigm
 peer-to-peer
paradigm
 learn about protocols
by examining popular
application-level
protocols




HTTP
FTP
SMTP / POP3 / IMAP
DNS
 programming network
applications
 socket API
Application 2-82
Some network apps
 e-mail
 voice over IP
 web
 real-time video
 instant messaging
 remote login
 P2P file sharing
 multi-user network
games
 streaming stored video
(YouTube)
conferencing
 cloud computing
 …
 …

Application 2-83
Creating a network app
write programs that



run on (different) end
systems
communicate over network
e.g., web server software
communicates with browser
software
No need to write software
for network-core devices


network-core devices do
not run user applications
applications on end systems
allows for rapid app
development, propagation
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
Application 2-84
Application architectures
 client-server
 peer-to-peer (P2P)
 hybrid of client-server and P2P
Application 2-85
Client-server architecture
server:
 always-on host
 permanent IP address
 server farms for
scaling
clients:
client/server




communicate with server
may be intermittently
connected
may have dynamic IP
addresses
do not communicate
directly with each other
Application 2-86
Pure P2P architecture
 no always-on server
 arbitrary end systems
directly communicate peer-peer
 peers are intermittently
connected and change IP
addresses
highly scalable but
difficult to manage
Application 2-87
Hybrid of client-server and P2P
Skype
 voice-over-IP P2P application
 centralized server: finding address of remote
party:
 client-client connection: direct (not through
server)
Instant messaging
 chatting between two users is P2P
 centralized service: client presence
detection/location
• user registers its IP address with central
server when it comes online
• user contacts central server to find IP
addresses of buddies
Application 2-88
Processes communicating
process: program running
within a host.
 within same host, two
processes communicate
using inter-process
communication (defined
by OS).
 processes in different
hosts communicate by
exchanging messages
client process: process
that initiates
communication
server process: process
that waits to be
contacted

aside: applications with
P2P architectures have
client processes &
server processes
Application 2-89
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 which
brings message to socket
at receiving process
host or
server
host or
server
process
controlled by
app developer
process
socket
socket
TCP with
buffers,
variables
Internet
TCP with
buffers,
variables
controlled
by OS
API: (1) choice of transport protocol; (2) ability to fix
a few parameters (lots more on this later)
Application 2-90
Addressing processes
 to receive messages,
process must have
identifier
 host device has unique
32-bit IP address
 Q: does IP address of
host on which process
runs suffice for
identifying the process?
Application 2-91
Addressing processes
 to receive messages,
 identifier includes both
process must have
IP address and port
identifier
numbers associated with
process on host.
 host device has unique
32-bit IP address
 example port numbers:
 HTTP server: 80
 Q: does IP address of
 Mail server: 25
host on which process
runs suffice for
 to send HTTP message
identifying the process?
to gaia.cs.umass.edu web
server:
 A: No, many
 IP address: 128.119.245.12
processes can be
 Port number: 80
running on same host
 more shortly…
Application 2-92
App-layer protocol defines
 types of messages
exchanged,

e.g., request, response
 message syntax:
 what fields in messages &
how fields are delineated
 message semantics
 meaning of information in
fields
public-domain protocols:
 defined in RFCs
 allows for
interoperability
 e.g., HTTP, SMTP
proprietary protocols:
 e.g., Skype
 rules for when and how
processes send &
respond to messages
Application 2-93
What transport service does an app need?
Data loss
 some apps (e.g., audio) can
tolerate some loss
 other apps (e.g., file
transfer, telnet) require
100% reliable data
transfer
Timing
 some apps (e.g.,
Internet telephony,
interactive games)
require low delay to be
“effective”
Throughput
 some apps (e.g.,
multimedia) require
minimum amount of
throughput to be
“effective”
 other apps (“elastic apps”)
make use of whatever
throughput they get
Security
 encryption, data integrity,
…
Application 2-94
Transport service requirements of common apps
Data loss
Throughput
Time Sensitive
file transfer
e-mail
Web documents
real-time audio/video
no loss
no loss
no loss
loss-tolerant
no
no
no
yes, 100’s msec
stored audio/video
interactive games
instant messaging
loss-tolerant
loss-tolerant
no loss
elastic
elastic
elastic
audio: 5kbps-1Mbps
video:10kbps-5Mbps
same as above
few kbps up
elastic
Application
yes, few secs
yes, 100’s msec
yes and no
Application 2-95
Internet transport protocols services
TCP service:
 connection-oriented: setup




required between client and
server processes
reliable transport between
sending and receiving process
flow control: sender won’t
overwhelm receiver
congestion control: throttle
sender when network
overloaded
does not provide: timing,
minimum throughput
guarantees, security
UDP service:
 unreliable data transfer
between sending and
receiving process
 does not provide:
connection setup,
reliability, flow control,
congestion control, timing,
throughput guarantee, or
security
Q: why bother? Why is
there a UDP?
Application 2-96
Internet apps: application, transport protocols
Application
e-mail
remote terminal access
Web
file transfer
streaming multimedia
Internet telephony
Application
layer protocol
Underlying
transport protocol
SMTP [RFC 2821]
Telnet [RFC 854]
HTTP [RFC 2616]
FTP [RFC 959]
HTTP (e.g., YouTube),
RTP [RFC 1889]
SIP, RTP, proprietary
(e.g., Skype)
TCP
TCP
TCP
TCP
TCP or UDP
typically UDP
Application 2-97
Chapter 2: Application layer
2.1 Principles of network
applications


app architectures
app requirements
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail

2.6 P2P applications
2.7 Socket programming
with TCP
2.8 Socket programming
with UDP
SMTP, POP3, IMAP
2.5 DNS
Application 2-98
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
 example URL:
www.someschool.edu/someDept/pic.gif
host name
path name
Application 2-99
HTTP overview
HTTP: hypertext
transfer protocol
 Web’s application layer
protocol
 client/server model
 client: browser that
requests, receives,
“displays” Web objects
 server: Web server
sends objects in
response to requests
PC running
Explorer
Server
running
Apache Web
server
Mac running
Navigator
Application 2-100
HTTP overview (continued)
Uses TCP:
 client initiates TCP
connection (creates socket)
to server, port 80
 server accepts TCP
connection from client
 HTTP messages (applicationlayer protocol messages)
exchanged between browser
(HTTP client) and Web
server (HTTP server)
 TCP connection closed
HTTP is “stateless”
 server maintains no
information about
past client requests
aside
protocols that maintain
“state” are complex!
 past history (state) must
be maintained
 if server/client crashes,
their views of “state” may
be inconsistent, must be
reconciled
Application 2-101
HTTP connections
non-persistent HTTP
 at most one object
sent over TCP
connection.
persistent HTTP
 multiple objects can
be sent over single
TCP connection
between client, server.
Application 2-102
Nonpersistent 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
www.someSchool.edu on port 80
2. HTTP client sends HTTP
request message (containing
URL) into TCP connection
socket. Message indicates
that client wants object
someDepartment/home.index
1b. HTTP server at host
www.someSchool.edu waiting
for TCP connection at port 80.
“accepts” connection, notifying
client
3. HTTP server receives request
message, forms response
message containing requested
object, and sends message
into its socket
time
Application 2-103
Nonpersistent HTTP (cont.)
4. HTTP server closes TCP
5. HTTP client receives response
connection.
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
Application 2-104
Non-Persistent HTTP: Response time
definition of RTT: time for
a small packet to travel
from client to server
and back.
response time:
 one RTT to initiate TCP
connection
 one RTT for HTTP
request and first few
bytes of HTTP response
to return
 file transmission time
total = 2RTT+transmit time
initiate TCP
connection
RTT
request
file
RTT
file
received
time
time to
transmit
file
time
Application 2-105
Persistent HTTP
non-persistent HTTP issues:
 requires 2 RTTs per object
 OS overhead for each TCP
connection
 browsers often open parallel
TCP connections to fetch
referenced objects
persistent HTTP
 server leaves connection
open after sending
response
 subsequent HTTP messages
between same
client/server sent over
open connection
 client sends requests as
soon as it encounters a
referenced object
 as little as one RTT for all
the referenced objects
Application 2-106
HTTP request message
 two types of HTTP messages: request, response
 HTTP request message:
 ASCII (human-readable format)
request line
(GET, POST,
HEAD commands)
header
lines
carriage return,
line feed at start
of line indicates
end of header lines
carriage return character
line-feed character
GET /index.html HTTP/1.1\r\n
Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
Keep-Alive: 115\r\n
Connection: keep-alive\r\n
\r\n
Application 2-107
HTTP request message: general format
request
line
header
lines
body
Application 2-108
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
Application 2-109
Method types
HTTP/1.0
 GET
 POST
 HEAD

asks server to leave
requested object out of
response
HTTP/1.1
 GET, POST, HEAD
 PUT

uploads file in entity
body to path specified
in URL field
 DELETE
 deletes file specified in
the URL field
Application 2-110
HTTP response message
status line
(protocol
status code
status phrase)
header
lines
data, e.g.,
requested
HTML file
HTTP/1.1 200 OK\r\n
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
ETag: "17dc6-a5c-bf716880"\r\n
Accept-Ranges: bytes\r\n
Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-88591\r\n
\r\n
data data data data data ...
Application 2-111
HTTP response status codes


status code appears in 1st line in server->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
Application 2-112
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
Host: cis.poly.edu
by typing this in (hit carriage
return twice), you send
this minimal (but complete)
GET request to HTTP server
3. look at response message sent by HTTP server!
(or use Wireshark!)
Application 2-113
User-server state: cookies
example:
 Susan always access
Internet from PC
 visits specific e1) cookie header line of
HTTP response message
commerce site for first
2) cookie header line in
time
HTTP request message
 when initial HTTP
3) cookie file kept on
user’s host, managed by
requests arrives at site,
user’s browser
site creates:
4) back-end database at
 unique ID
Web site
 entry in backend
database for ID
many Web sites use
cookies
four components:
Application 2-114
Cookies: keeping “state” (cont.)
client
ebay 8734
cookie file
ebay 8734
amazon 1678
server
usual http request msg
usual http response
Set-cookie: 1678
usual http request msg
cookie: 1678
one week later:
ebay 8734
amazon 1678
usual http response msg
usual http request msg
cookie: 1678
usual http response msg
Amazon server
creates ID
1678 for user create
entry
cookiespecific
action
access
access
backend
database
cookiespecific
action
Application 2-115
Cookies (continued)
what cookies can bring:
 authorization
 shopping carts
 recommendations
 user session state
(Web e-mail)
aside
cookies and privacy:
 cookies permit sites to
learn a lot about you
 you may supply name
and e-mail to sites
how to keep “state”:
 protocol endpoints: maintain state
at sender/receiver over multiple
transactions
 cookies: http messages carry state
Application 2-116
Web caches (proxy server)
Goal: satisfy client request without involving origin server
 user sets browser:
Web accesses via
cache
 browser sends all
HTTP requests to
cache


object in cache: cache
returns object
else cache requests
object from origin
server, then returns
object to client
origin
server
client
client
Proxy
server
origin
server
Application 2-117
More about Web caching
 cache acts as both
client and server
 typically cache is
installed by ISP
(university, company,
residential ISP)
why Web caching?
 reduce response time
for client request
 reduce traffic on an
institution’s access
link.
 Internet dense with
caches: enables “poor”
content providers to
effectively deliver
content (but so does
P2P file sharing)
Application 2-118
Caching example
origin
servers
assumptions
 average object size = 100,000
bits
 avg. request rate from
institution’s browsers to origin
servers = 15/sec
 delay from institutional router
to any origin server and back
to router = 2 sec
consequences
public
Internet
1.5 Mbps
access link
institutional
network
10 Mbps LAN
 utilization on LAN = 15%
 utilization on access link = 100%
 total delay
= Internet delay +
access delay + LAN delay
= 2 sec + minutes + milliseconds
institutional
cache
Application 2-119
Caching example (cont)
possible solution
 increase bandwidth of access
link to, say, 10 Mbps
consequence
 utilization on LAN = 15%
 utilization on access link = 15%
 Total delay = Internet delay
+ access delay + LAN delay
= 2 sec + msecs + msecs
 often a costly upgrade
origin
servers
public
Internet
10 Mbps
access link
institutional
network
10 Mbps LAN
institutional
cache
Application 2-120
Caching example (cont)
origin
servers
possible solution:
 install cache
consequence
public
Internet
 suppose hit rate is 0.4


40% requests will be
satisfied almost
immediately
60% requests satisfied by
origin server
 utilization of access link
reduced to 60%, resulting in
negligible delays (say 10
msec)
 total avg delay = Internet
delay + access delay + LAN
delay = .6*(2.01) secs +
.4*milliseconds < 1.4 secs
1.5 Mbps
access link
institutional
network
10 Mbps LAN
institutional
cache
Application 2-121
Conditional GET
 Goal: don’t send object if
cache has up-to-date
cached version
 cache: specify date of
cached copy in HTTP
request
If-modified-since:
<date>
server
cache
HTTP request msg
If-modified-since: <date>
HTTP response
HTTP/1.0
304 Not Modified
object
not
modified
before
<date>
 server: response contains
no object if cached copy is
up-to-date:
HTTP/1.0 304 Not
Modified
HTTP request msg
If-modified-since: <date>
HTTP response
HTTP/1.0 200 OK
<data>
object
modified
after
<date>
Application 2-122
Chapter 2: Application layer
2.1 Principles of network
applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic mail

2.6 P2P applications
2.7 Socket programming
with TCP
2.8 Socket programming
with UDP
SMTP, POP3, IMAP
2.5 DNS
Application 2-123
FTP: the file transfer protocol
user
at host
FTP
FTP
user
client
interface
file transfer
local file
system
FTP
server
remote file
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

Application 2-124
FTP: separate control, data connections
TCP control connection,
server port 21
 FTP client contacts FTP server




at port 21, TCP is transport
protocol
client authorized over control
connection
client browses remote
directory by sending commands
over control connection.
when server receives file
transfer command, server
opens 2nd TCP connection (for
file) to client
after transferring one file,
server closes data connection.
FTP
client



TCP data connection,
server port 20
FTP
server
server opens another TCP
data connection to transfer
another file.
control connection: “out of
band”
FTP server maintains “state”:
current directory, earlier
authentication
Application 2-125
FTP commands, responses
sample commands:
sample return codes
 sent as ASCII text over
 status code and phrase (as
control channel
 USER username
 PASS password
 LIST return list of file in


current directory
 RETR filename retrieves

 STOR filename stores

(gets) file
(puts) file onto remote
host
in HTTP)
331 Username OK,
password required
125 data connection
already open;
transfer starting
425 Can’t open data
connection
452 Error writing
file
Application 2-126
Chapter 2: Application layer
2.1 Principles of network
applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail

2.6 P2P applications
2.7 Socket programming
with TCP
2.8 Socket programming
with UDP
SMTP, POP3, IMAP
2.5 DNS
Application 2-127
Electronic Mail
outgoing
message queue
user mailbox
Three major components:
 user agents
 mail servers
 simple mail transfer
user
agent
mail
server
protocol: SMTP
User Agent
SMTP
 a.k.a. “mail reader”
 composing, editing, reading
mail
mail messages
server
 e.g., Outlook, elm, Mozilla
Thunderbird, iPhone mail
client
user
 outgoing, incoming messages
agent
stored on server
SMTP
SMTP
user
agent
mail
server
user
agent
user
agent
user
agent
Application 2-128
Electronic Mail: mail servers
user
agent
Mail Servers
 mailbox contains incoming
messages for user
 message queue of outgoing
(to be sent) mail messages
 SMTP protocol between mail
servers to send email
messages
 client: sending mail
server
 “server”: receiving mail
server
mail
server
SMTP
SMTP
mail
server
user
agent
SMTP
user
agent
mail
server
user
agent
user
agent
user
agent
Application 2-129
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
Application 2-130
Scenario: Alice sends message to Bob
1) Alice uses UA to compose
message and “to”
bob@someschool.edu
2) Alice’s UA sends message
to her mail server; message
placed in message queue
3) Client side of SMTP opens
TCP connection with Bob’s
mail server
1
user
agent
2
mail
server
3
4) SMTP client sends Alice’s
message over the TCP
connection
5) Bob’s mail server places the
message in Bob’s mailbox
6) Bob invokes his user agent
to read message
mail
server
4
5
6
user
agent
Application 2-131
Sample SMTP interaction
S:
C:
S:
C:
S:
C:
S:
C:
S:
C:
C:
C:
S:
C:
S:
220 hamburger.edu
HELO crepes.fr
250 Hello crepes.fr, pleased to meet you
MAIL FROM: <alice@crepes.fr>
250 alice@crepes.fr... Sender ok
RCPT TO: <bob@hamburger.edu>
250 bob@hamburger.edu ... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Do you like ketchup?
How about pickles?
.
250 Message accepted for delivery
QUIT
221 hamburger.edu closing connection
Application 2-132
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)
Application 2-133
SMTP: final words
 SMTP uses persistent
connections
 SMTP requires message
(header & body) to be in 7bit ASCII
 SMTP server uses
CRLF.CRLF to determine
end of message
comparison with HTTP:
 HTTP: pull
 SMTP: push
 both have ASCII
command/response
interaction, status codes
 HTTP: each object
encapsulated in its own
response msg
 SMTP: multiple objects
sent in multipart msg
Application 2-134
Mail message format
SMTP: protocol for
exchanging email msgs
RFC 822: standard for text
message format:
 header lines, e.g.,
To:
 From:
 Subject:
different from SMTP
commands!

header
blank
line
body
 body

the “message”, ASCII
characters only
Application 2-135
Mail access protocols
user
agent
SMTP
SMTP
sender’s mail
server
access
protocol
user
agent
receiver’s mail
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: gmail, Hotmail, Yahoo! Mail, etc.
Application 2-136
POP3 protocol
authorization phase
 client commands:
user: declare username
 pass: password
 server responses
 +OK
 -ERR

transaction phase, client:
 list: list message numbers
 retr: retrieve message by
number
 dele: delete
 quit
S:
C:
S:
C:
S:
+OK POP3 server ready
user bob
+OK
pass hungry
+OK user successfully logged
C:
S:
S:
S:
C:
S:
S:
C:
C:
S:
S:
C:
C:
S:
list
1 498
2 912
.
retr 1
<message 1 contents>
.
dele 1
retr 2
<message 1 contents>
.
dele 2
quit
+OK POP3 server signing off
on
Application 2-137
POP3 (more) and IMAP
more about POP3
 previous example uses
“download and delete”
mode.
 Bob cannot re-read email if he changes
client
 “download-and-keep”:
copies of messages on
different clients
 POP3 is stateless
across sessions
IMAP
 keeps all messages in
one place: at server
 allows user to organize
messages in folders
 keeps user state
across sessions:

names of folders and
mappings between
message IDs and folder
name
Application 2-138
Chapter 2: Application layer
 2.1 Principles of
network applications
 2.2 Web and HTTP
 2.3 FTP
 2.4 Electronic Mail

 2.6 P2P applications
 2.7 Socket programming
with TCP
 2.8 Socket programming
with UDP
SMTP, POP3, IMAP
 2.5 DNS
Application 2-139
DNS: Domain Name System
people: many identifiers:

SSN, name, passport #
Internet hosts, routers:


IP address (32 bit) used for addressing
datagrams
“name”, e.g.,
www.yahoo.com - used
by humans
Q: map between IP
address and name, and
vice versa ?
Domain Name System:
 distributed database
implemented in hierarchy of
many name servers
 application-layer protocol
host, routers, name servers to
communicate to resolve names
(address/name translation)
 note: core Internet
function, implemented as
application-layer protocol
 complexity at network’s
“edge”
Application 2-140
DNS
DNS services
 hostname to IP
address translation
 host aliasing

Canonical, alias names
 mail server aliasing
 load distribution
 replicated Web
servers: set of IP
addresses for one
canonical name
Why not centralize DNS?
 single point of failure
 traffic volume
 distant centralized
database
 maintenance
doesn’t scale!
Application 2-141
Distributed, Hierarchical Database
Root DNS Servers
com DNS servers
yahoo.com
amazon.com
DNS servers DNS servers
org DNS servers
pbs.org
DNS servers
edu DNS servers
poly.edu
umass.edu
DNS serversDNS 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
Application 2-142
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 LA)
d U Maryland College Park, MD
g US DoD Vienna, VA
h ARL Aberdeen, MD
j Verisign, ( 21 locations)
e NASA Mt View, CA
f Internet Software C. Palo Alto,
k RIPE London (also 16 other locations)
i Autonomica, Stockholm (plus
28 other locations)
m WIDE Tokyo (also Seoul,
Paris, SF)
CA (and 36 other locations)
13 root name
servers worldwide
b USC-ISI Marina del Rey, CA
l ICANN Los Angeles, CA
Application 2-143
TLD and 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 DNS servers, providing
authoritative hostname to IP mappings for
organization’s servers (e.g., Web, mail).
 can be maintained by organization or service
provider

Application 2-144
Local 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

acts as proxy, forwards query into hierarchy
Application 2-145
DNS name
resolution example
root DNS server
2
 host at cis.poly.edu
3
wants IP address for
gaia.cs.umass.edu
iterated query:


contacted server
replies with name of
server to contact
“I don’t know this
name, but ask this
server”
TLD DNS server
4
5
local DNS server
dns.poly.edu
1
8
7
6
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu
gaia.cs.umass.edu
Application 2-146
DNS name
resolution example
recursive query:


root DNS server
2
puts burden of name
7
resolution on
contacted name
server
local DNS server
heavy load?
dns.poly.edu
1
3
6
TLD DNS server
5
4
8
authoritative DNS server
dns.cs.umass.edu
requesting host
cis.poly.edu
gaia.cs.umass.edu
Application 2-147
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 proposed IETF
standard

RFC 2136
Application 2-148
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name,
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
value, type, ttl)
Type=CNAME
 name is alias name for some
“canonical” (the real) name
 www.ibm.com is really
servereast.backup2.ibm.com
 value is canonical name
Type=MX
 value is name of mailserver
associated with name
Application 2-149
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
Application 2-150
DNS protocol, messages
Name, type fields
for a query
RRs in response
to query
records for
authoritative servers
additional “helpful”
info that may be used
Application 2-151
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
 How do people get IP address of your Web site?
Application 2-152
Chapter 2: Application layer
2.1 Principles of network
applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail

2.6 P2P applications
2.7 Socket programming
with TCP
2.8 Socket programming
with UDP
SMTP, POP3, IMAP
2.5 DNS
Application 2-153
Future Client Server Nets: Beyond
IP Networking
Building Large Networks (at the edge)…
 Large Scale Ethernets and enterprise
networks - Scaling Ethernets to millions of
nodes
 Building networks for the backend of the
Internet – networks for cloud computing and
data centers
Slides in this section by Prof. Zhi-Li Zhang, UMN
Advanced Networking Course CSci5221
154
Even within a Single Administrative Domain
 Large ISPs and enterprise
networks
 Large data centers with
thousands or tens of
thousands machines
 Metro Ethernet
 More and more devices are
“Internet-capable” and
plugged in
 Likely rich and more diverse
network topology and
connectivity
155
Data Center Networks
 Data centers
Backend of the Internet
 Mid- (most enterprises) to mega-scale (Google,
Yahoo, MS, etc.)

• E.g., A regional DC of a major on-line service provider
consists of 25K servers + 1K switches/routers
 To ensure business continuity, and to lower
operational cost, DCs must
Adapt to varying workload  Breathing
 Avoid/Minimize service disruption (when
maintenance, or failure)  Agility
 Maximize aggregate throughput  Load balancing

156
Challenges posed by These Trends
 Scalability: capability to connect tens of thousands,
millions or more users and devices

routing table size, constrained by router memory, lookup speed
 Mobility: hosts are more mobile
 need to separate location (“addressing”) and identity (“naming”)
 Availability & Reliability: must be resilient to failures
 need to be “proactive” instead of reactive
 need to localize effect of failures
 Manageability: ease of deployment, “plug-&-play”

need to minimize manual configuration
 self-configure, self-organize, while ensuring security and trust
 …….
157
Quick Overview of Ethernet
 Dominant wired LAN technology
 Covers the first IP-hop in most enterprises/campuses
 First widely used LAN technology
 Simpler, cheaper than token LANs, ATM, and IP
 Kept up with speed race: 10 Mbps and now to 40
Gbps

Soon 100 Gbps would be widely available
Metcalfe’s
Ethernet
sketch
158
Ethernet Frame Structure
 Addresses: source and destination MAC
addresses
Flat, globally unique, and permanent 48-bit
value
 Adaptor passes frame to network-level protocol

• If destination address matches the adaptor
• Or the destination address is the broadcast address

Otherwise, adapter discards frame
 Type: indicates the higher layer protocol
 Usually IP
159
Interaction w/ the Upper Layer (IP)
 Bootstrapping end hosts by automating host configuration (e.g., IP
address assignment)


DHCP (Dynamic Host Configuration Protocol)
Broadcast DHCP discovery and request messages
 Bootstrapping each conversation by enabling resolution from IP to MAC
addr


ARP (Address Resolution Protocol)
Broadcast ARP requests
 Both protocols work via Ethernet-layer broadcasting (i.e., shouting!)

Ethernet broadcast domain - A group of hosts and switches to which the same
broadcast or flooded frame is delivered
 Too large a broadcast domain leads to


160
Excessive flooding and broadcasting overhead
Insufficient security/performance isolation
State of the Practice:
A Hybrid Architecture
Enterprise networks comprised of Ethernet-based
IP subnets interconnected by routers
Ethernet Bridging
-
Flat addressing
Self-learning
Flooding
Forwarding along a tree
Broadcast Domain
(LAN or VLAN)
161
R
R
IP Routing (e.g., OSPF)
-
Hierarchical addressing
Subnet configuration
Host configuration
Forwarding along shortest paths
R
R
R
Ethernet Bridging: “Routing” at L2
 Routing determines paths to destinations
through which traffic is forwarded
 Routing takes place at any layer (including L2)
where devices are reachable across multiple
hops
App Layer
P2P, or CDN routing
Overlay routing
IP Layer
Link Layer
162
IP routing
Ethernet bridging
Ethernet (Layer-2) “Routing”
 Self-learning algorithm for dynamically building switch
(forwarding) tables
 “Eavesdrop” on source MACs of data packets
 Associate source MACs with port # (cached, “soft-state”)
 Forwarding algorithm

Forwarding algorithm
If dst MAC found in switch table, send to the corresp. port
 Otherwise, flood to all ports (except the one it comes from)
 Dealing with “loopy” topologies
 Running (periodically) spanning tree algorithm to convert it
into a tree (rooted at an “arbitrary” node)
 802.11 Wireless LANs use somewhat similar methods
 Use the same 48-bit MAC addresses more complex frame
structures;
 End hosts need to explicitly associate with APs

163
Layer 2 vs. Layer 3 Again
Neither bridging nor routing is satisfactory.
Can’t we take only the best of each?
Architectures
Features
Ease of configuration
Optimality in addressing
Host mobility
Path efficiency
Load distribution
Convergence speed
Tolerance to loop
Ethernet
Bridging
IP
Routing
SEATTLE





















164
SEATTLE
(Scalable Ethernet ArchiTecTure for Larger Enterprises)
 Plug-and-playable enterprise architecture ensuring both scalability
and efficiency
 Objectives
 Avoiding flooding
 Restraining broadcasting
 Keeping forwarding tables small
 Ensuring path efficiency
 SEATTLE architecture – design principles
 Hash-based location management
 Shortest-path forwarding
 Responding to network dynamics (reactive location resolution
and caching)
 Lessons

165
Trading a little data-plane efficiency for huge control-plane scalability
makes a qualitatively different system
Seattle
x
Deliver to x
Host discovery
or registration
C
End-hosts
Control flow
Data flow
167
y
Traffic to x
A
Hash
(F(x) = B)
Tunnel to
egress node, A
Entire enterprise
(A large single IP subnet)
Switches
Optimized forwarding
directly from D to A
Tunnel to
relay switch, B
LS core
Notifying
<x, A> to D
B
Store
<x, A> at B
D
Hash
(F(x) = B)
E
Cloud Computing
and Data Centers
Why Study this:
 they represent part of current and “future” trends


how applications will be serviced, delivered, …
what are important “new” networking problems?
 more importantly, what lessons can we learn in terms of
(future) networking design?


168
closely related, and there are many similar issues/challenges
(availability, reliability, scalability, manageability, ….)
(but of course, there are also unique challenges in networking)
Internet and Web
 Simple client-server model
a number of clients served by a single server
 performance determined by “peak load”
 doesn’t scale well (e.g., server crashes), when # of
clients suddenly increases -- “flash crowd”
 From single server to blade server to server farm (or
data center)

169
Internet and Web …
 From “traditional” web to “web service” (or SOA)

no longer simply “file” (or web page) downloads
• pages often dynamically generated, more complicated “objects”
(e.g., Flash videos used in YouTube)

HTTP is used simply as a “transfer” protocol
• many other “application protocols” layered on top of HTTP
web services & SOA (service-oriented architecture)
 A schematic representation of “modern” web services

web rendering, request routing, database, storage, computing, …
aggregators, …
front-end
back-end
170
Data Center and Cloud Computing
 Data center: large server farms + data warehouses
not simply for web/web services
 managed infrastructure: expensive!
 From web hosting to cloud computing
 individual web/content providers: must provision for peak load

• Expensive, and typically resources are under-utilized


web hosting: third party provides and owns the (server farm)
infrastructure, hosting web services for content providers
“server consolidation” via virtualization
Under client web
service control
App
Guest OS
VMM
171
Cloud Computing
 Cloud computing and cloud-based services:
beyond web-based “information access” or
“information delivery”
 computing, storage, …
 Cloud Computing: NIST Definition

"Cloud computing is a model for enabling convenient, on-demand network
access to a shared pool of configurable computing resources (e.g.,
networks, servers, storage, applications, and services) that can be rapidly
provisioned and released with minimal management effort or service
provider interaction."
 Models of Cloud Computing

“Infrastructure as a Service” (IaaS), e.g., Amazon EC2,
Rackspace
“Platform as a Service” (PaaS), e.g., Micorsoft Azure
172
 “Software as a Service” (SaaS), e.g., Google

Data Centers: Key Challenges
With thousands of servers within a data center,
 How to write applications (services) for them?
 How to allocate resources, and manage them?

in particular, how to ensure performance, reliability, availability, …
 Scale and complexity bring other key challenges


with thousands of machines, failures are the default case!
load-balancing, handling “heterogeneity,” …
 data center (server cluster) as a “computer”
 “super-computer” vs. “cluster computer”



A single “super-high-performance” and highly reliable computer
vs. a “computer” built out of thousands of “cheap & unreliable” PCs
Pros and cons?
173
Data Center Networking
Major Theme:
What are new networking issues posed by
large-scale data centers?
 Network Architecture?
 Topology design?
 Addressing?
 Routing?
 Forwarding?
180
CSci5221: Data Center Networking, and LargeScale Enterprise Networks: Part I
Data Center Interconnection
Structure
 Nodes in the system: racks of servers
 How are the nodes (racks) inter-
connected?

Typically a hierarchical inter-connection structure
 Today’s typical data center structure
Cisco recommended data center structure:
starting from the bottom level
 rack switches
 1-2 layers of (layer-2) aggregation switches
 access routers
 core routers
 Is such an architecture good enough?
181
Cisco Recommended DC Structure:
Illustration
Internet
Internet
CR
Data Center
Layer 3
Layer 2
LB
S
AR
S
S
S
…
182
AR
CR
…
AR
AR
LB
S
S
…
…
Key:
• CR = L3 Core Router
• AR = L3 Access Router
• S = L2 Switch
• LB = Load Balancer
• A = Rack of 20 servers
with Top of Rack switch
Data Center Design Requirements
 Data centers typically run two types of applications


outward facing (e.g., serving web pages to users)
internal computations (e.g., MapReduce for web indexing)
 Workloads often unpredictable:


Multiple services run concurrently within a DC
Demand for new services may spike unexpected
• Spike of demands for new services mean success!
• But this is when success spells trouble (if not prepared)!
 Failures of servers are the norm


183
Recall that GFS, MapReduce, etc., resort to dynamic re-assignment
of chunkservers, jobs/tasks (worker servers) to deal with failures;
data is often replicated across racks, …
“Traffic matrix” between servers are constantly changing
Data Center Costs
 Data centers typically run two types of applications
 outward facing (e.g., serving web pages to users)
 internal computations (e.g., MapReduce for web indexing)
 Workloads often unpredictable:
 Multiple services run concurrently within a DC
 Demand for new services may spike unexpected
• Spike of demands for new services mean success!
• But this is when success spells trouble (if not prepared)!
 Failures of servers are the norm
 Recall that GFS, MapReduce, etc., resort to dynamic reassignment of chunkservers, jobs/tasks (worker servers) to
deal with failures; data is often replicated across racks, …
 “Traffic matrix” between servers are constantly changing
184
Data Center Costs
Amortized Cost*
Component
Sub-Components
~45%
Servers
CPU, memory, disk
~25%
Power infrastructure UPS, cooling, power distribution
~15%
Power draw
Electrical utility costs
~15%
Network
Switches, links, transit
*3 yr amortization for servers, 15 yr for infrastructure; 5% cost of money
 Total cost varies



upwards of $1/4 B for mega data center
server costs dominate
network costs significant
 Long provisioning timescales:

new servers purchased quarterly at best
Source: the Cost of a Cloud: Research Problems in Data Center Networks. Sigcomm CCR 2009.
Greenberg, Hamilton, Maltz, Patel.
185
Goal: Agility- any service, any server

Turn the servers into a single large fungible pool


Let services “breathe” : dynamically expand and contract their footprint as needed
Benefits



Increase service developer productivity
Lower cost
Achieve high performance and reliability
Achieving Agility

Workload Management


means for rapidly installing a service’s code on a server
dynamical cluster scheduling and server assignment 
•



means for a server to access persistent data
distributed file systems (e.g., GFS) 
Network Management


186
virtual machines, disk images 
Storage Management


E.g., MapReduce, Bigtable, …
Means for communicating with other servers, regardless of where they are in the data center
Achieve high performance and reliability
Networking Objectives
1.
Uniform high capacity


Capacity between servers limited only by their NICs
No need to consider topology when adding servers
=> In other words, high capacity between two any servers no
matter which racks they are located !
2. Performance isolation

Traffic of one service should be unaffected by others
3. Ease of management: “Plug-&-Play” (layer-2 semantics)

Flat addressing, so any server can have any IP address

Server configuration is the same as in a LAN

Legacy applications depending on broadcast must work
187
Is Today’s DC Architecture Adequate?
• Hierarchical network; 1+1 redundancy
• Equipment higher in the hierarchy handles more traffic
• more expensive, more efforts made at availability  scale-up design
• Servers connect via 1 Gbps UTP to Top-of-Rack switches
• Other links are mix of 1G, 10G; fiber, copper
Uniform high capacity?
Performance isolation?
•
•
typically via VLANs
Agility in terms of
dynamically adding or
shrinking servers?
Agility in terms of
adapting to failures, and
to traffic dynamics?
Ease of management?
•
•
•
188
Internet
Internet
CR
Data Center
Layer 3
Layer 2
LB
S
AR
AR
S
S
S
…
S
CR
AR
…
LB
S
…
…
AR
Key:
• CR = L3 Core
Router
• AR = L3 Access
Router
• S = L2 Switch
• LB = Load
Balancer
• A = Top of Rack
switch
Recent Work
 A Scalable, Commodity Data Center Network Architecture

a new Fat-tree “inter-connection” structure (topology) to
increases “bi-section” bandwidth
• needs “new” addressing, forwarding/routing
 VL2: A Scalable and Flexible Data Center Network
consolidate layer-2/layer-3 into a “virtual layer
2”
 separating “naming” and “addressing”, also deal
with dynamic load-balancing issues

 PortLand: A Scalable Fault-Tolerant Layer 2 Data Center
Network Fabric
 BCube: A High-Performance, Server-centric Network
Architecture for Modular Data Centers
189
A Scalable, Commodity Data Center
Network Architecture
 Main Goal: addressing the limitations of today’s data center
network architecture


single point of failure
oversubscription of links higher up in the topology
• trade-offs between cost and providing
 Key Design Considerations/Goals

Allows host communication at line speed
• no matter where they are located!

Backwards compatible with existing infrastructure
• no changes in application & support of layer 2 (Ethernet)

Cost effective
• cheap infrastructure
• and low power consumption & heat emission
190
Fat-Tree Based DC Architecture
 Inter-connect racks (of servers) using a fat-tree topology
 Fat-Tree: a special type of Clos Networks (after C. Clos)
K-ary fat tree: three-layer topology (edge, aggregation and core)
 each pod consists of (k/2)2 servers & 2 layers of k/2 k-port switches
 each edge switch connects to k/2 servers & k/2 aggr. switches
 each aggr. switch connects to k/2 edge & k/2 core switches
 (k/2)2 core switches: each connects to k pods
Fat-tree
with K=2
191
Fat-Tree Based Topology …
 Why Fat-Tree?
 Fat tree has identical bandwidth at any bisections
 Each layer has the same aggregated bandwidth
 Can be built using cheap devices with uniform capacity
 Each port supports same speed as end host
 All devices can transmit at line speed if packets are distributed
uniform along available paths
 Great scalability
Fat tree network with K = 3 supporting 54 hosts
192
Cost of Maintaining Switches
193
Fat-tree Topology is Great, But …
Does using fat-tree topology to inter-connect racks
of servers in itself sufficient?
 What routing protocols should we run on these
switches?
 Layer 2 switch algorithm: data plane flooding!
 Layer 3 IP routing:


194
shortest path IP routing will typically use only one path
despite the path diversity in the topology
if using equal-cost multi-path routing at each switch
independently and blindly, packet re-ordering may occur;
further load may not necessarily be well-balanced
FAT-Tree Modified
 Enforce a special (IP) addressing scheme in
DC
unused.PodNumber.switchnumber.Endhost
 Allows host attached to same switch to route
only through switch
 Allows inter-pod traffic to stay within pod

 Use two level look-ups to distribute traffic
•
and maintain packet ordering
•
195
First level is prefix lookup
– used to route down the topology
to servers
Second level is a suffix lookup
– used to route up towards core
– maintain packet ordering by using
same ports for same server
More on Fat-Tree DC Architecture
Diffusion Optimizations
 Flow classification
Eliminates local congestion
 Assign to traffic to ports on a per-flow basis
instead of a per-host basis

 Flow scheduling
Eliminates global congestion
 Prevent long lived flows from sharing the same
links
 Assign long lived flows to different links

196
ADDITIONAL SLIDES
Introduction
1-197
Chapter 1: roadmap
1.1 What is the Internet?
1.2 Network edge

end systems, access networks, links
1.3 Network core

circuit switching, packet switching, network structure
1.4 Delay, loss and throughput in packet-switched
networks
1.5 Protocol layers, service models
1.6 Networks under attack: security
1.7 History
Introduction 1-198
How do loss and delay occur?
packets queue in router buffers


packet arrival rate to link exceeds output link capacity
packets queue, wait for turn
packet being transmitted (delay)
A
B
packets queueing (delay)
free (available) buffers: arriving packets
dropped (loss) if no free buffers
Introduction 1-199
Four sources of packet delay
transmission
A
propagation
B
nodal
processing
queueing
dnodal = dproc + dqueue + dtrans + dprop
dproc: nodal processing
 check bit errors
 determine output link
 typically < msec
dqueue: queueing delay
 time waiting at output link
for transmission
 depends on congestion level
of router
Introduction 1-200
Four sources of packet delay
transmission
A
propagation
B
nodal
processing
queueing
dnodal = dproc + dqueue + dtrans + dprop
dtrans: transmission delay:
 L: packet length (bits)
 R: link bandwidth (bps)
 dtrans = L/R
dtrans and dprop
very different
dprop: propagation delay:
 d: length of physical link
 s: propagation speed in
medium (~2x108 m/sec)
 dprop = d/s
Introduction 1-201
Caravan analogy
100 km
ten-car
caravan




toll
booth
cars “propagate” at
100 km/hr
toll booth takes 12 sec to
service car (transmission
time)
car~bit; caravan ~ packet
Q: How long until caravan
is lined up before 2nd toll
booth?
100 km
toll
booth
 time to “push” entire
caravan through toll
booth onto highway =
12*10 = 120 sec
 time for last car to
propagate from 1st to
2nd toll both:
100km/(100km/hr)= 1 hr
 A: 62 minutes
Introduction 1-202
Caravan analogy (more)
100 km
ten-car
caravan



toll
booth
100 km
toll
booth
cars now “propagate” at 1000 km/hr
toll booth now takes 1 min to service a car
Q: Will cars arrive to 2nd booth before all cars
serviced at 1st booth?
 A: Yes! After 7 min, 1st car arrives at second booth; three
cars still at 1st booth.
 1st bit of packet can arrive at 2nd router before packet is
fully transmitted at 1st router! (see Ethernet applet at AWL
Web site
Introduction 1-203



R: link bandwidth (bps)
L: packet length (bits)
a: average packet
arrival rate
average queueing
delay
Queueing delay (revisited)
traffic intensity
= La/R



La/R ~ 0: avg. queueing delay small
La/R -> 1: avg. queueing delay large
La/R > 1: more “work” arriving
than can be serviced, average delay infinite!
La/R ~ 0
La/R -> 1
Introduction 1-204
“Real” Internet delays and routes


What do “real” Internet delay & loss look like?
Traceroute program: provides delay
measurement from source to router along end-end
Internet path towards destination. For all i:
 sends three packets that will reach router i on path
towards destination
 router i will return packets to sender
 sender times interval between transmission and reply.
3 probes
3 probes
3 probes
Introduction 1-205
“Real” Internet delays and routes
traceroute: gaia.cs.umass.edu to www.eurecom.fr
Three delay measurements from
gaia.cs.umass.edu to cs-gw.cs.umass.edu
1 cs-gw (128.119.240.254) 1 ms 1 ms 2 ms
2 border1-rt-fa5-1-0.gw.umass.edu (128.119.3.145) 1 ms 1 ms 2 ms
3 cht-vbns.gw.umass.edu (128.119.3.130) 6 ms 5 ms 5 ms
4 jn1-at1-0-0-19.wor.vbns.net (204.147.132.129) 16 ms 11 ms 13 ms
5 jn1-so7-0-0-0.wae.vbns.net (204.147.136.136) 21 ms 18 ms 18 ms
6 abilene-vbns.abilene.ucaid.edu (198.32.11.9) 22 ms 18 ms 22 ms
7 nycm-wash.abilene.ucaid.edu (198.32.8.46) 22 ms 22 ms 22 ms trans-oceanic
8 62.40.103.253 (62.40.103.253) 104 ms 109 ms 106 ms
link
9 de2-1.de1.de.geant.net (62.40.96.129) 109 ms 102 ms 104 ms
10 de.fr1.fr.geant.net (62.40.96.50) 113 ms 121 ms 114 ms
11 renater-gw.fr1.fr.geant.net (62.40.103.54) 112 ms 114 ms 112 ms
12 nio-n2.cssi.renater.fr (193.51.206.13) 111 ms 114 ms 116 ms
13 nice.cssi.renater.fr (195.220.98.102) 123 ms 125 ms 124 ms
14 r3t2-nice.cssi.renater.fr (195.220.98.110) 126 ms 126 ms 124 ms
15 eurecom-valbonne.r3t2.ft.net (193.48.50.54) 135 ms 128 ms 133 ms
16 194.214.211.25 (194.214.211.25) 126 ms 128 ms 126 ms
17 * * *
* means no response (probe lost, router not replying)
18 * * *
19 fantasia.eurecom.fr (193.55.113.142) 132 ms 128 ms 136 ms
Introduction 1-206
Packet loss
queue (aka buffer) preceding link in buffer has
finite capacity
 packet arriving to full queue dropped (aka lost)
 lost packet may be retransmitted by previous
node, by source end system, or not at all

buffer
(waiting area)
A
B
packet being transmitted
packet arriving to
full buffer is lost
Introduction 1-207
Throughput

throughput: rate (bits/time unit) at which
bits transferred between sender/receiver
 instantaneous: rate at given point in time
 average: rate over longer period of time
link
capacity
that
can carry
server,
with
server
sends
bits pipe
Rs bits/sec
fluid
at rate
file of
F bits
(fluid)
into
pipe
Rs bits/sec)
to send to client
link that
capacity
pipe
can carry
Rfluid
c bits/sec
at rate
Rc bits/sec)
Introduction 1-208
Throughput (more)

Rs < Rc What is average end-end throughput?
Rs bits/sec

Rc bits/sec
Rs > Rc What is average end-end throughput?
Rs bits/sec
Rc bits/sec
bottleneck link
link on end-end path that constrains end-end throughput
Introduction 1-209
Throughput: Internet scenario
per-connection
end-end
throughput:
min(Rc,Rs,R/10)
 in practice: Rc or
Rs is often
bottleneck

Rs
Rs
Rs
R
Rc
Rc
Rc
10 connections (fairly) share
backbone bottleneck link R bits/sec
Introduction 1-210
Chapter 2: Application layer
2.1 Principles of network
applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail

2.6 P2P applications
2.7 Socket programming
with TCP
2.8 Socket programming
with UDP
SMTP, POP3, IMAP
2.5 DNS
Application 2-219
Socket programming
Goal: learn how to build client/server application that
communicate using sockets
Socket API
 introduced in BSD4.1 UNIX,
1981
 explicitly created, used,
released by apps
 client/server paradigm
 two types of transport
service via socket API:
 unreliable datagram
 reliable, byte streamoriented
socket
a host-local,
application-created,
OS-controlled interface
(a “door”) into which
application process can
both send and
receive messages to/from
another application
process
Application 2-220
Socket-programming using TCP
Socket: a door between application process and endend-transport protocol (UCP or TCP)
TCP service: reliable transfer of bytes from one
process to another
controlled by
application
developer
controlled by
operating
system
process
process
socket
TCP with
buffers,
variables
socket
TCP with
buffers,
variables
host or
server
internet
controlled by
application
developer
controlled by
operating
system
host or
server
Application 2-221
Socket programming with TCP
Client must contact server
 server process must first
be running
 server must have created
socket (door) that
welcomes client’s contact
Client contacts server by:
 creating client-local TCP
socket
 specifying IP address, port
number of server process
 when client creates socket:
client TCP establishes
connection to server TCP
 when contacted by client,
server TCP creates new
socket for server process to
communicate with client
 allows server to talk with
multiple clients
 source port numbers
used to distinguish
clients (more in Chap 3)
application viewpoint
TCP provides reliable, in-order
transfer of bytes (“pipe”)
between client and server
Application 2-222
Client/server socket interaction: TCP
Server (running on hostid)
Client
create socket,
port=x, for
incoming request:
welcomeSocket =
ServerSocket()
TCP
wait for incoming
connection request connection
connectionSocket =
welcomeSocket.accept()
read request from
connectionSocket
write reply to
connectionSocket
close
connectionSocket
setup
create socket,
connect to hostid, port=x
clientSocket =
Socket()
send request using
clientSocket
read reply from
clientSocket
close
clientSocket
Application 2-223
Stream jargon
Client
Process
process
output
stream
inFromServer
characters that flow into
or out of a process.
 input stream is attached to
some input source for the
process, e.g., keyboard or
socket.
 output stream is attached
to an output source, e.g.,
monitor or socket.
input
stream
outToServer
 stream is a sequence of
monitor
inFromUser
keyboard
input
stream
client
TCP
clientSocket
socket
to network
TCP
socket
from network
Application 2-224
Socket programming with TCP
Example client-server app:
1) client reads line from
standard input (inFromUser
stream) , sends to server via
socket (outToServer
stream)
2) server reads line from socket
3) server converts line to
uppercase, sends back to
client
4) client reads, prints modified
line from socket
(inFromServer stream)
Application 2-225
Example: Java client (TCP)
import java.io.*;
import java.net.*;
class TCPClient {
create
input stream
create
clientSocket object
of type Socket,
connect to server
create
output stream
attached to socket
This package defines Socket()
and ServerSocket() classes
public static void main(String argv[]) throws Exception
{
server name,
String sentence;
e.g., www.umass.edu
String modifiedSentence;
server port #
BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
Socket clientSocket = new Socket("hostname", 6789);
DataOutputStream outToServer =
new DataOutputStream(clientSocket.getOutputStream());
Application 2-226
Example: Java client (TCP), cont.
create
input stream
attached to socket
BufferedReader inFromServer =
new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
sentence = inFromUser.readLine();
send line
to server
outToServer.writeBytes(sentence + '\n');
read line
from server
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
close socket
clientSocket.close();
(clean up behind yourself!)
}
}
Application 2-227
Example: Java server (TCP)
import java.io.*;
import java.net.*;
class TCPServer {
create
welcoming socket
at port 6789
wait, on welcoming
socket accept() method
for client contact create,
new socket on return
create input
stream, attached
to socket
public static void main(String argv[]) throws Exception
{
String clientSentence;
String capitalizedSentence;
ServerSocket welcomeSocket = new ServerSocket(6789);
while(true) {
Socket connectionSocket = welcomeSocket.accept();
BufferedReader inFromClient =
new BufferedReader(new
InputStreamReader(connectionSocket.getInputStream()));
Application 2-228
Example: Java server (TCP), cont
create output
stream, attached
to socket
DataOutputStream outToClient =
new DataOutputStream(connectionSocket.getOutputStream());
read in line
from socket
clientSentence = inFromClient.readLine();
capitalizedSentence = clientSentence.toUpperCase() + '\n';
write out line
to socket
outToClient.writeBytes(capitalizedSentence);
}
}
}
end of while loop,
loop back and wait for
another client connection
Application 2-229
Chapter 2: Application layer
2.1 Principles of network
applications
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail

2.6 P2P applications
2.7 Socket programming
with TCP
2.8 Socket programming
with UDP
SMTP, POP3, IMAP
2.5 DNS
Application 2-230
Socket programming with UDP
UDP: no “connection” between
client and server
 no handshaking
 sender explicitly attaches
IP address and port of
destination to each packet
 server must extract IP
address, port of sender
from received packet
application viewpoint:
UDP provides unreliable transfer
of groups of bytes (“datagrams”)
between client and server
UDP: transmitted data may be
received out of order, or
lost
Application 2-231
Client/server socket interaction: UDP
Server (running on hostid)
create socket,
port= x.
serverSocket =
DatagramSocket()
read datagram from
serverSocket
write reply to
serverSocket
specifying
client address,
port number
Client
create socket,
clientSocket =
DatagramSocket()
Create datagram with server IP and
port=x; send datagram via
clientSocket
read datagram from
clientSocket
close
clientSocket
Application 2-232
Example: Java client (UDP)
input
stream
Client
Process
monitor
inFromUser
keyboard
Input: receives
process
packet (recall
thatTCP received
“byte stream”)
UDP
packet
receivePacket
packet (recall
that TCP sent “byte
stream”)
sendPacket
Output: sends
UDP
packet
client
UDP
clientSocket
socket
to network
UDP
socket
from network
Application 2-233
Example: Java client (UDP)
import java.io.*;
import java.net.*;
create
input stream
create
client socket
translate
hostname to IP
address using DNS
class UDPClient {
public static void main(String args[]) throws Exception
{
BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
DatagramSocket clientSocket = new DatagramSocket();
InetAddress IPAddress = InetAddress.getByName("hostname");
byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
String sentence = inFromUser.readLine();
sendData = sentence.getBytes();
Application 2-234
Example: Java client (UDP), cont.
create datagram
with data-to-send,
length, IP addr, port
DatagramPacket sendPacket =
new DatagramPacket(sendData, sendData.length, IPAddress, 9876);
send datagram
to server
clientSocket.send(sendPacket);
read datagram
from server
clientSocket.receive(receivePacket);
DatagramPacket receivePacket =
new DatagramPacket(receiveData, receiveData.length);
String modifiedSentence =
new String(receivePacket.getData());
System.out.println("FROM SERVER:" + modifiedSentence);
clientSocket.close();
}
}
Application 2-235
Example: Java server (UDP)
import java.io.*;
import java.net.*;
create
datagram socket
at port 9876
class UDPServer {
public static void main(String args[]) throws Exception
{
DatagramSocket serverSocket = new DatagramSocket(9876);
byte[] receiveData = new byte[1024];
byte[] sendData = new byte[1024];
while(true)
{
create space for
received datagram
receive
datagram
DatagramPacket receivePacket =
new DatagramPacket(receiveData, receiveData.length);
serverSocket.receive(receivePacket);
Application 2-236
Example: Java server (UDP), cont
String sentence = new String(receivePacket.getData());
get IP addr
port #, of
sender
InetAddress IPAddress = receivePacket.getAddress();
int port = receivePacket.getPort();
String capitalizedSentence = sentence.toUpperCase();
sendData = capitalizedSentence.getBytes();
create datagram
to send to client
DatagramPacket sendPacket =
new DatagramPacket(sendData, sendData.length, IPAddress,
port);
write out
datagram
to socket
serverSocket.send(sendPacket);
}
}
}
end of while loop,
loop back and wait for
another datagram
Application 2-237
Chapter 2: Summary
our study of network apps now complete!
 application architectures
 client-server
 P2P
 hybrid






 application service
requirements:

reliability, bandwidth,
delay
specific protocols:

HTTP
FTP
SMTP, POP, IMAP
DNS
P2P: BitTorrent, Skype
socket programming
 Internet transport
service model


connection-oriented,
reliable: TCP
unreliable, datagrams: UDP
Application 2-238
Chapter 2: Summary
most importantly: learned about protocols
 typical request/reply
message exchange:


client requests info or
service
server responds with
data, status code
 message formats:
 headers: fields giving
info about data
 data: info being
communicated
Important themes:
 control vs. data msgs
 in-band, out-of-band
 centralized vs.
decentralized
 stateless vs. stateful
 reliable vs. unreliable
msg transfer
 “complexity at network
edge”
Application 2-239