Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Transport Layer

Download as pdf or txt
Download as pdf or txt
You are on page 1of 52

Transport

Layer
Raj Jain
Washington University in Saint Louis
Saint Louis, MO 63130
Jain@wustl.edu
Audio/Video recordings of this lecture are available on-line at:
http://www.cse.wustl.edu/~jain/cse473-09/
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-1
Overview
‰ Transport Layer Design Issues:
‰ Multiplexing/Demultiplexing
‰ Flow control
‰ Error control
‰ UDP
‰ TCP
‰ Header format, connection management, checksum
‰ Slow Start Congestion Control
‰ Note: This class lecture is based on Chapter 3 of the textbook
(Kurose and Ross) and the figures provided by the authors.
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-2
Overview
Transport Layer Design Issues
1. Transport Layer Functions
2. Multiplexing and Demultiplexing
3. Error Detection: Checksum
4. Flow Control
5. Efficiency Principle
6. Error Control: Retransmissions

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-3
Protocol Layers
‰ Top-Down approach
Application HTTP FTP SMTP P2P DNS Skype

Transport TCP UDP

Internetwork IP

Host to
Ethernet Point-to-Point Wi-Fi
Network

Physical Coax Fiber Wireless

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-4
Transport Layer

End System Router Router End System


Application Application
Transport Transport
Network Network Network Network
Datalink Datalink Datalink Datalink
Physical Physical Physical Physical
‰ Transport = End-to-End Services
Services required at source and destination systems
Not required on intermediate hops
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-5
Transport Layer Functions
1. Multiplexing and demultiplexing: among
applications and processes at end systems
2. Error detection: Bit errors
3. Loss detection: Lost packets due to buffer overflow
at intermediate systems (Sequence numbers and
acks)
4. Error/loss recovery: Retransmissions
5. Flow control: Ensuring receiver has buffers
6. Congestion Control: Ensuring network has capacity
Not all transports provide all functions

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-6
Multiplexing and Demultiplexing
‰ Transport Ports and Network addresses are used to separate
flows

User 1 Server User 2


Application Web DNS Web DNS Web DNS
Port #
Transport TCP UDP TCP UDP TCP UDP
Protocol Type
Network IP:128.3.4.1 IP :209.3.1.1 IP :125.5.1.1

SP:3009 DP:80 SA: 128.3.4.1 DA: 209.3.1.1

SP:80 DP:3009 SA:209.3.1.1 DA:128.3.4.1


Washington University in St. Louis CSE473S ©2009 Raj Jain
3-7
Error Detection: Checksum
‰ Cyclic Redundancy Check (CRC): Powerful but generally
requires hardware
‰ Checksum: Weak but easily done in software
‰ Example: 1's complement of 1’s complement sum of 16-bit
words with overflow wrapped around
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1

sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
At receiver the checksum is zero.
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-8
Flow Control
‰ Flow Control Goals:
1. Sender does not flood the receiver,
2. Maximize throughput
Stop and Wait Flow Control Window Flow Control
Sender Receiver Sender Receiver
Pkt 1
Ack
Pkt 2
Ack
Pkt 3
Ack Large RTT
⇒ Low Thruput
L/R W L/R
Throughput = Throughput =
RTT+L/R RTT+L/R
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-9
Sliding Window Diagram

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-10
Stop and Wait Flow Control
sender receiver
first bit transmitted, t = 0
last bit transmitted, t = L / R

first bit arrives


RTT last bit arrives, send ACK

ACK arrives, send next


packet, t = RTT + L / R

L/R tframe 1
U = = =
RTT + L / R 2tprop+tframe 2α + 1
Here, α = tprop/tframe
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-11
Sliding Window Protocol Efficiency
W tframe
U=
2tprop+tframe
tframe Data
tprop W
= 2α+1

1 if W>2α+1
Ack

Here, α = tprop/tframe

W=1 ⇒ Stop and Wait

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-12
Utilization: Examples
Satellite Link: One-way Propagation Delay = 270 ms
RTT=540 ms
Frame Size L = 500 Bytes = 4 kb
Data rate R = 56 kbps ⇒ tframe = L/R= 4/56 = 71 ms
α = tprop/tframe = 270/71 = 3.8
U = 1/(2α+1) = 0.12

‰ Short Link: 1 km = 5 μs,


Rate=10 Mbps,
Frame=500 bytes ⇒ tframe= 4k/10M= 400 μs
α=tprop/tframe=5/400=0.012 ⇒ U=1/(2α+1)=0.98

Note: The textbook uses RTT in place of tprop and L/R for tframe
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-13
Effect of Window Size

α
‰ Larger window is better for larger α
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-14
Efficiency Principle
‰ For all protocols, the maximum utilization (efficiency)
is a non-increasing function of α.
Not Possible
Best
Max possible
Utilization Protocol 1
Protocol 2
α
tprop Distance/Speed of Signal
α= =
tframe Bits Transmitted /Bit rate
Distance × Bit rate
=
Bits Transmitted × Speed of Signal
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-15
Error Control: Retransmissions
‰ Retransmit lost packets ⇒ Automatic Repeat reQuest (ARQ)

Stop and Wait ARQ


Sender Receiver
Pkt 1
Ack
Pkt 2
Timeout ×
Pkt 2
Ack
Pkt 3
Timeout
× Pkt 3
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-16
Go-Back-N ARQ
Sender Rcvr
0
1
2 1
3
Nack 1
1
2
3

‰ Receiver does not cache out-of-order frames


‰ Sender has to go back and retransmit all frames after
the lost frame
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-17
Selective Repeat ARQ
Sender Rcvr
0
1
2 1
3
Nack 1
1
4
5

‰ Receiver caches out-of-order frames


‰ Sender retransmits only the lost frame
‰ Also known as selective reject ARQ

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-18
Selective Repeat: Window Size

0
1
2
3
4
Timeout 5
6
7
Ack
0

Sequence number space > 2 window size


Window size < 2n-1
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-19
Performance: Maximum Utilization
‰ Stop and Wait Flow Control: U = 1/(1+2α)
‰ Window Flow Control:

U=
1
W/(2α+1) { W> 2α+1
W< 2α+1
‰ Stop and Wait ARQ: U = (1-P)/(1+2α)
‰ Go-back-N ARQ: P = Probability of Loss

U= { (1-P)/(1+2αP)
W(1-P)/[(2α+1)(1-P+WP)] W< 2α+1
W> 2α+1

‰ Selective Repeat ARQ:

U=
(1-P)
{
W(1-P)/(2α+1)
W> 2α+1
W< 2α+1
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-20
Performance Comparison
1.0

0.8 W= 127 Go-back-N

W= 127 Selective-repeat
Utilization

0.6

W=7 Go-back-N &


Stop-and-wait W= 7 Selective-repeat
0.4

0.2

0.0
0.1 1 10 100 1000
α More bps or longer distance
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-21
Transport Layer Design Issues

1. Multiplexing/demultiplexing by a combination of source and


destination IP addresses and port numbers.
2. Window flow control is better for long-distance or high-speed
networks
3. Longer distance or higher speed
⇒ Larger α ⇒ Larger window is better
4. Stop and and wait flow control is ok for short distance or low-
speed networks
5. Selective repeat is better stop and wait ARQ
Only slightly better than go-back-N

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-22
Homework 3A
Problem 19 on page 302 of the textbook:
Consider the GBN protocol with a sender window size of 3 and a
sequence number range of 1,024. Suppose that at time t, the
next in-order packet that the receiver is expecting has a
sequence number of k. Assume that the medium does not
reorder messages. Answer the following questions:
A. What are the possible sets of sequence numbers insdie the
sender’s window at time t? Justify your answer.
B. What are all possible values of the ACK field in all possible
messages currently propagating back to the sender at time t?
Justify your answer.

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-23
Overview
UDP and TCP
1. User Datagram Protocol (UDP)
2. TCP Header Format, Options, Checksum
3. TCP Connection Management
4. Round Trip Time Estimation
5. Principles of Congestion Control
6. Slow Start Congestion Control

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-24
Transports
TCP UDP
Reliable data transfer Unreliable Data Transfer
Packet Sequence # required Sequence # optional
Every packet is acked Not Acked
Lost packets are retransmitted No Retransmission
May cause long delay Quick and Lossy
Connection-oriented service Connection-less Service
Good for Reliable and delay- Good for loss-tolerant and
insenstive applications delay sensitive applications
Applications: email, http, ftp, Telephony, Streaming
Remote terminal access Multimedia

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-25
User Datagram Protocol (UDP)
‰ Connectionless end-to-end service
‰ No flow control. No error recovery (no acks)
‰ Provides multiplexing via ports
‰ Error detection (Checksum) optional. Applies to pseudo-header
(same as TCP) and UDP segment. If not used, it is set to zero.
‰ Used by network management, DNS, Streamed multimedia
(Applications that are loss tolerant, delay sensitive, or have
their own reliability mechanisms)

Source Dest Check-


Length
Port Port sum
16 16 16 16 Size in bits
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-26
TCP
‰ Transmission Control Protocol
‰ Key Services:
‰ Send: Please send when convenient

‰ Data stream push: Please send it all now, if


possible.
‰ Urgent data signaling: Destination TCP! please
give this urgent data to the user
(Urgent data is delivered in sequence. Push at the
source should be explicit if needed.)
‰ Note: Push has no effect on delivery.
Urgent requests quick delivery

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-27
TCP Segment Format

Source Dest Seq Ack Data


Resvd U A P R S F
Port Port No No Offset
16 16 32 32 4 6 111111

Check-
Window Urgent Options Pad Data
sum
16 16 16 x y Size in bits

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-28
TCP Segment Format (Cont)
16b 16b
Source Port Dest Port
Seq No
Ack No
Data
Resvd U A P R S F Window
Offset
Checksum Urgent
Options
Pad

Data

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-29
TCP Header Fields
‰ Source Port (16 bits): Identifies source user process
‰ Destination Port (16 bits)
21 = FTP, 23 = Telnet, 53 = DNS, 80 = HTTP, ...
‰ Sequence Number (32 bits): Sequence number of the
first byte in the segment. If SYN is present, this is
the initial sequence number (ISN) and the first data
byte is ISN+1.
‰ Ack number (32 bits): Next byte expected
‰ Data offset (4 bits): Number of 32-bit words in the
header
‰ Reserved (6 bits)
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-30
TCP Header (Cont)
‰ Control (6 bits):Urgent pointer field significant,
Ack field significant,
Push function,
Reset the connection,
Synchronize the sequence numbers,
No more data from sender

URG ACK PSH RST SYN FIN

‰ Window (16 bits):


Will accept [Ack] to [Ack]+[window]-1
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-31
TCP Header (Cont)
‰ Checksum (16 bits): covers the segment plus a
pseudo header. Includes the following fields from IP
header: source and dest adr, protocol, segment length.
Protects from IP misdelivery.
‰ Urgent pointer (16 bits): Points to the byte following
urgent data. Lets receiver know how much data it
should deliver right away.
‰ Options (variable):
Max segment size (does not include TCP header,
default 536 bytes), Window scale factor, Selective
Ack permitted, Timestamp, No-Op, End-of-options

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-32
TCP Options
Kind Length Meaning
0 1 End of Valid options in header
1 1 No-op
2 4 Maximum Segment Size
3 3 Window Scale Factor
8 10 Timestamp

‰ End of Options: Stop looking for further option


‰ No-op: Ignore this byte. Used to align the next option on a 4-
byte word boundary
‰ Max Segment Size (MSS): Does not include TCP header

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-33
TCP Checksum
‰ Checksum is the 16-bit one's complement of the one's
complement sum of a pseudo header of information
from the IP header, the TCP header, and the data,
padded with zero octets at the end (if necessary) to
make a multiple of two octets.
‰ Checksum field is filled with zeros initially
‰ TCP length (in octet) is not transmitted but used in
calculations.
‰ Efficient implementation in RFC1071.

Source Adr Dest. Adr Zeros Protocol TCP Length


32 32 8 8 16
TCP Header TCP data
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-34
TCP Connection Management
‰ Connection Establishment ‰ Connection Termination
‰ Three way handshake ‰ Close with FIN flag set
‰ SYN flag set
‰ Abort
⇒ Request for connection

SYN, ISN = 100 FIN


SYN, ISN = 350, Ack 101 Ack
FIN
Ack 351 Ack

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-35
Example RTT estimation:
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr

350

300

250
RTT (milliseconds)

200

150

100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)

SampleRTT Estimated RTT

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-36
Round Trip Time Estimation
‰ Measured round trip time (SampleRTT) is very random.
‰ EstimatedRTT=(1- α)EstimatedRTT+α SampleRTT
‰ DevRTT = (1-β)DevRTT+ β |SampleRTT-EstmatedRTT|
‰ TimeoutInterval=EstimatedRTT+4 DevRTT

Probability
Very low probability
of false timeout

Value
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-37
Research on Congestion Control
1Mbps 1Mbps 1Mbps 1Mbps 10Mbps 1Mbps Bit in header
Time=6 minutes Time=6 hours
‰ Early 1980s Digital Equipment Corporation (DEC) introduced Ethernet
products
‰ Noticed that throughput goes down with a higher-speed link in middle
(because no congestion mechanisms in TCP)
‰ Results:
1. Timeout ⇒ Congestion
⇒ Reduce the TCP window to one on a timeout [Jain 1986]
2. Routers should set a bit when congested (DECbit).
[Jain, Ramakrishnan, Chiu 1988]
3. Introduced the term “Congestion Avoidance”
4. Additive increase and multiplicative decrease (AIMD principle)
[Chiu and Jain 1989]
‰ There were presented to IETF in 1986.
⇒ Slow-start based on Timeout and AIMD [Van Jacobson 1988]
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-38
AIMD Principle
‰ Additive Increase, Multiplicative
Efficient Fair
Decrease
‰ W1+W2 = Capacity
⇒ Efficiency,
W1=W2 ⇒ Fairness C
‰ (W1,W2) to (W1+DW,W2+DW)
⇒ Linear increase (45° line)
‰ (W1,W2) to (kW1,kW2)
W2
⇒ Multiplicative decrease W1 Capacity
(line through origin)
Ref: D. Chiu and Raj Jain, "Analysis of the Increase/Decrease Algorithms for
Congestion Avoidance in Computer Networks," Journal of Computer
Networks and ISDN, Vol. 17, No. 1, June 1989, pp. 1-14,
http://www.cse.wustl.edu/~jain/papers/cong_av.htm
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-39
ATM Networks
PBX PBX

1 3 5 2 3

‰ Asynchronous transfer mode


‰ Uses fixed size 53-byte cells
‰ Connection Oriented Network Layer
⇒ Connection setup before data transfer
‰ Cells contain Virtual Circuit Identifiers (VCI)
‰ Switch forwarding tables contain:
Input Interface + VCI → Output Interface + New VCI
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-40
ATM ABR Service
Source Switch Destination

‰ Explicit Rate Feedback for congestion control


⇒ Available bit rate (ABR) service
Every 32nd cell is a Resource Management (RM) cell. Switches
put the rate in the cell. Destinations return the cell to source.
‰ Ref: Anna Charny, David D. Clark, Raj Jain, "Congestion Control with
Explicit Rate Indication," ATM Forum/94-0692, July 1994,
http://www.cse.wustl.edu/~jain/atmf/af_mit2.htm

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-41
Slow Start Congestion Control
‰ Window = Flow Control Avoids receiver overrun
‰ Need congestion control to avoid network overrun
‰ The sender maintains two windows:
Credits from the receiver
Congestion window from the network
Congestion window is always less than the receiver window
‰ Starts with a congestion window (CWND) of 1 segment (one
max segment size)
⇒ Do not disturb existing connections too much.
‰ Increase CWND by 1 MSS every time an ack is received

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-42
Slow Start (Cont)
‰ If segments lost, remember slow start threshold
(SSThresh) to CWND/2
Set CWND to 1 MSS
Increment by 1 per ack until SSthresh
Increment by 1 MSS/CWND per ack afterwards

Receiver Window
Congestion Timeout
Window SSThresh Idle
CWND Interval

1
Washington University in St. Louis CSE473S Time ©2009 Raj Jain
3-43
Slow Start (Cont)
‰ At the beginning, SSThresh = Receiver window
‰ After a long idle period (exceeding one round-trip
time), reset the congestion window to one.
‰ Exponential growth phase is also known as “Slow
start” phase
‰ The linear growth phase is known as “congestion
avoidance phase”

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-44
Fast Recovery
‰ Optional – implemented in TCP Reno
(Earlier version was TCP Tahoe)
‰ Duplicate Ack indicates a lost/out-of-order segment
‰ On receiving 3 duplicate acks:
‰ Enter Fast Recovery mode

 Retransmit missing segment

 Set SSTHRESH=CWND/2

 Set CWND=SSTHRESH+3 MSS

 Every subsequent duplicate ack: CWND=CWND+1MSS

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-45
TCP Congestion Control State Diagram
New Ack
CWND=CWND+1
DupAckCount=0 Dup Ack
Dup Ack Transmit new segment as allowed DupAckCount++
DupAckCount++
Slow CWND>SSthresh Congestion
Initially Start Avoidance

eout
Timeout
CWND=1
ouTim Ssthresh=CWND/2
Ssthresh=64kB/MSS
CWND=1MSS
t

DupAckCount=0
DupAckCount=0
e
Tim

DupAckCount==3 Retransmit missing DupAckCount==3


Ssthresh=CWND/2 segment Ssthresh=CWND/2
Cwnd=ssthresh+3MSS Cwnd=ssthresh+3MSS
Retransmit missing Retransmit missing
segment segment
Dup Ack Fast
CWND=CWND+1MSS Recovery
Transmit new segments as allowed
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-46
TCP Average Throughput
1.22 MSS
‰ Average Throughput =
RTT √P

‰ Here, P = Probability of Packet loss

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-47
UDP and TCP: Summary
1. UDP provides flow multiplexing and optional
checksum
2. Both UDP and TCP use port numbers for
multiplexing
3. TCP provides reliable full-duplex connections.
4. TCP is stream based and has credit flow control
5. Slow-start congestion control works on timeout

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-48
Homework 3B
‰ Problem P37 on page 306 of the textbook:
‰ Consider Figure 3.58. Assuming TCP Reno is the protocol
experiencing the behavior shown above, answer the following
questions. In all cases, you should provide a short discussion
justifying your answer.
TCP Window Size
45
40
35
CWND

30
25
20
15
10
5
0
0 5 10 15 20 25 30
Transmission Round

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-49
Homework 3B (Cont)
‰ A. Identify the interval of time when TCP slow start is
operating.
‰ B. Identify the intervals of time when TCP congestion
avoidance is operating.
‰ C. After the 16th transmission round, is segement loss detected
by a triple duplicate ACK or by a timeout?
‰ D. After the 22nd tranmsission round, is segment loss detected
by a triple duplicate ACK or by a timeout?
‰ E. What is the initial value of ssthresh at the first transmission
round?
‰ F .What is the value of ssthresh at the 18th transmission round?
‰ G. What is the value of ssthresh at the 24th transmission round?

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-50
Homework 3B (Cont)
‰ H. During what transmission round is the 70th segment sent?
‰ I. Assuming a packet loss is detected after the 26th round by the
receipt of a triple duplicate ACK, what will be the values of the
congestion window size and of ssthresh?
‰ J. Suppose TCP Tahoe is used (instead of TCP Reno), and
assume that triple duplicate ACKs are received at the 16th
round. What are the ssthresh and the congestion window size at
the 19th round?
‰ K. Again suppose TCP Tahoe is used, and there is a timeout
event at 22nd round. How many packets have been sent out
from 17th round till 22nd round, inclusive?

Washington University in St. Louis CSE473S ©2009 Raj Jain


3-51
Summary

1. Multiplexing/demultiplexing by a combination of source and


destination IP addresses and port numbers.
2. Longer distance or higher speed
⇒ Larger α ⇒ Larger window is better
3. Window flow control is better for long-distance or high-speed
networks
4. UDP is connectionless and simple.
No flow/error control. Has error detection.
5. TCP provides full-duplex connections with
flow/error/congestion control.
Washington University in St. Louis CSE473S ©2009 Raj Jain
3-52

You might also like