TCP. UDP Header Format. User Datagram Protocol (UDP) Transmission Control Protocol (TCP)

Similar documents
Transport Layer Protocols

Outline. TCP connection setup/data transfer Computer Networking. TCP Reliability. Congestion sources and collapse. Congestion control basics

B-2 Analyzing TCP/IP Networks with Wireshark. Ray Tompkins Founder of Gearbit

Computer Networks. Chapter 5 Transport Protocols

Lecture 15: Congestion Control. CSE 123: Computer Networks Stefan Savage

TCP over Multi-hop Wireless Networks * Overview of Transmission Control Protocol / Internet Protocol (TCP/IP) Internet Protocol (IP)

Chapter 6 Congestion Control and Resource Allocation

Computer Networks UDP and TCP

TCP in Wireless Mobile Networks

ICOM : Computer Networks Chapter 6: The Transport Layer. By Dr Yi Qian Department of Electronic and Computer Engineering Fall 2006 UPRM

Transport Layer and Data Center TCP

Final for ECE374 05/06/13 Solution!!

TCP/IP Optimization for Wide Area Storage Networks. Dr. Joseph L White Juniper Networks

COMP 3331/9331: Computer Networks and Applications. Lab Exercise 3: TCP and UDP (Solutions)

This sequence diagram was generated with EventStudio System Designer (

TCP Flow Control. TCP Receiver Window. Sliding Window. Computer Networks. Lecture 30: Flow Control, Reliable Delivery

Chapter 5. Transport layer protocols

q Connection establishment (if connection-oriented) q Data transfer q Connection release (if conn-oriented) q Addressing the transport user

Lecture Objectives. Lecture 07 Mobile Networks: TCP in Wireless Networks. Agenda. TCP Flow Control. Flow Control Can Limit Throughput (1)

Ethernet. Ethernet. Network Devices

Data Networks Summer 2007 Homework #3

A Survey on Congestion Control Mechanisms for Performance Improvement of TCP

First Midterm for ECE374 03/09/12 Solution!!

Names & Addresses. Names & Addresses. Hop-by-Hop Packet Forwarding. Longest-Prefix-Match Forwarding. Longest-Prefix-Match Forwarding

TCP over Wireless Networks

2 TCP-like Design. Answer

[Prof. Rupesh G Vaishnav] Page 1

La couche transport dans l'internet (la suite TCP/IP)

Prefix AggregaNon. Company X and Company Y connect to the same ISP, and they are assigned the prefixes:

Computer Networks - CS132/EECS148 - Spring

Networking Overview. (as usual, thanks to Dave Wagner and Vern Paxson)

Higher Layer Protocols: UDP, TCP, ATM, MPLS

TCP/IP Networking for Wireless Systems. Integrated Communication Systems Group Ilmenau University of Technology

TCP Performance Management for Dummies

IP - The Internet Protocol

Networking part 3: the transport layer

Simulation-Based Comparisons of Solutions for TCP Packet Reordering in Wireless Network

Transport Layer. Chapter 3.4. Think about

Access Control: Firewalls (1)

IP address format: Dotted decimal notation:

CSE 473 Introduction to Computer Networks. Exam 2 Solutions. Your name: 10/31/2013

Improving the Performance of TCP Using Window Adjustment Procedure and Bandwidth Estimation

15-441: Computer Networks Homework 2 Solution

Visualizations and Correlations in Troubleshooting

Mobile Communications Chapter 9: Mobile Transport Layer

Transport layer protocols for ad hoc networks

Midterm Exam CMPSCI 453: Computer Networks Fall 2011 Prof. Jim Kurose

Congestions and Control Mechanisms n Wired and Wireless Networks

TCP and Wireless Networks Classical Approaches Optimizations TCP for 2.5G/3G Systems. Lehrstuhl für Informatik 4 Kommunikation und verteilte Systeme

Network Layer: Network Layer and IP Protocol

First Midterm for ECE374 03/24/11 Solution!!

Network Layer IPv4. Dr. Sanjay P. Ahuja, Ph.D. Fidelity National Financial Distinguished Professor of CIS. School of Computing, UNF

TCP Adaptation for MPI on Long-and-Fat Networks

TCP for Wireless Networks

IP Network Layer. Datagram ID FLAG Fragment Offset. IP Datagrams. IP Addresses. IP Addresses. CSCE 515: Computer Network Programming TCP/IP

La couche transport dans l'internet (la suite TCP/IP)

Effect of Packet-Size over Network Performance

High Speed Internet Access Using Satellite-Based DVB Networks

SELECTIVE-TCP FOR WIRED/WIRELESS NETWORKS

A Survey: High Speed TCP Variants in Wireless Networks

Homework 3 assignment for ECE374 Posted: 03/13/15 Due: 03/27/15

Chapter 3. TCP/IP Networks. 3.1 Internet Protocol version 4 (IPv4)

Computer Networks Practicum 2015

Congestion Control Review Computer Networking. Resource Management Approaches. Traffic and Resource Management. What is congestion control?

Application Level Congestion Control Enhancements in High BDP Networks. Anupama Sundaresan

How do I get to

Multipath TCP in Practice (Work in Progress) Mark Handley Damon Wischik Costin Raiciu Alan Ford

Internet Architecture and Philosophy

Overview. Securing TCP/IP. Introduction to TCP/IP (cont d) Introduction to TCP/IP

TCP Westwood for Wireless

High-Speed TCP Performance Characterization under Various Operating Systems

1. The subnet must prevent additional packets from entering the congested region until those already present can be processed.

TCP/IP Inside the Data Center and Beyond. Dr. Joseph L White, Juniper Networks

CS268 Exam Solutions. 1) End-to-End (20 pts)

Transport layer issues in ad hoc wireless networks Dmitrij Lagutin,

Networks: IP and TCP. Internet Protocol

Lecture 15. IP address space managed by Internet Assigned Numbers Authority (IANA)

TCP/IP and the Internet

Protocols and Architecture. Protocol Architecture.

Optimization of Communication Systems Lecture 6: Internet TCP Congestion Control

CS 457 Lecture 19 Global Internet - BGP. Fall 2011

Parallel TCP Data Transfers: A Practical Model and its Application

Recent advances in transport protocols

Lecture Computer Networks

TCP/IP Over Lossy Links - TCP SACK without Congestion Control

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

Network Intrusion Detection Systems. Beyond packet filtering

Indian Institute of Technology Kharagpur. TCP/IP Part I. Prof Indranil Sengupta Computer Science and Engineering Indian Institute of Technology

Improved Digital Media Delivery with Telestream HyperLaunch

CSE331: Introduction to Networks and Security. Lecture 9 Fall 2006

Low-rate TCP-targeted Denial of Service Attack Defense

ECSE-6600: Internet Protocols Exam 2

Protocols. Packets. What's in an IP packet

(Refer Slide Time: 02:17)

Question: 3 When using Application Intelligence, Server Time may be defined as.

04 Internet Protocol (IP)

FEW would argue that one of TCP s strengths lies in its

Applications. Network Application Performance Analysis. Laboratory. Objective. Overview

Networking Test 4 Study Guide

THE Internet provides a convenient and cost-effective

Transcription:

User Datagram Protocol (UDP) Thin wrapper around IP services Service Model Unreliable unordered datagram service Addresses multiplexing of multiple connections Multiplexing 16-bit port numbers (some are well-known ) Checksum Validate header Optional in IPv4 Mandatory in IPv6 UDP Header Format 0 8 16 31 Source Port Destination Port UDP Length Length includes 8-byte header and data Checksum Uses IP checksum algorithm Computed on header, data and pseudo header : UDP Checksum 0 8 16 31 Source IP Address 0 17 (UDP) Destination IP Address UDP Length Transmission Control Protocol (TCP) TCP Guaranteed delivery: Messages delivered in the order they were sent Messages delivered at most once No limit on message size Synchronization between sender and receiver Multiple connections per host Flow control 3 4

TCP TCP vs. Direct Link Connection oriented Explicit setup and teardown required Byte stream abstraction No boundaries in data App writes bytes, TCP send segments, App receives bytes Full duplex Data flows in both directions simultaneously Point-to-point connection Implements congestion control Flow control: receiver controls sender rate Congestion control: network indirectly controls sender rate Explicit connection setup requires RTT varies, depending on destination and network condition adaptive approach to retransmission Packets Delayed Reordered Late 5 6 Peer capabilities vary TCP vs. Direct Link Minimum link speed on route Buffering capacity at destination adaptive approach to window sizes Network capacity varies Other traffic competes for most links Requires global congestion control strategy TCP: Connection Stages 1. Connection setup 3-way handshake 2. Data transport: Sender writes data, and TCP Breaks data into segments Sends segment in IP packets Retransmits, reorders and removes duplicates as necessary Delivers data to receiver 3. Teardown 4 step exchange 7 8

TCP Segment Header Format TCP Segment Header 0 8 16 31 Source Port Destination Port Sequence Number Sequence Number Header Length 0 Flags Advertised Window TCP Checksum Urgent Pointer Options Meta header 0 8 16 31 Source IP Address Destination IP Address 0 16 (TCP) TCP Segment Length 16-bit source and destination ports 32-bit send and sequence numbers 4-bit header length (unit = 32 bits) Minimum 5 (20 bytes) Used as offset to first data byte 6 1-bit flags URG: *Segment contains urgent data : sequence number is valid PSH: *Do not delay delivery of data RST: Reset connection (reject or abn. termination) SYN: Synchronize segment for setup FIN: Final segment for teardown 9 10 TCP Segment Header (cont.) 16-bit advertised window Space remaining in receive window 16-bit checksum Uses IP checksum algorithm Computed on header, data and pseudo header 16-bit urgent data pointer If URG = 1 Index of last byte of urgent data in segment TCP Options Negotiate maximum segment size (MSS) Each host suggests a value Minimum of two values is chosen Prevents IP fragmentation over first and last hops Packet timestamp Allows RTT calculation for retransmitted packets Extends sequence number space for identification of stray packets Negotiate advertised window scaling factor Allows larger windows: 64KB too small for routes with large bandwidth-delay products 11 12

TCP: Data Transport Data broken into segments Limited by maximum segment size (MSS) Negotiable during connection setup Typically set to MTU of directly connected network size of TCP and IP headers Three events cause a segment to be sent At least MSS bytes of data ready to be sent Explicit PUSH operation by application Periodic timeout Write bytes Application process TCP Send buffer TCP Byte Stream Read bytes TCP Segment TCP Segment TCP Segment Application process TCP Recv buffer 13 14 TCP SNs and s TCP rules Seq. # s: Count bytes, not packets. First SN to avoid insertion s: SN of next byte expected from other side cumulative GBN: TCP spec doesn t say what to do with premature packets - up to implementation User types C host s receipt of echoed C Host A Host B simple telnet scenario host s receipt of C, echoes back C time 15 Event in-order segment arrival, no gaps, everything else already ed in-order segment arrival, no gaps, one delayed pending out-of-order segment arrival higher-than-expect seq. # gap detected arrival of segment that partially or completely fills gap TCP Receiver action delayed. Wait up to 500ms for next segment. If no next segment, send immediately send single cumulative send duplicate, indicating seq. # of next expected byte immediate if segment starts at lower end of gap 16

TCP: retransmission scenarios TCP: Retransmission and Timeouts Host A Host B Host A Host B Round-trip time (RTT) Retransmission TimeOut (RTO) timeout X loss Seq=100 timeout Seq=92 timeout Host A Host B Data1 Data2 Guard Band Estimated RTT time lost scenario premature timeout, cumulative s 17 TCP uses an adaptive retransmission timeout value Dynamic network (congestion, changes in routing) => RTT cannot be static 18 TCP: Retransmission and Timeouts TCP: Retransmission and Timeouts (Jacobson/Karels alg.) RTO value is important: too big: wait too long to retransmit a packet too small: unnecessarily retransmit packets. Original algorithm for picking RTO: 1. EstimatedRTT = α EstimatedRTT + (1 - α) SampleRTT 2. RTO = 2 EstimatedRTT Characteristics of the original algorithm: Std. dev. implicitly assumed to be bounded by RTT. But if utilization = 75%, could have factor 16 between typical (mean±2stdev) short and long RTTs Newer algorithm estimates std. dev. of RTT: 1. Diff = SampleRTT - EstimatedRTT 2. EstimatedRTT = EstimatedRTT + δ Diff (for some 0<δ<1) 3. Deviation = Deviation + δ ( Diff - Deviation ) 4. RTO = μ EstimatedRTT+ φ Deviation μ 1 φ 4 19 20

TCP: Retransmission and Timeouts (Karn s Alg.) TCP Sliding Window Protocol Sender Side Host A Host B Host A Host B LastByteAcked <= LastByteSent LastByteSent <= LastByteWritten Buffer bytes between LastByteAcked and LastByteWritten Retransmission Retransmission Maximum buffer size Wrong RTT Sample Wrong RTT Sample Advertised window Problem: How to estimate RTT of retransmitted packets? Solution: Don t! Also: double RTO. First unacknowledged byte Data available, but outside window Last byte sent 21 22 TCP Sliding Window Protocol Receiver Side LastByteRead < NextByteExpected NextByteExpected <= LastByteRcvd + 1 Buffer bytes between NextByteRead and LastByteRcvd Shrinks as data arrives and Grows as the application consumes data Maximum buffer size Next byte to be read by application Advertised window Buffered, out-of-order data Next byte expected ( value) TCP Flow Control Receiving side Receive buffer size = MaxRcvBuffer LastByteRcvd - LastByteRead < = MaxRcvBuffer AdvertisedWindow = MaxRcvBuffer -(NextByteExpected - NextByteRead) Shrinks as data arrives and Grows as the application consumes data Sending side Send buffer size = MaxSendBuffer LastByteSent - LastByteAcked < = AdvertisedWindow EffectiveWindow = AdvertisedWindow -(LastByteSent - LastByteAcked) EffectiveWindow > 0 to send data LastByteWritten - LastByteAcked < = MaxSendBuffer block sender if (LastByteWritten - LastByteAcked) + y > MaxSenderBuffer 23 24

TCP Flow Control TCP Flow Control Problem: Slow receiver application Advertised window goes to 0 Sender cannot send more data Receiver may not spontaneously generate update or update may be lost Sender gets stuck Solution Sender periodically sends 1-byte segment, ignoring advertised window of 0 Eventually window opens Sender learns of opening from next of 1-byte segment Problem: Application delivers tiny pieces of data to TCP Example: telnet in character mode Each piece sent as a segment, returned as Very inefficient Solution Delay transmission to accumulate more data Nagle s algorithm Send first piece of data Accumulate data until first piece ed Send accumulated data and restart accumulation Not ideal for some traffic (e.g. mouse motion) 25 26 TCP Flow Control Problem: Slow application reads data in tiny pieces Receiver advertises tiny window Sender fills tiny window Known as silly window syndrome Solution Advertise window opening only when MSS or ½ of buffer is available Sender delays sending until window is MSS or ½ of receiver s buffer (estimated) TCP Bit Allocation Limitations Sequence numbers vs. packet lifetime Assumed that IP packets live less than 60 seconds Can we send 2 32 bytes in 60 seconds? approx. 573Mbps: Less than an STS-12 line Advertised window vs. delay-bandwidth Only 16 bits for advertised window coast-coast RTT = 100 ms Adequate for only 5.24 Mbps! 27 28

TCP Sequence Numbers 32-bit TCP Connection Establishment Bandwidth Speed Time until wrap around T1 1.5 Mbps 6.4 hours Ethernet 10 Mbps 57 minutes T3 45 Mbps 13 minutes FDDI 100 Mbps 6 minutes STS-3 155 Mbps 4 minutes STS-12 622 Mbps 55 seconds STS-24 1.2 Gbps 28 seconds 29 3-Way Handshake Exchange initial sequence numbers (j,k) Message Types Synchronize (SYN) Acknowledge (): cumulative! Passive Open Server listens for connection from client Active Open Client initiates connection to server Client Server listen Time flows down 30 TCP: Connection Termination TCP State Descriptions Message Types Finished (FIN) Acknowledge () Active Close Client Server CLOSED LISTEN SYN_RCVD SYN_SENT Disconnected Waiting for incoming connection Connection request received Connection request sent Sends no more data Passive close Accepts no more data Connection can be half closed (one-way) Time flows down ESTABLISHED CLOSE_WAIT LAST_ FIN_WAIT_1 FIN_WAIT_2 CLOSING TIME_WAIT Connection ready for data transport Connection closed by peer Connection closed by peer, closed locally, await Connection closed locally Connection closed locally and d Connection closed by both sides simultaneously Wait for network to discard related packets 31

TCP State Transition Diagram TCP State Transition Diagram SYN_RCVD FIN_WAIT_1 FIN_WAIT_2 Passive open SYN/SYN + FIN/ FIN/ FIN + / CLOSED Close LISTEN SYN/SYN + ESTABLISHED CLOSING TIME_WAIT Send/SYN Timeout Close SYN_SENT SYN + / FIN/ CLOSE_WAIT LAST_ CLOSED Active open/syn Questions State transitions Describe the path taken by a server under normal conditions Describe the path taken by a client under normal conditions Describe the path taken assuming the client closes the connection first TIME_WAIT state What purpose does this state serve Prove that at least one side of a connection enters this state Explain how both sides might enter this state 33 34 TCP State Transition Diagram TCP State Transition Diagram SYN_RCVD FIN_WAIT_1 FIN_WAIT_2 Passive open SYN/SYN + FIN/ FIN/ FIN + / CLOSED Close LISTEN SYN/SYN + ESTABLISHED CLOSING TIME_WAIT Send/SYN Timeout Close SYN_SENT SYN + / FIN/ CLOSE_WAIT LAST_ CLOSED Active open/syn CLOSED Passive open Close SYN/SYN + LISTEN SYN_RCVD SYN/SYN + ESTABLISHED FIN_WAIT_1 FIN/ CLOSING FIN_WAIT_2 FIN + / FIN/ TIME_WAIT Send/SYN Close SYN_SENT SYN + / Active open/syn FIN/ CLOSE_WAIT LAST_ Timeout CLOSED 35 36

Congestion Congestion Control & Avoidance Cumulative bytes H 1 H 2 A 1 (t)+a 2 (t) A 1 (t) 10Mb/s A 2 (t) 100Mb/s X(t) A 2 (t) A 1 (t) R1 D(t) 1.5Mb/s H 3 A 1 (t) A 2 (t) X(t) D(t) D(t) 37 t 38 TCP Congestion Control Ideal steady state: self-clocking Basic idea: control rate by window size. Average rate (window)/rtt Crude Add notion of congestion window Effective window is minimum of Advertised window (flow control), and Congestion window (congestion control) 39 40

TCP Congestion Control Slow Start Start up phase: quickly find the correct rate Slow Start Steady state: gently try to increase rate, back off quickly when congestion detected Congestion Avoidance Objective: determine available capacity Idea: Begin with cwnd = 1 packet Increment cwnd by 1 packet for each Source Destination Phases are determined by the value of variable ssthres Meaning: double every RTT! 41 42 Slow Start Implementation When starting or restarting after timeout, cwnd=1. On each ack for new segment, cwnd += segsize. Slow Start Trace Each dot is a 512B packet sent, y-axis is sequence number, x-axis is time, straight line is 20 KBps of available bandwidth. without ss: ~7KBps, with ss: ~19KBps 43 44

Congestion is good? Empty buffers => low delay, low utilization Full buffers => good utilizaion, but high delay, potential loss Real question: how much congestion is too much? Host Solutions Q: How does the source determine whether or not the network is congested? A: Timeout signals packet loss Packet loss is rarely due to transmission error (on wired networks) Lost packet implies congestion! 45 46 Congestion Avoidance Control vs. avoidance Control: minimize impact of congestion when it occurs Avoidance: avoid producing congestion In terms of operating point limits avoidance power optimal load control idealized power curve load How to get to steady-state? If overusing link => packet loss => decrease rate Why increase at all? Must check all the time so in order not to leave dead bandwidth; only indication is dropped packets Slow-start: multiplicative increase Timeout: decrease to 1! Symmetric multiplicative increase and decrease: strong oscillation, poor throughput. Rush-hour effect. 47 48

Rush Hour Effect Additive Increase/ Multiplicative Decrease Easy to drive the network into saturation, but difficult for the network to recover. Analogy to rush hour traffic rate Arrivals & departures Queue size Algorithm Increment cwnd by one packet per RTT Linear increase Divide CongestionWindow by two whenever a timeout occurs Multiplicative decrease Source Destination 50 AIMD: additive increase, multiplicative decrease Why AIMD? increase window by 1 per RTT decrease window by factor of 2 on loss event Fairness goal: if N TCP sessions share same bottleneck link, each should get 1/N of link capacity TCP connection 1 TCP connection 2 bottleneck router capacity R Model: Two sessions compete for R bandwidth underutilized & unfair to 1 desired region R overutilized & unfair to 1 underutilized & unfair to 2 Conn 1 throughput full utilization line R overutilized & unfair to 2 51 52

Model assumptions AIMD Convergence Sessions know if link is overused (losses) Sessions don t know relative rates Simplification: Sessions respond simultaneously, and in the same direction (both increase or both decrease) R Conn 1 throughput full utilization line R Additive Increase up at 45º angle (both connections add 1) Multiplicative Decrease down R toward the origin X pt. of convergence full utilization line Conn 1 throughput R 53 54 TCP Congestion Avoidance Convergence Avoidance Typical Trace When a new segment is acked, the sender does the following: If (cwnd < ssthresh) cwnd += segsize else cwnd += segsize/cwnd (What happens when an arrives for x new segments?) On timeout: ssthresh := cwnd/2 cwnd := 1 (i.e., slow start) Trace: sawtooth behavior KB 70 60 50 40 30 20 10 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 Time (seconds) 10.0 55 56

Fast Retransmit and Fast Recovery TCP Congestion Control: summary Problem: crude TCP timeouts lead to idle periods, slow start is not fast Fast retransmit: use duplicate s to trigger retransmission Fast recovery: skip slow start, go directly to half the last successful cwnd (called ssthresh) Packet 1 Packet 2 Packet 3 Packet 4 Packet 5 Packet 6 TIMEOUT! Retransmit packet 3 Sender Receiver 1 2 2 2 2 6 Maintain threshold window size ( last good estimate ) Threshold value Initially set to maximum window size Set to 1/2 of current window on timeout or 3 dup s Congestion window drops to 1 on timeout, drops by half on 3 dup s When congestion window smaller than threshold: Double window for each window d (multiplicative increase) When congestion window larger than threshold: Increase window by one MSS for each window d Try to avoid timeouts by fast retransmit 57 58 TCP Congestion Window Trace TCP Dynamics: Rate Congestion Window 70 60 50 40 30 20 10 0 timeouts fast retransmission slow start period additive increase threshold congestion window 0 10 20 30 40 50 60 Time TCP Reno Sending rate: Congwin*MSS / RTT Assume fixed RTT Actual Sending rate: between W*MSS / RTT and (1/2) W*MSS / RTT Average (3/4) W*MSS / RTT W W/2 59 60

TCP Dynamics: Loss Congestion Avoidance Loss rate (TCP Reno) Consider a cycle Total packet sent: about (3/8) W 2 MSS/RTT = O(W 2 ) One packet loss Loss Probability: p=o(1/w 2 ) or W=O(1/ p) W W/2 TCP s strategy: increase load until congestion occurs, then back off Alternative Strategy Predict when congestion is about to happen and reduce rate just before packets start being discarded Two possibilities Some help from network: DECbit, RED Host-centric TCP Vegas 61 62