Transcript Chapter 3
A Closer Look at
HTTP, TCP, IP, and PPP
Chapter 3
Copyright 2001 Prentice Hall
Revision 2: July 2001
A Closer Look at
HTTP at the Application Layer
TCP (and UDP) at the Transport Layer
IP at the Internet Layer
PPP at the Data Link Layer
2
3
HTTP: A Closer Look
World Wide Web Standards
– HTML (HyperText Markup Language) governs
the structure of the HTML webpage
– HTTP (HyperText Transfer Protocol) governs
the format and timing of requests and
responses between the browser and the
webserver application program
HTTP
Browser
HTML
Webserver
Program
HTTP: A Closer Look
Sample HTTP Request Line
– All text, often only a single line
– Keyword<sp>absolute path<sp>HTTP/ version
– Keyword (Method) is GET for Retrievals
• GET must be capitalized
– Absolute path is URL without http://hostname
GET /report1/home.htm HTTP/1.1
Absolute Path
4
5
HTTP: A Closer Look
New
Sample HTTP Request Header
– Although the book only discusses the requestline, if only the absolute path is give, the
request line is supposed to be followed by a
header line naming the host.
– So if the host is puka.hawaii.edu, the requestline and header would be (where CRLF is
carriage return followed by line feed):
GET /report1/home.htm HTTP/1.1[CRLF]
Host:puka.hawaii.edu
HTTP: A Closer Look
Sample HTTP Response Message
– Header is multiple lines of text
– Each ends with [CRLF]
HTTP/1.1 200 OK[CRLF]
Date: Tuesday, 20-JAN-1999 18:32:15 GMT[CRLF]
Server: name of server software[CRLF]
MIME-version: 1.0[CRLF]
Content-type: text/plain[CRLF]
[CRLF]
File to be downloaded.
6
HTTP: A Closer Look
Sample HTTP Response Message
– 200 is a code for a successful retrieval,
followed by the humanly readable code, OK
– Other codes indicate errors, such as 404
HTTP/1.1 200 OK[CRLF]
Date: Tuesday, 20-JAN-1999 18:32:15 GMT[CRLF]
Server: name of server software[CRLF]
MIME-version: 1.0[CRLF]
Content-type: text/plain[CRLF]
[CRLF]
File to be downloaded.
7
HTTP: A Closer Look
Sample HTTP Response Message
– MIME-version and Content-type tell the type of
file being retrieved
– For HTML document, text/plain
HTTP/1.1 200 OK[CRLF]
Date: Tuesday, 20-JAN-1999 18:32:15 GMT[CRLF]
Server: name of server software[CRLF]
MIME-version: 1.0[CRLF]
Content-type: text/plain[CRLF]
[CRLF]
File to be downloaded.
8
HTTP: A Closer Look
HTML Pages Contain Text
– To be displayed
HTML Pages Contain Tags
– Some tags say “place a graphic here”, “place a
JAVA applet in a box here”, etc.
– For instance, the tag <img src=“big.jpg”> says
“Get file big.jpg and place it here in the HTML
document”
– Graphics, Java programs, etc. are separate
files
9
10
HTTP: A Closer Look
Downloading a “page” may require several
downloads
– One for the HTML document
– One each for the other files it calls for
– Each needs a separate request/response cycle
File Downloads
User
PC
2
3
1
HTML
Webserver
App.
java
Big.
jpg
11
HTTP: A Closer Look
How Many HTTP request-response cycles
will be needed to download the three files?
– 3 HTTP request-response cycles
HTTP Request-Response
Cycle 1
User
PC
2
3
HTML
Webserver
App.
java
Big.
jpg
HTTP: A Closer Look
HTTP is Unreliable
– No error detection and correction for errors
– As we will see later, TCP at the transport layer
is reliable, offering error detection and
correction
– TCP gives HTTP clean data, so there is no
need for HTTP to do error checking
12
13
HTTP: A Closer Look
HTTP is Connectionless
– HTTP is connectionless. Just send requests,
get responses. No connection between
messages
• Like sending a letter, fax, or e-mail
Browser
HTTP
Request
Webserver
Application
14
TCP: A Closer Look
Browser does not send HTTP Requests
directly to the webserver application
– The application layer programs are not
physically connected
– Browser sends HTTP Request to the user PC’s
transport layer process for delivery
Browser
HTTP Request
Transport
Process
15
TCP: A Closer Look
Transport layer process stores the HTTP
Request Temporarily
– Does NOT merely add a TCP header and then
pass the TCP segment down to the Internet
layer process as noted in Chapter 2
Browser
Request
Transport
Process
Transport
Process
16
TCP: A Closer Look
User PC transport process opens a
connection to the webserver transport layer
process
– This connection can be used to send several
TCP segments to handle a several HTTP
request-response cycles
Browser
Transport
Process
Transport
Process
17
TCP: A Closer Look
TCP has a Flags Field
– Six one-bit flags
TCP Segment
Bit 0
Source Port # (16)
Bit 31
Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len
Reserved (6)
(4)
Flags (6)
TCP Checksum (16)
Window Size (16)
Urgent Pointer (16)
Options (if any)
Data Field
PAD
18
TCP/IP: A Closer Look
Three Flags are Widely Used
– SYN bit set to 1 in a TCP segment to request a
connection
– ACK bit set to 1 in a segment to acknowledge a
received TCP segment
– FIN bit set to 1 in a segment to inform of a
connection closure
Hdr Len
Reserved (6)
(4)
Flags (6)
Window Size (16)
19
TCP: A Closer Look
Opening a connection takes 3 Segments
– First TCP segment has SYN flag set. Requests
connection to webserver transport process
(connection-oriented service)
• Like a telephone call
SYN
User PC
Transport
Process
Webserver
Transport
Process
20
TCP: A Closer Look
Opening a connection takes 3 Segments
– Second TCP segment asks to open a
connection and also acknowledges the first
SYN message (ACK flag set too)
SYN
User PC
Transport
Process
SYN, ACK
Webserver
Transport
Process
21
TCP: A Closer Look
Opening a connection takes 3 Segments
– Third TCP segment acknowledges the second
– All segments are acknowledged except for pure
ACKs like the third segment
SYN
User PC
Transport
Process
SYN, ACK
ACK
Webserver
Transport
Process
22
TCP: A Closer Look
Next, user PC sends the HTTP Request
– Sends HTTP Request in data field of a TCP
segment
– Will receive an ACK TCP segment to
acknowledge receipt
User PC
Transport
Process
TCP segment containing
HTTP Request
ACK
Webserver
Transport
Process
Delivering the HTTP Response
23
Transport layer process on the webserver
receives the TCP segment delivering the
HTTP Request
– The transport process on the webserver
passes the HTTP Request in the TCP segment
data field to the webserver application program
Webserver
Application
HTTP Request
Transport
Process
Delivering the HTTP Response
Webserver application creates the HTTP
Response message
– Webserver application passes the HTTP
Response message to the webserver transport
layer process for delivery to the user PC
transport layer process
Webserver
Application
HTTP Response
Transport
Process
24
Delivering the HTTP Response
25
Webserver Transport Process Delivers the
Response
– User PC transport process sends an
acknowledgement
User PC
Transport
Process
TCP segment containing
HTTP Response
ACK
Webserver
Transport
Process
26
TCP: A Closer Look
Multiple HTTP Request-Response Cycles
can be Handled with a Single TCP
Connection in HTTP/1.1 and later versions
Request message must have following line:
• Connection: Keep-Alive
New
27
TCP: A Closer Look
Closing the Connection takes 4 TCP
Segments
– You don’t simply hang up in a phone call!
– Initiated by the browser when it downloads the
last file
FIN
User PC
Transport
Process
ACK
FIN
ACK
Webserver
Transport
Process
TCP: A Closer Look
28
Refinement
– If your respond quickly to a letter, often include
acknowledgement of letter your received in
your response letter
– TCP segments too can both send new
information and acknowledge a segment
received.
• Example: SYN, ACK at start of connection
– If response will take time, however, send a pure
ACK message
TCP Connections: Recap
For Page Downloads…
– 3 TCP segments to open the connection
– 4 TCP segments per file downloaded
• More if file downloaded is long, because
may take multiple segments to download
– 4 TCP segments to close the connection
– A very chatty protocol
29
TCP: Error Handling
30
TCP is reliable--it does error correction
– ACKs acknowledge each correctly-received
TCP segment
– If a TCP segment is not acknowledged, the
other side retransmits it after awhile
TCP is reliable--it Places TCP Segments in
Order
– IP does not guarantee that packets will arrive in
order
– TCP can place TCP segments in order based
on their sequence numbers
TCP: Error Handling
TCP Reliability in Perspective
– Provides clean application data to application
program
– If data link layer frame or IP packet is lost at
lower layers, receiving transport process will
not acknowledge a segment
– The sending transport process will resend
automatically
– So TCP protects against errors at lower layers
as well as transport layer errors
31
User Datagram Protocol (UDP)
UDP
– User Datagram Protocol
– Alternative to TCP at the transport layer
– Lightweight
• No connections (connectionless)
• No error correction (unreliable)
• Reduces work source and destination host
must do
32
User Datagram Protocol (UDP)
UDP
– Good for voice, for which the delay of error
correction would be unacceptable
– Good for applications for which the cost of an
occasional message is small compared to the
cost of connection-oriented service
33
34
IP: Connectionless Service
The Internet Protocol (IP)
– Internet layer protocol
– Governs transmission between router and host
– Governs transmission between pairs of routers
– Gives end-to-end route across many routers
User
PC
IP Router
IP Router
IP
Webserver
35
IP: Connectionless Service
The Internet Protocol (IP)
– IP messages are called IP packets
IP is unreliable and connectionless
– Low overhead
– Let TCP correct any errors!
Internet
Process
IP Packet
Internet
Process
36
TCP/IP Partnership
TCP checks for errors only once, at the
destination host
By not checking for errors at each router
along the route, IP greatly reduces overall
processing work
– Reduces router costs
Check Only Once
Transport
Transport
Internet
Internet
Internet
Host
Router
Host
Connectionless IP
IP is unreliable (does not catch errors)
– But this is not bad
– First, errors are corrected--at the nexthigher layer (transport) if TCP is used
– Second, avoiding error correction at
each hop between routers lowers router
costs
– Far less expensive to correct errors on
one destination host than on many
routers along the way
37
IP Addresses and Router Forwarding
38
Routers use the destination IP address of
an incoming packet in the router forwarding
decision, that is, to decide what output port
to use to send the packet back out to the
destination host or to another router (B, C
or D?)
B
B?
D?
Router A
D
Packet
C?
C
39
Router Delivery
If Destination Host is On the Source Host’s
Subnet, Source Host Delivers the Packet
Directly
– No router is involved
– Called local delivery to destination host
Source
Host
Subnet
Subnet
Local Delivery
Destination Host
40
Router Delivery
If Destination Host is NOT On the Source
Host’s Subnet, Source Host Sends the
Packet to a Router for Delivery
– Delivery to next-hop router
Delivery to
Next-Hop Router
Subnet
Subnet
41
Router Delivery
If Destination Host is On One of the
Router’s Subnets, the Router Sends the
Packet to the Destination Host for Delivery
– Local delivery to destination host
Subnet
Local Delivery
Subnet
42
Router Delivery
If Destination Host is NOT On One of the
Router’s Subnets, the Router Sends the
Packet to a Next-Hop Router for Delivery
– May have to choose among several possible
next-hop routers for delivery
Subnet
Subnet
Delivery to
Next-Hop Router
43
Router Delivery
Border Routers Connect Networks, Not
Subnets
– Select between next-hop router on own
network or on another network
Own Network
Other Network
44
IP Addresses and Router Forwarding
Routers look at destination IP address of
packet to make decisions
What do I do with this packet, based upon
its IP destination address
B
B?
D?
Router A
D
Packet
C?
C
IP Addresses
Letter
Many Addressing Systems Use
Hierarchical Addressing
City 1
City 2
City 3
– Postal delivery: city, street address
– Post office looks at city first
• If not P.O.’s city, put in bag for other city
• If in P.O.’s city, put in bag for sorting by
street address
– Hierarchical addressing greatly speeds sorting
at each post office
• Imagine if we needed a sorting bin for each
address in the country!
45
IP Hierarchical Addressing
IP Address has Three Parts
– Network part
• Identifies host’s network on the Internet
– Subnet part
• Most networks consist of smaller subnets
• Identifies host’s subnet on that network
– Host part
• Identifies a particular host
– Total equals 32 bits (the whole IP address)
46
IP Hierarchical Addressing
47
Using Address Parts
– Router has one forwarding rule for all packets
to a particular network or to a particular
subnets
– Does not need a forwarding rule for each host
– Many fewer rules to look through when making
router forwarding decisions
– Vastly reduces the work that routers have to do
– Internet core routers still have 100,000 to
200,000 rules
New
48
IP Addresses
Network Part Numbers
– For the University of Hawaii, this is 128.171
– All IP Addresses in that organization’s network
begin with that Network Part
– Network parts can be 8 to 24 bits long
Network Part
IP Address
128.171
Assigning Network Parts
Organization applies to an Internet IP
address registrar
– Registrar gives organization a network part
– Organization assigns the remaining bits to its
hosts internally
– Only large organizations and ISPs get network
parts
128.171.17.13
Registrar
128.171
Firm
128.171.123.130
49
50
IP Addresses
Network Part is Followed by a Subnet Part
– Identifies the subnet within the network
– Remaining bits are the Host Part, designating a
particular host on that subnet
Network Part
Subnet Part
IP Address (32 bits total)
Host Part
51
Assigning Subnet Parts
Organization Assigns Subnet Parts
– Assigns subnet parts to suborganizations
– Suborganization assigns host bits to hosts
128.171
Registrar
128.171.17.13
Firm
Suborganization
128.171.17.13
Host
Assigning Parts
52
Example
– University of Hawaii has network part 128.171
– UH gave the College of Business Administration
the subnet part 17
– College of Business Administration gave the
host part 13 to a computer it later gave the host
name voyager.cba.hawaii.edu
– So the computer’s IP address became
128.171.17.13.
Importance of Part Sizes
53
Determine Number of Possible Networks,
Subnets, or Hosts
If There are N Bits in the Part, there can be
2N possible Networks, Subnets, or Hosts
Actually, 2N-2
– All zeros cannot be used for a part
– All ones cannot be used for a part
Example: if part has 8 bits, 28-2
possibilities (254)
Masks
54
Problem: Just looking at an IP address
does not tell you what bits belong to each
part
Solution: Create a second 32-bit number, a
mask, to tell the size of
– The network part for border router decisions
– The network plus subnet parts for internal
router decisions
Masks
Two Types: Network Masks and Subnet
Masks
– Network Mask Tells the Length of the Network
Part. To get packet closer to network.
– Subnet Mask Tells the length of the Network
Plus Subnet Parts (not just subnet part). To get
packet closer to subnet in own network
– IP Address will be paired with one or the other,
but not both simultaneously
– The correct pairing happens automatically
55
56
Masks
Masks Begin with 1s, End with 0s (111…00)
For network masks, 1s are in Network Part
bits; 0s are in Subnet and Host Parts
For subnet masks, 1s are in Network and
Subnet Parts; 0s are in Host part
– 1s are not just in the subnet part
Again, always total 32 bits
11111111111111110000000000000000
57
Masks
IP Address-Mask Pairs often Written with
Prefix Notation
– 128.171.17.13/16
– 16 means that the mask has 16 initial 1s
– Total number of bits is 32 in an IP address, so
there must be 16 trailing 0s
11111111111111110000000000000000
Router Forwarding Tables
Routers make forwarding decisions using
router forwarding tables
– Each row is a router forwarding rule for
matching packets
– Based on packet’s network or subnet on its
network
• Book calls first column the IP address part
Refinement
Network/Subnet
Delivery
128.171.17
Local
142.99
Next-Hop Router A
58
Router Forwarding Tables
59
Router Compares Destination IP Address
to Each Row in Router Forwarding Table
– If matches, adds to list of possible rules to use
– There usually are multiple matches
• Indicate alternative routes
Network/Subnet
Delivery
128.171.17
Local
142.99
Next-Hop Router A
60
Router Forwarding Tables
Also Has a Mask Column
– Tells number of network or network+subnet bits
– If Mask in a row is 24 bits long, router only
compares first 24 bits of packet’s IP destination
address to Net/Subnet bits in table row
– Tells size of network part or network+subnet
parts
Net/Subnet
Mask
Destination
128.171.17
24
Local
142
8
Next-Hop
Router A
61
Router Forwarding Tables
Also Has a Mask Column
– Network mask for a host outside the
organization’s network
– Subnet mask for an internal host
– Can’t tell which by looking at the mask
– Don’t worry. It’s all automatic
Net/Subnet
Mask
Destination
128.171.17
24
Local
142
8
Next-Hop
Router A
62
Router Forwarding Tables
Example
–
–
–
–
–
Destination IP Address is 128.171.17.13
Apply mask, get 128.171.17
Matches networks/subnet field (128.171.17)
The row is a match!
If only match, select this row.
Net/Subnet
Mask
Destination
128.171.17
24
Local
142
8
Next-Hop
Router A
63
Router Forwarding Tables
Longest Match Principle
– If two rows match, use longest match, that is
match to greatest number of bits
– For 128.171.17.13, use local delivery (24-bit
match)
Net/Subnet
Mask
Destination
128.171.17
24
Local
128.171
16
Next-Hop
Router A
64
Router Forwarding Tables
Metric
– If same length of match, turn to metric column
– Metric describes the desirability of a choice
– If metric is cost, choose lowest cost
– For other metrics (speed, etc.), may chose
largest value
Net/Subnet Mask
128.171
16
Metric
(Cost)
23
128.171
16
45
Delivery
Next-Hop
Router A
Local
Router Forwarding Tables
There May be No Matches
– One IP Address Part is Always 0.0.0.0
– Mask is 0.0.0.0, so every IP address matches
this row!
– Its next-hop router is called the Default Router
Net/Subnet
Delivery
128.171.17.13
Local
0.0.0.0
Next-Hop Router C
65
Router Forwarding Tables
66
Recap of Selection Rules
– Compare destination IP address of arriving packet
against ALL rows in the router forwarding table
• Add all matches to a list
– After examining all rows, select the best match
• If multiple rows match, select the longest match
• If multiple rows tie on the longest match, select
the best metric
• If no other match, select the default router row
Router Forwarding Tables
67
Delivery
– Table designates local delivery to destination
host or a next hop router
– Also designates the router interface (port) that
will be used for delivery
• Each interface connects to a different subnet
Interface
Delivery
2
3
Local (destination host is on the
subnet out interface 2)
Next-Hop Router C
3
Next-Hop Router D
Dynamic Routing Protocols
How Do Routers Get Information for their
Router Forwarding Tables?
– Share router forwarding table information
– Standards for these exchanges are called
dynamic routing protocols
Router Forwarding
Table Information
68
Dynamic Routing Protocols
How Do Routers Get Information for their
Router Forwarding Tables?
– Thanks to dynamic routing protocols, the
Internet needs no central point of control
– Routers create their router forwarding tables
strictly by information from peers and their own
knowledge
Router Forwarding
Table Information
69
IP Version 6
Current Version of IP is IP Version 4
– This is the version we have been discussing
– Has 32-bit IP address fields
– Not long enough; running out of IP addresses
Next Version will be IP Version 6
– Will have 128-bit IP address fields
– Will allow vast numbers of IP addresses (2128)
– Being adopted slowly
70
71
PPP
Point-to-Point Protocol
– Popular data link layer protocol for dial-in
connections
– Between data link layer processes on user PC
and first router
– Not between user PC and the destination host
DLL Process
User PC
PPP
DLL Process
First Router
72
PPP
Negotiation Phase
– Before exchanging data frames, the two sides
– Negotiate conditions of PPP operation
– Also negotiate how specific protocols will be
handled, such as IP
• Not limited to IP
DLL Process
User PC
PPP
DLL Process
First Router
73
PPP
Data Frames
– Header
– Information field (IP packet or other information)
– Trailer with Frame Check Sequence field
• Error detection but not correction
• If an error is found, PPP frame is discarded
Trailer
Information Field
IP Packet
Header
74
PPP
Flag Fields (1 Octet Each)
– Always contain: 01111110
– Designates start of frame and end of frame
Address and Control Fields (1 Octet Each)
– Left over from earlier protocol (HDLC)
– Address field always has the value: 11111111
– Control field always has the value 00000011
Flag
Addr
Ctrl
Prot
Info
CRC
Flag
75
PPP
Protocol Field (2 Octets)
– Identifies the contents of the information field
– There are values for IP, IPX, other internet layer
protocols that may be carried in the information
field for data frames
– There are values for supervisory messages to
be carried in the information field for
supervisory frames
Flag
Addr
Ctrl
Prot
Info
CRC
Flag
76
PPP
Cyclical Redundancy Check (2 Octets)
– For error-checking information
– Allows receiver to detect a PPP frame with a
transmission error
– Receiver discards such frames; error detection
but not reliability (no error correction)
Flag
Addr
Ctrl
Prot
Info
CRC
Flag
77
Physical Layer Process
Physical layer process does not create a
protocol data unit
– Sends one bit at a time over the data link
connecting the sending computer to the next
computer
– It is the data link layer process that organizes
these bits into frames over the data link
Physical Layer
Process
10110
Physical Layer
Process
Key Point about Reliability
78
Only TCP is Reliable or Needs to Be
– Corrects errors, gives application programs
clean data
– Corrects errors that occur a the transport layer
or lower layers because only correctly received
TCP segments are acknowledged