Top Banner
Transport Protocols - TCP & UDP
36

Transport Protocols - TCP & UDP

Jan 03, 2016

Download

Documents

hedwig-phillips

Transport Protocols - TCP & UDP. Transport Protocols. The transport protocol provides an end-to-end data transfer service that shields upper-layer protocols from the details of the intervening network. Two types of transport service connection oriented, e.g. TCP - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Transport Protocols  - TCP & UDP

Transport Protocols - TCP & UDP

Page 2: Transport Protocols  - TCP & UDP

Transport Protocols• The transport protocol provides an end-to-

end data transfer service that shields upper-layer protocols from the details of the intervening network.

• Two types of transport service— connection oriented, e.g. TCP— connectionless (datagram), e.g. UDP

Page 3: Transport Protocols  - TCP & UDP

TCP

• Transmission Control Protocol• Connection-oriented• Guarantees reliable and in-order delivery of

data• Allow multiple concurrent TCP applications

in the same host.• Error detection, Error Correction, Flow

Control

Page 4: Transport Protocols  - TCP & UDP

TCP Header

FlagsFlags

Page 5: Transport Protocols  - TCP & UDP

Multiplexing in TCP

Use of- source port- destination port

Page 6: Transport Protocols  - TCP & UDP

TCP (and UDP) Port Numbers- Server

• Servers use well-known port numbers for their major applications.—Port 80 = HTTP—Ports 20, 21 = FTP

• Port 21 for supervisory information• Port 20 for file transfers

—Port 23 = Telnet—Port 25 = SMTP (E-mail)

Page 7: Transport Protocols  - TCP & UDP

常見 TCP/IP應用服務與埠號

21 FTP23 Telnet25 SMTP53 DNS79 Finger80 HTTP110 POP3119 NNTP123 NTP

53 DNS67 BOOTP69 TFTP161 SNMP162 SNMP-Trap

TCPTCP UDPUDP

Port: 0~1023 ,網際網路標準專用

Page 8: Transport Protocols  - TCP & UDP

TCP (and UDP) Port Numbers- Client

• Clients Use Ephemeral Port Numbers.

—By IETF rules, Ports 49152 to 65535.

• Windows follows the rules.

• Unix programs usually do not.

—The client chooses a random ephemeral port number for each new connection.

暫時的 短命的

Page 9: Transport Protocols  - TCP & UDP

Range of TCP (and UDP) Port Numbers

• 0~1023—The range for assigned ports managed by the IANA

• 1024~49151—Registered Port Numbers

—For non-major applications.

—Unix does not follow the rule.• Uses some of these port numbers as ephemeral port

numbers.

• 49152~65535—Ephemeral Port Numbers—Dynamic and/or Private Ports

• Port numbers:—http://www.iana.org/assignments/port-numbers

Page 10: Transport Protocols  - TCP & UDP

Socket

• A socket is an IP address, a colon, and a port number.—Example: 128.171.17.13:80

• For servers, specifies a specific application on a specific server.

• For clients, specifies a specific connection on a specific client.

Page 11: Transport Protocols  - TCP & UDP

Use of TCP (and UDP) Port Numbers

Client 60.171.18.22

Webserver1.33.17.13

Port 80

From: 60.171.18.22:50047To: 1.33.17.13:80

SMTP Server123.30.17.120

Port 25

A connection has bothA source and destination socket.

Based on the packet IP addressesand the TCP or UDP port number fields

Ephemeral Source Port Number (50047)

Well-Known DestinationPort Number (80)

Page 12: Transport Protocols  - TCP & UDP

Use of TCP (and UDP) Port Numbers

Client 60.171.18.22

Webserver1.33.17.13

Port 80

From: 60.171.18.22:50047To: 1.33.17.13:80

From: 60.171.18.22:60003To: 123.30.17.120:25

SMTP Server123.30.17.120

Port 25

If a client connects to two servers,it will select different ephemeral port numbers(50047 and 60003) for the two connections

Page 13: Transport Protocols  - TCP & UDP

Sequence & Acknowledge Number

• Sequence Number (SN)—All octets sent within a TCP connection are

numbered sequentially. The number is started from ISN+1.

—The sequence number of the first octet of this segment.

• Acknowledge Number (AN)—If AN = j, all octets through SN= j-1 have been

received successfully.

—Next expected segment will begin from octet j.

ISN: Initial Sequence Number

Page 14: Transport Protocols  - TCP & UDP

Sequence & Acknowledge Number

ClientTransport Process

ServerTransport Process

Data (SN = 7000, length = 1460)

ACK (AN = 8460)

Data (SN=20000, length = 800)

ACK (AN = 20800)

Page 15: Transport Protocols  - TCP & UDP

Data Offset (4 bits)

• Header length• The number of 32-bit words in the TCP

header.• This indicates where the data begins.• The length of the TCP header is always a

multiple of 32 bits.

Page 16: Transport Protocols  - TCP & UDP

Flags (8 bits)

• CWR (Congestion Window Reduced)— To indicate that the sending host received a TCP segment with

ECE set.

• ECE (ECN-Echo)— To indicate that the TCP peer is ECN capable during 3-way

handshake

• URG: Urgent pointer field is significant

• ACK: Acknowledgement field is significant

• PSH: Push function

• RST: Reset the connection

• SYN: Synchronize sequence numbers

• FIN: No more data from sender

Page 17: Transport Protocols  - TCP & UDP

TCP Operations

• TCP Connection— Connection Establishment

• Three-way handshaking

— Data Transfer• Acknowledgement• Retransmission of lost packets• Discarding duplicate packets• Use of Window

— Connection Termination• Four-way handshaking

Page 18: Transport Protocols  - TCP & UDP

Connection Establishment• TCP three-way handshaking

ClientTransport Process

ServerTransport Process

1. SYN i

2. SYN j, ACK i+1

3. ACK j+1

Passive OpenActive Open

i: Client’s initial sequence number (ISN)j: Server’s initial sequence number (ISN)

Page 19: Transport Protocols  - TCP & UDP

Connection Termination• TCP four-way handshaking

ClientTransport Process

ServerTransport Process

1. FIN i

2. ACK i

3. FIN j

4. ACK j

* 2 & 3 can be combined three-way handshaking

Page 20: Transport Protocols  - TCP & UDP
Page 21: Transport Protocols  - TCP & UDP

Relative sequence numberRelative sequence number

Page 22: Transport Protocols  - TCP & UDP

Data Transfer• Acknowledgement

ClientTransport Process

ServerTransport Process

Data (c1)

ACK (of data c1)

Data (s1)

ACK (of data s1)

Page 23: Transport Protocols  - TCP & UDP

Retransmission of lost packets

ClientTransport Process

ServerTransport Process

Data (c1)

Data (c1)

ACK (of data c1)

Data (s1)

ACK (of data s1)

Retransmission Timeout

retransmit

X

Page 24: Transport Protocols  - TCP & UDP

Discarding duplicate packets

ClientTransport Process

ServerTransport Process

Data (c1)

Data (s1)

ACK (of s1)

RetransmissionTimeout ACK (of c1)

Data (c1)retransmit

X

duplicated

Discard it.

Page 25: Transport Protocols  - TCP & UDP

TCP state diagram

Page 26: Transport Protocols  - TCP & UDP

Window• TCP Window Size

—How many more octets it can transmit before getting another acknowledgement.

• Sender receives a TCP segment with AN=i, W=j.— Sender knows that the receiver has received octets before i.

—Sender can send octets i ~ i+j-1.

—Improve the stop-and-wait scheme, in which only one PDU at a time can be in transit.

• Sender receives a TCP segment with W=0.— Cannot send any more octets

— Flow control

Page 27: Transport Protocols  - TCP & UDP

17520 (3718091612 ~ 3718091612+17519)

Page 28: Transport Protocols  - TCP & UDP

3718091612 + 1460 = 3718093072

16060 (3718093072 ~ 3718091612+17519)

Page 29: Transport Protocols  - TCP & UDP

= 3718091612 + 1460

3718093072 + 1460 = 3718094532

13600 (3718094532 ~ 3718091612+17519)

Page 30: Transport Protocols  - TCP & UDP

= 3718093072 + 1460

17520 (3718094532 ~ 3718094532+17519)

Page 31: Transport Protocols  - TCP & UDP
Page 32: Transport Protocols  - TCP & UDP

TCP Options• Maximum segment size

— Included in SYN segment

• Window scale— Included in SYN segment—Window field gives credit allocation in octets—With Window Scale value in Window field multiplied by 2F

• F is the value of window scale option

• Sack-permitted—Selective acknowledgement allowed

• Sack—Receiver can inform sender of all segments received successfully—Sender retransmit segments not received

• Timestamps—Send timestamp in data segment and return echo of that

timestamp in ACK segment

Page 33: Transport Protocols  - TCP & UDP

Transport Protocol Timers

Page 34: Transport Protocols  - TCP & UDP

UDP• User Datagram Protocol (UDP)

—Connectionless—RFC 768

• Connectionless service for application level procedures—Unreliable—Delivery and duplication control not

guaranteed

• Reduced overhead• e.g. network management

Page 35: Transport Protocols  - TCP & UDP

UDP Uses• Inward data collection• Outward data dissemination• Request-Response• Real time application

Page 36: Transport Protocols  - TCP & UDP

UDP Header