Transmission Control Protocol

Transmission Control Protocol

TRANSMISSION CONTROL PROTOCOL (TCP) 2008.10 TCP , TCP RFC793 2. PHILOSOPHY: TCP cover 3.8 Interfaces: TCP layer interface 3.9 Event Processing: TCP state event Contents Introductions Motivation Scope Operation Header Format TCP protocol header Header fields Terminology Transmission Control Block (TCB) Send sequence variables

Receive sequence variables Current segment variables Connection states Events TCP connection state diagram 2 Contents Sequence Numbers Sequence number and acknowledgement Sequence number space Sequence number comparison Initial Sequence Number (ISN) selection Knowing when to keep quiet The TCP quiet time concept Establishing A Connection

Basic 3-way handshake Simultaneous connection synchronization Recovery from old duplicate SYN Half-open connections Half-open connection discovery Active side causes half-open connection discovery Old duplicate SYN Reset generation States for reset Reset processing 3 Contents Closing A Connection Close Close Close Close operation case 1: Local user initiates the close

case 2: TCP receives a FIN from the network case 3: Both users close simultaneously Precedence and Security Security/Compartment Rejecting a connection Sending security parameters Data Communication Data transmission Retransmission timeout The communication of urgent information Managing the window References 4 Introduction Motivation Packet Switching (PS) (RFC 793, Sep. 1981) Internet Protocol(IP) layer IP TCP data segment internet datagram envelope Internet datagram network

network gateway TCP segment fragmentation reassembly TCP segment , , Scope network process process network host-to-host protocol 5 Introduction Operation Basic Data Transfer octet TCP segment internet system octet stream TCP data , push Reliability Sequence Number, Positive Acknowledgement, Checksum data , , Flow Control TCP ACK window TCP data

Multiplexing host process TCP port IP layer TCP layer port socket socket Connections Reliability Flow Control data stream Connection Connection socket socket Precedence and Security TCP user Precedence Security , default value IP TCP 6 Header Format TCP protocol header TCP segment internet datagram IP header source, destination IP header TCP header 7 Header Format

Header Fields Source Port (16 bits) Source port number Destination Port (16 bits) Destination port number Sequence Number (32 bits) Segment data octet sequence number SYN SYN sequence number initial sequence number (ISN) data octet ISN+1 Acknowledge Number (32 bits) ACK control bit ack sequence number Connection Data Offset (4 bits) 32 bit word TCP header data TCP header 32 bit 8 Header Format Header Fields Reserved (6 bits) Reserved for future use 0

Control Bits (6 bits) URG: Urgent Pointer field ACK: Acknowledgement Number field PSH: Push Function RST: Connection reset SYN: Sequence number FIN: data Window (16 bits) data octet data octet ack number field sequence number octet Checksum (16 bits) TCP header data 16 bit 1 , 1 checksum ( code ) octet 0 padding 16 bit word Padding octet checksum Checksum TCP header checksum field 0 9

Header Format Header Fields Checksum (16 bits) TCP header 96 bit pseudo header checksum Source Address, Destination Address, Protocol IP header TCP Length header data (pseudo header ) Urgent Pointer (16 bits) Segment sequence number offset data octet sequence number , segment data octet urgent pointer octet data URG control bit 10 Header Format Header Fields Options (variable) TCP header 8 bit Case 1: octet option-kind Case 2: option-kind (1 octet), option length (1 octet, length kind length 2 octet ), option data (variable)

TCP option (RFC 793 option ) End of Option List (kind: 0, length: n/a) Option list TCP header No-Operation (kind: 1, length: n/a) Option option word padding option option word Maximum Segment Size (kind: 2, length: 4) segment size option segment connection (SYN control bit segment) Padding (variable) TCP header 32 bit 0 11 Terminology Transmission Control Block (TCB) TCP connection ( ) Local & remote socket number, connection security precedence , user / buffer pointer, queue pointer, current segment pointer Send Sequence Variables

SND.UNA - send unacknowledged SND.NXT - send next SND.WND - send window SND.UP - send urgent pointer SND.WL1 - segment sequence number used for last window update SND.WL2 - segment acknowledgment number used for last window update ISS - initial send sequence number 12 Terminology Receive Sequence Variables RCV.NXT - receive next RCV.WND - receive window RCV.UP - receive urgent pointer IRS - initial receive sequence number Current Segment Variables

SEG.SEQ - segment sequence number SEG.ACK - segment acknowledgment number SEG.LEN - segment length SEG.WND - segment window SEG.UP - segment urgent pointer SEG.PRC - segment precedence value 13 Terminology Connection States LISTEN host (SYN) SYN-SENT (SYN, ACK) SYN-RECEIVED , ACK ESTABLISHED Connection Data normal state , data user FIN-WAIT-1

ACK FIN-WAIT-2 ack TCP CLOSE-WAIT TCP local user 14 Terminology Connection States CLOSING TCP ACK ACK LAST-ACK TCP ACK , ACK TIME-WAIT TCP ACK CLOSED Connection

Events Connection State User Calls OPEN, SEND, RECEIVE, CLOSE, ABORT, STATUS Incoming Segments SYN, ACK, RST, FIN flag segment Timeout 15 TCP Connection State Diagram Event/Action Action state CLOSED Active open event client , Passive open event server 16 Sequence Numbers Sequence number and Acknowledgement TCP connection octet sequence number Cumulative ack Sequence number X ack X sequence number octet (X ) Sequence Number Space

Field 32 bits 0 232-1 Modulo 232 232-1 0 Sequence number comparison ack ack sequence number SND.UNA < SEG.ACK =< SND.NXT Segment sequence number ack ( queue segment ) segment sequence number ( , segment receive window ) RCV.NXT =< SEG.SEQ < RCV.NXT+RCV.WND RCV.NXT =< SEG.SEQ+SEG.LEN-1 < RCV.NXT+RCV.WND Segment length receive window size 0 17 Sequence Numbers Initial Sequence Number (ISN) Selection host connection connection sequence number connection segment network , connection segment seq number segment TCP seq number connection crash memory seq number segment network seq number segment

ISN generator connection ISN bit 4micro ( ) 32bit clock ISN 4.55 ISN unique Segment Maximum Segment Lifetime (MSL) network MSL 4.55 18 Sequence Numbers Initial Sequence Number (ISN) Selection Connection seq number Initial send sequence number (ISS) TCP , initial receive sequence number (IRS) TCP SYN control bit segment ISN host seq number host ISN ack 1) 2) 3) 4) A A A A --> <-<--->

B B B B SYN my sequence number is X ACK your sequence number is X SYN my sequence number is Y ACK your sequence number is Y Step 2, 3 message 3 message seq number (3 way handshake) host SYN seq number connection segment , seq number ack 3 way handshake 19 Sequence Numbers Knowing When to Keep Quiet Network seq number TCP MSL seq number connection , memory crash seq number MSL TCP seq number seq number RFC 793 MSL 2

The TCP Quiet Time Concept Quiet Time Restriction seq number MSL TCP data data , data data 20 Sequence Numbers The TCP Quiet Time Concept Duplicate detection and sequencing algorithm Segment data sequence space unique binding seq number data TCP ack , data network seq number TCP , seq number data Seq number TCP seq number seq number ack seq number duplicate data network Network duplicate data sequence space (32 bits) 2Mbps 232 seq number 4.5

MSL , network 100Mbps seq number 5.4 , 21 Establishing A Connection TCP A TCP B CLOSED SYNSENT ESTABLISH ED SEQ=100 CTL=SYN 101 SEQ=300 ACK= CTL=SYN,ACK SEQ=101 ACK= 301 CTL=ACK SEQ=101 ACK= 301 CTL=ACK DATA

LISTEN SYNRECEIVED ESTABLISHE D Basic 3-way handshake TCP A ISN 100 SYN TCP B SYN ACK SYN ACK field sequence 101 sequence 100 SYN TCP A SYN ACK TCP A data ACK sequence space ACK seq number 22 Establishing A Connection TCP A TCP B CLOSED SYNSENT SYNRECEIVED

ESTABLISH ED CLOSED SYN SEQ=300 CTL= SEQ=1 0 CTL=S 0 YN SEQ=100 ACK= 301 CTL=SYN,ACK 101 SEQ=300 ACK= CTL=SYN,ACK SEQ=101 ACK= 301 CTL= SYN-SENT SYNRECEIVED ACK ESTABLISHE D Simultaneous Connection Synchronization TCP CLOSED SYN-SENT SYN-RECEIVED

ESTABLISHED SYN-SENT SYN ack SYNRECEIVED SYN ack RFC 793 , SYN ack case 23 Establishing A Connection TCP A CLOSED SYNSENT ESTABLISH ED TCP B SE CT Q = 1 L= 00 SY N SEQ CTL =90 =S YN 91

SEQ=300 ACK= CTL=SYN,ACK SEQ=91 CTL= RST 101 SEQ=400 ACK= CTL=SYN,ACK SEQ=101 ACK= 401 CTL=ACK Recovery from Old Duplicate SYN LISTEN SYNRECEIVED LISTEN SYNRECEIVED ESTABLISHE D LISTEN TCP B TCP A duplicate SYN TCP B SYN duplicate TCP B SYN, ACK TCP A TCP B ACK RST seq number ACK TCP A SYN TCP B TCP A SYN RST TCP B TCP B RST

24 Establishing A Connection Half-Open Connections Connection open TCP TCP close abort Memory crash TCP sync data data connection reset Reset connection abort Process A B A TCP crash B A crash OS recovery TCP A , crash OPEN SEND SEND local TCP connection not open error message A connection SYN , B data 25 Establishing A Connection TCP A (CRASH) CLOSED SYNSENT

(!!) TCP B (send 300, receive 100) SEQ=400 ESTABLISHE CTL=SYN D (??) SYN100 CTL=ACK RECEIVED SEQ=300 ACK= SEQ=100 CTL= RST SEQ=400 CTL=SYN Half-Open Connection Discovery (abort!!) CLOSED TCP B A segment seq number(400) window seq number ACK(100) TCP A ACK seq number ACK connection sync TCP A connection half-open RST TCP B connection abort TCP A connection basic 3-way handshake

26 Establishing A Connection TCP A TCP B (CRASH) (??) 100 DATA=10 SEQ=300 ACK= CTL=ACK (send 300, receive 100) ESTABLISHE D SEQ=100 CTL= RST (abort!!) Active Side Causes Half-Open Connection Discovery TCP A crash TCP B data TCP A connection RST RST TCP B connection abort

27 Establishing A Connection TCP A LISTEN (??) TCP B SEQ =Z C TL= S LISTEN YN 1 CTL=SYN,ACK SEQ=X ACK=Z+ SYNRECEIVED SEQ=Z+1 CTL= RST (return to LISTEN!) LISTEN

Old Duplicate SYN TCP A B SYN LISTEN duplicate SYN TCP B SYN, ACK TCP A TCP A TCP B ACK RST TCP B RST LISTEN 28 Establishing A Connection Reset Generation RST generation and processing connection segment RST RST States for Reset 1. Connection (CLOSED) reset segment reset , connection SYN reject segment ACK field reset segment seq number ACK number segment ACK field reset segment seq number 0, ack number seq number + data connection CLOSED 29 Establishing A Connection

States for Reset 2. Connection non-synchronized (LISTEN, SYN-SENT, SYNRECEIVED) segment reset SYN ack , segment precedence level precedence level Precedence level TCP local TCP precedence level ( segment ) connection SYN ack ( segment ack )

(TCP user system ) local precedence level Reset SYN ack , segment precedence level precedence level segment ack seq number connection security level, compartment segment segment local precedence level reset segment ACK field reset segment seq number ACK segment ACK field reset segment seq number 0, ack number seq number + data connection 30 Establishing A Connection States for Reset 3. Connection synchronized (ESTABLISHED, FINWAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT)

segment (seq number window , ack number ) ACK segment ACK seq number seq number, ack number ack number Connection segment security level, compartment, precedence level, compartment, precedence reset Connection CLOSED Reset segment seq number segment ack number 31 Establishing A Connection Reset Processing Reset reset SYN-SENT RST segment Reset segment seq field window reset

SYN-SENT RST segment RST SYN ACK field reset reset connection LISTEN reset SYN-RECEIVED LISTEN LISTEN connection abort CLOSED Connection abort user CLOSED 32 Closing A Connection CLOSE operation data TCP CLOSE user CLOSE RECEIVE TCP CLOSE (user RECEIVE ) TCP user TCP CLOSE , user connection TCP connection CLOSE user data Close Case 1: Local user initiates the close TCP FIN segment queue

user SEND (RECEIVE ) TCP FIN-WAIT-1 FIN segment FIN segment ack Remote TCP local TCP FIN ack remote FIN local TCP remote FIN ack FIN TCP ack , FIN user CLOSE 33 Closing A Connection Close Case 2: TCP receives a FIN from the network TCP ( ) FIN ack user CLOSE user TCP CLOSE TCP queue data FIN FIN TCP ack , connection User timeout ack connection abort user Close Case 3: Both users close simultaneously Connection user CLOSE FIN segment FIN segment ack TCP FIN ack ack connection

34 Closing A Connection TCP A ESTABLISH ED (Close) FIN-WAIT1 FIN-WAIT-2 TIME-WAIT (2 MSL) CLOSED TCP B SEQ=100 A CK=300 CTL=FIN,A CK CLOSING TIME-WAIT (2 MSL) CLOSED CLOSE-WAIT 101 CTL=ACK SEQ=300 ACK= (Close)

101 SEQ=300 ACK= CTL=FIN,ACK SEQ=101 ACK= 301 CTL=ACK LAST-ACK CLOSED Normal Close Sequence TCP A ESTABLISH (Close) ED FIN-WAIT-1 ESTABLISHE D TCP B 100 SEQ=300 ACK= K SEQ= CTL=FIN,AC 1 CTL= 00 ACK=3 FIN,A 00

CK 101 CTL=ACK SEQ=301 ACK= SEQ= 101 A CK=3 CTL= 01 ACK Simultaneous Close Sequence 35 ESTABLISH (Close) ED CLOSING TIME-WAIT (2 MSL) CLOSED Precedence and Security RFC 793 IP Security/Compartment Security compartment connection port level precedence TCP precedence security parameter IP

TCP spec. (RFC 793) security/compartment IP security parameter (security, compartment, user group, handling restriction ) Rejecting a connection Security/compartment precedence reset precedence SYN ack Sending security parameters Non-secure network security parameter non-secure network host security parameter Security parameter 36 Data Communication Data Transmission Error (checksum error), network congestion segment segment TCP segment Network segment Seq number ack number segment

SND.NXT (sender): sequence number Sender segment RCV.NXT (receiver): sequence number Receiver segment ack SND.UNA (sender): ack sequence number Sender ack data ack data flow , Communication segment data length ESTABLISHED segment ack User CLOSE , TCP FIN segment push function 37 Data Communication Retransmission Timeout Retransmission timeout Internetwork network , TCP

The Communication of Urgent Information TCP urgent mechanism user user data urgent data urgent data user TCP user End of urgent information pointer TCP pointer receive seq number (RCV.NXT) user urgent mode seq number pointer TCP user normal mode User urgent mode pointer update user Urgent field TCP header URG control flag segment seq number urgent field urgent pointer URG flag urgent data Push function urgent data 38 Data Communication Managing the Window Window field Data seq number connection buffer size data Window size , network TCP Window size

Shrinking the window TCP window size window , Robustness principle TCP window size TCP window size Zero size window TCP send window size 0 1 octet data user Window size 0 2 0 size window TCP window size 0 segment seq number window size (0) ack 39 Data Communication Managing the Window Data packaging TCP data window size segment packaging Retransmission queue segment packaging

Identical sequence numbers data connection ack segment seq number Network ack , window size window size data Ack number segment 40 References RFC 793: TRANSMISSION CONTROL PROTOCOL IETF Sep. 1981 TCP/IP ( ) Charles M. Kozierok ( ) 2006 1 41

Recently Viewed Presentations

  • Principles of criminal liability - Teaching With Crump!

    Principles of criminal liability - Teaching With Crump!

    Principles of criminal liability The three offences under the Offences Against the Person Act 1861 Lesson Objectives I will be able to describe, using authority, the actus reus and mens rea of s47, s20 and s18 of the Offences Against...
  • Presentation Deck Beneficial Ownership What Constitutes a Triggering

    Presentation Deck Beneficial Ownership What Constitutes a Triggering

    A financial institution must update customer information, to include beneficial ownership information, when it detects information about the customer in the course of its normal monitoring that is relevant to assessing or reevaluating the risk posed by the customer.
  • Title of chapter 1 - (MBA)-Human Resource Management

    Title of chapter 1 - (MBA)-Human Resource Management

    Variable costing (also called direct costing or marginal costing) treats only those costs of production that vary with output as product costs. This approach dovetails with the contribution approach income statement and supports CVP analysis because of its emphasis on...
  • Climate and Change 1 - Earth Geography

    Climate and Change 1 - Earth Geography

    Sources of evidence for climate change taken from tree, sediment, ice & coral cores. www.epa.gov www.epa.gov Ice cover in the last Ice Age A glacial period (or alternatively glacial or glaciation) is an interval of time (thousands of years) within...
  • Create your own WW2 propaganda poster that is

    Create your own WW2 propaganda poster that is

    Write five interesting facts about the Battle of Britain. Lets see how many different ones we have as a class! Draw and label the uniform that an RAF or Luftwaffe pilot would have worn in the battle. Battle of Britain...
  • Certification Overview

    Certification Overview

    Board of Canadian Registered Safety Professionals (BCRSP) National Certification Body 1976 - Consumer & Corporate Affairs (Letters Patent) Governing Board (15 CRSPs elected by members) Accountable to the Federal government and membership (CRSPs) Responsible for evaluation, examination (CRSPEX), registration, discipline,...
  • Organizational Structure - Google Sites

    Organizational Structure - Google Sites

    Organizational Structures ... selective expertise Board of Directors their Job Establish polices for company Review performance of CEO Approve annual budget Set salaries and compensation of company management Organizational Chart You are the President of "Colonel By Enterprises" and you...
  • Investing Today in Renewable Energy and Green Jobs Will Cost ...

    Investing Today in Renewable Energy and Green Jobs Will Cost ...

    "It is the intent of the Legislature that all replacement air-conditioning systems in residential applications be installed using energy-saving, quality installation procedures, including, but not limited to, equipment sizing analysis and duct inspection.