Transcript Module 4

ES 101-02. Module 4
Transport Layer Protocols
Last Lecture(s)
• Routing and IP Addressing
• Domain Name System
This Lecture
• Transport Layer Services
• User Datagram Protocol (UDP)
• Transmission Control Protocol (TCP)
Transport Layer Operation
• The transport layer interfaces to applications
• One application may have multiple simultaneous interfaces
to remote clients for a given application
– Web servers, ftp servers, etc.
• The converse is also true, ie. the server may support multiple
applications to one or more clients
• The application provides the transport layer with “Protocol
Data Units” or PDUs
• These PDUs are then segmented and encapsulated in a
transport layer “segment”
• The transport layer segment is then encapsulated in IP, and
on, and on…
Transport Layer Applications
• In order to understand the operation of the
transport layer, Layer 4, we must first examine the
requirements of this layer, and then go through
some common scenarios for the TCP/IP protocol
stack
– The foundation for the operation of the Internet
TCP/IP Architecture
HTTP
TCP
UDP
Note: We have covered IP previously.
Transport Layer Services
•
•
•
•
•
•
•
•
•
Type of Service Indicators
Quality of Service Indicators
Data Transfer
Application Programing Interface (API)
Connection Management
Delivery Prioritization
Status Reporting
Security
Multiplexing and demultiplexing
Transport Layer Services (cont’d)
• The performance of the transport layer must be
discussed with respect to the underlying network
layer
– IP in the case of the Internet
• Two types of transport layer services are available:
– Reliable, sequencing
• Transmission Control Protocol (TCP)
– Unreliable, ie. no sequencing mechanism
• User Datagram Protocol (UDP)
Packet Switching Review
• Recall that the IP layer launches packets into the network,
and “hopes for the best”
• This means that packets can arrive at the destination out of
sequence, or get lost
– Late packets that are OK upon arrival
– Packets that get destroyed in transit due to “collisions”
• How can this happen?
– Different routes
– Packet “destruction”
Note: In the TCP/IP world, packets are referred
to as “datagrams”
Out of Order Datagram
Lost Datagram
Corruption of Packets by Routers
Consequences of Out-of-Sequence
Transmission
Techniques for Reliability
• Connection-oriented transmission of packets
• Error Control
– Error detection, ie. are packets damaged?
• Accomplished via Cyclic Redundancy Checking
• Header corruption
• Payload corruption
– Error recovery
• NACK the bad or missing packets
• Retransmit the packet again
• This requires packet sequence numbers
Connection-Oriented Transmission
• A “session” is established between the client and server
before data transmission is initiated
– Connection Establishment
• During data transmission, packets are monitored for errors
– This requires packet sequence numbers
• If data is lost, retransmission is requested
• At the conclusion of the session, the connection is closed
– “Log off”
Error Control and Recovery
• Error control refers to the detection of errors in either the
header, the payload, or both
• This is accomplished by a Cyclic Redundancy Check
(CRC) algorithm
– The CRC is calculated upon transmission and appended to the
packet
– The CRC is then re-calculated upon receipt of the packet
• If the CRC calculation does not match that which was
appended upon transmission, the packet is assumed to be
damaged, and is not processed further
• Re-transmission of the damaged packet is then requested
Requirements for Transmission over an
Unreliable Network
• As stated previously, additional requirements are placed on
the transport protocol if the underlying network is
unreliable, and reliable transmission of data is required
–
–
–
–
Ordered Delivery
Retransmission Strategy
Duplicate Detection
Flow Control
• Results from congestion
– Connection Establishment and Termination
– Crash Recovery
• Layer 4 protocols may not implement all of these features
This Lecture
• Transport Layer Services
• User Datagram Protocol (UDP)
• Transmission Control Protocol (TCP)
User Datagram Protocol (UDP)
• Before we discuss TCP which is a connection-oriented,
reliable, sequencing protocol, we will discuss UDP
– Connectionless
• There is no connection establishment or termination
– Error detection
• Header only, to prevent misrouted packets
• UDP is very efficient, and is widely used for applications
that do not require reliability, but do require multiplexing
– Identification of each communication link
• UDP is essentially IP with sockets
• But first, we must understand sockets…
UDP Application Example
• The Simple Network Management Protocol (SNMP)
utilizes UDP
• SNMP consists of two parts:
– Management station
– Management Information Base (MIB) in all networked devices
• The devices send a “health” message to the management
station at 10 second intervals
• Device health is displayed graphically to a network
administrator in the Network Operations Center (NOC)
• If a device shows that it has failed, the NOC operator takes
a corrective action
Do we care if an update is lost or misordered?
UDP Overview
• Documented in RFC 768
• Communication occurs via “ports” and “sockets”
• Unreliable delivery, ie. operates over IP
– Connectionless service
– Lost datagrams are possible
– Out of sequence datagrams are possible
• Very efficient protocol
– No connection establishment or closure
– “Fire and forget” protocol
UDP Ports
• UDP essentially adds a port addressing capability to IP
• Each packet is tagged with unique source and destination
identifiers known as a “ports”
• The combination of a port number and a device IP address
is unique
– This combination is known as a “socket”
• Different applications use different port values
• UDP Client/Server operation
– Server listens passively
– Client “knows” port numbers, and initiates (requests) information
transfer
– Server responds to client request
UDP Header
Multiplexing
• UDP accomplishes multiplexing/demultiplexing
by keeping track of sockets at each end of the link
• Each connection is therefore uniquely identified
• This technique supports many concurrent
connections
– Interleaving of PDUs, ie. multiplexing
Multiplexing of Concurrent Applications
UDP Process Identification
Well Known UDP Ports
Socket Schematic
Checksum
• 16-bit “ones complement”
– Includes information from the IP header, UDP header, data, and
padding octets
• Must end up with an even number of octets
• A “pseudo-header” is pre-pended to the UDP header to
calculate the checksum only for the UDP header
– Avoids misrouting to the wrong process
• This information protects against misrouted datagrams
– Header/address corruption
UDP Header
This Lecture
• Transport Layer Services
• User Datagram Protocol (UDP)
• Transmission Control Protocol (TCP)
Transmission Control Protocol Overview
• Documented in RFC 793
• Why is TCP necessary?
– UDP adds little reliability to the IP connectionless
service
• TCP provides additional reliability over UDP
–
–
–
–
Error free
Assured delivery
In sequence packets, or segments
No duplication of segments
So, what services does TCP provide?
TCP Services
• Multiplexing
• Connection-oriented
– Connection establishment
– Crash recovery
– Connection termination
• Reliable
– Sequence numbers provided
– Mechanisms for error detection/recovery at the byte level
• Flow Control
Multiplexing
• TCP accomplishes multiplexing/demultiplexing by
keeping track of ports and sockets at each end of
the link
• This process is identical to the technique for UDP
with the exception that many concurrent data
“streams” must be supported
TCP Header
TCP Connections
TCP Connections (cont’d)
Well Known TCP Ports
Connection Establishment
• TCP clients must have a reliable way to “connect” to
servers
– This is done using a three-way handshake
• The server passively “listens” on a well known port
• A connection request is made when the client issues a
“SYN” packet to the appropriate port number
• The server “connects” and then assigns a different port
number for the session
– There can be up to 216 concurrent sessions
– This port is “open” until session termination, after which it can be
reassigned
Connection Establishment (cont’d)
• TCP utilizes a three-way handshake
• To initiate a connection, the originator sets the SYN and
Sequence Number (SN) fields in the TCP header
– SN is set to the initial number of the first octet in the segment, SN = X
• The destination then responds with a TCP message (header)
with the SYN and ACK bits set, SN = Y, and the
Acknowledgement Number (AN) set equal to AN = X + 1
– This acknowledges the first SYN packet, and acknowledges that the
next octet to be received is X+1
Connection Establishment (cont’d)
• The originator then responds with a message with
the acknowledgement number set:
– AN = Y + 1
– This is the last packet in the three way handshake
– The connection is then established
Passive/Active Connection Request
Three Way Handshake
Data Transfer
• After connection establishment, TCP transfers application
data by packaging it in a TCP “segment”, or data packet
• Sequence numbers are indirectly provided for every octet
(byte) in the segment
• When packets arrive at the destination, they are
reassembled in the correct order
– Missing and duplicate information is detected and corrected
• Sequence numbers are independent of each “flow”
TCP Header
Data Byte Numbering
Acknowledgement
Error Recovery
Data Sequence Numbers
• The TCP technique of providing sequence numbers that
represent each octet in the segment allows detection of
missed octets, assuming the CRC check is OK
– Number of octets in a TCP message can be 232
– Each TCP header contains the sequence number of the first octet in
the segment
• This sequence number cannot be repeated during the
lifetime of the session transmission
– Recall that each session can have different sequence numbers,
since this is a connection-oriented approach
• 216 concurrent sessions
Checksum - TCP
• Operates in the same fashion as UDP
– Header Only
– Avoids misrouting to the wrong process
• However, when used in conjunction with the
payload octet sequence numbering and error
recovery, reliability of transmission is assured
Checksum – TCP
Flow Control
• Flow control is accomplished by using a credit allocation
scheme
• The credit is equal to the number of octets in the “send
window”
– This is the total number of octets that can be outstanding
(unacknowledged) before requiring an acknowledgement
• The credit allocation approach allows the destination
device to adjust the origin transmission window
– This essentially controls the “flow” in bytes/second that the sender
can launch into the network
Why is flow control necessary?
Buffer Overflows
• If a router or switch on the network receives more
information than it can process per unit of time, it buffers
the information until it can get to it
• If the network gets congested, the offered load is greater
than the routers can buffer
• When this happens, the routers overwrite their buffers,
causing the loss of data (packets)
• So, it is necessary for devices attached to the network to be
able to “slow down” the transmission process
Flow Control Schematic
Crash Recovery
• Sometimes, the a device “stalls” or fails
– This could be either the server, client, or the network
• When this happens, the other “party” to the conversation
does not know what is going on
– The receiver may be waiting forever to get the next chunk of
information
• There must therefore be a mechanism to force the
transmitter to respond
– Are you still there?
How is this done?
Push and Reset Flags
• This is accomplished via the Push and RST flags
in the TCP header
• The push and reset flags are used to allow the
originator to force data accumulated in the buffer
to be sent
– Allows use as an “end of block” flag
• If a segment is misrouted, the receiver sends a
TCP header back with the RST flag set
– Example: Delayed or duplicate SYNs
TCP Header
SN
AN
ACK
SYN
Closing the Connection
• When all data has been transmitted, it is necessary
to close the connection
• Otherwise, all of the ports would eventually be
used up
– No further sessions could be established
Closing the Connection
Next Lecture(s)
• HTTP and URLs
• HTML Overview
• HTML Editors