CCNA1-CH14-Transport Layer
CCNA1-CH14-Transport Layer
• Uses port number and sequence number to assemble and distinguish between
multiple applications segments received at a device .
• This also allows data to be multiplexed on the line.
Transport Layer
TCP UDP
3
TCP vs. UDP
• Applications: • Applications :
4
HTTP FTP TFTP
Web
Server
TCP
TCP
Email and
TCP FTP
UDP Server
TCP
UDP
◆ A single client might have multiple TCP or UDP connections with multiple servers
at the same time.
◆ As the TCP perform handshaking , it is represented by a two ways arrow.
6
Segmentation and Reassembly
• An Ethernet frame has a maximum frame size or Maximum Transmission Unit (MTU)
of 1,518 bytes.
1500 octets
8
Transport Layer
segment segment
◆ TCP/UDP extend IP’s delivery service between two end systems by it’s offered
services.
9
TCP Header UDP Header
Application Header
i.e. (HTTP) header
or + data
10
Some types of data where errors can be tolerated might be send quickly.
Port Numbers: TCP and UDP
Identifying the Conversations
IP Packet Header
• At the TCP/IP Internet Layer:
• Port numbers are used to inform the receiver the proper application by which
it should process the “Data”.” Used to pass information to upper layers”
◆ The combination of the port number and the host IP address uniquely identifies a
particular process running “socket number” . An HTTP web page with (port 80)
running on a host with IP address of 192.168.1.20 would be destined to socket
192.168.1.20:80.
◆ Port numbers are assigned by the Internet Assigned Numbers Authority (IANA).
◆ Port numbers are divided in to three main categories (Well known ports ,
Registered ports , Dynamic or private ports).
14
Port Addressing Types and Tools
• Well-Known Ports:
• Note: Some peer-to-peer file sharing programs use these ports as Register Ports.
Telnet
Client TCP Header
1028
23
Telnet Data
18
Client Server
Example : Establishing a Telnet
session
Telnet
Server TCP Header
23 1028
Telnet Data
19
Same client to same server but with
two different HTTP sessions
49888 49890
◆ Client: Same destination port
◆ Client: Different source ports to
uniquely identify this web session.
C:\netstat -n
Destination Port Connection
Active Connections Source Port State
TCP Proto Local Address Foreign Address State
or TCP 192.168.1.101:49888 198.133.219.25:80 TIME_WAIT
UDP TCP 192.168.1.101:49890 198.133.219.25:80 TIME_WAIT
Source IP Destination IP
20
Connectionless Transport: UDP
UDP
23
The UDP header – a smaller header overhead
24
UDP - No connection establishment
Client Server
U DP
se g m
Time ent
U DP
s e gm
e nt
U DP
se g m
e nt
U DP
s e gm
e nt
25
UDP Checksum ..Error detection But not correction
◆ If datagrams take multiple paths, they will sometimes arrive in the wrong order.
UDP does not sequence or acknowledge datagrams as TCP does .
◆ UDP (only detects if there is an error) it does nothing to recover the error.
26
UDP
◆ The user uses TFTP to upload a file to a TFTP server.
27
UDP
◆ Although DNS and SNMP use UDP by default, both can also use TCP.
◆ DNS will use TCP if the DNS request or DNS response is more than
512 bytes, such as when a DNS response includes many name
resolutions. Similarly, under some situations the network
28
administrator may want to configure SNMP to use TCP.
UDP
◆ DNS uses UDP when clients send requests to a DNS server, and TCP
when two DNS serves directly communicate.
29
Connection-oriented Transport: TCP
TCP
◆ TCP provides:
• Reliable delivery
• Error checking
• Flow control
• Congestion control
• Ordered delivery
• Connection establishment
31
TCP Header
32
TCP Header
TCP Header Field Description
Source Port A 16-bit field used to identify the source application by port number.
Destination Port A 16-bit field used to identify the destination application by port number.
A 32-bit field used to indicate that data has been received and the next byte expected from the
Acknowledgment Number
source.
Header Length A 4-bit field known as ʺdata offsetʺ that indicates the length of the TCP segment header.
A 6-bit field used that includes bit codes, or flags, which indicate the purpose and function of the
Control bits
TCP segment.
Window size A 16-bit field used to indicate the number of bytes that can be accepted at one time.
Checksum A 16-bit field used for error checking of the segment header and data.
33
TCP
34
3 Way Handshake – role
• Verifies that the destination device has an active service and inform it that
the source client intends to establish a communication session on that port
number.
• The initial window size is also determined during the three-way handshake.
Step 1:
SYN, SEQ=8563
SYN Received
SYN, ACK,
SEQ=1678
SYN, ACK Received
ACK=8564
Step 2:
◆ The TCP server needs to acknowledge the receipt of the SYN segment.
◆ Server sends a segment back to the client with ACK flag set.
◆ The value of the acknowledgment number field is equal to the client initial
sequence number plus 1. (Expectational acknowledgement - The next
byte this host expects to receive ).
• SYN flag is also set with its own random ISN for the Sequence number.
38
39 ◆ Step 2: Server responds with ACK=8564, own ISN, SEQ=1678
Client Web Server
Three-way
Handshake
SYN, SEQ=8563
SYN Received
SYN, ACK,
SEQ=1678
SYN, ACK Received
ACK=8564
ACK,
SEQ=8564
ACK=1679 ACK Received
HTTP Request
(GET)
Step 3:
◆ TCP client responds with a segment containing an ACK that is the response to
the TCP SYN sent by the server.
◆ The value in the acknowledgment number field contains one more than the initial
sequence number received from the server.
◆ After the three way handshaking is completed , The client can now send
application data encapsulated in TCP segment.
• HTTP Request (GET)
40
◆ Step 3: Client sends ACK=1679
41
TCP: Connection Termination
1. When the client has no more data to send in the stream, it sends a segment with
the FIN flag set.
2. The server sends an ACK to acknowledge the receipt of the FIN to terminate the
session from client to server.
3. The server sends a FIN to the client, to terminate the server to client session.
4. The client responds with an ACK to acknowledge the FIN from the server.
42
Flow Control and Reliability
◆ Reliability
◆ Flow Control
43
Client
Windo
Size= w
5,000
er
Serv w
o
Wind 10,000
Size=
◆ TCP is a full duplex service, client and server specify their own window sizes.
44
Client W
ind
Size=5,0 ow
00
My Receive My Receive
Window: 5,000 ow
ve r Wind Window: 10,000
Ser 10,000
Size=
Client Example
◆ Receive Window Size=5,000 bytes – Server can only send 5,000 bytes before it
receives an acknowledgement.
◆ Send Window Size = 10,000 bytes – Server told the client that client can send the
server 10,000 bytes before receiving an acknowledgment.
45
Flow Control and Reliability
● When TCP has a large file (such an image) it breaks it into equal segments, with
the last segment typically smaller.
46
MSS of 1,000 bytes
Client Web
Client Win Server
do
Size=5,00 w
0 bytes Send Window=5,000
SEQ=1 (to 1,000)
◆ This is known as a Stop- Window
Server 000bytes…
and-Wait windowing 0, SEQ=1,001 (to 2,000)
Size=1
protocol. SEQ=2,001 (to 3,000)
◆ Server must wait for SEQ=3,001 (to 4,000)
acknowledgment before
SEQ=4,001 (to 5,000)
continuing to send data.
Send Window: Byte 10,000
ACK=5,
001 (With Sliding windows)
47
TCP Retransmission
• A destination host service using TCP usually only acknowledges data for
contiguous sequence bytes.
• If one or more segments are missing, only the data in the segments that
complete the stream are acknowledged.
Sliding Windows
◆ Sliding window algorithms are methods of flow control used by the receiver to
control data transfer ( flow) using the receivers Window size.
◆ Over time, this sliding window size increases as the receiver acknowledges data.
49
The TCP retransmission timer
◆ TCP uses a single retransmission timer for all of it’s unacknowledged segment
sent within a TCP connection.
50
Scenario 1: Loss of an ACK
Client Web
Server
51
Scenario 2: ACK arrives after timer expires Web Server
Client
◆ Web Server:
a
• Sends 2 segments , 8 bytes dat
2
• Starts timer for oldest segment, SEQ=9 seq 92
SEQ=92 ata Timeout
0 , 2 0 bytes d
0
• Waits for ACK SEQ=1
AC (TCP
◆ Client: AC K=
1
Retransmission
K= 00
• Receives both segments 1
Timer)
20
• Sends 2 separate ACKs
a
, 8 bytes dat
2
SEQ=9 seq 92
◆ Web Server:
Timeout
• Neither ACK has arrived yet
AC
• Timer for SEQ=92 expires K=
1
• Resends segment SEQ=92 20
• Restarts timer for SEQ=92
52
Client Web Server
Scenario 3: Loss of first ACK
53
Scenario 4: Data Loss and
Retransmission
• ACKs not arriving before retransmission timer expires or not arriving at all.
◆ This may also cause the host to increase it’s retransmission timer interval.
• Receive buffers are decreasing, filling up.
56
A few more notes on Window Size, Timers, etc.
Application
Layer
FTP HTTP SMTP Telnet TFTP SNMP DHCP DNS
Transport
Layer
TCP UDP
Internet
IP
Layer
Network
Access
Layer LAN / WAN
58
Summary: Port Numbers
Port Layer 4
Application Description
Number Protocol
20 FTP TCP File Transfer Protocol – Data