Professional Documents
Culture Documents
Chapter 3 - Transport Layer.1
Chapter 3 - Transport Layer.1
Chapter 3 - Transport Layer.1
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
UDP provides:
• TCP provides:
No connection establishment.
• Connection establishment. “Does not negotiate details”
Unreliable , no data error checking.
“Negotiate transport details”
No flow or congestion control.
• Reliable , error checked data. No ordered delivery.
• Flow and congestion control.
• Ordered delivery. Applications :
4
HTTP FTP TFTP
Web Server
TCP
TCP
Email and
TCP FTP Server
UDP
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
• Segment is encapsulated in to a packet in the network layer. The network layer protocol IP is a best-effort
service “ Not guaranteed or Unreliable service .
• TCP/UDP extend IP’s delivery service between two end systems by it’s offered services. 9
TCP Header UDP Header
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:
• When a packet is decapsulated at the destination, the protocol code in the IP Packet Header
specifies whether the segment is TCP or UDP.
• 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:
5004 – RTP
8080 – Alternate HTTP
• Dynamic Ports:
• Note: Some peer-to-peer file sharing programs use these ports as Register Ports.
Client Server
Example : Establishing a Telnet session
Telnet
Client TCP Header
1028
23
Telnet Data
18
Client Server
Example : Establishing a Telnet session
Telnet
Server TCP Header
23 1028
Telnet Data
C:\netstat -n
Destination Port Connection State
Active Connections Source Port
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
0 15 16 31
Client Server
0 15 16 31
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.
It is up to the application layer protocol (example TFTP) to decide what to do, such as prompt the user
to download/upload the entire file again.
25
UDP
• The user uses TFTP to upload a file to a TFTP server.
26
CONNECTION-ORIENTED TRANSPORT:
TCP
TCP
• TCP provides:
• Reliable delivery 0 15 16 31
28
0 15 16 31
• 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.
• Sequence number synchronization is used to track the order of packets to ensure no packets lost in
transmission.
THREE-WAY
HANDSHAKE
Step 1:
SYN Received
• The three-way handshake starts by sending a segment
with the SYN (Synchronize Sequence Number) control
flag set, indicating an initial value in the sequence number
field in the header.
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 ).
33
• SYN flag is also set with its own random ISN for the Sequence number.
34
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
35
segment.
• HTTP Request (GET)
36
0 15 16 31
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. 37
0 15 16 31
• Reliability
• Flow Control
er W indow
Serv 0
32 bit Acknowledgement Number
10,00
Size=
4-bit Header 6-bit U A P R S F
Length (Reserved) R C S S Y I 16-bit Window Size
G K H T N N
• The receiving host's TCP layer reports a window size to the sending host's TCP layer. “The
maximum number of received data (bytes) that can be buffered by this host, before an
acknowledgment from this (the receiver host ) will be sent.
• TCP is a full duplex service, client and server specify their own window sizes. 39
Client Win
dow
Size=5,000
My Receive My Receive Window:
Window: 5,000 dow 10,000
erver Win
S 0
10,00
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.
40
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.
For example, starting with a sequence number of 2000, if 10 segments of 1000 bytes each were received
by the server, an acknowledgement number of 12001 would be returned to the source.
41
MSS of 1,000 bytes
Client Web
Client Wind Server
ow
Size=5,000
bytes Send Window=5,000
SEQ=1 (to 1,000)
• This is known as a Stop-and-Wait indow
Server W 0bytes …
,00 SEQ=1,001 (to 2,000)
windowing protocol. Size=10
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,0
0 1 (With Sliding windows)
• 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.
44
THE TCP RETRANSMISSION
TIMER
• TCP uses a single retransmission timer for all of it’s unacknowledged segment sent within a TCP
connection.
45
Scenario 1: Loss of an ACK
Client Web
Server
• Client
• Receives segment but discards it.
• Resends ACK
• Web Server
• Receives ACK
46
Scenario 2: ACK arrives after timer expires Web Server
Client
• Web Server:
ata
• Sends 2 segments Q=92 , 8 bytes d
SE seq 92
• Starts timer for oldest segment, SEQ=92 s data Timeout
Q=10 0, 20 byte
• Waits for ACK SE
AC (TCP
AC K= Retransmission
• Client: K
10
0 Timer)
=1
• Receives both segments 2 0
• Sends 2 separate ACKs , 8 bytes data
S EQ=92
seq 92
Timeout
• Web Server: AC
K=
• Neither ACK has arrived yet 12
0
• Timer for SEQ=92 expires
• Resends segment SEQ=92
• Restarts timer for SEQ=92 This ACK tells
the Web Server
• Client: that both
segments have
• Receives retransmitted SEQ=92 segment. been received.
• Discards segment
47
• Re-sends ACK=120 for next byte needed
Client Web Server
Scenario 3: Loss of first ACK
• Web Server:
• Before timer expires for SEQ=92 ACK
(ACK=100), receives ACK=120
• Web Server knows that Client has received
everything up to byte 119.
• Does not need to resend either of the two
segments. 48
A FEW MORE NOTES ON WINDOW SIZE, TIMERS, ETC.
0 15 16 31 0 15 16 31
16-bit Source Port Number 16-bit Destination Port Number 16-bit Source Port Number 16-bit Destination Port Number
16-bit TCP Checksum 16-bit Urgent Pointer 16-bit TCP Checksum 16-bit Urgent Pointer
• 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.
Application
Layer
FTP HTTP SMTP Telnet TFTP SNMP DHCP DNS
Transport
Layer
TCP UDP
Internet
IP
Layer
Network
Access
Layer LAN / WAN
50
SUMMARY: PORT NUMBERS
Port Layer 4
Application Description
Number Protocol
20 FTP TCP File Transfer Protocol – Data