1 tcp/ip introduction from: tcp/ip 網路管理 craig hunt 著 第一章 綜觀 tcp/ip reference...

63
1 TCP/IP Introduction From: TCP/IP 網網網網 Craig Hunt 網 網 網網 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose, Keith Ross. Addison-Wesley, July 2007.

Post on 21-Dec-2015

242 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

1

TCP/IP Introduction

From: TCP/IP 網路管理 Craig Hunt 著第一章 綜觀 TCP/IP

Reference Book:

Computer Networking: A Top Down Approach. 4th edition. Jim Kurose, Keith Ross. Addison-Wesley, July 2007.

Page 2: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

2

Outlines

TCP/IP Protocol Stack Internet Protocol ( IP ) User Datagram Protocol ( UDP ) Transmission Control Protocol ( TCP )

Page 3: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

3

Part 1

TCP/IP Protocol Stack

Page 4: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

4

TCP/IP Introduction

ARPANET & TCP/IP history Internet v.s. internet

Internet: the world wide network based on ARPANET

internet: a network which is constructed from many small networks and interconnected through IP

Page 5: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

5

Features of TCP/IP

Open protocol standard Hardware independent Operating system independent A great addressing Identical services based on the same

application protocol

Page 6: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

6

TCP/IP Protocol Suite vs. OSI Reference Model

Application Layer

Host-to-host Transport Layer

Internet Layer

Network Access Layer

Page 7: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

7

Layers of TCP/IP

由網路應用程式與相關的處理程序所組成

提供端點對端點完整的資料傳遞服務

定義資料段並掌控資料的傳輸路徑

定義存取實體網路的例行程序

4.Application Layer

3. Host-to-host Transport Layer

2. Internet Layer

1. Network Access Layer

Page 8: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

8

Flow of Data

encapsulation decapsulation

Page 9: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

9

Encapsulation of TCP/IP

header Data

Data

Data

DataReceiveSend

frame

datagram

segment packet

stream message

Encapsulation Decapsulation

Application Layer

Host-to-host Transport Layer

Internet Layer

Network Access Layer

header

header

headerheader

header

TCP UDP

Page 10: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

10

Network Access Layer Include OSI 3 lower layers

For each physical specification, there are some corresponding protocols (drivers) in network access layer.

Main Functions: Encapsulate IP datagram into frame Map IP addresses into physical addresses

The commonest protocols in this layer: RFC894: Interface IP-Ethernet RFC826: Address Resolution Protocol (ARP)

Page 11: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

11

Internet Layer

Provide the addressing and data encapsulation on heterogeneous networks

The commonest protocols in this layer: RFC 791: Internet Protocol (IP) RFC 792: Internet Control Message Protocol

(ICMP)

Page 12: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

12

Routable v.s. Nonroutable

Routable: provide the capability to communicate with hosts in other LANs IP is a routable protocol.

Nonroutable: only communicate with hosts in its own LAN NetBIOS Protocol is nonroutable

Page 13: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

13

Host-to-host Transport Layer

Provide end-to-end data delivery The commonest protocols in this layer:

RFC 768: User Datagram Protocol (UDP) Unreliable, best effort

RFC 793: Transmission Control Protocol (TCP)

Connection-oriented, reliable

Users of host-to-host transport layer should choose TCP or UDP depend on their requirements.

Page 14: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

14

TCP Connection

Page 15: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

15

Application Layer

Define how to use the protocols in the transport layer to deliver data

Page 16: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

16

Some Application Protocols (1/2) telnet: Network Terminal Protocol

Provide the service of remote login FTP: File Transfer Protocol

Transfer files between client and server SMTP: Simple Mail Transfer Protocol

Send email POP3: Post Office Protocol

Retrieve email from mailbox HTTP: Hyper Text Transfer Protocol

Send web pages via Internet

Page 17: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

17

Some Application Protocols (2/2) DNS: Domain Name System

Mapping the domain name and IP addresses OSPF: Open Shortest Path First

A routing protocol for routers NFS: Network File System

Share files among hosts on the net SNMP: Simple Network Management Protocol

Manage the operation of network DHCP: Dynamic Host Configuration Protocol

Allocate dynamic IP addresses 

Page 18: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

18

TCP/IP Architecture

UART Ethernet

RS-232CDriver

EthernetDriver

PPP

IP

ARP RARP

ICMP UDP TCP

PING TFTP DNS Telnet FTP SMTP

Page 19: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

19

Part 2

Internet Protocol (IP)

Page 20: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

20

Internet Protocol (IP) IP provides a basic service of packet

delivery: Define the basic packet unit delivered on

Internet: the format of datagram Define the logical addressing on Internet Put/retrieve data between the network access

layer and the transport layer Determine the route of datagram moving from

source to the destination Perform the segmentation and reassembling of

datagram

Page 21: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

21

Features of IP

Connectionless service IP does not exchange control messages

(handshake) with remote host before sending data.

IP is non-reliable IP provides neither error detection nor

error correction. Variable Length of Datagram Best Effort Delivery

Page 22: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

22

Connection-oriented vs. Connectionless Connection-oriented

Telephone System Users first establishes a connection, uses the

connection and then releases the connection. All of data are received in order.

Connectionless Postal System No connection is established Data is received out of order due to network

delay.

Page 23: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

23

Reliable vs. Unreliable

Reliable: this protocol checks whether packets are received correctly.

Unreliable: this protocol does not check whether packets are received correctly. IP (Internet Protocol) is an unreliable

protocol.

Page 24: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

24

Variable Length of Datagram

IP can take over variable-length data from upper layer.

Thus, it is easy to write upper application programs. The minimum size of data in a datagram is

one byte while the maximum is 64K bytes. IP header contains the information to route

the datagram.

Page 25: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

25

Best-Effort Delivery IP does not deal with the following problems:

Datagram lost Delay or out of order Datagram destruction Duplicate datagram

Because IP works on any physical networks, underlining network may be unreliable and cause IP datagram lost, duplication, delay, out of order or destruction. Upper layer above IP must handle these questions.

Page 26: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

26

The IP Datagram Header Format

Total LengthVersion

Data from upper layer...

Options Padding

Destination IP address

Header ChecksumTime to Live

Source IP address

Protocol

Header Length

Type of Service

FlagsIdentification Fragment Offset

Bit

0 16 314 8 24

1

2

3

4

5

6

Header

Word

Page 27: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

27

IP Header (1/4) Version 4 Header Length

32bits per unit Type of Service (TOS)

Reliability, precedence, delay, throughput Total Length

Length of IP datagram (unit: byte)

Page 28: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

28

IP Header (2/4)

Identification, Flags, and Fragment Offset A datagram can be split into fragments Identification: identify data fragments Flags: indicate the last fragment Offset: show the position of this segment Maximum transfer unit in data link layer

FDDI 4352 bytes 、 Ethernet 1500 bytes 、 x.25 576 bytes 、 PPP 296 bytes

Page 29: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

29

IP Header (3/4)

Time to Live (TTL) max number remaining hops (decremented

at each router) Protocol

Indicate the higher-layer protocol TCP (6), UDP (17)

Header Checksum

Page 30: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

30

IP Header (4/4)

Source and Destination IP Addresses 32-bit address in IPv4

Options E.g. timestamp, record route, taken, specify,

list of routers to visit. Padding Data

Variable length, typically a TCP or UDP segment

Page 31: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

31

IP Datagram Delivery Determine the routing path based on

destination IP address Encapsulation data and send IP datagram

through the network access layer Extract data and send to the transport layer

According to the protocol number in header Send to the correct module in transport layer

The port number in the header of transport layer indicates the application process

Refer to "Data Transfer.ppt"

Page 32: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

32

Internet Control Message Protocol (ICMP)

Use IP to send control messages Common functions:

Flow control Detect unreachable destination redirect the routing path Detect remote host if it is alive

Refer to “ICMP.ppt”

Page 33: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

33

Part 3

User Datagram Protocol (UDP)

Page 34: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

34

UDP (1/2) Pass individual pieces of data from an

application to IP Connectionless

No handshaking between UDP sender & receiver No connection state at sender& receiver No connection establishment (which can add delay) Each UDP segment handled independently of

others No ACK, inherently unreliable

Best Effort, unreliable

Page 35: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

35

UDP (2/2) Simple, high efficiency, small delay

Small segment header No congestion control: UDP can blast away as fast as

desired AP can transmit data in least offer.

Applications A quick, on-shot transmission of data, request/response,

e.g., DNS, SNMP Streaming multimedia: Loss tolerant & rate sensitive, e.g.,

voice

Page 36: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

36

UDP Packet

Length

Message from upper layer

Destination Port

Checksum

Source Port

Bit

0 16 31

Page 37: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

37

UDP Packet Header

Source Port (16bits) Optional

Destination Port (16bits) Length (16bits)

The length (byte) of header+data Checksum

Optional header + pseudo header + data

Data A message from application layer

Page 38: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

38

UDP Pseudoheader

UDP Length0

Destination IP Address

Protocol

Bit

0 16 314 8 24

1

2

3

WordSource IP Address

Page 39: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

39

Identify Used Protocols

Protocol numbers

Port numbers

Page 40: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

40

Part 4

Transmission Control Protocol

(TCP)

Page 41: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

41

TCP (1/2)

Virtual circuit connection Reliable connection creation and closing End-to-end communication

In sequence, without omissions and errors Reliability ( by acknowledge )

End-to-end confirmation, packet retransmission, flow control, congestion control

Full duplex connection Byte stream oriented Applications: HTTP, FTP

Page 42: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

42

TCP (2/2) 以三段式交握( Three-way Handshake )來建立與結束連結( Connection )。

提供端點對端點 (end-to end) 傳輸之間的錯誤偵測與更正功能。 TCP 將上層的 data stream 切割成 segment ,每一個 segment 會配上相對應的一個 segment header ,再送到 IP layer 封裝於一個 packet 中。

以確認重傳( Positive Acknowledgement with Re-transmission , PAR )的方式來提供可靠性。

Page 43: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

43

TCP Segment

Urgent Pointer

Data from upper layer…

Options Padding

Destination Port

Checksum

Window

Source Port

Sequence Number

FlagRes.Offset

Bit0 16 314 8 24

1

2

3

4

5

6

Header

WordAcknowledge Number

Page 44: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

44

The TCP Header (1/5) TCP Port Numbers

Identifying a specific instance of a given application

Well-known port numbers: 0-1023 21: FTP; 23: telnet; 25: SMTP; 80: HTTP

Registered ports: 1024 to 49151 They are assigned by IANA for specific service

A socket pair specifies a unique session. Source address and port number (a socket

address) + Destination address and port number (another socket address)

Page 45: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

45

The TCP Header (2/5) Sequence and acknowledge numbers

Identify individual segments Actually count data octets transmitted A given segment with a Sequence Number of

100 and contains 150 octets of data The ack number will be 250 The Sequence Number of the next segment is 250

Data offset: header length (in 32-bit words)

Receive Window The amount of buffer space available for

receiving data

Page 46: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

46

The TCP Header (3/5)

Urgent Pointer An offset to the first segment after the

urgent data Indicates the length of the urgent data Critical information to be sent to the user

application as soon as possible

Page 47: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

47

The TCP Header (4/5)

Checksum of TCP header, data, and TCP pseudoheader

Option: maximum segment size (MSS) Padding Data

TCP Length0Destination IP AddressProtocol=6

0 16 314 8 241

2

3

Bit

Source IP Address

TCP pseudoheader

Page 48: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

48

The TCP Header (5/5) Control bits

URG: 1 if urgent data is included, use urgent pointer field

Urgent Pointer field significant ACK: 1 for an ACK

Acknowledgement field significant PSH: for the push function RST: reset the connection; an error and

abort a session SYN: Synchronize sequence number; 1 for

the initial messages FIN: Finish; close a session; no more data

Page 49: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

49

Create A TCP ConnectionClient Server

SYN=1Seq = 2000

SYN=1, ACK=1Seq = 4000

ACK # = 2001Window size

ACK=1 Seq = 2001ACK # = 4001 data

Step 1: client host sends TCP SYN segment to server

specifies initial seq # no data

Step 2: server host receives SYN, replies with SYNACK segment

server allocates buffers specifies server initial seq. #

Step 3: client receives SYN/ACK, replies with ACK segment, which may contain data

Page 50: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

50

TCP Slow Start

When a connection begins, increase rate exponentially.

TCP doubles transmission rate every RTT.

Host A

one segment

RTT

Host B

time

two segments

four segments

Page 51: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

51

TCP Flow Control TCP treat data as a continuous byte-stream.

TCP must maintain the order of data bytes. TCP uses a buffer to save the received data.

While creating Connection, two hosts use SYN fields to show their ISN.

Based on Sequence Number, receivers reassemble these byte into origin Stream.

Receivers send ACK. Thus, senders will know the rest buffer size in receivers and know how much data can be sent.

Page 52: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

52

Fields Used for Flow Control (1/2)

序號( Sequence number, SYN ) : 指出該 Segment 的 data content 第一個 byte 是整個 Stream 的第幾個 byte 。

確認號碼( Acknowledge Number, ACK ) : 指出 Receiver 期待下次收到的 byte 的序號。 同時表示確認已收到的此 Acknowledge

number 之前的所有 bytes 。

Page 53: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

53

Fields Used for Flow Control (2/2)

訊窗( Windows ) : 緩衝器( Buffers )所能接收的 byte 數目( Window size )。 控制 Source 所能送出的 Bytes 數目。 Example: Window size=6000 , Sender 最多只能送出 6000 bytes 的資料。

Example: Window size=0 , Sender 必須停止發送封包。

It is a kind of sliding window.

Page 54: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

54

Example 1 for Flow Control

1001 2001 3001 4001 5001 6001 7001

Now, upper AP retrieve 1-2000 bytes from buffer.

Receiver gets 2001-3000 bytes

Window

1001 2001 3001 4001 5001 6001 7001

Window (specifies which streams are want to be received)

Window Slides

1

1

means that TCP has received this block.

ISN=0 ACK=2001, Window=2000

ACK=5001, Window=3000

Page 55: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

55

Example 2 for Flow Control

Page 56: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

56

Traffic Jam Too many sources sending too much

data too fast for network to handle long delays (queueing in router

buffers) lost packets (buffer overflow at

routers)unlimited shared

output link buffers

Host A original data

Host B

receive data

Page 57: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

57

Retransmission in TCP

Positive Acknowledgement with Retransmission (PAR)

Senders retransmit segments if no ACK are received before timeout Timeout (the segment is lost) Checksum error: discard this segment

Page 58: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

58

Message Loss and Retransmission

Set the timeout for retransmission

Page 59: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

59

Adaptive Retransmission Time

Collect and get the mean of round-trip delay. According to the average, Set the timeout of retransmission.

Page 60: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

60

How to Set the Value of Timeout

Page 61: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

61

Congestion Control

After timeout event Slow start (one segment) Window then grows exponentially To a threshold, then grows linearly

Page 62: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

62

Close A TCP ConnectionClient Server

FIN=1Seq = 12500ACK = 7000

FIN=1, ACK=1Seq = 7000

ACK # = 12501

ACK=1Seq = 12501ACK # = 7001

1: client end system sends TCP FIN control segment to server

2: server receives FIN, replies with ACK. Closes connection,

sends FIN. 3: client receives FIN, replies

with ACK. Enters “timed wait” - will respond with ACK to received FINs

4: server, receives ACK. Connection closed.

Page 63: 1 TCP/IP Introduction From: TCP/IP 網路管理 Craig Hunt 著 第一章 綜觀 TCP/IP Reference Book: Computer Networking: A Top Down Approach. 4 th edition. Jim Kurose,

63

Summary You have know the protocols: IP, UDP, TCP

The header format defines the functionality of a protocol. So we should study the header fields for each protocols.

For each AP, to choose UDP or TCP is a good question.

You can study more about the impact of TCP flow control TCP congestion control