HANNAM UNIVERSITY Http://netwk.hannam.ac.kr 1 Chapter 12 Upon completion you will be able to:...

Post on 20-Jan-2016

214 views 0 download

Transcript of HANNAM UNIVERSITY Http://netwk.hannam.ac.kr 1 Chapter 12 Upon completion you will be able to:...

1HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Chapter 12Chapter 12

Upon completion you will be able to:

TransmissionTransmissionControl ProtocolControl Protocol

• 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

Objectives

2HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

CONTENTSCONTENTS

• PROCESS-TO-PROCESS COMMUNICATION• TCP SERVICES• NUMBERING BYTES• FLOW CONTROL• SILLY WINDOW SYNDROME• ERROR CONTROL• TCP TIMERS

3HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

CONTENTS CONTENTS (continued)(continued)

• CONGESTION CONTROL• SEGMENT• OPTIONS• CHECKSUM• CONNECTION• STATE TRANSITION DIAGRAM• TCP OERATION• TCP PACKAGE

4HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

TCP/IP TCP/IP 프로토콜에서 프로토콜에서 TCPTCP 의 위치의 위치

5HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

전송 계층전송 계층 ((TCP)TCP) 이 제공하는 기능이 제공하는 기능

프로세스간 통신 개설 ( 포트 번호 이용 )

전송 단계에서 흐름 제어 메커니즘 제공 (

슬라이딩 윈도우 프로토콜 이용 )

전송 단계에서 오류 제어 메커니즘 제공 ( 응답

패킷 , 시간 - 초과 , 재전송 방식 이용 )

연결 지향의 신뢰성 있는 프로토콜

6HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.1 TCP SERVICES

We explain the services offered by TCP to the processes at the We explain the services offered by TCP to the processes at the application layer.application layer.

The topics discussed in this section include:The topics discussed in this section include:

Process-to-Process CommunicationProcess-to-Process CommunicationStream Delivery ServiceStream Delivery ServiceFull-Duplex CommunicationFull-Duplex CommunicationConnection-Oriented ServiceConnection-Oriented ServiceReliable ServiceReliable Service

7HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

TCP- 대 -IP

12.1 TCP 서비스

8HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

클라이언트 / 서버 통신에 필요한 사항

로컬 클라이언트 프로그램

원격 서버 프로그램

로컬 호스트

원격 호스트

포트번호

IP 주소

12.1 TCP 서비스

9HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

포트 번호

12.1 TCP 서비스

10HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

TCP 에서 사용되는 잘 알려진 포트

12.1 TCP 서비스

11HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

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.

Example 1

$ grep ftp /etc/services

ftp-data 20/tcpftp-control 21/tcp

12HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

소켓 주소IP 주소와 포트 번호의 조합

종단간 연결 설정에 사용

클라이언트와 서버 소켓 주소 필요

IP 헤더 (IP 주소 ) 와 TCP 헤더 ( 포트 번호 ) 에

들어있음

12.1 TCP 서비스

13HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

스트림 배달 서비스

전이중 서비스

연결 지향 서비스

신뢰성 서비스

12.1 TCP 서비스

14HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

스트림 배달

12.1 TCP 서비스

15HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

스트림 배달 서비스송신 TCP

송신 응용 프로그램으로부터 문자 스트림 수신 ( 송신 버퍼 이용 )

적절한 크기인 세그먼트를 만들어 네트워크를 통하여 전송

수신 TCP 세그먼트를 수신 ( 수신 버퍼 이용 ) 데이터를 추출하여 문자 스트림으로 수신 응용 프로그램에

전달

12.1 TCP 서비스

16HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

송신 버퍼와 수신 버퍼

12.1 TCP 서비스

17HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

TCP 세그먼트

12.1 TCP 서비스

18HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

전이중 서비스동시에 양방향 전송송신 데이터와 수신 데이터에 대한 확인 응답을

함께 보내는 피기백킹 (piggybacking) 연결 - 지향 서비스

TCP 는 연결지향 프로토콜물리적 연결이 아닌 가상의 연결요청→승인 → 데이터 교환 → 해제 순으로 진행

신뢰성 서비스확인 응답 메커니즘 이용

12.1 TCP 서비스

19HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.2 TCP FEATURES

To provide the services mentioned in the previous section, TCP has To provide the services mentioned in the previous section, TCP has several features that are briefly summarized in this section. several features that are briefly summarized in this section.

The topics discussed in this section include:The topics discussed in this section include:

Numbering System Numbering System Flow ControlFlow ControlError ControlError ControlCongestion ControlCongestion Control

20HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.2 2 바이트 순서바이트 순서

The bytes of data being transferred in each connection are numbered by TCP. The numbering starts with a randomly

generated number.

Note:Note:

21HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

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?

Example 2

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)

22HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The value in the sequence number field of a segment defines the number

of the first data byte containedin that segment.

Note:Note:

12.12.2 2 바이트 순서바이트 순서

23HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.2 2 바이트 순서바이트 순서 확인응답번호

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.

Note:Note:

24HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

흐름 제어데이터 수신측은 송신측에서 전송할 데이터양

제어 오류 제어

신뢰성 있는 서비스를 제공하기 위해 오류 제어 메커니즘 구현

혼잡 제어망의 혼잡을 고려하여 데이터양을 수신측에서

조절

12.12.2 2 바이트 순서바이트 순서

25HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.3 SEGMENT

A packet in TCP is called a segmentA packet in TCP is called a segment

The topics discussed in this section include:The topics discussed in this section include:

FormatFormatEncapsulationEncapsulation

26HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.3 3 세그먼트세그먼트

TCP 세그먼트 형태TCP 를 이용하여 두 개의 장치간에 전달되는 데이터

단위

27HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.3 12.3 세그먼트세그먼트

세그먼트 발신지 포트 번호 (source port address) : 전송 호스트 응용

프로그램의 포트 번호 목적지 포트 번호 (destination port address) : 수신 호스트 응용

프로그램의 포트 번호 순서 번호 (sequence number) : 세그먼트에 포함된 데이터의

첫번째 바이트에 부여된 번호 확인 응답 번호 (acknowledgement number) : 상대방

노드로부터 수신하고자 하는 바이트의 번호 헤더길이 (header length) : TCP 헤더 길이의 4 바이트 워드 값 제어 (control) : 제어 또는 플래그

28HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.3 3 세그먼트세그먼트

제어 필드

29HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.3 3 세그먼트세그먼트

30HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.3 3 세그먼트세그먼트

세그먼트 ( 계속 )윈도우 크기 (window size) : 상대방이 유지해야

하는 바이트 단위의 윈도우 크기

검사합 (checksum) : 오류 제어

긴급 포인터 (urgent pointer) : 긴급 데이터

옵션 (option) : 옵션 정보

31HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Pseudoheader added to the TCP

datagram

12.12.3 3 세그먼트세그먼트

32HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The inclusion of the checksum in TCP is mandatory.

Note:Note:

12.12.3 3 세그먼트세그먼트

33HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.3 3 세그먼트세그먼트

Encapsulation and decapsulation

34HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.4 A TCP CONNECTION

TCP is connection-oriented. A connection-oriented transport protocol TCP is connection-oriented. A connection-oriented transport protocol establishes a virtual path between the source and destination. All of the 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 segments belonging to a message are then sent over this virtual path. A connection-oriented transmission requires three phases: connection connection-oriented transmission requires three phases: connection establishment, data transfer, and connection termination.establishment, data transfer, and connection termination.

The topics discussed in this section include:The topics discussed in this section include:

Connection EstablishmentConnection EstablishmentData TransferData TransferConnection TerminationConnection TerminationConnection ResetConnection Reset

35HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.4 4 연결연결

TCP : 연결 - 지향 프로토콜

발신지와 목적지 간에 가상 경로 설정

연결 설정과 연결 종료를 통하여 이루어짐

36HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.4 4 연결연결

연결 설정4 단계 수행

1)호스트 A 는 호스트 B 에게 연결 설정 세그먼트를 전송( 초기화 정보 )

2)호스트 B 는 호스트 A 에게 확인응답 세그먼트 전송

3)호스트 B 는 호스트 A 에게 초기화 정보 세그먼트 전송

4)호스트 A 는 호스트 B 에게 확인응답 세그먼트 전송

37HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.4 4 연결연결

3 단계 핸드쉐이크 (three-way handshaking)

38HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

A SYN segment cannot carry data, but it consumes one sequence number.

Note:Note:

12.12.4 4 연결연결

39HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

A SYN + ACK segment cannot carry data, but does consume one

sequence number.

Note:Note:

12.12.4 4 연결연결

40HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

An ACK segment, if carrying no data, consumes no sequence number.

Note:Note:

12.12.4 4 연결연결

41HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.4 4 연결연결 Data transfer

42HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The FIN segment consumes one sequence number if it does not carry

data.

Note:Note:

12.12.4 4 연결연결

43HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.4 4 연결연결 Connection termination using three-way

handshaking

44HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The FIN + ACK segment consumes one sequence number if it does not

carry data.

Note:Note:

12.12.4 4 연결연결

45HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.4 4 연결연결

Half-close

46HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.5 STATE TRANSITION DIAGRAM

To keep track of all the different events happening during connection To keep track of all the different events happening during connection establishment, connection termination, and data transfer, the TCP establishment, connection termination, and data transfer, the TCP software is implemented as a finite state machine. . software is implemented as a finite state machine. .

The topics discussed in this section include:The topics discussed in this section include:

ScenariosScenarios

47HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램

유한 상태 기기 (finite state machine) 이용 구현 TCP 상태

48HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램

상태 천이 다이어그램

49HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상대 천이 다이어그램상대 천이 다이어그램

상태 천이 다이어그램상태 (state) : 타원형한 상태에서 다른 상태로의 천이 : 지시선사선으로 나누어지는 두 개의 문자열

1)첫번째 열 : TCP 가 수신하는 입력2)두번째 열 : TCP 가 전송하는 출력

점선 : 서버실선 : 클라이언트가는선 : 비 정상적인 상황

50HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램 Common scenario

51HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The common value for MSL is between 30 seconds and 1 minute.

Note:Note:

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램

52HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램 Three-way handshake

53HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램 Simultaneous

open

54HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램 Simultaneous

close

55HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램 Denying a

connection

56HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.5 5 상태 천이 다이어그램상태 천이 다이어그램 Aborting a

connection

57HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.6 FLOW CONTROL

Flow control regulates the amount of data a source can send before Flow control regulates the amount of data a source can send before receiving an acknowledgment from the destination. TCP defines a receiving an acknowledgment from the destination. TCP defines a window that is imposed on the buffer of data delivered from the window that is imposed on the buffer of data delivered from the application program. application program.

The topics discussed in this section include:The topics discussed in this section include:

Sliding Window ProtocolSliding Window ProtocolSilly Window SyndromeSilly Window Syndrome

58HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.6 6 흐름 제어흐름 제어 Sliding window

59HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

A sliding window is used to make transmission more efficient as well as to control the flow of data so that the

destination does not become overwhelmed with data.

TCP’s sliding windows are byte oriented.

Note:Note:

12.12.6 6 흐름 제어흐름 제어

60HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

What is the value of the receiver window (rwnd) for host A if the receiver, host B, has a buffer size of 5,000 bytes and 1,000 bytes of received and unprocessed data?

Example 3

SolutionThe value of rwnd = 5,000 − 1,000 = 4,000. Host B can receive only 4,000 bytes of data before overflowing its buffer. Host B advertises this value in its next segment to A.

61HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

What is the size of the window for host A if the value of rwnd is 3,000 bytes and the value of cwnd is 3,500 bytes?

Example 4

SolutionThe size of the window is the smaller of rwnd and cwnd, which is 3,000 bytes.

62HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Figure 12.21 shows an unrealistic example of a sliding window. The sender has sent bytes up to 202. We assume that cwnd is 20 (in reality this value is thousands of bytes). The receiver has sent an acknowledgment number of 200 with an rwnd of 9 bytes (in reality this value is thousands of bytes). The size of the sender window is the minimum of rwnd and cwnd or 9 bytes. Bytes 200 to 202 are sent, but not acknowledged. Bytes 203 to 208 can be sent without worrying about acknowledgment. Bytes 209 and above cannot be sent.

Example 5

63HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.6 6 흐름 제어흐름 제어 Example 5

64HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

In Figure 12.21 the server receives a packet with an acknowledgment value of 202 and an rwnd of 9. The host has already sent bytes 203, 204, and 205. The value of cwnd is still 20. Show the new window.

Example 6

SolutionFigure 12.22 shows the new window. Note that this is a case in which the window closes from the left and opens from the right by an equal number of bytes; the size of the window has not been changed. The acknowledgment value, 202, declares that bytes 200 and 201 have been received and the sender needs not worry about them; the window can slide over them.

65HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.6 6 흐름 제어흐름 제어 Example 6

66HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

In Figure 12.22 the sender receives a packet with an acknowledgment value of 206 and an rwnd of 12. The host has not sent any new bytes. The value of cwnd is still 20. Show the new window.

Example 7

SolutionThe value of rwnd is less than cwnd, so the size of the window is 12. Figure 12.23 shows the new window. Note that the window has been opened from the right by 7 and closed from the left by 4; the size of the window has increased.

67HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.6 6 흐름 제어흐름 제어

Example 7

68HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

In Figure 12.23 the host receives a packet with an acknowledgment value of 210 and an rwnd of 5. The host has sent bytes 206, 207, 208, and 209. The value of cwnd is still 20. Show the new window.

Example 8

SolutionThe value of rwnd is less than cwnd, so the size of the window is 5. Figure 12.24 shows the situation. Note that this is a case not allowed by most implementations. Although the sender has not sent bytes 215 to 217, the receiver does not know this.

69HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.6 6 흐름 제어흐름 제어 Example 8

70HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

How can the receiver avoid shrinking the window in the previous example?

Example 9

SolutionThe receiver needs to keep track of the last acknowledgment number and the last rwnd. If we add the acknowledgment number to rwnd we get the byte number following the right wall. If we want to prevent the right wall from moving to the left (shrinking), we must always have the following relationship.

new ack + new rwnd ≥ last ack + last rwndor

new rwnd ≥ (last ack + last rwnd) − new ack

71HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

To avoid shrinking the sender window, the receiver must wait until more space

is available in its buffer.

Note:Note:

12.12.6 6 흐름 제어흐름 제어

72HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Some points about TCP’s sliding windows:

❏ The size of the window is the lesser of rwnd and cwnd. ❏ The source does not have to send a full window’s

worth of data.❏ The window can be opened or closed by the receiver, but should not be shrunk.❏ The destination can send an acknowledgment at any time as long as it does not result in a shrinking window.❏ The receiver can temporarily shut down the window; the sender, however, can always send a segment of one byte after the window is shut down.

Note:Note:

12.12.6 6 흐름 제어흐름 제어

73HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.7 ERROR CONTROL

TCP provides reliability using error control, which detects corrupted, TCP provides reliability using error control, which detects corrupted, lost, out-of-order, and duplicated segments. Error control in TCP is lost, out-of-order, and duplicated segments. Error control in TCP is achieved through the use of the checksum, acknowledgment, and time-achieved through the use of the checksum, acknowledgment, and time-out. out.

The topics discussed in this section include:The topics discussed in this section include:

ChecksumChecksumAcknowledgmentAcknowledgmentAcknowledgment TypeAcknowledgment TypeRetransmissionRetransmissionOut-of-Order Segments Out-of-Order Segments Some ScenariosSome Scenarios

74HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

ACK segments do not consume sequence numbers and are not

acknowledged.

Note:Note:

12.12.7 7 오류 제어오류 제어

75HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

In modern implementations, a retransmission occurs if the

retransmission timer expires or three duplicate ACK segments have arrived.

Note:Note:

12.12.7 7 오류 제어오류 제어

76HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

No retransmission timer is set for an ACK segment.

Note:Note:

12.12.7 7 오류 제어오류 제어

77HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Data may arrive out of order and be temporarily stored by the receiving TCP, but TCP guarantees that no out-of-order

segment is delivered to the process.

Note:Note:

12.12.7 7 오류 제어오류 제어

78HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어

오류 감지 메커니즘훼손 세그먼트손실 세그먼트순서가 어긋난 세그먼트중복 세그먼트

오류 정정 메커니즘

79HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어

오류 발견과 정정오류 발견 도구 : 검사합 , 확인응답 , 시간 - 초과세그먼트의 검사합 필드 이용 훼손 여부 확인수신을 송신측에 알려주는 확인응답 이용시간 - 초과 전까지 확인응답 되지 않으면 훼손

또는 손실 간주오류 정정 : 시간 - 초과 카운터 이용 - 재전송

80HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어

훼손 세그먼트

81HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어

손실 세그먼트

82HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어

중복 세그먼트시간 - 초과 이전에 확인응답이 도착하지 않는 송신같은 순서번호를 가진 세그먼트는 폐기

순서가 잘못된 세그먼트데이터그램의 서로 다른 경로를 통한 전달로

인하여 발생이전의 세그먼트로 모두 수신하기까지 확인응답을

전송하지 않음시간 - 초과가 발생하면 세그먼트가 재전송 됨

83HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어

The receiver TCP delivers only ordered data to the process.

Note:Note:

84HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어

확인응답 손실

85HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어 Lost

acknowledgment

86HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.7 7 오류 제어오류 제어 Lost acknowledgment corrected by resending a

segment

87HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Lost acknowledgments may create deadlock if they are not properly

handled.

Note:Note:

12.12.7 7 오류 제어오류 제어

88HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.8 CONGESTION CONTROL

Congestion control refers to the mechanisms and techniques to keep the Congestion control refers to the mechanisms and techniques to keep the load below the capacity. load below the capacity.

The topics discussed in this section include:The topics discussed in this section include:

Network PerformanceNetwork PerformanceCongestion Control MechanismsCongestion Control MechanismsCongestion Control in TCPCongestion Control in TCP

89HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어

Router queues

90HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어

혼잡 (Congestion) 현상라우터가 패킷을 처리할 수 있는 속도보다 더 빨리

패킷을 수신하는 경우 발생

TCPTCP 는 손실 세그먼트의 원인이 망의 는 손실 세그먼트의 원인이 망의 혼잡에 기인한 것이라고 가정한다혼잡에 기인한 것이라고 가정한다 ..

91HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어 Packet delay and network load

92HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어 Throughput versus network load

93HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어

혼잡 윈도우 실제 윈도우 크기 = 최소 ( 수신측에서 알려주는 윈도우

크기 , 혼잡 윈도우 크기 )

혼잡회피 느린 시작 : 임계치 설정 ( 최대 윈도우 크기의 반 ),

임계치에 도달할 때까지 확인응답이 도착하면 지수형태로 윈도우 크기를 증가

가산증가 : 임계치까지 도달하면 , 확인응답이 도착하면 혼잡 윈도우 크기를 하나씩 증가

지수 감소 : 혼잡이 발생하면 임계치를 현재 윈도우 크기의 반으로 줄여서 느린 시작을 수행

94HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어

Slow start, exponential increase

95HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

In the slow start algorithm, the size of the congestion window increases exponentially until it reaches a

threshold.

Note:Note:

12.12.8 8 혼잡제어혼잡제어

96HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어 Congestion avoidance, additive increase

97HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

In the congestion avoidance algorithm the size of the congestion window

increases additively until congestion is detected.

Note:Note:

12.12.8 8 혼잡제어혼잡제어

98HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Most implementations react differently to congestion detection:

❏ If detection is by time-out, a new slow start phase starts.

❏ If detection is by three ACKs, a new congestion avoidance phase starts.

Note:Note:

12.12.8 8 혼잡제어혼잡제어

99HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어 TCP congestion policy summary

100HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.8 8 혼잡제어혼잡제어 Congestion

example

101HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.9 TCP TIMERS

To perform its operation smoothly, most TCP implementations use at To perform its operation smoothly, most TCP implementations use at least four timers. least four timers.

The topics discussed in this section include:The topics discussed in this section include:

Retransmission TimerRetransmission TimerPersistence TimerPersistence TimerKeepalive TimerKeepalive TimerTIME-WAIT TimerTIME-WAIT Timer

102HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.9 TCP 9 TCP 타이머타이머

TCP 타이머

103HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

In TCP, there can be only be one RTT measurement in progress at any time.

Note:Note:

12.12.9 TCP 9 TCP 타이머타이머

104HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Let us give a hypothetical example. Figure 12.38 shows part of a connection. The figure shows the connection establishment and part of the data transfer phases.

Example 10

1. When the SYN segment is sent, there is no value for RTTM , RTTS , or RTTD . The value of RTO is set to 6.00 seconds. The following shows the value of these variables at this moment:

RTTM = 1.5 RTTS = 1.5

RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5

2. When the SYN+ACK segment arrives, RTTM is measured and is equal to 1.5 seconds. The next slide shows the values of these variables:

105HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Example 10

RTTM = 1.5 RTTS = 1.5RTTD = 1.5 / 2 = 0.75 RTO = 1.5 + 4 . 0.75 = 4.5

3.When the first data segment is sent, a new RTT measurement starts. Note that the sender does not start an RTT measurement when it sends the ACK segment, because it does not consume a sequence number and there is no time-out. No RTT measurement starts for the second data segment because a measurement is already in progress.

RTTM = 2.5RTTS = 7/8 (1.5) + 1/8 (2.5) = 1.625RTTD = 3/4 (7.5) + 1/4 |1.625 − 2.5| = 0.78RTO = 1.625 + 4 (0.78) = 4.74

106HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.9 TCP 9 TCP 타이머타이머 Example 10

107HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

TCP does not consider the RTT of a retransmitted segment in its calculation of a new RTO.

Note:Note:

12.12.9 TCP 9 TCP 타이머타이머

108HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Figure 12.39 is a continuation of the previous example. There is retransmission and Karn’s algorithm is applied. The first segment in the figure is sent, but lost. The RTO timer expires after 4.74 seconds. The segment is retransmitted and the timer is set to 9.48, twice the previous value of RTO. This time an ACK is received before the time-out. We wait until we send a new segment and receive the ACK for it before recalculating the RTO (Karn’s algorithm).

Example 11

109HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.9 TCP 9 TCP 타이머타이머 Example 11

110HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.9 TCP 9 TCP 타이머타이머

재전송 타이머 (retransmission timer)재전송 시간 : 세그먼트 전송 후 확인응답을

기다리는 시간

타이머가 끝나기 전 확인응답이 수신되면 타이머 소멸

확인응답이 수신되기 전 타이머가 종료되면 해당 세그먼트는 재전송되고 타이머 초기화

재전송 시간 = 2 * RTT(round-trip time)

111HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.9 TCP 9 TCP 타이머타이머

Karn 알고리즘 전송된 세그먼트에 대해 확인 응답되지 않아 재전송된 경우 이전 세그먼트에 대한 확인응답인지 재전송에 대한

확인응답인지 여부 판단이 애매하다 RTT 값은 재전송 없이 확인응답 수신 전까지 변동이 없음

영속 타이머 (persistence timer) 윈도우 크기가 0 인 경우를 처리하기 위한 타이머 수신 TCP 가 윈도우 크기 0 을 통보했는데 , 송신 TCP 가

이에 대한 확인응답을 보냈지만 수신 TCP 가 이를 수신하지 못함

양쪽 TCP 가 서로 기다리는 교착상태 (deadlock) 해결

112HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.9 TCP 9 TCP 타이머타이머

Keepalive 타이머두 TCP 간에 설정된 연결이 오랫동안 휴지 (idle)

상태에 있는 것을 방지하기 위한 타이머시간 - 종료 : 2 시간2 시간이 지나도록 세그먼트를 수신하지 못하면 7

5 초 간격으로 10 개의 프루브 (probe) 전송응답이 없으면 다운으로 간주하고 연결 종료

시간 - 대기 타이머 (time-waited timer)연결 종료 동안에 사용

113HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.10 OPTIONS

The TCP header can have up to 40 bytes of optional information. The TCP header can have up to 40 bytes of optional information. Options convey additional information to the destination or align other Options convey additional information to the destination or align other options.options.

114HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션

옵션

115HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션

옵션 - 끝 (end of option)맨 끝에 패딩을 위해 사용되는 한 바이트 옵션

116HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

EOP can be used only once.

Note:Note:

12.12.10 10 옵션옵션

117HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션

무 동작 (no operation)맨 끝에 패딩을 위해 사용되는 한 바이트 옵션

118HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

NOP can be used more than once.

Note:Note:

12.12.10 10 옵션옵션

119HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션

최대 세그먼트 크기 (maximum segment size : MSS) 목적지에서 수신할 수 있는 데이터 세그먼트의 최대 크기 연결 설정 단계 중에 목적지에 의해 결정

120HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The value of MSS is determined during connection establishment and

does not change during the connection.

Note:Note:

12.12.10 10 옵션옵션

121HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션

윈도우 확장 인자 윈도우 크기를 증가시키기 위해 사용 새로운 윈도우 크기 = 헤더에서 정의된 윈도우 크기 Χ2 윈도우확장인자

최대 설정값 : 16 최대 윈도우 크기 : 216Χ216=232( 순서번호 값과 동일 )

122HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The value of the window scale factor can be determined only during

connection establishment; it does not change during the connection.

Note:Note:

12.12.10 10 옵션옵션

123HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션

타임 스탬프 (timestamp) 10 바이트 길이 옵션왕복시간 (round-trip time) 계산에 사용

124HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

One application of the timestamp option is the calculation of round trip

time (RTT).

Note:Note:

12.12.10 10 옵션옵션

125HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Figure 12.46 shows an example that calculates the round-trip time for one end. Everything must be flipped if we want to calculate the RTT for the other end.

Example 12

The sender simply inserts the value of the clock (for example, the number of seconds past from midnight) in the timestamp field for the first and second segment. When an acknowledgment comes (the third segment), the value of the clock is checked and the value of the echo reply field is subtracted from the current time. RTT is 12 s in this scenario.

126HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The receiver’s function is more involved. It keeps track of the last acknowledgment sent (12000). When the first segment arrives, it contains the bytes 12000 to 12099. The first byte is the same as the value of lastack. It then copies the timestamp value (4720) into the tsrecent variable. The value of lastack is still 12000 (no new acknowledgment has been sent). When the second segment arrives, since none of the byte numbers in this segment include the value of lastack, the value of the timestamp field is ignored. When the receiver decides to send an accumulative acknowledgment with acknowledgment 12200, it changes the value of lastack to 12200 and inserts the value of tsrecent in the echo reply field. The value of tsrecent will not change until it isreplaced by a new segment that carries byte 12200 (next segment).

Example 12

127HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Note that as the example shows, the RTT calculated is the time difference between sending the first segment and receiving the third segment. This is actually the meaning of RTT: the time difference between a packet sent and the acknowledgment received. The third segment carries the acknowledgment for the first and second segments.

Example 12

128HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션 Example 12

129HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The timestamp option can also be used for PAWS.

Note:Note:

12.12.10 10 옵션옵션

130HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션 SACK

131HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

Let us see how the SACK option is used to list out-of-order blocks. In Figure 12.48 an end has received five segments of data.

Example 13

The first and second segments are in consecutive order. An accumulative acknowledgment can be sent to report the reception of these two segments. Segments 3, 4, and 5, however, are out of order with a gap between the second and third and a gap between the fourth and the fifth. An ACK and a SACK together can easily clear the situation for the sender. The value of ACK is2001, which means that the sender need not worry about bytes 1 to 2000. The SACK has two blocks. The first block announces that bytes 4001 to 6000 have arrived out of order. The second block shows that bytes 8001 to 9000 have also arrived out of order. This means that bytes 2001 to 4000 and bytes 6001 to 8000 are lost or discarded. The sender can resend only these bytes.

132HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션 Example 13

133HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The example in Figure 12.49 shows how a duplicate segment can be detected with a combination of ACK and SACK. In this case, we have some out-of-order segments (in one block) and one duplicate segment. To show both out-of-order and duplicate data, SACK uses the first block, in this case, to show the duplicate data and other blocks to show out-of-order data. Note that only the first block can be used for duplicate data. The natural question is how the sender, when it receives these ACK and SACK values knows that the first block is for duplicate data (compare this example with the previous example). The answer is that the bytes in the first block are already acknowledged in the ACK field; therefore, this block must be a duplicate.

Example 14

134HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션 Example 14

135HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

The example in Figure 12.50 shows what happens if one of the segments in the out-of-order section is also duplicated. In this example, one of the segments (4001:5000) is duplicated. The SACK option announces this duplicate data first and then the out-of-order block. This time, however, the duplicated block is not yet acknowledged by ACK, but because it is part of the out-of-order block (4001:5000 is part of 4001:6000), it is understood by the sender that it defines the duplicate data.

Example 15

136HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.10 10 옵션옵션 Example 15

137HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.11 TCP PACKAGE

We present a simplified, bare-bones TCP package to simulate the heart We present a simplified, bare-bones TCP package to simulate the heart of TCP. The package involves tables called transmission control blocks, of TCP. The package involves tables called transmission control blocks, a set of timers, and three software modules.a set of timers, and three software modules.

The topics discussed in this section include:The topics discussed in this section include:

Transmission Control Blocks (TCBs)Transmission Control Blocks (TCBs)TimersTimersMain ModuleMain ModuleInput Processing ModuleInput Processing ModuleOutput Processing ModuleOutput Processing Module

138HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.112.11 TCP 1 TCP 설계설계

전송 제어 블록 (TCB : Transmission Control Block)

타이머 (Timer)

메인 모듈 (Main Module)

입력 프로세스 모듈 (Input Process Module)

출력 프로세스 모듈 (Output Process Module)

139HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.11 TCP 11 TCP 설계설계

TCP 설계

140HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.12.11 TCP 11 TCP 설계설계

전송 제어 블록 (TCB) 연결 제어에 대한 정보 보관

141HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.112.11 TCP 1 TCP 설계설계

전송 제어 블록 (TCB)상태 (state)

프로세스 (process)

로컬 IP 주소로컬 포트 번호원격지 IP 주소원격지 포트 번호인터페이스로컬 윈도우

142HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.112.11 TCP 1 TCP 설계설계

전송 제어 블록 (TCB)( 계속 )원격지 윈도우송신순서번호수신순서번호왕복 (round-trip) 시간시간 초과 값버퍼 크기버퍼 포인터

143HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

12.112.11 TCP 1 TCP 설계설계

타이머 TCP 동작을 처리하기 위한 여러 가지 타이머

메인 모듈 TCP 세그먼트 도착 시간 - 초과 이벤트 발생 응용 프로그램으로부터 메시지가 들어오는 경우

입력 처리 모듈 연결 설정 상태에서 수신하는 데이터나 확인응답을 처리하기

위해 필요한 기능담당 출력 처리 모듈

연결 설정 상태에서 응용 프로그램으로부터 수신한 데이터를 전송하기 위해 필요한 기능 담당

144HANNAM UNIVERSITYHttp://netwk.hannam.ac.kr

연습문제 풀이해서

Report 로 다음주까지 (일주일 후 )

제출해 주세요 !

알림알림