data communication networks (graduate level) transport...

17
12/5/2013 1 Department of Computer and IT Engineering University of Kurdistan Data Communication Networks (Graduate level) Transport Layer By: Dr. Alireza Abdollahpouri 2 TCP/IP protocol suite 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 messages into segments, passes to network layer receiving side: reassembles segments into messages, passes to application layer more than one transport protocol available to applications. Internet: TCP and UDP network data link physical Logical end to end transport Transport Layer application transport network data link physical application transport network data link physical 4

Upload: trinhkhanh

Post on 28-May-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

1

Department of Computer and IT Engineering

University of Kurdistan

Data Communication Networks (Graduate level)

Transport Layer

By: Dr. Alireza Abdollahpouri

2

TCP/IP protocol suite

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 messages into segments, passes to network layer

� receiving side: reassembles segments into messages, passes to application layer

� more than one transport protocol available to applications.

� Internet: TCP and UDP

network

data link physical

Logical end to end

transport

Transport Layer

application transport network data link physical

application transport network data link physical

4

Page 2: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

2

Ht

Message

application Ha 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. Process

5

Port numbers

6

IP addresses versus port numbers

7

IANA ranges for port numbers

8

Page 3: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

3

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

Page 4: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

4

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.

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

Page 5: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

5

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 محيطي را فراهم مي آورد كه گويي دو پروسه به وسيله يك لوله فرضي به همديگر متصل شده اند

19

Sending and receiving buffers

TCPدر دو طرف فرستنده و گيرنده يك بافر براي ارسال و دريافت دارد TCPدر دو طرف فرستنده و گيرنده يك بافر براي ارسال و دريافت دارد

20

TCP segments

جرياني از بايتها را در قالب سگمنت ها ارسال مي كند اليه باالتر چيزي در موردسگمنتها و محدوده آنها نميداند

TCPجرياني از بايتها را در قالب سگمنت ها ارسال مي كند اليه باالتر چيزي در موردسگمنتها و محدوده آنها نميداند

1. Write 100 bytes

2. Write 20 bytes 1. Read 40 bytes

2. Read 40 bytes

3. Read 40 bytes

Page 6: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

6

21

The bytes of data being transferred in

each connection are numbered by TCP.

The numbering starts with a randomly

generated number.

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

Solution

The 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 contained

in that segment.

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:

Page 7: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

7

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

Se

q=

00

1

Se

q=

10

01

Se

q=

20

01

Se

q=

30

01

Se

q=

40

01

Se

q=

50

01

Byte

data

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

Data is broken into 6 1000-Byte-segments.

TCP Header

26

27

TCP Header

شماره ترتيب اولين بايتي كه در قسمت داده قرار

دارد

شماره ترتيب بايتي كه منتظر دريافت آن است

20

By

tes

28

TCP Header

4طول هدر بر حسب كلمه بايتي

Page 8: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

8

29

TCP Header

مورد -اندازه پنجره دريافت استفاده در مكانيسم كنترل جريان

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

درون سگمنت معين ميكند

TCP Header - Urgent Data Pointer

• Last byte of urgent data (LBUD) = sequenceNumber + urgentPointer

• First byte of urgent data never explicitly defined

• Any data in Receive buffer up to LBUD may be

considered urgent

urgent data pointer

sequence number

Received byte stream, stored in Receive Buffer

seq. num + urg. ptr = Last Byte of Urgent Data

urgent data

Received TCP segment

non-urgent data

30

31

I

Description of flags in the control field

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

32

Connection establishment using “three-way handshaking”

A SYN segment cannot carry data, but it consumes

one sequence number.

Page 9: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

9

33

A SYN + ACK segment cannot carry

data, but does consume one

sequence number.

Note:

An ACK segment, if carrying no

data, consumes no sequence number.

34

Data transfer

35

Connection termination

The FIN and (FIN+ACK) segments consume one sequence number if

they do not carry data.

36

States for TCP

Page 10: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

10

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

37

TCP flow control and congestion control

38

39

TCP Flow Control

1 2 3 4 5 6 7 8 9 10 11

Advertised window

sent but not

acknowledged can be sent

USABLE

WINDOW

sent and

acknowledged

can't sent

.استفاده ميكند» پنجره لغزان«براي كنترل جريان از مكانيزم 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 = 4

is received

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

TCP Flow Control

گيرنده فرستنده

40

Page 11: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

11

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 = 6

is received

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

TCP Flow Control

41

Sliding Window: Example

3K

2K SeqNo=0

ReceiverBuffer

0 4KSendersends 2K

of data

2K

AckNo=2048 Win=2048

Sendersends 2Kof data 2K SeqNo=2048

4K

AckNo=4096 Win=0

AckNo=4096 Win=1024

Sender b

locked

42

43 44 acknowledged sent to be sent outside window

Source Port Dest. Port

Sequence Number

Acknowledgment

HL/Flags Window

D. Checksum Urgent Pointer

Options…

Source Port Dest. Port

Sequence Number

Acknowledgment

HL/Flags Window

D. Checksum Urgent Pointer

Options...

Segment Sent Segment Received

App write

Window Flow Control: Sender Side

Page 12: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

12

Sliding Window Protocols

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

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

در مورد اين پروتكلها و تحليل كارايي آنها در اليه پيوند داده توضيح داده شده است در مورد اين پروتكلها و تحليل كارايي آنها در اليه پيوند داده توضيح داده شده است

مشابه پروتكلهاي كنترل جريان در اليه پيوند داده

45

� 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

46

Network Conceptual Model

We don’t know when sources will start/end their sessions; also their datarates are variable

Many sources and many receivers …

NetworkNetworkNetworkNetwork

(a)

47

Simplified Network Model

The entire network is abstracted as a single router – “black box”

(b)

Network resources Represented by “Congestion Window Size”

Receiver resources Represented by

“Receive Window Size”

48

Page 13: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

13

49

Router queues

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

اگرنرخ حركت بسته ها در صفهاي خروجي كمتر از نرخ پردازش آنها باشد، .صفهاي خروجي طوالني خواهند شد

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

50

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

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

Queue

Sink Outbound Link Router Inbound Link

Sink

TCP

TCP AQM

TCP in action

Queue

Sink Outbound Link Router Inbound Link

Sink

TCP

TCP

ACK…

ACK…

Queue

Sink Outbound Link Router Inbound Link

Sink

TCP

TCP

ACK…

ACK…

Queue

Sink Outbound Link Router Inbound Link

Sink

TCP

TCP

ACK…

Drop!!!

Queue

Sink Outbound Link Router Inbound Link

Sink

TCP

TCP

Congestion Notification…

ACK…

51 52

Slow start, exponential increase

Page 14: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

14

AAAA BBBBcwnd=cwnd=cwnd=cwnd=1111cwnd=cwnd=cwnd=cwnd=2222cwnd=cwnd=cwnd=cwnd=3333cwnd=cwnd=cwnd=cwnd=4444cwnd=cwnd=cwnd=cwnd=5555cwnd=cwnd=cwnd=cwnd=6666cwnd=cwnd=cwnd=cwnd=8888cwnd=cwnd=cwnd=cwnd=7777cwnd=cwnd=cwnd=cwnd=9999cwnd=cwnd=cwnd=cwnd=16161616SN=SN=SN=SN=1111SN=SN=SN=SN=101101101101A=A=A=A=101101101101SN=SN=SN=SN=201201201201

Slow Start AAAA BBBBcwnd=cwnd=cwnd=cwnd=1111cwnd=cwnd=cwnd=cwnd=2222cwnd=cwnd=cwnd=cwnd=3333cwnd=cwnd=cwnd=cwnd=4444cwnd=cwnd=cwnd=cwnd=5555cwnd=cwnd=cwnd=cwnd=6666cwnd=cwnd=cwnd=cwnd=8888cwnd=cwnd=cwnd=cwnd=7777cwnd=cwnd=cwnd=cwnd=9999cwnd=cwnd=cwnd=cwnd=16161616SN=SN=SN=SN=1111SN=SN=SN=SN=101101101101A=A=A=A=101101101101SN=SN=SN=SN=2012012012012020202015151515

000010101010 1111 2222 3333 44445555....

....

....

....

....

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 AAAA BBBBcwnd=cwnd=cwnd=cwnd=1111cwnd=cwnd=cwnd=cwnd=2222cwnd=cwnd=cwnd=cwnd=3333cwnd=cwnd=cwnd=cwnd=4444cwnd=cwnd=cwnd=cwnd=5555cwnd=cwnd=cwnd=cwnd=6666cwnd=cwnd=cwnd=cwnd=8888cwnd=cwnd=cwnd=cwnd=7777cwnd=cwnd=cwnd=cwnd=9999cwnd=cwnd=cwnd=cwnd=16161616

SN=SN=SN=SN=1111SN=SN=SN=SN=101101101101A=A=A=A=101101101101SN=SN=SN=SN=201201201201AAAA BBBBcwnd=cwnd=cwnd=cwnd=1111cwnd=cwnd=cwnd=cwnd=2222cwnd=cwnd=cwnd=cwnd=3333cwnd=cwnd=cwnd=cwnd=4444cwnd=cwnd=cwnd=cwnd=5555cwnd=cwnd=cwnd=cwnd=6666cwnd=cwnd=cwnd=cwnd=8888cwnd=cwnd=cwnd=cwnd=7777cwnd=cwnd=cwnd=cwnd=9999cwnd=cwnd=cwnd=cwnd=16161616SN=SN=SN=SN=1111SN=SN=SN=SN=101101101101A=A=A=A=101101101101SN=SN=SN=SN=201201201201

53 54

In the slow start algorithm, the size

of the congestion window increases

exponentially until it reaches a

threshold.

Note:

55

Additive increase

56

In the congestion avoidance

algorithm the size of the congestion

window increases additively until

congestion is detected.

Note:

Page 15: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

15

57

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:

58

Congestion Control example

TCP Congestion Control

16

8

4

2

1

sent packets per 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%

59 60

TCP Behavior

W

RTT

1

2

3

4

5

6

7

8

Calculate “average packet loss rate” and “average

throughput”

Page 16: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

16

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

61

TCP timer management

Data link layer Transport layer

62

TCP Round Trip Time and Timeout

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

r typical value: αααα = 0.125 RTT: 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)

RT

T (

mil

lise

co

nd

s)

SampleRTT Estimated RTT

63

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*DevRTT

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

(typically, ββββ = 0.25)

Then set timeout interval:

64

Page 17: Data Communication Networks (Graduate level) Transport Layereng.uok.ac.ir/abdollahpouri/Data_Communication/Lecture6_Transport... · Data Communication Networks (Graduate level) Transport

12/5/2013

17

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

average rate of R/K

TCP connection 1

bottleneck router

capacity R

TCP connection 2

TCP Fairness

65

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 throughput

congestion avoidance: additive increase

loss: decrease window by factor of 2

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

66

67

Questions Questions