TCP Implementation. TCP Implementation. A byte-stream oriented protocol. TCP transfer protocol

Similar documents
Transport Layer Protocols

TCP for Wireless Networks

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

Mobile Communications Chapter 9: Mobile Transport Layer

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

Computer Networks. Chapter 5 Transport Protocols

TCP in Wireless Mobile Networks

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

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

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

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

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

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

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

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

TCP in Wireless Networks

Ethernet. Ethernet. Network Devices

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

TCP over Wireless Networks

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

[Prof. Rupesh G Vaishnav] Page 1

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

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

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

Chapter 6 Congestion Control and Resource Allocation

Mobile Computing/ Mobile Networks

Higher Layer Protocols: UDP, TCP, ATM, MPLS

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

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

Computer Networks UDP and TCP

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

Chapter 5. Transport layer protocols

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

Transport layer issues in ad hoc wireless networks Dmitrij Lagutin,

Congestions and Control Mechanisms n Wired and Wireless Networks

This sequence diagram was generated with EventStudio System Designer (

A Survey on Congestion Control Mechanisms for Performance Improvement of TCP

Final for ECE374 05/06/13 Solution!!

IP - The Internet Protocol

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

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

Access Control: Firewalls (1)

Stop And Wait. ACK received; transmit frame 2 CS 455 3

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

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

Transport Layer. Chapter 3.4. Think about

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

CSMA/CA. Information Networks p. 1

We will give some overview of firewalls. Figure 1 explains the position of a firewall. Figure 1: A Firewall

AN IMPROVED SNOOP FOR TCP RENO AND TCP SACK IN WIRED-CUM- WIRELESS NETWORKS

IP address format: Dotted decimal notation:

TCP/IP Support Enhancements

TCP Performance Management for Dummies

Visualizations and Correlations in Troubleshooting

Computer Networks - CS132/EECS148 - Spring

An enhanced TCP mechanism Fast-TCP in IP networks with wireless links

A Transport Protocol for Multimedia Wireless Sensor Networks

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

D. SamKnows Methodology 20 Each deployed Whitebox performs the following tests: Primary measure(s)

Effect of Packet-Size over Network Performance

15-441: Computer Networks Homework 2 Solution

17: Queue Management. Queuing. Mark Handley

Transport layer protocols for ad hoc networks

Low-rate TCP-targeted Denial of Service Attack Defense

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

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

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

Digital Audio and Video Data

Computer Networks Practicum 2015

How do I get to

High Performance VPN Solutions Over Satellite Networks

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

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

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

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

Network Security I: Overview

TCP Adaptation for MPI on Long-and-Fat Networks

Final exam review, Fall 2005 FSU (CIS-5357) Network Security

Protocols. Packets. What's in an IP packet

Networking part 3: the transport layer

Per-Flow Queuing Allot's Approach to Bandwidth Management

Recent advances in transport protocols

Architecture and Performance of the Internet

TCP Westwood for Wireless

Based on Computer Networking, 4 th Edition by Kurose and Ross

CSE 123: Computer Networks

(Refer Slide Time: 02:17)

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

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

Voice over IP. Demonstration 1: VoIP Protocols. Network Environment

Improving Effective WAN Throughput for Large Data Flows By Peter Sevcik and Rebecca Wetzel November 2008

A Survey: High Speed TCP Variants in Wireless Networks

Web Servers Should Turn Off Nagle to Avoid Unnecessary 200 ms Delays +

TCP Offload Engines. As network interconnect speeds advance to Gigabit. Introduction to

Transport Layer and Data Center TCP

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

The present and the future of TCP/IP

A Resilient Transport Layer for Messaging Systems

SELECTIVE-TCP FOR WIRED/WIRELESS NETWORKS

Data Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine

Transcription:

TCP Implementation TCP Implementation A quick review of TCP TCP implementation options Some other implementation considerations Optimizing TCP s performance TCP over wireless networks TCP Implementation 1 TCP Implementation 2 A byte-stream oriented protocol TCP is designed to treat data as a generic stream of bytes. Pays no attention to message boundaries, etc. Bytes are sequence-numbered by the sender (32-bit seq number) TCP transfer protocol Extended form of sliding window algorithm Review of SWA: All segs have sequence number Multiple segs can be in flight Sender starts timer when transmitting each seg Receiver sends ACK for seg when all previous segs have been received If send timer times out before seg is ACKEd, sender re-sends the seg TCP Implementation 3 TCP Implementation 4 1

Header Length Header Source port # Dest port # Checksum 4 Bytes Sequence # Flags (6) ACK # Options Window Size Urgent Pointer TCP header flags URG Indicates seg contains urgent data ACK Indicates this is an ACK seg PSH Push. Requests receiver to deliver data to app without buffering RST Reset. NACK. SYN Connect request / connect accepted FIN Connection release TCP Implementation 5 TCP Implementation 6 Urgent data A way to embed signaling in the data stream (e.g, to kill the process on the remote machine) Process: Sending app gives signal to TCP with Urgent flag set Sending TCP sets Urgent Pointer (points to end of urgent data) in seg header and immediately transmits buffer Receiving TCP can interrupt app to transfer urgent data TCP flow control Implemented by Window Size field in header Window size set by receiver to indicate how many bytes (not segs) can be sent before next ACK Returned in ACK seg TCP Implementation 7 TCP Implementation 8 2

Segment size Seg = 20 header bytes +? Option header bytes +0-~64KB data Max seg size = 64K-20 (max IP payload) Actual seg size determined by sending TCP: Local MTU Local sending rules Truncated seg for Urgent Data Well-known ports If a remote node wants to obtain a particular service from a server, how does it know which port # to make the request on? Well-known ports (ports 1-1023) are reserved for standard services: E.g, 21=TCP, 80=HTTP, 110=POP3 For the entire list, see http://www.iana.org/assignments/port-numbers TCP Implementation 9 TCP Implementation 10 TCP Implementation A quick review of TCP TCP implementation options Some other implementation considerations Optimizing TCP s performance TCP over wireless networks TCP Implementation Options The TCP spec lays out the details of the protocol However, some policy options are left to the implementer Two implementations that use different options will interoperate, but performance may suffer TCP Implementation 11 TCP Implementation 12 3

TCP Imp Options: Send Policy The sending TCP accepts bytes from the app and buffers them It is free to send them whenever it chooses (except for pushed data, urgent data, or a closed send window) TCP Imp Options: Deliver Policy Receiving TCP will receive segments and buffer them, handling errors and in-order considerations. It is free to deliver the data to the app wherever it chooses (except for urgent data or pushed data) TCP Implementation 13 TCP Implementation 14 TCP Imp Options: Accept Policy When segs arrive out of order, the receiving TCP can: 1. Discard any segs that arrive out of order 2. Accept any seg that has a sequence number within the receive window Note: Policy 1 is easier to implement and needs less complex buffering, but Policy 2 is better for performance TCP Imp Options: Retransmit Policy Governs how the sender will handle a retransmission First-Only Policy Batch Policy Individual Policy TCP Implementation 15 TCP Implementation 16 4

Retransmit Policy options: First-Only Policy Keep a send-order queue of unacked segs. Keep a single timeout timer When an ACK arrives, remove the ACKed seg(s) from the queue and reset the timer When the timer times out, re-send the seg at the head of the queue Simple and low-traffic, but can be slow (the timer for the second seg in the queue doesn t start until the first one times out) Retransmit Policy Options: Batch Policy Same as First-Only except: When the timer times out, re-send the entire queue Basically a go-back-n approach. Simple, but may cause needless additional traffic TCP Implementation 17 TCP Implementation 18 Retransmit Policy Options: Individual Policy Keep a timeout timer for each seg in the queue If any timer expires re-transmit just that seg Complex implementation. Very traffic efficient. Retransmit Policy Options Ideally, the retransmit policy would be selected to be compatible with the receiver s accept policy (e.g., if receiver uses in-order, the best match is a batch retransmit policy). But you can t count on that in real networks TCP Implementation 19 TCP Implementation 20 5

TCP Imp Options: ACK Policy The receiving TCP must ACK segs that are received in order. It can do so: Immediately Immediately send an empty ACK segment for the received data seg Cumulative Hold the ACK until it can be piggybacked on outgoing data (recall that ACK applies to the seg received and all before it). Keep a timer to prevent too long a delay. Most installations use Cumulative because it yields lower traffic loads, but this is a good bit more complex to implement and manage. TCP Implementation A quick review of TCP TCP implementation options Some other implementation considerations Optimizing TCP s performance TCP over wireless networks TCP Implementation 21 TCP Implementation 22 Setting the segment size Max = 64KB Min/default = 556B Often restricted to 1460 data bytes: 1460 data bytes + 20 TCP header + 20 IP header 1500 bytes (One Ethernet payload) Actual Max seg size is negotiated by sender and receiver during setup A problem with the window size field Window size field is 16 bits => 64KB max window Not enough for many purposes: Example (Tanenbaum): On a T3 line (44.7 Mbps), it takes 12 msec to send a 64KB window. If RTT is 50 msec, sender is idle 75% of the time waiting for ACKs TCP Implementation 23 TCP Implementation 24 6

A window size patch Window scale is set during negotiation* Sets scale factor used in interpreting the Window Size field: Act_Win_Size = Win_Size_Field x 2 Win_Scale Allows window sizes up to ~2 30 B A potential TCP deadlock When the receiver wants the sender to stop sending temporarily, it will advertise a window size of 0. The sender will stop. Later, when the receiver can accept data again, it will advertise a larger window size. The sender will re-start. A deadlock occurs if the second advertisement is lost. TCP * RFC Implementation 1323 25 TCP Implementation 26 Deadlock avoidance When a sender receives a Window Size =0, it starts a persistence timer When the persistence timer times out, the sender sends a query to the receiver, and the receiver sends the current advertised window size If the size still = 0, the sender re-starts the persistence timer TCP Implementation A quick review of TCP TCP implementation options Some other implementation considerations Optimizing TCP s performance TCP over wireless networks TCP Implementation 27 TCP Implementation 28 7

Optimizing performance Deciding when to send a segment The Silly Window Syndrome Managing the Congestion Window Managing the timeout timer Deciding when to send a segment Within the negotiated seg size limits, the sending TCP has to decide when to stop buffering data bytes and send them When bytes come in slowly from the app (e.g., a user typing), how does the sending TCP decide when to send the buffered bytes? If you send each one separately, you are using 40 overhead bytes (20 send header and 20 ACK header) to send 1 data byte If you wait to build a large seg, the first bytes typed may be impossibly late TCP Implementation 29 TCP Implementation 30 One way of helping the problem delayed ACK The receiver can delay ACKing a small seg (typ: 0.5 sec) in the hope of receiving another one that can be ACKed in the same ACK seg Fairly common approach, but not practical when fast response needed, and sender is still inefficient Another way: Nagle s Algorithm When data comes in a byte at a time from the app, Send the first byte immediately Buffer succeeding bytes until the first byte is ACKed, then send them in one seg This is a good strategy when RTT is variable: When network is lightly loaded, the impact of small segs is less. Since ACKs return quickly, more small segs are sent When the network is congested, ACKs return slowly and more data is packed in each seg. Note: Nagle s performance may not be good enough for highly interactive applications sometimes it is disabled TCP Implementation 31 TCP Implementation 32 8

Optimizing performance Deciding when to send a segment The Silly Window Syndrome Managing the Congestion Window Managing the timeout timer A related problem: Silly Window Syndrome Occurs when data is sent in large blocks, but receiving app reads a byte at a time: Sending TCP sends until rcv buffer full Receiving TCP advertises window size = 0 Receiving app reads a byte Receiving TCP advertises window size =1 Sending TCP sends a byte TCP Implementation 33 TCP Implementation 34 A fix for the Silly Window Syndrome Receiver is prevented from advertising when only small buffer space is available It can only advertise when either: It can handle the negotiated max seg size, or half of the receive buffer is empty Optimizing performance Deciding when to send a segment The Silly Window Syndrome Managing the Congestion Window Managing the timeout timer TCP Implementation 35 TCP Implementation 36 9

Congestion control Recall that basic TCP considers two numbers to set the send window size: Advertised window size set by the receiver to prevent sender from overrunning the receive buffer (flow control) Congestion window size set by the sender to try to prevent aggravating network congestion (congestion control) Send window size is set to the minimum of the two numbers Managing congestion window size The basic Slow Start algorithm ( Additive increase, multiplicative decrease ) At start, set CW = 1 max seg size If n segs ACKed, CW=CW + n max seg sizes If timeout, CW = CW / 2 Once CW is reduced, it is not increased again TCP Implementation 37 TCP Implementation 38 A consideration The basic algorithm does not change CW after it is reduced. In complex networks, congestion will come and go. We d like to have a scheme that reduces CW when congestion is high, but increases it when the congestion is relieved Refined Slow Start When timeout occurs: Set threshold = CW/2 Reset CW to 1 and start Slow Start again After CW >= threshold, only increase CW by 1 for each ACK received (regardless of how many segs the ACK is for) TCP Implementation 39 TCP Implementation 40 10

CW size (segs) A typical CW profile 10 Timeout 5 Threshold 0 0 5 10 RTTs TCP Implementation 41 Optimizing performance Deciding when to send a segment The Silly Window Syndrome Managing the Congestion Window Managing the timeout timer TCP Implementation 42 Managing the timeout timer How do we set the value for the timeout timer? Too long performance suffers because it takes a long time to discover that a seg has been lost Too short many unnecessary retransmissions, increasing network load Managing the timeout timer Timeout interval for a connection should be related to the RTT for that connection But on the Internet, RTT can vary wildly We would like a dynamic measure of RTT TCP Implementation 43 TCP Implementation 44 11

Dynamic RTT measurement simple averaging For each connection, TCP maintains a variable AvgRTT When an ACK arrives, TCP calculates the RTT experienced AvgRTT is calculated by simple averaging Problem: treats long-ago behavior as importantly as recent behavior Dynamic RTT measurement exponential averaging AvgRTT = alpha x AvgRTT + (1-alpha) x measured RTT where 0 < alpha < 1 This formulation favors recent measurements Smaller alpha causes more weight on recent measurements Problem: works well for small variance, but does not react well to an abrupt, large change in RTT TCP Implementation 45 TCP Implementation 46 Setting timeout from RTT Generally, timeout is calculated by: timeout = beta x AvgRTT In the early days of the Internet, beta was set to 2 Problem: when the variance in RTT is wide, a fixed beta may not work The fix: Jacobson s Algorithm tracks deviation of the measured RTT and sets beta accordingly. Jacobson s Algorithm: The Idea Instead of calculating AvgRTT by averaging, take the variability of the RTT samples into account TCP Implementation 47 TCP Implementation 48 12

Jacobson s Algorithm: Approach SampleRTT = ACK_time SEND_time Diff = SampleRTT Current Estimated RTT EstimatedRTT = EstimatedRTT + δ x Diff (where 0 <= δ <= 1) Dev = Dev + δ ( Diff - Dev) THEN: Timeout = EstimatedRTT + p x Dev (typical p = 4) How Jacobson s Alg acts When variability is small, Timeout tends toward the long-term average of RTT When variability is large, Timeout tends toward p x (magnitude of the variation) TCP Implementation 49 TCP Implementation 50 A problem with timeouts When network is congested, a higher fraction of attempted sends will timeout due to delay and the timed-out senders will re-send This increases the traffic that the network is trying to handle, probably increasing the congestion and lengthening delay A partial fix: Exponential timeout backoff For each re-transmission, double the timeout For example: Original send timeout = x First re-send timeout = 2x Second re-send timeout = 4x TCP Implementation 51 TCP Implementation 52 13

More problems with setting timeouts Assume you send a seg, timeout, then resend If you get an ACK, is this the ACK for the first send or the second? If you guess wrong, you will corrupt the value of AvgRTT An over-all fix: Karn s Algorithm Use Jacobsons Alg to dynamically adjust RTT until a re-transmission occurs Do not use the RTT of re-transmitted segs in the AvgRTT calculation Use Exponential Timeout Backoff for all re-transmissions until a non-retransmitted seg is ACKed Then, re-start Jacobson's Alg TCP Implementation 53 TCP Implementation 54 TCP Implementation A quick review of TCP TCP implementation options Some other implementation considerations Optimizing TCP s performance TCP over wireless networks TCP over wireless The earliest versions of TCP assumed that timeouts could be either caused by congestion or by lost packets As wired network reliability improved, TCP was optimized to emphasize the congestion case (the retransmit service, which was designed for error handling, has been specialized for congestion control) But wireless links are much less reliable and lost packets can occur frequently TCP Implementation 55 TCP Implementation 56 14

An example of how TCP is not optimized for wireless When segs timeout, TCP re-starts Slow Start and sends more slowly (assuming this will relieve congestion) But when data is lost (happens often on a wireless link), the best thing to do for performance is to re-send quickly Furthermore, many wireless systems (e.g., 802.11) use L2 re-transmission and slowdown. L2 re-trans causes slowdown which can trigger slow-start. TCP and disconnections Mobile users may experience fairly long disconnects If a conventional TCP connection was disconnected, TCP using normal settings would timeout and re-transmit repeatedly, doubling interval each time (up to one minute) for a max of 12 times If the mobile reconnected during this time, it might have to wait an entire minute before the datastream resumed. TCP Implementation 57 TCP Implementation 58 Some things that TCP needs to tolerate to run on wireless networks High error rates Temporary disconnects during handover Heterogeneous wired/wireless connections (and, sender may not know the composition) NOTE: The fact that conventional TCP is not designed to handle these problem does not mean that it won t work on wireless systems, just that its performance is not optimized. TCP mods are possible, but Some proposals (e.g., RFC 3168) recommend returning the timeout structure to error control and adding an Explicit Congestion Notification (ECN) mechanism But this would require changing all TCP installations, most of which run over wired systems and operate fine as-is. TCP Implementation 59 TCP Implementation 60 15

Some fixes for TCP over wireless Indirect TCP (I-TCP) Snooping TCP Indirect TCP (I-TCP) The idea: Combine conventional TCP on the wired network with a Wireless TCP version tuned to run on the wireless part. TCP Implementation 61 TCP Implementation 62 Sender Conventional TCP I-TCP Base Station Wireless TCP Mobile Receiver I-TCP: Plusses and Minuses Plusses: No changes to existing protocol Wireless errors do not directly affect wired system Minuses: Breaks the paradigm of TCP operation an ACK does not mean that the receiver got the seg The base station buffers data for the mobile and ACKs it as it arrives. When a handover occurs, there is no way to get the sender to re-send the buffered data the base station must forward it. To tolerate disconnections, must have very large buffers when disconnect is followed by handover, even more data to forward. TCP Implementation 63 TCP Implementation 64 16

Snooping TCP Uses a single end-to-end TCP connection (so the paradigm is not broken) Base station snoops on the connection Snooping The base station buffers and forwards all packets destined to the mobile (without ACKing the sender) Monitors the connection from the mobile to detect ACKs and gaps in transmitted data Missing ACKs: Performs local re-transmits based on a short timeout timer Missing data: sends NACK to mobile for retransmit TCP Implementation 65 TCP Implementation 66 Snooping TCP Plusses and Minuses Plusses: Preserves the end-to-end TCP paradigm No changes in the wired part of the network Handovers to new base stations happen automatically (any buffered data will simply time out at the sender and be re-transmitted) Minuses: Problems in the wireless segment can affect the wired segment (e.g., lost wireless packets can trigger Slow Start) End-to-end encryption at L3 (e.g, IPSec) foils snooping Does not help in the event of a disconnect (there are no ACKs to snoop) TCP Implementation 67 17