Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 37

15-441 Computer Networking

Lecture 16 – Transport Protocols


Outline

• Transport introduction

• Error recovery

• TCP flow control

Lecture 16: 03-16-2004 2


Transport Protocols

• Lowest level end-to-


end protocol.
77 77
• Header generated by
sender is interpreted 66 66
only by the destination
55 55
• Routers view transport
header as part of the Transport
Transport Transport
Transport
payload IP IP IP
IP IP IP

Datalink
Datalink 22 22 Datalink
Datalink

Physical
Physical 11 11 Physical
Physical

router

Lecture 16: 03-16-2004 3


Functionality Split

• Network provides best-effort delivery


• End-systems implement many functions
• Reliability
• In-order delivery
• Demultiplexing
• Message boundaries
• Connection abstraction
• Congestion control
• …

Lecture 16: 03-16-2004 4


Transport Protocols

• UDP provides just integrity and demux


• TCP adds…
• Connection-oriented
• Reliable
• Ordered
• Point-to-point
• Byte-stream
• Full duplex
• Flow and congestion controlled

Lecture 16: 03-16-2004 5


UDP: User Datagram Protocol [RFC 768]

• “No frills,” “bare bones”


Internet transport protocol Why is there a UDP?
• “Best effort” service, UDP • No connection establishment
segments may be: (which can add delay)
• Lost • Simple: no connection state
• Delivered out of order to app at sender, receiver
• Connectionless: • Small header
• No handshaking between UDP • No congestion control: UDP
sender, receiver can blast away as fast as
• Each UDP segment handled desired
independently of others

Lecture 16: 03-16-2004 6


UDP, cont.

• Often used for


32 bits
streaming
multimedia apps Length, in Source port # Dest port #
• Loss tolerant bytes of UDP Length Checksum
segment,
• Rate sensitive including
• Other UDP uses header
(why?):
• DNS, SNMP Application
data
• Reliable transfer (message)
over UDP
• Must be at
application layer UDP segment format
• Application-specific
error recovery
Lecture 16: 03-16-2004 7
UDP Checksum

Goal: detect “errors” (e.g., flipped bits) in transmitted segment – optional use!

Sender: Receiver:
• Treat segment contents as • Compute checksum of
sequence of 16-bit integers received segment
• Checksum: addition (1’s • Check if computed checksum
complement sum) of segment
contents equals checksum field value:
• Sender puts checksum value
• NO - error detected
into UDP checksum field • YES - no error detected
But maybe errors
nonethless?

Lecture 16: 03-16-2004 8


High-Level TCP Characteristics

• Protocol implemented entirely at the ends


• Fate sharing
• Protocol has evolved over time and will continue
to do so
• Nearly impossible to change the header
• Uses options to add information to the header
• Change processing at endpoints
• Backward compatibility is what makes it TCP

Lecture 16: 03-16-2004 9


TCP Header

Source port Destination port

Sequence number
Flags: SYN
Acknowledgement
FIN
RESET HdrLen 0 Flags Advertised window
PUSH
URG Checksum Urgent pointer
ACK Options (variable)

Data

Lecture 16: 03-16-2004 10


Evolution of TCP

1984
1975 Nagel’s algorithm
Three-way handshake to reduce overhead 1987
Raymond Tomlinson of small packets; Karn’s algorithm 1990
In SIGCOMM 75 predicts congestion to better estimate 4.3BSD Reno
collapse round-trip time fast retransmit
delayed ACK’s
1983
BSD Unix 4.2 1986 1988
1974 supports TCP/IP Congestion Van Jacobson’s
TCP described by collapse algorithms
Vint Cerf and Bob Kahn observed congestion avoidance
In IEEE Trans Comm 1982 and congestion control
TCP & IP (most implemented in
RFC 793 & 791 4.3BSD Tahoe)

1975 1980 1985 1990

Lecture 16: 03-16-2004 11


TCP Through the 1990s

1994 1996
T/TCP SACK TCP
(Braden) (Floyd et al)
Transaction Selective
TCP Acknowledgement

1993 1994 1996 1996


TCP Vegas ECN Hoe FACK TCP
(Brakmo et al) (Floyd) Improving TCP (Mathis et al)
real congestion Explicit startup extension to SACK
avoidance Congestion
Notification

1993 1994 1996

Lecture 16: 03-16-2004 12


Outline

• Transport introduction

• Error recovery

• TCP flow control

Lecture 16: 03-16-2004 13


Stop and Wait

• ARQ
• Receiver sends
acknowledgement (ACK)
Sender Receiver
when it receives packet
• Sender waits for ACK and Packe
t

Timeout
timeouts if it does not arrive
within some time period ACK
• Simplest ARQ protocol
• Send a packet, stop and Time
wait until ACK arrives

Lecture 16: 03-16-2004 14


Recovering from Error

Packe Packe Packe


t t t
Timeout

Timeout

Timeout
ACK C K
Time A
Packe
Packe Packe t
t t
Timeout

Timeout

Timeout
ACK
ACK ACK

ACK lost Packet lost Early timeout

Lecture 16: 03-16-2004 15


Problems with Stop and Wait

• How to recognize a duplicate


• Performance
• Can only send one packet per round trip

Lecture 16: 03-16-2004 16


How to Recognize Resends?

• Use sequence numbers


• both packets and acks Pkt 0
• Sequence # in packet is finite
0
-- how big should it be? AC
K
• For stop and wait? Pkt 0

• One bit – won’t send seq #1 ACKP0kt


1
until received ACK for seq #0
ACK 1

Lecture 16: 03-16-2004 17


How to Keep the Pipe Full?

• Send multiple packets without waiting


for first to be acked
• Number of pkts in flight = window
• Reliable, unordered delivery
• Several parallel stop & waits
• Send new packet after each ack
• Sender keeps list of unack’ed packets;
resends after timeout
• Receiver same as stop & wait
• How large a window is needed?
• Suppose 10Mbps link, 4ms delay, 500byte
pkts
• 1? 10? 20?
• Round trip delay * bandwidth = capacity of
pipe

Lecture 16: 03-16-2004 18


Sliding Window

• Reliable, ordered delivery


• Receiver has to hold onto a packet until all prior
packets have arrived
• Why might this be difficult for just parallel stop & wait?
• Sender must prevent buffer overflow at receiver
• Circular buffer at sender and receiver
• Packets in transit ≤ buffer size
• Advance when sender and receiver agree packets at
beginning have been received

Lecture 16: 03-16-2004 19


Sender/Receiver State

Sender
Sender Receiver
Receiver

Max ACK received Next seqnum Next expected Max acceptable

… … … …

Sender window Receiver window

Sent & Acked Sent Not Acked Received & Acked Acceptable Packet

OK to Send Not Usable Not Usable

Lecture 16: 03-16-2004 20


Window Sliding – Common Case

• On reception of new ACK (i.e. ACK for something that was


not acked earlier)
• Increase sequence of max ACK received
• Send next packet
• On reception of new in-order data packet (next expected)
• Hand packet to application
• Send cumulative ACK – acknowledges reception of all packets up
to sequence number
• Increase sequence of max acceptable packet

Lecture 16: 03-16-2004 21


Loss Recovery

• On reception of out-of-order packet


• Send nothing (wait for source to timeout)
• Cumulative ACK (helps source identify loss)
• Timeout (Go-Back-N recovery)
• Set timer upon transmission of packet
• Retransmit all unacknowledged packets
• Performance during loss recovery
• No longer have an entire window in transit
• Can have much more clever loss recovery

Lecture 16: 03-16-2004 22


Go-Back-N in Action

Lecture 16: 03-16-2004 23


Selective Repeat

• Receiver individually acknowledges all correctly


received pkts
• Buffers packets, as needed, for eventual in-order delivery
to upper layer
• Sender only resends packets for which ACK not
received
• Sender timer for each unACKed packet
• Sender window
• N consecutive seq #’s
• Again limits seq #s of sent, unACKed packets

Lecture 16: 03-16-2004 24


Selective Repeat: Sender, Receiver
Windows

Lecture 16: 03-16-2004 25


Sequence Numbers

• How large do sequence numbers need to be?


• Must be able to detect wrap-around
• Depends on sender/receiver window size
• E.g.
• Max seq = 7, send win=recv win=7
• If pkts 0..6 are sent succesfully and all acks lost
• Receiver expects 7,0..5, sender retransmits old 0..6!!!
• Max sequence must be ≥ send window + recv window

Lecture 16: 03-16-2004 26


Outline

• Transport introduction

• Error recovery

• TCP flow control

Lecture 16: 03-16-2004 27


Sequence Number Space

• Each byte in byte stream is numbered.


• 32 bit value
• Wraps around
• Initial values selected at start up time
• TCP breaks up the byte stream in packets.
• Packet size is limited to the Maximum Segment Size
• Each packet has a sequence number.
• Indicates where it fits in the byte stream

13450 14950 16050 17550

packet 8 packet 9 packet 10


Lecture 16: 03-16-2004 28
Sequence Numbers

• 32 Bits, Unsigned
• Circular Comparison

a
a
b
Max 0 Max 0

• Why So Big? b<a a<b


• For sliding window, must have
|Sequence Space| > |Sending Window| + |Receiving Window|
• No problem
• Also, want to guard against stray packets
• With IP, packets have maximum lifetime of 120s
• Sequence number would wrap around in this time at 286MB/s

Lecture 16: 03-16-2004 29


TCP Flow Control

• TCP is a sliding window protocol


• For window size n, can send up to n bytes without
receiving an acknowledgement
• When the data is acknowledged then the window
slides forward
• Each packet advertises a window size
• Indicates number of bytes the receiver has space for
• Original TCP always sent entire window
• Congestion control now limits this

Lecture 16: 03-16-2004 30


Window Flow Control: Send Side

window

Sent and acked Sent but not acked Not yet sent

Next to be sent

Lecture 16: 03-16-2004 31


Window Flow Control: Send Side

Packet Sent Packet Received


Source
SourcePort
Port Dest.
Dest.Port
Port Source
SourcePort
Port Dest.
Dest.Port
Port
Sequence
SequenceNumber
Number Sequence
SequenceNumber
Number
Acknowledgment
Acknowledgment Acknowledgment
Acknowledgment
HL/Flags
HL/Flags Window
Window HL/Flags
HL/Flags Window
Window
D.
D.Checksum
Checksum Urgent
UrgentPointer
Pointer D.
D.Checksum
Checksum Urgent
UrgentPointer
Pointer
Options…
Options… Options...
Options...

App write

acknowledged sent to be sent outside window


Lecture 16: 03-16-2004 32
Window Flow Control: Receive Side

What should receiver do?

New

Receive buffer

Acked but not Not yet


delivered to user acked

window
Lecture 16: 03-16-2004 33
TCP Persist

• What happens if window is 0?


• Receiver updates window when application reads data
• What if this update is lost?
• TCP Persist state
• Sender periodically sends 1 byte packets
• Receiver responds with ACK even if it can’t store the
packet

Lecture 16: 03-16-2004 34


Performance Considerations

• The window size can be controlled by receiving


application
• Can change the socket buffer size from a default (e.g.
8Kbytes) to a maximum value (e.g. 64 Kbytes)
• The window size field in the TCP header limits the
window that the receiver can advertise
• 16 bits  64 KBytes
• 10 msec RTT  51 Mbit/second
• 100 msec RTT  5 Mbit/second
• TCP options to get around 64KB limit

Lecture 16: 03-16-2004 35


Important Lessons

• Transport service
• UDP  mostly just IP service
• TCP  congestion controlled, reliable, byte stream
• Types of ARQ protocols
• Stop-and-wait  slow, simple
• Go-back-n  can keep link utilized (except w/ losses)
• Selective repeat  efficient loss recovery
• TCP flow control
• Sliding window  mapping to packet headers
• 32bit sequence numbers (bytes)

Lecture 16: 03-16-2004 36


Next Lecture

• TCP connection setup

• TCP reliability

• Congestion control

Lecture 16: 03-16-2004 37

You might also like