Transports and TCP Transports and TCP Adolfo Rodriguez CPS 214 - - PowerPoint PPT Presentation

transports and tcp transports and tcp
SMART_READER_LITE
LIVE PREVIEW

Transports and TCP Transports and TCP Adolfo Rodriguez CPS 214 - - PowerPoint PPT Presentation

Transports and TCP Transports and TCP Adolfo Rodriguez CPS 214 Host- -to to- -Host vs. Host vs. Host Process- -to to- -Process Communication Process Communication Process Until now, we have focused on delivering packets between


slide-1
SLIDE 1

Transports and TCP Transports and TCP

Adolfo Rodriguez CPS 214

slide-2
SLIDE 2

Host Host-

  • to

to-

  • Host vs.

Host vs. Process Process-

  • to

to-

  • Process Communication

Process Communication

Until now, we have focused on delivering packets between

arbitrary hosts connected to Internet

  • Routing protocols
  • IP best effort delivery model
  • Scalability and robustness through hierarchy and soft state

Transition to arbitrary processes communicating together

  • One goal: provide illusion that all processes located on one

large computer

  • Can address (name) and reliably communicate with any

process

Ports

slide-3
SLIDE 3

UDP UDP

User Datagram Protocol (UDP)

  • Simple demultiplexing

No guarantees about reliability, in-order delivery

  • Thin veneer on top of IP adds src/dest port numbers

16 bit port number allows for identification of 65536 unique communication endpoints per host Note that a single process can utilize multiple ports IP addr + port number uniquely identifies all Internet endpoints

  • UDP Packet

Link-layer IP SrcPort DestPort Checksum Len Data… UDP Header

slide-4
SLIDE 4

A Brief Internet History A Brief Internet History

1970 1975 1980 1985 1990 1995

1969 ARPANET created 1972 TELNET

RFC 318

1973 FTP

RFC 454

1982 TCP & IP

RFC 793 & 791

1977 MAIL

RFC 733

1984 DNS

RFC 883

1986 NNTP

RFC 977

1990 ARPANET dissolved 1991 WWW/HTTP 1992 MBONE 1995 Multi-backbone Internet

slide-5
SLIDE 5

TCP Timeline TCP Timeline

1975 1980 1985 1990

1982 TCP & IP

RFC 793 & 791

1974 TCP described by Vint Cerf and Bob Kahn In IEEE Trans Comm 1983 BSD Unix 4.2 supports TCP/IP 1984 Nagel’s algorithm to reduce overhead

  • f small packets;

predicts congestion collapse 1987 Karn’s algorithm to better estimate round-trip time 1986 Congestion collapse

  • bserved

1988 Van Jacobson’s algorithms congestion avoidance and congestion control (most implemented in 4.3BSD Tahoe) 1990 4.3BSD Reno fast retransmit delayed ACK’s 1975 Three-way handshake Raymond Tomlinson In SIGCOMM 75

slide-6
SLIDE 6

TCP: After 1990 TCP: After 1990

1993 1994 1996

1994 ECN (Floyd) Explicit Congestion Notification 1993 TCP Vegas (Brakmo et al) real congestion avoidance 1994 T/TCP (Braden) Transaction TCP 1996 SACK TCP (Floyd et al) Selective Acknowledgement 1996 Hoe Improving TCP startup 1996 FACK TCP (Mathis et al) extension to SACK Interaction of real-time protocols with TCP? XCP…

1999

slide-7
SLIDE 7

TCP TCP

Transmission Control Protocol (TCP)

  • Reliable in-order delivery of byte stream
  • Full duplex (endpoints simultaneously send/receive)

e.g., single socket for web browser talking to web server

  • Flow-control

To ensure that sender does not overrun receiver Fast server talking to slow client

  • Congestion control

Keep the sender from overrunning the network Many simultaneous connections across routers (cross traffic)

slide-8
SLIDE 8

TCP TCP

Utilize sliding window protocol, plus:

  • Need for connection establishment (no dedicated cable)
  • Varying round trip times over life of connection

Different paths, different levels of congestion

  • Ready for very old packets
  • Delay-bandwidth product highly variable

Amount of available buffer space at receivers also variable

  • Sender has no idea what links will be traversed to receiver

Must dynamically estimate changing end-to-end characteristics

slide-9
SLIDE 9

TCP Flavors TCP Flavors

TCP Tahoe

  • Jacobson’s implementation of congestion control (AIMD)

TCP Reno

  • Fast recovery
  • Fast retransmit
  • Delayed ACK’s

TCP Vegas

  • Source-based congestion avoidance rather than control
  • TCP Reno needs to cause congestion to determine available

bandwidth

slide-10
SLIDE 10

TCP Header Format TCP Header Format

SrcPort DestPort SequenceNum Acknowledgment HdrLen AdvertisedWindow Flags CheckSum UrgPtr Options (variable) Data 4 10 16 31

Without options, TCP header 20 bytes

  • Thus, typical Internet packet minimum of 40 bytes
slide-11
SLIDE 11

TCP Connection Establishment TCP Connection Establishment

Exchange necessary information to begin communication Three-way handshake

  • E.g., server listening on socket

Client Server S Y N , s e q u e n c e # = x A C K , A c k n

  • w

l e d g e m e n t = y + 1 S Y N + A C K , S e q u e n c e # = y A c k n

  • w

l e d g m e n t = x + 1

slide-12
SLIDE 12

TCP Connection Teardown TCP Connection Teardown

Closing process sends a FIN message

  • Waits for ACK of FIN to come back
  • This side of the connection is now closed

Each side of a TCP connection can independently close the

connection

  • Thus, possible to have a half duplex connection
slide-13
SLIDE 13

Reliable Transmission Reliable Transmission

How do we send a packet reliably when it can be lost? Two mechanisms

  • Acknowledgements
  • Timeouts

Simplest reliable protocol: Stop and Wait

slide-14
SLIDE 14

Stop and Wait Stop and Wait

Time P a c k e t ACK Timeout Send a packet, stop and wait until acknowledgement arrives Sender Receiver

slide-15
SLIDE 15

Recovering From Error Recovering From Error

P a c k e t ACK Timeout P a c k e t ACK Timeout P a c k e t Timeout P a c k e t ACK Timeout Time P a c k e t ACK Timeout P a c k e t ACK Timeout ACK lost Packet lost Early timeout

slide-16
SLIDE 16

Problems with Stop and Wait Problems with Stop and Wait

How to recognize a duplicate transmission?

  • Solution: put sequence number in packet

Performance

  • Unless Latency-Bandwidth product is very small, sender

cannot fill the pipe

  • Solution: sliding window protocols
slide-17
SLIDE 17

Keeping the Pipe Full Keeping the Pipe Full

Bandwidth-Delay product measures network capacity How much data can you put into the network before the

first byte reaches receiver

Stop and Wait: 1 data packet per RTT

  • Ex. 1.5-Mbps link with 45-ms RTT
  • Stop-and-wait: 182 Kbps

Ideally, send enough packets to fill the pipe before

requiring first ACK

Bandwidth Latency

slide-18
SLIDE 18

How Do We Keep the Pipe Full? How Do We Keep the Pipe Full?

Send multiple packets without waiting for

first to be ACK’d

Reliable, unordered delivery:

  • Send new packet after each ACK
  • Sender keeps list of unack’d packets; resends

after timeout

Ideally, first ACK arrives immediately after

pipe is filled

  • Opens up another “slot”
slide-19
SLIDE 19

TCP Flow Control 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 in TCP header

  • Indicates number of bytes the receiver is willing to get

Original TCP always sent entire window immediately

  • Too bursty?
slide-20
SLIDE 20

Sliding Window Sliding Window

Receivers buffer later packets until prior packets arrive

  • For out of order delivery

Sender must prevent buffer overflow at receiver

  • Flow control

Solution: sliding window

  • Circular buffer at sender and receiver

Packets in transit <= buffer size Advance when sender and receiver agree packets at beginning have been received

slide-21
SLIDE 21

Visualizing the Window Visualizing the Window

4 5 6 7 8 9 1 2 3 10 11 12

  • ffered window

(advertised by receiver) usable window sent and acknowledged sent, not ACKed can send ASAP can’t send until window moves

Left side of window advances when data is acknowledged. Right side controlled by size of window advertisement.

slide-22
SLIDE 22

Visualizing the Window: Example Visualizing the Window: Example

4 5 6 7 8 9 1 2 3 10 11 12

advertised window sent and acknowledged sent, not ACKed can send ASAP can’t send until window moves

Initial State, Receiver has 6 slots to buffer packets Packets 4, 5, 6 sent, but not yet received

4 5 6 7 8 9 1 2 3 10 11 12

  • ffered window

ACK’d and read Available bufs can’t recv until window moves

Sender Receiver

slide-23
SLIDE 23

Visualizing the Window: Example Visualizing the Window: Example

4 5 6 7 8 9 1 2 3 10 11 12

advertised window sent and acknowledged sent, not ACKed can send ASAP can’t send until window moves

Receiver to Sender ACK 5, Window 4

4 5 6 7 8 9 1 2 3 10 11 12

  • ffered window

ACK’d and read Available bufs can’t recv until window moves

Sender Receiver

ACK’d, not read

slide-24
SLIDE 24

Visualizing the Window: Example Visualizing the Window: Example

4 5 6 7 8 9 1 2 3 10 11 12

advertised window sent and acknowledged sent, not ACKed can’t send until window moves

Sender to Receiver Send 7, 8, 9

4 5 6 7 8 9 1 2 3 10 11 12

  • ffered window

ACK’d and read Available bufs can’t recv until window moves

Sender Receiver

ACK’d, not read

slide-25
SLIDE 25

Visualizing the Window: Example Visualizing the Window: Example

4 5 6 7 8 9 1 2 3 10 11 12

advertised window=0 sent and acknowledged can’t send until window moves

4 5 6 7 8 9 1 2 3 10 11 12

ACK’d and read can’t recv until window moves

Sender Receiver

ACK’d, not read

  • ffered window=0

Receiver to Sender ACK 9, Window 0

slide-26
SLIDE 26

Visualizing the Window: Example Visualizing the Window: Example

4 5 6 7 8 9 1 2 3 10 11 12

advertised window=0 sent and acknowledged can’t send until window moves

4 5 6 7 8 9 1 2 3 10 11 12

ACK’d and read

Sender Receiver

ACK’d, not read

  • ffered window=3

Available bufs

Receiver App reads packets 4, 5, 6 But sender has no way of knowing that more room is available!

slide-27
SLIDE 27

Options for Sender Discovery of Increased Options for Sender Discovery of Increased Advertised Window Advertised Window

Receiver sends duplicate ACK with a larger advertised

window

  • Complicates receiver design
  • TCP design philosophy: keep receiver simple

Also explains slow deployment of SACK, NACK, etc.

Sender periodically transmits a 1-byte packet

  • If no space available at receiverpacket dropped, no ACK
  • If additional space became availableACK contains new

advertised window

NOTE: advertised window in bytes, not packets

slide-28
SLIDE 28

Sequence Numbers Sequence Numbers

TCP uses 32-bit sequence number

  • TCP assumes that packet will not live in Internet for > 1 min
  • On 622 Mbps link, can wrap 32-bit sequence number in 55

seconds

Gbps links becoming common

  • Why is this a problem?
slide-29
SLIDE 29

Sequence Numbers Sequence Numbers

TCP uses 32-bit sequence number

  • TCP assumes that packet will not live in Internet for > 1 min
  • On 622 Mbps link, can wrap 32-bit sequence number in 55

seconds

Gbps links becoming common

  • Proposal: extend sequence number with timestamp to

distinguish between old and new incarnations of packets

slide-30
SLIDE 30

Advertised Window Advertised Window

TCP uses a 16-bit advertised window field (flow control)

  • Specifies number of bytes that can be sent from sender to

receiver

  • Recall “keeping pipe full” to obtain available bandwidth
  • 16-bit field translates to max 64KB advertised window
  • For 100 ms RTT T3 link (45 Mbps), delay-bandwidth

product is 549 KB

Advertised window not large enough to keep pipe full Poor bandwidth utilization

slide-31
SLIDE 31

Advertised Window Advertised Window

TCP uses a 16-bit advertised window field (flow control)

  • Specifies number of bytes that can be sent from sender to

receiver

  • Recall “keeping pipe full” to obtain available bandwidth
  • 16-bit field translates to max 64KB advertised window
  • For 100 ms RTT T3 link (45 Mbps), delay-bandwidth

product is 549 KB

Advertised window not large enough to keep pipe full Poor bandwidth utilization

  • Proposal: advertised window specifies chunks larger than

byte granularity

slide-32
SLIDE 32

Adaptive Retransmission for Adaptive Retransmission for Reliable Delivery Reliable Delivery

TCP retransmits packet if ACK not received within

timeout period

  • Necessary for reliability on top of “best-effort” IP

Round trip time varies with congestion, route changes, …

  • If timeout too small, useless retransmits
  • If timeout too big, low utilization

TCP: estimate RTT by timing ACKs

  • Exponential weighted moving average
  • Factor in RTT variability
slide-33
SLIDE 33

Retransmission Retransmission

How long a timeout to set? Original TCP: Estimate round-trip time R

  • R = αR + (1- α)M
  • α is a smoothing factor of 0.9

Places much more weight on historical result Smooth out outlying measurements

  • M is measured round-trip time (ACK’s to data)

Timeout at Rβ, where β is a delay variance factor of 2.0

  • Conservative: do not retransmit until two RTT’s have passed

Jacobson’s TCP modifications allows for varying β

slide-34
SLIDE 34

Retransmission Ambiguity Retransmission Ambiguity

How do we distinguish first ACK from

retransmitted ACK?

  • First send to first ACK

What if ACK dropped?

  • Last send to last ACK

What if last ACK dropped?

Timeout!

Which RTT??

slide-35
SLIDE 35

Retransmission Ambiguity: Solutions Retransmission Ambiguity: Solutions

TCP: Karn-Partridge

  • Ignore RTT estimates for retransmitted packets
  • Double timeout on every retransmission

Exponential backoff similar to Ethernet for congestion avoidance

Add sequence #’s to retransmissions (retry #1, retry #2) TCP proposal: Add timestamp into packet header; ACK

returns timestamp

slide-36
SLIDE 36

Jacobson Jacobson’ ’s RTT estimator s RTT estimator

Problem:

  • Originial TCP does not adapt to wide variance in RTT
  • Uses fixed β of 2.0

Need to account for both estimate RTT and variance Jacobson:

  • Low varianceestimate RTT sufficient
  • High variance estimate RTT could be far off

Solution:

  • Timeout = μ*EstimateRTT + φ*Deviation
  • μ=1, φ=4
slide-37
SLIDE 37

Can We Shortcut Timeout? Can We Shortcut Timeout?

If packets usually arrive in order, out of order signals a drop

  • Negative ACK (NACK)

Receiver requests missing packet

  • Selective ACK (SACK)

Receiver describes state of receive window

  • Fast retransmit

Sender detects missing ACK from multiple duplicate ACKs Recall: receiver ACKs highest sequence # received in order Triple duplicate ACKs for fast retransmission (shortcut timeout)

How is retransmission timer related to congestion control?

slide-38
SLIDE 38

Transport Protocol Summary Transport Protocol Summary

TCP designed to connect arbitrary hosts on the Internet

  • Difficult to determine link characteristics
  • Difficult to determine receiving host characteristics
  • Both host/network characteristics change over time

Network becomes more congestedlarger RTT Receiving becomes overloadedsmaller advertised window

TCP provides

  • Reliable, in-order delivery of byte stream
  • Flow control
  • Congestion control
slide-39
SLIDE 39

Silly Window Syndrome Silly Window Syndrome

Problem: (Clark, 1982)

  • If receiver advertises small increases in the receive window

then the sender may waste time sending lots of small packets

e.g., application reads small number of bytes, freeing up small amount of kernel buffer space

Solution:

  • Receiver must not advertise small window increases
slide-40
SLIDE 40

Nagel Nagel’ ’s algorithm (self s algorithm (self-

  • clocking)

clocking)

Small packet problem:

  • Don’t want to send a 41 byte packet for each keystroke

IP 20 bytes, TCP 20 bytes, keystroke 1 byte

  • How long should OS/app buffer keystrokes?

Solution:

  • Only one outstanding small segment not yet ACK’d

e.g., telnet cannot echo last character until ACK’d anyway

Can turn of with TCP_NODELAY option

  • What’s the story with these options anyway?