Date post: | 27-Dec-2015 |
Category: |
Documents |
Upload: | alexandra-flowers |
View: | 224 times |
Download: | 0 times |
3
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
5
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
Browser
WebserverProgramHTML
HTTP
6
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
7
HTTP: A Closer Look
Sample HTTP Request Header
– Although the book only discusses the request-line, 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 request-line 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
New
8
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.
9
HTTP: A Closer Look Sample HTTP Response Message
– 200 is a code for a successful retrieval, followed by the humanly readable code, OK
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.
10
HTTP: A Closer Look Sample HTTP Response Message
– There are other codes, indicating errors, such as 404
– Followed by a humanly readable code, such as, host not found
HTTP/1.1 404 Host not Found[CRLF]
11
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.
12
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
13
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
HTML
Big.jpg
App.java
WebserverUserPC
File Downloads
2
3
1
14
HTTP: A Closer Look
Each download requires a separate HTTP request-response cycle!– So downloading complex webpages
may require many HTTP request-response cycles
HTML
Big.jpg
App.java
WebserverUserPC
HTTPRequest-Response
Cycle 1
2
3
15HTTP: A Closer Look How Many HTTP messages will be created
to download the three files?– 3 HTTP request-response cycles– 2 HTTP messages per cycle (request and
response)– 6 HTTP messages total
HTML
Big.jpg
App.java
WebserverUserPC
HTTP Request-ResponseCycle 1
2
3
16
HTTP: A Closer Look HTTP is Unreliable
– There is no error detection and correction for transmission errors
– This helps makes HTTP simple, allowing browsers and webserver application programs to be simple and inexpensive
– So Unreliability can be good!
17
HTTP: A Closer Look HTTP is Unreliable
– 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
– Unreliability saves processing time on the source and destination hosts, reducing host costs
– Unreliability makes browsers and webservers easier to write, reducing their costs
18
HTTP: A Closer Look
HTTP is Connectionless
– Connection-oriented services establish a connection, maintain it for the duration of a communication, and then break the connection
– For instance, in a telephone call, people say hello (agreeing to talk), note if the line goes dead, and agree to break the connection (we don’t simply hang up on the other person)
19
HTTP: A Closer Look
HTTP is Connectionless
– Connectionless services merely send the message without a connection. Like sending a letter
– HTTP is connectionless. Just send requests, get responses. No opens, maintenance, or closes
BrowserWebserverApplication
HTTPRequest
20
HTTP: A Closer Look
HTTP is Connectionless
– Connectionless operation is simple because of the lack of opens, maintenance, and closes
– This makes HTTP simple, allowing browsers and webservers to be built easily
BrowserWebserverApplication
HTTPRequest
22
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
TransportProcess
HTTP Request
23
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
TransportProcess
TransportProcess
Request
24
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
TransportProcess
TransportProcess
25
TCP: A Closer Look TCP has a Flags Field
– Six one-bit flags
Source Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len(4) Flags (6) Window Size (16)
Options (if any) PAD
Bit 0 Bit 31
Reserved (6)
TCP Checksum (16) Urgent Pointer (16)
TCP Segment
Data Field
26
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(4) Flags (6) Window Size (16)Reserved (6)
27
TCP: A Closer Look Opening a connection takes 3 Segments
– First TCP segment has SYN flag set. Requests connection to webserver transport process
User PCTransportProcess
WebserverTransportProcess
SYN
28
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)
User PCTransportProcess
WebserverTransportProcess
SYN
SYN, ACK
29
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
User PCTransportProcess
WebserverTransportProcess
SYN
SYN, ACK
ACK
30TCP: 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 PCTransportProcess
WebserverTransportProcess
TCP segment containingHTTP Request
ACK
31
Delivering the HTTP Response 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
WebserverApplication
TransportProcess
HTTP Request
32
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
WebserverApplication
TransportProcess
HTTP Response
33
Delivering the HTTP Response Webserver Transport Process Delivers the
Response– User PC transport process sends an
acknowledgement
User PCTransportProcess
WebserverTransportProcess
TCP segment containingHTTP Response
ACK
34
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 Connection:
Keep-Alive
Each will have the following:– TCP segment carrying the HTTP request– Acknowledgement of this segment– TCP segment carrying the HTTP response– Acknowledgement of response segment
35TCP: A Closer Look Closing the Connection takes 4 TCP
Segments– Initiated by the browser when it
downloads the last file
User PCTransportProcess
WebserverTransportProcess
FIN
FIN
ACK
ACK
36
TCP: A Closer Look Refinement
– If you respond quickly to a letter, often include acknowledgement of letter you received in your response letter
– TCP segments can send new information and acknowledge a segment received
• Ex. SYN, ACK at start of connection
– If response will take time, however, send a pure ACK message
37
TCP Connections: Recap For EACH Page Download…
– 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
38
TCP: Error Handling TCP is reliable--it does error correction
– Each TCP segment has a 32-bit sequence number that increases with each TCP segment a transport process sends
Source Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Bit 0 Bit 31TCP Segment
39
TCP: Error Handling TCP is reliable--it does error correction
– ACKs acknowledge a specific TCP segment in the sequence
– If a TCP segment is not acknowledged, the other side retransmits it after awhile
– This adds TCP segments beyond the ones we have seen
40
TCP: Error Handling TCP is reliable--it Places TCP Segments in
Order
– TCP segments are encapsulated in IP packets
– IP does not guarantee that packets will arrive in order
– TCP can place TCP segments in order based on their sequence numbers
41
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
42TCP: Why Connections? Opens, closes, and ACKs create overhead,
so undesirable
Why do it?– Allows sequence numbers, so that
errors can be handled easily
Overall, TCP is a high-overhead, highly reliable transport layer protocol that catches any errors at lower layers, giving “clean” service to the application programs
43
TCP: Refinements
Fragmentation
– Transport process must fragment long application messages (break them into several pieces) and transmits them in several TCP segments
– So when large files are downloaded in webservice, many more TCP segments will be generated than we discussed above
Mod A
App Frag 2 TCP-H App Frag 1 TCP-H
44
TCP: Refinements
Flow Control
– TCP implements flow control, so that one transport process will not overload its peer by transmitting too quickly
Mod A
User PCTransportProcess
WebserverTransportProcess
Data
ACKCommand toLimit Speed
45
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
46
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
More on TCP Acknowledgements
Sequence Number Field
Initial Sequence Number
Acknowledgement Number Field
48
TCP
TCP is Reliable
– IP packets carrying TCP segments may arrive out of order
– TCP must put the TCP segments in order
3 4 2 15
49
TCP
TCP is Reliable
– Each correct TCP segment is acknowledged by the receiver
SourceTransportProcess
SourceTransportProcess
DestinationTransportProcess
DestinationTransportProcess
TCP SegmentTCP Segment
ACKACK
50
TCP Segment Each TCP segment sent by a side must
have a sequence number
– Simplest: 1,2,3,4,5,6,7
– To detect lost or out-of-sequence messages
– TCP uses a more complex approach
11 44 22 55
3?
51
TCP Sequence Numbers
TCP header has a 32-bit sequence number field to identify a TCP segment’s position in a series of segments
Source Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len(4) Flags (6) Window Size (16)
Options (if any) PAD
Reserved (6)
TCP Checksum (16) Urgent Pointer (16)
Data Field
52
TCP Sequence Numbers
Initial Sequence Number is randomly selected by the sender; Say, 79
Sent in the sequence number field of the first TCP segment
79
TCP Data Field
TCP Header
Sequence Number Fieldwith Initial Sequence Number (79)
53
TCP Sequence Numbers
Data octets in data fields of all segments in a connection are viewed as a long string
TCP Segment 1 79
TCP Segment 2 808182
TCP Segment 3 8384
3 Octets in Data Field
2 Octets in Data Field
ISN
54
TCP Sequence Numbers
Supervisory segments, which contain a header but no data, are treated as carrying a single octet of data
TCP seg 1 898899
TCP seg 2 900
TCP seg 3 901902…
Supervisory segment
Carries data
Carries data
55
TCP Sequence Numbers
Sequence number field gets the value of the first octet in the data field
TCP 1 79
TCP 2 808182
TCP 3 8384
80 is SeqNum Field Value
83 is SeqNum Field Value
79 is SeqNum Field Value
56
TCP Acknowledgements
Acknowledgement must indicate which TCP segment is being acknowledged
SourceTCP
Process
SourceTCP
Process
DestinationTCP
Process
DestinationTCP
Process
TCP SegmentTCP Segment
ACKACK
57
TCP Acknowledgements
TCP header contains a 32-bit Acknowledgement Number field to designate the TCP segment being acknowledged
Source Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len(4) Flags (6) Window Size (16)
Options (if any) PAD
Reserved (6)
TCP Checksum (16) Urgent Pointer (16)
Data Field
58
TCP Acknowledgment Numbers
Acknowledgement Number field contains the next byte expected--the last byte of the segment being acknowledged, plus one
TCP 1 79
TCP 2 808182
TCP 3 8384
83 is AckNum Field Value
85 is AckNum Field Value
80 is AckNum Field Value
59
TCP Acknowledgement Number
Quiz: A TCP segment contains the following data octets– 567, 568, 569, 570, 571, 572, 573, 574
What will be in the sequence number field of the TCP segment delivering the data?
What will be in the acknowledgement number field of the TCP segment acknowledging the TCP segment that delivers these octets?
60
TCP Flow Control
Flow Control– One TCP process transmits too fast– Other TCP process is overwhelmed– Receiver must control transmission rate– This is flow control
TCP Process TCP Process
Too MuchData
Flow Control Message
61
TCP Flow Control
A TCP segment has a Window Size field– Used in acknowledgements
Source Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len(4) Flags (6) Window Size (16)
Options (if any) PAD
Reserved (6)
TCP Checksum (16) Urgent Pointer (16)
Data Field
62
TCP Flow Control
A TCP segment has a Window Size field– Tell how many more octets the sender
can send beyond the segment being acknowledged
TCP Process TCP Process
Data
Acknowledgement with Window Size Field
63TCP Flow Control Example
– TCP segment contained octets 45-89– Acknowledgement number for TCP
segment acknowledging the segment is 90
– If Window Size field value is 50, then– Sender may send through octet 140 (90
plus 50)– Must stop before 50 unless the window
is extended in another acknowledgement
64
TCP Flow Control
Each Acknowledgement extends the window of octets that may be sent– Called a sliding window protocol
1-44 45-79 80-419 420-630
400May send through 480
1-44 45-79 80-419 420-630
500May send through 920
65
TCP Fragmentation
TCP Segments have maximum data field sizes– (Size limit details are discussed later)– What if an application layer message is
too large?
TCP HeaderTCP Data Field Max
Application Layer Message
66
TCP Fragmentation
Application layer message must be fragmented– Broken into several pieces– Delivered in separate TCP segments
TCP HeaderTCP Data Field Max
App Frag 1 App Frag 2 App Frag 3
67
TCP Fragmentation
Note that, in TCP fragmentation, the TCP segment is NOT fragmented– The application layer message is
fragmented
TCP HeaderTCP Data Field Max
App Frag 1 App Frag 2 App Frag 3
68
TCP Fragmentation Transport layer process on the source
host does the fragmentation– Application layer on the source host is
not involved– Transparent to the application layer
Application
Transport
Internet
Application Message
TCP Segment TCP Segment
69
TCP Fragmentation Transport layer process on the destination
host does the reassembly– Application layer on the destination host
is not involved; Gets original application layer message
Application
Transport
Internet
Application Message
TCP Segment TCP Segment
70
TCP Fragmentation
What is the maximum TCP data field size?– Complex
Maximum Segment Size (MSS)– Maximum size of a TCP segment’s data
field– NOT maximum size of the segment as
its name would suggest!!!
71
TCP Fragmentation
MSS Default is 536 octets
– Minimum IP packet size any network must support is 576 octets
• Larger IP packets MAY be fragmented
– IP and TCP headers are 20 octets each if there are no options
– This gives the default MSS of 536
– Smaller if there are options in the IP or TCP header
72
TCP Fragmentation
MSS Default is 536 octets
– Suppose the application layer process is 1,000 octets long
– Two TCP segments will be needed to send the data
– The first can send the first 536 octets
– The second can carry the remaining 464 octets of the application layer message
73
TCP Fragmentation
Each side MAY announce a larger MSS
– An option usually used in the initial SYN message it sends to the other
– If announces MSS of 2,048, this many octets of data may be sent in each TCP segments
– 536 is only the default—the value to use if no other value is specified by the other side
75
Mask Operations
Masks were introduced in Chapter 3
IP addresses alone do not tell you the size of their network or subnet parts
Network Mask– Has 1s in the network part– Has 0s in the remaining bits
Subnet Mask– Has 1s in the network plus subnet parts– Has 0s in the remaining bits
76
Multiplexing
IP packets can carry different things in their data fields
– TCP segments
– UDP datagrams
– ICMP supervisory messages (later)
– RIP messages (later)
IP Data Field IP Header
77
Multiplexing
We say that IP can multiplex (mix) different types of traffic in a stream of IP packets
UDP IP-H TCP IP-H UDP IP-H ICMP IP-H
Stream of Arriving or Outgoing IP Packets
Single IP PacketCarrying UDP Datagram
78
Multiplexing IP process must pass contents of arriving
IP packets to the correct process for subsequent handling
IP
TCP UDP
ICMPUDP IP-H
IP ProcessArrivingPackets