Sequence Number. Acknowledgment Number. Checksum. Urgent Pointer plus Sequence Number indicates end of some URGENT data in the packet

Similar documents
> : S. timestamp > : (0) win <mss 1460,nop,wscale 0,nop,nop, 4 different options used

User Datagram Protocol

TCP Service Model. Today s Lecture. TCP Support for Reliable Delivery. EE 122:TCP, Connection Setup, Reliability

CS419: Computer Networks. Lecture 10, Part 2: Apr 11, 2005 Transport: TCP mechanics (RFCs: 793, 1122, 1323, 2018, 2581)

Transport Protocols. Raj Jain. Washington University in St. Louis

CS457 Transport Protocols. CS 457 Fall 2014

Transport Layer Marcos Vieira

TCP Strategies. Keepalive Timer. implementations do not have it as it is occasionally regarded as controversial. between source and destination

Connection-oriented (virtual circuit) Reliable Transfer Buffered Transfer Unstructured Stream Full Duplex Point-to-point Connection End-to-end service

Guide To TCP/IP, Second Edition UDP Header Source Port Number (16 bits) IP HEADER Protocol Field = 17 Destination Port Number (16 bit) 15 16

7. TCP 최양희서울대학교컴퓨터공학부

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4021: Networks Discussion. Chapter 5 - Part 2

Introduction to TCP/IP networking

TCP : Fundamentals of Computer Networks Bill Nace

Introduction to Networking. Operating Systems In Depth XXVII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

Transport Protocols & TCP TCP

I TCP 1/2. Internet TA: Connection-oriented (virtual circuit) Connectionless (datagram) (flow control) (congestion control) TCP Connection-oriented

Transmission Control Protocol (TCP)

The Transport Layer. Internet solutions. Nixu Oy PL 21. (Mäkelänkatu 91) Helsinki, Finland. tel fax.

Information Network 1 TCP 1/2

CSC 401 Data and Computer Communications Networks

TCP Basics : Computer Networking. Overview. What s Different From Link Layers? Introduction to TCP. TCP reliability Assigned reading

Transmission Control Protocol. ITS 413 Internet Technologies and Applications

The Transport Layer. Part 1

Packet Header Formats

Transport Over IP. CSCI 690 Michael Hutt New York Institute of Technology

Two approaches to Flow Control. Cranking up to speed. Sliding windows in action

ICS 451: Today's plan. Sliding Window Reliable Transmission Acknowledgements Windows and Bandwidth-Delay Product Retransmission Timers Connections

CMSC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. October 25, 2018

Introduction to Networks and the Internet

Lecture 3: The Transport Layer: UDP and TCP

ECE 435 Network Engineering Lecture 9

What is TCP? Transport Layer Protocol

CS118 Discussion 1A, Week 4. Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m.

Outline. What is TCP protocol? How the TCP Protocol Works SYN Flooding Attack TCP Reset Attack TCP Session Hijacking Attack

Transport Protocols and TCP

User Datagram Protocol (UDP):

TCP. CSU CS557, Spring 2018 Instructor: Lorenzo De Carli (Slides by Christos Papadopoulos, remixed by Lorenzo De Carli)

6.1 Internet Transport Layer Architecture 6.2 UDP (User Datagram Protocol) 6.3 TCP (Transmission Control Protocol) 6. Transport Layer 6-1

Connections. Topics. Focus. Presentation Session. Application. Data Link. Transport. Physical. Network

TCP = Transmission Control Protocol Connection-oriented protocol Provides a reliable unicast end-to-end byte stream over an unreliable internetwork.

Transport Protocols and TCP: Review

Introduction to Internet. Ass. Prof. J.Y. Tigli University of Nice Sophia Antipolis

EEC-682/782 Computer Networks I

TCP/IP Performance ITL

TCP and Congestion Control (Day 1) Yoshifumi Nishida Sony Computer Science Labs, Inc. Today's Lecture

CSCI-GA Operating Systems. Networking. Hubertus Franke

Transport Layer: Outline

Some slides courtesy David Wetherall. Communications Software. Lecture 4: Connections and Flow Control. CSE 123b. Spring 2003.

6. The Transport Layer and protocols

Announcements Computer Networking. Outline. Transport Protocols. Transport introduction. Error recovery & flow control. Mid-semester grades

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2. Goals for Todayʼs Lecture. Role of Transport Layer

TCP/IP Networking. Part 4: Network and Transport Layer Protocols

Transport: How Applications Communicate

CSC 634: Networks Programming

TCP Overview. Connection-oriented Byte-stream

ECE4110 Internetwork Programming. Introduction and Overview

Lecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24

Outline Computer Networking. Functionality Split. Transport Protocols

Transport Layer. Application / Transport Interface. Transport Layer Services. Transport Layer Connections

Simulation of TCP Layer

Sequence Number. Acknowledgment Number. Data

05 Transmission Control Protocol (TCP)

Transport Protocols Reading: Sections 2.5, 5.1, and 5.2

CS 716: Introduction to communication networks th class; 7 th Oct Instructor: Sridhar Iyer IIT Bombay

Transport layer. UDP: User Datagram Protocol [RFC 768] Review principles: Instantiation in the Internet UDP TCP

EEC-484/584 Computer Networks. Lecture 16. Wenbing Zhao

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

Transport Layer. <protocol, local-addr,local-port,foreign-addr,foreign-port> ϒ Client uses ephemeral ports /10 Joseph Cordina 2005

Kent State University

ECE 435 Network Engineering Lecture 15

To see the details of TCP (Transmission Control Protocol). TCP is the main transport layer protocol used in the Internet.

Mobile Transport Layer Lesson 10 Timeout Freezing, Selective Retransmission, Transaction Oriented TCP and Explicit Notification Methods

CSE/EE 461 Lecture 12 TCP. A brief Internet history...

Chapter 5 End-to-End Protocols

Multiple unconnected networks

TCP: Transmission Control Protocol RFC 793,1122,1223. Prof. Lin Weiguo Copyleft 2009~2017, School of Computing, CUC

Internet Layers. Physical Layer. Application. Application. Transport. Transport. Network. Network. Network. Network. Link. Link. Link.

Chapter 3 outline. 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management

ECE 650 Systems Programming & Engineering. Spring 2018

Computer Networks. Transmission Control Protocol. Jianping Pan Spring /3/17 CSC361 1

Transport Layer: outline

CS4700/CS5700 Fundamentals of Computer Networks

EE 122: Transport Protocols. Kevin Lai October 16, 2002

CSCD 330 Network Programming

COMPUTER NETWORKS CS CS 55201

COMP/ELEC 429/556 Introduction to Computer Networks

COMPUTER NETWORKS CS CS 55201

COMP 431 Internet Services & Protocols. Transport Layer Protocols & Services Outline. The Transport Layer Reliable data delivery & flow control in TCP

9th Slide Set Computer Networks

Networking Technologies and Applications

Computer Networking Introduction

ITS323: Introduction to Data Communications

Programming Assignment 3: Transmission Control Protocol

Problem. Chapter Outline. Chapter Goal. End-to-end Protocols. End-to-end Protocols. Chapter 5. End-to-End Protocols

Transport layer. Review principles: Instantiation in the Internet UDP TCP. Reliable data transfer Flow control Congestion control

The Transport Layer Reliable data delivery & flow control in TCP. Transport Layer Protocols & Services Outline

Lecture 4: Congestion Control

ECE 435 Network Engineering Lecture 9

The Transport Layer: TCP & Reliable Data Transfer

Transcription:

TCP Urgent Source Port Destination Port Sequence Number Acknowledgment Number HdrLen Reserved UA P RS F Checksum Window Size Urgent Pointer Urgent Pointer plus Sequence Number indicates end of some URGENT data in the packet TCP Urgent (2) Seq=200000 UrgPtr=123 The byte with sequence id 200123 the last of urgent data Urgent Pointer valid only when the URG bit is set URG remains set until packet containing urgent data transmitted "Urgent" data is just data that the receiver needs to know has arrived as soon as possible Receiving URG switches receiver into urgent processing mode until urgent data has been consumed then back to normal mode TCP Urgent Spec Urgent Pointer: 16 bits This field communicates the current value of the urgent pointer as a positive offset from the sequence number in this segment. The urgent pointer points to the sequence number of the octet following the urgent data. This field is only be interpreted in segments with the URG control bit set. [...] If the urgent flag is set, then SND.UP <- SND.NXT-1 and set the urgent pointer in the outgoing segments. SND.UP -- the urgent pointer SND.NXT -- Seq Number of next byte to send 1981 (RFC793)

TCP Correction RFC1122 4.2.2.4 Urgent Pointer: RFC-793 Section 3.1 The second sentence is in error: the urgent pointer points to the sequence number of the LAST octet (not LAST+1) in a sequence of urgent data. The description on page 56 (last sentence) is correct. 1989 (RFC1122) Text descriptions of protocols can be ambiguous contradictory TCP implementations still need to deal with this Some early implementations used each definition Finite State Machine More formal method of speificiation Often depicted using drawing Some number of states defined drawn as circles or rectangles In each state specific events can occur inputs timeouts cause transition to another state cause output action to occur FSM Basics State Event Output State The FSM is in some state An event occurs drawn beside a line shows transition to a new state Some output may accompany transition Transition may return to the same state Or may transition to another state

FSM (example) State 1 State 3 Initial State 1 2 3 C A B 2 Q State 2 P 1 2 Y 3 1 M 3 X Three States 1 2 and 3 Three events that occur 1 2 and 3 Several output actions State 1 is the initial state For input events 1 1 1 2 3 2 3 1 2 2 3 What states does FSM pass through? What output actions are performed? 1 2 3 2 1 3 3 1 2 1 2 2 A M P Q C Y X A Q B - TCP Connections (States) Closed Syn Rcvd Listen Syn Sent Established Fin Wait 1 Fin Wait 2 Closing Time Wait Close Wait Last Ack FSM of TCP connection machinery Inputs & Outputs to come later TCP Connections (Hdr Fields) Source Port Destination Port Sequence Number Acknowledgment Number HdrLen Reserved UA P RS F Checksum Window Size Urgent Pointer RST - RESET SYN - SYNCHRONISE - ISH SYN & consume sequence numbers

TCP SYN/ & Seq Numbers Source Port Destination Port Sequence Number Acknowledgment Number HdrLen Reserved UA P RS F Checksum Window Size Urgent Pointer SYN + 1 Byte Two sequence numbers consumed Sequence number in header is sequence number of SYN gets next sequence number TCP Specification FSM not used to specify everything The sequence number of the first data octet in this segment (except when SYN is present). If SYN is present the sequence number is the initial sequence number (ISN) and the first data octet is ISN+1. TCP Connections (Identity) TCP Connection identified by 4-tuple Source IP Address Destination IP Address Source TCP Port Number Destination TCP Port Number All remain constant for one TCP connection

TCP Client Open Syn Rcvd Closed (Application Request) Send SYN Listen Syn Sent Established Syn+Ack Received Send Fin Wait 1 Fin Wait 2 Closing Time Wait Close Wait Last Ack 3-way Handshake SYN SYN+ TCP Sequence Number Choices Sequence number used to acknowledge data being transferred (as noted previously) Any increasing number works for this. But also used to exclude old data from previous connections that remains in the network For this, need sequence numbers to globally (for a node) increase over time New connection not re-use the sequence numbers of any recent previous connection TCP Sequence Number Start End

TCP Sequence Numbers Also used to avoid connection hijacking Hijacker needs to know sequence numbers to generate valid packets Want seq numbers to be random So, want a random number that increases Must be random enough to avoid brute force attacks Sequential enough to keep out old packets TCP Specification To avoid confusion we must prevent segments from one incarnation of a connection from being used while the same sequence numbers may still be present in the network from an earlier incarnation. We want to assure this, even if a TCP crashes and loses all knowledge of the sequence numbers it has been using. When new connections are created, an initial sequence number (ISN) generator is employed which selects a new 32 bit ISN. The generator is bound to a (possibly fictitious) 32 bit clock whose low order bit is incremented roughly every 4 microseconds. Thus, the ISN cycles approximately every 4.55 hours. Since we assume that segments will stay in the network no more than the Maximum Segment Lifetime (MSL) and that the MSL is less than 4.55 hours we can reasonably assume that ISN s will be unique. TCP Server Open Syn Rcvd SYN+ SYN Closed (application request) Listen Syn Sent Established Fin Wait 1 Fin Wait 2 Closing Time Wait Close Wait Last Ack Same 3-way handshake SYN SYN+

TCP Sequence Numbers Also used to avoid connection hijacking Hijacker needs to know sequence numbers to generate valid packets Want seq numbers to be random So, want a random number that increases Must be random enough to avoid brute force attacks Sequential enough to keep out old packets TCP Specification To avoid confusion we must prevent segments from one incarnation of a connection from being used while the same sequence numbers may still be present in the network from an earlier incarnation. We want to assure this, even if a TCP crashes and loses all knowledge of the sequence numbers it has been using. When new connections are created, an initial sequence number (ISN) generator is employed which selects a new 32 bit ISN. The generator is bound to a (possibly fictitious) 32 bit clock whose low order bit is incremented roughly every 4 microseconds. Thus, the ISN cycles approximately every 4.55 hours. Since we assume that segments will stay in the network no more than the Maximum Segment Lifetime (MSL) and that the MSL is less than 4.55 hours we can reasonably assume that ISN s will be unique. TCP Open Example 172.30.0.77.65291 > 172.30.0.161.9: S 1561401491:1561401491(0) win 16384 172.30.0.161.9 > 172.30.0.77.65291: S 3751259715:3751259715(0) ack 1561401492 win 16384 172.30.0.77.65291 > 172.30.0.161.9:. ack 3751259716 win 17520

TCP Requested Close Closed Syn Rcvd Listen Syn Sent (application request) + Established Fin Wait 1 Closing Close Wait Fin Wait 2 Time Wait (timer expires) Last Ack TCP Response Close Closed Syn Rcvd Listen Syn Sent Fin Wait 1 Fin Wait 2 Established Closing Time Wait Close Wait (appl close) Last Ack TCP Close Example 172.30.0.77.65291 > 172.30.0.161.9: F 1561401492:1561401492(0) ack 3751259716 win 17520 172.30.0.161.9 > 172.30.0.77.65291:. ack 1561401493 win 17520 172.30.0.161.9 > 172.30.0.77.65291: F 3751259716:3751259716(0) ack 1561401493 win 17520 172.30.0.77.65291 > 172.30.0.161.9:. ack 3751259717 win 17519

TCP TIME WAIT Active Internet connections (including servers) Proto Local Address Foreign Address State tcp 172.30.0.77.65291 172.30.0.161.9 TIME_WAIT "Connection" on client remains in TIME WAIT for twice the maximum segment lifetime Guards against old packets in the network Graceful termination How to acknowledge the final packet? Send an acknowledge? But then that is the final packet... How is that acknowledged? Eventually, simply stop! TCP (concluded) Source Port Destination Port Sequence Number Acknowledgment Number HdrLen Reserved UA P RS F Checksum Window Size Urgent Pointer Source Port Destination Port Transport address Checksum As for UDP includes pseudo-header Source IP Address Destination IP Address 0 Protocol Payload Length But not optional.

TCP Options Source Port Sequence Number Destination Port Acknowledgment Number HdrLen Reserved UA P RS F Checksum Window Size Urgent Pointer Options (optional...) Header Length Allows size of options to be calculated Counts 32 bit words in header Minimum value 5 (20 bytes) Maximum value 15 (60 bytes) Max 40 bytes of options Options not needed in every packet Extensions to TCP TCP Options 172.30.0.77.65486 > 172.30.0.161.9: S 334775908:334775908(0) win 16384 <mss 1460,nop,wscale 0,nop,nop, timestamp 11188 0> 4 different options used NOP padding (keeps alignment of other options) MSS WSCALE TIMESTAMP TCP Specification Options: variable Options may occupy space at the end of the TCP header and are a multiple of 8 bits in length. All options are included in the checksum. An option may begin on any octet boundary. There are two cases for the format of an option: Case 1: A single octet of option-kind. Case 2: An octet of option-kind, an octet of option-length, and the actual option-data octets. The option-length counts the two octets of option-kind and option-length as well as the option-data octets. Note that the list of options may be shorter than the data offset field might imply. The content of the header beyond the End-of-Option option must be header padding (i.e., zero). A TCP must implement all options.

TCP Specification Currently defined options include: Kind Length Meaning ---- ------ ------- 0 - End of option list. 1 - No-Operation. 2 4 Maximum Segment Size. End of Option 1 byte 0 What follows is padding Padding required to be 0 No Operation 1 byte 1 TCP Max Segment Size Opt Allows one TCP to tell the other the maximum segment size to send Segment ~= packet but one segment may be fragmented into several packets Maximum Segment Size 4 bytes Kind 2 Length 4 Value (2 bytes) MSS TCP MSS Practice TCP will attempt to avoid fragmentation by advising peer of the maximum segment size Segment size (within window) not usually important Works correctly only when low MTU links are directly connected to hosts Largely overtaken by PMTUD now Or should be Option only permitted when SYN is set not required in every packet

TCP Window Size Limitation Maximum window size is 64K bytes (-1) Once "window" size bytes of data have been sent, TCP must stall and wait for of (at least) first segment before sending more At 56K bits per second (original arpanet) sending 64K bytes takes more than 9 seconds As long as RTT is less than 9 seconds, (Round Trip Time) TCP need never stall TCP Window Size Limitation At 100 M bits/second (current network speeds) sending 64K bytes takes about 5.5 milliseconds So RTT must be less than 5.5 milliseconds to avoid stall OK for LAN WAN might easily have RTT of 500ms TCP can only use about 1% of available bandwidth Want to extend TCP to allow higher throughput Add an option TCP Window Scale Option Allows TCP systems to discover that both implement the option specify that all window values should be multiplied by a power of two Limited to 2^14 So, max window is (64K - 1) * 2^14 ~= 1GB Thus max of 1/4 of the entire window space If both TCPs send wscale option, window scaling protocol is used Each TCP indicates how much its window should be scaled If either does not send option No window scaling In either direction

TCP Option Usage 172.30.0.77.65486 > 172.30.0.161.9: S 334775908:334775908(0) win 16384 <mss 1460,nop,wscale 0,nop,nop, timestamp 11188 0> WScale == 0 Scale window size by 2^0 2^0 == 1 So, no scaling Why is option included? So other host knows this TCP supports the window scale option Round Trip Time Estimation Useful to know when to retransmit if have not received within the RTT (plus a bit) then assume packet lost But how to measure the RTT? Measure delay between packet and its easy But Send packet wait... wait... wait (nothing) Retransmit packet arrives Which packet was acknowledged? The initial packet acknowledged slower than expected Or the retransmit? TCP RTT Measurement

TCP RTT Measurement (2) TCP RTT Measurement (3) TCP Timestamp Option Each TCP can add timestamp option to every packet Peer TCP sends back timestamp received with each Allows TCP to determine which packet was d Better than that, no need to remember when packets were sent, the returning timestamp contains that information Also used for long delayed old packet detection extends the sequence number space

TCP RTT Measurement (tstamp) T=6 (YT=5) T=8 T=5 (YT=6) T=6 (YT=5) T=8 T=5 (YT=6) T=13 (YT=13) T=13 (YT=8) (YT=13) TCP or UDP UDP is unreliable, not flow controlled TCP is reliable, has flow control But Often would prefer to use TCP to UDP Overheads are much greater Typical TCP Client Server SYN One RTT Start with 3 way handshake SYN + SYN + Then DATA Server delay before reply and another RTT Now Close connection Another RTT (but unimportant) Done - 2*RTT + server delay (11 packets)

UDP Alternative Client Server Just send the data Reply Server Delay And One RTT Done - 1*RTT + server delay (2 packets) 2 packets instead of 11 1 RTT instead of 2 Minimal TCP Client SYN SYN SYN + + + What might be merged in TCP? Server Can put data in SYN packet Can even put in SYN packet SYN + + Server data reply can carry Still 2*RTT + server delay (6 packets) TCP Cannot Do Client SYN + + SYN + Server Server cannot return data with its SYN as TCP prohibits passing any data in original SYN to application until 3-way handshake is complete Until then, not known that SYN is new + in SYN+ acks only the SYN

Old Duplicate SYN Client SYN + + SYN + + Server Consider a client sending a SYN which is lost in the net and retransmitted Transaction continues as normal SYN + + Later the "lost" SYN arrives TCP sends normal SYN+ reply but client is not expecting this so sends a RST What if data were already delivered? SYN + + SYN + + RST TCP Can Sometimes Do Client SYN + + Server (which s data in SYN packet) can be merged with DATA reply packet SYN + Depends on Server Delay Still 2*RTT + server delay (5 packets) + Maximum Transaction Rate Bounded by 2 * RTT + server delay But also limited by TIME WAIT state No more data on same connection for 2*MSL Client picks a different port number different connection If 1000 connections / second, and MSL == 2 mins (120 secs) Then 240*1000 connections in TIME WAIT state Consumes lots of memory (if 40 bytes/connection, almost 10MB) Worse! Impossible, only 65536 ports! Thus limited to about 270 trans/sec