Sunteți pe pagina 1din 51

Layer 4

Transport Layer
Transport Layer : Objectives
 Describe the purpose of the transport layer in managing the
transportation of data in end-to-end communication.
 Describe characteristics of the TCP and UDP protocols, including
port numbers and their uses.
 Explain how TCP session establishment and termination processes
facilitate reliable communication.
 Explain how TCP protocol data units are transmitted and
acknowledged to guarantee delivery.
 Explain the UDP client processes to establish communication with a
server.
 Determine whether high-reliability TCP transmissions, or non-
guaranteed UDP transmissions, are best suited for common
applications.
Role of the Transport Layer
The transport layer is responsible for establishing a temporary
communication session between two applications and delivering data
between them.
TCP/IP uses two protocols to achieve this:
 Transmission Control Protocol (TCP)
 User Datagram Protocol (UDP)
Primary Responsibilities of Transport Layer Protocols
 Tracking the individual communication between applications on the
source and destination hosts
 Segmenting data for manageability and reassembling segmented
data into streams of application data at the destination
 Identifying the proper application for each communication stream
Transportation of Data
Role of the Transport Layer (Cont.)
Transportation of Data
Conversation Multiplexing
Segmenting the Data
 Enables many different communications, from many different
users, to be interleaved (multiplexed) on the same network, at the
same time.
 Provides the means to both send and receive data when running
multiple applications.
 Header added to each segment to identify it.
Transportation of Data
Conversation Multiplexing (Cont.)
Transport Layer Protocols

 TCP – Transmission Control Protocol

 UDP – User Datagram Protocol


TCP-Transmission Control Protocol
 Overview
 Defined in RFC 793
 Connection-oriented – handshaking (exchange of control
messages) to initialize sender, receiver state before data
exchange.
 Reliable delivery – guaranteed arrival, no error, in order
retransmits lost or corrupt data.
 Ordered data reconstruction – Reconstructs numbering
and sequencing of segments.
 Flow control – Regulates the amount of data transmitted
 Stateful protocol – Tracks the session
 Flow controlled - Sender does not overwhelm receiver
TCP segment structure
TCP segment fields
 Source port: Is the port number of the host sending the
data.
 Destination port: Is the port number of the application
requested on the destination host.
 Header length: defines the number of 32-bit words in the
header.
 Urgent pointer: Indicates the end of urgent data.
 Option: Sets the maximum TCP segment size to either 0
or 32 bits, if any.
 Data: Is handed down to the TCP protocol at the
Transport layer, which includes the upper-layer headers.
TCP Segment fields cont’d

The Sequence Number field gives the TCP segment’s


order in the session.
The Acknowledgement Number Defines which TCP
segment is expected next.
These fields are 32 bits long.
TCP Segment cont’d
Flag fields(Code bits) are one-bit fields.
If the value is 1, the flag field is Set.
If the value is 0, the flag field is Not Set.
Flag bits are SYN, ACK, FIN, and RST.
They are used to set up and terminate a
session

TCP has six flag fields.


TCP Segment

The TCP Checksum field is for error correction.


The sender computes the value in the field.
If the receiver computes the same value,
it sends an ACK.
If not, the receiver discards the segment and
sends nothing. The sender will resend the
segment. TCP is reliable.
TCP Segment
 TCP segments always have headers.
 SOME TCP segments do not have data fields.
Supervisory segments, such as SYN, do not carry data because
the information to be conveyed, such as opening a connection,
delivers no data.

 TCP segments NEVER have trailers.


TCP segment - example
UDP- User Datagram Protocol
Overview:
 Defined in RFC 768
 Connectionless
 Unreliable delivery
 No ordered data
reconstruction
 No flow control
 Stateless protocol

Applications that use


UDP:
 Domain Name
System (DNS)
 Video Streaming
 VoIP
UDP segment
18
Pearson
2.11: UDP Datagram

In UDP, the application message must fit into a single UDP


datagram.
So, few header fields are needed.
The UDP Checksum field is for error detection.
If there is an error, UDP discards the datagram.
If it does not detect an error, it accepts the datagram but
does not send an acknowledgement.
UDP segment fields
 Source port: Port number of the host sending the data
 Destination port: Port number of the application
requested on the destination host
 Length of the segment: Length of UDP header and
UDP data
 CRC: Checksum of both the UDP header and UDP data
fields
 Data: Upper-layer data
UDP segment - example
Transport Layer Standards
TCP UDP
 Connection-oriented  Connectionless
 Reliable  Unreliable
 Places a heavy load on  Places a light load on the
the network network

Which is better?
Transportation of Data
The Right Transport Layer Protocol

TCP or UDP
 There is a trade-off between the value of reliability and the burden it
places on the network.
 Application developers choose the transport protocol based on the
requirements of their applications.
Transportation of Data
The Right Transport Layer Protocol (Cont.)
Port Number Fields

Both TCP and UDP headers begin with


a Source Port Number field and
a Destination Port Number field.
Port Numbers on Servers

Multitasking servers run multiple applications.


Each application is assigned a port number.
Port Numbers on Servers

Major applications usually are given


well-known port numbers from 0 to 1023.
HTTP’s well-known port number is 80.
The File Transfer Protocol has two: 20 and 21.
Separating Multiple Communications
 TCP and UDP use port numbers to differentiate between
applications.
TCP and UDP Port Addressing (Cont.)
The combination of the source and destination IP addresses and the
source and destination port numbers is known as a Socket.
TCP and UDP Port Addressing (Cont.)
TCP Port Numbers
TCP and UDP Port Addressing (Cont.)
UDP Port Numbers
TCP and UDP Segmentation
The Transport Layer divides the data into pieces called segments
and adds a header for delivery over the network.
TCP Reliable Delivery
The reliability of TCP communication is obtained through the use of
connection-oriented sessions, ordered delivery,
acknowledgements, fast retransmissions. .
TCP connection management
 Establishment:
• TCP sender, receiver establish “connection” before exchanging
data segments
• initialize TCP variables: starting seq. #s, MSS, buffers,
• flow control info (e.g. RcvWindow)

 MSS is the maximum TCP segment size each side is


willing to accept
• typically the largest segment size fit into a link-layer frame

 Teardown:
• freeing up resources after mutually close
TCP connection Establishment
 Three way handshake:
 Step 1: client (active open) sends TCP SYN segment to
server
• specifies initial seq #
• no data

 Step 2: server (passive open) host receives SYN, replies


with SYNACK segment
• server allocates buffers
• specifies server initial seq. #

 Step 3: client receives SYNACK, replies with ACK


TCP connection Establishment
TCP connection Teardown
 Closing a connection:
• close socket: close(sockfd);

 Step 1: A (active closing host) sends TCP FIN control


segment to server
 Step 2: B (passive closing host) receives FIN, replies
with ACK.
 Closes connection, sends FIN.
 Step 3: A receives FIN, replies with ACK.
• Enters “timed wait” – resend

 ACK in case it is lost


 Step 4: B receives ACK.
 Connection closed.
TCP connection teardown
Protocol Data Units
TCP Reliability – Ordered Delivery
Sequence numbers are used to reassemble segments into the
original order.
TCP Reliability – Acknowledgement and
Window Size
The sequence number and acknowledgement number are used
together to confirm receipt.

The window size is the amount of data that a source can transmit
before an acknowledgement must be received.
Protocol Data Units
TCP Reliability – Data Loss and Retransmission
Data Loss and Retransmission
When TCP at the source host has not received an acknowledgement
after a predetermined amount of time, it goes back to the last
acknowledgement number that it received and retransmits data from
that point forward.
TCP Flow Control
 Uses the Window Size field in the TCP header to specify
the amount of data that can be transmitted before an
acknowledgement must be received.
 Adjusts the effective rate of data transmission to the
maximum flow that the network and destination device
can support without loss.
 Manages the rate of transmission so that all data is
received and retransmissions are minimized.
Flow control cont’d
TCP Server Processes
TCP Server Processes (Cont.)
UDP Communication
UDP Low Overhead vs. Reliability
UDP:
 Simple protocol that provides the basic transport layer function
 Used by applications that can tolerate small loss of data
 Used by applications that cannot tolerate delay

UDP used by:


 DNS
 Simple Network Management Protocol (SNMP)
 Dynamic Host Configuration Protocol (DHCP)
 Trivial File Transfer Protocol (TFTP)
 IP telephony or VoIP
 Online games
UDP Communication
Datagram Reassembly
UDP Communication
UDP Server Processes and Requests
 UDP-based
server
applications are
assigned well-
known or
registered port
numbers.
UDP Communication
UDP Server and Client Processes
 UDP client process
randomly selects a
port number from
range of dynamic
port numbers as
the source port.
TCP or UDP, that is the Question
Applications Using TCP
TCP or UDP, that is the Question
Applications Using UDP
Summary
In this chapter, you learned:
 The role of the transport layer is to provide three main services:
multiplexing, segmentation and reassembly, and error checking.
It does this by:
• Dividing data received from an application into segments.
• Adding a header to identify and manage each segment.
• Using the header information to reassemble the segments
back into application data.
• Passing the assembled data to the correct application.
 How TCP and UDP operate and which popular applications use
each protocol.
 Transport Layer functions are necessary to address issues in
QoS and security in networks.
 Ports provide a “tunnel” for data to get from the transport layer to
the appropriate application at the destination.

S-ar putea să vă placă și