TCP/IP Revisited. IP s Transport Layer UDP and TCP. Computer Science 742 S2C, 2010 TCP UDP

Similar documents
Transport Layer Protocols

Final for ECE374 05/06/13 Solution!!

Computer Networks. Chapter 5 Transport Protocols

Computer Networks UDP and TCP

[Prof. Rupesh G Vaishnav] Page 1

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

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

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

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

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

Ethernet. Ethernet. Network Devices

TCP Performance Management for Dummies

This sequence diagram was generated with EventStudio System Designer (

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

A Survey on Congestion Control Mechanisms for Performance Improvement of TCP

Chapter 5. Transport layer protocols

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

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

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

TCP in Wireless Mobile Networks

Data Networks Summer 2007 Homework #3

How do I get to

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

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

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

Visualizations and Correlations in Troubleshooting

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

Chapter 6 Congestion Control and Resource Allocation

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

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

Congestions and Control Mechanisms n Wired and Wireless Networks

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

CPS221 Lecture: Layered Network Architecture

TCP over Wireless Networks

Network Security TCP/IP Refresher

2 TCP-like Design. Answer

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

Transport Layer. Chapter 3.4. Think about

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

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

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

Effect of Packet-Size over Network Performance

IP - The Internet Protocol

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

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

Recent advances in transport protocols

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

CSMA/CA. Information Networks p. 1

Per-Flow Queuing Allot's Approach to Bandwidth Management

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

15-441: Computer Networks Homework 2 Solution

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

Higher Layer Protocols: UDP, TCP, ATM, MPLS

Networking part 3: the transport layer

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

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

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

CHAPTER 1 PRINCIPLES OF NETWORK MONITORING

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

Mobile Communications Chapter 9: Mobile Transport Layer

Outline. CSc 466/566. Computer Security. 18 : Network Security Introduction. Network Topology. Network Topology. Christian Collberg

IP address format: Dotted decimal notation:

Transport Layer and Data Center TCP

An Introduction to VoIP Protocols

THE UNIVERSITY OF AUCKLAND

MOBILITY AND MOBILE NETWORK OPTIMIZATION

High Speed Internet Access Using Satellite-Based DVB Networks

Computer Networks - CS132/EECS148 - Spring

MASTER'S THESIS. Testing as a Service for Machine to Machine Communications. Jorge Vizcaíno 2014

Low-rate TCP-targeted Denial of Service Attack Defense

High Performance VPN Solutions Over Satellite Networks

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

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

The Data Replication Bottleneck: Overcoming Out of Order and Lost Packets across the WAN

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

The Fundamentals of Intrusion Prevention System Testing

Networks: IP and TCP. Internet Protocol

What is a DoS attack?

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

2.1 Introduction. 2.2 Voice over IP (VoIP)

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

Pig Laboratory. Additional documentation for the laboratory. Exercises and Rules. Tstat Data

Protocols. Packets. What's in an IP packet

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

SJBIT, Bangalore, KARNATAKA

Final Exam. Route Computation: One reason why link state routing is preferable to distance vector style routing.

Ethernet. Ethernet Frame Structure. Ethernet Frame Structure (more) Ethernet: uses CSMA/CD

The present and the future of TCP/IP

Protagonist International Journal of Management And Technology (PIJMT) Online ISSN Vol 2 No 3 (May-2015) Active Queue Management

ESSENTIALS. Understanding Ethernet Switches and Routers. April 2011 VOLUME 3 ISSUE 1 A TECHNICAL SUPPLEMENT TO CONTROL NETWORK

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

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

8-bit Microcontroller. Application Note. AVR460: Embedded Web Server. Introduction. System Description

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT COMPUTER NETWORKS

TCP/IP and the Internet

Computer Networks Practicum 2015

Network Simulation Traffic, Paths and Impairment

Improved Digital Media Delivery with Telestream HyperLaunch

technology standards and protocol for ip telephony solutions

Transcription:

TCP/IP, COMPSCI 742, 2010 p. 3/29 IP s Transport Layer UDP and TCP TCP/IP, COMPSCI 742, 2010 p. 4/29 TCP/IP Revisited Computer Science 742 S2C, 2010 Nevil Brownlee, with acknowledgements to Ulrich Speidel You should be familiar with IP from 314 or equivalent experience Buzzwords to look up: IP addresses, IP routing, best effort, fragmentation, time-to-live TCP or UDP comes in packets (frames, datagrams) that are encapsulated as payload inside an IP datagram There are many other Transport Protocols, e.g. DCCP provides various types of congestion management over IP, for applications that don t need reliability SCTP carries sequenced streams of datagrams RTP carries multimedia streams UDP TCP/IP, COMPSCI 742, 2010 p. 1/29 TCP TCP/IP, COMPSCI 742, 2010 p. 2/29 UDP is used to send individual datagrams from an application on one computer to another application on a different computer across the network Applications are identified by 16-bit port numbers on either side Delivery is best effort, not guaranteed Applications that require recovery from lost transmissions must implement their own detection and recovery protocol TCP: Transmission Control Protocol, RFC 793 Provides a reliable bi-directional byte stream channel between an application on one computer and another application on a different computer across the network Applications identified by 16-bit port numbers at each end Delivery is guaranteed, i.e. TCP handles error detection and recovery TCP is usually described as connection oriented sender and receiver establish initial state they maintain that state during the connection lifetime state is forgotten when the connection ends contrast that with virtual circuit networking, where connection state is stored in switches throughout the network

TCP datagram format TCP/IP, COMPSCI 742, 2010 p. 7/29 TCP port assignment TCP/IP, COMPSCI 742, 2010 p. 8/29 0 4 10 16 31 Source Port Dest Port U A P R S F Hdr Len 000000 R C S S Y IN Advertised Window G K H T N TCP Checksum Sequence Number Acknowledgement Number Urgent Pointer Options (variable length) Port numbers are the first two 16-bit fields in the TCP header TCP is a symmetric protocol, both ends can send and receive streams of data bytes A client machine connecting to a server will usually attempt to open a TCP connecton to a well-known port. It will use a random high-numbered port as its SrcPort. Many applications these days use port numbers 1024 Note that SrcPort and DestPort do not depend on who is client and who is server, but on the direction in which the datagram travels TCP payload (variable length) TCP Sequence number TCP/IP, COMPSCI 742, 2010 p. 5/29 TCP acknowledgements TCP/IP, COMPSCI 742, 2010 p. 6/29 A TCP connection may carry thousands of datagrams in each direction Must have a way to ensure they arrive in sequence and that we can detect missing ones SeqNum header field carries 32 bit sequence number of first byte in datagram. Sequence numbers apply to their datagram s respective direction Are supposed to start at a random value but may just start at 0; i.e. they may not be particularly random Can also be used as SYN cookies, allowing a TCP server to time out an attacker s half-open connections Wrap-around: sequence number 2 32 1 is followed by sequence number 0 (assuming one-byte datagrams) TCP sequence numbers use unsigned 32-bit arithmetic The Acknowledgement field contains the sequence number of the next byte that the machine expects to receive The sending machine can use it to determine how many of its transmitted datagrams have been successfully received Field is only valid if flag in flags field is set Timing issues (see later)! Ack packets can carry data bytes, but they usually do not. Many protocols carry most of their data in one direction; can you think of some which carry data in both directions?

TCP header length TCP/IP, COMPSCI 742, 2010 p. 11/29 TCP flags (1) TCP/IP, COMPSCI 742, 2010 p. 12/29 TCP header is not fixed in length can get different size headers depending on use of Options field HdrLen field gives the total size of the TCP header in four-byte units, i.e. length = HdrLen 4 Everything following the header is payload (data that is to be delivered to the application) Six bits in the TCP header are used for flags: SYN: Set when the client sends its first datagram to the server, and in the server s acknowledgement of that datagram. Basically, it marks the connection request/confirmation : Indicates that the Acknowledgement field contains a valid segment number. Remember that we can t set no value in a 32 bit field! SYN and flags are enough to get a connection established TCP flags (2) TCP/IP, COMPSCI 742, 2010 p. 9/29 TCP connection handshake (simplest case) TCP/IP, COMPSCI 742, 2010 p. 10/29 Flags which terminate a connection: FIN: Signals that a host has finished with a connection. The other host should finish too RESET: Shuts down the connection immediately. Used in case of errors should not see this in proper implementations! Other flags: PUSH: Indicates receiver should pass all data in its buffer to application. Not very useful these days URG: Indicates that UrgPtr points to last byte of urgent data, but there s no way to indicate the first byte of such data not often used Host A sends datagram with SYN flag set and an initial sequence number, say 382 in its Sequence field Host B responds with datagram that has SYN+ set, Ack field contains 383, Sequence field is, say, 12765 Host A sends datagram that has set, Ack field contains 12766. Client now regards the connection as established, sequence number is 383 Note that: The SYN flag counts as one byte Host A s second datagram completes the connection handshake. It can also carry data, e.g. an HTTP GET request

TCP acknowledgement TCP/IP, COMPSCI 742, 2010 p. 15/29 TCP flow control: sliding window TCP/IP, COMPSCI 742, 2010 p. 16/29 One side (host A) sends one-byte datagram with sequence number, say 387 Other side (host B) responds with datagram that has set. Acknowledgement field contains number 388, its own sequence number is, say, 12779 Host A now knows that host B has received all bytes from host A up to and including number 387 note: carries the sequence number of the next byte B expects to recieive If a datagram is lost on the way from A to B, next from B contains an earlier sequence number After an appropriate timeout, A resends the missing datagram(s) Problem: What is an appropriate waiting time? Receiver advertises a window in its datagrams that have the flag set: the number of bytes left in its receive buffer for the connection this is the number of bytes it can still receive Sender must ensure that there is at most this amount of unacknowledged data on the connection Problem: If receiver advertises window size 0, the sender will not know when the window size increases again Solution: sender sends small (ack) frame every so often; that evokes a response from receiver advertising the current window size Adaptive retransmission (1) TCP/IP, COMPSCI 742, 2010 p. 13/29 Adaptive retransmission (2) TCP/IP, COMPSCI 742, 2010 p. 14/29 Problem: datagrams in transit between sender and receiver are not included in the advertised window. By the time the advertised window size arrives at the sender, it is out of date How big is the problem? Depends on bandwidth-delay product. On a connection between NZ and the US that terminates in 100 Mb/s Ethernet either side and has 100 ms latency, it s no less than 10 Mb, i.e., about 1 MB of payload data! A big problem indeed, especially for people in NZ! Need some sort of algorithm that can handle this data in transit Time each frame: measure time between transmission of the datagram and arrival of its corresponding. Use that as estimate of round-trip time (RTT) Sending side computes capacity of receiver buffers plus channel and can (conservatively) transmit data until this capacity is reached Problem: s are not associated with a particular copy of a datagram is it for the original or the resend? Can t compute RTT values for such cases Karn/Partridge: double RTT timeout every time a datagram needs to be resent ( exponential backoff ). Only do calculation for packets that are not resent Karels/Jacobson: compute RTT timeout more closely based on RTT statistics

TCP in more detail [p 378 / 384] TCP/IP, COMPSCI 742, 2010 p. 19/29 TCP state diagram (RFC 793) TCP/IP, COMPSCI 742, 2010 p. 20/29 Ordered delivery Each end has a buffer for the max window size Max receive window sent in each segment Sequence number = nbr of first byte Acknowledgement number = nbr of next expected byte Seq + TCP length = Ack (when Acking a single segment) Out-of-sequence segments re-send earlier Ack Sequence numbers are 32-bit unsigned, and will wrap Flow control Don t send more data than will fit in the receive window Receive window size changes as data removed from buffer Active Open SYN CLOSED Legend: CLOSE Active SEND SYN CLOSE Passive Open COMMAND from application FLAG received FLAG sent SYN_SENT LISTEN SYN SYN+ SYN SYN+ SYN_RECV (of SYN) FIN Normal operation CLOSEFIN CLOSEFIN CLOSE_WAIT LAST_ CLOSED Send remaining data in buffer ESTABLISHED CLOSE FIN FINWAIT_1 CLOSING FIN+ (of FIN) (of FIN) (of FIN) Receive remaining data from other side s buffer TIMEOUT (2x MSL) FINWAIT_2 TIME_WAIT FIN TCP Congestion Management [p 468 / 474] TCP/IP, COMPSCI 742, 2010 p. 17/29 TCP Congestion Management (2) TCP/IP, COMPSCI 742, 2010 p. 18/29 Feedback scheme Idea is to use Acks to clock packets onto link RFC 2581 Sender maintains congestion window, never sends more than min(cwin, rwin) bytes Slow Start Begin by sending 1..3 packets Increment cwin each Ack segment until a segment is lost Halve cwin, switch to AI/MD Additive increase / multiplicative decrease (AI/MD) Increment cwin once per RTT until a segment is lost Halve cwin and repeat Note that packet loss is required for TCP congestion management RFC 2309 Recommendations on Queue Management and Congestion Avoidance in the Internet

TCP errors, etc. TCP/IP, COMPSCI 742, 2010 p. 23/29 Algorithms used in TCP Implementation TCP/IP, COMPSCI 742, 2010 p. 24/29 Error handling Lost segment detected by timeout, or by receiving three duplicate Acks Fast retransmit: re-send segment starting with Ack byte (only re-send one segment) Half-open connections From host which crashed (without sending FINs) Keepalive packets Some implementations send these, and close connections if no data bytes are sent during the timeout interval This is not part of the TCP protocol, sessions stay open until they are closed by FIN or RST When to send data Nagle: if (< mss bytes and unacked bytes) wait else send Measuring RTT Karn/Partridge: don t time retransmitted segments Jacobson/Karels: allow for variance in RTTs Congestion Management Slow Start: set cwind = IW (usually 1 or 2 segments), increment by SMSS each up to ssthresh (init 65535) Congestion Avoidance: AI/MD Fast Retransmit: resend after third duplicate Fast Recovery: don t Slow Start after Fast Retransmit Congestive collapse TCP/IP, COMPSCI 742, 2010 p. 21/29 Flavours of TCP (1) TCP/IP, COMPSCI 742, 2010 p. 22/29 In case of congestion on data networks, there is a condition called congestive collapse Under TCP, when datagrams do not get through, TCP s RTT will back off exponentially can reach total inactivity pretty quickly! Back-off is designed to relieve pressure on resources Only works fairly if everyone keeps to the rules (no DoS attacks). Even so, retries create extra traffic Congestive collapse occurs when almost the entire traffic consists of retransmissions that don t get through as a result of the congestion, in turn generating retries No back-off in other protocols, e.g. UDP P&D [494] say that TCP is defined by an implementation We look (briefly) at the best-known implementations: Tahoe: the original BSD implementation of TCP (BNR1) begins in slow start, reaches ssthresh then switches to congestion avoidance detects loss by timeout before getting an set cwin to one and switch back to slow start Reno: added more algorithms to improve data transfer rate fast retransmit: three duplicate acks indicate packet loss; resend the missing segment, halve cwin, switch to fast recovery fast recovery: if no for resent segment, switch to slow start delayed s: only send an for every second packet the most widely-deployed TCP implementation

Flavours of TCP (2) TCP/IP, COMPSCI 742, 2010 p. 27/29 Further reading TCP/IP, COMPSCI 742, 2010 p. 28/29 Vegas: mid-90 s[495] observe data rate using RTTs for recent packets, detect changes in rate adjust cwin up or down, attempting to match the observed rate to the expected rate idea is to keep enough bits on the wire, without getting lots of bits (packets) backed up in router buffers, i.e. use queueing delay instead of loss probability to detect congestion not widely deployed FAST TCP: 2005 tries to maintain constant number of packets on the wire variable-sized adjustments to cwin proprietary (patented), i.e. not following a standard RFCs covering TCP implementation RFC 2581: TCP Congestion Control READ THIS ONE! It s quite short, it explains TCP s four intertwined algorithms (for congestion control) very clearly RFC 3390: Increasing TCP s Initial Window Congestion in the Internet RFC 2309: Recommendations on Queue Management and Congestion Avoidance Simulation-based comparisons of Tahoe, Reno and S TCP, Kevin Fall, Sally Floyd, CACM, vol 26, pp5-21, 1996. All these are on the 742 Resources web page Note: new implementations of TCP must interwork properly with existing ones! TCP Throughput Formula TCP/IP, COMPSCI 742, 2010 p. 25/29 TCP Throughput Formula (2) TCP/IP, COMPSCI 742, 2010 p. 26/29 Matthew Mathis, Jeffrey Semke, Jamshid Mahdavi, Teunis Ott, The Macroscopic Behaviour of the TCP Congestion Avoidance Algorithm, SIGCOMM, July 1997 Data delivered = area under sawtooth, i.e. 3/8 W 2 Each cycle delivers 1/p packets (p is the packet loss rate) data per cycle BW = time per cycle = MSS RT T C p, and C = p 3/2 Note that BW is inversely proportional to p i.e. need low loss rates to get high bandwidth This is a very simple model of TCP behaviour, many other papers about TCP behaviour have been published Some authors suggest that a TCP sender sends packets in flights, and use those flights to measure RT T

A different model of TCP In 2003, Allen Downey (Boston University) published a paper summarising his observations of TCP behaviour, and presented a Markov Model based on them Allen s work was published as: (D96) An Empirical model of TCP transfers, Allen B. Downey, Olin College Technical Report, January 14, 2003 That paper is on the 742 resources web page TCP/IP, COMPSCI 742, 2010 p. 29/29