1 department of computer and it engineering university of kurdistan computer networks ii transport...

Post on 18-Jan-2016

219 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

Department of Computer and IT EngineeringDepartment of Computer and IT EngineeringUniversity of KurdistanUniversity of Kurdistan

Computer Networks IITransport Layer (UDP and TCP)

By: Dr. Alireza AbdollahpouriBy: Dr. Alireza Abdollahpouri

2

TCP/IP protocol suite

The transport layer is responsible for process-to-process delivery.

The transport layer is responsible for process-to-process delivery.

Transport Layer

3

provide logical communication between application processes running on different hosts

transport protocols run in end systems sending side: breaks app

messagesmessages into segments, passes to network layer

receiving side: reassembles segments into messagesmessages, passes to application layer

more than one transport protocol available to applications. Internet: TCP and UDP

provide logical communication between application processes running on different hosts

transport protocols run in end systems sending side: breaks app

messagesmessages into segments, passes to network layer

receiving side: reassembles segments into messagesmessages, passes to application layer

more than one transport protocol available to applications. Internet: TCP and UDP

networkdata linkphysical

Logical Logical end to end end to end transporttransport

Transport Layer

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

4

Ht

Message

applicationHa Message

transport Ht Ht Ht

network

App. Process decides to send a message to its counterpart

App. Layer adds its header, sends the message to transport layer

Transport layer breaks down the message into several parts,

add its header to each part And makes segments.

It sends one-by-one segments to network layer

Protocol layering and data

App. ProcessApp. ProcessApp. ProcessApp. Process

5

Port numbers

6

IP addresses versus port numbers

7

IANA ranges for port numbers

8

Socket address

9

Multiplexing and demultiplexing

10

11

TCP/IP protocol suite

UDP is a connectionless, unreliable protocol that has no flow and error

control. It uses port numbers to multiplex data from the application

layer.

UDP

12

Some Well-known ports used by UDP

Port Protocol Description

  13 Daytime Returns the date and the time

  17 Quote Returns a quote of the day

  53 Nameserver Domain Name Service

  67 Bootps Server port to download bootstrap information

  68 Bootpc Client port to download bootstrap information

  69 TFTP Trivial File Transfer Protocol

111 RPC Remote Procedure Call

123 NTP Network Time Protocol

161 SNMP Simple Network Management Protocol

13

User datagram format

The calculation of checksum and its inclusion in the user datagram are optional.

The calculation of checksum and its inclusion in the user datagram are optional.

14

Popular Applications That Use UDP

Multimedia streaming Retransmitting lost/corrupted packets is not

worthwhile By the time the packet is retransmitted, it’s too late E.g., telephone calls, video conferencing, gaming

Simple query protocols like Domain Name System Overhead of connection establishment is overkill Easier to have the application retransmit if needed

“Address for www.cnn.com?”

“12.3.4.15”15

16

TCP/IP protocol suite

Transmission Control Protocol (TCP)

Connection oriented Explicit set-up and tear-down of TCP session

Stream-of-bytes service Sends and receives a stream of bytes, not messages

Reliable, in-order delivery Checksums to detect corrupted data Acknowledgments & retransmissions for reliable delivery Sequence numbers to detect losses and reorder data

Flow control Prevent overflow of the receiver’s buffer space

Congestion control Adapt to network congestion for the greater good

17

18

Stream delivery

TCP محیطی را فراهم می آورد که گویی دوپروسه به وسیله یک لوله فرضی به همدیگر

متصل شده اند

TCP محیطی را فراهم می آورد که گویی دوپروسه به وسیله یک لوله فرضی به همدیگر

متصل شده اند

19

Sending and receiving buffers

TCP در دو طرف فرستنده و گیرنده یک بافربرای ارسال و دریافت دارد

TCP در دو طرف فرستنده و گیرنده یک بافربرای ارسال و دریافت دارد

20

TCP segments

TCP جریانی از بایتها را در قالب سگمنت هاارسال می کند

الیه باالتر چیزی در موردسگمنتها و محدوده آنها نمیداند

TCP جریانی از بایتها را در قالب سگمنت هاارسال می کند

الیه باالتر چیزی در موردسگمنتها و محدوده آنها نمیداند

1. Write 100 bytes2. Write 20 bytes

1. Read 40 bytes2. Read 40 bytes3. Read 40 bytes

21

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

generated number.

Note:Note:

22

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 of Byte numbering and sequence numbers

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)

23

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

of the first data byte containedin that segment.

Note:Note:

24

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:

TCP

IP

Applications

23 10480Ports:

TCP

IP

Applications

7 1680 Ports:

A pair <IP address, port number> identifies one endpoint of a connection. Two pairs <client IP address, server port number> and <server IP address, server port number> identify a TCP connection.

49123

TCP connection

25

Seq

=001

Seq

=1001

Seq

=2001

Seq

=3001

Seq

=4001

Seq

=5001

Byte

data

1 2 … 1001 … 2001 … 3001 … 4001 … 5001…

Data is broken into 6 1000-Byte-segments.

TCP Header

26

27

TCP Header

شماره ترتیب اولین بایتی که در قسمت داده قرار

داردشماره ترتیب

بایتی که منتظر دریافت

آن است

20 B

ytes

28

TCP Header

طول هدر بر 4حسب کلمه

بایتی

29

TCP Header

اندازه پنجره دریافت- مورد استفاده در مکانیسم کنترل

جریان

این فیلد به عنوان یک اشاره گر موقعیت داده هاي اضطراری را درون

سگمنت معین میکند

30

II

Description of flags in the control field

برای برقراری و قطع ACK و FINو SYNبیتهای اتصال استفاده می شوند

برای برقراری و قطع ACK و FINو SYNبیتهای اتصال استفاده می شوند

31

Connection establishment using “three-way handshaking”

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

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

32

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

sequence number.

Note:Note:

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

33

Data transfer

34

Connection termination

The FIN and (FIN+ACK) segments consume one sequence number if they do not carry data.

The FIN and (FIN+ACK) segments consume one sequence number if they do not carry data.

35

States for TCP

TCP states

TCP client lifecycle

TCP server lifecycle

Used in case ACK gets lost. It is implementation-dependent (e.g. 30

seconds, 1 minute, 2 minutes

Connection formally closes – all resources (e.g. port numbers) are

released

1

2

3

4

5

6

7

8

9

10

11

12

36

TCP flow control and congestion control

37

38

TCP Flow Control

1 2 3 4 5 6 7 8 9 10 11

Advertised window

sent but notacknowledged can be sent

USABLEWINDOW

sent andacknowledged

can't sent

TCP« پنجره برای کنترل جریان از مکانیزم« استفاده میکند.لغزان

TCP« پنجره برای کنترل جریان از مکانیزم« استفاده میکند.لغزان

1 2 3 4 5 6 7 8 9 10 11

1 2 3 4 5 6 7 8 9 10 11

Transmit Byte 6

1 2 3 4 5 6 7 8 9 10 11

AckNo = 5, Win = 4is received

• Transmission of a single byte (with SeqNo = 6) and acknowledgement is received (AckNo = 5, Win=4):

TCP Flow Control

گیرندهفرستندهSegment

ACK

39

1 2 3 4 5 6 7 8 9 10 11

1 2 3 4 5 6 7 8 9 10 11

AckNo = 5, Win = 6is received

• Acknowledgement is received that enlarges the window to the right (AckNo = 5, Win=6):

TCP Flow Control

40

Sliding Window: Example

3K

ReceiverBuffer

0 4KSendersends 2Kof data

2K

Sendersends 2Kof data

4K

Sender blocked

41

42

43acknowledged sent to be sent outside window

Source PortSource Port Dest. PortDest. Port

Sequence NumberSequence Number

AcknowledgmentAcknowledgment

HL/FlagsHL/Flags WindowWindow

D. ChecksumD. Checksum Urgent PointerUrgent Pointer

Options…Options…

Source PortSource Port Dest. PortDest. Port

Sequence NumberSequence Number

AcknowledgmentAcknowledgment

HL/FlagsHL/Flags WindowWindow

D. ChecksumD. Checksum Urgent PointerUrgent Pointer

Options...Options...

Segment Sent Segment Received

App write

Window Flow Control: Sender Side

Sliding Window Protocols

Go Back nاز بسته خراب شده به بعد مجددا ارسال شوند

Selective Repeatفقط بسته خراب شده مجددا ارسال شود

در مورد این پروتکلها و تحلیل کارایی آنها در درس توضیح داده شده است1شبکه

در مورد این پروتکلها و تحلیل کارایی آنها در درس توضیح داده شده است1شبکه

مشابه پروتکلهای کنترل جریان در الیه پیوند داده

44

TCP limit sending rate as a function of perceived network congestion little traffic – increase sending rate much traffic – reduce sending rate

Congestion algorithm has three major “components”: additive-increase, multiplicative-decrease (AIMD) slow-start reaction to timeout events

TCP Congestion Control

45

46

Router queues

اگرنرخ ورودي بسته ها، از سرعت پردازش بسته ها در داخل مسیریاب بیشتر باشد، صفهاي ورودي

طوالنی خواهند شد. اگرنرخ حرکت بسته ها در صفهاي خروجی کمتر از

نرخ پردازش آنها باشد، صفهاي خروجی طوالنی خواهند شد.

در صورت پر شدن بافر، مسیریاب مجبور به دور ریختن بسته میشود.

47

هنگامی که بار بیش از ظرفیت میگردد، تاخیر به سمت بینهایت میرود. در این حالت بسته ها به مقصد نمیرسند و صفها طوالنی و طوالنیتر خواهند شد. از طرف دیگر، فرستنده بسته ها نیز به دلیل

اینکه پیام تصدیقی از جانب گیرنده دریافت نمیکند، اقدام به ارسال مجدد بسته ها نموده و به بدتر شدن شرایط کمک مینماید.

Queue

SinkOutbound LinkRouterInbound Link

Sink

TCP

TCP AQM

TCP in action

Queue

SinkOutbound LinkRouterInbound Link

Sink

TCP

TCP

ACK…

ACK…

Queue

SinkOutbound LinkRouterInbound Link

Sink

TCP

TCP

ACK…

ACK…

Queue

SinkOutbound LinkRouterInbound Link

Sink

TCP

TCP

ACK…

Drop!!!

Queue

SinkOutbound LinkRouterInbound Link

Sink

TCP

TCP

Congestion Notification…

ACK…

48

49

Slow start, exponential increase

A B

cwnd=1

cwnd=2

cwnd=3cwnd=4

cwnd=5cwnd=6

cwnd=8cwnd=7

cwnd=9

cwnd=16

Slow Start

A B

cwnd=1

cwnd=2

cwnd=3cwnd=4

cwnd=5cwnd=6

cwnd=8cwnd=7

cwnd=9

cwnd=16

20

15

0

10

1 2 3 4

5

...

.

.

CWND/rtt

If CWND is less than or equal to SSTHRESTH : Slow start Slow start dictates that CWND start at one segment, and be

incremented by one segment every time an ACK is received

A B

cwnd=1

cwnd=2

cwnd=3cwnd=4

cwnd=5cwnd=6

cwnd=8cwnd=7

cwnd=9

cwnd=16

A B

cwnd=1

cwnd=2

cwnd=3cwnd=4

cwnd=5cwnd=6

cwnd=8cwnd=7

cwnd=9

cwnd=16

50

51

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

threshold.

Note:Note:

52

Additive increase

53

In the congestion avoidance algorithm the size of the congestion window

increases additively until congestion is detected.

Note:Note:

54

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:

55

Congestion Control example

TCP Congestion Control

16

8

4

2

1

sent packetsper round

(congestion window)

time

40

20

10

5

80

15

30

25

35

75

55

45

50

65

60

70

Losing a single packet (TCP Tahoe): threshold drops to halve CONGESTION WINDOW CONGESTION WINDOW back to 1

Losing a single packet (TCP Reno): threshold drops to halve CONGESTION WINDOW CONGESTION WINDOW back to new threshold

ssthresh

ssthresh

50%

56

57

TCP Behavior

W

RTT

1

2

3

4

5

6

7

8Calculate “average packet

loss rate” and “average throughput”

TCP Round Trip Time and Timeout

Q: how to set TCP timeout value?

longer than RTT but RTT varies

too short: premature timeout unnecessary

retransmissions too long: slow reaction

to segment loss

Q: how to estimate RTT? SampleRTT: measured time from

segment transmission until ACK receipt ignore retransmissions

SampleRTT will vary, want estimated RTT “smoother” average several recent

measurements, not just current SampleRTT

58

TCP Round Trip Time and Timeout

EstimatedRTT = (1- )*EstimatedRTT + *SampleRTTEstimatedRTT = (1- )*EstimatedRTT + *SampleRTT

typical value: = 0.125RTT: gaia.cs.umass.edu to fantasia.eurecom.fr

100

150

200

250

300

350

1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106

time (seconnds)

RTT

(mill

isec

onds

)

SampleRTT Estimated RTT

59

TCP Round Trip Time and Timeout

Setting the timeout EstimatedRTT plus “safety margin”

large variation in EstimatedRTT -> larger safety margin first estimate of how much SampleRTT deviates from EstimatedRTT:

TimeoutInterval = EstimatedRTT + 4*DevRTTTimeoutInterval = EstimatedRTT + 4*DevRTT

DevRTT = (1-)*DevRTT +*|SampleRTT-EstimatedRTT|

(typically, = 0.25)

Then set timeout interval:

60

Fairness goal: if K TCP sessions share same bottleneck link of bandwidth R, each should have average rate of R/K

TCP connection 1

bottleneckrouter

capacity R

TCP connection 2

TCP Fairness

61

Why is TCP fair?

Two competing sessions: Additive increase gives slope of 1, as throughout increases multiplicative decrease decreases throughput proportionally

R

R

equal bandwidth share

Connection 1 throughputCon

necti

on

2 t

hro

ug

hp

ut

congestion avoidance: additive increase

loss: decrease window by factor of 2congestion avoidance: additive

increase

loss: decrease window by factor of 2

62

63QuestionsQuestionsQuestionsQuestions

top related