1.44k likes | 1.55k Views
Chapter 12. Transmission Control Protocol. Objectives. Upon completion you will be able to:. Be able to name and understand the services offered by TCP Understand TCP’s flow and error control and congestion control Be familiar with the fields in a TCP segment
E N D
Chapter 12 TransmissionControl Protocol Objectives Upon completion you will be able to: Be able to name and understand the services offered by TCP Understand TCP’s flow and error control and congestion control Be familiar with the fields in a TCP segment Understand the phases in a connection-oriented connection Understand the TCP transition state diagram Be able to name and understand the timers used in TCP Be familiar with the TCP options
CONTENTS PROCESS-TO-PROCESS COMMUNICATION TCP SERVICES NUMBERING BYTES FLOW CONTROL SILLY WINDOW SYNDROME ERROR CONTROL TCP TIMERS
CONTENTS (continued) CONGESTION CONTROL SEGMENT OPTIONS CHECKSUM CONNECTION STATE TRANSITION DIAGRAM TCP OERATION TCP PACKAGE
전송 계층(TCP)이 제공하는 기능 • 프로세스간 통신 개설(포트 번호 이용) • 전송 단계에서 흐름 제어 메커니즘 제공(슬라이딩 윈도우 프로토콜 이용) • 전송 단계에서 오류 제어 메커니즘 제공(응답 패킷, 시간-초과, 재전송 방식 이용) • 연결 지향의 신뢰성 있는 프로토콜
12.1 TCP SERVICES We explain the services offered by TCP to the processes at the application layer. The topics discussed in this section include: Process-to-Process Communication Stream Delivery Service Full-Duplex Communication Connection-Oriented Service Reliable Service
12.1 TCP 서비스 • TCP-대-IP
12.1 TCP 서비스 • 클라이언트/서버 통신에 필요한 사항 • 로컬 클라이언트 프로그램 • 원격 서버 프로그램 • 로컬 호스트 • 원격 호스트 포트번호 IP주소
12.1 TCP 서비스 • 포트 번호
12.1 TCP 서비스 • TCP에서 사용되는 잘 알려진 포트
Example 1 As we said in Chapter 11, in UNIX, the well-known ports are stored in a file called /etc/services. Each line in this file gives the name of the server and the well-known port number. We can use the grep utility to extract the line corresponding to the desired application. The following shows the ports for FTP. $ grep ftp /etc/services ftp-data 20/tcpftp-control 21/tcp
12.1 TCP 서비스 • 소켓 주소 • IP 주소와 포트 번호의 조합 • 종단간 연결 설정에 사용 • 클라이언트와 서버 소켓 주소 필요 • IP 헤더(IP 주소)와 TCP 헤더(포트 번호)에 들어있음
12.1 TCP 서비스 • 스트림 배달 서비스 • 전이중 서비스 • 연결 지향 서비스 • 신뢰성 서비스
12.1 TCP 서비스 • 스트림 배달
12.1 TCP 서비스 • 스트림 배달 서비스 • 송신 TCP • 송신 응용 프로그램으로부터 문자 스트림 수신(송신 버퍼 이용) • 적절한 크기인 세그먼트를 만들어 네트워크를 통하여 전송 • 수신 TCP • 세그먼트를 수신(수신 버퍼 이용) • 데이터를 추출하여 문자 스트림으로 수신 응용 프로그램에 전달
12.1 TCP 서비스 • 송신 버퍼와 수신 버퍼
12.1 TCP 서비스 • TCP 세그먼트
12.1 TCP 서비스 • 전이중 서비스 • 동시에 양방향 전송 • 송신 데이터와 수신 데이터에 대한 확인 응답을 함께 보내는 피기백킹(piggybacking) • 연결-지향 서비스 • TCP는 연결지향 프로토콜 • 물리적 연결이 아닌 가상의 연결 • 요청→승인 → 데이터 교환 → 해제 순으로 진행 • 신뢰성 서비스 • 확인 응답 메커니즘 이용
12.2 TCP FEATURES To provide the services mentioned in the previous section, TCP has several features that are briefly summarized in this section. The topics discussed in this section include: Numbering System Flow Control Error ControlCongestion Control
12.2 바이트 순서 Note: The bytes of data being transferred in each connection are numbered by TCP. The numbering starts with a randomly generated number.
Example 2 Suppose a TCP connection is transferring a file of 5000 bytes. The first byte is numbered 10001. What are the sequence numbers for each segment if data is sent in five segments, each carrying 1000 bytes? SolutionThe following shows the sequence number for each segment: Segment 1➡ Sequence Number: 10,001 (range: 10,001 to 11,000) Segment 2➡ Sequence Number: 11,001 (range: 11,001 to 12,000) Segment 3➡ Sequence Number: 12,001 (range: 12,001 to 13,000) Segment 4➡ Sequence Number: 13,001 (range: 13,001 to 14,000) Segment 5 ➡ Sequence Number: 14,001 (range: 14,001 to 15,000)
12.2 바이트 순서 Note: The value in the sequence number field of a segment defines the number of the first data byte containedin that segment.
12.2 바이트 순서 • 확인응답번호 Note: The value of the acknowledgment field in a segment defines the number of the next byte a party expects to receive. The acknowledgment number is cumulative.
12.2 바이트 순서 • 흐름 제어 • 데이터 수신측은 송신측에서 전송할 데이터양 제어 • 오류 제어 • 신뢰성 있는 서비스를 제공하기 위해 오류 제어 메커니즘 구현 • 혼잡 제어 • 망의 혼잡을 고려하여 데이터양을 수신측에서 조절
12.3 SEGMENT A packet in TCP is called a segment The topics discussed in this section include: Format Encapsulation
12.3 세그먼트 • TCP 세그먼트 형태 • TCP를 이용하여 두 개의 장치간에 전달되는 데이터 단위
12.3 세그먼트 • 세그먼트 • 발신지 포트 번호(source port address) : 전송 호스트 응용 프로그램의 포트 번호 • 목적지 포트 번호(destination port address) : 수신 호스트 응용 프로그램의 포트 번호 • 순서 번호(sequence number) : 세그먼트에 포함된 데이터의 첫번째 바이트에 부여된 번호 • 확인 응답 번호(acknowledgement number) : 상대방 노드로부터 수신하고자 하는 바이트의 번호 • 헤더길이(header length) : TCP 헤더 길이의 4바이트 워드 값 • 제어(control) : 제어 또는 플래그
12.3 세그먼트 • 제어 필드
12.3 세그먼트 • 세그먼트(계속) • 윈도우 크기(window size) : 상대방이 유지해야 하는 바이트 단위의 윈도우 크기 • 검사합(checksum) : 오류 제어 • 긴급 포인터(urgent pointer) : 긴급 데이터 • 옵션(option) : 옵션 정보
12.3 세그먼트 • Pseudoheader added to the TCP datagram
12.3 세그먼트 Note: The inclusion of the checksum in TCP is mandatory.
12.3 세그먼트 • Encapsulation and decapsulation
12.4 A TCP CONNECTION TCP is connection-oriented. A connection-oriented transport protocol establishes a virtual path between the source and destination. All of the segments belonging to a message are then sent over this virtual path. A connection-oriented transmission requires three phases: connection establishment, data transfer, and connection termination. The topics discussed in this section include: Connection Establishment Data Transfer Connection Termination Connection Reset
12.4 연결 • TCP : 연결-지향 프로토콜 • 발신지와 목적지 간에 가상 경로 설정 • 연결 설정과 연결 종료를 통하여 이루어짐
12.4 연결 • 연결 설정 • 4 단계 수행 • 호스트 A는 호스트 B에게 연결 설정 세그먼트를 전송(초기화 정보) • 호스트 B는 호스트 A에게 확인응답 세그먼트 전송 • 호스트 B는 호스트 A에게 초기화 정보 세그먼트 전송 • 호스트 A는 호스트 B에게 확인응답 세그먼트 전송
12.4 연결 • 3 단계 핸드쉐이크(three-wayhandshaking)
12.4 연결 Note: A SYN segment cannot carry data, but it consumes one sequence number.
12.4 연결 Note: A SYN + ACK segment cannot carry data, but does consume onesequence number.
12.4 연결 Note: An ACK segment, if carrying no data, consumes no sequence number.
12.4 연결 • Data transfer
12.4 연결 Note: The FIN segment consumes one sequence number if it does not carry data.
12.4 연결 • Connection termination using three-way handshaking
Note: The FIN + ACK segment consumes one sequence number if it does not carry data. 12.4 연결
12.4 연결 • Half-close
12.5 STATE TRANSITION DIAGRAM To keep track of all the different events happening during connection establishment, connection termination, and data transfer, the TCP software is implemented as a finite state machine. . The topics discussed in this section include: Scenarios
12.5 상태 천이 다이어그램 • 유한 상태 기기(finite state machine) 이용 구현 • TCP 상태
12.5 상태 천이 다이어그램 • 상태 천이 다이어그램
12.5 상대 천이 다이어그램 • 상태 천이 다이어그램 • 상태(state) : 타원형 • 한 상태에서 다른 상태로의 천이 : 지시선 • 사선으로 나누어지는 두 개의 문자열 • 첫번째 열 : TCP가 수신하는 입력 • 두번째 열 : TCP가 전송하는 출력 • 점선 : 서버 • 실선 : 클라이언트 • 가는선 : 비 정상적인 상황
12.5 상태 천이 다이어그램 • Common scenario