Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Transport Layer (TCP)

Similar presentations


Presentation on theme: "The Transport Layer (TCP)"— Presentation transcript:

1 The Transport Layer (TCP)
Lecture 7: The Transport Layer (TCP)

2 Outline TCP connection Reliability Flow control (Loose ends) Security
Congestion control

3 Outline TCP connection Reliability Flow control (Loose ends) Security
Congestion control

4 Bob Alice process process app layer socket socket receive buf.
send buffer transport layer TCP TCP network layer

5 Alice Bob process process socket socket TCP TCP

6 Alice Bob process process socket socket TCP TCP

7 Bob Alice process process socket socket recv. buf. send buf.
TCP TCP

8 What is a TCP connection?
Sockets pass data between app-layer process & TCP Buffers store sent/received data (bidirectional or “full-duplex” communication) Variables will discuss in a moment A set of resources allocated at the end-systems

9 connection established
Alice Bob connection request request acknowledgment ack. of request ack. connection established

10 How is it established? 3-way handshake between end-systems
“client” = the initiating process “server” = the other process (but data may flow both directions)

11 Outline TCP connection Reliability Flow control (Loose ends) Security
Congestion control

12 (connection established)
Alice Bob (connection established) data=byte #1 ACK=2

13 (connection established)
Alice Bob (connection established) SEQ=1, data=bytes #1 to #100 ACK=101

14 X Bob Alice cumulative ACK SEQ=1, data=byte #1 ACK=2

15 SEQ & ACK numbers (TCP payload = sequence of numbered bytes)
Sequence number (SEQ) provided by data sender # of first byte of data Acknowledgment number (ACK) provided by data receiver # of oldest byte expected by receiver (cumulative)

16 Bob Alice Alice’s last ACK=200 Bob’s last SEQ= , ACK= , 10 ACK=10 200
data=”?” data=”!” 11 SEQ= , ACK= , 200 SEQ= , ACK= 11 201 SEQ= , ACK= , 11 201 data=”?”

17 Bob Alice Alice’s last ACK=200 Bob’s last SEQ= , ACK= , 10 ACK=10 200
data=”hello” data=”hey” 15 SEQ= , ACK= , 200 SEQ= , ACK= 15 203 SEQ= , ACK= , 15 203 data=”hello”

18 SEQ & ACK numbers Always present Sequence number Acknowledgment number
even when they are not needed Sequence number # of first byte of data (if no data, pretend there is some) Acknowledgment number # of oldest byte expected by receiver

19 X Bob Alice timeout ignores the data SEQ=1, data=byte #1 ACK=2

20 Bob Alice timeout ignores the data SEQ=1, data=byte #1
ACK=2 ACK=3 timeout SEQ=1, data=byte #1 ignores the data ACK=3

21 Timeout & retransmit Sender times out
segment corrupted, lost or delayed ACK corrupted, lost or delayed Sender retransmits the segment with oldest un-ACKed sequence number

22 Timeout = ? A bit longer than the round-trip time
allow enough time for segment to reach receiver and ACK to reach sender How can the sender predict the RTT?

23 Bob Alice 200 msec sampleRTT = 200 msec 2 sec sampleRTT = 2 sec
SEQ=1, data=byte #1 200 msec ACK=2 sampleRTT = 200 msec SEQ=2, data=byte #2 2 sec ACK=3 sampleRTT = 2 sec

24 Empirical, conservative prediction of RTT
Timeout calculation EstimatedRTT = EstimatedRTT SampleRTT DevRTT = function(RTT variance) Timeout = EstimatedRTT + 4 DevRTT Empirical, conservative prediction of RTT

25 X Bob Alice fast retransmit SEQ=1, data=byte #1 SEQ=2, data=byte #2
ACK=2 SEQ=3, data=byte #3 SEQ=4, data=byte #4 ACK=2 SEQ=5, data=byte #5 ACK=2 ACK=2 fast retransmit SEQ=2, data=byte #2

26 Fast retransmit Sender receives 3 duplicate ACKs
segment lost or delayed Sender retransmits segment with oldest un-ACKed sequence number

27 Retransmission events
Sender times out segment corrupted, lost or delayed ACK corrupted, lost or delayed Sender receives 3 duplicate ACKs

28 Is TCP Go-Back-N or SR? Go-Back-N element Selective Repeat element
receiver sends cumulative ACKs does not ACK individual out-of-order segments Selective Repeat element sender retransmits only one segment (with the oldest un-ACK-ed sequence number) It is a hybrid

29 Outline TCP connection Reliability Flow control (Loose ends) Security
Congestion control

30 Bob Alice process process socket socket receive buf. send buffer
spare room TCP TCP

31 Bob Alice receiver window=100 bytes SEQ=1, data=bytes #1 to #100
ACK=101, receiver window=80 bytes

32 Bob Alice receiver window=4000 bytes SEQ=1, data=bytes #1 to #1500
ACK=4001, receiver window=0 bytes

33 Bob Alice ACK=4001, receiver window=0 bytes SEQ=4001

34 Flow control Receiver provides receiver window
equal to free space in TCP receive buffer specifies how many bytes it can receive Sender sends up to this # of bytes must wait for receiver window to “open” Slows down the sender

35 Outline TCP connection Reliability Flow control (Loose ends) Security
Congestion control

36 Bob Alice SYN=1,SEQ=14527657 SYN segment
SYN=1,SEQ= , ACK= SYNACK segment SYN=0,SEQ= , ACK= , data=...

37 Bob Alice timeout connection closed FIN=1,SEQ=145287942 ACK=145287943

38 Outline TCP connection Reliability Flow control (Loose ends) Security
Congestion control

39 Alice discards Bob’s data
Jack (the hijacker) Alice Bob SEQ=1, ACK=1, data=http GET request SEQ=1,ACK=21,data=evil html file SEQ=1,ACK=21,data=html file Alice discards Bob’s data

40 Jack (the hijacker) Alice Bob
SEQ= , ACK= , data= GET req. SEQ=??,ACK=??,data=evil html file ?? SEQ= , ACK= ,data= html file

41 Make segment content unpredictable
TCP hijacking Attack: impersonate one of the parties & provide fake content Defense: randomize sequence numbers Make segment content unpredictable

42 Denis Bob SYN segment SYN segment SYN segment SYN segment
SYNACK segment

43 Bob Alice process process socket socket SYN from Denis SYN from Denis
incomplete connections incomplete connections SYN from Denis SYN from Denis SYN from Denis SYN from Denis

44 Bob Alice SYN from Alice SYN segment SYNACK segment
non-forgeable ticket non-forgeable ticket

45 Pass the state to the TCP client
SYN flooding Attack: exhaust the SYN buffer Defense: get rid of the SYN buffer instead use non-forgeable ticket Pass the state to the TCP client

46 Outline TCP connection Reliability Flow control (Loose ends) Security
Congestion control

47 Alice’s max throughput is R
bottleneck link transmission rate R Alice Bob Alice’s max throughput is R

48 Alice’s max throughput is R/2
bottleneck link transmission rate R Alice Bob Alice’s max throughput is R/2

49 If Alice’s transport transmits at rate R/2,
bottleneck link transmission rate R Alice Bob If Alice’s transport transmits at rate R/2, she experiences high queuing delay

50 If Alice’s transport transmits at rate R/2,
bottleneck link transmission rate R Alice Bob 4 4 2 3 1 If Alice’s transport transmits at rate R/2, part of that rate is spent on retransmissions, so, her effective throughput is < R/2

51 If Alice times out prematurely, and needlessly (re)transmits packets,
bottleneck link transmission rate R Alice Bob 4 4 If Alice times out prematurely, and needlessly (re)transmits packets, the switch performs useless transmissions

52 The network uses resources to
Alice Bob The network uses resources to transmit packets that will later be dropped

53 Bad congestion effects
Long queuing delays Resource waste sender has to retransmit routers transmit duplicate packets routers transmit packets that will be dropped

54 Congestion-control approaches
At the network layer packet switches signal congestion to end-hosts At the transport layer end-hosts signal congestion to each other

55 Congestion window The number of unacknowledged bytes that the sender may transmit... ... so as to avoid “creating congestion”

56 Alice Bob RTT R bps x RTT sec bandwidth delay product seq# 0 seq# 100
ACK 100 seq# 200 seq# 300 R bps x RTT sec bandwidth delay product

57 Bandwidth-delay product
The max amount of traffic that the sender can transmit until he gets the first ACK = the maximum sender window size

58 X X Alice Bob seq# 0 100 bytes ACK 100 seq# 100 200 bytes seq# 200
timeout! 100 bytes seq# 100

59 Self-clocking Inferring the “right” congestion window based on the ACKs ACK = no congestion, increase window No ACK = congestion, decrease window

60 Alice Bob seq# 0 100 bytes 0 - 99 ACK 100 200 bytes seq# 100 100 - 199
ACK 200 300 bytes ACK 300 400 bytes

61 Alice Bob 100 bytes 200 bytes 300 bytes 400 bytes

62 Alice Bob 100 bytes RTT 200 bytes RTT 300 bytes RTT 400 bytes

63 Increase window size Exponentially by 1 MSS for every ACKed MSS
when we do not expect congestion

64 Alice Bob 400 bytes X timeout! 100 bytes

65 Alice Bob 100 bytes 200 bytes 300 bytes

66 Increase window size Exponentially Linearly
by 1 MSS for every ACKed MSS when we do not expect congestion Linearly by 1 MSS every RTT when we expect congestion

67 X Alice Bob 100 bytes 200 bytes 400 bytes timeout! 100 bytes
threshold = 200

68 Alice Bob 100 bytes 200 bytes 300 bytes threshold = 200

69 Basic algorithm Start with exponential increase
when sender times out, it resets window to MSS sets congestion threshold to last window size / 2 Transition to linear increase, when: window reaches congestion threshold

70 X Alice Bob 400 bytes seq# 500 500 - 599 600 - 699 700 - 799 800 - 899
ACK 500 ACK 500 fast retransmit! ACK 500 seq# 500 500 bytes seq# 900 threshold = 200

71 exponential increase linear increase new ACK new ACK
window = window + MSS window = window + MSS *(MSS/window) window >= threshold exponential increase linear increase timeout threshold = window/2 timeout window = MSS threshold = window/2 retransmit window = MSS retransmit

72 exponential increase linear increase fast recovery
threshold = window/2 new ACK window = window + MSS exponential increase linear increase timeout window = MSS window >= threshold window = window + MSS *(MSS/window) 3 duplicate ACKs retransmit new ACK threshold = window/2 window = threshold + 3 MSS timeout fast retransmit retransmit fast recovery 3 duplicate ACKs duplicate ACK threshold = window/2 window = window + MSS window = threshold + 3 MSS fast retransmit

73 Basic algorithm Start with exponential increase
when sender times out, it resets window to MSS sets congestion threshold to last window size / 2 Transition to linear increase, when: window reaches congestion threshold sender receives 3 duplicate ACKs

74 TCP terminology Exponential increase = slow start
when sender times out, it resets window to MSS sets congestion threshold to last window size / 2 Linear increase = congestion avoidance window reaches congestion threshold sender receives 3 duplicate ACKs


Download ppt "The Transport Layer (TCP)"

Similar presentations


Ads by Google