1 / 35

TCP 프로토콜

TCP 프로토콜. 1999. 7. Transport Protocol(1/2) . end-to-end reliable 서비스의 필요성 지금까지의 IP 서비스는 네트워크의 각 노드에서 이루어지는 네트워크 계층 서비스이다 . IP 서비스는 unreliable network service 를 제공해 주고 있다 . no error control no congestion control duplicate packet delivery out-of-order packet delivery

umed
Download Presentation

TCP 프로토콜

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TCP 프로토콜 1999. 7

  2. Transport Protocol(1/2) • end-to-end reliable 서비스의 필요성 • 지금까지의 IP 서비스는 네트워크의 각 노드에서 이루어지는 네트워크 계층 서비스이다. • IP 서비스는 unreliable network service를 제공해 주고 있다. • no error control • no congestion control • duplicate packet delivery • out-of-order packet delivery • 따라서 응응 프로그램이 네트워크를 통해 전달된 데이터를 신뢰하고 처리하기 위해서는 transport 계층에서 신뢰성 있는 서비스를 제공해 주어야 한다. TCP Protocol

  3. Transport Protcol(2/2) Application Application End-to-end 서비스 TCP TCP IP IP IP Network access Network access Network access subnet subnet TCP Protocol

  4. TCP와 UDP • TCP • 연결형 방식 • 보장성 서비스 제공 • flow control • error control • congestion control • byte-oriented (stream-oriented) • UDP • 비연결형 방식 • 비보장성 서비스 제공 • datagram-oriented TCP Protocol

  5. TCP/IP 프로토콜 구조 Telnet SMTP BGP RIP FTP DNS SNMP TCP UDP IGMP ICMP OSPF IP RARP ARP TCP Protocol

  6. TCP 서비스 • 연결형 서비스 • 점대점 통신 • 보장형 서비스 • Full duplex 통신 • 스트림 전송 • Graceful 연결 해제 TCP Protocol

  7. TCP 보장성 서비스 • Segment 단위의 전송 • 타이머 관리 • ACK 전송 • Checksum • 순서 보장 • 중복 패킷 방지 • 흐름 제어(flow control) • 체증 제어(congestion control) TCP Protocol

  8. TCP 세그먼트 구성(1/2) 0 16 31 Source Port Destination Port Sequence Number Acknowledgement Number TCP Header Window Resv HLEN flag Checksum Urgent Pointer Options(있는 경우) Padding Data Data TCP Protocol

  9. TCP 세그먼트 구성(2/2) • TCP 세그먼트 • TCP에 의해 전송되는 기본 단위 • TCP 헤더 • 20 bytes의 고정 헤더 부분과 option field로 구성 • 4bytes로 정렬 • 따라서 option 필드가 4 bytes 단위가 아닐 경우 padding한다. • 가변 길이의 헤더는 헤더 길이 필드(HLEN)에 의해 표시 • 데이터 TCP Protocol

  10. TCP 헤더 필드 • source와 destination 포트 번호 • TCP 연결의 양 종단에 있는 응용 프로그램을 나타내는 포트 번호 • sequence 번호 • 세그먼트에 들어 있는 데이터가 응용 프로그램의 byte stream에서 어느 위치에 있는지를 표시한다. • ACK 번호 • 수신측에서 송신측으로부터 받은 세그먼트에 대한 응답 • 바로 다음에 받기를 기다리는 세그먼트의 byte 번호를 의미한다. TCP Protocol

  11. TCP 헤더 필드 • 헤더 길이 • 32 bits의 정수배로 계산된 세그먼트 헤더 길이를 나타내는 정수값 • 윈도우 크기(window size) • receiver의 입장에서 현재 자신의 가용 버퍼(availiable buffer)의 크기를 알려 준다. • 이것을 이용하여 양 종단 간의 flow control을 수행한다. • Checksum • pseudoheader TCP Protocol

  12. Pseudoheader 31 0 16 31 Source IP address pseudoheader Destination IP address zero Protocol id Segment 길이 TCP header TCP segment User Data TCP Protocol

  13. Flag • 세그먼트의 사용 목적을 나타낸다. Bit(좌측→우측) Bit가 1로 Set됐을 때를 의미 URG Urgent Pointer Field가 유효 ACK Acknowledgement Field가 유효 PSH 이 Segement는 Push를 Request RST Connection을 Reset SYN Sequence Number를 Synchronize FIN 송신측의 Byte Stream이 끝났음 TCP Protocol

  14. PSH와 URG flag • 데이터 스트림 push • 응용 프로그램(TCP 사용자)은 송수신측 TCP 모듈에게 세그먼트를 만들 때까지 기다리지 말고 지금의 데이터를 바로 전송하도록 한다. • 예를 들면, 프로그램의 abort나 interrupt signal을 송신할 경우에 쓰인다. • Urgent data signaling • 수신측 응용 프로그램에게 urgent data가 전송되었음을 알린다. • 이 데이터의 처리는 수신측 응용 프로그램의 처분에 달려 있다. • URG flag을 설정 • 세그먼트 내에서 urgent data가 끝나는 위치를 Urgent pointer로서 가리킨다. TCP Protocol

  15. Option 필드 • Maximum Segment Size(MSS) • Window Scale option • Timestamp option 연결 설정을 할 때 MTU MTU TCP Protocol

  16. appl appl appl appl Port(TSAP) TCP connection TCP TCP protocol IP IP IP SNAPA Network access Network access Network access subnet subnet TCP 연결(1/2) TCP Protocol

  17. TCP 연결(2/2) • TCP 종점 주소 • 두 가지 level로 나타내어 진다. • 네트워크 접속점 주소 • TCP 사용자 주소 • 네트워크 접속점 주소는 IP 호스트 주소가 된다. • 이 주소는 글로벌 인터넷에서 유일한 접속점을 나타낸다. • TCP 연결 identifier • <송신측 TCP 종점 주소, 수신측 TCP 종점 주소> • 즉 <송신측 IP 주소, 송신측 TCP 사용자 주소, 수신측 IP 주소, 수신측 TCP 사용자 주소> TCP Protocol

  18. TCP 포트 번호 • 포트 번호(port number) • TCP 혹은 UDP가 제공하는 서비스 즉 응용 프로그램을 나타낸다. • 포트 번호는 16 bits의 길이로 표시된다. • well-known 포트 번호 • 1 부터 1023번이 할당 • 일반적으로 이용되는 server를 나타낸다. • 예를 들면, FTP server는 21, Telnet server는 23등 • Internet Assigned Number Authority(IANA)에 의해 관리된다. • Ephemeral 포트 번호 • 1024 부터 5000번까지 • client 포트 번호 TCP Protocol

  19. initiator receiver SYN (seq = x) SYN (seq=y, ACK=x+1) SYN (seq=x+1, ACK=y+1) TCP 연결 설정 • 3-way handshake TCP Protocol

  20. client server FIN ACK FIN ACK TCP 연결 해제 TCP Protocol

  21. TCP 전송 방식(1/3) • stream-oriented • 데이터는 TCP 연결을 통해서 segment 단위로 전송한다. • 하지만 데이터는 stream of bytes로서 취급된다. • 따라서 모든 bytes는 번호가 붙여진다.(modulo 2**32) • sequence number 사용 • 모든 세그먼트는 sequence number를 갖는다. • 이 번호는 데이터에서 해당 세그먼트가 차지하는 위치의 byte 번호를 의미한다. TCP Protocol

  22. TCP 전송 방식(2/3) • 버퍼 사용 • 응용 프로그램으로부터 데이터를 받았을 때 송신측 TCP는 그것을 바로 세그먼트로 전송하지 않고 버퍼에 두었다가 일정 크기 이상이 되면 세그먼트로 만들어 전송한다. • 수신측 TCP도 세그먼트가 도착하였을 경우 이것을 바로 응용 프로그램에 전달하지 않고 버퍼에 보관하였다가 일정 크기가 될 때 이것을 응용 프로그램에 전달한다. • 물론 이것은 구현상에서 차이가 있을 수 있다. TCP Protocol

  23. TCP 전송 방식(3/3) • Flow control • credit allocation 방식 • Buffering • 데이터 push • 긴급 데이터 전송 TCP Protocol

  24. 재전송 Send segment 1 Receive segment 1 Send ACK 1 Receive ACK 1 Send segment 2 Receive segment 2 Send ACK 2 Receive ACK 2 Segment lost Send segment 3 Retransmission timer expires retransmit segment 3 TCP Protocol

  25. Flow Control 4k 0 2K seq=0 write 2K 2k Ack=2048, win=2048 2K seq=2048 write 3K Ack=4096, win=0 read 2K 2k Ack=4096, win=2048 1K seq=4096 Send 1K more 3k TCP Protocol

  26. Nagle’s algorithm • Telnet 전송의 예 41 bytes IP packets A keystroke arrive 40 bytes ACK Application read 1 byte of keystroke 40 bytes window update Application echoes it 41 bytes IP packets TCP Protocol

  27. Silly window syndrome과 Clark’s algorithm Receiver’s buffer is full Application read 1 byte Window update segment sent New byte arrives Receiver’s buffer is full TCP Protocol

  28. Retransmission Timer • RTT variance estimation • exponential RTO backoff • Karn’s algorithm RTP: retransmission timer SRTT(K+1) = (1-g) SRTT(K) + g RTT(K+1) SERR(K+1) = RTT(K+1) - SRTT(K) SDEV(K+1) = (1-h) SDEV(K) + h |SERR(K+1)| RTO(K+1) = SRTT(K+1) + f SDEV(K+1) TCP Protocol

  29. TCP congestion Control • Congestion detection • timeout • Congestion control • slow start • congestion avoidance • fast retransmit • fast recovery TCP Protocol

  30. Slow start • 두 가지 windows • receiver’s advertised window(awnd) • congestion window (cwnd) • initialize: • cwnd = 1 segment size • 매번 ACK을 받을 때 마다, • cwnd = cwnd + 1 until min(cwnd, awnd) • exponential growth TCP Protocol

  31. receiver sender Segment 1 Cwnd = 1 ACK 2 Cwnd = 2 Segment 2 Segment 3 ACK 3 Cwnd = 3 ACK 4 Cwnd = 4 Segment 4 ... Segment 7 ACK 5 ..... ACK 8 Cwnd = 8

  32. Congestion Avoidance • 새로운 파라메터 • slow start threshold size(ssthresh) • 패킷 손실이 발생하면 • 1. Set ssthresh = cwnd/2 • 2. Set cwnd = 1 그리고 cwnd=ssthresh 될 때 까지 slow start 절차 수행 • 3. When cwnd  ssthresh, cwnd는 왕복 지연 시간마다 1 세그먼트 씩 증가한다. TCP Protocol

  33. 20 Time out occurs 15 cwnd 10 Threshold 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Round-trip times slow start와 congestion avoidance TCP Protocol

  34. UDP • 단순함 • Datagram-oriented • one application data -> one UDP datagram • 비보장성 Application data UDP 헤더 Application data IP 헤더 8 bytes 20 bytes TCP Protocol

  35. UDP 헤더 16 0 31 dest port number source port number UDP 길이 UDP checksum TCP Protocol

More Related