IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book:...

32
IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer Networking” – J. Kurose, K. Ross Chapter 3: Transport Layer Chapter 3: Transport Layer Part 2 : Transmissio n Part 2 : Transmissio n Control Protocol (TCP) Control Protocol (TCP)

description

Learning Outcomes 1 Explain the functions of TCP and its connection management scheme 2 Describe the three way handshaking process 3 Differentiate between error control, flow control and congestion control 4 Describe the flow and congestion control in TCP and the slow start mechanism 5 Describe the different fields in TCP packets and explain their roles 6 Describe how to secure TCP connections 3

Transcript of IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book:...

Page 1: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

IT 424Networks2

Ack.: Slides are adapted from the slides of the book: “Computer Networking” – J. Kurose, K. Ross

Chapter 3: Transport Layer

Chapter 3: Transport Layer

Part 2 : Transmission

Part 2 : Transmission

Control Protocol (TCP)

Control Protocol (TCP)

Page 2: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Transp

ort L

ayer

Proto

col -

TCP

TCP Connection M

anagement

TCP Error Control

TCP Flow & Congestion ControlOverview

2

TCP Segment Structure & Security

Page 3: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Learning Outcomes

1Explain the functions of TCP and its connection management scheme

2 Describe the three way handshaking process

3 Differentiate between error control, flow control and congestion control

4 Describe the flow and congestion control in TCP and the slow start mechanism

5 Describe the different fields in TCP packets and explain their roles

6 Describe how to secure TCP connections3

Page 4: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Transp

ort L

ayer

Proto

col -

TCP

TCP Connection M

anagement

TCP Error Control

TCP Flow & Congestion ControlOverview

4

TCP Segment Structure & Security

Page 5: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Reliable, in-order delivery: Transport Control Protocol (TCP)

Unreliable, unordered delivery: User Datagram Protocol (UDP)

Services not available: Delay guarantees Bandwidth guarantees

Recap: Transport-Layer Services in The Internet

Transport Layer Protocols - TCP

applicationtransportnetworkdata linkphysical

logical end-end transport

applicationtransportnetworkdata linkphysical

5

Page 6: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP VS. UDP Functions

•UDP: fragmentation and reassembly, Multiplexing/ Demultiplexing, error-detection using checksum

•TCP: All UDP functionalities + reliable data transfer (connection management, error-control, flow control, congestion control)

Transport Layer Protocols - TCP

6

Page 7: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP creates reliable service on top of unreliable channel

Point-to-point: One sender, one receiver

Reliable, in-order byte stream Error control Flow control Congestion control

TCP: Overview RFCs: 793, 1323, 2581

socketdoor

TC Psend buffer

TC Prece ive buffer

socketdoor

segm ent

applica tionwrites data

applica tionreads data

Full duplex data: Bi-directional data flow in same

connection

Connection-oriented: Handshaking (exchange of control

messages), initiate sender, receiver state before data exchange

Send & receive buffers

Transport Layer Protocols - TCP

7

Page 8: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Transp

ort L

ayer

Proto

col -

TCP

TCP Connection M

anagement

TCP Error Control

TCP Flow & Congestion ControlOverview

8

TCP Segment Structure & Security

Page 9: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP Connection Management

TCP sender, receiver establish “connection” before exchanging data segments

Initialize TCP variables: Seq. #s Buffers, flow control info (e.g. Rcvwindow)

Client: connection initiator

Server: contacted by client

TCP Connection Management

9

Page 10: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

A. Three way handshake:

Step 1: client host initiates by sending 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 SYNACK, replies with ACK segment, which may contain data

TCP Connection Management (cont)

TCP Connection Management

client

SYN

server

SYNACK

ACK

Initiate

Specify seq#

Specify seq #

Allocates Buffer

10

Page 11: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

B. Closing a connection:

Client closes socket:

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

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

Step 3: client receives FIN, replies with ACK, Enters “timed wait”

Step 4: server, receives ACK. Connection closed.

TCP Connection Management (cont)

TCP Connection Management

client

FIN

server

ACK

ACK

FIN

closing

closing

timed

wai

tclosed

11

Page 12: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Transp

ort L

ayer

Proto

col -

TCP

TCP Connection M

anagement

TCP Error Control

TCP Flow & Congestion ControlOverview

12

TCP Segment Structure & Security

Page 13: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP Reliable Data Transfer

Aim: no bit will be received corrupted and no packet will be lost

Approach:

1. Reactive: resend lost or corrupted packet (error control )

2. Proactive: Prevent packet loss at the receiver buffer (flow control) and

at the router buffers (congestion control)

TCP Error Control

13

Page 14: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Error-Control

Aim: no bit will be corrupted and no packet will be lost

Why we need Error-Control? Underlying channel may flip bits in packets (bit-error). Network layer does not

provide a guaranteed service. Packets may be lost if routed to a wrong address or if dropped because of

congestion

Q. How to provide a reliable transmission between end users?

TCP Error Control

14

Page 15: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Error Control Solution

Procedure

o A method for detecting bit errors

o A way for detecting lost packets

o A feedback from the receiver

o Retransmission of lost or corrupted packets

A mechanism that is based on retransmission when detecting an error is called ARQ:

Automatic Repeat reQuest

TCP Error Control

15

Page 16: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

ARQ: Automatic Repeat reQuest

Bit-error detection: e.g. checksum

Packet-loss detection: sequence numbers

Receiver feedback: acknowledgement (ACK) or negative ack. (NAK)

Retransmission: stop-and-wait; or pipelined protocols using sliding window

(Taught previously in Networks_1, please refer to networks_1 slides for more

details)

TCP Error Control - ARQ

16

Page 17: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP creates reliable service on top of IP’s unreliable service

Pipelined segments Cumulative acks Single retransmission timer

Retransmissions triggered by: Timeout events Duplicate acks (fast retransmit)

TCP Error Control

TCP Error Control

lost ACK scenario

Host BHost A

Seq=92, 8 bytes of data

ACK=100

Seq=92, 8 bytes of data

Xtimeo

ut

ACK=10017

Page 18: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP Error Control – Retransmission Scenarios

TCP Error Control

premature timeout

Host BHost A

Seq=92, 8 bytes of data

ACK=100

Seq=92, 8bytes of data

timeo

ut

ACK=120

Seq=100, 20 bytes of data

ACK=120

SendBase=100

SendBase=120

SendBase=120

SendBase=92

X

cumulative ACK

Host BHost A

Seq=92, 8 bytes of data

ACK=100

Seq=120, 15 bytes of datatim

eout

Seq=100, 20 bytes of data

ACK=120

18

Page 19: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Time-out period often relatively long: Long delay before resending lost packet

Detect lost segments via duplicate acks. Sender often sends many segments

back-to-back If segment is lost, there will likely be

many duplicate acks.

TCP Fast Retransmit

TCP Error Control – Fast Retransmit

If sender receives 3 acks for same data (+original)(“Triple duplicate acks”), resend unacked segment with smallest seq #

Likely that unacked segment lost, so don’t wait for timeout

TCP fast retransmit

19

Page 20: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP Error Control – Fast Retransmit

TCP Fast Retransmit

X

fast retransmit after sender receipt of triple duplicate ACK

Host BHost A

Seq=92, 8 bytes of data

ACK=100

timeo

ut

ACK=100

ACK=100

ACK=100

Seq=100, 20 bytes of data

Seq=100, 20 bytes of data

Seq=120, 10 bytes of data

20

Page 21: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Transp

ort L

ayer

Proto

col -

TCP

TCP Connection M

anagement

TCP Error Control

TCP Flow & Congestion ControlOverview

21

TCP Segment Structure & Security

Page 22: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Prevent packet loss at receiver buffer Sender won’t overflow receiver’s buffer by

transmitting too much, too fast Speed-matching service: matching the send

rate to the receiving app’s drain rate

Approach: control number of sent packet

(Sender window) based upon the receiver

buffer

TCP Flow Control

TCP Flow & Congestion Control - Flow Control

receiver side of TCP connection has a receive buffer:

app process may be slow at reading from buffer

22

Page 23: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Receiver send the spare buffer-size to sender Receiver advertises spare room by

including value of RcvWindow in segments

Spare room in buffer= RcvWindow

Sender limits unACKed data to RcvWindow Guarantees receiver buffer doesn’t

overflow

TCP Flow Control: How It Works?

TCP Flow & Congestion Control - Flow Control

23

Page 24: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

The sender window size is controlled by the receiver window (the number of empty bytes in the receiver buffer)

Closing the sender window – if the receiver buffer is totally full; sender should stop

Flow Control: Sender Window Size

Expanding the sender window

Shrinking the sender window

TCP Flow & Congestion Control - Flow Control

24

Page 25: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Congestion Control

Congestion:

Informally: “too many sources sending too much data too fast for network to

handle”

Consequences: Lost packets (buffer overflow at routers) Long delays (queueing in router buffers)

Two approaches:

1.end-to-end

2.network-assisted congestion control

Different from flow control!

TCP Flow & Congestion Control - Congestion Control

25

Page 26: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP Congestion Control

End- to-end congestion control:No explicit feedback from networkCongestion inferred from end-system observed by loss, delay,..Basic idea: ask sender to slow down (or stop altogether) when there is congestion

Procedure Sender notes the receivers advertised window AND a second window is defined, the Congestion Window The sender can send up to the lowest of the two Sender alters the Congestion Window according to the way the network is currently

performing The Congestion Window will keep increasing until segments timeout and then start

reducing

TCP Flow & Congestion Control - Congestion Control

26

Page 27: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

When connection begins, increase rate exponentially until first loss event: Initially cwnd = 1 MSS (maximum

segment size) Double cwnd every RTT Done by incrementing cwnd for every

ACK received

Summary: initial rate is slow but ramps up exponentially fast

TCP Slow Start Mechanism

Host A

one segment

RTT

Host B

time

two segments

four segments

TCP Flow & Congestion Control - Slow Start

27

Page 28: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Transp

ort L

ayer

Proto

col -

TCP

TCP Connection M

anagement

TCP Error Control

TCP Flow & Congestion ControlOverview

28

TCP Segment Structure & Security

Page 29: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

TCP Segment Structure & Security

TCP Segment Structure

29

Page 30: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Securing TCP

TCP & UDP No encryption Clear text passwords sent into

socket traverse Internet in clear text

SSL Provides encrypted TCP

connection Data integrity End-point authentication

SSL is at application layer Applications use SSL libraries,

which “talk” to TCP

SSL socket API Clear text passwords sent into

socket traverse Internet encrypted

TCP Segment Structure & Security

30

Page 31: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

Conclusion

Conclusion

TCP service:

Connection-oriented: setup required between client and server processesError control: between sending and receiving processFlow control: sender won’t overwhelm receiver Congestion control: throttle sender when network overloadedDoes not provide: timing, minimum bandwidth guarantees

UDP service:

Unreliable data transfer between sending and receiving processesDoes not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee

31

Page 32: IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer…

References

References

Computer Networking: A Top-Down Approach Featuring the Internet by James Kurose and Keith Ross, Addison Wesley, 2012 (chapter 3 )

Transmission Control Protocol (RFC793)

TCP Extensions for High Performance (RFC1323)

TCP Congestion Control (RFC2581)

32