18-441/741: Computer Networks Lectures 2: Protocol Stack
Swarun Kumar
1
Today’s Lecture
• Network applications
• Requirements
• Latency and bandwidth
• Internet architecture • Protocols
• A layered design • Life of a packet
• Network utilities
2
Applications and Application Protocols
• Application: communicating, distributed processes
• Running in network hosts in “user space”
• Exchange messages to implement app
• e.g., email, file transfer, Web • Application protocols
• One “piece” of an app
• Define messages exchanged
by apps and actions taken
• User services provided by lower layer protocols
application
transport network data link physical
application
transport network data link physical
application
transport network data link physical
3
Client-Server Paradigm
Typical network app has two pieces: client and server Client:
• Initiates contact with server (“speaks first”)
• Typically requests service
• Web: client is implemented in
browser; e-mail: in mail reader
Server:
• Provides a service to client
• e.g., Web server sends
requested Web page, mail server delivers e-mail
application
transport network data link physical
request
reply
application
transport network data link physical
4
Yesterday’s Applications
• FTP: transfer files to a host
• No distributed file systems!
• Mostly replaced by “the web” – http
• Telnet: use a computer remotely
• Similar to ssh today (minus the security)
• Mail: exchange electronic e-mail
• Similar today (kind of)
• Initially host-to-host: name@my.computer.edu
• Already very useful!
5
HTTP: The Hypertext Transfer Protocol
Requests / Dataà ß HT File transfer
HTTP browser
• Transfer (hypertext) files as they are requested
• Client/server model that allows clients to access multiple servers as
per their need
• The Hypertext markup language (HTML) allows for describing rich content (video, text, audio, images, etc)
• Project: will learn more about HTTP
HTTP server
user at host
remote file system
6
Today’s Applications
• Amazon, Facebook, etc.
• 2009 quote: “Amazon found every 100ms of latency cost them 1%
in sales”
• Video streaming (YouTube, Netflix, …)
• Accounts for very high percentage of bandwidth
• Interactive versus broadcast versus playback
• What matters most?
• Audio and video conferencing (Skype, Facetime,…)
• Traditional telephone app
• What matters most?
7
Requirements
• Performance:latencyandthroughput
• Networkreliability
• Network service must always be available
• Security:forusersandthenetworkitself
• Privacy, authentication, deal with various attacks, …
• Attacks on the network, versus enabled by the network
• Scalability.
• Scale to large numbers of users, traffic flows, …
• Manageability:monitoring,enforcingpolicies, billing, …
8
What Service Does an Application Need?
Data loss Timing
• Some apps (e.g., audio) can tolerate some loss
• Other apps (e.g., file transfer, telnet) require 100% reliable
data transfer
Bandwidth
• Some apps (e.g., Internet telephony, interactive games) require low delay to be “effective”
• Most apps are flexible
• Some apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”
• Other apps (“elastic apps”) make use of whatever bandwidth they can get
9
Transport Service Requirements of Common Apps
Application
file transfer e-mail web documents real-time audio/ video stored audio/video interactive games financial apps
Data loss
no loss
no loss
no loss loss-tolerant
loss-tolerant loss-tolerant no loss
Bandwidth
elastic
elastic
elastic
audio: 5Kb-1Mb video:10Kb-5Mb same as above few Kbps
elastic
Time Sensitive
no
no
no
yes, 100’s msec
yes, few secs yes, 100’s msec yes and no
10
A Closer Look at Packet Delay
Store & Forward Cut-through
Prop + xmit 2*(Prop + xmit) 2*prop + xmit
When does cut-through matter?
Next: Routers have finite speed (processing delay)
Routers may buffer packets (queueing delay)
11
Packet Delay Components
• Sum of a number of different delay components.
• Propagation delay on each link.
• Proportional to the length of the link
• Transmission delay on each link.
• Proportional to the packet size and 1/link speed • Processing delay on each router.
• Depends on the speed of the router • Queuing delay on each router.
• Depends on the traffic load and queue size DBCBAA
12
A Word about Units
• What do “Kilo” and “Mega” mean? • Depends on context
• Storage works in powers of two.
• 1Byte=8bits
• 1 KByte = 1024 Bytes
• 1 MByte = 1024 Kbytes
• Networks work in decimal units.
• Network hardware sends bits, not Bytes
• 1 Kbps = 1000 bits per second
• To avoid confusion, use 1 Kbit/second
• Why? Historical: CS versus ECE.
13
Application-level Delay
Delay of one packet
Average sustained
throughput
Size Throughput
Delay* +
Units: seconds + bits/(bits/seconds)
* For minimum sized packet
14
Sample Quiz Question
• How long does it take to send a 100 Kbit file? • Assume a perfect world.. Fill in the blanks..
• Is the transfer latency or throughput limited?
• What about a 10 Kbit file?
Throughput Latency
100 Kbit/s
1 Mbit/s
100 Mbit/s
500 μsec
10.01005
0.1010105
0.0001565
10 msec
10.011
0.0112
00.0.011011
100 msec
101.121
0..121
0..11011
15
A Closer Look at Throughput
• Whenstreamingpackets,thenetworkworks like a pipeline.
• All links forward different packets in parallel
• Throughputisdeterminedbytheslowest stage.
• Called the bottleneck link
• Doesnotmatterwhythelinkisslow!
• •
Low link bandwidth
Many users sharing the link bandwidth
50
30
17
267
37
104
59
16
Bandwidth Sharing
• Bandwidth received on the bottleneck link determines end-to-end throughput.
• Router before the bottleneck link decides how much bandwidth each user gets.
• Users that try to send at a higher rate will see packet loss
• User bandwidth can fluctuate quickly as flows are added or end, or as flows change their transmit rate.
BW 100
Time
17
Fair Sharing of Bandwidth
• All else being equal, fair means that users get equal treatment.
• Sounds fair
• When things are not equal, we need a policy that determines who gets how much bandwidth.
• Users who pay more get more bandwidth
• Users with a higher “rank” get more bandwidth
• Certain classes of applications get priority
BW 100
Time
18
But It is Not that Simple
Bottleneck
19
Today’s Lecture
• Network applications
• Requirements
• Latency and bandwidth
• Internet architecture • Protocols
• A layered design • Life of a packet
• Network utilities
20
Lots of Protocols (and Acronyms!)
• IP: Internet protocol
• UDP: User datagram protocol
• TCP: Transmission control protocol
• FTP: File transfer protocol
• SMTP: Simple mail transfer protocol
• HTTP: Hypertext transfer protocol
• ARP: Address resolution protocol
• BGP: Border gateway protocol
• ICMP: Internet control message protocol
• DHCP: Dynamic host configuration protocol
• And many more …
21
What are Protocols?
• An agreement between parties on how communication should take place
• Module in layered structure
• Protocols define: Interface to peer
(syntax & semantics)
• Actions taken on receipt of a messages
• Format and order of messages
• Error handling, termination, ordering of
requests, etc.
• Example: Buying airline ticket
Friendly greeting
Muttered reply Destination?
Pittsburgh Thank you
22
• • •
Has many users Offers diverse services
Mixes very diverse technologies
Operating System
• Components built by many companies
• Diverse ownership
• Can evolve over time
How to Design a Network?
Application
Links
Router Software (many protocols)
Operating System Application
Computer
Protocol Software
Router Hardware
Network Interface Bridge HW/SW Computer
23
Solution #1
TCP
Tw. Pair
Coax
Web
FTP Wireless
HTTP UDP
Voice Optical
The Network
Telnet
DNS
24
Solution #2?
Web FTP Telnet Voice Video
Tw. Pair Coax Optical Wireless
25
Solution #3
Web FTP Telnet Voice
Intermediate Layer
Tw. Pair Coax Optical Wireless
26
Types of Protocols
host
host
host
host
host
host
host
• Core network: responsible for transferring data between a sending and receiving host.
• End-to-end protocols: present a network service to applications and users.
• May add value to the core network protocols
• Driven by differences in constraints: scalability, power, management, speed, etc.
27
Protocol and Service Levels
Application
Application Channel
Host to Host
Hardware
Layering: modular approach to network functionality
28
A Layer Network Model
The Open Systems Interconnection (OSI) Model
7 6 5 4 3 2 1
Application
Presentation
Session
Transport
Network
Data link
Physical
Application
Presentation
Session
Transport
Network
Data link
Physical
Network
Data link
Physical
Network
Data link
Physical
29
Layering Characteristics
• Each layer relies on services from layer below and exports services to layer above
• Interface defines interaction with peer on other hosts – called protocols
• Modules hide implementation – layers can change without disturbing other layers (black box)
30
OSI Model: 7 Protocol Layers
• Physical: how to transmit bits
• Datalink:howtotransmitframes
• Network:howtoroutepackets
• Transport:howtosendpacketsend2end
• Session:howtotieflowstogether
• Presentation:byteordering,security
• Application:everythingelse
• TCP/IPhasbeenamazinglysuccessful,andit is not based on rigid OSI model. The OSI model has been successful at shaping thought
31
Different Sources of Components
• Application: web server/browser, mail, distributed game,..
• Presentation/session
• Often part of application
• Transport/network
• Typically part of the operating
system • Datalink
• Often written by vendor of the network interface hardware
• Physical
• Hardware: card and link
Application
Presentation
Session
Transport
Network
Data link
Physical
32
Application & Upper Layers
•
• •
Application Layer: Provides services that are frequently required by applications: DNS, web acess, file transfer, email…
Presentation Layer: machine- independent representation of data…
Session Layer: dialog
management, recovery from
Mostly incorporated into Application Layer
Application Application
Application
AppLlaicyaetrion
Layer Presentation
library
Layer
sockets
Session
Transport Layer
Layer Transport
Layer
errors, …
33
The Internet Engineering Task Force
• Standardization is key to network interoperability
• The hardware/software of communicating parties are often not built by the same vendoràyet they can communicate because they use the same protocol
• Internet Engineering Task Force
• Based on working groups that focus on specific issues
• Request for Comments
• Document that provides information or defines standard
• Requests feedback from the community
• Can be “promoted” to standard under certain conditions
• consensusinthecommittee
• interoperatingimplementations
• Project 1 will look at the Internet Relay Chat (IRC) RFC
34
Life of Packet
Application
Presentation Session Transport Network
Data Link Physical
Host Bridge/Switch
Router/Gateway Host
35
Layer Encapsulation
User A
User B
Get index.html
Connection ID
Source/Destination Link Address
36
Multiplexing and Demultiplexing
• There may be multiple implementations of each layer.
• How does the receiver know what version of a layer to use?
• Each header includes a demultiplexing field that is used to identify the next layer.
• Filled in by the sender
• Used by the receiver
• Multiplexing occurs at multiple layers. E.g., IP, TCP, …
TCP TCP
IP IP
V/HL
TOS
Length
ID
Flags/Offset
TTL
Prot.
H. Checksum
Source IP address
Destination IP address
Options..
37
Protocol Demultiplexing
• Multiple choices at each layer
FTP
TCP
HTTP
NV
UDP
TFTP
Network
IP
TCP/UDP
IPX
IP
Type Protocol Port Field Field Number
NET1
…
NET2
NETn
38
Server and Client
Server and Client exchange messages over the network through a common Socket API
ports
Socket API
user space
Server
Clients
TCP/UDP
TCP/UDP
kernel space
IP
IP
Ethernet Adapter
Ethernet Adapter
hardware
39
The Internet Protocol Suite
FTP
TCP
Applications UDP TCP
Data Link Physical
HTTP
NV
TFTP
UDP
IP
Narrow Waist
NET1
…
NET2
NETn
The Hourglass Model
The waist facilitates interoperability … but evolution is hard
40
IP based on a Minimalist Approach
• Dumbnetwork
• IPprovideminimalfunctionalitiestosupportconnectivity
• Addressing, forwarding, routing • Smartendsystem
• Transportlayerorapplicationperformsmoresophisticated functionalities
• Flow control, error control, congestion control • Advantages
• Accommodateheterogeneoustechnologies(Ethernet, modem, satellite, wireless)
• Supportdiverseapplications(telnet,ftp,Web,Xwindows)
• Decentralizednetworkadministration
42
Sample Quiz Question
• Question: Which of these will be hardest launch at Internet-scale: a new version of
TCP, a new version of IP, or a new version of WiFi?
• Answer: New IP (why?)
43
Today’s Lecture
• Network applications
• Requirements
• Latency and bandwidth
• Internet architecture • A layered design
• Protocols
• Life of a packet
• Network utilities
44
Network tools
• ping
• traceroute • ipconfig
• tcpdump •…
45
ping
• Application to determine if host is reachable
• Based on Internet Control Message Protocol
• ICMP informs source host about errors encountered in IP packet processing by routers or by destination host
• ICMP Echo message requests reply from destination host
• PING sends echo message & sequence #
• Determines reachability & round-trip delay
• Sometimes disabled for security reasons
traceroute
• Findroutefromlocalhosttoaremotehost • Time-to-Live(TTL)
• IPpacketshaveTTLfieldthatspecifiesmaximum# hops traversed before packet discarded
• EachrouterdecrementsTTLby1
• WhenTTLreaches0packetisdiscarded
• Traceroute
• SendUDPtoremotehostwithTTL=1
• FirstrouterwillreplyICMPTimeExceededMessage • SendUDPtoremotehostwithTTL=2,…
• Eachsteprevealsnextrouterinpathtoremotehost
• tracert (windows), tracepath (linux)
ipconfig
• Utility in Microsoft Windows to display TCP/IP information about a host
• Many options
• Simplest: IP address, subnet mask, default
gateway for the host
• Information about each IP interface of a host
• DNS hostname, IP addresses of DNS servers, physical address of network card, IP address, …
• Renew IP address from DHCP server
52
netstat
• Queries a host about TCP/IP network status
• Status of network drivers & their interface cards
• #packets in, #packets out, errored packets, …
• State of routing table in host
• TCP/IP active server processes
• TCP active connections
tcpdump and Network Protocol Analyzers
• tcpdump program captures IP packets on a network interface (usually Ethernet NIC)
• Filtering used to select packets of interest
• Packets & higher-layer messages can be displayed and
analyzed
• tcpdump basis for many network protocol analyzers for troubleshooting networks
• We use the open source Ethereal analyzer to generate examples (or wireshark, etc.)
• www.ethereal.com
How the layers work together: Network Analyzer Example
Internet
l User clicks on http://www.nytimes.com/
l Ethereal network analyzer captures all frames observed
by its Ethernet NIC (or Wireshark)
l Sequence of frames and contents of frame can be examined in detail down to individual bytes
Top Pane shows frame/packet
Middle Pane shows encapsulation for a given frame
Ethereal windows
sequence
Bottom Pane shows hex & text
Top pane: frame sequence
DNS Query
TCP Connection Setup
HTTP Request & Response
Middle pane: Encapsulation
Ethernet Frame
Protocol Type
Ethernet Destination and Source Addresses
IP Source and Destination Addresses
Middle pane: Encapsulation
And a lot of other stuff!
IP Packet
Protocol Type
Source and Destination Port Numbers
GET
Middle pane: Encapsulation
TCP Segment
HTTP Request
Goals [Clark88]
0 Connect existing networks
initially ARPANET and ARPA packet radio network
1. Survivability
ensure communication service even in the presence of
network and router failures
2. Support multiple types of services
3. Must accommodate a variety of networks 4. Allow distributed management
5. Allow host attachment with a low level of effort
6. Be cost effective
7. Allow resource accountability
62
Principle: End-to-End Argument (Saltzer’81)
• Focus of the paper is “system” • Not a pure networking paper
• Deals with where to place functionality • Inside the network (in switching elements) • At the edges
• Argument: Some functions can only be correctly implemented by the endpoints – do not try to implement these elsewhere
• Not a law – more of a “best practices”
63
Example: Reliable File Transfer
Host A
Host B
Appl. OS
Appl. OS
OK
• Solution 1: make each step reliable, and then concatenate them
• Solution 2: end-to-end check and retry
64
Sample Quiz Question
• Question: A switch and a router both cost $100 and have similar specs and achieve
similar performance in packet switching/routing. As a rational buyer, which should you buy?
• Answer: The router (why?)
65
Life of Packet
Application
Presentation Session Transport Network
Data Link Physical
Host Bridge/Switch
Router/Gateway Host
66
Next Lecture
• The “PHY”
67