TCP (Transmission Control Protocol ) RFC 793 Transport Layer.

Презентация:



Advertisements
Похожие презентации
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Ensuring the Reliability of Data Delivery Establishing a TCP Connection.
Advertisements

TCP/IP Protocol Suite 1 Chapter 12 Upon completion you will be able to: Transmission Control Protocol Be able to name and understand the services offered.
Copyright 2003 CCNA 1 Chapter 9 TCP/IP Transport and Application Layers By Your Name.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Building a Simple Serial Network Understanding the OSI Model.
Copyright 2003 CCNA 2 Chapter 17 TCP/IP Suite Error and Control Messages By Your Name.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Module Summary In the OSI model, it is the transport layer that manages the reliability of.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Ensuring the Reliability of Data Delivery Understanding How UDP and TCP Work.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Connecting Networks Exploring the IP Packet Delivery Process.
© 2006 Cisco Systems, Inc. All rights reserved. BSCI v Configuring EIGRP Using EIGRP in an Enterprise Network.
© 2005 Cisco Systems, Inc. All rights reserved. INTRO v Module Summary TCP/IP is the most widely used networking protocol, with functions that can.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Operating and Configuring Cisco IOS Devices Configuring a Router.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Connecting Networks Understanding How TCP/IP Works.
Copyright 2003 By Your Name CCNA 3 Chapter 1 Review: The OSI Reference Model and Routing.
Copyright 2003 CCNA 3 Chapter 5 Switching Concepts By Your Name.
© 2006 Cisco Systems, Inc. All rights reserved. BSCI v Implementing BGP Explaining BGP Concepts and Terminology.
© 2006 Cisco Systems, Inc. All rights reserved. MPLS v MPLS Concepts Introducing MPLS Labels and Label Stacks.
Copyright 2003 CCNA 4 Chapter 20 CCNA Certification Exam Review By Your Name.
© 2005 Cisco Systems, Inc. All rights reserved. INTRO v Growing the Network Maximizing the Benefits of Switching.
© 2005 Cisco Systems, Inc. All rights reserved. BGP v BGP Overview Monitoring and Troubleshooting BGP.
2.1 Chapter 2 Network Models Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Транксрипт:

TCP (Transmission Control Protocol ) RFC 793 Transport Layer

TCP in TCP/IP Stack Media Access Control (Ethernet, Token Ring, FDDI, X.25, PPP, etc.) User Datagram Protocol (UDP) RFC 768 ~ connectionless transport ~ Transmission Control Protocol (TCP) RFC 793 ~ connection-oriented transport ~ Upper-Layer Protocols ~ such as SNMP, telnet, FTP, HTTP, POP3, etc. ~ Upper Transport Network Data Link ARP Internet Control Messaging Protocol (ICMP) RFC 792 Internet Protocol version 4 (IPv4) RFC 791 RARP

TCP Overview Byte-stream –app writes bytes –TCP sends segments –app reads bytes Point-to-point: –one sender, one receiver Connection-oriented Application process Write bytes TCP Send buffer Segment Transmit segments Application process Read bytes TCP Receive buffer … …… Full duplex Reliability Flow control: keep sender from overrunning receiver Congestion control: keep sender from overrunning network

Connection Establishment Active participant (client) Passive participant (server) SYN, Seq=100 ACK, Seq=101, Ack=1001 time SYNACK, Seq=1000, Ack=101 LISTEN (Passive open) SYN_RCVD SYN_SENT (Active open) ESTABLISHED

Connection Establishment TCP uses three-way handshake for reliable connection establishment and termination –Host 1 sends segment with SYN bit set and random sequence number –Host 2 responds with segment with SYN bit set acknowledgment to Host 1 and random sequence number –Host 1 responds with acknowledgment TCP will retransmit lost segments Random sequence numbers ensure synchronization between endpoints Each connection is full duplex

Connection Termination Time_wait =2MSL (maximum segment lifetime) */ На практике часто вместо последнего ACK передают RST или ACK,RST Тогда закрытие без ожидания 2MSL client FIN server ACK FIN Active closing Passive closing closed timed wait closed FIN_WAIT_1 CLOSE_WAIT LAST_ACK CLOSED TIME_WAIT

TCP Error Control Two types of errors: – Lost packets – Damaged packets Most Error Control techniques are based on: 1. Error Detection Scheme (Parity checks, CRC). 2. Retransmission Scheme. Error control schemes that involve error detection and retransmission of lost or corrupted packets are referred to as Automatic Repeat Request (ARQ) error control.

Lost packets TCP uses positive acknowledgment with retransmission to achieve reliable data delivery Recipient sends acknowledgment control messages (ACK) to sender to verify successful receipt of data Sender sets timer when data transmitted; if timer expires before acknowledgment arrives, sender retransmits (with new timer)

TCP client states

TCP server states

TCP Connection Management Modeling The states used in the TCP connection management finite state machine

State Transition Diagram for TCP

The TCP Segment Header CWRCWR ECEECE

Segment Format (2) Each connection identified with 4-tuple: –(SrcPort, SrcIPAddr, DstPort, DstIPAddr) Sliding window + flow control –acknowledgment, SequenceNum, AdvertisedWinow Flags –SYN, FIN, RESET, PUSH, URG, ACK Checksum –pseudo header + TCP header + data Sender Data(SequenceNum) Acknowledgment + AdvertisedWindow Receiver

TCP Flags URG (Urgent pointer field is significant) - Поле «Указатель важности» задействовано ACK (Acknowledgement field is significant) - Поле «Номер подтверждения» задействовано PSH (Push function) – получатель должен протолкнуть данные, накопившиеся в приемном буфере, в приложение пользователя RST (Reset the connection) Оборвать соединения, сбросить буфер (очистка буфера) SYN (Synchronize sequence numbers) - Синхронизация номеров последовательности FIN (Final) - флаг указывает на завершение соединения + новый RFC 3168 CWR (Congestion Window Reduced) - Поле «Окно перегрузки уменьшено» - флаг установлен отправителем, чтоб указать, что получен пакет с установленным флагом ECE ECE (ECN-Echo) - Поле «Эхо ECN» - указывает, что данный узел способен на ECN (явное уведомление перегрузки) и для указания отправителю о перегрузках в сети

The pseudoheader included in the TCP checksum

Options

Options(1) Maximum Segment Size Option This option is only used during the establishment of the connection (SYN control bit set) and is sent from the side that is to receive data to indicate the maximum segment length it can handle MSS = MTU – IPHeader – TCPHeader For Ethernet: 1500 – 20 – 20 = 1460 байт

Path MTU Discovery. Example. SYN mss = 1460 MTU is 552! I can send datagram with 512 bytes of data. Host 1 Host 2 Router 1 MTU = 1500 MTU = 552 MTU = 296 SYN, ACK mss = 512 1:513 (512) ACK 1:257(256) ACK Router: I cant send so big datagram without fragmentation. But DF bit is set => error occur! ICMP error message: Host 1 unreachable, need to frag, mtu = 296 (newer implementation routers TCP) My MSS now 256 (MTU = 296)

Window Scale Option (RFC1323) Option in their SYN segments to enable windows scaling in their direction. The Window Scale expands the definition of the TCP window to 32 bits. Time Stamps Option (RFC1323) The time stamps option sends a time stamp value that indicates the current value of the time stamp clock of the TCP sending the option. Options(2) bytes:

Options(3) SACK-Permitted Option This option is set when selective acknowledgment is used in that TCP connection (with SYN bit only) SACK Option Selective Acknowledgment (SACK) allows the receiver to inform the sender about all the segments which are received successfully. RFC

TCP Flow Control receive side of TCP connection has a receive buffer: speed-matching service: matching the send rate to the receiving apps drain rate app process may be slow at reading from buffer sender wont overflow receivers buffer by transmitting too much, too fast flow control

TCP sliding window TCP uses sliding window for flow control Receiver specifies window –Called window advertisement –Specifies which bytes in the data stream can be sent –Carried in segment along with ACK Sender can transmit any bytes, in any size segment, between last acknowledged byte and within window size

A 4-packet window sliding through outgoing data. The window is shown (a) when transmission begins, (b) after two packets have been acknowledged, (c) after eight packets have been acknowledged. The sender can transmit all packets in the window. TCP sliding window

TCP Congestion Control

Principles of Congestion Control Congestion: informally: too many sources sending too much data too fast for network to handle different from flow control! manifestations: –lost packets (buffer overflow at routers) –long delays (queueing in router buffers)

Stop-and-wait operation first packet bit transmitted, t = 0 senderreceiver RTT last packet bit transmitted, t = L / R first packet bit arrives last packet bit arrives, send ACK ACK arrives, send next packet, t = RTT + L / R

TCP Slow Start When connection begins, increase rate exponentially until first loss event: –double CongWin every RTT –done by incrementing CongWin for every ACK received Summary: initial rate is slow but ramps up exponentially fast Host A one segment RTT Host B time two segments four segments

Дополнительно - Модели реализации протокола TCP и его перспективы