Networking Test Friday Online
© 2007 Cisco Systems, Inc. All rights reserved. Cisco Public 1
OSI Transport Layer
Network Fundamentals – Chapter 4
Dr. C. BouSaba
2 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
OSI transport layer
OSI model layer 4
Application
Presentation
Session
Transport
Network
Data link
Physical
Application
Transport
Internet
Network Access
TCP, UDP
IP
Ethernet,
WAN
technologies
HTTP, FTP,
TFTP, SMTP
etc
Segment
Packet
Frame
Bits
Data
stream
TCP/IP model Transport layer
3 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Purpose of transport layer
Responsible for the overall end-to-end transfer of application data.
Enables multiple applications on the same device to send data over the network at the same time
Provides “reliability” and error handling if required. (Checks if data has arrived and re-sends if it has not.)
4 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Transport Layer TCP and UDP
Preparing application data for transport over the network and processing network data for use by applications.
Tracking the individual communication between (one or more) applications on the source and destination hosts
Segmenting data and managing each piece
Reassembling the segments into application data
Identifying the different applications using an identifier (port number)
5 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Transport Layer:
Controlling the Conversations
6 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Supporting Reliable Communication
7 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Transport Layer TCP and UDP
8 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Why two transport protocols?
Some applications need their data to be complete with no errors or gaps and they can accept a slight delay to ensure this. They use TCP.
Some applications can accept occasional errors or gaps in the data but they cannot accept any delay. They use UDP.
Reliable
Fast
9 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP and UDP headers
10 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
11 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP UDP
Sets up a connection with the receiving host before sending data.
Checks if segments have arrived and resends if they were lost. (Reliability)
Sorts segments in right order before reassembling the data.
Sends at a speed to suit the receiving host. (Flow control)
But – this takes time and resources (High overhead).
Robust
Connectionless. Does not contact receiving host before sending data.
Does not check if data arrived and does not re-send. (Unreliable)
Does not sort into the right order.
“Best effort”.
Low overhead.
Used for VoIP, streaming video, DNS, TFTP (data sensitive to delays)
12 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Port Numbers and Sockets
Used by TCP and UDP as a form of addressing.
Identifies the application and the conversation.
Common application protocols have default port numbers e.g. 80 for HTTP, 110 for POP3 mail, 20/21 for FTP, 23 for Telnet
Client PC uses port 80.
Identifies HTTP as application.
Requesting a web page.
Client PC uses port 49152.
Chosen at random.
Remembers this to identify
application and conversation.
Port + IP address = socket. E.g. 192.168.2.12:80
13 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Transport Layer Role and Services
14 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Port Addressing: Identifying the Conversations
15 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Port numbers
The Internet Assigned Numbers Authority (IANA) assigns port numbers.
Well Known Ports (0 to 1023) - Reserved for common services and applications such as HTTP, FTP, Telnet, POP3, SMTP.
Registered Ports (1024 to 49151) - Assigned to user processes or applications. Can be dynamically selected by a client as its source port.
Dynamic or Private or Ephemeral Ports (49152 to 65535) – Can be assigned dynamically to client applications when initiating a connection.
16 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
The IANA assigns port numbers
17 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
The IANA assigns port numbers
18 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
The IANA assigns port numbers
19 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Port Addressing: netstat command Sometimes it is necessary to know which active TCP connections are open
and running on a networked host.
Unexpected connections may mean there is a security problem.
Netstat is an important network utility that can be used to verify those connections. Netstat lists:
protocol in use, local address and port number, foreign address and port number, state of the connection.
20 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Segment and sequence
Both TCP and UDP split application data into suitably sized pieces for transport and re-assemble them on arrival.
TCP has sequence numbers in the segment headers. It re-assembles segments in the right order.
UDP has no sequence numbers. It assembles datagrams in the order they arrive.
21 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Connection oriented
TCP sets up a connection between end hosts before sending data
The two hosts go through a synchronization process to ensure that both hosts are ready and know the initial sequence numbers.
This process is the Three-way handshake
When data transfer is finished, the hosts send signals to end the session.
22 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Three way handshake
Send SYN
seq = x
Receive SYN
seq = x
Receive SYN
ack = y
seq = x+1
Receive ACK
ack = y+1
Send ACK
ack = y+1
Send SYN
ack = y
seq = x+1
23 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Terminating connection
24 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP-Making Conversations Reliable The key distinction between TCP and UDP is reliability.
The reliability of TCP communication is performed using connection-oriented sessions. (3 way handshake)
Before a host using TCP sends data to another host, the Transport layer initiates a process to create a connection with the destination.
This process ensures that each host is aware of and prepared for communication.
After a session has been established (3 way handshake), the destination sends acknowledgements to the source for the segments that it receives.
As the source receives an acknowledgement, it knows that the data has been successfully delivered and can quit tracking that data.
If the source does not receive an acknowledgement within a predetermined amount of time, it retransmits that data to the destination.
There is also additional overhead on the individual hosts created by the necessity to keep track of which segments are awaiting acknowledgement and by the retransmission process.
25 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Expectational acknowledgement
TCP checks that data has been received.
The receiving host sends an acknowledgement giving the sequence number of the byte that it expects next.
26 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Window size
Controls how many bytes are sent before an acknowledgement is expected.
27 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Lost segments
Send bytes 1 to 2999
Receive 1 to 2999, send ACK 3000
Send bytes 3000 to 4999
Receive 3000 to 3999, send ACK 4000 (bytes 4000 to 4999 were lost)
Send bytes 4000 to 5999
Lost segments are re-sent.
If no ACK – send them all again
28 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Flow control
The initial window size is agreed during the three-way handshake.
If this is too much for the receiver and it loses data (e.g. buffer overflow) then it can decrease the window size.
If all is well then the receiver will increase the window size.
29 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Application and Operation of TCP Mechanisms
30 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Application and Operation of TCP Mechanisms
31 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP Connection Establishment and Termination
32 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP Connection Establishment and Termination
33 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP Connection Establishment and Termination
34 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP Connection Establishment: Three-way Handshake
The three steps in TCP connection establishment are:
1. The initiating client sends a segment containing an initial sequence value, which serves as a request to the server to begin a communications session.
2. The server responds with a segment containing an acknowledgement value equal to the received sequence value plus 1, plus its own synchronizing sequence value.
The value is one greater than the sequence number because the ACK is always the next expected Byte or Octet.
This acknowledgement value enables the client to tie the response back to the original segment that it sent to the server.
3. Initiating client responds with an acknowledgement value equal to the sequence value it received plus one. This completes the process of establishing the connection.
35 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP Termination Look at the various values that the two hosts exchange.
Within the TCP segment header, there are six 1-bit fields that contain control information used to manage the TCP processes. Those fields are:
URG - Urgent pointer field significant
ACK - Acknowledgement field significant
PSH - Push function
RST - Reset the connection
SYN - Synchronize sequence numbers
FIN - No more data from sender
These fields are referred to as flags, because the value of one of these fields is only 1 bit and, therefore, has only two values: 1 or 0. When a bit value is set to 1, it indicates what control information is contained in the segment.
Using a four-step process, flags are exchanged to terminate a TCP connection.
36 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP Segment Reassembly
37 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP Acknowledgement with Windowing
38 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
UDP: Low Overhead vs. Reliability
39 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
UDP – Low Overhead vs. Reliability UDP is a simple protocol that provides the basic Transport layer functions.
It is not connection-oriented
It does not provide retransmission, sequencing, and flow control.
This does not mean that applications that use UDP are always unreliable.
It simply means that these functions are not provided by the Transport layer protocol and must be implemented elsewhere if required.
key Application layer protocols that use UDP include:
Domain Name System (DNS)
Simple Network Management Protocol (SNMP)
Dynamic Host Configuration Protocol (DHCP)
Routing Information Protocol (RIP)
Trivial File Transfer Protocol (TFTP)
Online games
If these applications used TCP, they may experience large delays while TCP detects data loss and retransmits data.
These delays would be more detrimental to the application than small data losses.
40 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
UDP Protocol
41 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
UDP Datagram Reassembly
42 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
UDP Client Processes
43 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
UDP Client Processes
44 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Comparison of TCP and UDP
Both TCP and UDP use port numbers
Both split up application data if necessary
TCP sets up a connection
TCP uses acknowledgements and re-sends
TCP uses flow control
TCP can re-assemble segments in the right order if they arrive out of sequence
UDP has less overhead so is faster
45 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Comparison of TCP and UDP
46 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
TCP and UDP The 2 most common Transport layer protocols:
User Datagram Protocol (UDP)
UDP is a connectionless protocol, described in RFC 768.
It provides low overhead data delivery.
The pieces of communication in UDP are called datagrams.
each UDP segment only has 8 bytes of overhead.
These datagrams are sent as "best effort".
Applications that use UDP include: Domain Name System (DNS), Video Streaming, Voice over IP (VoIP)
Transmission Control Protocol (TCP)
TCP is a connection-oriented protocol, described in RFC 793.
TCP incurs additional overhead to gain functions.
Additional functions specified by TCP are: the same order delivery, reliable delivery, and flow control.
Each TCP segment has 20 bytes of overhead in the header encapsulating the Application layer data,
Applications that use TCP are: Web Browsers, E-mail, File Transfers
47 © 2007 Cisco Systems, Inc. All rights reserved. Cisco Public
Summary